@somnia-chain/markets-sdk / index / Executor
Interface: Executor
Defined in: packages/sdk/src/executor/types.ts:138
Executes unsigned calls on ONE chain as ONE actor and returns the receipt.
Details
chainIdis the only chain this executor sends on. A call carrying anotherchainIdis refused with InvalidInputError before anything is signed — the guard every built-in executor applies through assertCallsOnChain, and one a custom executor should apply too.actoris the address the pool sees asmsg.sender: the signer for a key or wallet, the session account for a session key, the safe itself for a safe. The writer reads allowances and operator grants for it.executetakes a LIST because a safe can pack several calls into one transaction (an approval and the order it enables). An executor that cannot batch executes the calls in order, each as its own transaction, and STOPS at the first receipt whosestatusis"reverted"or that carries afailure, returning that receipt so the writer throws it — the calls after it are never sent. When every call succeeds it returns the last receipt.
Gotchas
An executor never fetches a receipt it already has: the SDK decodes the
order id and fills from receipt.logs. Return the receipt the send gave
you (Somnia's realtime_sendRawTransaction and somnia_sendSessionTransaction
both return it in the same call).
Example (A custom executor over an app's own account layer)
const executor: Executor = {
chainId: 5031,
actor: safeAddress,
async execute(calls) {
const hash = await myAccountLayer.sendBatch(calls); // your safe, your relayer…
const receipt = await myAccountLayer.waitForReceipt(hash);
return { hash, receipt }; // decoded by the SDK from here
},
};
const trader = exchange.client.createTrader({ executor });
Properties
chainId
readonlychainId:number
Defined in: packages/sdk/src/executor/types.ts:140
The one chain this executor sends on.
actor
readonlyactor:`0x${string}`
Defined in: packages/sdk/src/executor/types.ts:142
The address the chain sees as the caller of every call this executor sends.
signTypedData?
readonlyoptionalsignTypedData?:TypedDataSigner
Defined in: packages/sdk/src/executor/types.ts:163
Present on actors that can sign EIP-712 typed data as themselves.
- Throws RpcError - the signer failed or refused;
causehas the original.
The complete union is ExecutorSignTypedDataError.
Methods
execute()
execute(
calls,options?):Promise<Executed>
Defined in: packages/sdk/src/executor/types.ts:155
Send calls (one transaction where possible) and return the receipt.
- Throws InvalidInputError -
callsis empty or names another chain, or the safe or required MultiSend address has no code. - Throws NotConfiguredError - the Safe code check has no chain transport.
- Throws RpcError - the signer, transport or node failed;
causehas the original. - Throws ContractRevertError - the send surfaced a revert with data before mining.
The complete union is ExecutorExecuteError. A MINED revert is not a
throw: it comes back as a "reverted" receipt for the writer to decode.
Parameters
calls
readonly UnsignedCall[]
options?
Returns
Promise<Executed>