Skip to main content

Class: SubmittedTransaction

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

Type Parameters​

Type ParameterDefault type
TConfirmationAppliedTrade | Position | null

Constructors​

Constructor​

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

Construct a submitted transaction from a successful gateway response.

Parameters​

ParameterTypeDescription
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; }-
options.blockNumber?number | null-
options.dexBackendBaseUrlstring-
options.envelope?unknown-
options.httpRequestorHttpRequestor-
options.methodstring-
options.mode"queued" | "sync"-
options.positionConfirmation?(signal) => Promise<PositionConfirmationResult>-
options.requestTimeoutMs?number-
options.resultunknown-
options.transactionIdstring | null-
options.uniqueKeystring-
options.wire?WireOptionsWire 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​

PropertyModifierTypeDescription
blockNumberreadonlynumber | nullThe block of the transaction, when the answer carried one; otherwise null.
envelopereadonlyunknownThe 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.
methodreadonlystringThe chain method that was submitted (RequestTrade, AddLiquidity, ...).
modereadonly"queued" | "sync"The gateway's data.mode: 'sync' (executed, result is the chain result) or 'queued'.
resultreadonlyunknownThe synchronous gateway result, or undefined when mode === 'queued'.
statusreadonlySubmitStatusWhat 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.
transactionIdreadonlystring | nullThe request transaction id the gateway reported, or null when it gave none.
uniqueKeyreadonlystringThe write's durable correlation key: persist it, and confirm from it alone later.

Methods​

confirm()​

confirm(options?): Promise<TConfirmation>

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​

ParameterType
options?ConfirmOptions

Returns​

Promise<TConfirmation>

Example​

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