Skip to main content

Function: isRelayableRefusal()

gSwap SDK 2.0.0-rc.4


gSwap SDK 2.0.0-rc.4 / isRelayableRefusal

Function: isRelayableRefusal()

Call Signature​

isRelayableRefusal(error): error is GSwapSDKError<RelayableCode>

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

True when the error is a gateway refusal whose params.serverMessage an app may relay to the person as the gateway sent it: GATEWAY_REPORTED_ERROR, the gateway bounces (METHOD_NOT_ALLOWED, SIGNATURE_INVALID, SIGNER_MISMATCH, DTO_INVALID, BOUNDS_VIOLATION, SYMBOL_CONFLICT, RATE_LIMITED, GATEWAY_REJECTED) and CHAIN_DISPATCH_FAILED. The app shows serverMessage when it is not empty and its own line when it is; the SDK's English message is never what to show.

It accepts a plain-object view of an SDK error too (FailureView: an app's wrapper with a code), and decides from the code in the same way. It narrows to GSwapSDKError<...> ONLY when called with an SDK error; with an unknown or a view it answers boolean (narrow with isGSwapError first, or read the view's own params).

It is a test on the code alone, so it also holds for CHAIN_DISPATCH_FAILED with HTTP 409 (the uniqueKey was already consumed; classifyFailure says unknown): an app that words that case itself ("already submitted", then confirm the key) checks error.status === 409 BEFORE relaying. It is false for CHAIN_REJECTED (the chain's verdict, worded by where it is shown: the submit and confirm screens differ), for HTTP_ERROR (a proxy's page, not an answer to this write) and for the five unproven acknowledgements (isUnprovenAcknowledgement: they carry no server text).

Parameters​

error​

GSwapSDKError

Returns​

error is GSwapSDKError<RelayableCode>

Example​

if (isRelayableRefusal(error)) show(error.params.serverMessage || t('swap.requestFailed'));

Call Signature​

isRelayableRefusal(error): boolean

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

True when the error is a gateway refusal whose params.serverMessage an app may relay to the person as the gateway sent it: GATEWAY_REPORTED_ERROR, the gateway bounces (METHOD_NOT_ALLOWED, SIGNATURE_INVALID, SIGNER_MISMATCH, DTO_INVALID, BOUNDS_VIOLATION, SYMBOL_CONFLICT, RATE_LIMITED, GATEWAY_REJECTED) and CHAIN_DISPATCH_FAILED. The app shows serverMessage when it is not empty and its own line when it is; the SDK's English message is never what to show.

It accepts a plain-object view of an SDK error too (FailureView: an app's wrapper with a code), and decides from the code in the same way. It narrows to GSwapSDKError<...> ONLY when called with an SDK error; with an unknown or a view it answers boolean (narrow with isGSwapError first, or read the view's own params).

It is a test on the code alone, so it also holds for CHAIN_DISPATCH_FAILED with HTTP 409 (the uniqueKey was already consumed; classifyFailure says unknown): an app that words that case itself ("already submitted", then confirm the key) checks error.status === 409 BEFORE relaying. It is false for CHAIN_REJECTED (the chain's verdict, worded by where it is shown: the submit and confirm screens differ), for HTTP_ERROR (a proxy's page, not an answer to this write) and for the five unproven acknowledgements (isUnprovenAcknowledgement: they carry no server text).

Parameters​

error​

unknown

Returns​

boolean

Example​

if (isRelayableRefusal(error)) show(error.params.serverMessage || t('swap.requestFailed'));