Skip to main content

Interface: ChainGatewayOptions

Options for a chain-gateway client.

Properties​

PropertyTypeDescription
answerOfRejection?(error) => RejectedAnswer | undefinedTells the gateway which rejections of YOUR httpRequestor are an HTTP ANSWER, and what the answer was: a requestor built on an HTTP client that rejects every non-2xx (an interceptor that throws on a 4xx, a version wall that throws on a 426) loses the answer the SDK reads errors from. Return { status, body } (the parsed JSON, or the raw text; headers for Retry-After) for such a rejection and the write is handled exactly as if the requestor had resolved that answer: the gateway's own code becomes its catalogued error (DTO_INVALID, RATE_LIMITED, CHAIN_DISPATCH_FAILED, ...), an uncoded body HTTP_ERROR, both carrying the signed uniqueKey and classified by classifyFailure as a write. Return undefined for any other rejection: it reaches the caller unchanged. Used only when submitting a write; isTransportFailure is asked first (no answer proves nothing, so "maybe queued" wins), and a throw from this hook, or a status outside 100-599, means "not an answer". Never throw from it. Example new ChainGateway({ dexBackendBaseUrl, httpRequestor: httpRequestorFromAxios(instance, { rejectOnHttpError: true }), answerOfRejection: (error) => error instanceof GatewayError && error.status !== undefined ? { status: error.status, body: error.data } : undefined, });
chainCallTimeoutMs?numberTimeout of every gateway request in milliseconds (default 30 000); also the per-read timeout of the services built on this gateway and of confirm(). Infinity arms no timer, for an app whose HTTP stack owns request lifetimes.
dexBackendBaseUrlstring-
httpRequestor?HttpRequestor-
isTransportFailure?(error) => booleanTells the gateway which rejections of YOUR httpRequestor mean "no HTTP answer arrived" (the connection failed, was reset or dropped), as opposed to an answer your requestor turned into an error (an interceptor that rejects on a 4xx, a version wall). Used only when submitting a write: a rejection it accepts becomes SUBMISSION_OUTCOME_UNKNOWN with reason: 'transport' (the request may have been queued; the original error is cause), and any other rejection reaches the caller unchanged. The SDK's own TRANSPORT_ERROR (the default fetch requestor, httpRequestorFromAxios) always counts, so this is only for requestors that reject with their own errors. Never throw from it; a throw is treated as "not a transport failure". Example new ChainGateway({ dexBackendBaseUrl, httpRequestor: galaFetch, // a fetch wrapper: its TypeError is the network failing isTransportFailure: (error) => error instanceof TypeError, });
walletAddress?string-
wire?WireOptionsWire format of every request of this gateway and of the services built on it: the headers (userAgent, headers) of reads AND of the POSTs that submit writes, and the query encoding of reads. X-Wallet-Address and X-Shadow always win over a same-named wire.headers entry.