@somnia-chain/markets-sdk


@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

  • chainId is the only chain this executor sends on. A call carrying another chainId is refused with InvalidInputError before anything is signed — the guard every built-in executor applies through assertCallsOnChain, and one a custom executor should apply too.
  • actor is the address the pool sees as msg.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.
  • execute takes 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 whose status is "reverted" or that carries a failure, 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)

ts
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

readonly chainId: number

Defined in: packages/sdk/src/executor/types.ts:140

The one chain this executor sends on.


actor

readonly actor: `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?

readonly optional signTypedData?: 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; cause has 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 - calls is 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; cause has 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?

ExecuteOptions

Returns

Promise<Executed>