Skip to main content

Function: mayHaveBeenQueued()

gSwap SDK 2.0.0-rc.4


gSwap SDK 2.0.0-rc.4 / mayHaveBeenQueued

Function: mayHaveBeenQueued()

mayHaveBeenQueued(error): boolean

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

True when the failed call was a WRITE that may nevertheless have been queued: its outcome is unknown (classifyFailure(error).outcome === 'unknown': a timeout or broken connection after the request left, an acknowledgement that proves nothing, a gateway 409 or 5xx, a failed confirmation). The app must keep error.uniqueKey and confirm it, and must NOT submit again under a fresh key. Every other outcome (rejected, not_queued, not_sent, invalid_input, transient) proves the write is not pending.

A value the SDK cannot judge (an app requestor's own rejection after the request left) is unknown too, so it is true; handle errors your own code raised BEFORE calling the SDK first. Meant for the catch of a write; a read never has a pending key to keep.

Parameters​

error​

unknown

Returns​

boolean

Example​

try {
await swaps.swap('GALA', 'GUSDC', 3000, { exactIn: '100' });
} catch (error) {
if (mayHaveBeenQueued(error)) keepPendingAndConfirm(error);
}