Skip to main content

Interface: ChainGatewayOptions

gSwap SDK 2.0.0-rc.4


gSwap SDK 2.0.0-rc.4 / ChainGatewayOptions

Interface: ChainGatewayOptions

Defined in: packages/gswap-sdk/dist/index.d.ts:1511

Options for a chain-gateway client.

Properties​

answerOfRejection?​

optional answerOfRejection?: (error) => RejectedAnswer | undefined

Defined in: packages/gswap-sdk/dist/index.d.ts:1573

Tells 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.

Parameters​

error​

unknown

Returns​

RejectedAnswer | undefined

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?​

optional chainCallTimeoutMs?: number

Defined in: packages/gswap-sdk/dist/index.d.ts:1520

Timeout 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.


dexBackendBaseUrl​

dexBackendBaseUrl: string

Defined in: packages/gswap-sdk/dist/index.d.ts:1512


httpRequestor?​

optional httpRequestor?: HttpRequestor

Defined in: packages/gswap-sdk/dist/index.d.ts:1513


isTransportFailure?​

optional isTransportFailure?: (error) => boolean

Defined in: packages/gswap-sdk/dist/index.d.ts:1546

Tells 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".

Parameters​

error​

unknown

Returns​

boolean

Example​

new ChainGateway({
dexBackendBaseUrl,
httpRequestor: galaFetch, // a fetch wrapper: its TypeError is the network failing
isTransportFailure: (error) => error instanceof TypeError,
});

walletAddress?​

optional walletAddress?: string

Defined in: packages/gswap-sdk/dist/index.d.ts:1514


wire?​

optional wire?: WireOptions

Defined in: packages/gswap-sdk/dist/index.d.ts:1526

Wire 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.