Skip to main content

Class: SubmittedTransaction\<TConfirmation\>

gSwap SDK 2.0.0-rc.4


gSwap SDK 2.0.0-rc.4 / SubmittedTransaction

Class: SubmittedTransaction<TConfirmation>

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

A submitted v2 transaction whose confirmation mode is explicit in the gateway response.

Type Parameters​

TConfirmation​

TConfirmation = AppliedTrade | Position | null

Constructors​

Constructor​

new SubmittedTransaction<TConfirmation>(options): SubmittedTransaction<TConfirmation>

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

Construct a submitted transaction from a successful gateway response.

Parameters​

options​
blockNumber?​

number | null

dexBackendBaseUrl​

string

envelope?​

unknown

httpRequestor​

HttpRequestor

method​

string

mode​

"queued" | "sync"

positionConfirmation?​

(signal) => Promise<PositionConfirmationResult>

requestTimeoutMs?​

number

result​

unknown

transactionId​

string | null

uniqueKey​

string

wire?​

WireOptions

Wire options of the apply-results polls confirm() makes.

Returns​

SubmittedTransaction<TConfirmation>

Example​

const transaction = new SubmittedTransaction({
method: 'RequestTrade', mode: 'queued', uniqueKey: 'swap-1',
transactionId: 'request-tx', result: undefined,
dexBackendBaseUrl: 'https://dex.example', httpRequestor,
});

Properties​

blockNumber​

readonly blockNumber: number | null

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

The block of the transaction, when the answer carried one; otherwise null.


envelope​

readonly envelope: unknown

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

The gateway's whole JSON answer as it came ({ status, message, error, data }), for an app that hands the backend's own envelope to its callers; undefined for a transaction built from a uniqueKey alone.


method​

readonly method: string

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

The chain method that was submitted (RequestTrade, AddLiquidity, ...).


mode​

readonly mode: "queued" | "sync"

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

The gateway's data.mode: 'sync' (executed, result is the chain result) or 'queued'.


result​

readonly result: unknown

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

The synchronous gateway result, or undefined when mode === 'queued'.


status​

readonly status: SubmitStatus

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

What the gateway's answer established: 'executed' for mode: 'sync', 'queued' for mode: 'queued' (accepted, NOT executed: await confirm() for the outcome). A refused answer never becomes a transaction, so there is no 'rejected' here; see classifySubmitEnvelope for classifying a raw envelope.


transactionId​

readonly transactionId: string | null

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

The request transaction id the gateway reported, or null when it gave none.


uniqueKey​

readonly uniqueKey: string

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

The write's durable correlation key: persist it, and confirm from it alone later.

Methods​

confirm()​

confirm(options?): Promise<TConfirmation>

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

Confirm a queued RequestTrade or prove the affected position for a liquidity write.

For RequestTrade, calling this method is required to learn the outcome: the queued acknowledgement proves acceptance, not execution.

Every failure is the write's (it carries uniqueKey, so mayHaveBeenQueued is true): a re-read that cannot succeed is CONFIRMATION_FAILED (a terminal HTTP status) or CONFIRMATION_MALFORMED (an unusable answer); one that may (no answer, a 5xx, 404, 408, 429) is read again until the deadline, then CONFIRMATION_TIMEOUT with the last read error as cause. Confirm the same transaction again; never resubmit the write.

Parameters​

options?​

ConfirmOptions

Returns​

Promise<TConfirmation>

Example​

const applied = await submitted.confirm({ initialDelayMs: 3_000 });