@gala-chain/gswap-sdk 2.1.0-beta.0 → 2.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/browser/classes/gswap_error_catalog.js +1 -1
- package/dist/browser/classes/gswap_error_catalog.js.map +1 -1
- package/dist/browser/classes/gswap_error_phase_table.js +1 -1
- package/dist/browser/classes/gswap_error_phase_table.js.map +1 -1
- package/dist/browser/classes/gswap_sdk_error.js +1 -1
- package/dist/browser/classes/gswap_sdk_error.js.map +1 -1
- package/dist/browser/utils/failure_classification.js +1 -1
- package/dist/browser/utils/failure_classification.js.map +1 -1
- package/dist/browser/utils/failure_guards.js +1 -1
- package/dist/browser/utils/failure_guards.js.map +1 -1
- package/dist/index.cjs +10 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.mjs +10 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -21,6 +21,12 @@ a `SubmittedTransaction`. Swap acknowledgements are queued; call `confirm()` to
|
|
|
21
21
|
read the applied trade or chain rejection. There is no bundler or socket
|
|
22
22
|
waiter, and EIP-712 is only an opt-in scheme of `BrowserWalletSigner`.
|
|
23
23
|
|
|
24
|
+
Every signed DTO carries the `dtoOperation` of its call
|
|
25
|
+
(`asset-channel_basic-asset_GalaChainDex:<Method>`): the chain refuses a DTO without it or with
|
|
26
|
+
another call's, and it is part of what is signed. The SDK sets it before signing, from the same
|
|
27
|
+
table that builds the route; a DTO you sign yourself must set it first (core's `withDtoOperation`).
|
|
28
|
+
See [Signing and Identity](./docs/other/signing-and-identity.md).
|
|
29
|
+
|
|
24
30
|
## Install
|
|
25
31
|
|
|
26
32
|
```bash
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{GALA_ERROR_CATALOG as e}from"@gala-chain/gala-core-sdk";const t=[`timeout`,`transport`],n=`0,500,3000,10000`,r={HTTP_ERROR:{phase:`post_send`,template:`Unexpected HTTP error {status} from {url}.`,params:{status:`number`,url:`string`,serverMessage:`string`},unrendered:[`serverMessage`]},UPDATE_REQUIRED:{phase:`post_send`,template:`The backend refused this app version and requires an update (HTTP {status}); nothing was queued.`,params:{status:`number`}},REQUEST_FAILED:{phase:`in_flight`,template:`The {operation} request failed.`,params:{operation:`string`}},METHOD_NOT_SUPPORTED:{phase:`pre_send`,template:`The method {method} is not supported; swaps are queued through RequestTrade.`,params:{method:`string`}},SUBMISSION_OUTCOME_UNKNOWN:{phase:`in_flight`,template:`The submission outcome is unknown ({reason}): the request may have reached the gateway. Confirm before retrying.`,params:{reason:t}},GATEWAY_REPORTED_ERROR:{phase:`post_send`,template:`The gateway reported an error for this write: {serverMessage}`,params:{serverMessage:`string`}},GATEWAY_DATA_MISSING:{phase:`post_send`,template:`The gateway response is missing its data object.`,params:{}},GATEWAY_MODE_INVALID:{phase:`post_send`,template:`Gateway response must contain data.mode="sync" with data.result, or data.mode="queued".`,params:{}},GATEWAY_SYNC_REQUEST_TRADE:{phase:`post_send`,template:`The gateway executed RequestTrade synchronously, which this SDK refuses; RequestTrade must be queued.`,params:{}},MISSING_UNIQUE_KEY:{phase:`post_send`,template:`The gateway acknowledged RequestTrade without echoing its uniqueKey, so it cannot be tied to the signed request.`,params:{}},UNIQUE_KEY_MISMATCH:{phase:`post_send`,template:`Gateway response data.uniqueKey must match the signed RequestTrade uniqueKey.`,params:{}},SHADOW_NOT_QUEUED:{phase:`post_send`,template:`The swap backend did not queue the shadow request.`,params:{}},SHADOW_SUBMIT_NEEDS_WALLET_ADDRESS:{phase:`pre_send`,template:`A shadow submission needs a walletAddress (the X-Wallet-Address header): pass one to the GSwap constructor or to this call.`,params:{}},METHOD_NOT_ALLOWED:{phase:`post_send`,template:`The gateway does not expose this contract method: {serverMessage}`,params:{serverMessage:`string`}},SIGNATURE_INVALID:{phase:`post_send`,template:`The gateway could not verify the signature: {serverMessage}`,params:{serverMessage:`string`}},SIGNER_MISMATCH:{phase:`post_send`,template:`The recovered signer does not match an actor named by the operation: {serverMessage}`,params:{serverMessage:`string`}},DTO_INVALID:{phase:`post_send`,template:`The gateway rejected the DTO shape: {serverMessage}`,params:{serverMessage:`string`}},BOUNDS_VIOLATION:{phase:`post_send`,template:`The gateway rejected a numeric, tick, symbol or range bound: {serverMessage}`,params:{serverMessage:`string`}},SYMBOL_CONFLICT:{phase:`post_send`,template:`The CreatePool symbol is already owned by another class: {serverMessage}`,params:{serverMessage:`string`}},RATE_LIMITED:{phase:`post_send`,template:`The gateway rate-limited this signer: {serverMessage}`,params:{serverMessage:`string`}},CHAIN_DISPATCH_FAILED:{phase:`post_send`,template:`The chain dispatch failed (chain error key "{errorKey}"): {serverMessage}`,params:{errorKey:`string`,serverMessage:`string`}},GATEWAY_REJECTED:{phase:`post_send`,template:`Gateway rejected {gatewayCode}: {serverMessage}`,params:{gatewayCode:`string`,serverMessage:`string`}},CHAIN_REJECTED:{phase:`post_send`,template:`GalaChain error {errorKey}: {serverMessage}`,params:{errorKey:`string`,serverMessage:`string`}},INVALID_CHAIN_RESPONSE:{phase:`post_send`,template:`Backend returned an invalid {resource}.`,params:{resource:`string`}},INVALID_POSITION_RESPONSE:{phase:`post_send`,template:`Backend returned an invalid position ({reason}).`,params:{reason:`string`}},CONFIRMATION_TIMEOUT:{phase:`post_send`,template:`Transaction confirmation timed out; the trade may still apply. Confirm the same uniqueKey again later instead of resubmitting.`,params:{}},CONFIRMATION_ABORTED:{phase:`post_send`,template:`Transaction confirmation was aborted.`,params:{}},CONFIRMATION_FAILED:{phase:`post_send`,template:`Transaction confirmation failed with HTTP {status}.`,params:{status:`number`,serverMessage:`string`},unrendered:[`serverMessage`]},CONFIRMATION_MALFORMED:{phase:`post_send`,template:`Transaction confirmation returned a malformed body.`,params:{}},CONFIRMATION_KEY_MISMATCH:{phase:`post_send`,template:`Apply result key did not match the requested key.`,params:{}},NO_SIGNER:{phase:`pre_send`,template:`This method requires a signer. Please provide a signer to the GSwap constructor.`,params:{}},NO_WALLET_ADDRESS:{phase:`post_send`,template:`Cannot confirm this write: no walletAddress was provided to the GSwap constructor, so the resulting position cannot be looked up to confirm it landed on chain.`,params:{}},NO_POOL_AVAILABLE:{phase:`post_send`,template:`No pool is available for {tokenIn}/{tokenOut} (fee tier {fee}).`,params:{tokenIn:`string`,tokenOut:`string`,fee:`string`}},INSUFFICIENT_LIQUIDITY:{phase:`post_send`,template:`The selected pool has insufficient liquidity for {tokenIn}/{tokenOut} (fee tier {fee}).`,params:{tokenIn:`string`,tokenOut:`string`,fee:`string`}},UNKNOWN_TOKEN:{phase:`pre_send`,template:`Token {token} is not registered on the DEX contract: it has no trading symbol.`,params:{token:`string`}},SYMBOL_NOT_FOUND:{phase:`pre_send`,template:`Token {token} could not be resolved to a trading symbol.`,params:{token:`string`}},STREAM_API_KEY_UNUSABLE:{phase:`pre_send`,template:`GdexStreamConfig.apiKey needs a non-empty key and an explicit webSocketImpl that accepts upgrade headers as its third argument (the "ws" package, or React Native). A browser WebSocket cannot send x-api-key, so the key would be silently dropped.`,params:{}},STREAM_WEBSOCKET_UNAVAILABLE:{phase:`pre_send`,template:`GdexStreamService requires a standards-compatible WebSocket constructor. Node.js versions before 22 must provide one with config.webSocketImpl (for example, from the "ws" package).`,params:{}},STREAM_NOT_CONNECTED:{phase:`pre_send`,template:`GDEX stream is not connected. Call connect() first.`,params:{}},STREAM_DISCONNECTED:{phase:`in_flight`,template:`GDEX stream disconnected.`,params:{}},STREAM_REQUEST_TIMEOUT:{phase:`in_flight`,template:`GDEX request "{method}" timed out after {timeoutMs} ms.`,params:{method:`string`,timeoutMs:`number`}},STREAM_CONNECT_FAILED:{phase:`in_flight`,template:`Failed to connect to GDEX stream at {url}.`,params:{url:`string`}},STREAM_CLOSED_BEFORE_CONNECT:{phase:`in_flight`,template:`GDEX stream closed before connecting (code {closeCode}).`,params:{closeCode:`number`}},STREAM_CONNECTION_CLOSED:{phase:`in_flight`,template:`GDEX stream connection closed (code {closeCode}).`,params:{closeCode:`number`}},TOKEN_RESOLUTION_FAILED:{phase:`pre_send`,template:`Token {token} could not be looked up; nothing was sent.`,params:{token:`string`}},MISSING_WALLET_ADDRESS:{phase:`pre_send`,template:`Invalid wallet address: No wallet address provided. Either provide a wallet address to the function you are calling, or set one when instantiating GSwapSDK.`,params:{}},NON_CANONICAL_PAIR:{phase:`pre_send`,template:`The pair {token0}/{token1} is not in canonical order: token0 must sort before token1.`,params:{token0:`string`,token1:`string`}},UNORDERABLE_SYMBOLS:{phase:`pre_send`,template:`Unable to order trading symbols: expected a pair of symbols, got {received}.`,params:{received:`string`}},INVALID_TOKEN_CLASS_KEY:{phase:`pre_send`,template:`Invalid token class key "{tokenClassKey}": expected a collection followed by category, type and additionalKey`,params:{tokenClassKey:`string`}},INCOMPLETE_TOKEN_CLASS_KEY:{phase:`pre_send`,template:`Token class key "{compositeKey}" is missing {part}.`,params:{compositeKey:`string`,part:`string`}},INVALID_TRADING_SYMBOL:{phase:`pre_send`,template:`Invalid trading symbol "{symbol}": must be 1-32 ASCII letters and digits and not a reserved word (Token, Unit, none).`,params:{symbol:`string`}},NO_VALID_TRADING_SYMBOL:{phase:`pre_send`,template:`No valid trading symbol for token class {classKey}: "{displaySymbol}" is not an acceptable symbol and none is registered`,params:{classKey:`string`,displaySymbol:`string`}},TOKEN_SYMBOL_NOT_REGISTERED:{phase:`pre_send`,template:`Token {token} is not registered in the trading-symbol registry yet; pass token0Symbol/token1Symbol (the token class symbol) to propose one. A symbol cannot be derived from a class key.`,params:{token:`string`}},SYMBOL_DISAGREES_WITH_REGISTRY:{phase:`pre_send`,template:`Supplied symbol {suppliedSymbol} for {token} disagrees with the registered trading symbol {registeredSymbol}.`,params:{token:`string`,suppliedSymbol:`string`,registeredSymbol:`string`}},CREATE_POOL_NEEDS_CLASS_KEY:{phase:`pre_send`,template:`createPool needs each token as a class key; {token} is a bare trading symbol, which does not carry one.`,params:{token:`string`}},AMOUNT_IS_JS_NUMBER:{phase:`pre_send`,template:`Invalid {field}: use a decimal string or BigNumber, not a JavaScript number`,params:{field:`string`}},AMOUNT_NOT_FINITE:{phase:`pre_send`,template:`Invalid {field}: must be a finite number (got {value})`,params:{field:`string`,value:`string`}},AMOUNT_NOT_POSITIVE:{phase:`pre_send`,template:`Invalid {field}: must be positive (got {value})`,params:{field:`string`,value:`string`}},AMOUNT_NEGATIVE:{phase:`pre_send`,template:`Invalid {field}: must not be negative (got {value})`,params:{field:`string`,value:`string`}},PRICE_VALUES_IS_JS_NUMBER:{phase:`pre_send`,template:`Invalid price values: use decimal strings or BigNumber values, not JavaScript numbers`,params:{}},INVALID_PRICE_VALUES:{phase:`pre_send`,template:`Invalid price values: all prices must be finite and positive (spot {spotPrice}, lower {lowerPrice}, upper {upperPrice})`,params:{spotPrice:`string`,lowerPrice:`string`,upperPrice:`string`}},INVALID_PRICE_RANGE:{phase:`pre_send`,template:`Invalid price range: lower price {lowerPrice} must be less than or equal to upper price {upperPrice}`,params:{lowerPrice:`string`,upperPrice:`string`}},INVALID_PRICE_BOUNDS:{phase:`pre_send`,template:`Price bounds must be finite and positive (minPrice {minPrice}, maxPrice {maxPrice}).`,params:{minPrice:`string`,maxPrice:`string`}},PRICE_BOUNDS_ORDER:{phase:`pre_send`,template:`minPrice {minPrice} must be less than or equal to maxPrice {maxPrice}.`,params:{minPrice:`string`,maxPrice:`string`}},INVALID_STARTING_PRICE:{phase:`pre_send`,template:`Starting price must be finite and positive (got {value}).`,params:{value:`string`}},INVALID_SQRT_PRICE:{phase:`pre_send`,template:`Cannot invert a non-positive sqrt price ({sqrtPrice}).`,params:{sqrtPrice:`string`}},INVALID_TOKEN_DECIMALS:{phase:`pre_send`,template:`Invalid {field}: must be a non-negative integer (got {value})`,params:{field:`string`,value:`number`}},TICKS_NOT_INTEGERS:{phase:`pre_send`,template:`Invalid tick values: ticks must be integers (got {tickLower} and {tickUpper})`,params:{tickLower:`number`,tickUpper:`number`}},INVALID_TICK_RANGE:{phase:`pre_send`,template:`Invalid tick range: tickLower {tickLower} must be less than tickUpper {tickUpper}`,params:{tickLower:`number`,tickUpper:`number`}},TICKS_OUT_OF_BOUNDS:{phase:`pre_send`,template:`Invalid tick range: ticks {tickLower} and {tickUpper} must be between {minTick} and {maxTick}`,params:{tickLower:`number`,tickUpper:`number`,minTick:`number`,maxTick:`number`}},TICKS_NOT_ALIGNED:{phase:`pre_send`,template:`Ticks {tickLower} and {tickUpper} must be aligned to spacing {spacing}.`,params:{tickLower:`number`,tickUpper:`number`,spacing:`number`}},INVALID_TICK_SPACING:{phase:`pre_send`,template:`Invalid tick spacing: must be a positive integer (got {value})`,params:{value:`number`}},INVALID_FEE:{phase:`pre_send`,template:`Invalid {field}: {value} is not a supported fee tier; must be one of {allowed}.`,params:{field:`string`,value:`number`,allowed:`string`}},EXACT_AMOUNT_REQUIRED:{phase:`pre_send`,template:`{field} is required for this swap.`,params:{field:`string`}},EXACTLY_ONE_OF_REQUIRED:{phase:`pre_send`,template:`Provide exactly one of {first} or {second}.`,params:{first:`string`,second:`string`}},AT_MOST_ONE_OF_ALLOWED:{phase:`pre_send`,template:`Provide at most one of {first} or {second}.`,params:{first:`string`,second:`string`}},POOL_MISMATCH:{phase:`pre_send`,template:`tokenIn {tokenIn} and tokenOut {tokenOut} must be the two tokens of the pinned pool {poolToken0}/{poolToken1}.`,params:{tokenIn:`string`,tokenOut:`string`,poolToken0:`string`,poolToken1:`string`}},INVALID_DTO:{phase:`pre_send`,template:`{method} DTO field {field} is invalid (expected {expected}).`,params:{method:`string`,field:`string`,expected:`string`}},DTO_NOT_CANONICAL:{phase:`pre_send`,template:`The {method} DTO is not in the form the SDK builders produce; build it with the matching build function and submit that.`,params:{method:`string`}},SEARCH_TOO_LONG:{phase:`pre_send`,template:`search must be at most {maxLength} characters (got {length}).`,params:{length:`number`,maxLength:`number`}},INVALID_SORT_BY:{phase:`pre_send`,template:`sortBy "{value}" is not allowed; it must be one of {allowed}.`,params:{value:`string`,allowed:`string`}},INVALID_SORT_ORDER:{phase:`pre_send`,template:`sortOrder "{value}" is not allowed; it must be asc or desc.`,params:{value:`string`}},INVALID_PAGE:{phase:`pre_send`,template:`page must be an integer of at least 1 (got {value}).`,params:{value:`number`}},INVALID_LIMIT:{phase:`pre_send`,template:`limit must be an integer from {min} to {max} (got {value}).`,params:{value:`number`,min:`number`,max:`number`}},INVALID_MARKET_TOKEN:{phase:`pre_send`,template:`A market read names a token by a symbol or class key of 1 to 120 letters, digits and . _ $ + / : | - characters (got "{token}").`,params:{token:`string`}},INVALID_TIMEFRAME:{phase:`pre_send`,template:`timeframe "{value}" is not allowed; it must be one of {allowed}.`,params:{value:`string`,allowed:`string`}},INVALID_SEASON_ID:{phase:`pre_send`,template:`seasonId must be an integer of at least 1 (got {value}).`,params:{value:`string`}},INVALID_POLL_INTERVAL:{phase:`pre_send`,template:`intervalMs must be a finite number of milliseconds of at least 1 (got {value}).`,params:{value:`string`}}},i={...e,...r},a=Object.fromEntries(Object.entries(r).map(([e,t])=>[e,t.template]));export{n as ALLOWED_FEE_TIERS_TEXT,r as GSWAP_ERROR_CATALOG,i as GSWAP_SDK_ERROR_ENTRIES,t as SUBMISSION_OUTCOME_UNKNOWN_REASONS,a as gswapErrorTemplates};
|
|
1
|
+
import{GALA_ERROR_CATALOG as e}from"@gala-chain/gala-core-sdk";const t=[`timeout`,`transport`],n=`0,500,3000,10000`,r={HTTP_ERROR:{phase:`post_send`,template:`Unexpected HTTP error {status} from {url}.`,params:{status:`number`,url:`string`,serverMessage:`string`},unrendered:[`serverMessage`]},UPDATE_REQUIRED:{phase:`post_send`,template:`The backend refused this app version and requires an update (HTTP {status}); nothing was queued.`,params:{status:`number`}},REQUEST_FAILED:{phase:`in_flight`,template:`The {operation} request failed.`,params:{operation:`string`}},METHOD_NOT_SUPPORTED:{phase:`pre_send`,template:`The method {method} is not supported; swaps are queued through RequestTrade.`,params:{method:`string`}},SUBMISSION_OUTCOME_UNKNOWN:{phase:`in_flight`,template:`The submission outcome is unknown ({reason}): the request may have reached the gateway. Confirm before retrying.`,params:{reason:t}},GATEWAY_REPORTED_ERROR:{phase:`post_send`,template:`The gateway reported an error for this write: {serverMessage}`,params:{serverMessage:`string`}},GATEWAY_DATA_MISSING:{phase:`post_send`,template:`The gateway response is missing its data object.`,params:{}},GATEWAY_MODE_INVALID:{phase:`post_send`,template:`Gateway response must contain data.mode="sync" with data.result, or data.mode="queued".`,params:{}},GATEWAY_SYNC_REQUEST_TRADE:{phase:`post_send`,template:`The gateway executed RequestTrade synchronously, which this SDK refuses; RequestTrade must be queued.`,params:{}},MISSING_UNIQUE_KEY:{phase:`post_send`,template:`The gateway acknowledged RequestTrade without echoing its uniqueKey, so it cannot be tied to the signed request.`,params:{}},UNIQUE_KEY_MISMATCH:{phase:`post_send`,template:`Gateway response data.uniqueKey must match the signed RequestTrade uniqueKey.`,params:{}},SHADOW_NOT_QUEUED:{phase:`post_send`,template:`The swap backend did not queue the shadow request.`,params:{}},SHADOW_SUBMIT_NEEDS_WALLET_ADDRESS:{phase:`pre_send`,template:`A shadow submission needs a walletAddress (the X-Wallet-Address header): pass one to the GSwap constructor or to this call.`,params:{}},METHOD_NOT_ALLOWED:{phase:`post_send`,template:`The gateway does not expose this contract method: {serverMessage}`,params:{serverMessage:`string`}},SIGNATURE_INVALID:{phase:`post_send`,template:`The gateway could not verify the signature: {serverMessage}`,params:{serverMessage:`string`}},SIGNER_MISMATCH:{phase:`post_send`,template:`The recovered signer does not match an actor named by the operation: {serverMessage}`,params:{serverMessage:`string`}},DTO_INVALID:{phase:`post_send`,template:`The gateway rejected the DTO shape: {serverMessage}`,params:{serverMessage:`string`}},DTO_OPERATION_MISMATCH:{phase:`post_send`,template:`The signed DTO has no dtoOperation, or one that is not the call it was sent to: {serverMessage}`,params:{serverMessage:`string`}},BOUNDS_VIOLATION:{phase:`post_send`,template:`The gateway rejected a numeric, tick, symbol or range bound: {serverMessage}`,params:{serverMessage:`string`}},SYMBOL_CONFLICT:{phase:`post_send`,template:`The CreatePool symbol is already owned by another class: {serverMessage}`,params:{serverMessage:`string`}},RATE_LIMITED:{phase:`post_send`,template:`The gateway rate-limited this signer: {serverMessage}`,params:{serverMessage:`string`}},CHAIN_DISPATCH_FAILED:{phase:`post_send`,template:`The chain dispatch failed (chain error key "{errorKey}"): {serverMessage}`,params:{errorKey:`string`,serverMessage:`string`}},GATEWAY_REJECTED:{phase:`post_send`,template:`Gateway rejected {gatewayCode}: {serverMessage}`,params:{gatewayCode:`string`,serverMessage:`string`}},CHAIN_REJECTED:{phase:`post_send`,template:`GalaChain error {errorKey}: {serverMessage}`,params:{errorKey:`string`,serverMessage:`string`}},INVALID_CHAIN_RESPONSE:{phase:`post_send`,template:`Backend returned an invalid {resource}.`,params:{resource:`string`}},INVALID_POSITION_RESPONSE:{phase:`post_send`,template:`Backend returned an invalid position ({reason}).`,params:{reason:`string`}},CONFIRMATION_TIMEOUT:{phase:`post_send`,template:`Transaction confirmation timed out; the trade may still apply. Confirm the same uniqueKey again later instead of resubmitting.`,params:{}},CONFIRMATION_ABORTED:{phase:`post_send`,template:`Transaction confirmation was aborted.`,params:{}},CONFIRMATION_FAILED:{phase:`post_send`,template:`Transaction confirmation failed with HTTP {status}.`,params:{status:`number`,serverMessage:`string`},unrendered:[`serverMessage`]},CONFIRMATION_MALFORMED:{phase:`post_send`,template:`Transaction confirmation returned a malformed body.`,params:{}},CONFIRMATION_KEY_MISMATCH:{phase:`post_send`,template:`Apply result key did not match the requested key.`,params:{}},NO_SIGNER:{phase:`pre_send`,template:`This method requires a signer. Please provide a signer to the GSwap constructor.`,params:{}},NO_WALLET_ADDRESS:{phase:`post_send`,template:`Cannot confirm this write: no walletAddress was provided to the GSwap constructor, so the resulting position cannot be looked up to confirm it landed on chain.`,params:{}},NO_POOL_AVAILABLE:{phase:`post_send`,template:`No pool is available for {tokenIn}/{tokenOut} (fee tier {fee}).`,params:{tokenIn:`string`,tokenOut:`string`,fee:`string`}},INSUFFICIENT_LIQUIDITY:{phase:`post_send`,template:`The selected pool has insufficient liquidity for {tokenIn}/{tokenOut} (fee tier {fee}).`,params:{tokenIn:`string`,tokenOut:`string`,fee:`string`}},UNKNOWN_TOKEN:{phase:`pre_send`,template:`Token {token} is not registered on the DEX contract: it has no trading symbol.`,params:{token:`string`}},SYMBOL_NOT_FOUND:{phase:`pre_send`,template:`Token {token} could not be resolved to a trading symbol.`,params:{token:`string`}},STREAM_API_KEY_UNUSABLE:{phase:`pre_send`,template:`GdexStreamConfig.apiKey needs a non-empty key and an explicit webSocketImpl that accepts upgrade headers as its third argument (the "ws" package, or React Native). A browser WebSocket cannot send x-api-key, so the key would be silently dropped.`,params:{}},STREAM_WEBSOCKET_UNAVAILABLE:{phase:`pre_send`,template:`GdexStreamService requires a standards-compatible WebSocket constructor. Node.js versions before 22 must provide one with config.webSocketImpl (for example, from the "ws" package).`,params:{}},STREAM_NOT_CONNECTED:{phase:`pre_send`,template:`GDEX stream is not connected. Call connect() first.`,params:{}},STREAM_DISCONNECTED:{phase:`in_flight`,template:`GDEX stream disconnected.`,params:{}},STREAM_REQUEST_TIMEOUT:{phase:`in_flight`,template:`GDEX request "{method}" timed out after {timeoutMs} ms.`,params:{method:`string`,timeoutMs:`number`}},STREAM_CONNECT_FAILED:{phase:`in_flight`,template:`Failed to connect to GDEX stream at {url}.`,params:{url:`string`}},STREAM_CLOSED_BEFORE_CONNECT:{phase:`in_flight`,template:`GDEX stream closed before connecting (code {closeCode}).`,params:{closeCode:`number`}},STREAM_CONNECTION_CLOSED:{phase:`in_flight`,template:`GDEX stream connection closed (code {closeCode}).`,params:{closeCode:`number`}},TOKEN_RESOLUTION_FAILED:{phase:`pre_send`,template:`Token {token} could not be looked up; nothing was sent.`,params:{token:`string`}},MISSING_WALLET_ADDRESS:{phase:`pre_send`,template:`Invalid wallet address: No wallet address provided. Either provide a wallet address to the function you are calling, or set one when instantiating GSwapSDK.`,params:{}},NON_CANONICAL_PAIR:{phase:`pre_send`,template:`The pair {token0}/{token1} is not in canonical order: token0 must sort before token1.`,params:{token0:`string`,token1:`string`}},UNORDERABLE_SYMBOLS:{phase:`pre_send`,template:`Unable to order trading symbols: expected a pair of symbols, got {received}.`,params:{received:`string`}},INVALID_TOKEN_CLASS_KEY:{phase:`pre_send`,template:`Invalid token class key "{tokenClassKey}": expected a collection followed by category, type and additionalKey`,params:{tokenClassKey:`string`}},INCOMPLETE_TOKEN_CLASS_KEY:{phase:`pre_send`,template:`Token class key "{compositeKey}" is missing {part}.`,params:{compositeKey:`string`,part:`string`}},INVALID_TRADING_SYMBOL:{phase:`pre_send`,template:`Invalid trading symbol "{symbol}": must be 1-32 ASCII letters and digits and not a reserved word (Token, Unit, none).`,params:{symbol:`string`}},NO_VALID_TRADING_SYMBOL:{phase:`pre_send`,template:`No valid trading symbol for token class {classKey}: "{displaySymbol}" is not an acceptable symbol and none is registered`,params:{classKey:`string`,displaySymbol:`string`}},TOKEN_SYMBOL_NOT_REGISTERED:{phase:`pre_send`,template:`Token {token} is not registered in the trading-symbol registry yet; pass token0Symbol/token1Symbol (the token class symbol) to propose one. A symbol cannot be derived from a class key.`,params:{token:`string`}},SYMBOL_DISAGREES_WITH_REGISTRY:{phase:`pre_send`,template:`Supplied symbol {suppliedSymbol} for {token} disagrees with the registered trading symbol {registeredSymbol}.`,params:{token:`string`,suppliedSymbol:`string`,registeredSymbol:`string`}},CREATE_POOL_NEEDS_CLASS_KEY:{phase:`pre_send`,template:`createPool needs each token as a class key; {token} is a bare trading symbol, which does not carry one.`,params:{token:`string`}},AMOUNT_IS_JS_NUMBER:{phase:`pre_send`,template:`Invalid {field}: use a decimal string or BigNumber, not a JavaScript number`,params:{field:`string`}},AMOUNT_NOT_FINITE:{phase:`pre_send`,template:`Invalid {field}: must be a finite number (got {value})`,params:{field:`string`,value:`string`}},AMOUNT_NOT_POSITIVE:{phase:`pre_send`,template:`Invalid {field}: must be positive (got {value})`,params:{field:`string`,value:`string`}},AMOUNT_NEGATIVE:{phase:`pre_send`,template:`Invalid {field}: must not be negative (got {value})`,params:{field:`string`,value:`string`}},PRICE_VALUES_IS_JS_NUMBER:{phase:`pre_send`,template:`Invalid price values: use decimal strings or BigNumber values, not JavaScript numbers`,params:{}},INVALID_PRICE_VALUES:{phase:`pre_send`,template:`Invalid price values: all prices must be finite and positive (spot {spotPrice}, lower {lowerPrice}, upper {upperPrice})`,params:{spotPrice:`string`,lowerPrice:`string`,upperPrice:`string`}},INVALID_PRICE_RANGE:{phase:`pre_send`,template:`Invalid price range: lower price {lowerPrice} must be less than or equal to upper price {upperPrice}`,params:{lowerPrice:`string`,upperPrice:`string`}},INVALID_PRICE_BOUNDS:{phase:`pre_send`,template:`Price bounds must be finite and positive (minPrice {minPrice}, maxPrice {maxPrice}).`,params:{minPrice:`string`,maxPrice:`string`}},PRICE_BOUNDS_ORDER:{phase:`pre_send`,template:`minPrice {minPrice} must be less than or equal to maxPrice {maxPrice}.`,params:{minPrice:`string`,maxPrice:`string`}},INVALID_STARTING_PRICE:{phase:`pre_send`,template:`Starting price must be finite and positive (got {value}).`,params:{value:`string`}},INVALID_SQRT_PRICE:{phase:`pre_send`,template:`Cannot invert a non-positive sqrt price ({sqrtPrice}).`,params:{sqrtPrice:`string`}},INVALID_TOKEN_DECIMALS:{phase:`pre_send`,template:`Invalid {field}: must be a non-negative integer (got {value})`,params:{field:`string`,value:`number`}},TICKS_NOT_INTEGERS:{phase:`pre_send`,template:`Invalid tick values: ticks must be integers (got {tickLower} and {tickUpper})`,params:{tickLower:`number`,tickUpper:`number`}},INVALID_TICK_RANGE:{phase:`pre_send`,template:`Invalid tick range: tickLower {tickLower} must be less than tickUpper {tickUpper}`,params:{tickLower:`number`,tickUpper:`number`}},TICKS_OUT_OF_BOUNDS:{phase:`pre_send`,template:`Invalid tick range: ticks {tickLower} and {tickUpper} must be between {minTick} and {maxTick}`,params:{tickLower:`number`,tickUpper:`number`,minTick:`number`,maxTick:`number`}},TICKS_NOT_ALIGNED:{phase:`pre_send`,template:`Ticks {tickLower} and {tickUpper} must be aligned to spacing {spacing}.`,params:{tickLower:`number`,tickUpper:`number`,spacing:`number`}},INVALID_TICK_SPACING:{phase:`pre_send`,template:`Invalid tick spacing: must be a positive integer (got {value})`,params:{value:`number`}},INVALID_FEE:{phase:`pre_send`,template:`Invalid {field}: {value} is not a supported fee tier; must be one of {allowed}.`,params:{field:`string`,value:`number`,allowed:`string`}},EXACT_AMOUNT_REQUIRED:{phase:`pre_send`,template:`{field} is required for this swap.`,params:{field:`string`}},EXACTLY_ONE_OF_REQUIRED:{phase:`pre_send`,template:`Provide exactly one of {first} or {second}.`,params:{first:`string`,second:`string`}},AT_MOST_ONE_OF_ALLOWED:{phase:`pre_send`,template:`Provide at most one of {first} or {second}.`,params:{first:`string`,second:`string`}},POOL_MISMATCH:{phase:`pre_send`,template:`tokenIn {tokenIn} and tokenOut {tokenOut} must be the two tokens of the pinned pool {poolToken0}/{poolToken1}.`,params:{tokenIn:`string`,tokenOut:`string`,poolToken0:`string`,poolToken1:`string`}},INVALID_DTO:{phase:`pre_send`,template:`{method} DTO field {field} is invalid (expected {expected}).`,params:{method:`string`,field:`string`,expected:`string`}},DTO_NOT_CANONICAL:{phase:`pre_send`,template:`The {method} DTO is not in the form the SDK builders produce; build it with the matching build function and submit that.`,params:{method:`string`}},SEARCH_TOO_LONG:{phase:`pre_send`,template:`search must be at most {maxLength} characters (got {length}).`,params:{length:`number`,maxLength:`number`}},INVALID_SORT_BY:{phase:`pre_send`,template:`sortBy "{value}" is not allowed; it must be one of {allowed}.`,params:{value:`string`,allowed:`string`}},INVALID_SORT_ORDER:{phase:`pre_send`,template:`sortOrder "{value}" is not allowed; it must be asc or desc.`,params:{value:`string`}},INVALID_PAGE:{phase:`pre_send`,template:`page must be an integer of at least 1 (got {value}).`,params:{value:`number`}},INVALID_LIMIT:{phase:`pre_send`,template:`limit must be an integer from {min} to {max} (got {value}).`,params:{value:`number`,min:`number`,max:`number`}},INVALID_MARKET_TOKEN:{phase:`pre_send`,template:`A market read names a token by a symbol or class key of 1 to 120 letters, digits and . _ $ + / : | - characters (got "{token}").`,params:{token:`string`}},INVALID_TIMEFRAME:{phase:`pre_send`,template:`timeframe "{value}" is not allowed; it must be one of {allowed}.`,params:{value:`string`,allowed:`string`}},INVALID_SEASON_ID:{phase:`pre_send`,template:`seasonId must be an integer of at least 1 (got {value}).`,params:{value:`string`}},INVALID_POLL_INTERVAL:{phase:`pre_send`,template:`intervalMs must be a finite number of milliseconds of at least 1 (got {value}).`,params:{value:`string`}}},i={...e,...r},a=Object.fromEntries(Object.entries(r).map(([e,t])=>[e,t.template]));export{n as ALLOWED_FEE_TIERS_TEXT,r as GSWAP_ERROR_CATALOG,i as GSWAP_SDK_ERROR_ENTRIES,t as SUBMISSION_OUTCOME_UNKNOWN_REASONS,a as gswapErrorTemplates};
|
|
2
2
|
//# sourceMappingURL=gswap_error_catalog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gswap_error_catalog.js","names":["SUBMISSION_OUTCOME_UNKNOWN_REASONS","ALLOWED_FEE_TIERS_TEXT","GSWAP_ERROR_CATALOG","GSWAP_SDK_ERROR_ENTRIES","GALA_ERROR_CATALOG","gswapErrorTemplates","code","entry"],"sources":["../../../src/classes/gswap_error_catalog.ts"],"sourcesContent":["/**\n * The catalog of every error code gswap-sdk ITSELF throws (the DEX codes): the SINGLE source of\n * truth for its `code`, the named parameters it carries and the English template its `message` is\n * generated from. The codes of the signing, transport and wallet layer (`INVALID_PRIVATE_KEY`,\n * `REQUEST_TIMEOUT`, `SIGNING_FAILED`, `TYPED_DATA_*`, ...) live in `@gala-chain/gala-core-sdk`'s\n * `GALA_ERROR_CATALOG`; no code is defined in both. A `GSwapSDKError` can carry a code of either\n * catalog (`GSwapErrorCode` is the union), and reads its template from both.\n *\n * - `code` is the only discriminator. It is stable: apps branch on it, never on message text.\n * - `params` are the named placeholders of the error: a flat object of primitives (string,\n * number, boolean) that an app feeds to its own localization (i18next, ICU, FormatJS).\n * Raw server payloads are never params (they are `error.body` / `error.bodyText`), and no\n * secret (private key, signature, raw DTO) ever is.\n * - `template` is English with `{placeholder}` markers. `error.message` is generated from it\n * and the params, so the two cannot drift. It is for logs and developers: it is not stable and\n * must not be shown to users or matched on.\n *\n * Every placeholder in a template is a declared param and every declared param is a placeholder,\n * except the few `unrendered` params that carry server text for the app and are kept out of\n * `message` on purpose (pinned by tests/error_catalog.test.ts). Facts that are not placeholders (HTTP status, URL,\n * `uniqueKey`, transaction ids, the raw body, the cause) are typed properties of the error, see\n * `GalaErrorContext`.\n */\n\nimport {\n GALA_ERROR_CATALOG,\n type ErrorParamsOf,\n type GalaErrorCatalogEntry,\n type GalaErrorCode,\n} from '@gala-chain/gala-core-sdk';\n\n/**\n * Why the outcome of a write submission is unknown (`SUBMISSION_OUTCOME_UNKNOWN.params.reason`).\n * Both say the same thing about the swap (it MAY have been queued: never resubmit under a fresh\n * key, confirm `error.uniqueKey` instead) and differ only in what happened to the request.\n *\n * - `timeout`: the POST exceeded the gateway's timeout; the request may still be running.\n * - `transport`: the POST failed before an HTTP answer was read (offline, connection reset, DNS,\n * CORS, a body that broke off). The bytes may have reached the server and been queued, so this\n * does NOT prove the swap was not sent.\n */\nexport const SUBMISSION_OUTCOME_UNKNOWN_REASONS = ['timeout', 'transport'] as const;\n\n/** One member of {@link SUBMISSION_OUTCOME_UNKNOWN_REASONS}. */\nexport type SubmissionOutcomeUnknownReason = (typeof SUBMISSION_OUTCOME_UNKNOWN_REASONS)[number];\n\n/** The fee tiers as they appear in `INVALID_FEE.allowed`. */\nexport const ALLOWED_FEE_TIERS_TEXT = '0,500,3000,10000';\n\n/** The whole DEX catalog. Add a code here before throwing it anywhere in gswap-sdk. */\nexport const GSWAP_ERROR_CATALOG = {\n // ---------------------------------------------------------------------------------- transport\n HTTP_ERROR: {\n phase: 'post_send',\n template: 'Unexpected HTTP error {status} from {url}.',\n params: { status: 'number', url: 'string', serverMessage: 'string' },\n unrendered: ['serverMessage'],\n },\n UPDATE_REQUIRED: {\n phase: 'post_send',\n template:\n 'The backend refused this app version and requires an update (HTTP {status}); nothing was queued.',\n params: { status: 'number' },\n },\n REQUEST_FAILED: {\n phase: 'in_flight',\n template: 'The {operation} request failed.',\n params: { operation: 'string' },\n },\n\n // ----------------------------------------------------------------------------------- gateway\n METHOD_NOT_SUPPORTED: {\n phase: 'pre_send',\n template: 'The method {method} is not supported; swaps are queued through RequestTrade.',\n params: { method: 'string' },\n },\n SUBMISSION_OUTCOME_UNKNOWN: {\n phase: 'in_flight',\n template:\n 'The submission outcome is unknown ({reason}): the request may have reached the gateway. Confirm before retrying.',\n params: { reason: SUBMISSION_OUTCOME_UNKNOWN_REASONS },\n },\n GATEWAY_REPORTED_ERROR: {\n phase: 'post_send',\n template: 'The gateway reported an error for this write: {serverMessage}',\n params: { serverMessage: 'string' },\n },\n GATEWAY_DATA_MISSING: {\n phase: 'post_send',\n template: 'The gateway response is missing its data object.',\n params: {},\n },\n GATEWAY_MODE_INVALID: {\n phase: 'post_send',\n template:\n 'Gateway response must contain data.mode=\"sync\" with data.result, or data.mode=\"queued\".',\n params: {},\n },\n GATEWAY_SYNC_REQUEST_TRADE: {\n phase: 'post_send',\n template:\n 'The gateway executed RequestTrade synchronously, which this SDK refuses; RequestTrade must be queued.',\n params: {},\n },\n MISSING_UNIQUE_KEY: {\n phase: 'post_send',\n template:\n 'The gateway acknowledged RequestTrade without echoing its uniqueKey, so it cannot be tied to the signed request.',\n params: {},\n },\n UNIQUE_KEY_MISMATCH: {\n phase: 'post_send',\n template: 'Gateway response data.uniqueKey must match the signed RequestTrade uniqueKey.',\n params: {},\n },\n SHADOW_NOT_QUEUED: {\n phase: 'post_send',\n template: 'The swap backend did not queue the shadow request.',\n params: {},\n },\n SHADOW_SUBMIT_NEEDS_WALLET_ADDRESS: {\n phase: 'pre_send',\n template:\n 'A shadow submission needs a walletAddress (the X-Wallet-Address header): pass one to the GSwap constructor or to this call.',\n params: {},\n },\n METHOD_NOT_ALLOWED: {\n phase: 'post_send',\n template: 'The gateway does not expose this contract method: {serverMessage}',\n params: { serverMessage: 'string' },\n },\n SIGNATURE_INVALID: {\n phase: 'post_send',\n template: 'The gateway could not verify the signature: {serverMessage}',\n params: { serverMessage: 'string' },\n },\n SIGNER_MISMATCH: {\n phase: 'post_send',\n template:\n 'The recovered signer does not match an actor named by the operation: {serverMessage}',\n params: { serverMessage: 'string' },\n },\n DTO_INVALID: {\n phase: 'post_send',\n template: 'The gateway rejected the DTO shape: {serverMessage}',\n params: { serverMessage: 'string' },\n },\n BOUNDS_VIOLATION: {\n phase: 'post_send',\n template: 'The gateway rejected a numeric, tick, symbol or range bound: {serverMessage}',\n params: { serverMessage: 'string' },\n },\n SYMBOL_CONFLICT: {\n phase: 'post_send',\n template: 'The CreatePool symbol is already owned by another class: {serverMessage}',\n params: { serverMessage: 'string' },\n },\n RATE_LIMITED: {\n phase: 'post_send',\n template: 'The gateway rate-limited this signer: {serverMessage}',\n params: { serverMessage: 'string' },\n },\n CHAIN_DISPATCH_FAILED: {\n phase: 'post_send',\n template: 'The chain dispatch failed (chain error key \"{errorKey}\"): {serverMessage}',\n params: { errorKey: 'string', serverMessage: 'string' },\n },\n GATEWAY_REJECTED: {\n phase: 'post_send',\n template: 'Gateway rejected {gatewayCode}: {serverMessage}',\n params: { gatewayCode: 'string', serverMessage: 'string' },\n },\n CHAIN_REJECTED: {\n phase: 'post_send',\n template: 'GalaChain error {errorKey}: {serverMessage}',\n params: { errorKey: 'string', serverMessage: 'string' },\n },\n INVALID_CHAIN_RESPONSE: {\n phase: 'post_send',\n template: 'Backend returned an invalid {resource}.',\n params: { resource: 'string' },\n },\n INVALID_POSITION_RESPONSE: {\n phase: 'post_send',\n template: 'Backend returned an invalid position ({reason}).',\n params: { reason: 'string' },\n },\n\n // -------------------------------------------------------------------------------- confirmation\n CONFIRMATION_TIMEOUT: {\n phase: 'post_send',\n template:\n 'Transaction confirmation timed out; the trade may still apply. Confirm the same uniqueKey again later instead of resubmitting.',\n params: {},\n },\n CONFIRMATION_ABORTED: {\n phase: 'post_send',\n template: 'Transaction confirmation was aborted.',\n params: {},\n },\n CONFIRMATION_FAILED: {\n phase: 'post_send',\n template: 'Transaction confirmation failed with HTTP {status}.',\n params: { status: 'number', serverMessage: 'string' },\n unrendered: ['serverMessage'],\n },\n CONFIRMATION_MALFORMED: {\n phase: 'post_send',\n template: 'Transaction confirmation returned a malformed body.',\n params: {},\n },\n CONFIRMATION_KEY_MISMATCH: {\n phase: 'post_send',\n template: 'Apply result key did not match the requested key.',\n params: {},\n },\n\n // ----------------------------------------------------------------------------------- services\n NO_SIGNER: {\n phase: 'pre_send',\n template: 'This method requires a signer. Please provide a signer to the GSwap constructor.',\n params: {},\n },\n NO_WALLET_ADDRESS: {\n phase: 'post_send',\n template:\n 'Cannot confirm this write: no walletAddress was provided to the GSwap constructor, so the resulting position cannot be looked up to confirm it landed on chain.',\n params: {},\n },\n NO_POOL_AVAILABLE: {\n phase: 'post_send',\n template: 'No pool is available for {tokenIn}/{tokenOut} (fee tier {fee}).',\n params: { tokenIn: 'string', tokenOut: 'string', fee: 'string' },\n },\n INSUFFICIENT_LIQUIDITY: {\n phase: 'post_send',\n template:\n 'The selected pool has insufficient liquidity for {tokenIn}/{tokenOut} (fee tier {fee}).',\n params: { tokenIn: 'string', tokenOut: 'string', fee: 'string' },\n },\n UNKNOWN_TOKEN: {\n phase: 'pre_send',\n template: 'Token {token} is not registered on the DEX contract: it has no trading symbol.',\n params: { token: 'string' },\n },\n SYMBOL_NOT_FOUND: {\n phase: 'pre_send',\n template: 'Token {token} could not be resolved to a trading symbol.',\n params: { token: 'string' },\n },\n STREAM_API_KEY_UNUSABLE: {\n phase: 'pre_send',\n template:\n 'GdexStreamConfig.apiKey needs a non-empty key and an explicit webSocketImpl that accepts upgrade headers as its third argument (the \"ws\" package, or React Native). A browser WebSocket cannot send x-api-key, so the key would be silently dropped.',\n params: {},\n },\n STREAM_WEBSOCKET_UNAVAILABLE: {\n phase: 'pre_send',\n template:\n 'GdexStreamService requires a standards-compatible WebSocket constructor. Node.js versions before 22 must provide one with config.webSocketImpl (for example, from the \"ws\" package).',\n params: {},\n },\n STREAM_NOT_CONNECTED: {\n phase: 'pre_send',\n template: 'GDEX stream is not connected. Call connect() first.',\n params: {},\n },\n STREAM_DISCONNECTED: {\n phase: 'in_flight',\n template: 'GDEX stream disconnected.',\n params: {},\n },\n STREAM_REQUEST_TIMEOUT: {\n phase: 'in_flight',\n template: 'GDEX request \"{method}\" timed out after {timeoutMs} ms.',\n params: { method: 'string', timeoutMs: 'number' },\n },\n STREAM_CONNECT_FAILED: {\n phase: 'in_flight',\n template: 'Failed to connect to GDEX stream at {url}.',\n params: { url: 'string' },\n },\n STREAM_CLOSED_BEFORE_CONNECT: {\n phase: 'in_flight',\n template: 'GDEX stream closed before connecting (code {closeCode}).',\n params: { closeCode: 'number' },\n },\n STREAM_CONNECTION_CLOSED: {\n phase: 'in_flight',\n template: 'GDEX stream connection closed (code {closeCode}).',\n params: { closeCode: 'number' },\n },\n\n // ------------------------------------------------------------------------------ wallet / keys\n TOKEN_RESOLUTION_FAILED: {\n phase: 'pre_send',\n template: 'Token {token} could not be looked up; nothing was sent.',\n params: { token: 'string' },\n },\n MISSING_WALLET_ADDRESS: {\n phase: 'pre_send',\n template:\n 'Invalid wallet address: No wallet address provided. Either provide a wallet address to the function you are calling, or set one when instantiating GSwapSDK.',\n params: {},\n },\n\n // ------------------------------------------------------------------------ input validation\n NON_CANONICAL_PAIR: {\n phase: 'pre_send',\n template:\n 'The pair {token0}/{token1} is not in canonical order: token0 must sort before token1.',\n params: { token0: 'string', token1: 'string' },\n },\n UNORDERABLE_SYMBOLS: {\n phase: 'pre_send',\n template: 'Unable to order trading symbols: expected a pair of symbols, got {received}.',\n params: { received: 'string' },\n },\n INVALID_TOKEN_CLASS_KEY: {\n phase: 'pre_send',\n template:\n 'Invalid token class key \"{tokenClassKey}\": expected a collection followed by category, type and additionalKey',\n params: { tokenClassKey: 'string' },\n },\n INCOMPLETE_TOKEN_CLASS_KEY: {\n phase: 'pre_send',\n template: 'Token class key \"{compositeKey}\" is missing {part}.',\n params: { compositeKey: 'string', part: 'string' },\n },\n INVALID_TRADING_SYMBOL: {\n phase: 'pre_send',\n template:\n 'Invalid trading symbol \"{symbol}\": must be 1-32 ASCII letters and digits and not a reserved word (Token, Unit, none).',\n params: { symbol: 'string' },\n },\n NO_VALID_TRADING_SYMBOL: {\n phase: 'pre_send',\n template:\n 'No valid trading symbol for token class {classKey}: \"{displaySymbol}\" is not an acceptable symbol and none is registered',\n params: { classKey: 'string', displaySymbol: 'string' },\n },\n TOKEN_SYMBOL_NOT_REGISTERED: {\n phase: 'pre_send',\n template:\n 'Token {token} is not registered in the trading-symbol registry yet; pass token0Symbol/token1Symbol (the token class symbol) to propose one. A symbol cannot be derived from a class key.',\n params: { token: 'string' },\n },\n SYMBOL_DISAGREES_WITH_REGISTRY: {\n phase: 'pre_send',\n template:\n 'Supplied symbol {suppliedSymbol} for {token} disagrees with the registered trading symbol {registeredSymbol}.',\n params: { token: 'string', suppliedSymbol: 'string', registeredSymbol: 'string' },\n },\n CREATE_POOL_NEEDS_CLASS_KEY: {\n phase: 'pre_send',\n template:\n 'createPool needs each token as a class key; {token} is a bare trading symbol, which does not carry one.',\n params: { token: 'string' },\n },\n AMOUNT_IS_JS_NUMBER: {\n phase: 'pre_send',\n template: 'Invalid {field}: use a decimal string or BigNumber, not a JavaScript number',\n params: { field: 'string' },\n },\n AMOUNT_NOT_FINITE: {\n phase: 'pre_send',\n template: 'Invalid {field}: must be a finite number (got {value})',\n params: { field: 'string', value: 'string' },\n },\n AMOUNT_NOT_POSITIVE: {\n phase: 'pre_send',\n template: 'Invalid {field}: must be positive (got {value})',\n params: { field: 'string', value: 'string' },\n },\n AMOUNT_NEGATIVE: {\n phase: 'pre_send',\n template: 'Invalid {field}: must not be negative (got {value})',\n params: { field: 'string', value: 'string' },\n },\n PRICE_VALUES_IS_JS_NUMBER: {\n phase: 'pre_send',\n template:\n 'Invalid price values: use decimal strings or BigNumber values, not JavaScript numbers',\n params: {},\n },\n INVALID_PRICE_VALUES: {\n phase: 'pre_send',\n template:\n 'Invalid price values: all prices must be finite and positive (spot {spotPrice}, lower {lowerPrice}, upper {upperPrice})',\n params: { spotPrice: 'string', lowerPrice: 'string', upperPrice: 'string' },\n },\n INVALID_PRICE_RANGE: {\n phase: 'pre_send',\n template:\n 'Invalid price range: lower price {lowerPrice} must be less than or equal to upper price {upperPrice}',\n params: { lowerPrice: 'string', upperPrice: 'string' },\n },\n INVALID_PRICE_BOUNDS: {\n phase: 'pre_send',\n template:\n 'Price bounds must be finite and positive (minPrice {minPrice}, maxPrice {maxPrice}).',\n params: { minPrice: 'string', maxPrice: 'string' },\n },\n PRICE_BOUNDS_ORDER: {\n phase: 'pre_send',\n template: 'minPrice {minPrice} must be less than or equal to maxPrice {maxPrice}.',\n params: { minPrice: 'string', maxPrice: 'string' },\n },\n INVALID_STARTING_PRICE: {\n phase: 'pre_send',\n template: 'Starting price must be finite and positive (got {value}).',\n params: { value: 'string' },\n },\n INVALID_SQRT_PRICE: {\n phase: 'pre_send',\n template: 'Cannot invert a non-positive sqrt price ({sqrtPrice}).',\n params: { sqrtPrice: 'string' },\n },\n INVALID_TOKEN_DECIMALS: {\n phase: 'pre_send',\n template: 'Invalid {field}: must be a non-negative integer (got {value})',\n params: { field: 'string', value: 'number' },\n },\n TICKS_NOT_INTEGERS: {\n phase: 'pre_send',\n template: 'Invalid tick values: ticks must be integers (got {tickLower} and {tickUpper})',\n params: { tickLower: 'number', tickUpper: 'number' },\n },\n INVALID_TICK_RANGE: {\n phase: 'pre_send',\n template: 'Invalid tick range: tickLower {tickLower} must be less than tickUpper {tickUpper}',\n params: { tickLower: 'number', tickUpper: 'number' },\n },\n TICKS_OUT_OF_BOUNDS: {\n phase: 'pre_send',\n template:\n 'Invalid tick range: ticks {tickLower} and {tickUpper} must be between {minTick} and {maxTick}',\n params: { tickLower: 'number', tickUpper: 'number', minTick: 'number', maxTick: 'number' },\n },\n TICKS_NOT_ALIGNED: {\n phase: 'pre_send',\n template: 'Ticks {tickLower} and {tickUpper} must be aligned to spacing {spacing}.',\n params: { tickLower: 'number', tickUpper: 'number', spacing: 'number' },\n },\n INVALID_TICK_SPACING: {\n phase: 'pre_send',\n template: 'Invalid tick spacing: must be a positive integer (got {value})',\n params: { value: 'number' },\n },\n INVALID_FEE: {\n phase: 'pre_send',\n template: 'Invalid {field}: {value} is not a supported fee tier; must be one of {allowed}.',\n params: { field: 'string', value: 'number', allowed: 'string' },\n },\n EXACT_AMOUNT_REQUIRED: {\n phase: 'pre_send',\n template: '{field} is required for this swap.',\n params: { field: 'string' },\n },\n EXACTLY_ONE_OF_REQUIRED: {\n phase: 'pre_send',\n template: 'Provide exactly one of {first} or {second}.',\n params: { first: 'string', second: 'string' },\n },\n AT_MOST_ONE_OF_ALLOWED: {\n phase: 'pre_send',\n template: 'Provide at most one of {first} or {second}.',\n params: { first: 'string', second: 'string' },\n },\n POOL_MISMATCH: {\n phase: 'pre_send',\n template:\n 'tokenIn {tokenIn} and tokenOut {tokenOut} must be the two tokens of the pinned pool {poolToken0}/{poolToken1}.',\n params: {\n tokenIn: 'string',\n tokenOut: 'string',\n poolToken0: 'string',\n poolToken1: 'string',\n },\n },\n INVALID_DTO: {\n phase: 'pre_send',\n template: '{method} DTO field {field} is invalid (expected {expected}).',\n params: { method: 'string', field: 'string', expected: 'string' },\n },\n DTO_NOT_CANONICAL: {\n phase: 'pre_send',\n template:\n 'The {method} DTO is not in the form the SDK builders produce; build it with the matching build function and submit that.',\n params: { method: 'string' },\n },\n SEARCH_TOO_LONG: {\n phase: 'pre_send',\n template: 'search must be at most {maxLength} characters (got {length}).',\n params: { length: 'number', maxLength: 'number' },\n },\n INVALID_SORT_BY: {\n phase: 'pre_send',\n template: 'sortBy \"{value}\" is not allowed; it must be one of {allowed}.',\n params: { value: 'string', allowed: 'string' },\n },\n INVALID_SORT_ORDER: {\n phase: 'pre_send',\n template: 'sortOrder \"{value}\" is not allowed; it must be asc or desc.',\n params: { value: 'string' },\n },\n INVALID_PAGE: {\n phase: 'pre_send',\n template: 'page must be an integer of at least 1 (got {value}).',\n params: { value: 'number' },\n },\n INVALID_LIMIT: {\n phase: 'pre_send',\n template: 'limit must be an integer from {min} to {max} (got {value}).',\n params: { value: 'number', min: 'number', max: 'number' },\n },\n INVALID_MARKET_TOKEN: {\n phase: 'pre_send',\n template:\n 'A market read names a token by a symbol or class key of 1 to 120 letters, digits and . _ $ + / : | - characters (got \"{token}\").',\n params: { token: 'string' },\n },\n INVALID_TIMEFRAME: {\n phase: 'pre_send',\n template: 'timeframe \"{value}\" is not allowed; it must be one of {allowed}.',\n params: { value: 'string', allowed: 'string' },\n },\n INVALID_SEASON_ID: {\n phase: 'pre_send',\n template: 'seasonId must be an integer of at least 1 (got {value}).',\n params: { value: 'string' },\n },\n INVALID_POLL_INTERVAL: {\n phase: 'pre_send',\n template: 'intervalMs must be a finite number of milliseconds of at least 1 (got {value}).',\n params: { value: 'string' },\n },\n} as const satisfies Record<string, GalaErrorCatalogEntry>;\n\n/** Every code a `GSwapSDKError` can carry: the core codes and gswap-sdk's own DEX codes. */\nexport type GSwapErrorCode = GalaErrorCode | keyof typeof GSWAP_ERROR_CATALOG;\n\n/** Both catalogs as one type: a code of either reads its entry here. */\ntype GSwapCatalog = typeof GALA_ERROR_CATALOG & typeof GSWAP_ERROR_CATALOG;\n\n/** The named params of one error code (core or DEX): a flat object of primitives (or closed string tokens). */\nexport type GSwapErrorParams<C extends GSwapErrorCode> = ErrorParamsOf<GSwapCatalog, C>;\n\n/**\n * The catalog `GSwapSDKError` reads templates and phases from: core's entries and the DEX entries,\n * merged (never redefined: the two key sets are disjoint, pinned by tests/error_catalog.test.ts).\n */\nexport const GSWAP_SDK_ERROR_ENTRIES: Readonly<Record<GSwapErrorCode, GalaErrorCatalogEntry>> = {\n ...GALA_ERROR_CATALOG,\n ...GSWAP_ERROR_CATALOG,\n};\n\n/**\n * The English template of every DEX error code, `{placeholder}` markers included. An optional seed\n * or fallback for an app's own translations; the SDK's `message` is generated from it. The core\n * codes' templates are `galaErrorTemplates` from `@gala-chain/gala-core-sdk`: an app that seeds\n * every code a `GSwapSDKError` can carry merges the two.\n */\nexport const gswapErrorTemplates: { readonly [C in keyof typeof GSWAP_ERROR_CATALOG]: string } =\n Object.fromEntries(\n Object.entries(GSWAP_ERROR_CATALOG).map(([code, entry]) => [code, entry.template]),\n ) as { readonly [C in keyof typeof GSWAP_ERROR_CATALOG]: string };\n"],"mappings":"A,+DAyCA,MAAaA,EAAqC,CAAC,UAAW,WAAW,EAM5DC,EAAyB,mBAGzBC,EAAsB,CAEjC,WAAY,CACV,MAAO,YACP,SAAU,6CACV,OAAQ,CAAE,OAAQ,SAAU,IAAK,SAAU,cAAe,QAAS,EACnE,WAAY,CAAC,eAAe,CAC9B,EACA,gBAAiB,CACf,MAAO,YACP,SACE,mGACF,OAAQ,CAAE,OAAQ,QAAS,CAC7B,EACA,eAAgB,CACd,MAAO,YACP,SAAU,kCACV,OAAQ,CAAE,UAAW,QAAS,CAChC,EAGA,qBAAsB,CACpB,MAAO,WACP,SAAU,+EACV,OAAQ,CAAE,OAAQ,QAAS,CAC7B,EACA,2BAA4B,CAC1B,MAAO,YACP,SACE,mHACF,OAAQ,CAAE,OAAQF,CAAmC,CACvD,EACA,uBAAwB,CACtB,MAAO,YACP,SAAU,gEACV,OAAQ,CAAE,cAAe,QAAS,CACpC,EACA,qBAAsB,CACpB,MAAO,YACP,SAAU,mDACV,OAAQ,CAAC,CACX,EACA,qBAAsB,CACpB,MAAO,YACP,SACE,0FACF,OAAQ,CAAC,CACX,EACA,2BAA4B,CAC1B,MAAO,YACP,SACE,wGACF,OAAQ,CAAC,CACX,EACA,mBAAoB,CAClB,MAAO,YACP,SACE,mHACF,OAAQ,CAAC,CACX,EACA,oBAAqB,CACnB,MAAO,YACP,SAAU,gFACV,OAAQ,CAAC,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AAMC,EAAM,QAAQ,CAAC,CACnF,E"}
|
|
1
|
+
{"version":3,"file":"gswap_error_catalog.js","names":["SUBMISSION_OUTCOME_UNKNOWN_REASONS","ALLOWED_FEE_TIERS_TEXT","GSWAP_ERROR_CATALOG","GSWAP_SDK_ERROR_ENTRIES","GALA_ERROR_CATALOG","gswapErrorTemplates","code","entry"],"sources":["../../../src/classes/gswap_error_catalog.ts"],"sourcesContent":["/**\n * The catalog of every error code gswap-sdk ITSELF throws (the DEX codes): the SINGLE source of\n * truth for its `code`, the named parameters it carries and the English template its `message` is\n * generated from. The codes of the signing, transport and wallet layer (`INVALID_PRIVATE_KEY`,\n * `REQUEST_TIMEOUT`, `SIGNING_FAILED`, `TYPED_DATA_*`, ...) live in `@gala-chain/gala-core-sdk`'s\n * `GALA_ERROR_CATALOG`; no code is defined in both. A `GSwapSDKError` can carry a code of either\n * catalog (`GSwapErrorCode` is the union), and reads its template from both.\n *\n * - `code` is the only discriminator. It is stable: apps branch on it, never on message text.\n * - `params` are the named placeholders of the error: a flat object of primitives (string,\n * number, boolean) that an app feeds to its own localization (i18next, ICU, FormatJS).\n * Raw server payloads are never params (they are `error.body` / `error.bodyText`), and no\n * secret (private key, signature, raw DTO) ever is.\n * - `template` is English with `{placeholder}` markers. `error.message` is generated from it\n * and the params, so the two cannot drift. It is for logs and developers: it is not stable and\n * must not be shown to users or matched on.\n *\n * Every placeholder in a template is a declared param and every declared param is a placeholder,\n * except the few `unrendered` params that carry server text for the app and are kept out of\n * `message` on purpose (pinned by tests/error_catalog.test.ts). Facts that are not placeholders (HTTP status, URL,\n * `uniqueKey`, transaction ids, the raw body, the cause) are typed properties of the error, see\n * `GalaErrorContext`.\n */\n\nimport {\n GALA_ERROR_CATALOG,\n type ErrorParamsOf,\n type GalaErrorCatalogEntry,\n type GalaErrorCode,\n} from '@gala-chain/gala-core-sdk';\n\n/**\n * Why the outcome of a write submission is unknown (`SUBMISSION_OUTCOME_UNKNOWN.params.reason`).\n * Both say the same thing about the swap (it MAY have been queued: never resubmit under a fresh\n * key, confirm `error.uniqueKey` instead) and differ only in what happened to the request.\n *\n * - `timeout`: the POST exceeded the gateway's timeout; the request may still be running.\n * - `transport`: the POST failed before an HTTP answer was read (offline, connection reset, DNS,\n * CORS, a body that broke off). The bytes may have reached the server and been queued, so this\n * does NOT prove the swap was not sent.\n */\nexport const SUBMISSION_OUTCOME_UNKNOWN_REASONS = ['timeout', 'transport'] as const;\n\n/** One member of {@link SUBMISSION_OUTCOME_UNKNOWN_REASONS}. */\nexport type SubmissionOutcomeUnknownReason = (typeof SUBMISSION_OUTCOME_UNKNOWN_REASONS)[number];\n\n/** The fee tiers as they appear in `INVALID_FEE.allowed`. */\nexport const ALLOWED_FEE_TIERS_TEXT = '0,500,3000,10000';\n\n/** The whole DEX catalog. Add a code here before throwing it anywhere in gswap-sdk. */\nexport const GSWAP_ERROR_CATALOG = {\n // ---------------------------------------------------------------------------------- transport\n HTTP_ERROR: {\n phase: 'post_send',\n template: 'Unexpected HTTP error {status} from {url}.',\n params: { status: 'number', url: 'string', serverMessage: 'string' },\n unrendered: ['serverMessage'],\n },\n UPDATE_REQUIRED: {\n phase: 'post_send',\n template:\n 'The backend refused this app version and requires an update (HTTP {status}); nothing was queued.',\n params: { status: 'number' },\n },\n REQUEST_FAILED: {\n phase: 'in_flight',\n template: 'The {operation} request failed.',\n params: { operation: 'string' },\n },\n\n // ----------------------------------------------------------------------------------- gateway\n METHOD_NOT_SUPPORTED: {\n phase: 'pre_send',\n template: 'The method {method} is not supported; swaps are queued through RequestTrade.',\n params: { method: 'string' },\n },\n SUBMISSION_OUTCOME_UNKNOWN: {\n phase: 'in_flight',\n template:\n 'The submission outcome is unknown ({reason}): the request may have reached the gateway. Confirm before retrying.',\n params: { reason: SUBMISSION_OUTCOME_UNKNOWN_REASONS },\n },\n GATEWAY_REPORTED_ERROR: {\n phase: 'post_send',\n template: 'The gateway reported an error for this write: {serverMessage}',\n params: { serverMessage: 'string' },\n },\n GATEWAY_DATA_MISSING: {\n phase: 'post_send',\n template: 'The gateway response is missing its data object.',\n params: {},\n },\n GATEWAY_MODE_INVALID: {\n phase: 'post_send',\n template:\n 'Gateway response must contain data.mode=\"sync\" with data.result, or data.mode=\"queued\".',\n params: {},\n },\n GATEWAY_SYNC_REQUEST_TRADE: {\n phase: 'post_send',\n template:\n 'The gateway executed RequestTrade synchronously, which this SDK refuses; RequestTrade must be queued.',\n params: {},\n },\n MISSING_UNIQUE_KEY: {\n phase: 'post_send',\n template:\n 'The gateway acknowledged RequestTrade without echoing its uniqueKey, so it cannot be tied to the signed request.',\n params: {},\n },\n UNIQUE_KEY_MISMATCH: {\n phase: 'post_send',\n template: 'Gateway response data.uniqueKey must match the signed RequestTrade uniqueKey.',\n params: {},\n },\n SHADOW_NOT_QUEUED: {\n phase: 'post_send',\n template: 'The swap backend did not queue the shadow request.',\n params: {},\n },\n SHADOW_SUBMIT_NEEDS_WALLET_ADDRESS: {\n phase: 'pre_send',\n template:\n 'A shadow submission needs a walletAddress (the X-Wallet-Address header): pass one to the GSwap constructor or to this call.',\n params: {},\n },\n METHOD_NOT_ALLOWED: {\n phase: 'post_send',\n template: 'The gateway does not expose this contract method: {serverMessage}',\n params: { serverMessage: 'string' },\n },\n SIGNATURE_INVALID: {\n phase: 'post_send',\n template: 'The gateway could not verify the signature: {serverMessage}',\n params: { serverMessage: 'string' },\n },\n SIGNER_MISMATCH: {\n phase: 'post_send',\n template:\n 'The recovered signer does not match an actor named by the operation: {serverMessage}',\n params: { serverMessage: 'string' },\n },\n DTO_INVALID: {\n phase: 'post_send',\n template: 'The gateway rejected the DTO shape: {serverMessage}',\n params: { serverMessage: 'string' },\n },\n DTO_OPERATION_MISMATCH: {\n phase: 'post_send',\n template:\n 'The signed DTO has no dtoOperation, or one that is not the call it was sent to: {serverMessage}',\n params: { serverMessage: 'string' },\n },\n BOUNDS_VIOLATION: {\n phase: 'post_send',\n template: 'The gateway rejected a numeric, tick, symbol or range bound: {serverMessage}',\n params: { serverMessage: 'string' },\n },\n SYMBOL_CONFLICT: {\n phase: 'post_send',\n template: 'The CreatePool symbol is already owned by another class: {serverMessage}',\n params: { serverMessage: 'string' },\n },\n RATE_LIMITED: {\n phase: 'post_send',\n template: 'The gateway rate-limited this signer: {serverMessage}',\n params: { serverMessage: 'string' },\n },\n CHAIN_DISPATCH_FAILED: {\n phase: 'post_send',\n template: 'The chain dispatch failed (chain error key \"{errorKey}\"): {serverMessage}',\n params: { errorKey: 'string', serverMessage: 'string' },\n },\n GATEWAY_REJECTED: {\n phase: 'post_send',\n template: 'Gateway rejected {gatewayCode}: {serverMessage}',\n params: { gatewayCode: 'string', serverMessage: 'string' },\n },\n CHAIN_REJECTED: {\n phase: 'post_send',\n template: 'GalaChain error {errorKey}: {serverMessage}',\n params: { errorKey: 'string', serverMessage: 'string' },\n },\n INVALID_CHAIN_RESPONSE: {\n phase: 'post_send',\n template: 'Backend returned an invalid {resource}.',\n params: { resource: 'string' },\n },\n INVALID_POSITION_RESPONSE: {\n phase: 'post_send',\n template: 'Backend returned an invalid position ({reason}).',\n params: { reason: 'string' },\n },\n\n // -------------------------------------------------------------------------------- confirmation\n CONFIRMATION_TIMEOUT: {\n phase: 'post_send',\n template:\n 'Transaction confirmation timed out; the trade may still apply. Confirm the same uniqueKey again later instead of resubmitting.',\n params: {},\n },\n CONFIRMATION_ABORTED: {\n phase: 'post_send',\n template: 'Transaction confirmation was aborted.',\n params: {},\n },\n CONFIRMATION_FAILED: {\n phase: 'post_send',\n template: 'Transaction confirmation failed with HTTP {status}.',\n params: { status: 'number', serverMessage: 'string' },\n unrendered: ['serverMessage'],\n },\n CONFIRMATION_MALFORMED: {\n phase: 'post_send',\n template: 'Transaction confirmation returned a malformed body.',\n params: {},\n },\n CONFIRMATION_KEY_MISMATCH: {\n phase: 'post_send',\n template: 'Apply result key did not match the requested key.',\n params: {},\n },\n\n // ----------------------------------------------------------------------------------- services\n NO_SIGNER: {\n phase: 'pre_send',\n template: 'This method requires a signer. Please provide a signer to the GSwap constructor.',\n params: {},\n },\n NO_WALLET_ADDRESS: {\n phase: 'post_send',\n template:\n 'Cannot confirm this write: no walletAddress was provided to the GSwap constructor, so the resulting position cannot be looked up to confirm it landed on chain.',\n params: {},\n },\n NO_POOL_AVAILABLE: {\n phase: 'post_send',\n template: 'No pool is available for {tokenIn}/{tokenOut} (fee tier {fee}).',\n params: { tokenIn: 'string', tokenOut: 'string', fee: 'string' },\n },\n INSUFFICIENT_LIQUIDITY: {\n phase: 'post_send',\n template:\n 'The selected pool has insufficient liquidity for {tokenIn}/{tokenOut} (fee tier {fee}).',\n params: { tokenIn: 'string', tokenOut: 'string', fee: 'string' },\n },\n UNKNOWN_TOKEN: {\n phase: 'pre_send',\n template: 'Token {token} is not registered on the DEX contract: it has no trading symbol.',\n params: { token: 'string' },\n },\n SYMBOL_NOT_FOUND: {\n phase: 'pre_send',\n template: 'Token {token} could not be resolved to a trading symbol.',\n params: { token: 'string' },\n },\n STREAM_API_KEY_UNUSABLE: {\n phase: 'pre_send',\n template:\n 'GdexStreamConfig.apiKey needs a non-empty key and an explicit webSocketImpl that accepts upgrade headers as its third argument (the \"ws\" package, or React Native). A browser WebSocket cannot send x-api-key, so the key would be silently dropped.',\n params: {},\n },\n STREAM_WEBSOCKET_UNAVAILABLE: {\n phase: 'pre_send',\n template:\n 'GdexStreamService requires a standards-compatible WebSocket constructor. Node.js versions before 22 must provide one with config.webSocketImpl (for example, from the \"ws\" package).',\n params: {},\n },\n STREAM_NOT_CONNECTED: {\n phase: 'pre_send',\n template: 'GDEX stream is not connected. Call connect() first.',\n params: {},\n },\n STREAM_DISCONNECTED: {\n phase: 'in_flight',\n template: 'GDEX stream disconnected.',\n params: {},\n },\n STREAM_REQUEST_TIMEOUT: {\n phase: 'in_flight',\n template: 'GDEX request \"{method}\" timed out after {timeoutMs} ms.',\n params: { method: 'string', timeoutMs: 'number' },\n },\n STREAM_CONNECT_FAILED: {\n phase: 'in_flight',\n template: 'Failed to connect to GDEX stream at {url}.',\n params: { url: 'string' },\n },\n STREAM_CLOSED_BEFORE_CONNECT: {\n phase: 'in_flight',\n template: 'GDEX stream closed before connecting (code {closeCode}).',\n params: { closeCode: 'number' },\n },\n STREAM_CONNECTION_CLOSED: {\n phase: 'in_flight',\n template: 'GDEX stream connection closed (code {closeCode}).',\n params: { closeCode: 'number' },\n },\n\n // ------------------------------------------------------------------------------ wallet / keys\n TOKEN_RESOLUTION_FAILED: {\n phase: 'pre_send',\n template: 'Token {token} could not be looked up; nothing was sent.',\n params: { token: 'string' },\n },\n MISSING_WALLET_ADDRESS: {\n phase: 'pre_send',\n template:\n 'Invalid wallet address: No wallet address provided. Either provide a wallet address to the function you are calling, or set one when instantiating GSwapSDK.',\n params: {},\n },\n\n // ------------------------------------------------------------------------ input validation\n NON_CANONICAL_PAIR: {\n phase: 'pre_send',\n template:\n 'The pair {token0}/{token1} is not in canonical order: token0 must sort before token1.',\n params: { token0: 'string', token1: 'string' },\n },\n UNORDERABLE_SYMBOLS: {\n phase: 'pre_send',\n template: 'Unable to order trading symbols: expected a pair of symbols, got {received}.',\n params: { received: 'string' },\n },\n INVALID_TOKEN_CLASS_KEY: {\n phase: 'pre_send',\n template:\n 'Invalid token class key \"{tokenClassKey}\": expected a collection followed by category, type and additionalKey',\n params: { tokenClassKey: 'string' },\n },\n INCOMPLETE_TOKEN_CLASS_KEY: {\n phase: 'pre_send',\n template: 'Token class key \"{compositeKey}\" is missing {part}.',\n params: { compositeKey: 'string', part: 'string' },\n },\n INVALID_TRADING_SYMBOL: {\n phase: 'pre_send',\n template:\n 'Invalid trading symbol \"{symbol}\": must be 1-32 ASCII letters and digits and not a reserved word (Token, Unit, none).',\n params: { symbol: 'string' },\n },\n NO_VALID_TRADING_SYMBOL: {\n phase: 'pre_send',\n template:\n 'No valid trading symbol for token class {classKey}: \"{displaySymbol}\" is not an acceptable symbol and none is registered',\n params: { classKey: 'string', displaySymbol: 'string' },\n },\n TOKEN_SYMBOL_NOT_REGISTERED: {\n phase: 'pre_send',\n template:\n 'Token {token} is not registered in the trading-symbol registry yet; pass token0Symbol/token1Symbol (the token class symbol) to propose one. A symbol cannot be derived from a class key.',\n params: { token: 'string' },\n },\n SYMBOL_DISAGREES_WITH_REGISTRY: {\n phase: 'pre_send',\n template:\n 'Supplied symbol {suppliedSymbol} for {token} disagrees with the registered trading symbol {registeredSymbol}.',\n params: { token: 'string', suppliedSymbol: 'string', registeredSymbol: 'string' },\n },\n CREATE_POOL_NEEDS_CLASS_KEY: {\n phase: 'pre_send',\n template:\n 'createPool needs each token as a class key; {token} is a bare trading symbol, which does not carry one.',\n params: { token: 'string' },\n },\n AMOUNT_IS_JS_NUMBER: {\n phase: 'pre_send',\n template: 'Invalid {field}: use a decimal string or BigNumber, not a JavaScript number',\n params: { field: 'string' },\n },\n AMOUNT_NOT_FINITE: {\n phase: 'pre_send',\n template: 'Invalid {field}: must be a finite number (got {value})',\n params: { field: 'string', value: 'string' },\n },\n AMOUNT_NOT_POSITIVE: {\n phase: 'pre_send',\n template: 'Invalid {field}: must be positive (got {value})',\n params: { field: 'string', value: 'string' },\n },\n AMOUNT_NEGATIVE: {\n phase: 'pre_send',\n template: 'Invalid {field}: must not be negative (got {value})',\n params: { field: 'string', value: 'string' },\n },\n PRICE_VALUES_IS_JS_NUMBER: {\n phase: 'pre_send',\n template:\n 'Invalid price values: use decimal strings or BigNumber values, not JavaScript numbers',\n params: {},\n },\n INVALID_PRICE_VALUES: {\n phase: 'pre_send',\n template:\n 'Invalid price values: all prices must be finite and positive (spot {spotPrice}, lower {lowerPrice}, upper {upperPrice})',\n params: { spotPrice: 'string', lowerPrice: 'string', upperPrice: 'string' },\n },\n INVALID_PRICE_RANGE: {\n phase: 'pre_send',\n template:\n 'Invalid price range: lower price {lowerPrice} must be less than or equal to upper price {upperPrice}',\n params: { lowerPrice: 'string', upperPrice: 'string' },\n },\n INVALID_PRICE_BOUNDS: {\n phase: 'pre_send',\n template:\n 'Price bounds must be finite and positive (minPrice {minPrice}, maxPrice {maxPrice}).',\n params: { minPrice: 'string', maxPrice: 'string' },\n },\n PRICE_BOUNDS_ORDER: {\n phase: 'pre_send',\n template: 'minPrice {minPrice} must be less than or equal to maxPrice {maxPrice}.',\n params: { minPrice: 'string', maxPrice: 'string' },\n },\n INVALID_STARTING_PRICE: {\n phase: 'pre_send',\n template: 'Starting price must be finite and positive (got {value}).',\n params: { value: 'string' },\n },\n INVALID_SQRT_PRICE: {\n phase: 'pre_send',\n template: 'Cannot invert a non-positive sqrt price ({sqrtPrice}).',\n params: { sqrtPrice: 'string' },\n },\n INVALID_TOKEN_DECIMALS: {\n phase: 'pre_send',\n template: 'Invalid {field}: must be a non-negative integer (got {value})',\n params: { field: 'string', value: 'number' },\n },\n TICKS_NOT_INTEGERS: {\n phase: 'pre_send',\n template: 'Invalid tick values: ticks must be integers (got {tickLower} and {tickUpper})',\n params: { tickLower: 'number', tickUpper: 'number' },\n },\n INVALID_TICK_RANGE: {\n phase: 'pre_send',\n template: 'Invalid tick range: tickLower {tickLower} must be less than tickUpper {tickUpper}',\n params: { tickLower: 'number', tickUpper: 'number' },\n },\n TICKS_OUT_OF_BOUNDS: {\n phase: 'pre_send',\n template:\n 'Invalid tick range: ticks {tickLower} and {tickUpper} must be between {minTick} and {maxTick}',\n params: { tickLower: 'number', tickUpper: 'number', minTick: 'number', maxTick: 'number' },\n },\n TICKS_NOT_ALIGNED: {\n phase: 'pre_send',\n template: 'Ticks {tickLower} and {tickUpper} must be aligned to spacing {spacing}.',\n params: { tickLower: 'number', tickUpper: 'number', spacing: 'number' },\n },\n INVALID_TICK_SPACING: {\n phase: 'pre_send',\n template: 'Invalid tick spacing: must be a positive integer (got {value})',\n params: { value: 'number' },\n },\n INVALID_FEE: {\n phase: 'pre_send',\n template: 'Invalid {field}: {value} is not a supported fee tier; must be one of {allowed}.',\n params: { field: 'string', value: 'number', allowed: 'string' },\n },\n EXACT_AMOUNT_REQUIRED: {\n phase: 'pre_send',\n template: '{field} is required for this swap.',\n params: { field: 'string' },\n },\n EXACTLY_ONE_OF_REQUIRED: {\n phase: 'pre_send',\n template: 'Provide exactly one of {first} or {second}.',\n params: { first: 'string', second: 'string' },\n },\n AT_MOST_ONE_OF_ALLOWED: {\n phase: 'pre_send',\n template: 'Provide at most one of {first} or {second}.',\n params: { first: 'string', second: 'string' },\n },\n POOL_MISMATCH: {\n phase: 'pre_send',\n template:\n 'tokenIn {tokenIn} and tokenOut {tokenOut} must be the two tokens of the pinned pool {poolToken0}/{poolToken1}.',\n params: {\n tokenIn: 'string',\n tokenOut: 'string',\n poolToken0: 'string',\n poolToken1: 'string',\n },\n },\n INVALID_DTO: {\n phase: 'pre_send',\n template: '{method} DTO field {field} is invalid (expected {expected}).',\n params: { method: 'string', field: 'string', expected: 'string' },\n },\n DTO_NOT_CANONICAL: {\n phase: 'pre_send',\n template:\n 'The {method} DTO is not in the form the SDK builders produce; build it with the matching build function and submit that.',\n params: { method: 'string' },\n },\n SEARCH_TOO_LONG: {\n phase: 'pre_send',\n template: 'search must be at most {maxLength} characters (got {length}).',\n params: { length: 'number', maxLength: 'number' },\n },\n INVALID_SORT_BY: {\n phase: 'pre_send',\n template: 'sortBy \"{value}\" is not allowed; it must be one of {allowed}.',\n params: { value: 'string', allowed: 'string' },\n },\n INVALID_SORT_ORDER: {\n phase: 'pre_send',\n template: 'sortOrder \"{value}\" is not allowed; it must be asc or desc.',\n params: { value: 'string' },\n },\n INVALID_PAGE: {\n phase: 'pre_send',\n template: 'page must be an integer of at least 1 (got {value}).',\n params: { value: 'number' },\n },\n INVALID_LIMIT: {\n phase: 'pre_send',\n template: 'limit must be an integer from {min} to {max} (got {value}).',\n params: { value: 'number', min: 'number', max: 'number' },\n },\n INVALID_MARKET_TOKEN: {\n phase: 'pre_send',\n template:\n 'A market read names a token by a symbol or class key of 1 to 120 letters, digits and . _ $ + / : | - characters (got \"{token}\").',\n params: { token: 'string' },\n },\n INVALID_TIMEFRAME: {\n phase: 'pre_send',\n template: 'timeframe \"{value}\" is not allowed; it must be one of {allowed}.',\n params: { value: 'string', allowed: 'string' },\n },\n INVALID_SEASON_ID: {\n phase: 'pre_send',\n template: 'seasonId must be an integer of at least 1 (got {value}).',\n params: { value: 'string' },\n },\n INVALID_POLL_INTERVAL: {\n phase: 'pre_send',\n template: 'intervalMs must be a finite number of milliseconds of at least 1 (got {value}).',\n params: { value: 'string' },\n },\n} as const satisfies Record<string, GalaErrorCatalogEntry>;\n\n/** Every code a `GSwapSDKError` can carry: the core codes and gswap-sdk's own DEX codes. */\nexport type GSwapErrorCode = GalaErrorCode | keyof typeof GSWAP_ERROR_CATALOG;\n\n/** Both catalogs as one type: a code of either reads its entry here. */\ntype GSwapCatalog = typeof GALA_ERROR_CATALOG & typeof GSWAP_ERROR_CATALOG;\n\n/** The named params of one error code (core or DEX): a flat object of primitives (or closed string tokens). */\nexport type GSwapErrorParams<C extends GSwapErrorCode> = ErrorParamsOf<GSwapCatalog, C>;\n\n/**\n * The catalog `GSwapSDKError` reads templates and phases from: core's entries and the DEX entries,\n * merged (never redefined: the two key sets are disjoint, pinned by tests/error_catalog.test.ts).\n */\nexport const GSWAP_SDK_ERROR_ENTRIES: Readonly<Record<GSwapErrorCode, GalaErrorCatalogEntry>> = {\n ...GALA_ERROR_CATALOG,\n ...GSWAP_ERROR_CATALOG,\n};\n\n/**\n * The English template of every DEX error code, `{placeholder}` markers included. An optional seed\n * or fallback for an app's own translations; the SDK's `message` is generated from it. The core\n * codes' templates are `galaErrorTemplates` from `@gala-chain/gala-core-sdk`: an app that seeds\n * every code a `GSwapSDKError` can carry merges the two.\n */\nexport const gswapErrorTemplates: { readonly [C in keyof typeof GSWAP_ERROR_CATALOG]: string } =\n Object.fromEntries(\n Object.entries(GSWAP_ERROR_CATALOG).map(([code, entry]) => [code, entry.template]),\n ) as { readonly [C in keyof typeof GSWAP_ERROR_CATALOG]: string };\n"],"mappings":"A,+DAyCA,MAAaA,EAAqC,CAAC,UAAW,WAAW,EAM5DC,EAAyB,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,QAAS,CAC7B,EACA,gBAAiB,CACf,MAAO,WACP,SAAU,gEACV,OAAQ,CAAE,OAAQ,SAAU,UAAW,QAAS,CAClD,EACA,gBAAiB,CACf,MAAO,WACP,SAAU,gEACV,OAAQ,CAAE,MAAO,SAAU,QAAS,QAAS,CAC/C,EACA,mBAAoB,CAClB,MAAO,WACP,SAAU,8DACV,OAAQ,CAAE,MAAO,QAAS,CAC5B,EACA,aAAc,CACZ,MAAO,WACP,SAAU,uDACV,OAAQ,CAAE,MAAO,QAAS,CAC5B,EACA,cAAe,CACb,MAAO,WACP,SAAU,8DACV,OAAQ,CAAE,MAAO,SAAU,IAAK,SAAU,IAAK,QAAS,CAC1D,EACA,qBAAsB,CACpB,MAAO,WACP,SACE,mIACF,OAAQ,CAAE,MAAO,QAAS,CAC5B,EACA,kBAAmB,CACjB,MAAO,WACP,SAAU,mEACV,OAAQ,CAAE,MAAO,SAAU,QAAS,QAAS,CAC/C,EACA,kBAAmB,CACjB,MAAO,WACP,SAAU,2DACV,OAAQ,CAAE,MAAO,QAAS,CAC5B,EACA,sBAAuB,CACrB,MAAO,WACP,SAAU,kFACV,OAAQ,CAAE,MAAO,QAAS,CAC5B,CACF,EAeaG,EAAmF,CAC9F,GAAGC,EACH,GAAGF,CACL,EAQaG,EACX,OAAO,YACL,OAAO,QAAQH,CAAmB,CAAC,CAAC,KAAK,CAACI,EAAMC,KAAW,CAACD,EAAMC,EAAM,QAAQ,CAAC,CACnF,E"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{GALA_ERROR_PHASE_BY_CODE as e,isGalaCatalogCode as t}from"@gala-chain/gala-core-sdk";const n={HTTP_ERROR:`post_send`,UPDATE_REQUIRED:`post_send`,REQUEST_FAILED:`in_flight`,METHOD_NOT_SUPPORTED:`pre_send`,SUBMISSION_OUTCOME_UNKNOWN:`in_flight`,GATEWAY_REPORTED_ERROR:`post_send`,GATEWAY_DATA_MISSING:`post_send`,GATEWAY_MODE_INVALID:`post_send`,GATEWAY_SYNC_REQUEST_TRADE:`post_send`,MISSING_UNIQUE_KEY:`post_send`,UNIQUE_KEY_MISMATCH:`post_send`,SHADOW_NOT_QUEUED:`post_send`,SHADOW_SUBMIT_NEEDS_WALLET_ADDRESS:`pre_send`,METHOD_NOT_ALLOWED:`post_send`,SIGNATURE_INVALID:`post_send`,SIGNER_MISMATCH:`post_send`,DTO_INVALID:`post_send`,BOUNDS_VIOLATION:`post_send`,SYMBOL_CONFLICT:`post_send`,RATE_LIMITED:`post_send`,CHAIN_DISPATCH_FAILED:`post_send`,GATEWAY_REJECTED:`post_send`,CHAIN_REJECTED:`post_send`,INVALID_CHAIN_RESPONSE:`post_send`,INVALID_POSITION_RESPONSE:`post_send`,CONFIRMATION_TIMEOUT:`post_send`,CONFIRMATION_ABORTED:`post_send`,CONFIRMATION_FAILED:`post_send`,CONFIRMATION_MALFORMED:`post_send`,CONFIRMATION_KEY_MISMATCH:`post_send`,NO_SIGNER:`pre_send`,NO_WALLET_ADDRESS:`post_send`,NO_POOL_AVAILABLE:`post_send`,INSUFFICIENT_LIQUIDITY:`post_send`,UNKNOWN_TOKEN:`pre_send`,SYMBOL_NOT_FOUND:`pre_send`,STREAM_API_KEY_UNUSABLE:`pre_send`,STREAM_WEBSOCKET_UNAVAILABLE:`pre_send`,STREAM_NOT_CONNECTED:`pre_send`,STREAM_DISCONNECTED:`in_flight`,STREAM_REQUEST_TIMEOUT:`in_flight`,STREAM_CONNECT_FAILED:`in_flight`,STREAM_CLOSED_BEFORE_CONNECT:`in_flight`,STREAM_CONNECTION_CLOSED:`in_flight`,TOKEN_RESOLUTION_FAILED:`pre_send`,MISSING_WALLET_ADDRESS:`pre_send`,NON_CANONICAL_PAIR:`pre_send`,UNORDERABLE_SYMBOLS:`pre_send`,INVALID_TOKEN_CLASS_KEY:`pre_send`,INCOMPLETE_TOKEN_CLASS_KEY:`pre_send`,INVALID_TRADING_SYMBOL:`pre_send`,NO_VALID_TRADING_SYMBOL:`pre_send`,TOKEN_SYMBOL_NOT_REGISTERED:`pre_send`,SYMBOL_DISAGREES_WITH_REGISTRY:`pre_send`,CREATE_POOL_NEEDS_CLASS_KEY:`pre_send`,AMOUNT_IS_JS_NUMBER:`pre_send`,AMOUNT_NOT_FINITE:`pre_send`,AMOUNT_NOT_POSITIVE:`pre_send`,AMOUNT_NEGATIVE:`pre_send`,PRICE_VALUES_IS_JS_NUMBER:`pre_send`,INVALID_PRICE_VALUES:`pre_send`,INVALID_PRICE_RANGE:`pre_send`,INVALID_PRICE_BOUNDS:`pre_send`,PRICE_BOUNDS_ORDER:`pre_send`,INVALID_STARTING_PRICE:`pre_send`,INVALID_SQRT_PRICE:`pre_send`,INVALID_TOKEN_DECIMALS:`pre_send`,TICKS_NOT_INTEGERS:`pre_send`,INVALID_TICK_RANGE:`pre_send`,TICKS_OUT_OF_BOUNDS:`pre_send`,TICKS_NOT_ALIGNED:`pre_send`,INVALID_TICK_SPACING:`pre_send`,INVALID_FEE:`pre_send`,EXACT_AMOUNT_REQUIRED:`pre_send`,EXACTLY_ONE_OF_REQUIRED:`pre_send`,AT_MOST_ONE_OF_ALLOWED:`pre_send`,POOL_MISMATCH:`pre_send`,INVALID_DTO:`pre_send`,DTO_NOT_CANONICAL:`pre_send`,SEARCH_TOO_LONG:`pre_send`,INVALID_SORT_BY:`pre_send`,INVALID_SORT_ORDER:`pre_send`,INVALID_PAGE:`pre_send`,INVALID_LIMIT:`pre_send`,INVALID_MARKET_TOKEN:`pre_send`,INVALID_TIMEFRAME:`pre_send`,INVALID_SEASON_ID:`pre_send`,INVALID_POLL_INTERVAL:`pre_send`};function r(e){return Object.hasOwn(n,e)}function i(e){return t(e)||r(e)}function a(i){return i.phase===void 0?t(i.code)?e[i.code]:r(i.code)?n[i.code]:void 0:i.phase}export{n as GSWAP_ERROR_PHASE_BY_CODE,i as isCatalogCode,a as phaseOfView};
|
|
1
|
+
import{GALA_ERROR_PHASE_BY_CODE as e,isGalaCatalogCode as t}from"@gala-chain/gala-core-sdk";const n={HTTP_ERROR:`post_send`,UPDATE_REQUIRED:`post_send`,REQUEST_FAILED:`in_flight`,METHOD_NOT_SUPPORTED:`pre_send`,SUBMISSION_OUTCOME_UNKNOWN:`in_flight`,GATEWAY_REPORTED_ERROR:`post_send`,GATEWAY_DATA_MISSING:`post_send`,GATEWAY_MODE_INVALID:`post_send`,GATEWAY_SYNC_REQUEST_TRADE:`post_send`,MISSING_UNIQUE_KEY:`post_send`,UNIQUE_KEY_MISMATCH:`post_send`,SHADOW_NOT_QUEUED:`post_send`,SHADOW_SUBMIT_NEEDS_WALLET_ADDRESS:`pre_send`,METHOD_NOT_ALLOWED:`post_send`,SIGNATURE_INVALID:`post_send`,SIGNER_MISMATCH:`post_send`,DTO_INVALID:`post_send`,DTO_OPERATION_MISMATCH:`post_send`,BOUNDS_VIOLATION:`post_send`,SYMBOL_CONFLICT:`post_send`,RATE_LIMITED:`post_send`,CHAIN_DISPATCH_FAILED:`post_send`,GATEWAY_REJECTED:`post_send`,CHAIN_REJECTED:`post_send`,INVALID_CHAIN_RESPONSE:`post_send`,INVALID_POSITION_RESPONSE:`post_send`,CONFIRMATION_TIMEOUT:`post_send`,CONFIRMATION_ABORTED:`post_send`,CONFIRMATION_FAILED:`post_send`,CONFIRMATION_MALFORMED:`post_send`,CONFIRMATION_KEY_MISMATCH:`post_send`,NO_SIGNER:`pre_send`,NO_WALLET_ADDRESS:`post_send`,NO_POOL_AVAILABLE:`post_send`,INSUFFICIENT_LIQUIDITY:`post_send`,UNKNOWN_TOKEN:`pre_send`,SYMBOL_NOT_FOUND:`pre_send`,STREAM_API_KEY_UNUSABLE:`pre_send`,STREAM_WEBSOCKET_UNAVAILABLE:`pre_send`,STREAM_NOT_CONNECTED:`pre_send`,STREAM_DISCONNECTED:`in_flight`,STREAM_REQUEST_TIMEOUT:`in_flight`,STREAM_CONNECT_FAILED:`in_flight`,STREAM_CLOSED_BEFORE_CONNECT:`in_flight`,STREAM_CONNECTION_CLOSED:`in_flight`,TOKEN_RESOLUTION_FAILED:`pre_send`,MISSING_WALLET_ADDRESS:`pre_send`,NON_CANONICAL_PAIR:`pre_send`,UNORDERABLE_SYMBOLS:`pre_send`,INVALID_TOKEN_CLASS_KEY:`pre_send`,INCOMPLETE_TOKEN_CLASS_KEY:`pre_send`,INVALID_TRADING_SYMBOL:`pre_send`,NO_VALID_TRADING_SYMBOL:`pre_send`,TOKEN_SYMBOL_NOT_REGISTERED:`pre_send`,SYMBOL_DISAGREES_WITH_REGISTRY:`pre_send`,CREATE_POOL_NEEDS_CLASS_KEY:`pre_send`,AMOUNT_IS_JS_NUMBER:`pre_send`,AMOUNT_NOT_FINITE:`pre_send`,AMOUNT_NOT_POSITIVE:`pre_send`,AMOUNT_NEGATIVE:`pre_send`,PRICE_VALUES_IS_JS_NUMBER:`pre_send`,INVALID_PRICE_VALUES:`pre_send`,INVALID_PRICE_RANGE:`pre_send`,INVALID_PRICE_BOUNDS:`pre_send`,PRICE_BOUNDS_ORDER:`pre_send`,INVALID_STARTING_PRICE:`pre_send`,INVALID_SQRT_PRICE:`pre_send`,INVALID_TOKEN_DECIMALS:`pre_send`,TICKS_NOT_INTEGERS:`pre_send`,INVALID_TICK_RANGE:`pre_send`,TICKS_OUT_OF_BOUNDS:`pre_send`,TICKS_NOT_ALIGNED:`pre_send`,INVALID_TICK_SPACING:`pre_send`,INVALID_FEE:`pre_send`,EXACT_AMOUNT_REQUIRED:`pre_send`,EXACTLY_ONE_OF_REQUIRED:`pre_send`,AT_MOST_ONE_OF_ALLOWED:`pre_send`,POOL_MISMATCH:`pre_send`,INVALID_DTO:`pre_send`,DTO_NOT_CANONICAL:`pre_send`,SEARCH_TOO_LONG:`pre_send`,INVALID_SORT_BY:`pre_send`,INVALID_SORT_ORDER:`pre_send`,INVALID_PAGE:`pre_send`,INVALID_LIMIT:`pre_send`,INVALID_MARKET_TOKEN:`pre_send`,INVALID_TIMEFRAME:`pre_send`,INVALID_SEASON_ID:`pre_send`,INVALID_POLL_INTERVAL:`pre_send`};function r(e){return Object.hasOwn(n,e)}function i(e){return t(e)||r(e)}function a(i){return i.phase===void 0?t(i.code)?e[i.code]:r(i.code)?n[i.code]:void 0:i.phase}export{n as GSWAP_ERROR_PHASE_BY_CODE,i as isCatalogCode,a as phaseOfView};
|
|
2
2
|
//# sourceMappingURL=gswap_error_phase_table.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gswap_error_phase_table.js","names":["GSWAP_ERROR_PHASE_BY_CODE","isDexCatalogCode","code","isCatalogCode","isGalaCatalogCode","phaseOfView","view","GALA_ERROR_PHASE_BY_CODE"],"sources":["../../../src/classes/gswap_error_phase_table.ts"],"sourcesContent":["import {\n GALA_ERROR_PHASE_BY_CODE,\n isGalaCatalogCode,\n type FailureView,\n type GalaErrorPhase,\n} from '@gala-chain/gala-core-sdk';\nimport type { GSWAP_ERROR_CATALOG, GSwapErrorCode } from './gswap_error_catalog.js';\n\n/**\n * The phase of every DEX catalog code, WITHOUT the catalog. The failure guards (`classifyFailure`,\n * `mayHaveBeenQueued`, ...) need only a code's phase, and the catalog's English templates are\n * ~15 kB: reading the phase from here keeps an app shell that imports a guard from loading them.\n * The catalog entry is still where a code is declared; this table is checked against it AT\n * COMPILE TIME, in both directions (a missing code, an extra code or a different phase is a type\n * error), so the two cannot drift. The core codes' phases are core's `GALA_ERROR_PHASE_BY_CODE`.\n */\nexport const GSWAP_ERROR_PHASE_BY_CODE = {\n HTTP_ERROR: 'post_send',\n UPDATE_REQUIRED: 'post_send',\n REQUEST_FAILED: 'in_flight',\n METHOD_NOT_SUPPORTED: 'pre_send',\n SUBMISSION_OUTCOME_UNKNOWN: 'in_flight',\n GATEWAY_REPORTED_ERROR: 'post_send',\n GATEWAY_DATA_MISSING: 'post_send',\n GATEWAY_MODE_INVALID: 'post_send',\n GATEWAY_SYNC_REQUEST_TRADE: 'post_send',\n MISSING_UNIQUE_KEY: 'post_send',\n UNIQUE_KEY_MISMATCH: 'post_send',\n SHADOW_NOT_QUEUED: 'post_send',\n SHADOW_SUBMIT_NEEDS_WALLET_ADDRESS: 'pre_send',\n METHOD_NOT_ALLOWED: 'post_send',\n SIGNATURE_INVALID: 'post_send',\n SIGNER_MISMATCH: 'post_send',\n DTO_INVALID: 'post_send',\n BOUNDS_VIOLATION: 'post_send',\n SYMBOL_CONFLICT: 'post_send',\n RATE_LIMITED: 'post_send',\n CHAIN_DISPATCH_FAILED: 'post_send',\n GATEWAY_REJECTED: 'post_send',\n CHAIN_REJECTED: 'post_send',\n INVALID_CHAIN_RESPONSE: 'post_send',\n INVALID_POSITION_RESPONSE: 'post_send',\n CONFIRMATION_TIMEOUT: 'post_send',\n CONFIRMATION_ABORTED: 'post_send',\n CONFIRMATION_FAILED: 'post_send',\n CONFIRMATION_MALFORMED: 'post_send',\n CONFIRMATION_KEY_MISMATCH: 'post_send',\n NO_SIGNER: 'pre_send',\n NO_WALLET_ADDRESS: 'post_send',\n NO_POOL_AVAILABLE: 'post_send',\n INSUFFICIENT_LIQUIDITY: 'post_send',\n UNKNOWN_TOKEN: 'pre_send',\n SYMBOL_NOT_FOUND: 'pre_send',\n STREAM_API_KEY_UNUSABLE: 'pre_send',\n STREAM_WEBSOCKET_UNAVAILABLE: 'pre_send',\n STREAM_NOT_CONNECTED: 'pre_send',\n STREAM_DISCONNECTED: 'in_flight',\n STREAM_REQUEST_TIMEOUT: 'in_flight',\n STREAM_CONNECT_FAILED: 'in_flight',\n STREAM_CLOSED_BEFORE_CONNECT: 'in_flight',\n STREAM_CONNECTION_CLOSED: 'in_flight',\n TOKEN_RESOLUTION_FAILED: 'pre_send',\n MISSING_WALLET_ADDRESS: 'pre_send',\n NON_CANONICAL_PAIR: 'pre_send',\n UNORDERABLE_SYMBOLS: 'pre_send',\n INVALID_TOKEN_CLASS_KEY: 'pre_send',\n INCOMPLETE_TOKEN_CLASS_KEY: 'pre_send',\n INVALID_TRADING_SYMBOL: 'pre_send',\n NO_VALID_TRADING_SYMBOL: 'pre_send',\n TOKEN_SYMBOL_NOT_REGISTERED: 'pre_send',\n SYMBOL_DISAGREES_WITH_REGISTRY: 'pre_send',\n CREATE_POOL_NEEDS_CLASS_KEY: 'pre_send',\n AMOUNT_IS_JS_NUMBER: 'pre_send',\n AMOUNT_NOT_FINITE: 'pre_send',\n AMOUNT_NOT_POSITIVE: 'pre_send',\n AMOUNT_NEGATIVE: 'pre_send',\n PRICE_VALUES_IS_JS_NUMBER: 'pre_send',\n INVALID_PRICE_VALUES: 'pre_send',\n INVALID_PRICE_RANGE: 'pre_send',\n INVALID_PRICE_BOUNDS: 'pre_send',\n PRICE_BOUNDS_ORDER: 'pre_send',\n INVALID_STARTING_PRICE: 'pre_send',\n INVALID_SQRT_PRICE: 'pre_send',\n INVALID_TOKEN_DECIMALS: 'pre_send',\n TICKS_NOT_INTEGERS: 'pre_send',\n INVALID_TICK_RANGE: 'pre_send',\n TICKS_OUT_OF_BOUNDS: 'pre_send',\n TICKS_NOT_ALIGNED: 'pre_send',\n INVALID_TICK_SPACING: 'pre_send',\n INVALID_FEE: 'pre_send',\n EXACT_AMOUNT_REQUIRED: 'pre_send',\n EXACTLY_ONE_OF_REQUIRED: 'pre_send',\n AT_MOST_ONE_OF_ALLOWED: 'pre_send',\n POOL_MISMATCH: 'pre_send',\n INVALID_DTO: 'pre_send',\n DTO_NOT_CANONICAL: 'pre_send',\n SEARCH_TOO_LONG: 'pre_send',\n INVALID_SORT_BY: 'pre_send',\n INVALID_SORT_ORDER: 'pre_send',\n INVALID_PAGE: 'pre_send',\n INVALID_LIMIT: 'pre_send',\n INVALID_MARKET_TOKEN: 'pre_send',\n INVALID_TIMEFRAME: 'pre_send',\n INVALID_SEASON_ID: 'pre_send',\n INVALID_POLL_INTERVAL: 'pre_send',\n} as const satisfies {\n readonly [C in keyof typeof GSWAP_ERROR_CATALOG]: (typeof GSWAP_ERROR_CATALOG)[C]['phase'];\n};\n\n/** True for a DEX code (gswap-sdk's own catalog). */\nfunction isDexCatalogCode(code: string): code is keyof typeof GSWAP_ERROR_PHASE_BY_CODE {\n return Object.hasOwn(GSWAP_ERROR_PHASE_BY_CODE, code);\n}\n\n/** True for a code a `GSwapSDKError` can carry: a core code or a DEX code. */\nexport function isCatalogCode(code: string): code is GSwapErrorCode {\n return isGalaCatalogCode(code) || isDexCatalogCode(code);\n}\n\n/**\n * The phase of a view: the one it states, else the catalog's phase for its code (core's or the\n * DEX catalog's), else `undefined`.\n */\nexport function phaseOfView(view: FailureView): GalaErrorPhase | undefined {\n if (view.phase !== undefined) return view.phase;\n if (isGalaCatalogCode(view.code)) return GALA_ERROR_PHASE_BY_CODE[view.code];\n return isDexCatalogCode(view.code) ? GSWAP_ERROR_PHASE_BY_CODE[view.code] : undefined;\n}\n"],"mappings":"A,4FAgBA,MAAaA,EAA4B,CACvC,WAAY,YACZ,gBAAiB,YACjB,eAAgB,YAChB,qBAAsB,WACtB,2BAA4B,YAC5B,uBAAwB,YACxB,qBAAsB,YACtB,qBAAsB,YACtB,2BAA4B,YAC5B,mBAAoB,YACpB,oBAAqB,YACrB,kBAAmB,YACnB,mCAAoC,WACpC,mBAAoB,YACpB,kBAAmB,YACnB,gBAAiB,YACjB,YAAa,YACb,iBAAkB,YAClB,gBAAiB,YACjB,aAAc,YACd,sBAAuB,YACvB,iBAAkB,YAClB,eAAgB,YAChB,uBAAwB,YACxB,0BAA2B,YAC3B,qBAAsB,YACtB,qBAAsB,YACtB,oBAAqB,YACrB,uBAAwB,YACxB,0BAA2B,YAC3B,UAAW,WACX,kBAAmB,YACnB,kBAAmB,YACnB,uBAAwB,YACxB,cAAe,WACf,iBAAkB,WAClB,wBAAyB,WACzB,6BAA8B,WAC9B,qBAAsB,WACtB,oBAAqB,YACrB,uBAAwB,YACxB,sBAAuB,YACvB,6BAA8B,YAC9B,yBAA0B,YAC1B,wBAAyB,WACzB,uBAAwB,WACxB,mBAAoB,WACpB,oBAAqB,WACrB,wBAAyB,WACzB,2BAA4B,WAC5B,uBAAwB,WACxB,wBAAyB,WACzB,4BAA6B,WAC7B,+BAAgC,WAChC,4BAA6B,WAC7B,oBAAqB,WACrB,kBAAmB,WACnB,oBAAqB,WACrB,gBAAiB,WACjB,0BAA2B,WAC3B,qBAAsB,WACtB,oBAAqB,WACrB,qBAAsB,WACtB,mBAAoB,WACpB,uBAAwB,WACxB,mBAAoB,WACpB,uBAAwB,WACxB,mBAAoB,WACpB,mBAAoB,WACpB,oBAAqB,WACrB,kBAAmB,WACnB,qBAAsB,WACtB,YAAa,WACb,sBAAuB,WACvB,wBAAyB,WACzB,uBAAwB,WACxB,cAAe,WACf,YAAa,WACb,kBAAmB,WACnB,gBAAiB,WACjB,gBAAiB,WACjB,mBAAoB,WACpB,aAAc,WACd,cAAe,WACf,qBAAsB,WACtB,kBAAmB,WACnB,kBAAmB,WACnB,sBAAuB,UACzB,EAKA,SAASC,EAAiB,EAA8D,CACtF,OAAO,OAAO,OAAOD,EAA2BE,CAAI,CACtD,CAGA,SAAgBC,EAAc,EAAsC,CAClE,OAAOC,EAAkBF,CAAI,GAAKD,EAAiBC,CAAI,CACzD,CAMA,SAAgBG,EAAY,EAA+C,CAGzE,OAFIC,EAAK,QAAU,IAAA,GACfF,EAAkBE,EAAK,IAAI,EAAUC,EAAyBD,EAAK,MAChEL,EAAiBK,EAAK,IAAI,EAAIN,EAA0BM,EAAK,MAAQ,IAAA,GAFvCA,EAAK,KAG5C,C"}
|
|
1
|
+
{"version":3,"file":"gswap_error_phase_table.js","names":["GSWAP_ERROR_PHASE_BY_CODE","isDexCatalogCode","code","isCatalogCode","isGalaCatalogCode","phaseOfView","view","GALA_ERROR_PHASE_BY_CODE"],"sources":["../../../src/classes/gswap_error_phase_table.ts"],"sourcesContent":["import {\n GALA_ERROR_PHASE_BY_CODE,\n isGalaCatalogCode,\n type FailureView,\n type GalaErrorPhase,\n} from '@gala-chain/gala-core-sdk';\nimport type { GSWAP_ERROR_CATALOG, GSwapErrorCode } from './gswap_error_catalog.js';\n\n/**\n * The phase of every DEX catalog code, WITHOUT the catalog. The failure guards (`classifyFailure`,\n * `mayHaveBeenQueued`, ...) need only a code's phase, and the catalog's English templates are\n * ~15 kB: reading the phase from here keeps an app shell that imports a guard from loading them.\n * The catalog entry is still where a code is declared; this table is checked against it AT\n * COMPILE TIME, in both directions (a missing code, an extra code or a different phase is a type\n * error), so the two cannot drift. The core codes' phases are core's `GALA_ERROR_PHASE_BY_CODE`.\n */\nexport const GSWAP_ERROR_PHASE_BY_CODE = {\n HTTP_ERROR: 'post_send',\n UPDATE_REQUIRED: 'post_send',\n REQUEST_FAILED: 'in_flight',\n METHOD_NOT_SUPPORTED: 'pre_send',\n SUBMISSION_OUTCOME_UNKNOWN: 'in_flight',\n GATEWAY_REPORTED_ERROR: 'post_send',\n GATEWAY_DATA_MISSING: 'post_send',\n GATEWAY_MODE_INVALID: 'post_send',\n GATEWAY_SYNC_REQUEST_TRADE: 'post_send',\n MISSING_UNIQUE_KEY: 'post_send',\n UNIQUE_KEY_MISMATCH: 'post_send',\n SHADOW_NOT_QUEUED: 'post_send',\n SHADOW_SUBMIT_NEEDS_WALLET_ADDRESS: 'pre_send',\n METHOD_NOT_ALLOWED: 'post_send',\n SIGNATURE_INVALID: 'post_send',\n SIGNER_MISMATCH: 'post_send',\n DTO_INVALID: 'post_send',\n DTO_OPERATION_MISMATCH: 'post_send',\n BOUNDS_VIOLATION: 'post_send',\n SYMBOL_CONFLICT: 'post_send',\n RATE_LIMITED: 'post_send',\n CHAIN_DISPATCH_FAILED: 'post_send',\n GATEWAY_REJECTED: 'post_send',\n CHAIN_REJECTED: 'post_send',\n INVALID_CHAIN_RESPONSE: 'post_send',\n INVALID_POSITION_RESPONSE: 'post_send',\n CONFIRMATION_TIMEOUT: 'post_send',\n CONFIRMATION_ABORTED: 'post_send',\n CONFIRMATION_FAILED: 'post_send',\n CONFIRMATION_MALFORMED: 'post_send',\n CONFIRMATION_KEY_MISMATCH: 'post_send',\n NO_SIGNER: 'pre_send',\n NO_WALLET_ADDRESS: 'post_send',\n NO_POOL_AVAILABLE: 'post_send',\n INSUFFICIENT_LIQUIDITY: 'post_send',\n UNKNOWN_TOKEN: 'pre_send',\n SYMBOL_NOT_FOUND: 'pre_send',\n STREAM_API_KEY_UNUSABLE: 'pre_send',\n STREAM_WEBSOCKET_UNAVAILABLE: 'pre_send',\n STREAM_NOT_CONNECTED: 'pre_send',\n STREAM_DISCONNECTED: 'in_flight',\n STREAM_REQUEST_TIMEOUT: 'in_flight',\n STREAM_CONNECT_FAILED: 'in_flight',\n STREAM_CLOSED_BEFORE_CONNECT: 'in_flight',\n STREAM_CONNECTION_CLOSED: 'in_flight',\n TOKEN_RESOLUTION_FAILED: 'pre_send',\n MISSING_WALLET_ADDRESS: 'pre_send',\n NON_CANONICAL_PAIR: 'pre_send',\n UNORDERABLE_SYMBOLS: 'pre_send',\n INVALID_TOKEN_CLASS_KEY: 'pre_send',\n INCOMPLETE_TOKEN_CLASS_KEY: 'pre_send',\n INVALID_TRADING_SYMBOL: 'pre_send',\n NO_VALID_TRADING_SYMBOL: 'pre_send',\n TOKEN_SYMBOL_NOT_REGISTERED: 'pre_send',\n SYMBOL_DISAGREES_WITH_REGISTRY: 'pre_send',\n CREATE_POOL_NEEDS_CLASS_KEY: 'pre_send',\n AMOUNT_IS_JS_NUMBER: 'pre_send',\n AMOUNT_NOT_FINITE: 'pre_send',\n AMOUNT_NOT_POSITIVE: 'pre_send',\n AMOUNT_NEGATIVE: 'pre_send',\n PRICE_VALUES_IS_JS_NUMBER: 'pre_send',\n INVALID_PRICE_VALUES: 'pre_send',\n INVALID_PRICE_RANGE: 'pre_send',\n INVALID_PRICE_BOUNDS: 'pre_send',\n PRICE_BOUNDS_ORDER: 'pre_send',\n INVALID_STARTING_PRICE: 'pre_send',\n INVALID_SQRT_PRICE: 'pre_send',\n INVALID_TOKEN_DECIMALS: 'pre_send',\n TICKS_NOT_INTEGERS: 'pre_send',\n INVALID_TICK_RANGE: 'pre_send',\n TICKS_OUT_OF_BOUNDS: 'pre_send',\n TICKS_NOT_ALIGNED: 'pre_send',\n INVALID_TICK_SPACING: 'pre_send',\n INVALID_FEE: 'pre_send',\n EXACT_AMOUNT_REQUIRED: 'pre_send',\n EXACTLY_ONE_OF_REQUIRED: 'pre_send',\n AT_MOST_ONE_OF_ALLOWED: 'pre_send',\n POOL_MISMATCH: 'pre_send',\n INVALID_DTO: 'pre_send',\n DTO_NOT_CANONICAL: 'pre_send',\n SEARCH_TOO_LONG: 'pre_send',\n INVALID_SORT_BY: 'pre_send',\n INVALID_SORT_ORDER: 'pre_send',\n INVALID_PAGE: 'pre_send',\n INVALID_LIMIT: 'pre_send',\n INVALID_MARKET_TOKEN: 'pre_send',\n INVALID_TIMEFRAME: 'pre_send',\n INVALID_SEASON_ID: 'pre_send',\n INVALID_POLL_INTERVAL: 'pre_send',\n} as const satisfies {\n readonly [C in keyof typeof GSWAP_ERROR_CATALOG]: (typeof GSWAP_ERROR_CATALOG)[C]['phase'];\n};\n\n/** True for a DEX code (gswap-sdk's own catalog). */\nfunction isDexCatalogCode(code: string): code is keyof typeof GSWAP_ERROR_PHASE_BY_CODE {\n return Object.hasOwn(GSWAP_ERROR_PHASE_BY_CODE, code);\n}\n\n/** True for a code a `GSwapSDKError` can carry: a core code or a DEX code. */\nexport function isCatalogCode(code: string): code is GSwapErrorCode {\n return isGalaCatalogCode(code) || isDexCatalogCode(code);\n}\n\n/**\n * The phase of a view: the one it states, else the catalog's phase for its code (core's or the\n * DEX catalog's), else `undefined`.\n */\nexport function phaseOfView(view: FailureView): GalaErrorPhase | undefined {\n if (view.phase !== undefined) return view.phase;\n if (isGalaCatalogCode(view.code)) return GALA_ERROR_PHASE_BY_CODE[view.code];\n return isDexCatalogCode(view.code) ? GSWAP_ERROR_PHASE_BY_CODE[view.code] : undefined;\n}\n"],"mappings":"A,4FAgBA,MAAaA,EAA4B,CACvC,WAAY,YACZ,gBAAiB,YACjB,eAAgB,YAChB,qBAAsB,WACtB,2BAA4B,YAC5B,uBAAwB,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D,EAA2BE,CAAI,CACtD,CAGA,SAAgBC,EAAc,EAAsC,CAClE,OAAOC,EAAkBF,CAAI,GAAKD,EAAiBC,CAAI,CACzD,CAMA,SAAgBG,EAAY,EAA+C,CAGzE,OAFIC,EAAK,QAAU,IAAA,GACfF,EAAkBE,EAAK,IAAI,EAAUC,EAAyBD,EAAK,MAChEL,EAAiBK,EAAK,IAAI,EAAIN,EAA0BM,EAAK,MAAQ,IAAA,GAFvCA,EAAK,KAG5C,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{serverMessageOfBody as e}from"../utils/server_message.js";import{GSWAP_SDK_ERROR_ENTRIES as t}from"./gswap_error_catalog.js";import{phaseOfView as n}from"./gswap_error_phase_table.js";import r from"../_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/defineProperty.js";import{GalaSDKError as i,parseJson as a,toFailureView as o}from"@gala-chain/gala-core-sdk";const s=426;var c=class t extends i{constructor(e,t,n={}){super(e,t,n),this.name=`GSwapSDKError`}get notFound(){return super.notFound||this.code===`NO_POOL_AVAILABLE`||this.code===`UNKNOWN_TOKEN`}static noSignerError(){return new t(`NO_SIGNER`,{})}static noWalletAddressError(){return new t(`NO_WALLET_ADDRESS`,{})}static noPoolAvailableError(e,n,r,i){return new t(`NO_POOL_AVAILABLE`,{tokenIn:l(e),tokenOut:l(n),fee:u(r)},d(i))}static insufficientLiquidityError(e,n,r,i){return new t(`INSUFFICIENT_LIQUIDITY`,{tokenIn:l(e),tokenOut:l(n),fee:u(r)},d(i))}static fromGatewayBounce(e,n,r,i,a,o,s){let c={status:r,body:i,url:a,retryAfterMs:o,uniqueKey:s},l={serverMessage:n};switch(e){case`METHOD_NOT_ALLOWED`:return new t(`METHOD_NOT_ALLOWED`,l,c);case`SIGNATURE_INVALID`:return new t(`SIGNATURE_INVALID`,l,c);case`SIGNER_MISMATCH`:return new t(`SIGNER_MISMATCH`,l,c);case`DTO_INVALID`:return new t(`DTO_INVALID`,l,c);case`BOUNDS_VIOLATION`:return new t(`BOUNDS_VIOLATION`,l,c);case`SYMBOL_CONFLICT`:return new t(`SYMBOL_CONFLICT`,l,c);case`RATE_LIMITED`:return new t(`RATE_LIMITED`,l,c);case`CHAIN_DISPATCH_FAILED`:return new t(`CHAIN_DISPATCH_FAILED`,{...l,errorKey:h(i,`errorKey`)??``},c);default:return new t(`GATEWAY_REJECTED`,{gatewayCode:e,serverMessage:n},c)}}static fromChainError(e,n,r){return new t(`CHAIN_REJECTED`,{errorKey:e,serverMessage:n},r)}static unknownTokenError(e,n){return new t(`UNKNOWN_TOKEN`,{token:l(e)},d(n))}static confirmationTimeoutError(e,n){return new t(`CONFIRMATION_TIMEOUT`,{},{uniqueKey:e,cause:n})}static fromStatus(e,n={}){let{url:r,uniqueKey:i,write:a,serverMessage:o,body:s,retryAfterMs:c}=n,l=a??(i!==void 0&&i!==``);if(l&&(i===void 0||i===``))throw new t(`INVALID_UNIQUE_KEY`,{uniqueKey:i??``});let u={status:e,body:s,url:r,retryAfterMs:c,uniqueKey:l?i:void 0,write:l,phase:`post_send`};return e===426?new t(`UPDATE_REQUIRED`,{status:e},u):new t(`HTTP_ERROR`,{status:e,url:r??``,serverMessage:o??``},u)}static async fromErrorResponse(n,r){let i=await r.text(),o=a(i),s=m(o,`error`),c=h(s,`ErrorKey`),l=h(s,`Message`),u={status:r.status,body:o??i,url:n,write:!1};return r.status===426?new t(`UPDATE_REQUIRED`,{status:r.status},u):c!==void 0&&l!==void 0?new t(`CHAIN_REJECTED`,{errorKey:c,serverMessage:l},u):new t(`HTTP_ERROR`,{status:r.status,url:n,serverMessage:e(o)},u)}};r(c,`catalog`,t);function l(e){return typeof e==`string`?e:[e.collection,e.category,e.type,e.additionalKey].join(`$`)}function u(e){return e===void 0?`any`:String(e)}function d(e){return e===void 0?{}:{status:e.status,body:e.body??e.bodyText,url:e.url,phase:`post_send`,write:e.write}}function f(e,t){return e instanceof i&&(t===void 0||e.code===t)}function p(e){let t=o(e);return t!==void 0&&n(t)===`pre_send`}function m(e,t){if(typeof e!=`object`||!e||!(t in e))return;let n=e[t];return typeof n==`object`&&n?n:void 0}function h(e,t){if(typeof e!=`object`||!e||!(t in e))return;let n=e[t];return typeof n==`string`?n:void 0}export{c as GSwapSDKError,s as UPDATE_REQUIRED_STATUS,m as getObjectProperty,h as getStringProperty,f as isGSwapError,p as isPreSendError};
|
|
1
|
+
import{serverMessageOfBody as e}from"../utils/server_message.js";import{GSWAP_SDK_ERROR_ENTRIES as t}from"./gswap_error_catalog.js";import{phaseOfView as n}from"./gswap_error_phase_table.js";import r from"../_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/defineProperty.js";import{GalaSDKError as i,parseJson as a,toFailureView as o}from"@gala-chain/gala-core-sdk";const s=426;var c=class t extends i{constructor(e,t,n={}){super(e,t,n),this.name=`GSwapSDKError`}get notFound(){return super.notFound||this.code===`NO_POOL_AVAILABLE`||this.code===`UNKNOWN_TOKEN`}static noSignerError(){return new t(`NO_SIGNER`,{})}static noWalletAddressError(){return new t(`NO_WALLET_ADDRESS`,{})}static noPoolAvailableError(e,n,r,i){return new t(`NO_POOL_AVAILABLE`,{tokenIn:l(e),tokenOut:l(n),fee:u(r)},d(i))}static insufficientLiquidityError(e,n,r,i){return new t(`INSUFFICIENT_LIQUIDITY`,{tokenIn:l(e),tokenOut:l(n),fee:u(r)},d(i))}static fromGatewayBounce(e,n,r,i,a,o,s){let c={status:r,body:i,url:a,retryAfterMs:o,uniqueKey:s},l={serverMessage:n};switch(e){case`METHOD_NOT_ALLOWED`:return new t(`METHOD_NOT_ALLOWED`,l,c);case`SIGNATURE_INVALID`:return new t(`SIGNATURE_INVALID`,l,c);case`SIGNER_MISMATCH`:return new t(`SIGNER_MISMATCH`,l,c);case`DTO_INVALID`:return new t(`DTO_INVALID`,l,c);case`DTO_OPERATION_MISMATCH`:return new t(`DTO_OPERATION_MISMATCH`,l,c);case`BOUNDS_VIOLATION`:return new t(`BOUNDS_VIOLATION`,l,c);case`SYMBOL_CONFLICT`:return new t(`SYMBOL_CONFLICT`,l,c);case`RATE_LIMITED`:return new t(`RATE_LIMITED`,l,c);case`CHAIN_DISPATCH_FAILED`:return new t(`CHAIN_DISPATCH_FAILED`,{...l,errorKey:h(i,`errorKey`)??``},c);default:return new t(`GATEWAY_REJECTED`,{gatewayCode:e,serverMessage:n},c)}}static fromChainError(e,n,r){return new t(`CHAIN_REJECTED`,{errorKey:e,serverMessage:n},r)}static unknownTokenError(e,n){return new t(`UNKNOWN_TOKEN`,{token:l(e)},d(n))}static confirmationTimeoutError(e,n){return new t(`CONFIRMATION_TIMEOUT`,{},{uniqueKey:e,cause:n})}static fromStatus(e,n={}){let{url:r,uniqueKey:i,write:a,serverMessage:o,body:s,retryAfterMs:c}=n,l=a??(i!==void 0&&i!==``);if(l&&(i===void 0||i===``))throw new t(`INVALID_UNIQUE_KEY`,{uniqueKey:i??``});let u={status:e,body:s,url:r,retryAfterMs:c,uniqueKey:l?i:void 0,write:l,phase:`post_send`};return e===426?new t(`UPDATE_REQUIRED`,{status:e},u):new t(`HTTP_ERROR`,{status:e,url:r??``,serverMessage:o??``},u)}static async fromErrorResponse(n,r){let i=await r.text(),o=a(i),s=m(o,`error`),c=h(s,`ErrorKey`),l=h(s,`Message`),u={status:r.status,body:o??i,url:n,write:!1};return r.status===426?new t(`UPDATE_REQUIRED`,{status:r.status},u):c!==void 0&&l!==void 0?new t(`CHAIN_REJECTED`,{errorKey:c,serverMessage:l},u):new t(`HTTP_ERROR`,{status:r.status,url:n,serverMessage:e(o)},u)}};r(c,`catalog`,t);function l(e){return typeof e==`string`?e:[e.collection,e.category,e.type,e.additionalKey].join(`$`)}function u(e){return e===void 0?`any`:String(e)}function d(e){return e===void 0?{}:{status:e.status,body:e.body??e.bodyText,url:e.url,phase:`post_send`,write:e.write}}function f(e,t){return e instanceof i&&(t===void 0||e.code===t)}function p(e){let t=o(e);return t!==void 0&&n(t)===`pre_send`}function m(e,t){if(typeof e!=`object`||!e||!(t in e))return;let n=e[t];return typeof n==`object`&&n?n:void 0}function h(e,t){if(typeof e!=`object`||!e||!(t in e))return;let n=e[t];return typeof n==`string`?n:void 0}export{c as GSwapSDKError,s as UPDATE_REQUIRED_STATUS,m as getObjectProperty,h as getStringProperty,f as isGSwapError,p as isPreSendError};
|
|
2
2
|
//# sourceMappingURL=gswap_sdk_error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gswap_sdk_error.js","names":["_defineProperty","UPDATE_REQUIRED_STATUS","GSwapSDKError","GalaSDKError","code","params","context","tokenText","tokenIn","tokenOut","feeText","fee","sourceContext","source","gatewayCode","getStringProperty","body","token","options","isWrite","write","uniqueKey","status","url","serverMessage","bodyText","response","bodyJson","parseJson","errorObject","getObjectProperty","errorKey","message","serverMessageOfBody","GSWAP_SDK_ERROR_ENTRIES","isGSwapError","value","isPreSendError","view","toFailureView","phaseOfView","property","propertyValue"],"sources":["../../../src/classes/gswap_sdk_error.ts"],"sourcesContent":["import {\n GalaSDKError,\n parseJson,\n toFailureView,\n type GalaChainTokenClassKey,\n type GalaErrorContext,\n type HTTPResponse,\n} from '@gala-chain/gala-core-sdk';\nimport { serverMessageOfBody } from '../utils/server_message.js';\nimport {\n GSWAP_SDK_ERROR_ENTRIES,\n type GSwapErrorCode,\n type GSwapErrorParams,\n} from './gswap_error_catalog.js';\nimport { phaseOfView } from './gswap_error_phase_table.js';\n\n/**\n * The HTTP status of a version wall: the backend refuses an app version that is too old (HTTP 426\n * Upgrade Required). It is `UPDATE_REQUIRED` on every request the SDK sends, whatever else the body\n * says; a confirmation read keeps `CONFIRMATION_FAILED` because the write it confirms may be applied.\n */\nexport const UPDATE_REQUIRED_STATUS = 426;\n\n/** What {@link GSwapSDKError.fromStatus} may be told about the HTTP answer. */\nexport interface GSwapStatusErrorOptions {\n /** The URL the request went to. */\n url?: string | undefined;\n /** The signed `uniqueKey` of the WRITE the answer is for; its presence makes this a write. */\n uniqueKey?: string | undefined;\n /** Say it outright: `true` for a write (needs `uniqueKey`), `false` for a read. */\n write?: boolean | undefined;\n /** The server's own text, for `HTTP_ERROR.params.serverMessage` (`''` when none). */\n serverMessage?: string | undefined;\n /** The response body, kept as `error.body` (or `bodyText` for a string). */\n body?: unknown;\n /** How long the server asked to wait (`Retry-After`), in milliseconds. */\n retryAfterMs?: number | undefined;\n}\n\n/**\n * Error raised by gswap-sdk for validation, gateway, chain, or transaction failures. It is a\n * `GalaSDKError` (`@gala-chain/gala-core-sdk`), and can carry any code of the core catalog or of\n * gswap-sdk's own DEX catalog: the signing, transport and wallet failures of a gswap flow are core\n * codes, thrown either as a `GSwapSDKError` by gswap-sdk or as a plain `GalaSDKError` by core\n * itself (a signer, the fetch requestor). Catch both with `isGSwapError` (or core's `isGalaError`);\n * `instanceof GSwapSDKError` alone misses the second kind.\n *\n * Branch on {@link code} (stable) and render {@link params} through your own localization.\n * {@link message} is English generated from the catalog template for logs and developers: it\n * is not stable and must never be shown to a user or matched on.\n */\nexport class GSwapSDKError<C extends GSwapErrorCode = GSwapErrorCode> extends GalaSDKError<\n C,\n GSwapErrorParams<C>\n> {\n /** Core's catalog entries and the DEX entries: a `GSwapSDKError` can carry a code of either. */\n public static override readonly catalog = GSWAP_SDK_ERROR_ENTRIES;\n\n constructor(code: C, params: GSwapErrorParams<C>, context: GalaErrorContext = {}) {\n super(code, params, context);\n this.name = 'GSwapSDKError';\n }\n\n /**\n * True when the failure means \"that market, pool or position does not exist\" rather than\n * \"something went wrong\": an HTTP 404, a pair with no pool at any fee tier\n * (`NO_POOL_AVAILABLE`), or a token the DEX contract has no trading symbol for\n * (`UNKNOWN_TOKEN`). A pool that exists but is too thin (`INSUFFICIENT_LIQUIDITY`) is NOT\n * not-found.\n */\n public override get notFound(): boolean {\n return super.notFound || this.code === 'NO_POOL_AVAILABLE' || this.code === 'UNKNOWN_TOKEN';\n }\n\n /** Create the standard missing-signer error. */\n public static noSignerError(): GSwapSDKError<'NO_SIGNER'> {\n return new GSwapSDKError('NO_SIGNER', {});\n }\n\n /** Create the error used when confirming a position write without a configured wallet address. */\n public static noWalletAddressError(): GSwapSDKError<'NO_WALLET_ADDRESS'> {\n return new GSwapSDKError('NO_WALLET_ADDRESS', {});\n }\n\n /**\n * Create the error used when no pool can quote the requested pair. `source` is the backend\n * answer that said so; its status and body are kept.\n */\n public static noPoolAvailableError(\n tokenIn: GalaChainTokenClassKey | string,\n tokenOut: GalaChainTokenClassKey | string,\n fee?: number,\n source?: GSwapSDKError,\n ): GSwapSDKError<'NO_POOL_AVAILABLE'> {\n return new GSwapSDKError(\n 'NO_POOL_AVAILABLE',\n { tokenIn: tokenText(tokenIn), tokenOut: tokenText(tokenOut), fee: feeText(fee) },\n sourceContext(source),\n );\n }\n\n /** Create the error used when a pool lacks liquidity for a quote. `source` as for {@link noPoolAvailableError}. */\n public static insufficientLiquidityError(\n tokenIn: GalaChainTokenClassKey | string,\n tokenOut: GalaChainTokenClassKey | string,\n fee?: number,\n source?: GSwapSDKError,\n ): GSwapSDKError<'INSUFFICIENT_LIQUIDITY'> {\n return new GSwapSDKError(\n 'INSUFFICIENT_LIQUIDITY',\n { tokenIn: tokenText(tokenIn), tokenOut: tokenText(tokenOut), fee: feeText(fee) },\n sourceContext(source),\n );\n }\n\n /**\n * Convert a chain-gateway bounce into a typed SDK error: the gateway's own code when the SDK\n * knows it, `GATEWAY_REJECTED` (with the code as `params.gatewayCode`) when it does not.\n * `serverMessage` is the gateway's English text: for logs, not for a user interface. For\n * `CHAIN_DISPATCH_FAILED`, `params.errorKey` is the chain's `ErrorKey` from the body's\n * top-level `errorKey` (`''` when the gateway sent none): map it, not the text.\n */\n public static fromGatewayBounce(\n gatewayCode: string,\n serverMessage: string,\n status: number,\n body: unknown,\n url: string,\n retryAfterMs?: number,\n uniqueKey?: string,\n ): GSwapSDKError {\n const context: GalaErrorContext = { status, body, url, retryAfterMs, uniqueKey };\n const params = { serverMessage };\n switch (gatewayCode) {\n case 'METHOD_NOT_ALLOWED':\n return new GSwapSDKError('METHOD_NOT_ALLOWED', params, context);\n case 'SIGNATURE_INVALID':\n return new GSwapSDKError('SIGNATURE_INVALID', params, context);\n case 'SIGNER_MISMATCH':\n return new GSwapSDKError('SIGNER_MISMATCH', params, context);\n case 'DTO_INVALID':\n return new GSwapSDKError('DTO_INVALID', params, context);\n case 'BOUNDS_VIOLATION':\n return new GSwapSDKError('BOUNDS_VIOLATION', params, context);\n case 'SYMBOL_CONFLICT':\n return new GSwapSDKError('SYMBOL_CONFLICT', params, context);\n case 'RATE_LIMITED':\n return new GSwapSDKError('RATE_LIMITED', params, context);\n case 'CHAIN_DISPATCH_FAILED':\n // The gateway adds the chain's own machine-readable key as a top-level `errorKey`, only\n // when the chain supplied one; an older gateway sends none, which is the empty string.\n return new GSwapSDKError(\n 'CHAIN_DISPATCH_FAILED',\n { ...params, errorKey: getStringProperty(body, 'errorKey') ?? '' },\n context,\n );\n default:\n return new GSwapSDKError('GATEWAY_REJECTED', { gatewayCode, serverMessage }, context);\n }\n }\n\n /** Convert a GalaChain `Status: 0` response into a typed SDK error. */\n public static fromChainError(\n errorKey: string,\n serverMessage: string,\n context?: GalaErrorContext,\n ): GSwapSDKError<'CHAIN_REJECTED'> {\n return new GSwapSDKError('CHAIN_REJECTED', { errorKey, serverMessage }, context);\n }\n\n /**\n * Create the error used when a token is not registered by the current DEX contract. `source` is\n * the backend answer that said so (a quote); its status, body and url are kept.\n */\n public static unknownTokenError(\n token: GalaChainTokenClassKey | string,\n source?: GSwapSDKError,\n ): GSwapSDKError<'UNKNOWN_TOKEN'> {\n return new GSwapSDKError('UNKNOWN_TOKEN', { token: tokenText(token) }, sourceContext(source));\n }\n\n /** Create the error used when apply-results confirmation does not arrive in time. */\n public static confirmationTimeoutError(\n uniqueKey: string,\n cause?: unknown,\n ): GSwapSDKError<'CONFIRMATION_TIMEOUT'> {\n return new GSwapSDKError('CONFIRMATION_TIMEOUT', {}, { uniqueKey, cause });\n }\n\n /**\n * Builds, synchronously, the error the SDK itself throws for an HTTP answer of this `status`\n * that has no gateway or chain code: `UPDATE_REQUIRED` for the version wall (426, whatever\n * else is true), `HTTP_ERROR` for every other status. It is for an app that holds a resolved\n * HTTP answer the SDK did not read (a v1 endpoint, an interceptor's rejection) and wants the\n * SDK's classification of it (`classifyFailure`) instead of building the error by hand.\n *\n * Reads and writes differ exactly as they do in the gateway (`classifyFailure`): a WRITE\n * carries the signed `uniqueKey` (the handle to confirm it), a READ carries none. Pass\n * `uniqueKey` for a write, or `write: true` with it; `write: false` builds a read and drops any\n * `uniqueKey`. `write: true` without a non-empty `uniqueKey` throws `INVALID_UNIQUE_KEY`: a\n * write error with no key would be classified as a read, which is a different answer. Either\n * way an answer was read, so the phase is `post_send`.\n *\n * @example\n * ```ts\n * const read = GSwapSDKError.fromStatus(503, { url });\n * classifyFailure(read); // { outcome: 'transient', retryable: true }\n * const write = GSwapSDKError.fromStatus(503, { url, uniqueKey });\n * classifyFailure(write); // { outcome: 'unknown', retryable: false }: it may have been queued\n * classifyFailure(GSwapSDKError.fromStatus(426)); // invalid_input: only an update helps\n * ```\n */\n public static fromStatus(\n status: number,\n options: GSwapStatusErrorOptions = {},\n ): GSwapSDKError<'UPDATE_REQUIRED' | 'HTTP_ERROR'> {\n const { url, uniqueKey, write, serverMessage, body, retryAfterMs } = options;\n const isWrite = write ?? (uniqueKey !== undefined && uniqueKey !== '');\n if (isWrite && (uniqueKey === undefined || uniqueKey === '')) {\n throw new GSwapSDKError('INVALID_UNIQUE_KEY', { uniqueKey: uniqueKey ?? '' });\n }\n const context: GalaErrorContext = {\n status,\n body,\n url,\n retryAfterMs,\n uniqueKey: isWrite ? uniqueKey : undefined,\n write: isWrite,\n phase: 'post_send',\n };\n return status === UPDATE_REQUIRED_STATUS\n ? new GSwapSDKError('UPDATE_REQUIRED', { status }, context)\n : new GSwapSDKError(\n 'HTTP_ERROR',\n { status, url: url ?? '', serverMessage: serverMessage ?? '' },\n context,\n );\n }\n\n /** Convert an unexpected HTTP response into an SDK error. */\n public static async fromErrorResponse(\n url: string,\n response: HTTPResponse,\n ): Promise<GSwapSDKError> {\n const bodyText = await response.text();\n const bodyJson: unknown = parseJson(bodyText);\n const errorObject = getObjectProperty(bodyJson, 'error');\n const errorKey = getStringProperty(errorObject, 'ErrorKey');\n const message = getStringProperty(errorObject, 'Message');\n // Every request that goes through `HttpClient` is a READ (a quote, a list, an apply-results\n // GET); writes go through the gateway, which builds its own errors with the signed key.\n const context: GalaErrorContext = {\n status: response.status,\n body: bodyJson ?? bodyText,\n url,\n write: false,\n };\n\n if (response.status === UPDATE_REQUIRED_STATUS) {\n return new GSwapSDKError('UPDATE_REQUIRED', { status: response.status }, context);\n }\n\n if (errorKey !== undefined && message !== undefined) {\n return new GSwapSDKError('CHAIN_REJECTED', { errorKey, serverMessage: message }, context);\n }\n\n return new GSwapSDKError(\n 'HTTP_ERROR',\n { status: response.status, url, serverMessage: serverMessageOfBody(bodyJson) },\n context,\n );\n }\n}\n\n/** A token as the text a param carries: a string as is, a class key as its `$` composite. */\nfunction tokenText(token: GalaChainTokenClassKey | string): string {\n return typeof token === 'string'\n ? token\n : [token.collection, token.category, token.type, token.additionalKey].join('$');\n}\n\nfunction feeText(fee: number | undefined): string {\n return fee === undefined ? 'any' : String(fee);\n}\n\n/**\n * The HTTP facts of the error a classified error was derived from. An error derived from a\n * backend answer is `post_send`: the answer was read.\n */\nfunction sourceContext(source: GSwapSDKError | undefined): GalaErrorContext {\n if (source === undefined) return {};\n return {\n status: source.status,\n body: source.body ?? source.bodyText,\n url: source.url,\n phase: 'post_send',\n write: source.write,\n };\n}\n\n/** Any thrown value that is an SDK error of a gswap flow, narrowed to the union of every code. */\nexport type AnyGSwapError = { [C in GSwapErrorCode]: GSwapSDKError<C> }[GSwapErrorCode];\n\n/**\n * True when `value` is an SDK error a gswap flow can throw and, when `code` is given, carries\n * exactly that code. With a code, `error.params` narrows to that code's params.\n *\n * It recognises every `GalaSDKError` (`instanceof`), not only a `GSwapSDKError`: the signing,\n * transport and wallet failures of a gswap flow come from `@gala-chain/gala-core-sdk` (a signer,\n * the fetch requestor), carry a core code, and are core `GalaSDKError`s. For such an error the\n * fields are exactly a `GSwapSDKError`'s (`notFound` differs only for the DEX not-found codes,\n * which core never throws), so the narrowing holds for everything a gswap flow throws.\n *\n * @example\n * ```ts\n * if (isGSwapError(error, 'NON_CANONICAL_PAIR')) {\n * t('errors.NON_CANONICAL_PAIR', error.params); // { token0, token1 }\n * }\n * ```\n */\nexport function isGSwapError(value: unknown): value is AnyGSwapError;\nexport function isGSwapError<C extends GSwapErrorCode>(\n value: unknown,\n code: C,\n): value is GSwapSDKError<C>;\nexport function isGSwapError(value: unknown, code?: GSwapErrorCode): boolean {\n return value instanceof GalaSDKError && (code === undefined || value.code === code);\n}\n\n/**\n * True when `value` is an SDK error that was thrown BEFORE anything was transmitted\n * (`error.phase === 'pre_send'`): validation, symbol resolution, the signer, the wallet, a key\n * provider. A write that failed this way cannot have been queued, so the failure never calls for\n * \"confirm before you retry\". Every failure of an app-supplied callback that runs BEFORE the\n * request leaves reaches you as an SDK error of this kind (`SIGNING_FAILED`,\n * `KEY_PROVIDER_FAILED`, `TOKEN_RESOLUTION_FAILED`, the original error as `cause`), so an app\n * never needs an error class of its own to tell \"nothing was sent\" apart.\n *\n * Whether to offer Retry is `classifyFailure(error).retryable`, not this: a pre-send validation\n * error is pre-send too, and repeating the same call fails the same way.\n *\n * It also answers for a plain-object view of an SDK error (`{ code, phase? }`, see\n * `FailureView`): the view's own `phase`, else the catalog's phase for its `code` (a core code or\n * a DEX code). It is a plain `boolean`, not a type guard (a view is not a `GSwapSDKError`); use\n * `isGSwapError` to narrow.\n *\n * @example\n * ```ts\n * if (isPreSendError(error)) markNothingSent(); // no pending swap to confirm\n * ```\n */\nexport function isPreSendError(value: unknown): boolean {\n const view = toFailureView(value);\n return view !== undefined && phaseOfView(view) === 'pre_send';\n}\n\n/** Narrow an object property without trusting a cast at a network boundary. */\nexport function getObjectProperty(\n value: unknown,\n property: string,\n): Record<string, unknown> | undefined {\n if (typeof value !== 'object' || value === null || !(property in value)) return undefined;\n const propertyValue = (value as Record<string, unknown>)[property];\n return typeof propertyValue === 'object' && propertyValue !== null\n ? (propertyValue as Record<string, unknown>)\n : undefined;\n}\n\n/** Read a string property from an unknown object. */\nexport function getStringProperty(value: unknown, property: string): string | undefined {\n if (typeof value !== 'object' || value === null || !(property in value)) return undefined;\n const propertyValue = (value as Record<string, unknown>)[property];\n return typeof propertyValue === 'string' ? propertyValue : undefined;\n}\n"],"mappings":"A,iXAqBA,MAAaC,EAAyB,IA8BtC,IAAaC,EAAb,MAAaA,UAAiEC,CAG5E,CAIA,YAAY,EAAS,EAA6B,EAA4B,CAAC,EAAG,CAChF,MAAMC,EAAMC,EAAQC,CAAO,EAC3B,KAAK,KAAO,eACd,CASA,IAAoB,UAAoB,CACtC,OAAO,MAAM,UAAY,KAAK,OAAS,qBAAuB,KAAK,OAAS,eAC9E,CAGA,OAAc,eAA4C,CACxD,OAAO,IAAIJ,EAAc,YAAa,CAAC,CAAC,CAC1C,CAGA,OAAc,sBAA2D,CACvE,OAAO,IAAIA,EAAc,oBAAqB,CAAC,CAAC,CAClD,CAMA,OAAc,qBACZ,EACA,EACA,EACA,EACoC,CACpC,OAAO,IAAIA,EACT,oBACA,CAAE,QAASK,EAAUC,CAAO,EAAG,SAAUD,EAAUE,CAAQ,EAAG,IAAKC,EAAQC,CAAG,CAAE,EAChFC,EAAcC,CAAM,CACtB,CACF,CAGA,OAAc,2BACZ,EACA,EACA,EACA,EACyC,CACzC,OAAO,IAAIX,EACT,yBACA,CAAE,QAASK,EAAUC,CAAO,EAAG,SAAUD,EAAUE,CAAQ,EAAG,IAAKC,EAAQC,CAAG,CAAE,EAChFC,EAAcC,CAAM,CACtB,CACF,CASA,OAAc,kBACZ,EACA,EACA,EACA,EACA,EACA,EACA,EACe,CACf,IAAMP,EAA4B,CAAE,SAAQ,OAAM,MAAK,eAAc,WAAU,EACzED,EAAS,CAAE,eAAc,EAC/B,OAAQ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3B,CACL,OAAQA,EAAO,OACf,KAAMA,EAAO,MAAQA,EAAO,SAC5B,IAAKA,EAAO,IACZ,MAAO,YACP,MAAOA,EAAO,KAChB,CACF,CA2BA,SAAgBsB,EAAa,EAAgB,EAAgC,CAC3E,OAAOC,aAAiBjC,IAAiBC,IAAS,IAAA,IAAagC,EAAM,OAAShC,EAChF,CAwBA,SAAgBiC,EAAe,EAAyB,CACtD,IAAMC,EAAOC,EAAcH,CAAK,EAChC,OAAOE,IAAS,IAAA,IAAaE,EAAYF,CAAI,IAAM,UACrD,CAGA,SAAgBR,EACd,EACA,EACqC,CACrC,GAAI,OAAOM,GAAU,WAAYA,GAAkB,EAAEK,KAAYL,GAAQ,OACzE,IAAMM,EAAiBN,EAAkCK,GACzD,OAAO,OAAOC,GAAkB,UAAYA,EACvCA,EACD,IAAA,EACN,CAGA,SAAgB3B,EAAkB,EAAgB,EAAsC,CACtF,GAAI,OAAOqB,GAAU,WAAYA,GAAkB,EAAEK,KAAYL,GAAQ,OACzE,IAAMM,EAAiBN,EAAkCK,GACzD,OAAO,OAAOC,GAAkB,SAAWA,EAAgB,IAAA,EAC7D,C"}
|
|
1
|
+
{"version":3,"file":"gswap_sdk_error.js","names":["_defineProperty","UPDATE_REQUIRED_STATUS","GSwapSDKError","GalaSDKError","code","params","context","tokenText","tokenIn","tokenOut","feeText","fee","sourceContext","source","gatewayCode","getStringProperty","body","token","options","isWrite","write","uniqueKey","status","url","serverMessage","bodyText","response","bodyJson","parseJson","errorObject","getObjectProperty","errorKey","message","serverMessageOfBody","GSWAP_SDK_ERROR_ENTRIES","isGSwapError","value","isPreSendError","view","toFailureView","phaseOfView","property","propertyValue"],"sources":["../../../src/classes/gswap_sdk_error.ts"],"sourcesContent":["import {\n GalaSDKError,\n parseJson,\n toFailureView,\n type GalaChainTokenClassKey,\n type GalaErrorContext,\n type HTTPResponse,\n} from '@gala-chain/gala-core-sdk';\nimport { serverMessageOfBody } from '../utils/server_message.js';\nimport {\n GSWAP_SDK_ERROR_ENTRIES,\n type GSwapErrorCode,\n type GSwapErrorParams,\n} from './gswap_error_catalog.js';\nimport { phaseOfView } from './gswap_error_phase_table.js';\n\n/**\n * The HTTP status of a version wall: the backend refuses an app version that is too old (HTTP 426\n * Upgrade Required). It is `UPDATE_REQUIRED` on every request the SDK sends, whatever else the body\n * says; a confirmation read keeps `CONFIRMATION_FAILED` because the write it confirms may be applied.\n */\nexport const UPDATE_REQUIRED_STATUS = 426;\n\n/** What {@link GSwapSDKError.fromStatus} may be told about the HTTP answer. */\nexport interface GSwapStatusErrorOptions {\n /** The URL the request went to. */\n url?: string | undefined;\n /** The signed `uniqueKey` of the WRITE the answer is for; its presence makes this a write. */\n uniqueKey?: string | undefined;\n /** Say it outright: `true` for a write (needs `uniqueKey`), `false` for a read. */\n write?: boolean | undefined;\n /** The server's own text, for `HTTP_ERROR.params.serverMessage` (`''` when none). */\n serverMessage?: string | undefined;\n /** The response body, kept as `error.body` (or `bodyText` for a string). */\n body?: unknown;\n /** How long the server asked to wait (`Retry-After`), in milliseconds. */\n retryAfterMs?: number | undefined;\n}\n\n/**\n * Error raised by gswap-sdk for validation, gateway, chain, or transaction failures. It is a\n * `GalaSDKError` (`@gala-chain/gala-core-sdk`), and can carry any code of the core catalog or of\n * gswap-sdk's own DEX catalog: the signing, transport and wallet failures of a gswap flow are core\n * codes, thrown either as a `GSwapSDKError` by gswap-sdk or as a plain `GalaSDKError` by core\n * itself (a signer, the fetch requestor). Catch both with `isGSwapError` (or core's `isGalaError`);\n * `instanceof GSwapSDKError` alone misses the second kind.\n *\n * Branch on {@link code} (stable) and render {@link params} through your own localization.\n * {@link message} is English generated from the catalog template for logs and developers: it\n * is not stable and must never be shown to a user or matched on.\n */\nexport class GSwapSDKError<C extends GSwapErrorCode = GSwapErrorCode> extends GalaSDKError<\n C,\n GSwapErrorParams<C>\n> {\n /** Core's catalog entries and the DEX entries: a `GSwapSDKError` can carry a code of either. */\n public static override readonly catalog = GSWAP_SDK_ERROR_ENTRIES;\n\n constructor(code: C, params: GSwapErrorParams<C>, context: GalaErrorContext = {}) {\n super(code, params, context);\n this.name = 'GSwapSDKError';\n }\n\n /**\n * True when the failure means \"that market, pool or position does not exist\" rather than\n * \"something went wrong\": an HTTP 404, a pair with no pool at any fee tier\n * (`NO_POOL_AVAILABLE`), or a token the DEX contract has no trading symbol for\n * (`UNKNOWN_TOKEN`). A pool that exists but is too thin (`INSUFFICIENT_LIQUIDITY`) is NOT\n * not-found.\n */\n public override get notFound(): boolean {\n return super.notFound || this.code === 'NO_POOL_AVAILABLE' || this.code === 'UNKNOWN_TOKEN';\n }\n\n /** Create the standard missing-signer error. */\n public static noSignerError(): GSwapSDKError<'NO_SIGNER'> {\n return new GSwapSDKError('NO_SIGNER', {});\n }\n\n /** Create the error used when confirming a position write without a configured wallet address. */\n public static noWalletAddressError(): GSwapSDKError<'NO_WALLET_ADDRESS'> {\n return new GSwapSDKError('NO_WALLET_ADDRESS', {});\n }\n\n /**\n * Create the error used when no pool can quote the requested pair. `source` is the backend\n * answer that said so; its status and body are kept.\n */\n public static noPoolAvailableError(\n tokenIn: GalaChainTokenClassKey | string,\n tokenOut: GalaChainTokenClassKey | string,\n fee?: number,\n source?: GSwapSDKError,\n ): GSwapSDKError<'NO_POOL_AVAILABLE'> {\n return new GSwapSDKError(\n 'NO_POOL_AVAILABLE',\n { tokenIn: tokenText(tokenIn), tokenOut: tokenText(tokenOut), fee: feeText(fee) },\n sourceContext(source),\n );\n }\n\n /** Create the error used when a pool lacks liquidity for a quote. `source` as for {@link noPoolAvailableError}. */\n public static insufficientLiquidityError(\n tokenIn: GalaChainTokenClassKey | string,\n tokenOut: GalaChainTokenClassKey | string,\n fee?: number,\n source?: GSwapSDKError,\n ): GSwapSDKError<'INSUFFICIENT_LIQUIDITY'> {\n return new GSwapSDKError(\n 'INSUFFICIENT_LIQUIDITY',\n { tokenIn: tokenText(tokenIn), tokenOut: tokenText(tokenOut), fee: feeText(fee) },\n sourceContext(source),\n );\n }\n\n /**\n * Convert a chain-gateway bounce into a typed SDK error: the gateway's own code when the SDK\n * knows it, `GATEWAY_REJECTED` (with the code as `params.gatewayCode`) when it does not.\n * `serverMessage` is the gateway's English text: for logs, not for a user interface. For\n * `CHAIN_DISPATCH_FAILED`, `params.errorKey` is the chain's `ErrorKey` from the body's\n * top-level `errorKey` (`''` when the gateway sent none): map it, not the text.\n */\n public static fromGatewayBounce(\n gatewayCode: string,\n serverMessage: string,\n status: number,\n body: unknown,\n url: string,\n retryAfterMs?: number,\n uniqueKey?: string,\n ): GSwapSDKError {\n const context: GalaErrorContext = { status, body, url, retryAfterMs, uniqueKey };\n const params = { serverMessage };\n switch (gatewayCode) {\n case 'METHOD_NOT_ALLOWED':\n return new GSwapSDKError('METHOD_NOT_ALLOWED', params, context);\n case 'SIGNATURE_INVALID':\n return new GSwapSDKError('SIGNATURE_INVALID', params, context);\n case 'SIGNER_MISMATCH':\n return new GSwapSDKError('SIGNER_MISMATCH', params, context);\n case 'DTO_INVALID':\n return new GSwapSDKError('DTO_INVALID', params, context);\n case 'DTO_OPERATION_MISMATCH':\n return new GSwapSDKError('DTO_OPERATION_MISMATCH', params, context);\n case 'BOUNDS_VIOLATION':\n return new GSwapSDKError('BOUNDS_VIOLATION', params, context);\n case 'SYMBOL_CONFLICT':\n return new GSwapSDKError('SYMBOL_CONFLICT', params, context);\n case 'RATE_LIMITED':\n return new GSwapSDKError('RATE_LIMITED', params, context);\n case 'CHAIN_DISPATCH_FAILED':\n // The gateway adds the chain's own machine-readable key as a top-level `errorKey`, only\n // when the chain supplied one; an older gateway sends none, which is the empty string.\n return new GSwapSDKError(\n 'CHAIN_DISPATCH_FAILED',\n { ...params, errorKey: getStringProperty(body, 'errorKey') ?? '' },\n context,\n );\n default:\n return new GSwapSDKError('GATEWAY_REJECTED', { gatewayCode, serverMessage }, context);\n }\n }\n\n /** Convert a GalaChain `Status: 0` response into a typed SDK error. */\n public static fromChainError(\n errorKey: string,\n serverMessage: string,\n context?: GalaErrorContext,\n ): GSwapSDKError<'CHAIN_REJECTED'> {\n return new GSwapSDKError('CHAIN_REJECTED', { errorKey, serverMessage }, context);\n }\n\n /**\n * Create the error used when a token is not registered by the current DEX contract. `source` is\n * the backend answer that said so (a quote); its status, body and url are kept.\n */\n public static unknownTokenError(\n token: GalaChainTokenClassKey | string,\n source?: GSwapSDKError,\n ): GSwapSDKError<'UNKNOWN_TOKEN'> {\n return new GSwapSDKError('UNKNOWN_TOKEN', { token: tokenText(token) }, sourceContext(source));\n }\n\n /** Create the error used when apply-results confirmation does not arrive in time. */\n public static confirmationTimeoutError(\n uniqueKey: string,\n cause?: unknown,\n ): GSwapSDKError<'CONFIRMATION_TIMEOUT'> {\n return new GSwapSDKError('CONFIRMATION_TIMEOUT', {}, { uniqueKey, cause });\n }\n\n /**\n * Builds, synchronously, the error the SDK itself throws for an HTTP answer of this `status`\n * that has no gateway or chain code: `UPDATE_REQUIRED` for the version wall (426, whatever\n * else is true), `HTTP_ERROR` for every other status. It is for an app that holds a resolved\n * HTTP answer the SDK did not read (a v1 endpoint, an interceptor's rejection) and wants the\n * SDK's classification of it (`classifyFailure`) instead of building the error by hand.\n *\n * Reads and writes differ exactly as they do in the gateway (`classifyFailure`): a WRITE\n * carries the signed `uniqueKey` (the handle to confirm it), a READ carries none. Pass\n * `uniqueKey` for a write, or `write: true` with it; `write: false` builds a read and drops any\n * `uniqueKey`. `write: true` without a non-empty `uniqueKey` throws `INVALID_UNIQUE_KEY`: a\n * write error with no key would be classified as a read, which is a different answer. Either\n * way an answer was read, so the phase is `post_send`.\n *\n * @example\n * ```ts\n * const read = GSwapSDKError.fromStatus(503, { url });\n * classifyFailure(read); // { outcome: 'transient', retryable: true }\n * const write = GSwapSDKError.fromStatus(503, { url, uniqueKey });\n * classifyFailure(write); // { outcome: 'unknown', retryable: false }: it may have been queued\n * classifyFailure(GSwapSDKError.fromStatus(426)); // invalid_input: only an update helps\n * ```\n */\n public static fromStatus(\n status: number,\n options: GSwapStatusErrorOptions = {},\n ): GSwapSDKError<'UPDATE_REQUIRED' | 'HTTP_ERROR'> {\n const { url, uniqueKey, write, serverMessage, body, retryAfterMs } = options;\n const isWrite = write ?? (uniqueKey !== undefined && uniqueKey !== '');\n if (isWrite && (uniqueKey === undefined || uniqueKey === '')) {\n throw new GSwapSDKError('INVALID_UNIQUE_KEY', { uniqueKey: uniqueKey ?? '' });\n }\n const context: GalaErrorContext = {\n status,\n body,\n url,\n retryAfterMs,\n uniqueKey: isWrite ? uniqueKey : undefined,\n write: isWrite,\n phase: 'post_send',\n };\n return status === UPDATE_REQUIRED_STATUS\n ? new GSwapSDKError('UPDATE_REQUIRED', { status }, context)\n : new GSwapSDKError(\n 'HTTP_ERROR',\n { status, url: url ?? '', serverMessage: serverMessage ?? '' },\n context,\n );\n }\n\n /** Convert an unexpected HTTP response into an SDK error. */\n public static async fromErrorResponse(\n url: string,\n response: HTTPResponse,\n ): Promise<GSwapSDKError> {\n const bodyText = await response.text();\n const bodyJson: unknown = parseJson(bodyText);\n const errorObject = getObjectProperty(bodyJson, 'error');\n const errorKey = getStringProperty(errorObject, 'ErrorKey');\n const message = getStringProperty(errorObject, 'Message');\n // Every request that goes through `HttpClient` is a READ (a quote, a list, an apply-results\n // GET); writes go through the gateway, which builds its own errors with the signed key.\n const context: GalaErrorContext = {\n status: response.status,\n body: bodyJson ?? bodyText,\n url,\n write: false,\n };\n\n if (response.status === UPDATE_REQUIRED_STATUS) {\n return new GSwapSDKError('UPDATE_REQUIRED', { status: response.status }, context);\n }\n\n if (errorKey !== undefined && message !== undefined) {\n return new GSwapSDKError('CHAIN_REJECTED', { errorKey, serverMessage: message }, context);\n }\n\n return new GSwapSDKError(\n 'HTTP_ERROR',\n { status: response.status, url, serverMessage: serverMessageOfBody(bodyJson) },\n context,\n );\n }\n}\n\n/** A token as the text a param carries: a string as is, a class key as its `$` composite. */\nfunction tokenText(token: GalaChainTokenClassKey | string): string {\n return typeof token === 'string'\n ? token\n : [token.collection, token.category, token.type, token.additionalKey].join('$');\n}\n\nfunction feeText(fee: number | undefined): string {\n return fee === undefined ? 'any' : String(fee);\n}\n\n/**\n * The HTTP facts of the error a classified error was derived from. An error derived from a\n * backend answer is `post_send`: the answer was read.\n */\nfunction sourceContext(source: GSwapSDKError | undefined): GalaErrorContext {\n if (source === undefined) return {};\n return {\n status: source.status,\n body: source.body ?? source.bodyText,\n url: source.url,\n phase: 'post_send',\n write: source.write,\n };\n}\n\n/** Any thrown value that is an SDK error of a gswap flow, narrowed to the union of every code. */\nexport type AnyGSwapError = { [C in GSwapErrorCode]: GSwapSDKError<C> }[GSwapErrorCode];\n\n/**\n * True when `value` is an SDK error a gswap flow can throw and, when `code` is given, carries\n * exactly that code. With a code, `error.params` narrows to that code's params.\n *\n * It recognises every `GalaSDKError` (`instanceof`), not only a `GSwapSDKError`: the signing,\n * transport and wallet failures of a gswap flow come from `@gala-chain/gala-core-sdk` (a signer,\n * the fetch requestor), carry a core code, and are core `GalaSDKError`s. For such an error the\n * fields are exactly a `GSwapSDKError`'s (`notFound` differs only for the DEX not-found codes,\n * which core never throws), so the narrowing holds for everything a gswap flow throws.\n *\n * @example\n * ```ts\n * if (isGSwapError(error, 'NON_CANONICAL_PAIR')) {\n * t('errors.NON_CANONICAL_PAIR', error.params); // { token0, token1 }\n * }\n * ```\n */\nexport function isGSwapError(value: unknown): value is AnyGSwapError;\nexport function isGSwapError<C extends GSwapErrorCode>(\n value: unknown,\n code: C,\n): value is GSwapSDKError<C>;\nexport function isGSwapError(value: unknown, code?: GSwapErrorCode): boolean {\n return value instanceof GalaSDKError && (code === undefined || value.code === code);\n}\n\n/**\n * True when `value` is an SDK error that was thrown BEFORE anything was transmitted\n * (`error.phase === 'pre_send'`): validation, symbol resolution, the signer, the wallet, a key\n * provider. A write that failed this way cannot have been queued, so the failure never calls for\n * \"confirm before you retry\". Every failure of an app-supplied callback that runs BEFORE the\n * request leaves reaches you as an SDK error of this kind (`SIGNING_FAILED`,\n * `KEY_PROVIDER_FAILED`, `TOKEN_RESOLUTION_FAILED`, the original error as `cause`), so an app\n * never needs an error class of its own to tell \"nothing was sent\" apart.\n *\n * Whether to offer Retry is `classifyFailure(error).retryable`, not this: a pre-send validation\n * error is pre-send too, and repeating the same call fails the same way.\n *\n * It also answers for a plain-object view of an SDK error (`{ code, phase? }`, see\n * `FailureView`): the view's own `phase`, else the catalog's phase for its `code` (a core code or\n * a DEX code). It is a plain `boolean`, not a type guard (a view is not a `GSwapSDKError`); use\n * `isGSwapError` to narrow.\n *\n * @example\n * ```ts\n * if (isPreSendError(error)) markNothingSent(); // no pending swap to confirm\n * ```\n */\nexport function isPreSendError(value: unknown): boolean {\n const view = toFailureView(value);\n return view !== undefined && phaseOfView(view) === 'pre_send';\n}\n\n/** Narrow an object property without trusting a cast at a network boundary. */\nexport function getObjectProperty(\n value: unknown,\n property: string,\n): Record<string, unknown> | undefined {\n if (typeof value !== 'object' || value === null || !(property in value)) return undefined;\n const propertyValue = (value as Record<string, unknown>)[property];\n return typeof propertyValue === 'object' && propertyValue !== null\n ? (propertyValue as Record<string, unknown>)\n : undefined;\n}\n\n/** Read a string property from an unknown object. */\nexport function getStringProperty(value: unknown, property: string): string | undefined {\n if (typeof value !== 'object' || value === null || !(property in value)) return undefined;\n const propertyValue = (value as Record<string, unknown>)[property];\n return typeof propertyValue === 'string' ? propertyValue : undefined;\n}\n"],"mappings":"A,iXAqBA,MAAaC,EAAyB,IA8BtC,IAAaC,EAAb,MAAaA,UAAiEC,CAG5E,CAIA,YAAY,EAAS,EAA6B,EAA4B,CAAC,EAAG,CAChF,MAAMC,EAAMC,EAAQC,CAAO,EAC3B,KAAK,KAAO,eACd,CASA,IAAoB,UAAoB,CACtC,OAAO,MAAM,UAAY,KAAK,OAAS,qBAAuB,KAAK,OAAS,eAC9E,CAGA,OAAc,eAA4C,CACxD,OAAO,IAAIJ,EAAc,YAAa,CAAC,CAAC,CAC1C,CAGA,OAAc,sBAA2D,CACvE,OAAO,IAAIA,EAAc,o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IAAMM,EAAiBN,EAAkCK,GACzD,OAAO,OAAOC,GAAkB,SAAWA,EAAgB,IAAA,EAC7D,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{isCatalogCode as e}from"../classes/gswap_error_phase_table.js";import{NOT_QUEUED_FINAL as t,classification as n}from"./classification.js";import{isWriteView as r,numberParamOf as i,stringParamOf as a,toFailureView as o}from"@gala-chain/gala-core-sdk";const s=n(`rejected`),c=n(`unknown`),l=n(`not_queued`),u=n(`not_sent`),d=n(`invalid_input`),f=n(`transient`),p={REQUEST_TIMEOUT:f,TRANSPORT_ERROR:f,REQUEST_FAILED:f,SUBMISSION_OUTCOME_UNKNOWN:c,GATEWAY_REPORTED_ERROR:c,GATEWAY_DATA_MISSING:c,GATEWAY_MODE_INVALID:c,GATEWAY_SYNC_REQUEST_TRADE:c,MISSING_UNIQUE_KEY:c,UNIQUE_KEY_MISMATCH:c,GATEWAY_WRITE_OUTCOME_UNKNOWN:c,GATEWAY_RESPONSE_INVALID:c,BRIDGE_RESPONSE_INVALID:c,BRIDGE_WRITE_OUTCOME_UNKNOWN:c,BRIDGE_OUT_OUTCOME_UNKNOWN:c,BRIDGE_DEPOSIT_OUTCOME_UNKNOWN:c,BRIDGE_STATUS_TIMEOUT:c,SHADOW_NOT_QUEUED:t,METHOD_NOT_ALLOWED:l,SIGNATURE_INVALID:l,SIGNER_MISMATCH:l,DTO_INVALID:
|
|
1
|
+
import{isCatalogCode as e}from"../classes/gswap_error_phase_table.js";import{NOT_QUEUED_FINAL as t,classification as n}from"./classification.js";import{isWriteView as r,numberParamOf as i,stringParamOf as a,toFailureView as o}from"@gala-chain/gala-core-sdk";const s=n(`rejected`),c=n(`unknown`),l=n(`not_queued`),u=n(`not_sent`),d=n(`invalid_input`),f=n(`transient`),p={REQUEST_TIMEOUT:f,TRANSPORT_ERROR:f,REQUEST_FAILED:f,SUBMISSION_OUTCOME_UNKNOWN:c,GATEWAY_REPORTED_ERROR:c,GATEWAY_DATA_MISSING:c,GATEWAY_MODE_INVALID:c,GATEWAY_SYNC_REQUEST_TRADE:c,MISSING_UNIQUE_KEY:c,UNIQUE_KEY_MISMATCH:c,GATEWAY_WRITE_OUTCOME_UNKNOWN:c,GATEWAY_RESPONSE_INVALID:c,BRIDGE_RESPONSE_INVALID:c,BRIDGE_WRITE_OUTCOME_UNKNOWN:c,BRIDGE_OUT_OUTCOME_UNKNOWN:c,BRIDGE_DEPOSIT_OUTCOME_UNKNOWN:c,BRIDGE_STATUS_TIMEOUT:c,SHADOW_NOT_QUEUED:t,METHOD_NOT_ALLOWED:l,SIGNATURE_INVALID:l,SIGNER_MISMATCH:l,DTO_INVALID:t,DTO_OPERATION_MISMATCH:t,BOUNDS_VIOLATION:l,SYMBOL_CONFLICT:l,RATE_LIMITED:l,GATEWAY_REJECTED:l,CHAIN_REJECTED:s,INVALID_CHAIN_RESPONSE:f,INVALID_POSITION_RESPONSE:f,GATEWAY_READ_REJECTED:f,GATEWAY_READ_RESPONSE_INVALID:f,BRIDGE_READ_RESPONSE_INVALID:f,BRIDGE_TOKEN_NOT_FOUND:d,TOKEN_NOT_WRAPPABLE:d,BRIDGE_CHAIN_READ_FAILED:f,TOKEN_CLASS_NOT_FOUND:d,PAGINATION_LIMIT_EXCEEDED:d,CONFIRMATION_TIMEOUT:c,CONFIRMATION_ABORTED:c,CONFIRMATION_FAILED:c,CONFIRMATION_MALFORMED:c,CONFIRMATION_KEY_MISMATCH:c,STREAM_DISCONNECTED:f,STREAM_REQUEST_TIMEOUT:f,STREAM_CONNECT_FAILED:f,STREAM_CLOSED_BEFORE_CONNECT:f,STREAM_CONNECTION_CLOSED:f,SIGNING_FAILED:u,KEY_PROVIDER_FAILED:u,TOKEN_RESOLUTION_FAILED:u,TOKEN_NAME_RESOLUTION_FAILED:u,NO_WALLET_ADDRESS:d,NO_POOL_AVAILABLE:d,INSUFFICIENT_LIQUIDITY:d};function m(e){return a(e,`reason`)===`no_key_provided`?u:d}function h(e){return e.status??i(e,`status`)}function g(e){let n=h(e);return n===void 0?c:r(e)?n===429?l:n===408||n>=500?c:t:n===408||n===429||n>=500?f:d}function _(e){return r(e)&&h(e)===409?c:g(e)}function v(e){return r(e)?t:d}function y(e){let t=e.status;return t===void 0||t===409||t>=500?c:t===422?s:l}function b(e){let t=e.status;return t===void 0||t===409||t>=500?c:s}function x(e,t={}){let n=S(o(e));return t.afterQueued===!0&&n.outcome!==`rejected`?{...n,retryable:!1}:n}function S(t){if(t===void 0)return{...c};if(!e(t.code))return t.outcome===void 0?{...c}:t.retryable===!1?n(t.outcome,{retryable:!1}):n(t.outcome);let{code:r}=t;return r===`HTTP_ERROR`||r===`GATEWAY_HTTP_ERROR`?{...g(t)}:r===`GALACONNECT_HTTP_ERROR`?{..._(t)}:r===`GATEWAY_WRITE_REJECTED`||r===`BRIDGE_REQUEST_REJECTED`?{...b(t)}:r===`UPDATE_REQUIRED`?{...v(t)}:r===`CHAIN_DISPATCH_FAILED`?{...y(t)}:r===`INVALID_PRIVATE_KEY`?{...m(t)}:{...p[r]??d}}function C(e){return x(e).outcome===`unknown`}export{x as classifyFailure,C as mayHaveBeenQueued};
|
|
2
2
|
//# sourceMappingURL=failure_classification.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"failure_classification.js","names":["REJECTED","classification","UNKNOWN","NOT_QUEUED","NOT_SENT","INVALID_INPUT","TRANSIENT","BY_CODE","NOT_QUEUED_FINAL","classifyInvalidPrivateKey","stringParamOf","view","statusOfView","numberParamOf","classifyHttpError","status","isWriteView","classifyGalaConnectHttpError","classifyUpdateRequired","classifyChainDispatchFailed","classifyGatewayWriteRejected","classifyFailure","result","classifyView","toFailureView","error","options","isCatalogCode","code","mayHaveBeenQueued"],"sources":["../../../src/utils/failure_classification.ts"],"sourcesContent":["import {\n isWriteView,\n numberParamOf,\n stringParamOf,\n toFailureView,\n type FailureView,\n type GALA_ERROR_CATALOG,\n} from '@gala-chain/gala-core-sdk';\nimport type { GSWAP_ERROR_CATALOG, GSwapErrorCode } from '../classes/gswap_error_catalog.js';\nimport { isCatalogCode } from '../classes/gswap_error_phase_table.js';\nimport { classification, NOT_QUEUED_FINAL, type FailureClassification } from './classification.js';\n\n/**\n * `classifyFailure` and `mayHaveBeenQueued`: the one module that holds the decision for every\n * catalog code (~135 names, a floor no minifier can remove). It needs the code table and nothing\n * else: the classification values live in `classification.ts`, the yes/no guards in\n * `failure_guards.ts`, and the error class and catalog are only named as types.\n */\n\nconst REJECTED: FailureClassification = classification('rejected');\nconst UNKNOWN: FailureClassification = classification('unknown');\nconst NOT_QUEUED: FailureClassification = classification('not_queued');\nconst NOT_SENT: FailureClassification = classification('not_sent');\nconst INVALID_INPUT: FailureClassification = classification('invalid_input');\nconst TRANSIENT: FailureClassification = classification('transient');\n\n/**\n * The classification of every code whose meaning does not depend on the failing answer. A code\n * missing here is a compile error (unless it is `pre_send`, see {@link CodeTable}), so adding a\n * catalog code forces a decision.\n */\nconst BY_CODE = {\n // ----------------------------------------------------------------------------------- transport\n REQUEST_TIMEOUT: TRANSIENT,\n TRANSPORT_ERROR: TRANSIENT,\n REQUEST_FAILED: TRANSIENT,\n\n // ------------------------------------------------------------------------------- write: unknown\n // No answer was read, or a 2xx answer that does not prove the write was queued under the signed\n // key: it may have been applied.\n SUBMISSION_OUTCOME_UNKNOWN: UNKNOWN,\n GATEWAY_REPORTED_ERROR: UNKNOWN,\n GATEWAY_DATA_MISSING: UNKNOWN,\n GATEWAY_MODE_INVALID: UNKNOWN,\n GATEWAY_SYNC_REQUEST_TRADE: UNKNOWN,\n MISSING_UNIQUE_KEY: UNKNOWN,\n UNIQUE_KEY_MISMATCH: UNKNOWN,\n // Core `GatewayWrites` (token-contract writes): no answer read, or a 2xx that proves nothing.\n GATEWAY_WRITE_OUTCOME_UNKNOWN: UNKNOWN,\n GATEWAY_RESPONSE_INVALID: UNKNOWN,\n // Core `./bridge` (GalaConnect bridge writes): a 2xx without the id or hash the next step needs,\n // or no answer read after the request left.\n BRIDGE_RESPONSE_INVALID: UNKNOWN,\n BRIDGE_WRITE_OUTCOME_UNKNOWN: UNKNOWN,\n // Any failure after GalaConnect accepted a bridge-out request: the tokens may be locked, so\n // never a retry under a fresh key, whatever the inner failure (a BridgeTokenOut 429 included).\n BRIDGE_OUT_OUTCOME_UNKNOWN: UNKNOWN,\n // A bridge-in deposit that failed once it was being sent (sending, confirming, registering): the\n // funds may have left the wallet. A status wait that timed out: the bridge may still complete.\n BRIDGE_DEPOSIT_OUTCOME_UNKNOWN: UNKNOWN,\n BRIDGE_STATUS_TIMEOUT: UNKNOWN,\n\n // --------------------------------------------------------------------- write: refused, not queued\n SHADOW_NOT_QUEUED: NOT_QUEUED_FINAL,\n METHOD_NOT_ALLOWED: NOT_QUEUED,\n SIGNATURE_INVALID: NOT_QUEUED,\n SIGNER_MISMATCH: NOT_QUEUED,\n DTO_INVALID: NOT_QUEUED,\n BOUNDS_VIOLATION: NOT_QUEUED,\n SYMBOL_CONFLICT: NOT_QUEUED,\n RATE_LIMITED: NOT_QUEUED,\n GATEWAY_REJECTED: NOT_QUEUED,\n\n // ----------------------------------------------------------------------- the chain's own verdict\n CHAIN_REJECTED: REJECTED,\n\n // ----------------------------------------------------------------------- reads of backend data\n INVALID_CHAIN_RESPONSE: TRANSIENT,\n INVALID_POSITION_RESPONSE: TRANSIENT,\n // Core `GatewayReads` (unsigned token-contract reads): nothing is applied, so a refusal or an\n // unusable answer is worth another try; a class that does not exist, or a data set larger than\n // the caller allowed, needs a different request.\n GATEWAY_READ_REJECTED: TRANSIENT,\n GATEWAY_READ_RESPONSE_INVALID: TRANSIENT,\n // Core `./bridge` GalaConnect reads (configurations, fee, status): the same as a gateway read;\n // a symbol GalaConnect has no verified configuration for needs a different request.\n BRIDGE_READ_RESPONSE_INVALID: TRANSIENT,\n BRIDGE_TOKEN_NOT_FOUND: INVALID_INPUT,\n // A token the wrappable list does not have (or its counterpart, or a channel a wrap does not\n // move between): a different request is needed.\n TOKEN_NOT_WRAPPABLE: INVALID_INPUT,\n // A failed or unusable read of the external chain before a bridge-in deposit: nothing was sent.\n BRIDGE_CHAIN_READ_FAILED: TRANSIENT,\n TOKEN_CLASS_NOT_FOUND: INVALID_INPUT,\n PAGINATION_LIMIT_EXCEEDED: INVALID_INPUT,\n\n // -------------------------------------------------------------------------------- confirmation\n CONFIRMATION_TIMEOUT: UNKNOWN,\n CONFIRMATION_ABORTED: UNKNOWN,\n CONFIRMATION_FAILED: UNKNOWN,\n CONFIRMATION_MALFORMED: UNKNOWN,\n CONFIRMATION_KEY_MISMATCH: UNKNOWN,\n\n // ------------------------------------------------------------------------------ the realtime stream\n STREAM_DISCONNECTED: TRANSIENT,\n STREAM_REQUEST_TIMEOUT: TRANSIENT,\n STREAM_CONNECT_FAILED: TRANSIENT,\n STREAM_CLOSED_BEFORE_CONNECT: TRANSIENT,\n STREAM_CONNECTION_CLOSED: TRANSIENT,\n\n // ----------------------------------------------- pre-send: an app-supplied callback failed\n // The signer, the key provider or the token resolver threw before anything was transmitted. The\n // original error is `cause`. A repeat cannot apply anything twice.\n SIGNING_FAILED: NOT_SENT,\n KEY_PROVIDER_FAILED: NOT_SENT,\n TOKEN_RESOLUTION_FAILED: NOT_SENT,\n TOKEN_NAME_RESOLUTION_FAILED: NOT_SENT,\n\n // ------------------------------------------- the call cannot work as written, found AFTER an answer\n // (a pre_send code needs no row: it is `invalid_input` by default, see `CodeTable`)\n NO_WALLET_ADDRESS: INVALID_INPUT,\n NO_POOL_AVAILABLE: INVALID_INPUT,\n INSUFFICIENT_LIQUIDITY: INVALID_INPUT,\n} as const satisfies CodeTable;\n\n/** Both catalogs as one type: every code a `GSwapSDKError` can carry reads its entry here. */\ntype Catalogs = typeof GALA_ERROR_CATALOG & typeof GSWAP_ERROR_CATALOG;\n\n/** A code (core or DEX) whose catalog phase is `pre_send`. */\ntype PreSendCode = {\n [C in GSwapErrorCode]: Catalogs[C]['phase'] extends 'pre_send' ? C : never;\n}[GSwapErrorCode];\n\n/** The codes whose classification depends on the failing answer, not on a table row. */\ntype AnswerDependentCode =\n | 'HTTP_ERROR'\n | 'UPDATE_REQUIRED'\n | 'CHAIN_DISPATCH_FAILED'\n | 'INVALID_PRIVATE_KEY'\n | 'GATEWAY_HTTP_ERROR'\n | 'GALACONNECT_HTTP_ERROR'\n | 'GATEWAY_WRITE_REJECTED'\n | 'BRIDGE_REQUEST_REJECTED';\n\n/**\n * Every code that is NOT `pre_send` needs a row (a new one is a compile error until it has one);\n * a `pre_send` code may have one (`SIGNING_FAILED` is `not_sent`). A `pre_send` code without a row\n * is `invalid_input`: nothing was transmitted, so it cannot be `unknown`, and it is not a\n * condition a repeat clears. That keeps the 90-odd validation codes out of the table, which is\n * what keeps `classifyFailure` small enough for an app shell.\n */\ntype CodeTable = {\n readonly [C in Exclude<GSwapErrorCode, PreSendCode | AnswerDependentCode>]: FailureClassification;\n} & {\n readonly [C in Exclude<PreSendCode, AnswerDependentCode>]?: FailureClassification;\n};\n\n/**\n * A key that is not valid is the input's fault (`invalid_input`), except `no_key_provided`: the\n * provider had nothing to give right now (a locked wallet, an empty slot). That is the same\n * situation as a provider that throws (`KEY_PROVIDER_FAILED`), and it clears once a key exists, so\n * it is `not_sent` and Retry is safe.\n */\nfunction classifyInvalidPrivateKey(view: FailureView): FailureClassification {\n return stringParamOf(view, 'reason') === 'no_key_provided' ? NOT_SENT : INVALID_INPUT;\n}\n\n/** The status of an HTTP failure: the one it carries, else its `status` param. */\nfunction statusOfView(view: FailureView): number | undefined {\n return view.status ?? numberParamOf(view, 'status');\n}\n\n/**\n * An HTTP failure with no gateway or chain code: its meaning depends on the status and on read vs\n * write. A view that states no status at all cannot be judged: `unknown`.\n */\nfunction classifyHttpError(view: FailureView): FailureClassification {\n const status = statusOfView(view);\n if (status === undefined) return UNKNOWN;\n if (isWriteView(view)) {\n // A gateway that answered 5xx or 408 may still have queued the write; 429 and 4xx did not.\n if (status === 429) return NOT_QUEUED;\n if (status === 408 || status >= 500) return UNKNOWN;\n return NOT_QUEUED_FINAL;\n }\n return status === 408 || status === 429 || status >= 500 ? TRANSIENT : INVALID_INPUT;\n}\n\n/**\n * A core `./bridge` GalaConnect HTTP failure: like {@link classifyHttpError}, except that a\n * WRITE answered 409 is `unknown`: GalaChain's \"this uniqueKey was already consumed\", after which\n * an earlier attempt under the key may be applied (a bridge-out that locked the tokens).\n */\nfunction classifyGalaConnectHttpError(view: FailureView): FailureClassification {\n return isWriteView(view) && statusOfView(view) === 409 ? UNKNOWN : classifyHttpError(view);\n}\n\n/**\n * The version wall (HTTP 426). On a write the gateway refused it before queueing anything, and a\n * repeat of the same app version is refused the same way, so it is `not_queued` with no Retry. On a\n * read nothing changed either, and only an update helps: `invalid_input`, no Retry. Both say \"show\n * the update screen\", not \"try again\".\n */\nfunction classifyUpdateRequired(view: FailureView): FailureClassification {\n return isWriteView(view) ? NOT_QUEUED_FINAL : INVALID_INPUT;\n}\n\n/**\n * The chain dispatch failed. The gateway echoes the upstream status: 409 is \"this uniqueKey was\n * already consumed\" (the first attempt may be applied), 422 is the chain evaluating the write and\n * refusing it (definite), another 5xx is an upstream outage after which the write may have landed,\n * and a 4xx is a refusal before anything was queued.\n */\nfunction classifyChainDispatchFailed(view: FailureView): FailureClassification {\n const status = view.status;\n if (status === undefined || status === 409 || status >= 500) return UNKNOWN;\n return status === 422 ? REJECTED : NOT_QUEUED;\n}\n\n/**\n * GalaChain answered a core `GatewayWrites` token-contract write with a `Status` other than 1: the\n * chain's verdict, so the write was not applied (`rejected`), except where the verdict does not\n * prove that: a 409 is \"this uniqueKey was already consumed\" (an earlier attempt under it may be\n * applied), and a 5xx, or no status at all, cannot be judged.\n */\nfunction classifyGatewayWriteRejected(view: FailureView): FailureClassification {\n const status = view.status;\n return status === undefined || status === 409 || status >= 500 ? UNKNOWN : REJECTED;\n}\n\n/**\n * Classifies any thrown value from its code (and, for a few codes, its HTTP status), never from\n * message text, so an app does not have to re-derive \"may I offer Retry?\" and \"is the outcome\n * unknown?\" for every code. The decision for each code is in this module's table; a new catalog\n * code cannot be added without one.\n *\n * A failure BEFORE the request left (`error.phase === 'pre_send'`, `isPreSendError`) can never be\n * `unknown` or `rejected`: it is `invalid_input` (the input has to change) or `not_sent` (nothing\n * was transmitted; a repeat is safe). Every app-supplied callback the SDK calls before it sends\n * (the signer, the key provider, a token resolver) has its failure wrapped into such an error\n * (`SIGNING_FAILED`, `KEY_PROVIDER_FAILED`, `TOKEN_RESOLUTION_FAILED`, the original as `cause`),\n * so an app NEVER needs an error class of its own to say \"nothing was sent\": a locked wallet,\n * a declined signature and a failed lookup all arrive as `not_sent`, retryable.\n *\n * It accepts a `GSwapSDKError` or a plain-object VIEW of one ({@link FailureView}: `{ code,\n * params?, status?, uniqueKey?, ... }`, the shape of the wrapper an app builds from an SDK error;\n * `toFailureView` reads any value), and decides from the same fields, so an app does not need to\n * keep the original error to ask. `{ afterQueued: true }` says the write is already queued (the\n * step being classified is a confirmation): `retryable` is then always `false`.\n *\n * Anything that is not an SDK error or such a view, or a view whose `code` the catalog does not\n * define, is `{ outcome: 'unknown', retryable: false }`: the SDK\n * cannot say what happened, and refusing Retry is the safe answer. That is only what escapes AFTER\n * the request left (an app requestor that rejects with its own error, a callback of yours that\n * throws once bytes were sent). An error your own code raises BEFORE it calls the SDK says so\n * itself: give it a code of its own and `outcome` (`{ code: 'POSITION_STALE', outcome: 'not_sent'\n * }`), and the SDK answers with that outcome's classification and `mayHaveBeenQueued` is `false`.\n * The declared `outcome` is read only for a code the catalog does not define.\n *\n * A failure is a WRITE's unless it states `write: false` (`GSwapSDKError.write`, set for every\n * SDK read): see {@link FailureView}. A view that lost its `uniqueKey` is therefore still judged as\n * a write (a 5xx stays `unknown`), never as a retryable read.\n *\n * To learn that a failure came from the dark (shadow) path, read `error.shadow` (a typed field of\n * every `GSwapSDKError`) or call `isShadowError(error)`, which also covers a non-SDK object that\n * escaped `swapShadow` / `submitSwapShadow` / `ChainGateway.submitShadow`. The classification is\n * the same as on the public path; an app that withholds Retry or a public fallback after a dark\n * swap applies that policy on top of `retryable`.\n *\n * @example\n * ```ts\n * try {\n * await swaps.swap('GALA', 'GUSDC', 3000, { exactIn: '100' });\n * } catch (error) {\n * const { outcome, retryable } = classifyFailure(error);\n * if (outcome === 'unknown') keepPendingAndConfirm(error); // never a second swap\n * else if (retryable) offerRetry(); // a new request under a fresh key\n * }\n * ```\n */\nexport function classifyFailure(\n error: unknown,\n options: ClassifyFailureOptions = {},\n): FailureClassification {\n const result = classifyView(toFailureView(error));\n // A `rejected` outcome is the chain's definite no: the queued write was evaluated and NOT\n // applied, so a new request under a fresh key cannot double-apply it and Retry stays as it is.\n return options.afterQueued === true && result.outcome !== 'rejected'\n ? { ...result, retryable: false }\n : result;\n}\n\n/** Options of {@link classifyFailure}. */\nexport interface ClassifyFailureOptions {\n /**\n * The write is ALREADY queued (the gateway acknowledged it with this `uniqueKey`), and what is\n * being classified is a later step: confirming it, reading its apply result. Whatever the\n * outcome, `retryable` is then `false`: a NEW request would be a second trade, so the app\n * confirms the same key (or forgets it) and never offers \"Try again\". `outcome` is unchanged.\n *\n * The one exception is `rejected`: the chain evaluated the queued write and refused it (an\n * apply result of `Status: 0`, `CHAIN_REJECTED`; a 422 dispatch). That PROVES it was not\n * applied, so a new request under a fresh key cannot make a second trade, and `retryable`\n * keeps the answer it has without this option (`true`). Every outcome that does not prove\n * \"not applied\" (`unknown`, `transient`, `not_queued`, ...) is `false`.\n */\n afterQueued?: boolean | undefined;\n}\n\n/**\n * The classification of a failure view: the table decision for its code, the status-dependent\n * decision for the codes whose meaning needs it, and for a code the catalog does not define\n * (a wallet error, an ethers `ACTION_REJECTED`, a typo, an app's own error): `unknown` unless the\n * view DECLARES its `outcome` (an app's error, `{ code: 'POSITION_STALE', outcome: 'not_sent' }`),\n * then the SDK's own classification of that outcome. A value with no view is `unknown`.\n */\nfunction classifyView(view: FailureView | undefined): FailureClassification {\n if (view === undefined) return { ...UNKNOWN };\n if (!isCatalogCode(view.code)) {\n if (view.outcome === undefined) return { ...UNKNOWN };\n // Withhold-only: `retryable: false` removes Retry from the declared outcome, never adds it.\n return view.retryable === false\n ? classification(view.outcome, { retryable: false })\n : classification(view.outcome);\n }\n const { code } = view;\n // A core gateway HTTP failure without a chain envelope reads exactly like HTTP_ERROR (by its\n // status, and read vs write); so does a GalaConnect one, except a write's 409.\n if (code === 'HTTP_ERROR' || code === 'GATEWAY_HTTP_ERROR') {\n return { ...classifyHttpError(view) };\n }\n if (code === 'GALACONNECT_HTTP_ERROR') return { ...classifyGalaConnectHttpError(view) };\n // GalaChain's refusal of a core gateway or GalaConnect bridge write: by the chain's code.\n if (code === 'GATEWAY_WRITE_REJECTED' || code === 'BRIDGE_REQUEST_REJECTED') {\n return { ...classifyGatewayWriteRejected(view) };\n }\n if (code === 'UPDATE_REQUIRED') return { ...classifyUpdateRequired(view) };\n if (code === 'CHAIN_DISPATCH_FAILED') return { ...classifyChainDispatchFailed(view) };\n if (code === 'INVALID_PRIVATE_KEY') return { ...classifyInvalidPrivateKey(view) };\n const row: FailureClassification | undefined = (\n BY_CODE as Readonly<Partial<Record<GSwapErrorCode, FailureClassification>>>\n )[code];\n return { ...(row ?? INVALID_INPUT) };\n}\n\n/**\n * True when the failed call was a WRITE that may nevertheless have been queued: its outcome is\n * `unknown` (`classifyFailure(error).outcome === 'unknown'`: a timeout or broken connection after\n * the request left, an acknowledgement that proves nothing, a gateway 409 or 5xx, a failed\n * confirmation). The app must keep `error.uniqueKey` and confirm it, and must NOT submit again\n * under a fresh key. Every other outcome (`rejected`, `not_queued`, `not_sent`, `invalid_input`,\n * `transient`) proves the write is not pending.\n *\n * A value the SDK cannot judge (an app requestor's own rejection after the request left) is\n * `unknown` too, so it is `true`; handle errors your own code raised BEFORE calling the SDK first.\n * Meant for the catch of a write; a read never has a pending key to keep.\n *\n * @example\n * ```ts\n * try {\n * await swaps.swap('GALA', 'GUSDC', 3000, { exactIn: '100' });\n * } catch (error) {\n * if (mayHaveBeenQueued(error)) keepPendingAndConfirm(error);\n * }\n * ```\n */\nexport function mayHaveBeenQueued(error: unknown): boolean {\n return classifyFailure(error).outcome === 'unknown';\n}\n"],"mappings":"A,kQAmBA,MAAMA,EAAkCC,EAAe,UAAU,EAC3DC,EAAiCD,EAAe,SAAS,EACzDE,EAAoCF,EAAe,YAAY,EAC/DG,EAAkCH,EAAe,UAAU,EAC3DI,EAAuCJ,EAAe,eAAe,EACrEK,EAAmCL,EAAe,WAAW,EAO7DM,EAAU,CAEd,gBAAiBD,EACjB,gBAAiBA,EACjB,eAAgBA,EAKhB,2BAA4BJ,EAC5B,uBAAwBA,EACxB,qBAAsBA,EACtB,qBAAsBA,EACtB,2BAA4BA,EAC5B,mBAAoBA,EACpB,oBAAqBA,EAErB,8BAA+BA,EAC/B,yBAA0BA,EAG1B,wBAAyBA,EACzB,6BAA8BA,EAG9B,2BAA4BA,EAG5B,+BAAgCA,EAChC,sBAAuBA,EAGvB,kBAAmBM,EACnB,mBAAoBL,EACpB,kBAAmBA,EACnB,gBAAiBA,EACjB,YAAaA,EACb,iBAAkBA,EAClB,gBAAiBA,EACjB,aAAcA,EACd,iBAAkBA,EAGlB,eAAgBH,EAGhB,uBAAwBM,EACxB,0BAA2BA,EAI3B,sBAAuBA,EACvB,8BAA+BA,EAG/B,6BAA8BA,EAC9B,uBAAwBD,EAGxB,oBAAqBA,EAErB,yBAA0BC,EAC1B,sBAAuBD,EACvB,0BAA2BA,EAG3B,qBAAsBH,EACtB,qBAAsBA,EACtB,oBAAqBA,EACrB,uBAAwBA,EACxB,0BAA2BA,EAG3B,oBAAqBI,EACrB,uBAAwBA,EACxB,sBAAuBA,EACvB,6BAA8BA,EAC9B,yBAA0BA,EAK1B,eAAgBF,EAChB,oBAAqBA,EACrB,wBAAyBA,EACzB,6BAA8BA,EAI9B,kBAAmBC,EACnB,kBAAmBA,EACnB,uBAAwBA,CAC1B,EAwCA,SAASI,EAA0B,EAA0C,CAC3E,OAAOC,EAAcC,EAAM,QAAQ,IAAM,kBAAoBP,E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AW,EAAM,CAAC,EACjDV,EAAeU,EAAK,OAAO,EAEjC,GAAM,CAAE,QAASA,EAiBjB,OAdIiB,IAAS,cAAgBA,IAAS,qBAC7B,CAAE,GAAGd,EAAkBH,CAAI,CAAE,EAElCiB,IAAS,yBAAiC,CAAE,GAAGX,EAA6BN,CAAI,CAAE,EAElFiB,IAAS,0BAA4BA,IAAS,0BACzC,CAAE,GAAGR,EAA6BT,CAAI,CAAE,EAE7CiB,IAAS,kBAA0B,CAAE,GAAGV,EAAuBP,CAAI,CAAE,EACrEiB,IAAS,wBAAgC,CAAE,GAAGT,EAA4BR,CAAI,CAAE,EAChFiB,IAAS,sBAA8B,CAAE,GAAGnB,EAA0BE,CAAI,CAAE,EAIzE,CAAE,GAFPJ,EACAqB,IACkBvB,CAAe,CACrC,CAuBA,SAAgBwB,EAAkB,EAAyB,CACzD,OAAOR,EAAgBI,CAAK,CAAC,CAAC,UAAY,SAC5C,C"}
|
|
1
|
+
{"version":3,"file":"failure_classification.js","names":["REJECTED","classification","UNKNOWN","NOT_QUEUED","NOT_SENT","INVALID_INPUT","TRANSIENT","BY_CODE","NOT_QUEUED_FINAL","classifyInvalidPrivateKey","stringParamOf","view","statusOfView","numberParamOf","classifyHttpError","status","isWriteView","classifyGalaConnectHttpError","classifyUpdateRequired","classifyChainDispatchFailed","classifyGatewayWriteRejected","classifyFailure","result","classifyView","toFailureView","error","options","isCatalogCode","code","mayHaveBeenQueued"],"sources":["../../../src/utils/failure_classification.ts"],"sourcesContent":["import {\n isWriteView,\n numberParamOf,\n stringParamOf,\n toFailureView,\n type FailureView,\n type GALA_ERROR_CATALOG,\n} from '@gala-chain/gala-core-sdk';\nimport type { GSWAP_ERROR_CATALOG, GSwapErrorCode } from '../classes/gswap_error_catalog.js';\nimport { isCatalogCode } from '../classes/gswap_error_phase_table.js';\nimport { classification, NOT_QUEUED_FINAL, type FailureClassification } from './classification.js';\n\n/**\n * `classifyFailure` and `mayHaveBeenQueued`: the one module that holds the decision for every\n * catalog code (~135 names, a floor no minifier can remove). It needs the code table and nothing\n * else: the classification values live in `classification.ts`, the yes/no guards in\n * `failure_guards.ts`, and the error class and catalog are only named as types.\n */\n\nconst REJECTED: FailureClassification = classification('rejected');\nconst UNKNOWN: FailureClassification = classification('unknown');\nconst NOT_QUEUED: FailureClassification = classification('not_queued');\nconst NOT_SENT: FailureClassification = classification('not_sent');\nconst INVALID_INPUT: FailureClassification = classification('invalid_input');\nconst TRANSIENT: FailureClassification = classification('transient');\n\n/**\n * The classification of every code whose meaning does not depend on the failing answer. A code\n * missing here is a compile error (unless it is `pre_send`, see {@link CodeTable}), so adding a\n * catalog code forces a decision.\n */\nconst BY_CODE = {\n // ----------------------------------------------------------------------------------- transport\n REQUEST_TIMEOUT: TRANSIENT,\n TRANSPORT_ERROR: TRANSIENT,\n REQUEST_FAILED: TRANSIENT,\n\n // ------------------------------------------------------------------------------- write: unknown\n // No answer was read, or a 2xx answer that does not prove the write was queued under the signed\n // key: it may have been applied.\n SUBMISSION_OUTCOME_UNKNOWN: UNKNOWN,\n GATEWAY_REPORTED_ERROR: UNKNOWN,\n GATEWAY_DATA_MISSING: UNKNOWN,\n GATEWAY_MODE_INVALID: UNKNOWN,\n GATEWAY_SYNC_REQUEST_TRADE: UNKNOWN,\n MISSING_UNIQUE_KEY: UNKNOWN,\n UNIQUE_KEY_MISMATCH: UNKNOWN,\n // Core `GatewayWrites` (token-contract writes): no answer read, or a 2xx that proves nothing.\n GATEWAY_WRITE_OUTCOME_UNKNOWN: UNKNOWN,\n GATEWAY_RESPONSE_INVALID: UNKNOWN,\n // Core `./bridge` (GalaConnect bridge writes): a 2xx without the id or hash the next step needs,\n // or no answer read after the request left.\n BRIDGE_RESPONSE_INVALID: UNKNOWN,\n BRIDGE_WRITE_OUTCOME_UNKNOWN: UNKNOWN,\n // Any failure after GalaConnect accepted a bridge-out request: the tokens may be locked, so\n // never a retry under a fresh key, whatever the inner failure (a BridgeTokenOut 429 included).\n BRIDGE_OUT_OUTCOME_UNKNOWN: UNKNOWN,\n // A bridge-in deposit that failed once it was being sent (sending, confirming, registering): the\n // funds may have left the wallet. A status wait that timed out: the bridge may still complete.\n BRIDGE_DEPOSIT_OUTCOME_UNKNOWN: UNKNOWN,\n BRIDGE_STATUS_TIMEOUT: UNKNOWN,\n\n // --------------------------------------------------------------------- write: refused, not queued\n SHADOW_NOT_QUEUED: NOT_QUEUED_FINAL,\n METHOD_NOT_ALLOWED: NOT_QUEUED,\n SIGNATURE_INVALID: NOT_QUEUED,\n SIGNER_MISMATCH: NOT_QUEUED,\n // The gateway refuses the same signed DTO every time (its shape, or the operation it names): a\n // resend, under the same key or a fresh one, is refused again. The app has to fix or rebuild the\n // DTO, so Retry is withheld.\n DTO_INVALID: NOT_QUEUED_FINAL,\n DTO_OPERATION_MISMATCH: NOT_QUEUED_FINAL,\n BOUNDS_VIOLATION: NOT_QUEUED,\n SYMBOL_CONFLICT: NOT_QUEUED,\n RATE_LIMITED: NOT_QUEUED,\n GATEWAY_REJECTED: NOT_QUEUED,\n\n // ----------------------------------------------------------------------- the chain's own verdict\n CHAIN_REJECTED: REJECTED,\n\n // ----------------------------------------------------------------------- reads of backend data\n INVALID_CHAIN_RESPONSE: TRANSIENT,\n INVALID_POSITION_RESPONSE: TRANSIENT,\n // Core `GatewayReads` (unsigned token-contract reads): nothing is applied, so a refusal or an\n // unusable answer is worth another try; a class that does not exist, or a data set larger than\n // the caller allowed, needs a different request.\n GATEWAY_READ_REJECTED: TRANSIENT,\n GATEWAY_READ_RESPONSE_INVALID: TRANSIENT,\n // Core `./bridge` GalaConnect reads (configurations, fee, status): the same as a gateway read;\n // a symbol GalaConnect has no verified configuration for needs a different request.\n BRIDGE_READ_RESPONSE_INVALID: TRANSIENT,\n BRIDGE_TOKEN_NOT_FOUND: INVALID_INPUT,\n // A token the wrappable list does not have (or its counterpart, or a channel a wrap does not\n // move between): a different request is needed.\n TOKEN_NOT_WRAPPABLE: INVALID_INPUT,\n // A failed or unusable read of the external chain before a bridge-in deposit: nothing was sent.\n BRIDGE_CHAIN_READ_FAILED: TRANSIENT,\n TOKEN_CLASS_NOT_FOUND: INVALID_INPUT,\n PAGINATION_LIMIT_EXCEEDED: INVALID_INPUT,\n\n // -------------------------------------------------------------------------------- confirmation\n CONFIRMATION_TIMEOUT: UNKNOWN,\n CONFIRMATION_ABORTED: UNKNOWN,\n CONFIRMATION_FAILED: UNKNOWN,\n CONFIRMATION_MALFORMED: UNKNOWN,\n CONFIRMATION_KEY_MISMATCH: UNKNOWN,\n\n // ------------------------------------------------------------------------------ the realtime stream\n STREAM_DISCONNECTED: TRANSIENT,\n STREAM_REQUEST_TIMEOUT: TRANSIENT,\n STREAM_CONNECT_FAILED: TRANSIENT,\n STREAM_CLOSED_BEFORE_CONNECT: TRANSIENT,\n STREAM_CONNECTION_CLOSED: TRANSIENT,\n\n // ----------------------------------------------- pre-send: an app-supplied callback failed\n // The signer, the key provider or the token resolver threw before anything was transmitted. The\n // original error is `cause`. A repeat cannot apply anything twice.\n SIGNING_FAILED: NOT_SENT,\n KEY_PROVIDER_FAILED: NOT_SENT,\n TOKEN_RESOLUTION_FAILED: NOT_SENT,\n TOKEN_NAME_RESOLUTION_FAILED: NOT_SENT,\n\n // ------------------------------------------- the call cannot work as written, found AFTER an answer\n // (a pre_send code needs no row: it is `invalid_input` by default, see `CodeTable`)\n NO_WALLET_ADDRESS: INVALID_INPUT,\n NO_POOL_AVAILABLE: INVALID_INPUT,\n INSUFFICIENT_LIQUIDITY: INVALID_INPUT,\n} as const satisfies CodeTable;\n\n/** Both catalogs as one type: every code a `GSwapSDKError` can carry reads its entry here. */\ntype Catalogs = typeof GALA_ERROR_CATALOG & typeof GSWAP_ERROR_CATALOG;\n\n/** A code (core or DEX) whose catalog phase is `pre_send`. */\ntype PreSendCode = {\n [C in GSwapErrorCode]: Catalogs[C]['phase'] extends 'pre_send' ? C : never;\n}[GSwapErrorCode];\n\n/** The codes whose classification depends on the failing answer, not on a table row. */\ntype AnswerDependentCode =\n | 'HTTP_ERROR'\n | 'UPDATE_REQUIRED'\n | 'CHAIN_DISPATCH_FAILED'\n | 'INVALID_PRIVATE_KEY'\n | 'GATEWAY_HTTP_ERROR'\n | 'GALACONNECT_HTTP_ERROR'\n | 'GATEWAY_WRITE_REJECTED'\n | 'BRIDGE_REQUEST_REJECTED';\n\n/**\n * Every code that is NOT `pre_send` needs a row (a new one is a compile error until it has one);\n * a `pre_send` code may have one (`SIGNING_FAILED` is `not_sent`). A `pre_send` code without a row\n * is `invalid_input`: nothing was transmitted, so it cannot be `unknown`, and it is not a\n * condition a repeat clears. That keeps the 90-odd validation codes out of the table, which is\n * what keeps `classifyFailure` small enough for an app shell.\n */\ntype CodeTable = {\n readonly [C in Exclude<GSwapErrorCode, PreSendCode | AnswerDependentCode>]: FailureClassification;\n} & {\n readonly [C in Exclude<PreSendCode, AnswerDependentCode>]?: FailureClassification;\n};\n\n/**\n * A key that is not valid is the input's fault (`invalid_input`), except `no_key_provided`: the\n * provider had nothing to give right now (a locked wallet, an empty slot). That is the same\n * situation as a provider that throws (`KEY_PROVIDER_FAILED`), and it clears once a key exists, so\n * it is `not_sent` and Retry is safe.\n */\nfunction classifyInvalidPrivateKey(view: FailureView): FailureClassification {\n return stringParamOf(view, 'reason') === 'no_key_provided' ? NOT_SENT : INVALID_INPUT;\n}\n\n/** The status of an HTTP failure: the one it carries, else its `status` param. */\nfunction statusOfView(view: FailureView): number | undefined {\n return view.status ?? numberParamOf(view, 'status');\n}\n\n/**\n * An HTTP failure with no gateway or chain code: its meaning depends on the status and on read vs\n * write. A view that states no status at all cannot be judged: `unknown`.\n */\nfunction classifyHttpError(view: FailureView): FailureClassification {\n const status = statusOfView(view);\n if (status === undefined) return UNKNOWN;\n if (isWriteView(view)) {\n // A gateway that answered 5xx or 408 may still have queued the write; 429 and 4xx did not.\n if (status === 429) return NOT_QUEUED;\n if (status === 408 || status >= 500) return UNKNOWN;\n return NOT_QUEUED_FINAL;\n }\n return status === 408 || status === 429 || status >= 500 ? TRANSIENT : INVALID_INPUT;\n}\n\n/**\n * A core `./bridge` GalaConnect HTTP failure: like {@link classifyHttpError}, except that a\n * WRITE answered 409 is `unknown`: GalaChain's \"this uniqueKey was already consumed\", after which\n * an earlier attempt under the key may be applied (a bridge-out that locked the tokens).\n */\nfunction classifyGalaConnectHttpError(view: FailureView): FailureClassification {\n return isWriteView(view) && statusOfView(view) === 409 ? UNKNOWN : classifyHttpError(view);\n}\n\n/**\n * The version wall (HTTP 426). On a write the gateway refused it before queueing anything, and a\n * repeat of the same app version is refused the same way, so it is `not_queued` with no Retry. On a\n * read nothing changed either, and only an update helps: `invalid_input`, no Retry. Both say \"show\n * the update screen\", not \"try again\".\n */\nfunction classifyUpdateRequired(view: FailureView): FailureClassification {\n return isWriteView(view) ? NOT_QUEUED_FINAL : INVALID_INPUT;\n}\n\n/**\n * The chain dispatch failed. The gateway echoes the upstream status: 409 is \"this uniqueKey was\n * already consumed\" (the first attempt may be applied), 422 is the chain evaluating the write and\n * refusing it (definite), another 5xx is an upstream outage after which the write may have landed,\n * and a 4xx is a refusal before anything was queued.\n */\nfunction classifyChainDispatchFailed(view: FailureView): FailureClassification {\n const status = view.status;\n if (status === undefined || status === 409 || status >= 500) return UNKNOWN;\n return status === 422 ? REJECTED : NOT_QUEUED;\n}\n\n/**\n * GalaChain answered a core `GatewayWrites` token-contract write with a `Status` other than 1: the\n * chain's verdict, so the write was not applied (`rejected`), except where the verdict does not\n * prove that: a 409 is \"this uniqueKey was already consumed\" (an earlier attempt under it may be\n * applied), and a 5xx, or no status at all, cannot be judged.\n */\nfunction classifyGatewayWriteRejected(view: FailureView): FailureClassification {\n const status = view.status;\n return status === undefined || status === 409 || status >= 500 ? UNKNOWN : REJECTED;\n}\n\n/**\n * Classifies any thrown value from its code (and, for a few codes, its HTTP status), never from\n * message text, so an app does not have to re-derive \"may I offer Retry?\" and \"is the outcome\n * unknown?\" for every code. The decision for each code is in this module's table; a new catalog\n * code cannot be added without one.\n *\n * A failure BEFORE the request left (`error.phase === 'pre_send'`, `isPreSendError`) can never be\n * `unknown` or `rejected`: it is `invalid_input` (the input has to change) or `not_sent` (nothing\n * was transmitted; a repeat is safe). Every app-supplied callback the SDK calls before it sends\n * (the signer, the key provider, a token resolver) has its failure wrapped into such an error\n * (`SIGNING_FAILED`, `KEY_PROVIDER_FAILED`, `TOKEN_RESOLUTION_FAILED`, the original as `cause`),\n * so an app NEVER needs an error class of its own to say \"nothing was sent\": a locked wallet,\n * a declined signature and a failed lookup all arrive as `not_sent`, retryable.\n *\n * It accepts a `GSwapSDKError` or a plain-object VIEW of one ({@link FailureView}: `{ code,\n * params?, status?, uniqueKey?, ... }`, the shape of the wrapper an app builds from an SDK error;\n * `toFailureView` reads any value), and decides from the same fields, so an app does not need to\n * keep the original error to ask. `{ afterQueued: true }` says the write is already queued (the\n * step being classified is a confirmation): `retryable` is then always `false`.\n *\n * Anything that is not an SDK error or such a view, or a view whose `code` the catalog does not\n * define, is `{ outcome: 'unknown', retryable: false }`: the SDK\n * cannot say what happened, and refusing Retry is the safe answer. That is only what escapes AFTER\n * the request left (an app requestor that rejects with its own error, a callback of yours that\n * throws once bytes were sent). An error your own code raises BEFORE it calls the SDK says so\n * itself: give it a code of its own and `outcome` (`{ code: 'POSITION_STALE', outcome: 'not_sent'\n * }`), and the SDK answers with that outcome's classification and `mayHaveBeenQueued` is `false`.\n * The declared `outcome` is read only for a code the catalog does not define.\n *\n * A failure is a WRITE's unless it states `write: false` (`GSwapSDKError.write`, set for every\n * SDK read): see {@link FailureView}. A view that lost its `uniqueKey` is therefore still judged as\n * a write (a 5xx stays `unknown`), never as a retryable read.\n *\n * To learn that a failure came from the dark (shadow) path, read `error.shadow` (a typed field of\n * every `GSwapSDKError`) or call `isShadowError(error)`, which also covers a non-SDK object that\n * escaped `swapShadow` / `submitSwapShadow` / `ChainGateway.submitShadow`. The classification is\n * the same as on the public path; an app that withholds Retry or a public fallback after a dark\n * swap applies that policy on top of `retryable`.\n *\n * @example\n * ```ts\n * try {\n * await swaps.swap('GALA', 'GUSDC', 3000, { exactIn: '100' });\n * } catch (error) {\n * const { outcome, retryable } = classifyFailure(error);\n * if (outcome === 'unknown') keepPendingAndConfirm(error); // never a second swap\n * else if (retryable) offerRetry(); // a new request under a fresh key\n * }\n * ```\n */\nexport function classifyFailure(\n error: unknown,\n options: ClassifyFailureOptions = {},\n): FailureClassification {\n const result = classifyView(toFailureView(error));\n // A `rejected` outcome is the chain's definite no: the queued write was evaluated and NOT\n // applied, so a new request under a fresh key cannot double-apply it and Retry stays as it is.\n return options.afterQueued === true && result.outcome !== 'rejected'\n ? { ...result, retryable: false }\n : result;\n}\n\n/** Options of {@link classifyFailure}. */\nexport interface ClassifyFailureOptions {\n /**\n * The write is ALREADY queued (the gateway acknowledged it with this `uniqueKey`), and what is\n * being classified is a later step: confirming it, reading its apply result. Whatever the\n * outcome, `retryable` is then `false`: a NEW request would be a second trade, so the app\n * confirms the same key (or forgets it) and never offers \"Try again\". `outcome` is unchanged.\n *\n * The one exception is `rejected`: the chain evaluated the queued write and refused it (an\n * apply result of `Status: 0`, `CHAIN_REJECTED`; a 422 dispatch). That PROVES it was not\n * applied, so a new request under a fresh key cannot make a second trade, and `retryable`\n * keeps the answer it has without this option (`true`). Every outcome that does not prove\n * \"not applied\" (`unknown`, `transient`, `not_queued`, ...) is `false`.\n */\n afterQueued?: boolean | undefined;\n}\n\n/**\n * The classification of a failure view: the table decision for its code, the status-dependent\n * decision for the codes whose meaning needs it, and for a code the catalog does not define\n * (a wallet error, an ethers `ACTION_REJECTED`, a typo, an app's own error): `unknown` unless the\n * view DECLARES its `outcome` (an app's error, `{ code: 'POSITION_STALE', outcome: 'not_sent' }`),\n * then the SDK's own classification of that outcome. A value with no view is `unknown`.\n */\nfunction classifyView(view: FailureView | undefined): FailureClassification {\n if (view === undefined) return { ...UNKNOWN };\n if (!isCatalogCode(view.code)) {\n if (view.outcome === undefined) return { ...UNKNOWN };\n // Withhold-only: `retryable: false` removes Retry from the declared outcome, never adds it.\n return view.retryable === false\n ? classification(view.outcome, { retryable: false })\n : classification(view.outcome);\n }\n const { code } = view;\n // A core gateway HTTP failure without a chain envelope reads exactly like HTTP_ERROR (by its\n // status, and read vs write); so does a GalaConnect one, except a write's 409.\n if (code === 'HTTP_ERROR' || code === 'GATEWAY_HTTP_ERROR') {\n return { ...classifyHttpError(view) };\n }\n if (code === 'GALACONNECT_HTTP_ERROR') return { ...classifyGalaConnectHttpError(view) };\n // GalaChain's refusal of a core gateway or GalaConnect bridge write: by the chain's code.\n if (code === 'GATEWAY_WRITE_REJECTED' || code === 'BRIDGE_REQUEST_REJECTED') {\n return { ...classifyGatewayWriteRejected(view) };\n }\n if (code === 'UPDATE_REQUIRED') return { ...classifyUpdateRequired(view) };\n if (code === 'CHAIN_DISPATCH_FAILED') return { ...classifyChainDispatchFailed(view) };\n if (code === 'INVALID_PRIVATE_KEY') return { ...classifyInvalidPrivateKey(view) };\n const row: FailureClassification | undefined = (\n BY_CODE as Readonly<Partial<Record<GSwapErrorCode, FailureClassification>>>\n )[code];\n return { ...(row ?? INVALID_INPUT) };\n}\n\n/**\n * True when the failed call was a WRITE that may nevertheless have been queued: its outcome is\n * `unknown` (`classifyFailure(error).outcome === 'unknown'`: a timeout or broken connection after\n * the request left, an acknowledgement that proves nothing, a gateway 409 or 5xx, a failed\n * confirmation). The app must keep `error.uniqueKey` and confirm it, and must NOT submit again\n * under a fresh key. Every other outcome (`rejected`, `not_queued`, `not_sent`, `invalid_input`,\n * `transient`) proves the write is not pending.\n *\n * A value the SDK cannot judge (an app requestor's own rejection after the request left) is\n * `unknown` too, so it is `true`; handle errors your own code raised BEFORE calling the SDK first.\n * Meant for the catch of a write; a read never has a pending key to keep.\n *\n * @example\n * ```ts\n * try {\n * await swaps.swap('GALA', 'GUSDC', 3000, { exactIn: '100' });\n * } catch (error) {\n * if (mayHaveBeenQueued(error)) keepPendingAndConfirm(error);\n * }\n * ```\n */\nexport function mayHaveBeenQueued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jDV,EAAeU,EAAK,OAAO,EAEjC,GAAM,CAAE,QAASA,EAiBjB,OAdIiB,IAAS,cAAgBA,IAAS,qBAC7B,CAAE,GAAGd,EAAkBH,CAAI,CAAE,EAElCiB,IAAS,yBAAiC,CAAE,GAAGX,EAA6BN,CAAI,CAAE,EAElFiB,IAAS,0BAA4BA,IAAS,0BACzC,CAAE,GAAGR,EAA6BT,CAAI,CAAE,EAE7CiB,IAAS,kBAA0B,CAAE,GAAGV,EAAuBP,CAAI,CAAE,EACrEiB,IAAS,wBAAgC,CAAE,GAAGT,EAA4BR,CAAI,CAAE,EAChFiB,IAAS,sBAA8B,CAAE,GAAGnB,EAA0BE,CAAI,CAAE,EAIzE,CAAE,GAFPJ,EACAqB,IACkBvB,CAAe,CACrC,CAuBA,SAAgBwB,EAAkB,EAAyB,CACzD,OAAOR,EAAgBI,CAAK,CAAC,CAAC,UAAY,SAC5C,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{isWriteView as e,stringParamOf as t,toFailureView as n}from"@gala-chain/gala-core-sdk";function r(e){let t=n(e);return t?.code===`CHAIN_DISPATCH_FAILED`&&t.status===409}const i=[`GATEWAY_DATA_MISSING`,`GATEWAY_MODE_INVALID`,`GATEWAY_SYNC_REQUEST_TRADE`,`MISSING_UNIQUE_KEY`,`UNIQUE_KEY_MISMATCH`];function a(e){return s(e,i)}function o(e,t){return t.some(t=>t===e)}function s(e,t){let r=n(e);return r!==void 0&&o(r.code,t)}const c=[`GATEWAY_REPORTED_ERROR`,`METHOD_NOT_ALLOWED`,`SIGNATURE_INVALID`,`SIGNER_MISMATCH`,`DTO_INVALID`,`BOUNDS_VIOLATION`,`SYMBOL_CONFLICT`,`RATE_LIMITED`,`CHAIN_DISPATCH_FAILED`,`GATEWAY_REJECTED`];function l(e){return s(e,c)}function u(e){return a(e)||s(e,[`GATEWAY_REPORTED_ERROR`])}function d(e){let r=n(e);if(r===void 0||r.code!==`CHAIN_REJECTED`&&r.code!==`CHAIN_DISPATCH_FAILED`)return;let i=t(r,`errorKey`);return i===void 0||i===``?void 0:i}const f=[`NO_POOL_AVAILABLE`,`INSUFFICIENT_LIQUIDITY`,`UNKNOWN_TOKEN`];function p(t){let r=n(t);return r===void 0?!1:o(r.code,f)?!0:!e(r)&&(r.notFound===!0||r.status===404)}export{d as chainErrorKeyOf,p as isNoMarket,l as isRelayableRefusal,u as isUninterpretedAnswer,r as isUniqueKeyConsumed,a as isUnprovenAcknowledgement};
|
|
1
|
+
import{isWriteView as e,stringParamOf as t,toFailureView as n}from"@gala-chain/gala-core-sdk";function r(e){let t=n(e);return t?.code===`CHAIN_DISPATCH_FAILED`&&t.status===409}const i=[`GATEWAY_DATA_MISSING`,`GATEWAY_MODE_INVALID`,`GATEWAY_SYNC_REQUEST_TRADE`,`MISSING_UNIQUE_KEY`,`UNIQUE_KEY_MISMATCH`];function a(e){return s(e,i)}function o(e,t){return t.some(t=>t===e)}function s(e,t){let r=n(e);return r!==void 0&&o(r.code,t)}const c=[`GATEWAY_REPORTED_ERROR`,`METHOD_NOT_ALLOWED`,`SIGNATURE_INVALID`,`SIGNER_MISMATCH`,`DTO_INVALID`,`DTO_OPERATION_MISMATCH`,`BOUNDS_VIOLATION`,`SYMBOL_CONFLICT`,`RATE_LIMITED`,`CHAIN_DISPATCH_FAILED`,`GATEWAY_REJECTED`];function l(e){return s(e,c)}function u(e){return a(e)||s(e,[`GATEWAY_REPORTED_ERROR`])}function d(e){let r=n(e);if(r===void 0||r.code!==`CHAIN_REJECTED`&&r.code!==`CHAIN_DISPATCH_FAILED`)return;let i=t(r,`errorKey`);return i===void 0||i===``?void 0:i}const f=[`NO_POOL_AVAILABLE`,`INSUFFICIENT_LIQUIDITY`,`UNKNOWN_TOKEN`];function p(t){let r=n(t);return r===void 0?!1:o(r.code,f)?!0:!e(r)&&(r.notFound===!0||r.status===404)}export{d as chainErrorKeyOf,p as isNoMarket,l as isRelayableRefusal,u as isUninterpretedAnswer,r as isUniqueKeyConsumed,a as isUnprovenAcknowledgement};
|
|
2
2
|
//# sourceMappingURL=failure_guards.js.map
|