Class: ChainGateway
Thin client for backend-routed v2 writes: synchronous liquidity writes and queued RequestTrade.
Constructors
Constructor
new ChainGateway(
options):ChainGateway
Create a chain gateway client.
Parameters
| Parameter | Type |
|---|---|
options | ChainGatewayOptions |
Returns
ChainGateway
chain gateway options
Properties
dex backend base url request timeout ms wire options
Accessors
httpRequestor
Get Signature
get httpRequestor():
HttpRequestor
Expose the requestor for sibling read services that share this gateway transport.
Returns
HttpRequestor
http requestor
Methods
submit()
Call Signature
submit(
method,signedBody,options?):Promise<SubmittedTransaction<AppliedTrade>>
Submit a signed v2 DTO through the chain gateway.
Parameters
| Parameter | Type |
|---|---|
method | "RequestTrade" |
signedBody | Record<string, unknown> |
options? | ChainSubmitOptions |
Returns
Promise<SubmittedTransaction<AppliedTrade>>
Throws
GSwapSDKError SUBMISSION_OUTCOME_UNKNOWN when no answer was read: params.reason is
'timeout' (the POST exceeded chainCallTimeoutMs) or 'transport' (the connection failed
or broke off). Either way the write MAY have been queued: keep error.uniqueKey and confirm
it. Whether to offer the user a Retry (a NEW request under a fresh key) is the app's policy;
the SDK states only that the outcome is unknown. Reads keep TRANSPORT_ERROR.
Call Signature
submit(
method,signedBody,options?):Promise<SubmittedTransaction<Position|null>>
Submit a signed v2 DTO through the chain gateway.
Parameters
| Parameter | Type |
|---|---|
method | string |
signedBody | Record<string, unknown> |
options? | ChainSubmitOptions |
Returns
Promise<SubmittedTransaction<Position | null>>
Throws
GSwapSDKError SUBMISSION_OUTCOME_UNKNOWN when no answer was read: params.reason is
'timeout' (the POST exceeded chainCallTimeoutMs) or 'transport' (the connection failed
or broke off). Either way the write MAY have been queued: keep error.uniqueKey and confirm
it. Whether to offer the user a Retry (a NEW request under a fresh key) is the app's policy;
the SDK states only that the outcome is unknown. Reads keep TRANSPORT_ERROR.
signed body submitted transaction applied trade request chain submit options submission outcome unknown call timeout ms unique key transport error
submitShadow()
submitShadow(
method,signedBody,options?):Promise<ShadowSubmitResult>
Submit a signed v2 DTO as a SHADOW (dark) write: the same route and body as submit,
plus X-Wallet-Address and X-Shadow: true, so the swap backend marks the transaction private
before it reaches the contract. The wallet address is required (the backend resolves the
owner from it).
Unlike submit, EVERY HTTP status resolves: the result is the raw { httpStatus, body },
because shadow failures are classified from the status together with the body's code
(SHADOW_UNAVAILABLE, SHADOW_UNSUPPORTED_TYPE, SHADOW_RELAY_REJECTED);
see readShadowSubmitOutcome. Only a failure to get an answer rejects, and it rejects with
SUBMISSION_OUTCOME_UNKNOWN (params.reason 'timeout' or 'transport'): the request may
have been accepted. Every error it throws has error.shadow === true, and a non-SDK object
that escapes (your requestor's own rejection) answers isShadowError(error).
Parameters
| Parameter | Type |
|---|---|
method | string |
signedBody | Record<string, unknown> |
options? | ChainSubmitOptions |
Returns
Promise<ShadowSubmitResult>
Example
const result = await gateway.submitShadow('RequestTrade', signedDto, { walletAddress });
const outcome = readShadowSubmitOutcome('RequestTrade', signedDto, result);
submit shadow signed body result http status unavailable unsupported type relay rejected read outcome submission unknown is error chain options