@somnia-chain/markets-sdk / index / RpcError
Class: RpcError
Defined in: packages/sdk/src/errors.ts:399
A JSON-RPC / WebSocket request to the node did not complete, or the node refused a transaction.
Details
For a read, the request produced no chain answer (connection refused, timeout, unsupported method, subscription dropped). For a write, the node can also have answered with a refusal (nonce too low, insufficient funds).
Gotchas
A call that did reach the chain and was rejected by a contract is a ContractRevertError instead. Check for that first when branching.
A write whose signed transaction may already be on the node throws the subclass TransactionOutcomeUnknownError. Test for it before this class: sending that write again can execute it twice.
From the local-signer and session-key executors, a plain RpcError means
the node refused the transaction or nothing was sent. Other writes do not
guarantee this: a wallet client can fail after it broadcast, and admin,
lend and bridge writes do not make the distinction yet. After one of those
throws RpcError, check the chain before you send again.
Extends
Extended by
Constructors
Constructor
new RpcError(
operation,detail,options?):RpcError
Defined in: packages/sdk/src/errors.ts:421
Creates an RPC error with operation context and an optional cause.
Details
operation: What was attempted (e.g."eth_sendRawTransaction","watchBook").detail: Why it failed.options: Standardcausepassthrough — the underlying viem/transport error — pluschainIdwhen the failing chain is known.
Parameters
operation
string
detail
string
options?
ErrorOptions & object
Returns
RpcError
Overrides
SomniaMarketsError.constructor
Properties
chainId?
readonlyoptionalchainId?:number
Defined in: packages/sdk/src/errors.ts:410
The chain whose read failed. Set only on an exchange with two or more
chains, in two cases. The account reads of SomniaMarkets
(fetchBalance, fetchOpenOrders, fetchOrders, getOrdersPage,
getOrderHistoryPage, fetchMyTrades, fetchPositions,
fetchOpenStopOrders, watchUser) set it when the read spans more than
one chain, or when the read has no market and no chain filter, also if it
then touches only one chain. fetchDataStatus sets it on the error it
throws when every chain fails. Absent on every other RPC error.
operation
readonlyoperation:string
Defined in: packages/sdk/src/errors.ts:422