@somnia-chain/markets-sdk / index / Executor
Interface: Executor
Defined in: packages/sdk/src/executor/types.ts:160
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 (eth_sendRawTransactionSync 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:162
The one chain this executor sends on.
actor
readonlyactor:`0x${string}`
Defined in: packages/sdk/src/executor/types.ts:164
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:198
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:190
Send calls (one transaction where possible) and return the receipt.
- Throws InvalidInputError -
callsis empty or names another chain, the accounts SDK refuses a smart account's input, or a session send has no positive gas limit. - Throws NotConfiguredError - a chain read the executor needs has no chain transport.
- Throws RpcError - the signer, transport or node failed, or the
node refused the transaction;
causehas the original. From the local-signer and session-key executors, nothing was sent or the node refused it. A wallet can fail after it broadcast. - Throws TransactionOutcomeUnknownError - a signed transaction may
have reached the node and its receipt was not observed.
hashnames it (absent for a session send). Look it up before sending again. - 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.
Retry rule. Never send a write again after a
TransactionOutcomeUnknownError until you know what happened to hash.
Read its receipt, or read the state the write changes. A blind retry can
execute the write twice.
Parameters
calls
readonly UnsignedCall[]
options?
Returns
Promise<Executed>