@gala-chain/gala-core-sdk 1.1.0-beta.8 → 1.2.0-beta.1

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.
Files changed (41) hide show
  1. package/README.md +52 -5
  2. package/dist/bridge.cjs +1 -1
  3. package/dist/bridge.cjs.map +1 -1
  4. package/dist/bridge.mjs +2 -2
  5. package/dist/bridge.mjs.map +1 -1
  6. package/dist/browser/bridge.js +1 -1
  7. package/dist/browser/bridge.js.map +1 -1
  8. package/dist/browser/classes/error_catalog.js +1 -1
  9. package/dist/browser/classes/error_catalog.js.map +1 -1
  10. package/dist/browser/classes/error_phase_table.js +1 -1
  11. package/dist/browser/classes/error_phase_table.js.map +1 -1
  12. package/dist/browser/index.js +1 -1
  13. package/dist/browser/reads/gateway_reads.js +1 -1
  14. package/dist/browser/reads/nft_collections.js +2 -0
  15. package/dist/browser/reads/nft_collections.js.map +1 -0
  16. package/dist/browser/reads/nft_fees.js +2 -0
  17. package/dist/browser/reads/nft_fees.js.map +1 -0
  18. package/dist/browser/reads/request.js +1 -1
  19. package/dist/browser/reads/request.js.map +1 -1
  20. package/dist/browser/utils/dto_operation.js.map +1 -1
  21. package/dist/browser/utils/pre_send.js +1 -1
  22. package/dist/browser/utils/pre_send.js.map +1 -1
  23. package/dist/browser/utils/transport.js +1 -1
  24. package/dist/browser/version.js +1 -1
  25. package/dist/browser/version.js.map +1 -1
  26. package/dist/browser/writes/gateway_writes.js +1 -1
  27. package/dist/browser/writes/gateway_writes.js.map +1 -1
  28. package/dist/browser/writes/nft.js +2 -0
  29. package/dist/browser/writes/nft.js.map +1 -0
  30. package/dist/browser/writes/nft_fee.js +2 -0
  31. package/dist/browser/writes/nft_fee.js.map +1 -0
  32. package/dist/browser/writes/submit.js +1 -1
  33. package/dist/browser/writes/submit.js.map +1 -1
  34. package/dist/browser/writes/types.js.map +1 -1
  35. package/dist/index.cjs +741 -142
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts +276 -10
  38. package/dist/index.d.ts +276 -10
  39. package/dist/index.mjs +733 -143
  40. package/dist/index.mjs.map +1 -1
  41. package/package.json +32 -30
@@ -1,2 +1,2 @@
1
- const e=[`wrong_length`,`bad_encoding`,`not_on_curve`,`no_key_provided`],t=[`user_rejected`,`failed`],n=[`missing`,`ambiguous`,`bad_class_key`,`bad_instance`],r=[`signer`,`gatewayBaseUrl`,`httpRequestor`,`tokenNameResolver`],i=[`timeout`,`transport`],a=[`gatewayBaseUrl`,`httpRequestor`],o=[`limit`,`pageSize`,`maxPages`,`bookmark`],s=[`not_connected`,`disconnected`,`unauthorized`],c=[`no_accounts`,`user_rejected`,`failed`],l=[`eip1193_provider`,`private_key_or_eip1193_provider`],u=[`empty`,`unrecognized_format`,`unknown_mnemonic_word`,`mnemonic_checksum`],d=[`Ethereum`,`Solana`],f=[`not_a_number`,`not_positive`,`too_many_decimals`],p=[`request_id`,`bridge_token_out`,`transaction_hash`],m=[`send`,`confirmation`,`registration`],h=[`not_listed`,`no_counterpart`,`unknown_channel`],g=[`wrap`,`unwrap`],_={REQUEST_TIMEOUT:{phase:`in_flight`,template:`Request to {url} timed out after {timeoutMs} ms.`,params:{url:`string`,timeoutMs:`number`}},TRANSPORT_ERROR:{phase:`in_flight`,template:`The request to {url} failed before the server answered.`,params:{url:`string`}},INVALID_TIMEOUT:{phase:`pre_send`,template:`{field} must be a positive number of milliseconds, or Infinity for no timeout (got {value}).`,params:{field:`string`,value:`number`}},GALA_WALLET_NOT_AVAILABLE:{phase:`pre_send`,template:`Gala wallet is not available. Please ensure the Gala wallet is connected.`,params:{}},WALLET_UNAVAILABLE:{phase:`pre_send`,template:`No wallet is connected.`,params:{}},MALFORMED_WALLET_REQUEST:{phase:`pre_send`,template:`Wallet {method} request is malformed.`,params:{method:`string`}},UNSUPPORTED_WALLET_METHOD:{phase:`pre_send`,template:`Unsupported wallet method {method}.`,params:{method:`string`}},INVALID_SIGNATURE:{phase:`pre_send`,template:`Wallet returned an invalid {scheme} signature.`,params:{scheme:`string`}},INVALID_CHAIN_ID:{phase:`pre_send`,template:`Wallet returned an invalid chain id ({chainId}).`,params:{chainId:`string`}},SIGNER_ADDRESS_MISMATCH:{phase:`pre_send`,template:`The signing key does not belong to the expected account.`,params:{}},INVALID_PRIVATE_KEY:{phase:`pre_send`,template:`Invalid private key: {reason}.`,params:{reason:e}},SIGNING_FAILED:{phase:`pre_send`,template:`Signing the {method} request failed ({reason}); nothing was sent.`,params:{method:`string`,reason:t}},KEY_PROVIDER_FAILED:{phase:`pre_send`,template:`The signing key could not be fetched; nothing was sent.`,params:{}},INVALID_SIGNING_HASH_LENGTH:{phase:`pre_send`,template:`secp256k1 can only sign a 32-byte hash (got {length}).`,params:{length:`number`}},INVALID_WALLET_ADDRESS:{phase:`pre_send`,template:`Invalid {field}: "{value}" is not an accepted wallet address form.`,params:{field:`string`,value:`string`}},INVALID_ETH_USER_REF_PREFIX:{phase:`pre_send`,template:`Invalid {field}: "{value}" is not a GalaChain user reference. An eth| reference takes the 40 hex digits of the account with no 0x prefix; write it as "{expected}".`,params:{field:`string`,value:`string`,expected:`string`}},INVALID_DECIMAL:{phase:`pre_send`,template:`Invalid decimal quantity: {value}`,params:{value:`string`}},PERSONAL_SIGN_NOT_JSON:{phase:`pre_send`,template:`Personal-sign DTO is not valid JSON`,params:{}},PERSONAL_SIGN_NOT_OBJECT:{phase:`pre_send`,template:`Personal-sign DTO must be a JSON object`,params:{}},PERSONAL_SIGN_BAD_PREFIX:{phase:`pre_send`,template:`Personal-sign DTO prefix is not an EIP-191 "Ethereum Signed Message" header`,params:{}},PERSONAL_SIGN_ENVELOPE_FIELDS:{phase:`pre_send`,template:`Personal-sign DTO carries signing-envelope field(s): {fields}`,params:{fields:`string`}},PERSONAL_SIGN_NOT_CANONICAL:{phase:`pre_send`,template:`Personal-sign DTO is not in canonical serialized form`,params:{}},EIP712_NAME_COLLISION:{phase:`pre_send`,template:`Name collisions are not supported when deriving EIP-712 types ({name}).`,params:{name:`string`}},EIP712_UNSUPPORTED_VALUE:{phase:`pre_send`,template:`Unsupported EIP-712 value of type {valueType}.`,params:{valueType:`string`}},TYPED_DATA_NOT_STRING:{phase:`pre_send`,template:`Invalid typed data: {what} must be a string`,params:{what:`string`}},TYPED_DATA_UNPAIRED_SURROGATE:{phase:`pre_send`,template:`Invalid typed data: {what} has an unpaired surrogate`,params:{what:`string`}},TYPED_DATA_NOT_HEX_BYTES:{phase:`pre_send`,template:`Invalid typed data: {what} must be an even-length 0x hex string`,params:{what:`string`}},TYPED_DATA_NOT_SAFE_INTEGER:{phase:`pre_send`,template:`Invalid typed data: {what} must be a safe integer`,params:{what:`string`}},TYPED_DATA_NOT_INTEGER:{phase:`pre_send`,template:`Invalid typed data: {what} must be an integer`,params:{what:`string`}},TYPED_DATA_NOT_BOOLEAN:{phase:`pre_send`,template:`Invalid typed data: bool must be a boolean`,params:{}},TYPED_DATA_BAD_ADDRESS:{phase:`pre_send`,template:`Invalid typed data: address must be 0x followed by 40 hex digits`,params:{}},TYPED_DATA_BAD_CHECKSUM:{phase:`pre_send`,template:`Invalid typed data: address has a bad checksum`,params:{}},TYPED_DATA_BYTES_LENGTH:{phase:`pre_send`,template:`Invalid typed data: {type} must be exactly {width} bytes`,params:{type:`string`,width:`number`}},TYPED_DATA_OUT_OF_BOUNDS:{phase:`pre_send`,template:`Invalid typed data: value out of bounds for {type}`,params:{type:`string`}},TYPED_DATA_UNSUPPORTED_TYPE:{phase:`pre_send`,template:`Invalid typed data: unsupported type "{type}"`,params:{type:`string`}},TYPED_DATA_FIELDS_NOT_LIST:{phase:`pre_send`,template:`Invalid typed data: type {typeName} must be a list of fields`,params:{typeName:`string`}},TYPED_DATA_FIELD_MALFORMED:{phase:`pre_send`,template:`Invalid typed data: type {typeName} has a field without a string name and type`,params:{typeName:`string`}},TYPED_DATA_INVALID_FIELD_NAME:{phase:`pre_send`,template:`Invalid typed data: invalid field name "{name}"`,params:{name:`string`}},TYPED_DATA_DUPLICATE_FIELD:{phase:`pre_send`,template:`Invalid typed data: duplicate field "{name}" in {typeName}`,params:{name:`string`,typeName:`string`}},TYPED_DATA_INVALID_TYPE_NAME:{phase:`pre_send`,template:`Invalid typed data: invalid type name "{name}"`,params:{name:`string`}},TYPED_DATA_CIRCULAR_TYPE:{phase:`pre_send`,template:`Invalid typed data: circular type reference in {typeName}`,params:{typeName:`string`}},TYPED_DATA_UNKNOWN_FIELD_TYPE:{phase:`pre_send`,template:`Invalid typed data: unknown type "{type}" in {typeName}`,params:{type:`string`,typeName:`string`}},TYPED_DATA_NO_PRIMARY_TYPE:{phase:`pre_send`,template:`Invalid typed data: missing primary type`,params:{}},TYPED_DATA_AMBIGUOUS_PRIMARY_TYPE:{phase:`pre_send`,template:`Invalid typed data: ambiguous primary types or unused types ({roots})`,params:{roots:`string`}},TYPED_DATA_ARRAY_EXPECTED:{phase:`pre_send`,template:`Invalid typed data: {type} array value must be an array`,params:{type:`string`}},TYPED_DATA_ARRAY_LENGTH_MISMATCH:{phase:`pre_send`,template:`Invalid typed data: array length mismatch`,params:{}},TYPED_DATA_STRUCT_NOT_OBJECT:{phase:`pre_send`,template:`Invalid typed data: {typeName} value must be an object`,params:{typeName:`string`}},TYPED_DATA_MISSING_FIELD:{phase:`pre_send`,template:`Invalid typed data: {typeName} value is missing field "{field}"`,params:{typeName:`string`,field:`string`}},TYPED_DATA_DOMAIN_NOT_OBJECT:{phase:`pre_send`,template:`Invalid typed data: domain must be an object`,params:{}},TYPED_DATA_INVALID_DOMAIN_KEY:{phase:`pre_send`,template:`Invalid typed data: invalid typed-data domain key {key}`,params:{key:`string`}},INVALID_UNIQUE_KEY:{phase:`pre_send`,template:`The uniqueKey "{uniqueKey}" must be 1-128 characters of A-Z, a-z, 0-9, ".", "_", ":" or "-".`,params:{uniqueKey:`string`}},INVALID_UNIQUE_KEY_PREFIX:{phase:`pre_send`,template:`uniqueKeyPrefix "{uniqueKeyPrefix}" must be at most {maxLength} characters of A-Z, a-z, 0-9, ".", "_", ":" or "-".`,params:{uniqueKeyPrefix:`string`,maxLength:`number`}},CSPRNG_UNAVAILABLE:{phase:`pre_send`,template:`No cryptographically secure random source (globalThis.crypto.getRandomValues) is available to mint a uniqueKey or a new wallet; install a getRandomValues polyfill (react-native-get-random-values on Hermes).`,params:{}},INVALID_WRITES_OPTION:{phase:`pre_send`,template:`GatewayWrites option {option} is missing or is not of the expected type.`,params:{option:r}},INVALID_QUANTITY:{phase:`pre_send`,template:`{field} must be a positive decimal number of whole tokens, written as a string (got "{value}").`,params:{field:`string`,value:`string`}},INVALID_TOKEN_REFERENCE:{phase:`pre_send`,template:`Invalid token reference {field}: {reason}.`,params:{field:`string`,reason:n}},INVALID_TOKEN_BATCH:{phase:`pre_send`,template:`{method} takes 1 to {max} tokens (got {count}).`,params:{method:`string`,count:`number`,max:`number`}},INVALID_LOCK_EXPIRES:{phase:`pre_send`,template:`expires must be a non-negative whole number of epoch milliseconds, 0 for none (got {value}).`,params:{value:`string`}},INVALID_LOCK_NAME:{phase:`pre_send`,template:`The lock name must be a string (got a {valueType}).`,params:{valueType:`string`}},NO_TOKEN_NAME_RESOLVER:{phase:`pre_send`,template:`The token name "{tokenName}" cannot be resolved: no tokenNameResolver is configured. Pass its tokenClassKey instead.`,params:{tokenName:`string`}},TOKEN_NAME_RESOLUTION_FAILED:{phase:`pre_send`,template:`The token name "{tokenName}" could not be resolved to a token class key; nothing was sent.`,params:{tokenName:`string`}},GATEWAY_WRITE_OUTCOME_UNKNOWN:{phase:`in_flight`,template:`The outcome of {method} is unknown ({reason}): the request may have reached the gateway. Check the write by its uniqueKey before sending it again.`,params:{method:`string`,reason:i}},GATEWAY_HTTP_ERROR:{phase:`post_send`,template:`The gateway answered {method} with HTTP {status}.`,params:{method:`string`,status:`number`,serverMessage:`string`},unrendered:[`serverMessage`]},GATEWAY_WRITE_REJECTED:{phase:`post_send`,template:`GalaChain rejected {method} (Status {chainStatus}, error key "{errorKey}").`,params:{method:`string`,chainStatus:`number`,errorKey:`string`,serverMessage:`string`},unrendered:[`serverMessage`]},GATEWAY_RESPONSE_INVALID:{phase:`post_send`,template:`The gateway answered {method} with something that is not a GalaChain result; the write may have been applied.`,params:{method:`string`}},INVALID_READS_OPTION:{phase:`pre_send`,template:`GatewayReads option {option} is missing or is not of the expected type.`,params:{option:a}},INVALID_PAGE_REQUEST:{phase:`pre_send`,template:`{field} is not valid for a paginated read (got {value}): a page size or page count is a whole number from 1 to 10000, a bookmark a string.`,params:{field:o,value:`string`}},GATEWAY_READ_REJECTED:{phase:`post_send`,template:`GalaChain refused {method} (Status {chainStatus}, error key "{errorKey}").`,params:{method:`string`,chainStatus:`number`,errorKey:`string`,serverMessage:`string`},unrendered:[`serverMessage`]},GATEWAY_READ_RESPONSE_INVALID:{phase:`post_send`,template:`The gateway answered {method} with something that is not a usable GalaChain result.`,params:{method:`string`}},TOKEN_CLASS_NOT_FOUND:{phase:`post_send`,template:`GalaChain has no token class {tokenClassKey}.`,params:{tokenClassKey:`string`}},PAGINATION_LIMIT_EXCEEDED:{phase:`post_send`,template:`Reading every page of {method} takes more than {maxPages} pages; narrow the filter or raise maxPages.`,params:{method:`string`,maxPages:`number`}},WALLET_NOT_CONNECTED:{phase:`pre_send`,template:`The wallet is not connected ({reason}): connect it before {operation}.`,params:{reason:s,operation:`string`}},WALLET_CONNECTION_FAILED:{phase:`pre_send`,template:`Connecting to the wallet failed ({reason}).`,params:{reason:c}},INVALID_WALLET_PROVIDER_CONFIG:{phase:`pre_send`,template:`A wallet provider cannot be built without {missing}.`,params:{missing:l}},PRIVATE_KEY_NOT_ACCESSIBLE:{phase:`pre_send`,template:`This wallet provider signs in the wallet and cannot give out a private key; only a PrivateKeyProvider holds one.`,params:{}},INVALID_WALLET_INPUT:{phase:`pre_send`,template:`The wallet input was refused ({reason}): give a private key (64 hex digits) or a 12- or 24-word mnemonic.`,params:{reason:u}},INVALID_BRIDGE_AMOUNT:{phase:`pre_send`,template:`The bridge amount "{value}" was refused ({reason}).`,params:{value:`string`,reason:f}},UNSUPPORTED_BRIDGE_TOKEN:{phase:`pre_send`,template:`{symbol} cannot be bridged with {network}.`,params:{network:`string`,symbol:`string`}},BRIDGE_NOT_CONFIGURED:{phase:`pre_send`,template:`{network} bridging is not configured: give the bridge a {network} private key (ethereumPrivateKey / solanaPrivateKey).`,params:{network:d}},INVALID_TRANSACTION_HASH:{phase:`pre_send`,template:`"{value}" is not a {network} transaction hash.`,params:{network:d,value:`string`}},INVALID_BRIDGE_OPTION:{phase:`pre_send`,template:`The bridge option {option} is missing or out of range.`,params:{option:`string`}},BRIDGE_RESPONSE_INVALID:{phase:`post_send`,template:`GalaConnect answered {method} without a usable {missing}; the request may have been accepted.`,params:{method:`string`,missing:`string`}},BRIDGE_READ_RESPONSE_INVALID:{phase:`post_send`,template:`GalaConnect answered {method} with something that is not a usable result.`,params:{method:`string`}},BRIDGE_WRITE_OUTCOME_UNKNOWN:{phase:`in_flight`,template:`The outcome of {method} is unknown: the request failed in transit and may have reached GalaConnect. Check it before sending it again.`,params:{method:`string`}},GALACONNECT_HTTP_ERROR:{phase:`post_send`,template:`GalaConnect answered {method} with HTTP {status}.`,params:{method:`string`,status:`number`,serverMessage:`string`},unrendered:[`serverMessage`]},BRIDGE_TOKEN_NOT_FOUND:{phase:`post_send`,template:`GalaConnect has no verified bridge configuration for {symbol}.`,params:{symbol:`string`}},TOKEN_NOT_WRAPPABLE:{phase:`post_send`,template:`{tokenId} cannot be wrapped or unwrapped ({reason}).`,params:{tokenId:`string`,reason:h}},INVALID_WRAP_DIRECTION:{phase:`pre_send`,template:`Cannot {direction} {symbol}: it is on the wrong channel for it (use the other direction).`,params:{symbol:`string`,direction:g}},BRIDGE_REQUEST_REJECTED:{phase:`post_send`,template:`GalaChain refused {method} (Status {chainStatus}, error key "{errorKey}").`,params:{method:`string`,chainStatus:`number`,errorKey:`string`,serverMessage:`string`},unrendered:[`serverMessage`]},BRIDGE_OUT_OUTCOME_UNKNOWN:{phase:`in_flight`,template:`GalaConnect accepted the bridge-out request, which may have locked the tokens, then the bridge-out failed at {step}. Check it before bridging again.`,params:{step:p,bridgeRequestId:`string`},unrendered:[`bridgeRequestId`]},BRIDGE_DEPOSIT_OUTCOME_UNKNOWN:{phase:`in_flight`,template:`The {network} bridge deposit may have been sent, then its {step} failed. Check the deposit before sending another.`,params:{network:d,step:m,transactionHash:`string`},unrendered:[`transactionHash`]},BRIDGE_CHAIN_READ_FAILED:{phase:`post_send`,template:`The {network} read {call} failed or answered something unusable; nothing was sent.`,params:{network:d,call:`string`}},INSUFFICIENT_BRIDGE_BALANCE:{phase:`pre_send`,template:`The {network} balance of {symbol} is {available}; the bridge needs {needed}.`,params:{network:d,symbol:`string`,needed:`string`,available:`string`}},BRIDGE_STATUS_TIMEOUT:{phase:`in_flight`,template:`The bridge transaction did not reach a final status within {timeoutMs} ms (last status {lastStatus}); it may still complete.`,params:{transactionHash:`string`,timeoutMs:`number`,lastStatus:`number`},unrendered:[`transactionHash`]},WALLET_CONTEXT_MISSING:{phase:`pre_send`,template:`The wallet hooks and the wallet context need a WalletProvider above them.`,params:{}}},v=Object.fromEntries(Object.entries(_).map(([e,t])=>[e,t.template])),y=/\{([A-Za-z0-9_]+)\}/gu;function b(e,t){return e.replace(y,(e,n)=>{let r=t[n];return typeof r==`string`||typeof r==`number`||typeof r==`boolean`?String(r):e})}function x(e){return[...new Set([...e.matchAll(y)].map(e=>e[1]))]}export{f as BRIDGE_AMOUNT_PROBLEMS,m as BRIDGE_DEPOSIT_STEPS,d as BRIDGE_NETWORKS,p as BRIDGE_OUT_STEPS,_ as GALA_ERROR_CATALOG,a as GATEWAY_READS_OPTIONS,r as GATEWAY_WRITES_OPTIONS,i as GATEWAY_WRITE_OUTCOME_UNKNOWN_REASONS,e as INVALID_PRIVATE_KEY_REASONS,n as INVALID_TOKEN_REFERENCE_REASONS,o as PAGE_REQUEST_FIELDS,t as SIGNING_FAILURE_REASONS,c as WALLET_CONNECTION_FAILURE_REASONS,u as WALLET_INPUT_PROBLEMS,s as WALLET_NOT_CONNECTED_REASONS,l as WALLET_PROVIDER_CONFIG_MISSING,g as WRAP_DIRECTIONS,h as WRAP_REFUSAL_REASONS,v as galaErrorTemplates,b as renderGalaErrorTemplate,x as templatePlaceholders};
1
+ const e=[`wrong_length`,`bad_encoding`,`not_on_curve`,`no_key_provided`],t=[`user_rejected`,`failed`],n=[`missing`,`ambiguous`,`bad_class_key`,`bad_instance`],r=[`not_a_string`,`empty`,`bad_characters`,`not_a_positive_whole_number`,`above_mint_limit`,`bad_public_key`,`bad_authorities`,`bad_collection_name`],i=[`signer`,`gatewayBaseUrl`,`httpRequestor`,`tokenNameResolver`],a=[`timeout`,`transport`],o=[`gatewayBaseUrl`,`httpRequestor`],s=[`limit`,`pageSize`,`maxPages`,`bookmark`],c=[`not_connected`,`disconnected`,`unauthorized`],l=[`no_accounts`,`user_rejected`,`failed`],u=[`eip1193_provider`,`private_key_or_eip1193_provider`],d=[`empty`,`unrecognized_format`,`unknown_mnemonic_word`,`mnemonic_checksum`],f=[`Ethereum`,`Solana`],p=[`not_a_number`,`not_positive`,`too_many_decimals`],m=[`request_id`,`bridge_token_out`,`transaction_hash`],h=[`send`,`confirmation`,`registration`],g=[`not_listed`,`no_counterpart`,`unknown_channel`],_=[`wrap`,`unwrap`],v={REQUEST_TIMEOUT:{phase:`in_flight`,template:`Request to {url} timed out after {timeoutMs} ms.`,params:{url:`string`,timeoutMs:`number`}},TRANSPORT_ERROR:{phase:`in_flight`,template:`The request to {url} failed before the server answered.`,params:{url:`string`}},INVALID_TIMEOUT:{phase:`pre_send`,template:`{field} must be a positive number of milliseconds, or Infinity for no timeout (got {value}).`,params:{field:`string`,value:`number`}},GALA_WALLET_NOT_AVAILABLE:{phase:`pre_send`,template:`Gala wallet is not available. Please ensure the Gala wallet is connected.`,params:{}},WALLET_UNAVAILABLE:{phase:`pre_send`,template:`No wallet is connected.`,params:{}},MALFORMED_WALLET_REQUEST:{phase:`pre_send`,template:`Wallet {method} request is malformed.`,params:{method:`string`}},UNSUPPORTED_WALLET_METHOD:{phase:`pre_send`,template:`Unsupported wallet method {method}.`,params:{method:`string`}},INVALID_SIGNATURE:{phase:`pre_send`,template:`Wallet returned an invalid {scheme} signature.`,params:{scheme:`string`}},INVALID_CHAIN_ID:{phase:`pre_send`,template:`Wallet returned an invalid chain id ({chainId}).`,params:{chainId:`string`}},SIGNER_ADDRESS_MISMATCH:{phase:`pre_send`,template:`The signing key does not belong to the expected account.`,params:{}},INVALID_PRIVATE_KEY:{phase:`pre_send`,template:`Invalid private key: {reason}.`,params:{reason:e}},SIGNING_FAILED:{phase:`pre_send`,template:`Signing the {method} request failed ({reason}); nothing was sent.`,params:{method:`string`,reason:t}},KEY_PROVIDER_FAILED:{phase:`pre_send`,template:`The signing key could not be fetched; nothing was sent.`,params:{}},INVALID_SIGNING_HASH_LENGTH:{phase:`pre_send`,template:`secp256k1 can only sign a 32-byte hash (got {length}).`,params:{length:`number`}},INVALID_WALLET_ADDRESS:{phase:`pre_send`,template:`Invalid {field}: "{value}" is not an accepted wallet address form.`,params:{field:`string`,value:`string`}},INVALID_ETH_USER_REF_PREFIX:{phase:`pre_send`,template:`Invalid {field}: "{value}" is not a GalaChain user reference. An eth| reference takes the 40 hex digits of the account with no 0x prefix; write it as "{expected}".`,params:{field:`string`,value:`string`,expected:`string`}},INVALID_DECIMAL:{phase:`pre_send`,template:`Invalid decimal quantity: {value}`,params:{value:`string`}},PERSONAL_SIGN_NOT_JSON:{phase:`pre_send`,template:`Personal-sign DTO is not valid JSON`,params:{}},PERSONAL_SIGN_NOT_OBJECT:{phase:`pre_send`,template:`Personal-sign DTO must be a JSON object`,params:{}},PERSONAL_SIGN_BAD_PREFIX:{phase:`pre_send`,template:`Personal-sign DTO prefix is not an EIP-191 "Ethereum Signed Message" header`,params:{}},PERSONAL_SIGN_ENVELOPE_FIELDS:{phase:`pre_send`,template:`Personal-sign DTO carries signing-envelope field(s): {fields}`,params:{fields:`string`}},PERSONAL_SIGN_NOT_CANONICAL:{phase:`pre_send`,template:`Personal-sign DTO is not in canonical serialized form`,params:{}},EIP712_NAME_COLLISION:{phase:`pre_send`,template:`Name collisions are not supported when deriving EIP-712 types ({name}).`,params:{name:`string`}},EIP712_UNSUPPORTED_VALUE:{phase:`pre_send`,template:`Unsupported EIP-712 value of type {valueType}.`,params:{valueType:`string`}},TYPED_DATA_NOT_STRING:{phase:`pre_send`,template:`Invalid typed data: {what} must be a string`,params:{what:`string`}},TYPED_DATA_UNPAIRED_SURROGATE:{phase:`pre_send`,template:`Invalid typed data: {what} has an unpaired surrogate`,params:{what:`string`}},TYPED_DATA_NOT_HEX_BYTES:{phase:`pre_send`,template:`Invalid typed data: {what} must be an even-length 0x hex string`,params:{what:`string`}},TYPED_DATA_NOT_SAFE_INTEGER:{phase:`pre_send`,template:`Invalid typed data: {what} must be a safe integer`,params:{what:`string`}},TYPED_DATA_NOT_INTEGER:{phase:`pre_send`,template:`Invalid typed data: {what} must be an integer`,params:{what:`string`}},TYPED_DATA_NOT_BOOLEAN:{phase:`pre_send`,template:`Invalid typed data: bool must be a boolean`,params:{}},TYPED_DATA_BAD_ADDRESS:{phase:`pre_send`,template:`Invalid typed data: address must be 0x followed by 40 hex digits`,params:{}},TYPED_DATA_BAD_CHECKSUM:{phase:`pre_send`,template:`Invalid typed data: address has a bad checksum`,params:{}},TYPED_DATA_BYTES_LENGTH:{phase:`pre_send`,template:`Invalid typed data: {type} must be exactly {width} bytes`,params:{type:`string`,width:`number`}},TYPED_DATA_OUT_OF_BOUNDS:{phase:`pre_send`,template:`Invalid typed data: value out of bounds for {type}`,params:{type:`string`}},TYPED_DATA_UNSUPPORTED_TYPE:{phase:`pre_send`,template:`Invalid typed data: unsupported type "{type}"`,params:{type:`string`}},TYPED_DATA_FIELDS_NOT_LIST:{phase:`pre_send`,template:`Invalid typed data: type {typeName} must be a list of fields`,params:{typeName:`string`}},TYPED_DATA_FIELD_MALFORMED:{phase:`pre_send`,template:`Invalid typed data: type {typeName} has a field without a string name and type`,params:{typeName:`string`}},TYPED_DATA_INVALID_FIELD_NAME:{phase:`pre_send`,template:`Invalid typed data: invalid field name "{name}"`,params:{name:`string`}},TYPED_DATA_DUPLICATE_FIELD:{phase:`pre_send`,template:`Invalid typed data: duplicate field "{name}" in {typeName}`,params:{name:`string`,typeName:`string`}},TYPED_DATA_INVALID_TYPE_NAME:{phase:`pre_send`,template:`Invalid typed data: invalid type name "{name}"`,params:{name:`string`}},TYPED_DATA_CIRCULAR_TYPE:{phase:`pre_send`,template:`Invalid typed data: circular type reference in {typeName}`,params:{typeName:`string`}},TYPED_DATA_UNKNOWN_FIELD_TYPE:{phase:`pre_send`,template:`Invalid typed data: unknown type "{type}" in {typeName}`,params:{type:`string`,typeName:`string`}},TYPED_DATA_NO_PRIMARY_TYPE:{phase:`pre_send`,template:`Invalid typed data: missing primary type`,params:{}},TYPED_DATA_AMBIGUOUS_PRIMARY_TYPE:{phase:`pre_send`,template:`Invalid typed data: ambiguous primary types or unused types ({roots})`,params:{roots:`string`}},TYPED_DATA_ARRAY_EXPECTED:{phase:`pre_send`,template:`Invalid typed data: {type} array value must be an array`,params:{type:`string`}},TYPED_DATA_ARRAY_LENGTH_MISMATCH:{phase:`pre_send`,template:`Invalid typed data: array length mismatch`,params:{}},TYPED_DATA_STRUCT_NOT_OBJECT:{phase:`pre_send`,template:`Invalid typed data: {typeName} value must be an object`,params:{typeName:`string`}},TYPED_DATA_MISSING_FIELD:{phase:`pre_send`,template:`Invalid typed data: {typeName} value is missing field "{field}"`,params:{typeName:`string`,field:`string`}},TYPED_DATA_DOMAIN_NOT_OBJECT:{phase:`pre_send`,template:`Invalid typed data: domain must be an object`,params:{}},TYPED_DATA_INVALID_DOMAIN_KEY:{phase:`pre_send`,template:`Invalid typed data: invalid typed-data domain key {key}`,params:{key:`string`}},INVALID_UNIQUE_KEY:{phase:`pre_send`,template:`The uniqueKey "{uniqueKey}" must be 1-128 characters of A-Z, a-z, 0-9, ".", "_", ":" or "-".`,params:{uniqueKey:`string`}},INVALID_UNIQUE_KEY_PREFIX:{phase:`pre_send`,template:`uniqueKeyPrefix "{uniqueKeyPrefix}" must be at most {maxLength} characters of A-Z, a-z, 0-9, ".", "_", ":" or "-".`,params:{uniqueKeyPrefix:`string`,maxLength:`number`}},CSPRNG_UNAVAILABLE:{phase:`pre_send`,template:`No cryptographically secure random source (globalThis.crypto.getRandomValues) is available to mint a uniqueKey or a new wallet; install a getRandomValues polyfill (react-native-get-random-values on Hermes).`,params:{}},INVALID_WRITES_OPTION:{phase:`pre_send`,template:`GatewayWrites option {option} is missing or is not of the expected type.`,params:{option:i}},INVALID_QUANTITY:{phase:`pre_send`,template:`{field} must be a positive decimal number of whole tokens, written as a string (got "{value}").`,params:{field:`string`,value:`string`}},INVALID_TOKEN_REFERENCE:{phase:`pre_send`,template:`Invalid token reference {field}: {reason}.`,params:{field:`string`,reason:n}},INVALID_TOKEN_BATCH:{phase:`pre_send`,template:`{method} takes 1 to {max} tokens (got {count}).`,params:{method:`string`,count:`number`,max:`number`}},INVALID_LOCK_EXPIRES:{phase:`pre_send`,template:`expires must be a non-negative whole number of epoch milliseconds, 0 for none (got {value}).`,params:{value:`string`}},INVALID_LOCK_NAME:{phase:`pre_send`,template:`The lock name must be a string (got a {valueType}).`,params:{valueType:`string`}},INVALID_NFT_INPUT:{phase:`pre_send`,template:`Invalid NFT input {field}: {reason}.`,params:{field:`string`,reason:r}},NO_TOKEN_NAME_RESOLVER:{phase:`pre_send`,template:`The token name "{tokenName}" cannot be resolved: no tokenNameResolver is configured. Pass its tokenClassKey instead.`,params:{tokenName:`string`}},TOKEN_NAME_RESOLUTION_FAILED:{phase:`pre_send`,template:`The token name "{tokenName}" could not be resolved to a token class key; nothing was sent.`,params:{tokenName:`string`}},GATEWAY_WRITE_OUTCOME_UNKNOWN:{phase:`in_flight`,template:`The outcome of {method} is unknown ({reason}): the request may have reached the gateway. Check the write by its uniqueKey before sending it again.`,params:{method:`string`,reason:a}},GATEWAY_HTTP_ERROR:{phase:`post_send`,template:`The gateway answered {method} with HTTP {status}.`,params:{method:`string`,status:`number`,serverMessage:`string`},unrendered:[`serverMessage`]},GATEWAY_WRITE_REJECTED:{phase:`post_send`,template:`GalaChain rejected {method} (Status {chainStatus}, error key "{errorKey}").`,params:{method:`string`,chainStatus:`number`,errorKey:`string`,serverMessage:`string`},unrendered:[`serverMessage`]},GATEWAY_RESPONSE_INVALID:{phase:`post_send`,template:`The gateway answered {method} with something that is not a GalaChain result; the write may have been applied.`,params:{method:`string`}},INVALID_READS_OPTION:{phase:`pre_send`,template:`GatewayReads option {option} is missing or is not of the expected type.`,params:{option:o}},INVALID_PAGE_REQUEST:{phase:`pre_send`,template:`{field} is not valid for a paginated read (got {value}): a page size or page count is a whole number from 1 to 10000, a bookmark a string.`,params:{field:s,value:`string`}},GATEWAY_READ_REJECTED:{phase:`post_send`,template:`GalaChain refused {method} (Status {chainStatus}, error key "{errorKey}").`,params:{method:`string`,chainStatus:`number`,errorKey:`string`,serverMessage:`string`},unrendered:[`serverMessage`]},GATEWAY_READ_RESPONSE_INVALID:{phase:`post_send`,template:`The gateway answered {method} with something that is not a usable GalaChain result.`,params:{method:`string`}},TOKEN_CLASS_NOT_FOUND:{phase:`post_send`,template:`GalaChain has no token class {tokenClassKey}.`,params:{tokenClassKey:`string`}},PAGINATION_LIMIT_EXCEEDED:{phase:`post_send`,template:`Reading every page of {method} takes more than {maxPages} pages; narrow the filter or raise maxPages.`,params:{method:`string`,maxPages:`number`}},WALLET_NOT_CONNECTED:{phase:`pre_send`,template:`The wallet is not connected ({reason}): connect it before {operation}.`,params:{reason:c,operation:`string`}},WALLET_CONNECTION_FAILED:{phase:`pre_send`,template:`Connecting to the wallet failed ({reason}).`,params:{reason:l}},INVALID_WALLET_PROVIDER_CONFIG:{phase:`pre_send`,template:`A wallet provider cannot be built without {missing}.`,params:{missing:u}},PRIVATE_KEY_NOT_ACCESSIBLE:{phase:`pre_send`,template:`This wallet provider signs in the wallet and cannot give out a private key; only a PrivateKeyProvider holds one.`,params:{}},INVALID_WALLET_INPUT:{phase:`pre_send`,template:`The wallet input was refused ({reason}): give a private key (64 hex digits) or a 12- or 24-word mnemonic.`,params:{reason:d}},INVALID_BRIDGE_AMOUNT:{phase:`pre_send`,template:`The bridge amount "{value}" was refused ({reason}).`,params:{value:`string`,reason:p}},UNSUPPORTED_BRIDGE_TOKEN:{phase:`pre_send`,template:`{symbol} cannot be bridged with {network}.`,params:{network:`string`,symbol:`string`}},BRIDGE_NOT_CONFIGURED:{phase:`pre_send`,template:`{network} bridging is not configured: give the bridge a {network} private key (ethereumPrivateKey / solanaPrivateKey).`,params:{network:f}},INVALID_TRANSACTION_HASH:{phase:`pre_send`,template:`"{value}" is not a {network} transaction hash.`,params:{network:f,value:`string`}},INVALID_BRIDGE_OPTION:{phase:`pre_send`,template:`The bridge option {option} is missing or out of range.`,params:{option:`string`}},BRIDGE_RESPONSE_INVALID:{phase:`post_send`,template:`GalaConnect answered {method} without a usable {missing}; the request may have been accepted.`,params:{method:`string`,missing:`string`}},BRIDGE_READ_RESPONSE_INVALID:{phase:`post_send`,template:`GalaConnect answered {method} with something that is not a usable result.`,params:{method:`string`}},BRIDGE_WRITE_OUTCOME_UNKNOWN:{phase:`in_flight`,template:`The outcome of {method} is unknown: the request failed in transit and may have reached GalaConnect. Check it before sending it again.`,params:{method:`string`}},GALACONNECT_HTTP_ERROR:{phase:`post_send`,template:`GalaConnect answered {method} with HTTP {status}.`,params:{method:`string`,status:`number`,serverMessage:`string`},unrendered:[`serverMessage`]},BRIDGE_TOKEN_NOT_FOUND:{phase:`post_send`,template:`GalaConnect has no verified bridge configuration for {symbol}.`,params:{symbol:`string`}},TOKEN_NOT_WRAPPABLE:{phase:`post_send`,template:`{tokenId} cannot be wrapped or unwrapped ({reason}).`,params:{tokenId:`string`,reason:g}},INVALID_WRAP_DIRECTION:{phase:`pre_send`,template:`Cannot {direction} {symbol}: it is on the wrong channel for it (use the other direction).`,params:{symbol:`string`,direction:_}},BRIDGE_REQUEST_REJECTED:{phase:`post_send`,template:`GalaChain refused {method} (Status {chainStatus}, error key "{errorKey}").`,params:{method:`string`,chainStatus:`number`,errorKey:`string`,serverMessage:`string`},unrendered:[`serverMessage`]},BRIDGE_OUT_OUTCOME_UNKNOWN:{phase:`in_flight`,template:`GalaConnect accepted the bridge-out request, which may have locked the tokens, then the bridge-out failed at {step}. Check it before bridging again.`,params:{step:m,bridgeRequestId:`string`},unrendered:[`bridgeRequestId`]},BRIDGE_DEPOSIT_OUTCOME_UNKNOWN:{phase:`in_flight`,template:`The {network} bridge deposit may have been sent, then its {step} failed. Check the deposit before sending another.`,params:{network:f,step:h,transactionHash:`string`},unrendered:[`transactionHash`]},BRIDGE_CHAIN_READ_FAILED:{phase:`post_send`,template:`The {network} read {call} failed or answered something unusable; nothing was sent.`,params:{network:f,call:`string`}},INSUFFICIENT_BRIDGE_BALANCE:{phase:`pre_send`,template:`The {network} balance of {symbol} is {available}; the bridge needs {needed}.`,params:{network:f,symbol:`string`,needed:`string`,available:`string`}},BRIDGE_STATUS_TIMEOUT:{phase:`in_flight`,template:`The bridge transaction did not reach a final status within {timeoutMs} ms (last status {lastStatus}); it may still complete.`,params:{transactionHash:`string`,timeoutMs:`number`,lastStatus:`number`},unrendered:[`transactionHash`]},WALLET_CONTEXT_MISSING:{phase:`pre_send`,template:`The wallet hooks and the wallet context need a WalletProvider above them.`,params:{}}},y=Object.fromEntries(Object.entries(v).map(([e,t])=>[e,t.template])),b=/\{([A-Za-z0-9_]+)\}/gu;function x(e,t){return e.replace(b,(e,n)=>{let r=t[n];return typeof r==`string`||typeof r==`number`||typeof r==`boolean`?String(r):e})}function S(e){return[...new Set([...e.matchAll(b)].map(e=>e[1]))]}export{p as BRIDGE_AMOUNT_PROBLEMS,h as BRIDGE_DEPOSIT_STEPS,f as BRIDGE_NETWORKS,m as BRIDGE_OUT_STEPS,v as GALA_ERROR_CATALOG,o as GATEWAY_READS_OPTIONS,i as GATEWAY_WRITES_OPTIONS,a as GATEWAY_WRITE_OUTCOME_UNKNOWN_REASONS,r as INVALID_NFT_INPUT_REASONS,e as INVALID_PRIVATE_KEY_REASONS,n as INVALID_TOKEN_REFERENCE_REASONS,s as PAGE_REQUEST_FIELDS,t as SIGNING_FAILURE_REASONS,l as WALLET_CONNECTION_FAILURE_REASONS,d as WALLET_INPUT_PROBLEMS,c as WALLET_NOT_CONNECTED_REASONS,u as WALLET_PROVIDER_CONFIG_MISSING,_ as WRAP_DIRECTIONS,g as WRAP_REFUSAL_REASONS,y as galaErrorTemplates,x as renderGalaErrorTemplate,S as templatePlaceholders};
2
2
  //# sourceMappingURL=error_catalog.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"error_catalog.js","names":["INVALID_PRIVATE_KEY_REASONS","SIGNING_FAILURE_REASONS","INVALID_TOKEN_REFERENCE_REASONS","GATEWAY_WRITES_OPTIONS","GATEWAY_WRITE_OUTCOME_UNKNOWN_REASONS","GATEWAY_READS_OPTIONS","PAGE_REQUEST_FIELDS","WALLET_NOT_CONNECTED_REASONS","WALLET_CONNECTION_FAILURE_REASONS","WALLET_PROVIDER_CONFIG_MISSING","WALLET_INPUT_PROBLEMS","BRIDGE_NETWORKS","BRIDGE_AMOUNT_PROBLEMS","BRIDGE_OUT_STEPS","BRIDGE_DEPOSIT_STEPS","WRAP_REFUSAL_REASONS","WRAP_DIRECTIONS","GALA_ERROR_CATALOG","galaErrorTemplates","code","entry","PLACEHOLDER","renderGalaErrorTemplate","template","value","params","name","whole","templatePlaceholders","match"],"sources":["../../../src/classes/error_catalog.ts"],"sourcesContent":["/**\n * The catalog of every error `@gala-chain/gala-core-sdk` throws: the SINGLE source of truth for\n * its `code`, the named parameters it carries and the English template its `message` is generated\n * from. A product SDK (gswap-sdk, launchpad-sdk) keeps its OWN catalog of the codes only it throws,\n * and its error class (a subclass of `GalaSDKError`) reads both; no code is defined twice.\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\n * (HTTP status, URL, `uniqueKey`, transaction ids, the raw body, the cause) are typed properties of\n * the error, see {@link GalaErrorContext}.\n */\n\nimport type { GalaErrorPhase } from './error_phases.js';\n\n/**\n * The kinds a param can have: a primitive, or a CLOSED set of string tokens (a readonly tuple).\n * A closed set is a documented union: an app maps each member to its own text and can check that\n * it covered all of them, and a new member is a compile error until it does.\n */\nexport type GalaErrorParamKind = 'string' | 'number' | 'boolean' | readonly string[];\n\n/** One catalog entry (of this catalog, or of a product SDK's own catalog). */\nexport interface GalaErrorCatalogEntry {\n /** The phase this code is thrown in, unless a throw site says otherwise (see {@link GalaErrorPhase}). */\n readonly phase: GalaErrorPhase;\n /** English message template with `{placeholder}` markers. */\n readonly template: string;\n /** Param name to kind. Every param is required and appears in the template, except `unrendered`. */\n readonly params: Readonly<Record<string, GalaErrorParamKind>>;\n /**\n * Params that are carried for the app but deliberately NOT placeholders of the template. Used\n * for `serverMessage` on the codes whose failing answer may be anything (a proxy's page, a\n * validation list): the server's text is data for the app to relay or ignore, and keeping it out\n * of `message` means it cannot reach a log line or a user interface by accident.\n */\n readonly unrendered?: readonly string[];\n}\n\n/**\n * Why a private key was refused (`INVALID_PRIVATE_KEY.params.reason`). A token for the app to map\n * to its own text, never English and never any part of the key.\n *\n * - `wrong_length`: raw bytes that are not 32 bytes long (a `./bridge` Solana secret key: not 64\n * bytes once decoded).\n * - `bad_encoding`: a string that is neither 64 hex characters (optionally `0x`-prefixed, 63 is\n * left-padded) nor a 44-character base64 string (`./bridge`: an Ethereum key that is not `0x`\n * and 64 hex characters; a Solana secret key that is not base58, or whose public half does not\n * match its secret half).\n * - `not_on_curve`: 32 bytes that are not a valid secp256k1 secret scalar.\n * - `no_key_provided`: a lazy key provider returned something that is not a string.\n */\nexport const INVALID_PRIVATE_KEY_REASONS = [\n 'wrong_length',\n 'bad_encoding',\n 'not_on_curve',\n 'no_key_provided',\n] as const;\n\n/** One member of {@link INVALID_PRIVATE_KEY_REASONS}. */\nexport type InvalidPrivateKeyReason = (typeof INVALID_PRIVATE_KEY_REASONS)[number];\n\n/**\n * Why a signer could not produce a signature (`SIGNING_FAILED.params.reason`). A token for the\n * app to map to its own text.\n *\n * - `user_rejected`: the person declined in their wallet (an EIP-1193 `4001`, an ethers\n * `ACTION_REJECTED`, or a wallet that words it \"User rejected/denied ...\"). Nothing is wrong:\n * they may simply try again.\n * - `failed`: anything else the signer threw (a locked wallet, an unreachable extension, a wallet\n * that refused). The original error is `cause`.\n */\nexport const SIGNING_FAILURE_REASONS = ['user_rejected', 'failed'] as const;\n\n/** One member of {@link SIGNING_FAILURE_REASONS}. */\nexport type SigningFailureReason = (typeof SIGNING_FAILURE_REASONS)[number];\n\n/**\n * Why a gateway write refused the token it was asked to move\n * (`INVALID_TOKEN_REFERENCE.params.reason`). A token for the app to map to its own text.\n *\n * - `missing`: neither `tokenClassKey` nor `tokenName` was given.\n * - `ambiguous`: more than one way of naming the token was given (`tokenClassKey` and\n * `tokenName`, or a `tokenName` with an `instance`: a resolved name decides its own instance).\n * - `bad_class_key`: `tokenClassKey` is not a class key: a pipe string needs exactly four\n * non-empty parts, a `$` string at least four (split from the right), an object four non-empty\n * strings. A bare symbol is never a class key and none is derived from it.\n * - `bad_instance`: `instance` is not a string of decimal digits.\n */\nexport const INVALID_TOKEN_REFERENCE_REASONS = [\n 'missing',\n 'ambiguous',\n 'bad_class_key',\n 'bad_instance',\n] as const;\n\n/** One member of {@link INVALID_TOKEN_REFERENCE_REASONS}. */\nexport type InvalidTokenReferenceReason = (typeof INVALID_TOKEN_REFERENCE_REASONS)[number];\n\n/**\n * The `GatewayWrites` options that are refused when missing or of the wrong type\n * (`INVALID_WRITES_OPTION.params.option`). `walletAddress`, `requestTimeoutMs` and\n * `uniqueKeyPrefix` have codes of their own (`INVALID_WALLET_ADDRESS`, `INVALID_TIMEOUT`,\n * `INVALID_UNIQUE_KEY_PREFIX`).\n */\nexport const GATEWAY_WRITES_OPTIONS = [\n 'signer',\n 'gatewayBaseUrl',\n 'httpRequestor',\n 'tokenNameResolver',\n] as const;\n\n/** One member of {@link GATEWAY_WRITES_OPTIONS}. */\nexport type GatewayWritesOption = (typeof GATEWAY_WRITES_OPTIONS)[number];\n\n/**\n * Why the outcome of a gateway write is unknown (`GATEWAY_WRITE_OUTCOME_UNKNOWN.params.reason`).\n * Both say the same thing about the write (it MAY have been applied: never send it again under a\n * fresh key, check `error.uniqueKey` instead) and differ only in what happened to the request.\n *\n * - `timeout`: the POST exceeded `requestTimeoutMs`; the request may still be running.\n * - `transport`: the POST failed before an answer was read (offline, connection reset, DNS, CORS,\n * a body that broke off). The bytes may have reached the gateway.\n */\nexport const GATEWAY_WRITE_OUTCOME_UNKNOWN_REASONS = ['timeout', 'transport'] as const;\n\n/** One member of {@link GATEWAY_WRITE_OUTCOME_UNKNOWN_REASONS}. */\nexport type GatewayWriteOutcomeUnknownReason =\n (typeof GATEWAY_WRITE_OUTCOME_UNKNOWN_REASONS)[number];\n\n/**\n * The `GatewayReads` options that are refused when missing or of the wrong type\n * (`INVALID_READS_OPTION.params.option`). `requestTimeoutMs` has its own code (`INVALID_TIMEOUT`).\n */\nexport const GATEWAY_READS_OPTIONS = ['gatewayBaseUrl', 'httpRequestor'] as const;\n\n/** One member of {@link GATEWAY_READS_OPTIONS}. */\nexport type GatewayReadsOption = (typeof GATEWAY_READS_OPTIONS)[number];\n\n/**\n * The part of a paginated read that was refused (`INVALID_PAGE_REQUEST.params.field`):\n *\n * - `limit` / `pageSize`: results per page, a whole number from 1 to 10 000;\n * - `maxPages`: how many pages a `fetchAll...` read may walk, a whole number from 1 to 10 000;\n * - `bookmark`: the previous page's `nextPageBookmark`, a string.\n */\nexport const PAGE_REQUEST_FIELDS = ['limit', 'pageSize', 'maxPages', 'bookmark'] as const;\n\n/** One member of {@link PAGE_REQUEST_FIELDS}. */\nexport type PageRequestField = (typeof PAGE_REQUEST_FIELDS)[number];\n\n/**\n * Why a wallet provider is not connected (`WALLET_NOT_CONNECTED.params.reason`):\n *\n * - `not_connected`: `connect()` was never called, or `disconnect()` was;\n * - `disconnected`: the wallet reported it is disconnected (EIP-1193 `4900` / `4901`, a\n * `disconnect` event, or an `accountsChanged` with no account);\n * - `unauthorized`: the wallet refused the account (EIP-1193 `4100`): the person has not granted\n * this app access to it.\n */\nexport const WALLET_NOT_CONNECTED_REASONS = [\n 'not_connected',\n 'disconnected',\n 'unauthorized',\n] as const;\n\n/** One member of {@link WALLET_NOT_CONNECTED_REASONS}. */\nexport type WalletNotConnectedReason = (typeof WALLET_NOT_CONNECTED_REASONS)[number];\n\n/**\n * Why connecting a wallet provider failed (`WALLET_CONNECTION_FAILED.params.reason`):\n *\n * - `no_accounts`: the wallet answered `eth_requestAccounts` with no account;\n * - `user_rejected`: the person declined the connection in their wallet (EIP-1193 `4001`);\n * - `failed`: anything else the wallet threw (the original error is `cause`).\n */\nexport const WALLET_CONNECTION_FAILURE_REASONS = [\n 'no_accounts',\n 'user_rejected',\n 'failed',\n] as const;\n\n/** One member of {@link WALLET_CONNECTION_FAILURE_REASONS}. */\nexport type WalletConnectionFailureReason = (typeof WALLET_CONNECTION_FAILURE_REASONS)[number];\n\n/**\n * What a wallet provider was built without (`INVALID_WALLET_PROVIDER_CONFIG.params.missing`):\n *\n * - `eip1193_provider`: an `ExternalWalletProvider` / `GalaWalletProvider` needs the wallet's\n * provider object (`window.ethereum`, an EIP-6963 announcement, `window.gala`);\n * - `private_key_or_eip1193_provider`: `createWalletProvider` needs one of the two.\n */\nexport const WALLET_PROVIDER_CONFIG_MISSING = [\n 'eip1193_provider',\n 'private_key_or_eip1193_provider',\n] as const;\n\n/** One member of {@link WALLET_PROVIDER_CONFIG_MISSING}. */\nexport type WalletProviderConfigMissing = (typeof WALLET_PROVIDER_CONFIG_MISSING)[number];\n\n/**\n * Why `createWallet` refused its input (`INVALID_WALLET_INPUT.params.reason`), never naming any part\n * of it (it may be a key or a mnemonic):\n *\n * - `empty`: nothing but whitespace;\n * - `unrecognized_format`: neither 64 hex digits nor 12 / 24 words of letters;\n * - `unknown_mnemonic_word`: a word that is not in the BIP-39 English wordlist;\n * - `mnemonic_checksum`: every word is known but the phrase's checksum is wrong (a typo or a\n * swapped word).\n */\nexport const WALLET_INPUT_PROBLEMS = [\n 'empty',\n 'unrecognized_format',\n 'unknown_mnemonic_word',\n 'mnemonic_checksum',\n] as const;\n\n/** One member of {@link WALLET_INPUT_PROBLEMS}. */\nexport type WalletInputProblem = (typeof WALLET_INPUT_PROBLEMS)[number];\n\n/** The external networks `./bridge` bridges to and from. */\nexport const BRIDGE_NETWORKS = ['Ethereum', 'Solana'] as const;\n\n/** One member of {@link BRIDGE_NETWORKS}. */\nexport type BridgeNetwork = (typeof BRIDGE_NETWORKS)[number];\n\n/**\n * Why a bridge amount was refused (`INVALID_BRIDGE_AMOUNT.params.reason`):\n *\n * - `not_a_number`: not a finite decimal number;\n * - `not_positive`: zero or negative (a bridge of nothing only wastes the fee);\n * - `too_many_decimals`: more decimal places than the token has (it would be rounded).\n */\nexport const BRIDGE_AMOUNT_PROBLEMS = [\n 'not_a_number',\n 'not_positive',\n 'too_many_decimals',\n] as const;\n\n/** One member of {@link BRIDGE_AMOUNT_PROBLEMS}. */\nexport type BridgeAmountProblem = (typeof BRIDGE_AMOUNT_PROBLEMS)[number];\n\n/**\n * Where a bridge-out failed AFTER GalaConnect accepted its `RequestTokenBridgeOut`\n * (`BRIDGE_OUT_OUTCOME_UNKNOWN.params.step`):\n *\n * - `request_id`: the answer had no bridge request id;\n * - `bridge_token_out`: the `BridgeTokenOut` call failed;\n * - `transaction_hash`: the `BridgeTokenOut` answer had no transaction hash.\n */\nexport const BRIDGE_OUT_STEPS = ['request_id', 'bridge_token_out', 'transaction_hash'] as const;\n\n/** One member of {@link BRIDGE_OUT_STEPS}. */\nexport type BridgeOutStep = (typeof BRIDGE_OUT_STEPS)[number];\n\n/**\n * Where a bridge-in deposit failed once it was being sent (`BRIDGE_DEPOSIT_OUTCOME_UNKNOWN.params.step`):\n *\n * - `send`: sending the deposit transaction failed (it may have reached the network);\n * - `confirmation`: the deposit was sent and its confirmation failed or is unknown;\n * - `registration`: the deposit is confirmed and registering it with GalaConnect failed.\n */\nexport const BRIDGE_DEPOSIT_STEPS = ['send', 'confirmation', 'registration'] as const;\n\n/** One member of {@link BRIDGE_DEPOSIT_STEPS}. */\nexport type BridgeDepositStep = (typeof BRIDGE_DEPOSIT_STEPS)[number];\n\n/**\n * Why a token cannot be wrapped or unwrapped (`TOKEN_NOT_WRAPPABLE.params.reason`):\n *\n * - `not_listed`: the wrappable token list does not have it;\n * - `no_counterpart`: the token it wraps to / unwraps from is not listed;\n * - `unknown_channel`: its channel (or its counterpart's) is not one a wrap moves between.\n */\nexport const WRAP_REFUSAL_REASONS = ['not_listed', 'no_counterpart', 'unknown_channel'] as const;\n\n/** One member of {@link WRAP_REFUSAL_REASONS}. */\nexport type WrapRefusalReason = (typeof WRAP_REFUSAL_REASONS)[number];\n\n/** The two cross-channel directions (`INVALID_WRAP_DIRECTION.params.direction`). */\nexport const WRAP_DIRECTIONS = ['wrap', 'unwrap'] as const;\n\n/** One member of {@link WRAP_DIRECTIONS}. */\nexport type WrapDirection = (typeof WRAP_DIRECTIONS)[number];\n\n/** The whole core catalog. Add a code here before throwing it anywhere in this package. */\nexport const GALA_ERROR_CATALOG = {\n // ---------------------------------------------------------------------------------- transport\n REQUEST_TIMEOUT: {\n phase: 'in_flight',\n template: 'Request to {url} timed out after {timeoutMs} ms.',\n params: { url: 'string', timeoutMs: 'number' },\n },\n TRANSPORT_ERROR: {\n phase: 'in_flight',\n template: 'The request to {url} failed before the server answered.',\n params: { url: 'string' },\n },\n INVALID_TIMEOUT: {\n phase: 'pre_send',\n template:\n '{field} must be a positive number of milliseconds, or Infinity for no timeout (got {value}).',\n params: { field: 'string', value: 'number' },\n },\n\n // ------------------------------------------------------------------------------ wallet / keys\n GALA_WALLET_NOT_AVAILABLE: {\n phase: 'pre_send',\n template: 'Gala wallet is not available. Please ensure the Gala wallet is connected.',\n params: {},\n },\n WALLET_UNAVAILABLE: {\n phase: 'pre_send',\n template: 'No wallet is connected.',\n params: {},\n },\n MALFORMED_WALLET_REQUEST: {\n phase: 'pre_send',\n template: 'Wallet {method} request is malformed.',\n params: { method: 'string' },\n },\n UNSUPPORTED_WALLET_METHOD: {\n phase: 'pre_send',\n template: 'Unsupported wallet method {method}.',\n params: { method: 'string' },\n },\n INVALID_SIGNATURE: {\n phase: 'pre_send',\n template: 'Wallet returned an invalid {scheme} signature.',\n params: { scheme: 'string' },\n },\n INVALID_CHAIN_ID: {\n phase: 'pre_send',\n template: 'Wallet returned an invalid chain id ({chainId}).',\n params: { chainId: 'string' },\n },\n SIGNER_ADDRESS_MISMATCH: {\n phase: 'pre_send',\n template: 'The signing key does not belong to the expected account.',\n params: {},\n },\n INVALID_PRIVATE_KEY: {\n phase: 'pre_send',\n template: 'Invalid private key: {reason}.',\n params: { reason: INVALID_PRIVATE_KEY_REASONS },\n },\n SIGNING_FAILED: {\n phase: 'pre_send',\n template: 'Signing the {method} request failed ({reason}); nothing was sent.',\n params: { method: 'string', reason: SIGNING_FAILURE_REASONS },\n },\n KEY_PROVIDER_FAILED: {\n phase: 'pre_send',\n template: 'The signing key could not be fetched; nothing was sent.',\n params: {},\n },\n INVALID_SIGNING_HASH_LENGTH: {\n phase: 'pre_send',\n template: 'secp256k1 can only sign a 32-byte hash (got {length}).',\n params: { length: 'number' },\n },\n INVALID_WALLET_ADDRESS: {\n phase: 'pre_send',\n template: 'Invalid {field}: \"{value}\" is not an accepted wallet address form.',\n params: { field: 'string', value: 'string' },\n },\n INVALID_ETH_USER_REF_PREFIX: {\n phase: 'pre_send',\n template:\n 'Invalid {field}: \"{value}\" is not a GalaChain user reference. An eth| reference takes the 40 hex digits of the account with no 0x prefix; write it as \"{expected}\".',\n params: { field: 'string', value: 'string', expected: 'string' },\n },\n INVALID_DECIMAL: {\n phase: 'pre_send',\n template: 'Invalid decimal quantity: {value}',\n params: { value: 'string' },\n },\n\n // ------------------------------------------------------------------------- personal-sign DTOs\n PERSONAL_SIGN_NOT_JSON: {\n phase: 'pre_send',\n template: 'Personal-sign DTO is not valid JSON',\n params: {},\n },\n PERSONAL_SIGN_NOT_OBJECT: {\n phase: 'pre_send',\n template: 'Personal-sign DTO must be a JSON object',\n params: {},\n },\n PERSONAL_SIGN_BAD_PREFIX: {\n phase: 'pre_send',\n template: 'Personal-sign DTO prefix is not an EIP-191 \"Ethereum Signed Message\" header',\n params: {},\n },\n PERSONAL_SIGN_ENVELOPE_FIELDS: {\n phase: 'pre_send',\n template: 'Personal-sign DTO carries signing-envelope field(s): {fields}',\n params: { fields: 'string' },\n },\n PERSONAL_SIGN_NOT_CANONICAL: {\n phase: 'pre_send',\n template: 'Personal-sign DTO is not in canonical serialized form',\n params: {},\n },\n\n // ------------------------------------------------------------------ EIP-712 payload derivation\n EIP712_NAME_COLLISION: {\n phase: 'pre_send',\n template: 'Name collisions are not supported when deriving EIP-712 types ({name}).',\n params: { name: 'string' },\n },\n EIP712_UNSUPPORTED_VALUE: {\n phase: 'pre_send',\n template: 'Unsupported EIP-712 value of type {valueType}.',\n params: { valueType: 'string' },\n },\n\n // ----------------------------------------------------------------------------- EIP-712 typed data\n TYPED_DATA_NOT_STRING: {\n phase: 'pre_send',\n template: 'Invalid typed data: {what} must be a string',\n params: { what: 'string' },\n },\n TYPED_DATA_UNPAIRED_SURROGATE: {\n phase: 'pre_send',\n template: 'Invalid typed data: {what} has an unpaired surrogate',\n params: { what: 'string' },\n },\n TYPED_DATA_NOT_HEX_BYTES: {\n phase: 'pre_send',\n template: 'Invalid typed data: {what} must be an even-length 0x hex string',\n params: { what: 'string' },\n },\n TYPED_DATA_NOT_SAFE_INTEGER: {\n phase: 'pre_send',\n template: 'Invalid typed data: {what} must be a safe integer',\n params: { what: 'string' },\n },\n TYPED_DATA_NOT_INTEGER: {\n phase: 'pre_send',\n template: 'Invalid typed data: {what} must be an integer',\n params: { what: 'string' },\n },\n TYPED_DATA_NOT_BOOLEAN: {\n phase: 'pre_send',\n template: 'Invalid typed data: bool must be a boolean',\n params: {},\n },\n TYPED_DATA_BAD_ADDRESS: {\n phase: 'pre_send',\n template: 'Invalid typed data: address must be 0x followed by 40 hex digits',\n params: {},\n },\n TYPED_DATA_BAD_CHECKSUM: {\n phase: 'pre_send',\n template: 'Invalid typed data: address has a bad checksum',\n params: {},\n },\n TYPED_DATA_BYTES_LENGTH: {\n phase: 'pre_send',\n template: 'Invalid typed data: {type} must be exactly {width} bytes',\n params: { type: 'string', width: 'number' },\n },\n TYPED_DATA_OUT_OF_BOUNDS: {\n phase: 'pre_send',\n template: 'Invalid typed data: value out of bounds for {type}',\n params: { type: 'string' },\n },\n TYPED_DATA_UNSUPPORTED_TYPE: {\n phase: 'pre_send',\n template: 'Invalid typed data: unsupported type \"{type}\"',\n params: { type: 'string' },\n },\n TYPED_DATA_FIELDS_NOT_LIST: {\n phase: 'pre_send',\n template: 'Invalid typed data: type {typeName} must be a list of fields',\n params: { typeName: 'string' },\n },\n TYPED_DATA_FIELD_MALFORMED: {\n phase: 'pre_send',\n template: 'Invalid typed data: type {typeName} has a field without a string name and type',\n params: { typeName: 'string' },\n },\n TYPED_DATA_INVALID_FIELD_NAME: {\n phase: 'pre_send',\n template: 'Invalid typed data: invalid field name \"{name}\"',\n params: { name: 'string' },\n },\n TYPED_DATA_DUPLICATE_FIELD: {\n phase: 'pre_send',\n template: 'Invalid typed data: duplicate field \"{name}\" in {typeName}',\n params: { name: 'string', typeName: 'string' },\n },\n TYPED_DATA_INVALID_TYPE_NAME: {\n phase: 'pre_send',\n template: 'Invalid typed data: invalid type name \"{name}\"',\n params: { name: 'string' },\n },\n TYPED_DATA_CIRCULAR_TYPE: {\n phase: 'pre_send',\n template: 'Invalid typed data: circular type reference in {typeName}',\n params: { typeName: 'string' },\n },\n TYPED_DATA_UNKNOWN_FIELD_TYPE: {\n phase: 'pre_send',\n template: 'Invalid typed data: unknown type \"{type}\" in {typeName}',\n params: { type: 'string', typeName: 'string' },\n },\n TYPED_DATA_NO_PRIMARY_TYPE: {\n phase: 'pre_send',\n template: 'Invalid typed data: missing primary type',\n params: {},\n },\n TYPED_DATA_AMBIGUOUS_PRIMARY_TYPE: {\n phase: 'pre_send',\n template: 'Invalid typed data: ambiguous primary types or unused types ({roots})',\n params: { roots: 'string' },\n },\n TYPED_DATA_ARRAY_EXPECTED: {\n phase: 'pre_send',\n template: 'Invalid typed data: {type} array value must be an array',\n params: { type: 'string' },\n },\n TYPED_DATA_ARRAY_LENGTH_MISMATCH: {\n phase: 'pre_send',\n template: 'Invalid typed data: array length mismatch',\n params: {},\n },\n TYPED_DATA_STRUCT_NOT_OBJECT: {\n phase: 'pre_send',\n template: 'Invalid typed data: {typeName} value must be an object',\n params: { typeName: 'string' },\n },\n TYPED_DATA_MISSING_FIELD: {\n phase: 'pre_send',\n template: 'Invalid typed data: {typeName} value is missing field \"{field}\"',\n params: { typeName: 'string', field: 'string' },\n },\n TYPED_DATA_DOMAIN_NOT_OBJECT: {\n phase: 'pre_send',\n template: 'Invalid typed data: domain must be an object',\n params: {},\n },\n TYPED_DATA_INVALID_DOMAIN_KEY: {\n phase: 'pre_send',\n template: 'Invalid typed data: invalid typed-data domain key {key}',\n params: { key: 'string' },\n },\n\n // ---------------------------------------------------------------------------------- unique keys\n INVALID_UNIQUE_KEY: {\n phase: 'pre_send',\n template:\n 'The uniqueKey \"{uniqueKey}\" must be 1-128 characters of A-Z, a-z, 0-9, \".\", \"_\", \":\" or \"-\".',\n params: { uniqueKey: 'string' },\n },\n INVALID_UNIQUE_KEY_PREFIX: {\n phase: 'pre_send',\n template:\n 'uniqueKeyPrefix \"{uniqueKeyPrefix}\" must be at most {maxLength} characters of A-Z, a-z, 0-9, \".\", \"_\", \":\" or \"-\".',\n params: { uniqueKeyPrefix: 'string', maxLength: 'number' },\n },\n CSPRNG_UNAVAILABLE: {\n phase: 'pre_send',\n template:\n 'No cryptographically secure random source (globalThis.crypto.getRandomValues) is available to mint a uniqueKey or a new wallet; install a getRandomValues polyfill (react-native-get-random-values on Hermes).',\n params: {},\n },\n\n // ----------------------------------------------------------------------------- gateway writes\n INVALID_WRITES_OPTION: {\n phase: 'pre_send',\n template: 'GatewayWrites option {option} is missing or is not of the expected type.',\n params: { option: GATEWAY_WRITES_OPTIONS },\n },\n INVALID_QUANTITY: {\n phase: 'pre_send',\n template:\n '{field} must be a positive decimal number of whole tokens, written as a string (got \"{value}\").',\n params: { field: 'string', value: 'string' },\n },\n INVALID_TOKEN_REFERENCE: {\n phase: 'pre_send',\n template: 'Invalid token reference {field}: {reason}.',\n params: { field: 'string', reason: INVALID_TOKEN_REFERENCE_REASONS },\n },\n INVALID_TOKEN_BATCH: {\n phase: 'pre_send',\n template: '{method} takes 1 to {max} tokens (got {count}).',\n params: { method: 'string', count: 'number', max: 'number' },\n },\n INVALID_LOCK_EXPIRES: {\n phase: 'pre_send',\n template:\n 'expires must be a non-negative whole number of epoch milliseconds, 0 for none (got {value}).',\n params: { value: 'string' },\n },\n INVALID_LOCK_NAME: {\n phase: 'pre_send',\n template: 'The lock name must be a string (got a {valueType}).',\n params: { valueType: 'string' },\n },\n NO_TOKEN_NAME_RESOLVER: {\n phase: 'pre_send',\n template:\n 'The token name \"{tokenName}\" cannot be resolved: no tokenNameResolver is configured. Pass its tokenClassKey instead.',\n params: { tokenName: 'string' },\n },\n TOKEN_NAME_RESOLUTION_FAILED: {\n phase: 'pre_send',\n template:\n 'The token name \"{tokenName}\" could not be resolved to a token class key; nothing was sent.',\n params: { tokenName: 'string' },\n },\n GATEWAY_WRITE_OUTCOME_UNKNOWN: {\n phase: 'in_flight',\n template:\n 'The outcome of {method} is unknown ({reason}): the request may have reached the gateway. Check the write by its uniqueKey before sending it again.',\n params: { method: 'string', reason: GATEWAY_WRITE_OUTCOME_UNKNOWN_REASONS },\n },\n GATEWAY_HTTP_ERROR: {\n phase: 'post_send',\n template: 'The gateway answered {method} with HTTP {status}.',\n params: { method: 'string', status: 'number', serverMessage: 'string' },\n unrendered: ['serverMessage'],\n },\n GATEWAY_WRITE_REJECTED: {\n phase: 'post_send',\n template: 'GalaChain rejected {method} (Status {chainStatus}, error key \"{errorKey}\").',\n params: {\n method: 'string',\n chainStatus: 'number',\n errorKey: 'string',\n serverMessage: 'string',\n },\n unrendered: ['serverMessage'],\n },\n GATEWAY_RESPONSE_INVALID: {\n phase: 'post_send',\n template:\n 'The gateway answered {method} with something that is not a GalaChain result; the write may have been applied.',\n params: { method: 'string' },\n },\n\n // ------------------------------------------------------------------------------ gateway reads\n INVALID_READS_OPTION: {\n phase: 'pre_send',\n template: 'GatewayReads option {option} is missing or is not of the expected type.',\n params: { option: GATEWAY_READS_OPTIONS },\n },\n INVALID_PAGE_REQUEST: {\n phase: 'pre_send',\n template:\n '{field} is not valid for a paginated read (got {value}): a page size or page count is a whole number from 1 to 10000, a bookmark a string.',\n params: { field: PAGE_REQUEST_FIELDS, value: 'string' },\n },\n GATEWAY_READ_REJECTED: {\n phase: 'post_send',\n template: 'GalaChain refused {method} (Status {chainStatus}, error key \"{errorKey}\").',\n params: {\n method: 'string',\n chainStatus: 'number',\n errorKey: 'string',\n serverMessage: 'string',\n },\n unrendered: ['serverMessage'],\n },\n GATEWAY_READ_RESPONSE_INVALID: {\n phase: 'post_send',\n template: 'The gateway answered {method} with something that is not a usable GalaChain result.',\n params: { method: 'string' },\n },\n TOKEN_CLASS_NOT_FOUND: {\n phase: 'post_send',\n template: 'GalaChain has no token class {tokenClassKey}.',\n params: { tokenClassKey: 'string' },\n },\n PAGINATION_LIMIT_EXCEEDED: {\n phase: 'post_send',\n template:\n 'Reading every page of {method} takes more than {maxPages} pages; narrow the filter or raise maxPages.',\n params: { method: 'string', maxPages: 'number' },\n },\n\n // ------------------------------------------------------------- wallet providers (`./providers`)\n WALLET_NOT_CONNECTED: {\n phase: 'pre_send',\n template: 'The wallet is not connected ({reason}): connect it before {operation}.',\n params: { reason: WALLET_NOT_CONNECTED_REASONS, operation: 'string' },\n },\n WALLET_CONNECTION_FAILED: {\n phase: 'pre_send',\n template: 'Connecting to the wallet failed ({reason}).',\n params: { reason: WALLET_CONNECTION_FAILURE_REASONS },\n },\n INVALID_WALLET_PROVIDER_CONFIG: {\n phase: 'pre_send',\n template: 'A wallet provider cannot be built without {missing}.',\n params: { missing: WALLET_PROVIDER_CONFIG_MISSING },\n },\n PRIVATE_KEY_NOT_ACCESSIBLE: {\n phase: 'pre_send',\n template:\n 'This wallet provider signs in the wallet and cannot give out a private key; only a PrivateKeyProvider holds one.',\n params: {},\n },\n\n // ----------------------------------------------------------------------------- wallet helpers\n INVALID_WALLET_INPUT: {\n phase: 'pre_send',\n template:\n 'The wallet input was refused ({reason}): give a private key (64 hex digits) or a 12- or 24-word mnemonic.',\n params: { reason: WALLET_INPUT_PROBLEMS },\n },\n\n // ------------------------------------------------------------------------ bridge (`./bridge`)\n INVALID_BRIDGE_AMOUNT: {\n phase: 'pre_send',\n template: 'The bridge amount \"{value}\" was refused ({reason}).',\n params: { value: 'string', reason: BRIDGE_AMOUNT_PROBLEMS },\n },\n UNSUPPORTED_BRIDGE_TOKEN: {\n phase: 'pre_send',\n template: '{symbol} cannot be bridged with {network}.',\n params: { network: 'string', symbol: 'string' },\n },\n BRIDGE_NOT_CONFIGURED: {\n phase: 'pre_send',\n template:\n '{network} bridging is not configured: give the bridge a {network} private key (ethereumPrivateKey / solanaPrivateKey).',\n params: { network: BRIDGE_NETWORKS },\n },\n INVALID_TRANSACTION_HASH: {\n phase: 'pre_send',\n template: '\"{value}\" is not a {network} transaction hash.',\n params: { network: BRIDGE_NETWORKS, value: 'string' },\n },\n INVALID_BRIDGE_OPTION: {\n phase: 'pre_send',\n template: 'The bridge option {option} is missing or out of range.',\n params: { option: 'string' },\n },\n BRIDGE_RESPONSE_INVALID: {\n phase: 'post_send',\n template:\n 'GalaConnect answered {method} without a usable {missing}; the request may have been accepted.',\n params: { method: 'string', missing: 'string' },\n },\n BRIDGE_READ_RESPONSE_INVALID: {\n phase: 'post_send',\n template: 'GalaConnect answered {method} with something that is not a usable result.',\n params: { method: 'string' },\n },\n BRIDGE_WRITE_OUTCOME_UNKNOWN: {\n phase: 'in_flight',\n template:\n 'The outcome of {method} is unknown: the request failed in transit and may have reached GalaConnect. Check it before sending it again.',\n params: { method: 'string' },\n },\n GALACONNECT_HTTP_ERROR: {\n phase: 'post_send',\n template: 'GalaConnect answered {method} with HTTP {status}.',\n params: { method: 'string', status: 'number', serverMessage: 'string' },\n unrendered: ['serverMessage'],\n },\n BRIDGE_TOKEN_NOT_FOUND: {\n phase: 'post_send',\n template: 'GalaConnect has no verified bridge configuration for {symbol}.',\n params: { symbol: 'string' },\n },\n TOKEN_NOT_WRAPPABLE: {\n phase: 'post_send',\n template: '{tokenId} cannot be wrapped or unwrapped ({reason}).',\n params: { tokenId: 'string', reason: WRAP_REFUSAL_REASONS },\n },\n INVALID_WRAP_DIRECTION: {\n phase: 'pre_send',\n template:\n 'Cannot {direction} {symbol}: it is on the wrong channel for it (use the other direction).',\n params: { symbol: 'string', direction: WRAP_DIRECTIONS },\n },\n BRIDGE_REQUEST_REJECTED: {\n phase: 'post_send',\n template: 'GalaChain refused {method} (Status {chainStatus}, error key \"{errorKey}\").',\n params: {\n method: 'string',\n chainStatus: 'number',\n errorKey: 'string',\n serverMessage: 'string',\n },\n unrendered: ['serverMessage'],\n },\n BRIDGE_OUT_OUTCOME_UNKNOWN: {\n phase: 'in_flight',\n template:\n 'GalaConnect accepted the bridge-out request, which may have locked the tokens, then the bridge-out failed at {step}. Check it before bridging again.',\n params: { step: BRIDGE_OUT_STEPS, bridgeRequestId: 'string' },\n unrendered: ['bridgeRequestId'],\n },\n BRIDGE_DEPOSIT_OUTCOME_UNKNOWN: {\n phase: 'in_flight',\n template:\n 'The {network} bridge deposit may have been sent, then its {step} failed. Check the deposit before sending another.',\n params: { network: BRIDGE_NETWORKS, step: BRIDGE_DEPOSIT_STEPS, transactionHash: 'string' },\n unrendered: ['transactionHash'],\n },\n BRIDGE_CHAIN_READ_FAILED: {\n phase: 'post_send',\n template: 'The {network} read {call} failed or answered something unusable; nothing was sent.',\n params: { network: BRIDGE_NETWORKS, call: 'string' },\n },\n INSUFFICIENT_BRIDGE_BALANCE: {\n phase: 'pre_send',\n template: 'The {network} balance of {symbol} is {available}; the bridge needs {needed}.',\n params: { network: BRIDGE_NETWORKS, symbol: 'string', needed: 'string', available: 'string' },\n },\n BRIDGE_STATUS_TIMEOUT: {\n phase: 'in_flight',\n template:\n 'The bridge transaction did not reach a final status within {timeoutMs} ms (last status {lastStatus}); it may still complete.',\n params: { transactionHash: 'string', timeoutMs: 'number', lastStatus: 'number' },\n unrendered: ['transactionHash'],\n },\n\n // ------------------------------------------------------------------- React context (`./react`)\n WALLET_CONTEXT_MISSING: {\n phase: 'pre_send',\n template: 'The wallet hooks and the wallet context need a WalletProvider above them.',\n params: {},\n },\n} as const satisfies Record<string, GalaErrorCatalogEntry>;\n\n/** Every error code the core SDK can throw. */\nexport type GalaErrorCode = keyof typeof GALA_ERROR_CATALOG;\n\ninterface KindToType {\n string: string;\n number: number;\n boolean: boolean;\n}\n\n/** The value type of a param kind: a primitive, or the union of a closed set's members. */\ntype ParamValue<K> = K extends readonly (infer Member)[]\n ? Member\n : K extends keyof KindToType\n ? KindToType[K]\n : never;\n\n/**\n * The named params of code `C` of ANY catalog object (`typeof SOME_CATALOG`): a flat object of\n * primitives (or closed string tokens). A product SDK derives its own params type from its\n * catalog with it, so every catalog types its params the same way.\n */\nexport type ErrorParamsOf<\n Catalog extends Readonly<Record<string, GalaErrorCatalogEntry>>,\n C extends keyof Catalog,\n> = {\n readonly [P in keyof Catalog[C]['params']]: ParamValue<Catalog[C]['params'][P]>;\n};\n\n/** The named params of one core error code. */\nexport type GalaErrorParams<C extends GalaErrorCode> = ErrorParamsOf<typeof GALA_ERROR_CATALOG, C>;\n\n/**\n * The English template of every core error code, `{placeholder}` markers included. An optional\n * seed or fallback for an app's own translations; the SDK's `message` is generated from it. A\n * product SDK exports the templates of its own codes next to it.\n */\nexport const galaErrorTemplates: { readonly [C in GalaErrorCode]: string } = Object.fromEntries(\n Object.entries(GALA_ERROR_CATALOG).map(([code, entry]) => [code, entry.template]),\n) as { readonly [C in GalaErrorCode]: string };\n\nconst PLACEHOLDER = /\\{([A-Za-z0-9_]+)\\}/gu;\n\n/** Fills a template's `{placeholders}` from `params`; an unknown placeholder is left as written. */\nexport function renderGalaErrorTemplate(\n template: string,\n params: Readonly<Record<string, unknown>>,\n): string {\n return template.replace(PLACEHOLDER, (whole, name: string) => {\n const value = params[name];\n return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean'\n ? String(value)\n : whole;\n });\n}\n\n/** The placeholder names a template uses, in order of first appearance. */\nexport function templatePlaceholders(template: string): string[] {\n return [...new Set([...template.matchAll(PLACEHOLDER)].map((match) => match[1] as string))];\n}\n"],"mappings":"AA6DA,MAAaA,EAA8B,CACzC,eACA,eACA,eACA,iBACF,EAeaC,EAA0B,CAAC,gBAAiB,QAAQ,EAiBpDC,EAAkC,CAC7C,UACA,YACA,gBACA,cACF,EAWaC,EAAyB,CACpC,SACA,iBACA,gBACA,mBACF,EAcaC,EAAwC,CAAC,UAAW,WAAW,EAU/DC,EAAwB,CAAC,iBAAkB,eAAe,EAY1DC,EAAsB,CAAC,QAAS,WAAY,WAAY,UAAU,EAclEC,EAA+B,CAC1C,gBACA,eACA,cACF,EAYaC,EAAoC,CAC/C,cACA,gBAC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INVALID_NFT_INPUT_REASONS","GATEWAY_WRITES_OPTIONS","GATEWAY_WRITE_OUTCOME_UNKNOWN_REASONS","GATEWAY_READS_OPTIONS","PAGE_REQUEST_FIELDS","WALLET_NOT_CONNECTED_REASONS","WALLET_CONNECTION_FAILURE_REASONS","WALLET_PROVIDER_CONFIG_MISSING","WALLET_INPUT_PROBLEMS","BRIDGE_NETWORKS","BRIDGE_AMOUNT_PROBLEMS","BRIDGE_OUT_STEPS","BRIDGE_DEPOSIT_STEPS","WRAP_REFUSAL_REASONS","WRAP_DIRECTIONS","GALA_ERROR_CATALOG","galaErrorTemplates","code","entry","PLACEHOLDER","renderGalaErrorTemplate","template","value","params","name","whole","templatePlaceholders","match"],"sources":["../../../src/classes/error_catalog.ts"],"sourcesContent":["/**\n * The catalog of every error `@gala-chain/gala-core-sdk` throws: the SINGLE source of truth for\n * its `code`, the named parameters it carries and the English template its `message` is generated\n * from. A product SDK (gswap-sdk, launchpad-sdk) keeps its OWN catalog of the codes only it throws,\n * and its error class (a subclass of `GalaSDKError`) reads both; no code is defined twice.\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\n * (HTTP status, URL, `uniqueKey`, transaction ids, the raw body, the cause) are typed properties of\n * the error, see {@link GalaErrorContext}.\n */\n\nimport type { GalaErrorPhase } from './error_phases.js';\n\n/**\n * The kinds a param can have: a primitive, or a CLOSED set of string tokens (a readonly tuple).\n * A closed set is a documented union: an app maps each member to its own text and can check that\n * it covered all of them, and a new member is a compile error until it does.\n */\nexport type GalaErrorParamKind = 'string' | 'number' | 'boolean' | readonly string[];\n\n/** One catalog entry (of this catalog, or of a product SDK's own catalog). */\nexport interface GalaErrorCatalogEntry {\n /** The phase this code is thrown in, unless a throw site says otherwise (see {@link GalaErrorPhase}). */\n readonly phase: GalaErrorPhase;\n /** English message template with `{placeholder}` markers. */\n readonly template: string;\n /** Param name to kind. Every param is required and appears in the template, except `unrendered`. */\n readonly params: Readonly<Record<string, GalaErrorParamKind>>;\n /**\n * Params that are carried for the app but deliberately NOT placeholders of the template. Used\n * for `serverMessage` on the codes whose failing answer may be anything (a proxy's page, a\n * validation list): the server's text is data for the app to relay or ignore, and keeping it out\n * of `message` means it cannot reach a log line or a user interface by accident.\n */\n readonly unrendered?: readonly string[];\n}\n\n/**\n * Why a private key was refused (`INVALID_PRIVATE_KEY.params.reason`). A token for the app to map\n * to its own text, never English and never any part of the key.\n *\n * - `wrong_length`: raw bytes that are not 32 bytes long (a `./bridge` Solana secret key: not 64\n * bytes once decoded).\n * - `bad_encoding`: a string that is neither 64 hex characters (optionally `0x`-prefixed, 63 is\n * left-padded) nor a 44-character base64 string (`./bridge`: an Ethereum key that is not `0x`\n * and 64 hex characters; a Solana secret key that is not base58, or whose public half does not\n * match its secret half).\n * - `not_on_curve`: 32 bytes that are not a valid secp256k1 secret scalar.\n * - `no_key_provided`: a lazy key provider returned something that is not a string.\n */\nexport const INVALID_PRIVATE_KEY_REASONS = [\n 'wrong_length',\n 'bad_encoding',\n 'not_on_curve',\n 'no_key_provided',\n] as const;\n\n/** One member of {@link INVALID_PRIVATE_KEY_REASONS}. */\nexport type InvalidPrivateKeyReason = (typeof INVALID_PRIVATE_KEY_REASONS)[number];\n\n/**\n * Why a signer could not produce a signature (`SIGNING_FAILED.params.reason`). A token for the\n * app to map to its own text.\n *\n * - `user_rejected`: the person declined in their wallet (an EIP-1193 `4001`, an ethers\n * `ACTION_REJECTED`, or a wallet that words it \"User rejected/denied ...\"). Nothing is wrong:\n * they may simply try again.\n * - `failed`: anything else the signer threw (a locked wallet, an unreachable extension, a wallet\n * that refused). The original error is `cause`.\n */\nexport const SIGNING_FAILURE_REASONS = ['user_rejected', 'failed'] as const;\n\n/** One member of {@link SIGNING_FAILURE_REASONS}. */\nexport type SigningFailureReason = (typeof SIGNING_FAILURE_REASONS)[number];\n\n/**\n * Why a gateway write refused the token it was asked to move\n * (`INVALID_TOKEN_REFERENCE.params.reason`). A token for the app to map to its own text.\n *\n * - `missing`: neither `tokenClassKey` nor `tokenName` was given.\n * - `ambiguous`: more than one way of naming the token was given (`tokenClassKey` and\n * `tokenName`, or a `tokenName` with an `instance`: a resolved name decides its own instance).\n * - `bad_class_key`: `tokenClassKey` is not a class key: a pipe string needs exactly four\n * non-empty parts, a `$` string at least four (split from the right), an object four non-empty\n * strings. A bare symbol is never a class key and none is derived from it.\n * - `bad_instance`: `instance` is not a string of decimal digits.\n */\nexport const INVALID_TOKEN_REFERENCE_REASONS = [\n 'missing',\n 'ambiguous',\n 'bad_class_key',\n 'bad_instance',\n] as const;\n\n/** One member of {@link INVALID_TOKEN_REFERENCE_REASONS}. */\nexport type InvalidTokenReferenceReason = (typeof INVALID_TOKEN_REFERENCE_REASONS)[number];\n\n/**\n * Why an NFT read's, write's or fee quote's input is refused (`INVALID_NFT_INPUT.params.reason`).\n * A token for the app to map to its own text.\n */\nexport const INVALID_NFT_INPUT_REASONS = [\n 'not_a_string',\n 'empty',\n 'bad_characters',\n 'not_a_positive_whole_number',\n 'above_mint_limit',\n 'bad_public_key',\n 'bad_authorities',\n 'bad_collection_name',\n] as const;\n\n/** One member of {@link INVALID_NFT_INPUT_REASONS}. */\nexport type InvalidNftInputReason = (typeof INVALID_NFT_INPUT_REASONS)[number];\n\n/**\n * The `GatewayWrites` options that are refused when missing or of the wrong type\n * (`INVALID_WRITES_OPTION.params.option`). `walletAddress`, `requestTimeoutMs` and\n * `uniqueKeyPrefix` have codes of their own (`INVALID_WALLET_ADDRESS`, `INVALID_TIMEOUT`,\n * `INVALID_UNIQUE_KEY_PREFIX`).\n */\nexport const GATEWAY_WRITES_OPTIONS = [\n 'signer',\n 'gatewayBaseUrl',\n 'httpRequestor',\n 'tokenNameResolver',\n] as const;\n\n/** One member of {@link GATEWAY_WRITES_OPTIONS}. */\nexport type GatewayWritesOption = (typeof GATEWAY_WRITES_OPTIONS)[number];\n\n/**\n * Why the outcome of a gateway write is unknown (`GATEWAY_WRITE_OUTCOME_UNKNOWN.params.reason`).\n * Both say the same thing about the write (it MAY have been applied: never send it again under a\n * fresh key, check `error.uniqueKey` instead) and differ only in what happened to the request.\n *\n * - `timeout`: the POST exceeded `requestTimeoutMs`; the request may still be running.\n * - `transport`: the POST failed before an answer was read (offline, connection reset, DNS, CORS,\n * a body that broke off). The bytes may have reached the gateway.\n */\nexport const GATEWAY_WRITE_OUTCOME_UNKNOWN_REASONS = ['timeout', 'transport'] as const;\n\n/** One member of {@link GATEWAY_WRITE_OUTCOME_UNKNOWN_REASONS}. */\nexport type GatewayWriteOutcomeUnknownReason =\n (typeof GATEWAY_WRITE_OUTCOME_UNKNOWN_REASONS)[number];\n\n/**\n * The `GatewayReads` options that are refused when missing or of the wrong type\n * (`INVALID_READS_OPTION.params.option`). `requestTimeoutMs` has its own code (`INVALID_TIMEOUT`).\n */\nexport const GATEWAY_READS_OPTIONS = ['gatewayBaseUrl', 'httpRequestor'] as const;\n\n/** One member of {@link GATEWAY_READS_OPTIONS}. */\nexport type GatewayReadsOption = (typeof GATEWAY_READS_OPTIONS)[number];\n\n/**\n * The part of a paginated read that was refused (`INVALID_PAGE_REQUEST.params.field`):\n *\n * - `limit` / `pageSize`: results per page, a whole number from 1 to 10 000;\n * - `maxPages`: how many pages a `fetchAll...` read may walk, a whole number from 1 to 10 000;\n * - `bookmark`: the previous page's `nextPageBookmark`, a string.\n */\nexport const PAGE_REQUEST_FIELDS = ['limit', 'pageSize', 'maxPages', 'bookmark'] as const;\n\n/** One member of {@link PAGE_REQUEST_FIELDS}. */\nexport type PageRequestField = (typeof PAGE_REQUEST_FIELDS)[number];\n\n/**\n * Why a wallet provider is not connected (`WALLET_NOT_CONNECTED.params.reason`):\n *\n * - `not_connected`: `connect()` was never called, or `disconnect()` was;\n * - `disconnected`: the wallet reported it is disconnected (EIP-1193 `4900` / `4901`, a\n * `disconnect` event, or an `accountsChanged` with no account);\n * - `unauthorized`: the wallet refused the account (EIP-1193 `4100`): the person has not granted\n * this app access to it.\n */\nexport const WALLET_NOT_CONNECTED_REASONS = [\n 'not_connected',\n 'disconnected',\n 'unauthorized',\n] as const;\n\n/** One member of {@link WALLET_NOT_CONNECTED_REASONS}. */\nexport type WalletNotConnectedReason = (typeof WALLET_NOT_CONNECTED_REASONS)[number];\n\n/**\n * Why connecting a wallet provider failed (`WALLET_CONNECTION_FAILED.params.reason`):\n *\n * - `no_accounts`: the wallet answered `eth_requestAccounts` with no account;\n * - `user_rejected`: the person declined the connection in their wallet (EIP-1193 `4001`);\n * - `failed`: anything else the wallet threw (the original error is `cause`).\n */\nexport const WALLET_CONNECTION_FAILURE_REASONS = [\n 'no_accounts',\n 'user_rejected',\n 'failed',\n] as const;\n\n/** One member of {@link WALLET_CONNECTION_FAILURE_REASONS}. */\nexport type WalletConnectionFailureReason = (typeof WALLET_CONNECTION_FAILURE_REASONS)[number];\n\n/**\n * What a wallet provider was built without (`INVALID_WALLET_PROVIDER_CONFIG.params.missing`):\n *\n * - `eip1193_provider`: an `ExternalWalletProvider` / `GalaWalletProvider` needs the wallet's\n * provider object (`window.ethereum`, an EIP-6963 announcement, `window.gala`);\n * - `private_key_or_eip1193_provider`: `createWalletProvider` needs one of the two.\n */\nexport const WALLET_PROVIDER_CONFIG_MISSING = [\n 'eip1193_provider',\n 'private_key_or_eip1193_provider',\n] as const;\n\n/** One member of {@link WALLET_PROVIDER_CONFIG_MISSING}. */\nexport type WalletProviderConfigMissing = (typeof WALLET_PROVIDER_CONFIG_MISSING)[number];\n\n/**\n * Why `createWallet` refused its input (`INVALID_WALLET_INPUT.params.reason`), never naming any part\n * of it (it may be a key or a mnemonic):\n *\n * - `empty`: nothing but whitespace;\n * - `unrecognized_format`: neither 64 hex digits nor 12 / 24 words of letters;\n * - `unknown_mnemonic_word`: a word that is not in the BIP-39 English wordlist;\n * - `mnemonic_checksum`: every word is known but the phrase's checksum is wrong (a typo or a\n * swapped word).\n */\nexport const WALLET_INPUT_PROBLEMS = [\n 'empty',\n 'unrecognized_format',\n 'unknown_mnemonic_word',\n 'mnemonic_checksum',\n] as const;\n\n/** One member of {@link WALLET_INPUT_PROBLEMS}. */\nexport type WalletInputProblem = (typeof WALLET_INPUT_PROBLEMS)[number];\n\n/** The external networks `./bridge` bridges to and from. */\nexport const BRIDGE_NETWORKS = ['Ethereum', 'Solana'] as const;\n\n/** One member of {@link BRIDGE_NETWORKS}. */\nexport type BridgeNetwork = (typeof BRIDGE_NETWORKS)[number];\n\n/**\n * Why a bridge amount was refused (`INVALID_BRIDGE_AMOUNT.params.reason`):\n *\n * - `not_a_number`: not a finite decimal number;\n * - `not_positive`: zero or negative (a bridge of nothing only wastes the fee);\n * - `too_many_decimals`: more decimal places than the token has (it would be rounded).\n */\nexport const BRIDGE_AMOUNT_PROBLEMS = [\n 'not_a_number',\n 'not_positive',\n 'too_many_decimals',\n] as const;\n\n/** One member of {@link BRIDGE_AMOUNT_PROBLEMS}. */\nexport type BridgeAmountProblem = (typeof BRIDGE_AMOUNT_PROBLEMS)[number];\n\n/**\n * Where a bridge-out failed AFTER GalaConnect accepted its `RequestTokenBridgeOut`\n * (`BRIDGE_OUT_OUTCOME_UNKNOWN.params.step`):\n *\n * - `request_id`: the answer had no bridge request id;\n * - `bridge_token_out`: the `BridgeTokenOut` call failed;\n * - `transaction_hash`: the `BridgeTokenOut` answer had no transaction hash.\n */\nexport const BRIDGE_OUT_STEPS = ['request_id', 'bridge_token_out', 'transaction_hash'] as const;\n\n/** One member of {@link BRIDGE_OUT_STEPS}. */\nexport type BridgeOutStep = (typeof BRIDGE_OUT_STEPS)[number];\n\n/**\n * Where a bridge-in deposit failed once it was being sent (`BRIDGE_DEPOSIT_OUTCOME_UNKNOWN.params.step`):\n *\n * - `send`: sending the deposit transaction failed (it may have reached the network);\n * - `confirmation`: the deposit was sent and its confirmation failed or is unknown;\n * - `registration`: the deposit is confirmed and registering it with GalaConnect failed.\n */\nexport const BRIDGE_DEPOSIT_STEPS = ['send', 'confirmation', 'registration'] as const;\n\n/** One member of {@link BRIDGE_DEPOSIT_STEPS}. */\nexport type BridgeDepositStep = (typeof BRIDGE_DEPOSIT_STEPS)[number];\n\n/**\n * Why a token cannot be wrapped or unwrapped (`TOKEN_NOT_WRAPPABLE.params.reason`):\n *\n * - `not_listed`: the wrappable token list does not have it;\n * - `no_counterpart`: the token it wraps to / unwraps from is not listed;\n * - `unknown_channel`: its channel (or its counterpart's) is not one a wrap moves between.\n */\nexport const WRAP_REFUSAL_REASONS = ['not_listed', 'no_counterpart', 'unknown_channel'] as const;\n\n/** One member of {@link WRAP_REFUSAL_REASONS}. */\nexport type WrapRefusalReason = (typeof WRAP_REFUSAL_REASONS)[number];\n\n/** The two cross-channel directions (`INVALID_WRAP_DIRECTION.params.direction`). */\nexport const WRAP_DIRECTIONS = ['wrap', 'unwrap'] as const;\n\n/** One member of {@link WRAP_DIRECTIONS}. */\nexport type WrapDirection = (typeof WRAP_DIRECTIONS)[number];\n\n/** The whole core catalog. Add a code here before throwing it anywhere in this package. */\nexport const GALA_ERROR_CATALOG = {\n // ---------------------------------------------------------------------------------- transport\n REQUEST_TIMEOUT: {\n phase: 'in_flight',\n template: 'Request to {url} timed out after {timeoutMs} ms.',\n params: { url: 'string', timeoutMs: 'number' },\n },\n TRANSPORT_ERROR: {\n phase: 'in_flight',\n template: 'The request to {url} failed before the server answered.',\n params: { url: 'string' },\n },\n INVALID_TIMEOUT: {\n phase: 'pre_send',\n template:\n '{field} must be a positive number of milliseconds, or Infinity for no timeout (got {value}).',\n params: { field: 'string', value: 'number' },\n },\n\n // ------------------------------------------------------------------------------ wallet / keys\n GALA_WALLET_NOT_AVAILABLE: {\n phase: 'pre_send',\n template: 'Gala wallet is not available. Please ensure the Gala wallet is connected.',\n params: {},\n },\n WALLET_UNAVAILABLE: {\n phase: 'pre_send',\n template: 'No wallet is connected.',\n params: {},\n },\n MALFORMED_WALLET_REQUEST: {\n phase: 'pre_send',\n template: 'Wallet {method} request is malformed.',\n params: { method: 'string' },\n },\n UNSUPPORTED_WALLET_METHOD: {\n phase: 'pre_send',\n template: 'Unsupported wallet method {method}.',\n params: { method: 'string' },\n },\n INVALID_SIGNATURE: {\n phase: 'pre_send',\n template: 'Wallet returned an invalid {scheme} signature.',\n params: { scheme: 'string' },\n },\n INVALID_CHAIN_ID: {\n phase: 'pre_send',\n template: 'Wallet returned an invalid chain id ({chainId}).',\n params: { chainId: 'string' },\n },\n SIGNER_ADDRESS_MISMATCH: {\n phase: 'pre_send',\n template: 'The signing key does not belong to the expected account.',\n params: {},\n },\n INVALID_PRIVATE_KEY: {\n phase: 'pre_send',\n template: 'Invalid private key: {reason}.',\n params: { reason: INVALID_PRIVATE_KEY_REASONS },\n },\n SIGNING_FAILED: {\n phase: 'pre_send',\n template: 'Signing the {method} request failed ({reason}); nothing was sent.',\n params: { method: 'string', reason: SIGNING_FAILURE_REASONS },\n },\n KEY_PROVIDER_FAILED: {\n phase: 'pre_send',\n template: 'The signing key could not be fetched; nothing was sent.',\n params: {},\n },\n INVALID_SIGNING_HASH_LENGTH: {\n phase: 'pre_send',\n template: 'secp256k1 can only sign a 32-byte hash (got {length}).',\n params: { length: 'number' },\n },\n INVALID_WALLET_ADDRESS: {\n phase: 'pre_send',\n template: 'Invalid {field}: \"{value}\" is not an accepted wallet address form.',\n params: { field: 'string', value: 'string' },\n },\n INVALID_ETH_USER_REF_PREFIX: {\n phase: 'pre_send',\n template:\n 'Invalid {field}: \"{value}\" is not a GalaChain user reference. An eth| reference takes the 40 hex digits of the account with no 0x prefix; write it as \"{expected}\".',\n params: { field: 'string', value: 'string', expected: 'string' },\n },\n INVALID_DECIMAL: {\n phase: 'pre_send',\n template: 'Invalid decimal quantity: {value}',\n params: { value: 'string' },\n },\n\n // ------------------------------------------------------------------------- personal-sign DTOs\n PERSONAL_SIGN_NOT_JSON: {\n phase: 'pre_send',\n template: 'Personal-sign DTO is not valid JSON',\n params: {},\n },\n PERSONAL_SIGN_NOT_OBJECT: {\n phase: 'pre_send',\n template: 'Personal-sign DTO must be a JSON object',\n params: {},\n },\n PERSONAL_SIGN_BAD_PREFIX: {\n phase: 'pre_send',\n template: 'Personal-sign DTO prefix is not an EIP-191 \"Ethereum Signed Message\" header',\n params: {},\n },\n PERSONAL_SIGN_ENVELOPE_FIELDS: {\n phase: 'pre_send',\n template: 'Personal-sign DTO carries signing-envelope field(s): {fields}',\n params: { fields: 'string' },\n },\n PERSONAL_SIGN_NOT_CANONICAL: {\n phase: 'pre_send',\n template: 'Personal-sign DTO is not in canonical serialized form',\n params: {},\n },\n\n // ------------------------------------------------------------------ EIP-712 payload derivation\n EIP712_NAME_COLLISION: {\n phase: 'pre_send',\n template: 'Name collisions are not supported when deriving EIP-712 types ({name}).',\n params: { name: 'string' },\n },\n EIP712_UNSUPPORTED_VALUE: {\n phase: 'pre_send',\n template: 'Unsupported EIP-712 value of type {valueType}.',\n params: { valueType: 'string' },\n },\n\n // ----------------------------------------------------------------------------- EIP-712 typed data\n TYPED_DATA_NOT_STRING: {\n phase: 'pre_send',\n template: 'Invalid typed data: {what} must be a string',\n params: { what: 'string' },\n },\n TYPED_DATA_UNPAIRED_SURROGATE: {\n phase: 'pre_send',\n template: 'Invalid typed data: {what} has an unpaired surrogate',\n params: { what: 'string' },\n },\n TYPED_DATA_NOT_HEX_BYTES: {\n phase: 'pre_send',\n template: 'Invalid typed data: {what} must be an even-length 0x hex string',\n params: { what: 'string' },\n },\n TYPED_DATA_NOT_SAFE_INTEGER: {\n phase: 'pre_send',\n template: 'Invalid typed data: {what} must be a safe integer',\n params: { what: 'string' },\n },\n TYPED_DATA_NOT_INTEGER: {\n phase: 'pre_send',\n template: 'Invalid typed data: {what} must be an integer',\n params: { what: 'string' },\n },\n TYPED_DATA_NOT_BOOLEAN: {\n phase: 'pre_send',\n template: 'Invalid typed data: bool must be a boolean',\n params: {},\n },\n TYPED_DATA_BAD_ADDRESS: {\n phase: 'pre_send',\n template: 'Invalid typed data: address must be 0x followed by 40 hex digits',\n params: {},\n },\n TYPED_DATA_BAD_CHECKSUM: {\n phase: 'pre_send',\n template: 'Invalid typed data: address has a bad checksum',\n params: {},\n },\n TYPED_DATA_BYTES_LENGTH: {\n phase: 'pre_send',\n template: 'Invalid typed data: {type} must be exactly {width} bytes',\n params: { type: 'string', width: 'number' },\n },\n TYPED_DATA_OUT_OF_BOUNDS: {\n phase: 'pre_send',\n template: 'Invalid typed data: value out of bounds for {type}',\n params: { type: 'string' },\n },\n TYPED_DATA_UNSUPPORTED_TYPE: {\n phase: 'pre_send',\n template: 'Invalid typed data: unsupported type \"{type}\"',\n params: { type: 'string' },\n },\n TYPED_DATA_FIELDS_NOT_LIST: {\n phase: 'pre_send',\n template: 'Invalid typed data: type {typeName} must be a list of fields',\n params: { typeName: 'string' },\n },\n TYPED_DATA_FIELD_MALFORMED: {\n phase: 'pre_send',\n template: 'Invalid typed data: type {typeName} has a field without a string name and type',\n params: { typeName: 'string' },\n },\n TYPED_DATA_INVALID_FIELD_NAME: {\n phase: 'pre_send',\n template: 'Invalid typed data: invalid field name \"{name}\"',\n params: { name: 'string' },\n },\n TYPED_DATA_DUPLICATE_FIELD: {\n phase: 'pre_send',\n template: 'Invalid typed data: duplicate field \"{name}\" in {typeName}',\n params: { name: 'string', typeName: 'string' },\n },\n TYPED_DATA_INVALID_TYPE_NAME: {\n phase: 'pre_send',\n template: 'Invalid typed data: invalid type name \"{name}\"',\n params: { name: 'string' },\n },\n TYPED_DATA_CIRCULAR_TYPE: {\n phase: 'pre_send',\n template: 'Invalid typed data: circular type reference in {typeName}',\n params: { typeName: 'string' },\n },\n TYPED_DATA_UNKNOWN_FIELD_TYPE: {\n phase: 'pre_send',\n template: 'Invalid typed data: unknown type \"{type}\" in {typeName}',\n params: { type: 'string', typeName: 'string' },\n },\n TYPED_DATA_NO_PRIMARY_TYPE: {\n phase: 'pre_send',\n template: 'Invalid typed data: missing primary type',\n params: {},\n },\n TYPED_DATA_AMBIGUOUS_PRIMARY_TYPE: {\n phase: 'pre_send',\n template: 'Invalid typed data: ambiguous primary types or unused types ({roots})',\n params: { roots: 'string' },\n },\n TYPED_DATA_ARRAY_EXPECTED: {\n phase: 'pre_send',\n template: 'Invalid typed data: {type} array value must be an array',\n params: { type: 'string' },\n },\n TYPED_DATA_ARRAY_LENGTH_MISMATCH: {\n phase: 'pre_send',\n template: 'Invalid typed data: array length mismatch',\n params: {},\n },\n TYPED_DATA_STRUCT_NOT_OBJECT: {\n phase: 'pre_send',\n template: 'Invalid typed data: {typeName} value must be an object',\n params: { typeName: 'string' },\n },\n TYPED_DATA_MISSING_FIELD: {\n phase: 'pre_send',\n template: 'Invalid typed data: {typeName} value is missing field \"{field}\"',\n params: { typeName: 'string', field: 'string' },\n },\n TYPED_DATA_DOMAIN_NOT_OBJECT: {\n phase: 'pre_send',\n template: 'Invalid typed data: domain must be an object',\n params: {},\n },\n TYPED_DATA_INVALID_DOMAIN_KEY: {\n phase: 'pre_send',\n template: 'Invalid typed data: invalid typed-data domain key {key}',\n params: { key: 'string' },\n },\n\n // ---------------------------------------------------------------------------------- unique keys\n INVALID_UNIQUE_KEY: {\n phase: 'pre_send',\n template:\n 'The uniqueKey \"{uniqueKey}\" must be 1-128 characters of A-Z, a-z, 0-9, \".\", \"_\", \":\" or \"-\".',\n params: { uniqueKey: 'string' },\n },\n INVALID_UNIQUE_KEY_PREFIX: {\n phase: 'pre_send',\n template:\n 'uniqueKeyPrefix \"{uniqueKeyPrefix}\" must be at most {maxLength} characters of A-Z, a-z, 0-9, \".\", \"_\", \":\" or \"-\".',\n params: { uniqueKeyPrefix: 'string', maxLength: 'number' },\n },\n CSPRNG_UNAVAILABLE: {\n phase: 'pre_send',\n template:\n 'No cryptographically secure random source (globalThis.crypto.getRandomValues) is available to mint a uniqueKey or a new wallet; install a getRandomValues polyfill (react-native-get-random-values on Hermes).',\n params: {},\n },\n\n // ----------------------------------------------------------------------------- gateway writes\n INVALID_WRITES_OPTION: {\n phase: 'pre_send',\n template: 'GatewayWrites option {option} is missing or is not of the expected type.',\n params: { option: GATEWAY_WRITES_OPTIONS },\n },\n INVALID_QUANTITY: {\n phase: 'pre_send',\n template:\n '{field} must be a positive decimal number of whole tokens, written as a string (got \"{value}\").',\n params: { field: 'string', value: 'string' },\n },\n INVALID_TOKEN_REFERENCE: {\n phase: 'pre_send',\n template: 'Invalid token reference {field}: {reason}.',\n params: { field: 'string', reason: INVALID_TOKEN_REFERENCE_REASONS },\n },\n INVALID_TOKEN_BATCH: {\n phase: 'pre_send',\n template: '{method} takes 1 to {max} tokens (got {count}).',\n params: { method: 'string', count: 'number', max: 'number' },\n },\n INVALID_LOCK_EXPIRES: {\n phase: 'pre_send',\n template:\n 'expires must be a non-negative whole number of epoch milliseconds, 0 for none (got {value}).',\n params: { value: 'string' },\n },\n INVALID_LOCK_NAME: {\n phase: 'pre_send',\n template: 'The lock name must be a string (got a {valueType}).',\n params: { valueType: 'string' },\n },\n INVALID_NFT_INPUT: {\n phase: 'pre_send',\n template: 'Invalid NFT input {field}: {reason}.',\n params: { field: 'string', reason: INVALID_NFT_INPUT_REASONS },\n },\n NO_TOKEN_NAME_RESOLVER: {\n phase: 'pre_send',\n template:\n 'The token name \"{tokenName}\" cannot be resolved: no tokenNameResolver is configured. Pass its tokenClassKey instead.',\n params: { tokenName: 'string' },\n },\n TOKEN_NAME_RESOLUTION_FAILED: {\n phase: 'pre_send',\n template:\n 'The token name \"{tokenName}\" could not be resolved to a token class key; nothing was sent.',\n params: { tokenName: 'string' },\n },\n GATEWAY_WRITE_OUTCOME_UNKNOWN: {\n phase: 'in_flight',\n template:\n 'The outcome of {method} is unknown ({reason}): the request may have reached the gateway. Check the write by its uniqueKey before sending it again.',\n params: { method: 'string', reason: GATEWAY_WRITE_OUTCOME_UNKNOWN_REASONS },\n },\n GATEWAY_HTTP_ERROR: {\n phase: 'post_send',\n template: 'The gateway answered {method} with HTTP {status}.',\n params: { method: 'string', status: 'number', serverMessage: 'string' },\n unrendered: ['serverMessage'],\n },\n GATEWAY_WRITE_REJECTED: {\n phase: 'post_send',\n template: 'GalaChain rejected {method} (Status {chainStatus}, error key \"{errorKey}\").',\n params: {\n method: 'string',\n chainStatus: 'number',\n errorKey: 'string',\n serverMessage: 'string',\n },\n unrendered: ['serverMessage'],\n },\n GATEWAY_RESPONSE_INVALID: {\n phase: 'post_send',\n template:\n 'The gateway answered {method} with something that is not a GalaChain result; the write may have been applied.',\n params: { method: 'string' },\n },\n\n // ------------------------------------------------------------------------------ gateway reads\n INVALID_READS_OPTION: {\n phase: 'pre_send',\n template: 'GatewayReads option {option} is missing or is not of the expected type.',\n params: { option: GATEWAY_READS_OPTIONS },\n },\n INVALID_PAGE_REQUEST: {\n phase: 'pre_send',\n template:\n '{field} is not valid for a paginated read (got {value}): a page size or page count is a whole number from 1 to 10000, a bookmark a string.',\n params: { field: PAGE_REQUEST_FIELDS, value: 'string' },\n },\n GATEWAY_READ_REJECTED: {\n phase: 'post_send',\n template: 'GalaChain refused {method} (Status {chainStatus}, error key \"{errorKey}\").',\n params: {\n method: 'string',\n chainStatus: 'number',\n errorKey: 'string',\n serverMessage: 'string',\n },\n unrendered: ['serverMessage'],\n },\n GATEWAY_READ_RESPONSE_INVALID: {\n phase: 'post_send',\n template: 'The gateway answered {method} with something that is not a usable GalaChain result.',\n params: { method: 'string' },\n },\n TOKEN_CLASS_NOT_FOUND: {\n phase: 'post_send',\n template: 'GalaChain has no token class {tokenClassKey}.',\n params: { tokenClassKey: 'string' },\n },\n PAGINATION_LIMIT_EXCEEDED: {\n phase: 'post_send',\n template:\n 'Reading every page of {method} takes more than {maxPages} pages; narrow the filter or raise maxPages.',\n params: { method: 'string', maxPages: 'number' },\n },\n\n // ------------------------------------------------------------- wallet providers (`./providers`)\n WALLET_NOT_CONNECTED: {\n phase: 'pre_send',\n template: 'The wallet is not connected ({reason}): connect it before {operation}.',\n params: { reason: WALLET_NOT_CONNECTED_REASONS, operation: 'string' },\n },\n WALLET_CONNECTION_FAILED: {\n phase: 'pre_send',\n template: 'Connecting to the wallet failed ({reason}).',\n params: { reason: WALLET_CONNECTION_FAILURE_REASONS },\n },\n INVALID_WALLET_PROVIDER_CONFIG: {\n phase: 'pre_send',\n template: 'A wallet provider cannot be built without {missing}.',\n params: { missing: WALLET_PROVIDER_CONFIG_MISSING },\n },\n PRIVATE_KEY_NOT_ACCESSIBLE: {\n phase: 'pre_send',\n template:\n 'This wallet provider signs in the wallet and cannot give out a private key; only a PrivateKeyProvider holds one.',\n params: {},\n },\n\n // ----------------------------------------------------------------------------- wallet helpers\n INVALID_WALLET_INPUT: {\n phase: 'pre_send',\n template:\n 'The wallet input was refused ({reason}): give a private key (64 hex digits) or a 12- or 24-word mnemonic.',\n params: { reason: WALLET_INPUT_PROBLEMS },\n },\n\n // ------------------------------------------------------------------------ bridge (`./bridge`)\n INVALID_BRIDGE_AMOUNT: {\n phase: 'pre_send',\n template: 'The bridge amount \"{value}\" was refused ({reason}).',\n params: { value: 'string', reason: BRIDGE_AMOUNT_PROBLEMS },\n },\n UNSUPPORTED_BRIDGE_TOKEN: {\n phase: 'pre_send',\n template: '{symbol} cannot be bridged with {network}.',\n params: { network: 'string', symbol: 'string' },\n },\n BRIDGE_NOT_CONFIGURED: {\n phase: 'pre_send',\n template:\n '{network} bridging is not configured: give the bridge a {network} private key (ethereumPrivateKey / solanaPrivateKey).',\n params: { network: BRIDGE_NETWORKS },\n },\n INVALID_TRANSACTION_HASH: {\n phase: 'pre_send',\n template: '\"{value}\" is not a {network} transaction hash.',\n params: { network: BRIDGE_NETWORKS, value: 'string' },\n },\n INVALID_BRIDGE_OPTION: {\n phase: 'pre_send',\n template: 'The bridge option {option} is missing or out of range.',\n params: { option: 'string' },\n },\n BRIDGE_RESPONSE_INVALID: {\n phase: 'post_send',\n template:\n 'GalaConnect answered {method} without a usable {missing}; the request may have been accepted.',\n params: { method: 'string', missing: 'string' },\n },\n BRIDGE_READ_RESPONSE_INVALID: {\n phase: 'post_send',\n template: 'GalaConnect answered {method} with something that is not a usable result.',\n params: { method: 'string' },\n },\n BRIDGE_WRITE_OUTCOME_UNKNOWN: {\n phase: 'in_flight',\n template:\n 'The outcome of {method} is unknown: the request failed in transit and may have reached GalaConnect. Check it before sending it again.',\n params: { method: 'string' },\n },\n GALACONNECT_HTTP_ERROR: {\n phase: 'post_send',\n template: 'GalaConnect answered {method} with HTTP {status}.',\n params: { method: 'string', status: 'number', serverMessage: 'string' },\n unrendered: ['serverMessage'],\n },\n BRIDGE_TOKEN_NOT_FOUND: {\n phase: 'post_send',\n template: 'GalaConnect has no verified bridge configuration for {symbol}.',\n params: { symbol: 'string' },\n },\n TOKEN_NOT_WRAPPABLE: {\n phase: 'post_send',\n template: '{tokenId} cannot be wrapped or unwrapped ({reason}).',\n params: { tokenId: 'string', reason: WRAP_REFUSAL_REASONS },\n },\n INVALID_WRAP_DIRECTION: {\n phase: 'pre_send',\n template:\n 'Cannot {direction} {symbol}: it is on the wrong channel for it (use the other direction).',\n params: { symbol: 'string', direction: WRAP_DIRECTIONS },\n },\n BRIDGE_REQUEST_REJECTED: {\n phase: 'post_send',\n template: 'GalaChain refused {method} (Status {chainStatus}, error key \"{errorKey}\").',\n params: {\n method: 'string',\n chainStatus: 'number',\n errorKey: 'string',\n serverMessage: 'string',\n },\n unrendered: ['serverMessage'],\n },\n BRIDGE_OUT_OUTCOME_UNKNOWN: {\n phase: 'in_flight',\n template:\n 'GalaConnect accepted the bridge-out request, which may have locked the tokens, then the bridge-out failed at {step}. Check it before bridging again.',\n params: { step: BRIDGE_OUT_STEPS, bridgeRequestId: 'string' },\n unrendered: ['bridgeRequestId'],\n },\n BRIDGE_DEPOSIT_OUTCOME_UNKNOWN: {\n phase: 'in_flight',\n template:\n 'The {network} bridge deposit may have been sent, then its {step} failed. Check the deposit before sending another.',\n params: { network: BRIDGE_NETWORKS, step: BRIDGE_DEPOSIT_STEPS, transactionHash: 'string' },\n unrendered: ['transactionHash'],\n },\n BRIDGE_CHAIN_READ_FAILED: {\n phase: 'post_send',\n template: 'The {network} read {call} failed or answered something unusable; nothing was sent.',\n params: { network: BRIDGE_NETWORKS, call: 'string' },\n },\n INSUFFICIENT_BRIDGE_BALANCE: {\n phase: 'pre_send',\n template: 'The {network} balance of {symbol} is {available}; the bridge needs {needed}.',\n params: { network: BRIDGE_NETWORKS, symbol: 'string', needed: 'string', available: 'string' },\n },\n BRIDGE_STATUS_TIMEOUT: {\n phase: 'in_flight',\n template:\n 'The bridge transaction did not reach a final status within {timeoutMs} ms (last status {lastStatus}); it may still complete.',\n params: { transactionHash: 'string', timeoutMs: 'number', lastStatus: 'number' },\n unrendered: ['transactionHash'],\n },\n\n // ------------------------------------------------------------------- React context (`./react`)\n WALLET_CONTEXT_MISSING: {\n phase: 'pre_send',\n template: 'The wallet hooks and the wallet context need a WalletProvider above them.',\n params: {},\n },\n} as const satisfies Record<string, GalaErrorCatalogEntry>;\n\n/** Every error code the core SDK can throw. */\nexport type GalaErrorCode = keyof typeof GALA_ERROR_CATALOG;\n\ninterface KindToType {\n string: string;\n number: number;\n boolean: boolean;\n}\n\n/** The value type of a param kind: a primitive, or the union of a closed set's members. */\ntype ParamValue<K> = K extends readonly (infer Member)[]\n ? Member\n : K extends keyof KindToType\n ? KindToType[K]\n : never;\n\n/**\n * The named params of code `C` of ANY catalog object (`typeof SOME_CATALOG`): a flat object of\n * primitives (or closed string tokens). A product SDK derives its own params type from its\n * catalog with it, so every catalog types its params the same way.\n */\nexport type ErrorParamsOf<\n Catalog extends Readonly<Record<string, GalaErrorCatalogEntry>>,\n C extends keyof Catalog,\n> = {\n readonly [P in keyof Catalog[C]['params']]: ParamValue<Catalog[C]['params'][P]>;\n};\n\n/** The named params of one core error code. */\nexport type GalaErrorParams<C extends GalaErrorCode> = ErrorParamsOf<typeof GALA_ERROR_CATALOG, C>;\n\n/**\n * The English template of every core error code, `{placeholder}` markers included. An optional\n * seed or fallback for an app's own translations; the SDK's `message` is generated from it. A\n * product SDK exports the templates of its own codes next to it.\n */\nexport const galaErrorTemplates: { readonly [C in GalaErrorCode]: string } = Object.fromEntries(\n Object.entries(GALA_ERROR_CATALOG).map(([code, entry]) => [code, entry.template]),\n) as { readonly [C in GalaErrorCode]: string };\n\nconst PLACEHOLDER = /\\{([A-Za-z0-9_]+)\\}/gu;\n\n/** Fills a template's `{placeholders}` from `params`; an unknown placeholder is left as written. */\nexport function renderGalaErrorTemplate(\n template: string,\n params: Readonly<Record<string, unknown>>,\n): string {\n return template.replace(PLACEHOLDER, (whole, name: string) => {\n const value = params[name];\n return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean'\n ? String(value)\n : whole;\n });\n}\n\n/** The placeholder names a template uses, in order of first appearance. */\nexport function templatePlaceholders(template: string): string[] {\n return [...new Set([...template.matchAll(PLACEHOLDER)].map((match) => match[1] as string))];\n}\n"],"mappings":"AA6DA,MAAaA,EAA8B,CACzC,eACA,eACA,eACA,iBACF,EAeaC,EAA0B,CAAC,gBAAiB,QAAQ,EAiBpDC,EAAkC,CAC7C,UACA,YACA,gBACA,cACF,EASaC,EAA4B,CACvC,eACA,QACA,iBACA,8BACA,mBACA,iBACA,kBACA,qBACF,EAWaC,EAAyB,CACpC,SACA,iBACA,gBACA,mBACF,EAcaC,EAAwC,CAAC,UAAW,WAAW,EAU/DC,EAAwB,CAAC,iBAAkB,eAAe,EAY1DC,EAAsB,CAAC,QAAS,WAAY,WAAY,UAAU,EAclEC,EAA+B,CAC1C,gBACA,eACA,cACF,EAYaC,EAAoC,CAC/C,cACA,gBACA,QACF,EAYaC,EAAiC,CAC5C,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`in_flight`,TRANSPORT_ERROR:`in_flight`,INVALID_TIMEOUT:`pre_send`,GALA_WALLET_NOT_AVAILABLE:`pre_send`,WALLET_UNAVAILABLE:`pre_send`,MALFORMED_WALLET_REQUEST:`pre_send`,UNSUPPORTED_WALLET_METHOD:`pre_send`,INVALID_SIGNATURE:`pre_send`,INVALID_CHAIN_ID:`pre_send`,SIGNER_ADDRESS_MISMATCH:`pre_send`,INVALID_PRIVATE_KEY:`pre_send`,SIGNING_FAILED:`pre_send`,KEY_PROVIDER_FAILED:`pre_send`,INVALID_SIGNING_HASH_LENGTH:`pre_send`,INVALID_WALLET_ADDRESS:`pre_send`,INVALID_ETH_USER_REF_PREFIX:`pre_send`,INVALID_DECIMAL:`pre_send`,PERSONAL_SIGN_NOT_JSON:`pre_send`,PERSONAL_SIGN_NOT_OBJECT:`pre_send`,PERSONAL_SIGN_BAD_PREFIX:`pre_send`,PERSONAL_SIGN_ENVELOPE_FIELDS:`pre_send`,PERSONAL_SIGN_NOT_CANONICAL:`pre_send`,EIP712_NAME_COLLISION:`pre_send`,EIP712_UNSUPPORTED_VALUE:`pre_send`,TYPED_DATA_NOT_STRING:`pre_send`,TYPED_DATA_UNPAIRED_SURROGATE:`pre_send`,TYPED_DATA_NOT_HEX_BYTES:`pre_send`,TYPED_DATA_NOT_SAFE_INTEGER:`pre_send`,TYPED_DATA_NOT_INTEGER:`pre_send`,TYPED_DATA_NOT_BOOLEAN:`pre_send`,TYPED_DATA_BAD_ADDRESS:`pre_send`,TYPED_DATA_BAD_CHECKSUM:`pre_send`,TYPED_DATA_BYTES_LENGTH:`pre_send`,TYPED_DATA_OUT_OF_BOUNDS:`pre_send`,TYPED_DATA_UNSUPPORTED_TYPE:`pre_send`,TYPED_DATA_FIELDS_NOT_LIST:`pre_send`,TYPED_DATA_FIELD_MALFORMED:`pre_send`,TYPED_DATA_INVALID_FIELD_NAME:`pre_send`,TYPED_DATA_DUPLICATE_FIELD:`pre_send`,TYPED_DATA_INVALID_TYPE_NAME:`pre_send`,TYPED_DATA_CIRCULAR_TYPE:`pre_send`,TYPED_DATA_UNKNOWN_FIELD_TYPE:`pre_send`,TYPED_DATA_NO_PRIMARY_TYPE:`pre_send`,TYPED_DATA_AMBIGUOUS_PRIMARY_TYPE:`pre_send`,TYPED_DATA_ARRAY_EXPECTED:`pre_send`,TYPED_DATA_ARRAY_LENGTH_MISMATCH:`pre_send`,TYPED_DATA_STRUCT_NOT_OBJECT:`pre_send`,TYPED_DATA_MISSING_FIELD:`pre_send`,TYPED_DATA_DOMAIN_NOT_OBJECT:`pre_send`,TYPED_DATA_INVALID_DOMAIN_KEY:`pre_send`,INVALID_UNIQUE_KEY:`pre_send`,INVALID_UNIQUE_KEY_PREFIX:`pre_send`,CSPRNG_UNAVAILABLE:`pre_send`,INVALID_WRITES_OPTION:`pre_send`,INVALID_QUANTITY:`pre_send`,INVALID_TOKEN_REFERENCE:`pre_send`,INVALID_TOKEN_BATCH:`pre_send`,INVALID_LOCK_EXPIRES:`pre_send`,INVALID_LOCK_NAME:`pre_send`,NO_TOKEN_NAME_RESOLVER:`pre_send`,TOKEN_NAME_RESOLUTION_FAILED:`pre_send`,GATEWAY_WRITE_OUTCOME_UNKNOWN:`in_flight`,GATEWAY_HTTP_ERROR:`post_send`,GATEWAY_WRITE_REJECTED:`post_send`,GATEWAY_RESPONSE_INVALID:`post_send`,INVALID_READS_OPTION:`pre_send`,INVALID_PAGE_REQUEST:`pre_send`,GATEWAY_READ_REJECTED:`post_send`,GATEWAY_READ_RESPONSE_INVALID:`post_send`,TOKEN_CLASS_NOT_FOUND:`post_send`,PAGINATION_LIMIT_EXCEEDED:`post_send`,WALLET_NOT_CONNECTED:`pre_send`,WALLET_CONNECTION_FAILED:`pre_send`,INVALID_WALLET_PROVIDER_CONFIG:`pre_send`,PRIVATE_KEY_NOT_ACCESSIBLE:`pre_send`,INVALID_WALLET_INPUT:`pre_send`,INVALID_BRIDGE_AMOUNT:`pre_send`,UNSUPPORTED_BRIDGE_TOKEN:`pre_send`,BRIDGE_NOT_CONFIGURED:`pre_send`,INVALID_TRANSACTION_HASH:`pre_send`,INVALID_BRIDGE_OPTION:`pre_send`,BRIDGE_RESPONSE_INVALID:`post_send`,BRIDGE_READ_RESPONSE_INVALID:`post_send`,BRIDGE_WRITE_OUTCOME_UNKNOWN:`in_flight`,GALACONNECT_HTTP_ERROR:`post_send`,BRIDGE_TOKEN_NOT_FOUND:`post_send`,TOKEN_NOT_WRAPPABLE:`post_send`,INVALID_WRAP_DIRECTION:`pre_send`,BRIDGE_REQUEST_REJECTED:`post_send`,BRIDGE_OUT_OUTCOME_UNKNOWN:`in_flight`,BRIDGE_DEPOSIT_OUTCOME_UNKNOWN:`in_flight`,BRIDGE_CHAIN_READ_FAILED:`post_send`,INSUFFICIENT_BRIDGE_BALANCE:`pre_send`,BRIDGE_STATUS_TIMEOUT:`in_flight`,WALLET_CONTEXT_MISSING:`pre_send`};function t(t){return Object.hasOwn(e,t)}export{e as GALA_ERROR_PHASE_BY_CODE,t as isGalaCatalogCode};
1
+ const e={REQUEST_TIMEOUT:`in_flight`,TRANSPORT_ERROR:`in_flight`,INVALID_TIMEOUT:`pre_send`,GALA_WALLET_NOT_AVAILABLE:`pre_send`,WALLET_UNAVAILABLE:`pre_send`,MALFORMED_WALLET_REQUEST:`pre_send`,UNSUPPORTED_WALLET_METHOD:`pre_send`,INVALID_SIGNATURE:`pre_send`,INVALID_CHAIN_ID:`pre_send`,SIGNER_ADDRESS_MISMATCH:`pre_send`,INVALID_PRIVATE_KEY:`pre_send`,SIGNING_FAILED:`pre_send`,KEY_PROVIDER_FAILED:`pre_send`,INVALID_SIGNING_HASH_LENGTH:`pre_send`,INVALID_WALLET_ADDRESS:`pre_send`,INVALID_ETH_USER_REF_PREFIX:`pre_send`,INVALID_DECIMAL:`pre_send`,PERSONAL_SIGN_NOT_JSON:`pre_send`,PERSONAL_SIGN_NOT_OBJECT:`pre_send`,PERSONAL_SIGN_BAD_PREFIX:`pre_send`,PERSONAL_SIGN_ENVELOPE_FIELDS:`pre_send`,PERSONAL_SIGN_NOT_CANONICAL:`pre_send`,EIP712_NAME_COLLISION:`pre_send`,EIP712_UNSUPPORTED_VALUE:`pre_send`,TYPED_DATA_NOT_STRING:`pre_send`,TYPED_DATA_UNPAIRED_SURROGATE:`pre_send`,TYPED_DATA_NOT_HEX_BYTES:`pre_send`,TYPED_DATA_NOT_SAFE_INTEGER:`pre_send`,TYPED_DATA_NOT_INTEGER:`pre_send`,TYPED_DATA_NOT_BOOLEAN:`pre_send`,TYPED_DATA_BAD_ADDRESS:`pre_send`,TYPED_DATA_BAD_CHECKSUM:`pre_send`,TYPED_DATA_BYTES_LENGTH:`pre_send`,TYPED_DATA_OUT_OF_BOUNDS:`pre_send`,TYPED_DATA_UNSUPPORTED_TYPE:`pre_send`,TYPED_DATA_FIELDS_NOT_LIST:`pre_send`,TYPED_DATA_FIELD_MALFORMED:`pre_send`,TYPED_DATA_INVALID_FIELD_NAME:`pre_send`,TYPED_DATA_DUPLICATE_FIELD:`pre_send`,TYPED_DATA_INVALID_TYPE_NAME:`pre_send`,TYPED_DATA_CIRCULAR_TYPE:`pre_send`,TYPED_DATA_UNKNOWN_FIELD_TYPE:`pre_send`,TYPED_DATA_NO_PRIMARY_TYPE:`pre_send`,TYPED_DATA_AMBIGUOUS_PRIMARY_TYPE:`pre_send`,TYPED_DATA_ARRAY_EXPECTED:`pre_send`,TYPED_DATA_ARRAY_LENGTH_MISMATCH:`pre_send`,TYPED_DATA_STRUCT_NOT_OBJECT:`pre_send`,TYPED_DATA_MISSING_FIELD:`pre_send`,TYPED_DATA_DOMAIN_NOT_OBJECT:`pre_send`,TYPED_DATA_INVALID_DOMAIN_KEY:`pre_send`,INVALID_UNIQUE_KEY:`pre_send`,INVALID_UNIQUE_KEY_PREFIX:`pre_send`,CSPRNG_UNAVAILABLE:`pre_send`,INVALID_WRITES_OPTION:`pre_send`,INVALID_QUANTITY:`pre_send`,INVALID_TOKEN_REFERENCE:`pre_send`,INVALID_TOKEN_BATCH:`pre_send`,INVALID_LOCK_EXPIRES:`pre_send`,INVALID_LOCK_NAME:`pre_send`,INVALID_NFT_INPUT:`pre_send`,NO_TOKEN_NAME_RESOLVER:`pre_send`,TOKEN_NAME_RESOLUTION_FAILED:`pre_send`,GATEWAY_WRITE_OUTCOME_UNKNOWN:`in_flight`,GATEWAY_HTTP_ERROR:`post_send`,GATEWAY_WRITE_REJECTED:`post_send`,GATEWAY_RESPONSE_INVALID:`post_send`,INVALID_READS_OPTION:`pre_send`,INVALID_PAGE_REQUEST:`pre_send`,GATEWAY_READ_REJECTED:`post_send`,GATEWAY_READ_RESPONSE_INVALID:`post_send`,TOKEN_CLASS_NOT_FOUND:`post_send`,PAGINATION_LIMIT_EXCEEDED:`post_send`,WALLET_NOT_CONNECTED:`pre_send`,WALLET_CONNECTION_FAILED:`pre_send`,INVALID_WALLET_PROVIDER_CONFIG:`pre_send`,PRIVATE_KEY_NOT_ACCESSIBLE:`pre_send`,INVALID_WALLET_INPUT:`pre_send`,INVALID_BRIDGE_AMOUNT:`pre_send`,UNSUPPORTED_BRIDGE_TOKEN:`pre_send`,BRIDGE_NOT_CONFIGURED:`pre_send`,INVALID_TRANSACTION_HASH:`pre_send`,INVALID_BRIDGE_OPTION:`pre_send`,BRIDGE_RESPONSE_INVALID:`post_send`,BRIDGE_READ_RESPONSE_INVALID:`post_send`,BRIDGE_WRITE_OUTCOME_UNKNOWN:`in_flight`,GALACONNECT_HTTP_ERROR:`post_send`,BRIDGE_TOKEN_NOT_FOUND:`post_send`,TOKEN_NOT_WRAPPABLE:`post_send`,INVALID_WRAP_DIRECTION:`pre_send`,BRIDGE_REQUEST_REJECTED:`post_send`,BRIDGE_OUT_OUTCOME_UNKNOWN:`in_flight`,BRIDGE_DEPOSIT_OUTCOME_UNKNOWN:`in_flight`,BRIDGE_CHAIN_READ_FAILED:`post_send`,INSUFFICIENT_BRIDGE_BALANCE:`pre_send`,BRIDGE_STATUS_TIMEOUT:`in_flight`,WALLET_CONTEXT_MISSING:`pre_send`};function t(t){return Object.hasOwn(e,t)}export{e as GALA_ERROR_PHASE_BY_CODE,t as isGalaCatalogCode};
2
2
  //# sourceMappingURL=error_phase_table.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"error_phase_table.js","names":["GALA_ERROR_PHASE_BY_CODE","isGalaCatalogCode","code"],"sources":["../../../src/classes/error_phase_table.ts"],"sourcesContent":["import type { GALA_ERROR_CATALOG, GalaErrorCode } from './error_catalog.js';\n\n/**\n * The phase of every core catalog code, WITHOUT the catalog. A failure guard (a product SDK's\n * `classifyFailure`, `mayHaveBeenQueued`, ...) needs only a code's phase, and the catalog's English\n * templates are several kB: reading the phase from here keeps an app shell that imports a guard\n * from loading them. The catalog entry is still where a code is declared; this table is checked\n * against it AT COMPILE TIME, in both directions (a missing code, an extra code or a different\n * phase is a type error), so the two cannot drift. A product SDK keeps the same kind of table for\n * its own codes.\n */\nexport const GALA_ERROR_PHASE_BY_CODE = {\n REQUEST_TIMEOUT: 'in_flight',\n TRANSPORT_ERROR: 'in_flight',\n INVALID_TIMEOUT: 'pre_send',\n GALA_WALLET_NOT_AVAILABLE: 'pre_send',\n WALLET_UNAVAILABLE: 'pre_send',\n MALFORMED_WALLET_REQUEST: 'pre_send',\n UNSUPPORTED_WALLET_METHOD: 'pre_send',\n INVALID_SIGNATURE: 'pre_send',\n INVALID_CHAIN_ID: 'pre_send',\n SIGNER_ADDRESS_MISMATCH: 'pre_send',\n INVALID_PRIVATE_KEY: 'pre_send',\n SIGNING_FAILED: 'pre_send',\n KEY_PROVIDER_FAILED: 'pre_send',\n INVALID_SIGNING_HASH_LENGTH: 'pre_send',\n INVALID_WALLET_ADDRESS: 'pre_send',\n INVALID_ETH_USER_REF_PREFIX: 'pre_send',\n INVALID_DECIMAL: 'pre_send',\n PERSONAL_SIGN_NOT_JSON: 'pre_send',\n PERSONAL_SIGN_NOT_OBJECT: 'pre_send',\n PERSONAL_SIGN_BAD_PREFIX: 'pre_send',\n PERSONAL_SIGN_ENVELOPE_FIELDS: 'pre_send',\n PERSONAL_SIGN_NOT_CANONICAL: 'pre_send',\n EIP712_NAME_COLLISION: 'pre_send',\n EIP712_UNSUPPORTED_VALUE: 'pre_send',\n TYPED_DATA_NOT_STRING: 'pre_send',\n TYPED_DATA_UNPAIRED_SURROGATE: 'pre_send',\n TYPED_DATA_NOT_HEX_BYTES: 'pre_send',\n TYPED_DATA_NOT_SAFE_INTEGER: 'pre_send',\n TYPED_DATA_NOT_INTEGER: 'pre_send',\n TYPED_DATA_NOT_BOOLEAN: 'pre_send',\n TYPED_DATA_BAD_ADDRESS: 'pre_send',\n TYPED_DATA_BAD_CHECKSUM: 'pre_send',\n TYPED_DATA_BYTES_LENGTH: 'pre_send',\n TYPED_DATA_OUT_OF_BOUNDS: 'pre_send',\n TYPED_DATA_UNSUPPORTED_TYPE: 'pre_send',\n TYPED_DATA_FIELDS_NOT_LIST: 'pre_send',\n TYPED_DATA_FIELD_MALFORMED: 'pre_send',\n TYPED_DATA_INVALID_FIELD_NAME: 'pre_send',\n TYPED_DATA_DUPLICATE_FIELD: 'pre_send',\n TYPED_DATA_INVALID_TYPE_NAME: 'pre_send',\n TYPED_DATA_CIRCULAR_TYPE: 'pre_send',\n TYPED_DATA_UNKNOWN_FIELD_TYPE: 'pre_send',\n TYPED_DATA_NO_PRIMARY_TYPE: 'pre_send',\n TYPED_DATA_AMBIGUOUS_PRIMARY_TYPE: 'pre_send',\n TYPED_DATA_ARRAY_EXPECTED: 'pre_send',\n TYPED_DATA_ARRAY_LENGTH_MISMATCH: 'pre_send',\n TYPED_DATA_STRUCT_NOT_OBJECT: 'pre_send',\n TYPED_DATA_MISSING_FIELD: 'pre_send',\n TYPED_DATA_DOMAIN_NOT_OBJECT: 'pre_send',\n TYPED_DATA_INVALID_DOMAIN_KEY: 'pre_send',\n INVALID_UNIQUE_KEY: 'pre_send',\n INVALID_UNIQUE_KEY_PREFIX: 'pre_send',\n CSPRNG_UNAVAILABLE: 'pre_send',\n INVALID_WRITES_OPTION: 'pre_send',\n INVALID_QUANTITY: 'pre_send',\n INVALID_TOKEN_REFERENCE: 'pre_send',\n INVALID_TOKEN_BATCH: 'pre_send',\n INVALID_LOCK_EXPIRES: 'pre_send',\n INVALID_LOCK_NAME: 'pre_send',\n NO_TOKEN_NAME_RESOLVER: 'pre_send',\n TOKEN_NAME_RESOLUTION_FAILED: 'pre_send',\n GATEWAY_WRITE_OUTCOME_UNKNOWN: 'in_flight',\n GATEWAY_HTTP_ERROR: 'post_send',\n GATEWAY_WRITE_REJECTED: 'post_send',\n GATEWAY_RESPONSE_INVALID: 'post_send',\n INVALID_READS_OPTION: 'pre_send',\n INVALID_PAGE_REQUEST: 'pre_send',\n GATEWAY_READ_REJECTED: 'post_send',\n GATEWAY_READ_RESPONSE_INVALID: 'post_send',\n TOKEN_CLASS_NOT_FOUND: 'post_send',\n PAGINATION_LIMIT_EXCEEDED: 'post_send',\n WALLET_NOT_CONNECTED: 'pre_send',\n WALLET_CONNECTION_FAILED: 'pre_send',\n INVALID_WALLET_PROVIDER_CONFIG: 'pre_send',\n PRIVATE_KEY_NOT_ACCESSIBLE: 'pre_send',\n INVALID_WALLET_INPUT: 'pre_send',\n INVALID_BRIDGE_AMOUNT: 'pre_send',\n UNSUPPORTED_BRIDGE_TOKEN: 'pre_send',\n BRIDGE_NOT_CONFIGURED: 'pre_send',\n INVALID_TRANSACTION_HASH: 'pre_send',\n INVALID_BRIDGE_OPTION: 'pre_send',\n BRIDGE_RESPONSE_INVALID: 'post_send',\n BRIDGE_READ_RESPONSE_INVALID: 'post_send',\n BRIDGE_WRITE_OUTCOME_UNKNOWN: 'in_flight',\n GALACONNECT_HTTP_ERROR: 'post_send',\n BRIDGE_TOKEN_NOT_FOUND: 'post_send',\n TOKEN_NOT_WRAPPABLE: 'post_send',\n INVALID_WRAP_DIRECTION: 'pre_send',\n BRIDGE_REQUEST_REJECTED: 'post_send',\n BRIDGE_OUT_OUTCOME_UNKNOWN: 'in_flight',\n BRIDGE_DEPOSIT_OUTCOME_UNKNOWN: 'in_flight',\n BRIDGE_CHAIN_READ_FAILED: 'post_send',\n INSUFFICIENT_BRIDGE_BALANCE: 'pre_send',\n BRIDGE_STATUS_TIMEOUT: 'in_flight',\n WALLET_CONTEXT_MISSING: 'pre_send',\n} as const satisfies {\n readonly [C in GalaErrorCode]: (typeof GALA_ERROR_CATALOG)[C]['phase'];\n};\n\n/** True for a code the CORE catalog defines (a product SDK's own codes are not). */\nexport function isGalaCatalogCode(code: string): code is GalaErrorCode {\n return Object.hasOwn(GALA_ERROR_PHASE_BY_CODE, code);\n}\n"],"mappings":"AAWA,MAAaA,EAA2B,CACtC,gBAAiB,YACjB,gBAAiB,YACjB,gBAAiB,WACjB,0BAA2B,WAC3B,mBAAoB,WACpB,yBAA0B,WAC1B,0BAA2B,WAC3B,kBAAmB,WACnB,iBAAkB,WAClB,wBAAyB,WACzB,oBAAqB,WACrB,eAAgB,WAChB,oBAAqB,WACrB,4BAA6B,WAC7B,uBAAwB,WACxB,4BAA6B,WAC7B,gBAAiB,WACjB,uBAAwB,WACxB,yBAA0B,WAC1B,yBAA0B,WAC1B,8BAA+B,WAC/B,4BAA6B,WAC7B,sBAAuB,WACvB,yBAA0B,WAC1B,sBAAuB,WACvB,8BAA+B,WAC/B,yBAA0B,WAC1B,4BAA6B,WAC7B,uBAAwB,WACxB,uBAAwB,WACxB,uBAAwB,WACxB,wBAAyB,WACzB,wBAAyB,WACzB,yBAA0B,WAC1B,4BAA6B,WAC7B,2BAA4B,WAC5B,2BAA4B,WAC5B,8BAA+B,WAC/B,2BAA4B,WAC5B,6BAA8B,WAC9B,yBAA0B,WAC1B,8BAA+B,WAC/B,2BAA4B,WAC5B,kCAAmC,WACnC,0BAA2B,WAC3B,iCAAkC,WAClC,6BAA8B,WAC9B,yBAA0B,WAC1B,6BAA8B,WAC9B,8BAA+B,WAC/B,mBAAoB,WACpB,0BAA2B,WAC3B,mBAAoB,WACpB,sBAAuB,WACvB,iBAAkB,WAClB,wBAAyB,WACzB,oBAAqB,WACrB,qBAAsB,WACtB,kBAAmB,WACnB,uBAAwB,WACxB,6BAA8B,WAC9B,8BAA+B,YAC/B,mBAAoB,YACpB,uBAAwB,YACxB,yBAA0B,YAC1B,qBAAsB,WACtB,qBAAsB,WACtB,sBAAuB,YACvB,8BAA+B,YAC/B,sBAAuB,YACvB,0BAA2B,YAC3B,qBAAsB,WACtB,yBAA0B,WAC1B,+BAAgC,WAChC,2BAA4B,WAC5B,qBAAsB,WACtB,sBAAuB,WACvB,yBAA0B,WAC1B,sBAAuB,WACvB,yBAA0B,WAC1B,sBAAuB,WACvB,wBAAyB,YACzB,6BAA8B,YAC9B,6BAA8B,YAC9B,uBAAwB,YACxB,uBAAwB,YACxB,oBAAqB,YACrB,uBAAwB,WACxB,wBAAyB,YACzB,2BAA4B,YAC5B,+BAAgC,YAChC,yBAA0B,YAC1B,4BAA6B,WAC7B,sBAAuB,YACvB,uBAAwB,UAC1B,EAKA,SAAgBC,EAAkB,EAAqC,CACrE,OAAO,OAAO,OAAOD,EAA0BE,CAAI,CACrD,C"}
1
+ {"version":3,"file":"error_phase_table.js","names":["GALA_ERROR_PHASE_BY_CODE","isGalaCatalogCode","code"],"sources":["../../../src/classes/error_phase_table.ts"],"sourcesContent":["import type { GALA_ERROR_CATALOG, GalaErrorCode } from './error_catalog.js';\n\n/**\n * The phase of every core catalog code, WITHOUT the catalog. A failure guard (a product SDK's\n * `classifyFailure`, `mayHaveBeenQueued`, ...) needs only a code's phase, and the catalog's English\n * templates are several kB: reading the phase from here keeps an app shell that imports a guard\n * from loading them. The catalog entry is still where a code is declared; this table is checked\n * against it AT COMPILE TIME, in both directions (a missing code, an extra code or a different\n * phase is a type error), so the two cannot drift. A product SDK keeps the same kind of table for\n * its own codes.\n */\nexport const GALA_ERROR_PHASE_BY_CODE = {\n REQUEST_TIMEOUT: 'in_flight',\n TRANSPORT_ERROR: 'in_flight',\n INVALID_TIMEOUT: 'pre_send',\n GALA_WALLET_NOT_AVAILABLE: 'pre_send',\n WALLET_UNAVAILABLE: 'pre_send',\n MALFORMED_WALLET_REQUEST: 'pre_send',\n UNSUPPORTED_WALLET_METHOD: 'pre_send',\n INVALID_SIGNATURE: 'pre_send',\n INVALID_CHAIN_ID: 'pre_send',\n SIGNER_ADDRESS_MISMATCH: 'pre_send',\n INVALID_PRIVATE_KEY: 'pre_send',\n SIGNING_FAILED: 'pre_send',\n KEY_PROVIDER_FAILED: 'pre_send',\n INVALID_SIGNING_HASH_LENGTH: 'pre_send',\n INVALID_WALLET_ADDRESS: 'pre_send',\n INVALID_ETH_USER_REF_PREFIX: 'pre_send',\n INVALID_DECIMAL: 'pre_send',\n PERSONAL_SIGN_NOT_JSON: 'pre_send',\n PERSONAL_SIGN_NOT_OBJECT: 'pre_send',\n PERSONAL_SIGN_BAD_PREFIX: 'pre_send',\n PERSONAL_SIGN_ENVELOPE_FIELDS: 'pre_send',\n PERSONAL_SIGN_NOT_CANONICAL: 'pre_send',\n EIP712_NAME_COLLISION: 'pre_send',\n EIP712_UNSUPPORTED_VALUE: 'pre_send',\n TYPED_DATA_NOT_STRING: 'pre_send',\n TYPED_DATA_UNPAIRED_SURROGATE: 'pre_send',\n TYPED_DATA_NOT_HEX_BYTES: 'pre_send',\n TYPED_DATA_NOT_SAFE_INTEGER: 'pre_send',\n TYPED_DATA_NOT_INTEGER: 'pre_send',\n TYPED_DATA_NOT_BOOLEAN: 'pre_send',\n TYPED_DATA_BAD_ADDRESS: 'pre_send',\n TYPED_DATA_BAD_CHECKSUM: 'pre_send',\n TYPED_DATA_BYTES_LENGTH: 'pre_send',\n TYPED_DATA_OUT_OF_BOUNDS: 'pre_send',\n TYPED_DATA_UNSUPPORTED_TYPE: 'pre_send',\n TYPED_DATA_FIELDS_NOT_LIST: 'pre_send',\n TYPED_DATA_FIELD_MALFORMED: 'pre_send',\n TYPED_DATA_INVALID_FIELD_NAME: 'pre_send',\n TYPED_DATA_DUPLICATE_FIELD: 'pre_send',\n TYPED_DATA_INVALID_TYPE_NAME: 'pre_send',\n TYPED_DATA_CIRCULAR_TYPE: 'pre_send',\n TYPED_DATA_UNKNOWN_FIELD_TYPE: 'pre_send',\n TYPED_DATA_NO_PRIMARY_TYPE: 'pre_send',\n TYPED_DATA_AMBIGUOUS_PRIMARY_TYPE: 'pre_send',\n TYPED_DATA_ARRAY_EXPECTED: 'pre_send',\n TYPED_DATA_ARRAY_LENGTH_MISMATCH: 'pre_send',\n TYPED_DATA_STRUCT_NOT_OBJECT: 'pre_send',\n TYPED_DATA_MISSING_FIELD: 'pre_send',\n TYPED_DATA_DOMAIN_NOT_OBJECT: 'pre_send',\n TYPED_DATA_INVALID_DOMAIN_KEY: 'pre_send',\n INVALID_UNIQUE_KEY: 'pre_send',\n INVALID_UNIQUE_KEY_PREFIX: 'pre_send',\n CSPRNG_UNAVAILABLE: 'pre_send',\n INVALID_WRITES_OPTION: 'pre_send',\n INVALID_QUANTITY: 'pre_send',\n INVALID_TOKEN_REFERENCE: 'pre_send',\n INVALID_TOKEN_BATCH: 'pre_send',\n INVALID_LOCK_EXPIRES: 'pre_send',\n INVALID_LOCK_NAME: 'pre_send',\n INVALID_NFT_INPUT: 'pre_send',\n NO_TOKEN_NAME_RESOLVER: 'pre_send',\n TOKEN_NAME_RESOLUTION_FAILED: 'pre_send',\n GATEWAY_WRITE_OUTCOME_UNKNOWN: 'in_flight',\n GATEWAY_HTTP_ERROR: 'post_send',\n GATEWAY_WRITE_REJECTED: 'post_send',\n GATEWAY_RESPONSE_INVALID: 'post_send',\n INVALID_READS_OPTION: 'pre_send',\n INVALID_PAGE_REQUEST: 'pre_send',\n GATEWAY_READ_REJECTED: 'post_send',\n GATEWAY_READ_RESPONSE_INVALID: 'post_send',\n TOKEN_CLASS_NOT_FOUND: 'post_send',\n PAGINATION_LIMIT_EXCEEDED: 'post_send',\n WALLET_NOT_CONNECTED: 'pre_send',\n WALLET_CONNECTION_FAILED: 'pre_send',\n INVALID_WALLET_PROVIDER_CONFIG: 'pre_send',\n PRIVATE_KEY_NOT_ACCESSIBLE: 'pre_send',\n INVALID_WALLET_INPUT: 'pre_send',\n INVALID_BRIDGE_AMOUNT: 'pre_send',\n UNSUPPORTED_BRIDGE_TOKEN: 'pre_send',\n BRIDGE_NOT_CONFIGURED: 'pre_send',\n INVALID_TRANSACTION_HASH: 'pre_send',\n INVALID_BRIDGE_OPTION: 'pre_send',\n BRIDGE_RESPONSE_INVALID: 'post_send',\n BRIDGE_READ_RESPONSE_INVALID: 'post_send',\n BRIDGE_WRITE_OUTCOME_UNKNOWN: 'in_flight',\n GALACONNECT_HTTP_ERROR: 'post_send',\n BRIDGE_TOKEN_NOT_FOUND: 'post_send',\n TOKEN_NOT_WRAPPABLE: 'post_send',\n INVALID_WRAP_DIRECTION: 'pre_send',\n BRIDGE_REQUEST_REJECTED: 'post_send',\n BRIDGE_OUT_OUTCOME_UNKNOWN: 'in_flight',\n BRIDGE_DEPOSIT_OUTCOME_UNKNOWN: 'in_flight',\n BRIDGE_CHAIN_READ_FAILED: 'post_send',\n INSUFFICIENT_BRIDGE_BALANCE: 'pre_send',\n BRIDGE_STATUS_TIMEOUT: 'in_flight',\n WALLET_CONTEXT_MISSING: 'pre_send',\n} as const satisfies {\n readonly [C in GalaErrorCode]: (typeof GALA_ERROR_CATALOG)[C]['phase'];\n};\n\n/** True for a code the CORE catalog defines (a product SDK's own codes are not). */\nexport function isGalaCatalogCode(code: string): code is GalaErrorCode {\n return Object.hasOwn(GALA_ERROR_PHASE_BY_CODE, code);\n}\n"],"mappings":"AAWA,MAAaA,EAA2B,CACtC,gBAAiB,YACjB,gBAAiB,YACjB,gBAAiB,WACjB,0BAA2B,WAC3B,mBAAoB,WACpB,yBAA0B,WAC1B,0BAA2B,WAC3B,kBAAmB,WACnB,iBAAkB,WAClB,wBAAyB,WACzB,oBAAqB,WACrB,eAAgB,WAChB,oBAAqB,WACrB,4BAA6B,WAC7B,uBAAwB,WACxB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,EAAkB,EAAqC,CACrE,OAAO,OAAO,OAAOD,EAA0BE,CAAI,CACrD,C"}
@@ -1 +1 @@
1
- import{BRIDGE_AMOUNT_PROBLEMS as e,BRIDGE_DEPOSIT_STEPS as t,BRIDGE_NETWORKS as n,BRIDGE_OUT_STEPS as r,GALA_ERROR_CATALOG as i,GATEWAY_READS_OPTIONS as a,GATEWAY_WRITES_OPTIONS as o,GATEWAY_WRITE_OUTCOME_UNKNOWN_REASONS as s,INVALID_PRIVATE_KEY_REASONS as c,INVALID_TOKEN_REFERENCE_REASONS as l,PAGE_REQUEST_FIELDS as u,SIGNING_FAILURE_REASONS as d,WALLET_CONNECTION_FAILURE_REASONS as f,WALLET_INPUT_PROBLEMS as p,WALLET_NOT_CONNECTED_REASONS as m,WALLET_PROVIDER_CONFIG_MISSING as h,WRAP_DIRECTIONS as g,WRAP_REFUSAL_REASONS as _,galaErrorTemplates as v,renderGalaErrorTemplate as y,templatePlaceholders as b}from"./classes/error_catalog.js";import{GALA_ERROR_PHASE_BY_CODE as x,isGalaCatalogCode as S}from"./classes/error_phase_table.js";import{GALA_ERROR_PHASES as C}from"./classes/error_phases.js";import{hasGalaErrorBrand as w,isGalaErrorLike as T}from"./utils/error_brand.js";import{GalaSDKError as E,isGalaError as D,parseJson as O}from"./classes/gala_sdk_error.js";import{checksumEthereumAddress as k}from"./utils/eth_address.js";import{galaChainUserRef as A}from"./writes/identity.js";import{EIP712_CAPABLE_METHODS as j,buildEIP712Payload as M,eip712DomainFor as N,generateEIP712Types as P}from"./utils/eip712.js";import{calculatePersonalSignPrefix as F,ethAddressOfPrivateKey as I,fixpointPrefixFor as L,getPayloadToSign as R,normalizePrivateKey as z,personalSignPrefixFor as B,serialize as V,signNative as H,signPersonalMessage as U,signSerializedNative as W}from"./utils/signing.js";import{BrowserWalletSigner as G,GalaWalletSigner as K,PrivateKeySigner as q,createLazyPrivateKeySigner as J,ethereumAddressOfAccount as Y,withGalaWalletIdentity as X}from"./classes/signers.js";import{canonicalDecimalString as Z,resolvePersonalSignChainDtoPayload as Q,signChainDtoHash as $,signChainDtoNative as ee,signChainDtoPersonalSign as te,signRawObject as ne,stripEip712DomainType as re,tokenClassDollarKey as ie,withPrivateKey as ae}from"./utils/chain_dto_signing.js";import{hashTypedData as oe,signTypedDataPayload as se}from"./utils/typed_data.js";import{CHAIN_CONTRACT_OPERATION_PREFIXES as ce,dtoOperationOf as le,withDtoOperation as ue}from"./utils/dto_operation.js";import{isWalletUserRejection as de,walletDeclineCode as fe}from"./utils/wallet_rejection.js";import{signPreSend as pe}from"./utils/pre_send.js";import{GALA_CORE_SDK_VERSION as me}from"./version.js";import{armTimeout as he,buildQueryString as ge,buildRequestHeaders as _e,fetchRequestor as ve,readBlockNumberHeader as ye,readHeader as be,readResponseBody as xe,readRetryAfter as Se,requestWithTimeout as Ce,validateTimeoutMs as we}from"./utils/transport.js";import{httpRequestorFromAxios as Te}from"./utils/axios_requestor.js";import{eip1193ProviderFromEthers as Ee}from"./utils/ethers_provider.js";import{isFetchTransportFailure as De}from"./utils/fetch_failure.js";import{FAILURE_OUTCOMES as Oe}from"./utils/failure_outcomes.js";import{isWriteView as ke,numberParamOf as Ae,stringParamOf as je,toFailureView as Me}from"./utils/failure_view.js";import{compositeKeyOf as Ne,isTokenClassKey as Pe,splitClassKey as Fe,tryParseCompositeKey as Ie,tryParseTokenClassKey as Le}from"./utils/class_key.js";import{isValidUniqueKey as Re}from"./utils/unique_key_syntax.js";import{DEFAULT_UNIQUE_KEY_PREFIX as ze,assertUniqueKey as Be,createUniqueKey as Ve,resolveUniqueKeyPrefix as He}from"./utils/unique_key.js";import{createWallet as Ue,getEthereumAddressFromPrivateKey as We,getPublicKeyFromPrivateKey as Ge,validateWalletInput as Ke}from"./utils/wallet_keys.js";import{GALA_TOKEN_CLASS_KEY as qe}from"./writes/transfer.js";import{GATEWAY_WRITE_BATCH_LIMITS as Je,GATEWAY_WRITE_METHODS as Ye}from"./writes/types.js";import{GatewayWrites as Xe}from"./writes/gateway_writes.js";import{GATEWAY_READ_LIMITS as Ze,GATEWAY_READ_METHODS as Qe}from"./reads/types.js";import{GatewayReads as $e,tokenDetailsOf as et}from"./reads/gateway_reads.js";import{GALA_CHAIN_ENVIRONMENTS as tt}from"./config/environments.js";export{e as BRIDGE_AMOUNT_PROBLEMS,t as BRIDGE_DEPOSIT_STEPS,n as BRIDGE_NETWORKS,r as BRIDGE_OUT_STEPS,G as BrowserWalletSigner,ce as CHAIN_CONTRACT_OPERATION_PREFIXES,ze as DEFAULT_UNIQUE_KEY_PREFIX,j as EIP712_CAPABLE_METHODS,Oe as FAILURE_OUTCOMES,tt as GALA_CHAIN_ENVIRONMENTS,me as GALA_CORE_SDK_VERSION,i as GALA_ERROR_CATALOG,C as GALA_ERROR_PHASES,x as GALA_ERROR_PHASE_BY_CODE,qe as GALA_TOKEN_CLASS_KEY,a as GATEWAY_READS_OPTIONS,Ze as GATEWAY_READ_LIMITS,Qe as GATEWAY_READ_METHODS,o as GATEWAY_WRITES_OPTIONS,Je as GATEWAY_WRITE_BATCH_LIMITS,Ye as GATEWAY_WRITE_METHODS,s as GATEWAY_WRITE_OUTCOME_UNKNOWN_REASONS,E as GalaSDKError,K as GalaWalletSigner,$e as GatewayReads,Xe as GatewayWrites,c as INVALID_PRIVATE_KEY_REASONS,l as INVALID_TOKEN_REFERENCE_REASONS,u as PAGE_REQUEST_FIELDS,q as PrivateKeySigner,d as SIGNING_FAILURE_REASONS,f as WALLET_CONNECTION_FAILURE_REASONS,p as WALLET_INPUT_PROBLEMS,m as WALLET_NOT_CONNECTED_REASONS,h as WALLET_PROVIDER_CONFIG_MISSING,g as WRAP_DIRECTIONS,_ as WRAP_REFUSAL_REASONS,he as armTimeout,Be as assertUniqueKey,M as buildEIP712Payload,ge as buildQueryString,_e as buildRequestHeaders,F as calculatePersonalSignPrefix,Z as canonicalDecimalString,k as checksumEthereumAddress,Ne as compositeKeyOf,J as createLazyPrivateKeySigner,Ve as createUniqueKey,Ue as createWallet,le as dtoOperationOf,Ee as eip1193ProviderFromEthers,N as eip712DomainFor,I as ethAddressOfPrivateKey,Y as ethereumAddressOfAccount,ve as fetchRequestor,L as fixpointPrefixFor,A as galaChainUserRef,v as galaErrorTemplates,P as generateEIP712Types,We as getEthereumAddressFromPrivateKey,R as getPayloadToSign,Ge as getPublicKeyFromPrivateKey,w as hasGalaErrorBrand,oe as hashTypedData,Te as httpRequestorFromAxios,De as isFetchTransportFailure,S as isGalaCatalogCode,D as isGalaError,T as isGalaErrorLike,Pe as isTokenClassKey,Re as isValidUniqueKey,de as isWalletUserRejection,ke as isWriteView,z as normalizePrivateKey,Ae as numberParamOf,O as parseJson,B as personalSignPrefixFor,ye as readBlockNumberHeader,be as readHeader,xe as readResponseBody,Se as readRetryAfter,y as renderGalaErrorTemplate,Ce as requestWithTimeout,Q as resolvePersonalSignChainDtoPayload,He as resolveUniqueKeyPrefix,V as serialize,$ as signChainDtoHash,ee as signChainDtoNative,te as signChainDtoPersonalSign,H as signNative,U as signPersonalMessage,pe as signPreSend,ne as signRawObject,W as signSerializedNative,se as signTypedDataPayload,Fe as splitClassKey,je as stringParamOf,re as stripEip712DomainType,b as templatePlaceholders,Me as toFailureView,ie as tokenClassDollarKey,et as tokenDetailsOf,Ie as tryParseCompositeKey,Le as tryParseTokenClassKey,we as validateTimeoutMs,Ke as validateWalletInput,fe as walletDeclineCode,ue as withDtoOperation,X as withGalaWalletIdentity,ae as withPrivateKey};
1
+ import{BRIDGE_AMOUNT_PROBLEMS as e,BRIDGE_DEPOSIT_STEPS as t,BRIDGE_NETWORKS as n,BRIDGE_OUT_STEPS as r,GALA_ERROR_CATALOG as i,GATEWAY_READS_OPTIONS as a,GATEWAY_WRITES_OPTIONS as o,GATEWAY_WRITE_OUTCOME_UNKNOWN_REASONS as s,INVALID_NFT_INPUT_REASONS as c,INVALID_PRIVATE_KEY_REASONS as l,INVALID_TOKEN_REFERENCE_REASONS as u,PAGE_REQUEST_FIELDS as d,SIGNING_FAILURE_REASONS as f,WALLET_CONNECTION_FAILURE_REASONS as p,WALLET_INPUT_PROBLEMS as m,WALLET_NOT_CONNECTED_REASONS as h,WALLET_PROVIDER_CONFIG_MISSING as g,WRAP_DIRECTIONS as _,WRAP_REFUSAL_REASONS as v,galaErrorTemplates as y,renderGalaErrorTemplate as b,templatePlaceholders as x}from"./classes/error_catalog.js";import{GALA_ERROR_PHASE_BY_CODE as S,isGalaCatalogCode as C}from"./classes/error_phase_table.js";import{GALA_ERROR_PHASES as w}from"./classes/error_phases.js";import{hasGalaErrorBrand as T,isGalaErrorLike as E}from"./utils/error_brand.js";import{GalaSDKError as D,isGalaError as O,parseJson as k}from"./classes/gala_sdk_error.js";import{checksumEthereumAddress as A}from"./utils/eth_address.js";import{galaChainUserRef as j}from"./writes/identity.js";import{EIP712_CAPABLE_METHODS as M,buildEIP712Payload as N,eip712DomainFor as P,generateEIP712Types as F}from"./utils/eip712.js";import{calculatePersonalSignPrefix as I,ethAddressOfPrivateKey as L,fixpointPrefixFor as R,getPayloadToSign as z,normalizePrivateKey as B,personalSignPrefixFor as V,serialize as H,signNative as U,signPersonalMessage as W,signSerializedNative as G}from"./utils/signing.js";import{BrowserWalletSigner as K,GalaWalletSigner as q,PrivateKeySigner as J,createLazyPrivateKeySigner as Y,ethereumAddressOfAccount as X,withGalaWalletIdentity as Z}from"./classes/signers.js";import{canonicalDecimalString as Q,resolvePersonalSignChainDtoPayload as $,signChainDtoHash as ee,signChainDtoNative as te,signChainDtoPersonalSign as ne,signRawObject as re,stripEip712DomainType as ie,tokenClassDollarKey as ae,withPrivateKey as oe}from"./utils/chain_dto_signing.js";import{hashTypedData as se,signTypedDataPayload as ce}from"./utils/typed_data.js";import{CHAIN_CONTRACT_OPERATION_PREFIXES as le,dtoOperationOf as ue,withDtoOperation as de}from"./utils/dto_operation.js";import{isWalletUserRejection as fe,walletDeclineCode as pe}from"./utils/wallet_rejection.js";import{signPreSend as me,signPreSendFor as he}from"./utils/pre_send.js";import{GALA_CORE_SDK_VERSION as ge}from"./version.js";import{armTimeout as _e,buildQueryString as ve,buildRequestHeaders as ye,fetchRequestor as be,readBlockNumberHeader as xe,readHeader as Se,readResponseBody as Ce,readRetryAfter as we,requestWithTimeout as Te,validateTimeoutMs as Ee}from"./utils/transport.js";import{httpRequestorFromAxios as De}from"./utils/axios_requestor.js";import{eip1193ProviderFromEthers as Oe}from"./utils/ethers_provider.js";import{isFetchTransportFailure as ke}from"./utils/fetch_failure.js";import{FAILURE_OUTCOMES as Ae}from"./utils/failure_outcomes.js";import{isWriteView as je,numberParamOf as Me,stringParamOf as Ne,toFailureView as Pe}from"./utils/failure_view.js";import{compositeKeyOf as Fe,isTokenClassKey as Ie,splitClassKey as Le,tryParseCompositeKey as Re,tryParseTokenClassKey as ze}from"./utils/class_key.js";import{isValidUniqueKey as Be}from"./utils/unique_key_syntax.js";import{DEFAULT_UNIQUE_KEY_PREFIX as Ve,assertUniqueKey as He,createUniqueKey as Ue,resolveUniqueKeyPrefix as We}from"./utils/unique_key.js";import{createWallet as Ge,getEthereumAddressFromPrivateKey as Ke,getPublicKeyFromPrivateKey as qe,validateWalletInput as Je}from"./utils/wallet_keys.js";import{NFT_DEFAULT_ADDITIONAL_KEY as Ye,NFT_MINT_LIMIT as Xe,NFT_WRITE_METHODS as Ze}from"./writes/nft.js";import{GALA_TOKEN_CLASS_KEY as Qe}from"./writes/transfer.js";import{GATEWAY_WRITE_BATCH_LIMITS as $e,GATEWAY_WRITE_METHODS as et}from"./writes/types.js";import{GatewayWrites as tt}from"./writes/gateway_writes.js";import{GATEWAY_READ_LIMITS as nt,GATEWAY_READ_METHODS as rt}from"./reads/types.js";import{GatewayReads as it,tokenDetailsOf as at}from"./reads/gateway_reads.js";import{NftCollectionReads as ot}from"./reads/nft_collections.js";import{estimateNftOperationFees as st,getNftCollectionClaimFee as ct,getNftTokenClassCreateFee as lt}from"./reads/nft_fees.js";import{GALA_CHAIN_ENVIRONMENTS as ut}from"./config/environments.js";export{e as BRIDGE_AMOUNT_PROBLEMS,t as BRIDGE_DEPOSIT_STEPS,n as BRIDGE_NETWORKS,r as BRIDGE_OUT_STEPS,K as BrowserWalletSigner,le as CHAIN_CONTRACT_OPERATION_PREFIXES,Ve as DEFAULT_UNIQUE_KEY_PREFIX,M as EIP712_CAPABLE_METHODS,Ae as FAILURE_OUTCOMES,ut as GALA_CHAIN_ENVIRONMENTS,ge as GALA_CORE_SDK_VERSION,i as GALA_ERROR_CATALOG,w as GALA_ERROR_PHASES,S as GALA_ERROR_PHASE_BY_CODE,Qe as GALA_TOKEN_CLASS_KEY,a as GATEWAY_READS_OPTIONS,nt as GATEWAY_READ_LIMITS,rt as GATEWAY_READ_METHODS,o as GATEWAY_WRITES_OPTIONS,$e as GATEWAY_WRITE_BATCH_LIMITS,et as GATEWAY_WRITE_METHODS,s as GATEWAY_WRITE_OUTCOME_UNKNOWN_REASONS,D as GalaSDKError,q as GalaWalletSigner,it as GatewayReads,tt as GatewayWrites,c as INVALID_NFT_INPUT_REASONS,l as INVALID_PRIVATE_KEY_REASONS,u as INVALID_TOKEN_REFERENCE_REASONS,Ye as NFT_DEFAULT_ADDITIONAL_KEY,Xe as NFT_MINT_LIMIT,Ze as NFT_WRITE_METHODS,ot as NftCollectionReads,d as PAGE_REQUEST_FIELDS,J as PrivateKeySigner,f as SIGNING_FAILURE_REASONS,p as WALLET_CONNECTION_FAILURE_REASONS,m as WALLET_INPUT_PROBLEMS,h as WALLET_NOT_CONNECTED_REASONS,g as WALLET_PROVIDER_CONFIG_MISSING,_ as WRAP_DIRECTIONS,v as WRAP_REFUSAL_REASONS,_e as armTimeout,He as assertUniqueKey,N as buildEIP712Payload,ve as buildQueryString,ye as buildRequestHeaders,I as calculatePersonalSignPrefix,Q as canonicalDecimalString,A as checksumEthereumAddress,Fe as compositeKeyOf,Y as createLazyPrivateKeySigner,Ue as createUniqueKey,Ge as createWallet,ue as dtoOperationOf,Oe as eip1193ProviderFromEthers,P as eip712DomainFor,st as estimateNftOperationFees,L as ethAddressOfPrivateKey,X as ethereumAddressOfAccount,be as fetchRequestor,R as fixpointPrefixFor,j as galaChainUserRef,y as galaErrorTemplates,F as generateEIP712Types,Ke as getEthereumAddressFromPrivateKey,ct as getNftCollectionClaimFee,lt as getNftTokenClassCreateFee,z as getPayloadToSign,qe as getPublicKeyFromPrivateKey,T as hasGalaErrorBrand,se as hashTypedData,De as httpRequestorFromAxios,ke as isFetchTransportFailure,C as isGalaCatalogCode,O as isGalaError,E as isGalaErrorLike,Ie as isTokenClassKey,Be as isValidUniqueKey,fe as isWalletUserRejection,je as isWriteView,B as normalizePrivateKey,Me as numberParamOf,k as parseJson,V as personalSignPrefixFor,xe as readBlockNumberHeader,Se as readHeader,Ce as readResponseBody,we as readRetryAfter,b as renderGalaErrorTemplate,Te as requestWithTimeout,$ as resolvePersonalSignChainDtoPayload,We as resolveUniqueKeyPrefix,H as serialize,ee as signChainDtoHash,te as signChainDtoNative,ne as signChainDtoPersonalSign,U as signNative,W as signPersonalMessage,me as signPreSend,he as signPreSendFor,re as signRawObject,G as signSerializedNative,ce as signTypedDataPayload,Le as splitClassKey,Ne as stringParamOf,ie as stripEip712DomainType,x as templatePlaceholders,Pe as toFailureView,ae as tokenClassDollarKey,at as tokenDetailsOf,Re as tryParseCompositeKey,ze as tryParseTokenClassKey,Ee as validateTimeoutMs,Je as validateWalletInput,pe as walletDeclineCode,de as withDtoOperation,Z as withGalaWalletIdentity,oe as withPrivateKey};
@@ -1,2 +1,2 @@
1
- import e from"../_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/defineProperty.js";import{GalaSDKError as t,isGalaError as n}from"../classes/gala_sdk_error.js";import{galaChainUserRef as r}from"../writes/identity.js";import{fetchRequestor as i,validateTimeoutMs as a}from"../utils/transport.js";import{compositeKeyOf as o}from"../utils/class_key.js";import{tokenClassKeyOf as s}from"../writes/token_ref.js";import{parseBalances as c,parseNftCollectionAuthorization as l,parsePage as u,parsePublicKey as d,parseTokenClass as f,parseTokenClasses as p}from"./parse.js";import{chainErrorOf as m,channelOf as h,invalidAnswer as g,readGateway as _}from"./request.js";import{GATEWAY_READ_LIMITS as v}from"./types.js";import y from"bignumber.js";const b=[`collection`,`category`,`type`,`additionalKey`];function x(e,n){let r={};for(let i of b){let a=e[i];if(a!==void 0){if(typeof a!=`string`||a===``)throw new t(`INVALID_TOKEN_REFERENCE`,{field:`${n}${i}`,reason:`bad_class_key`});r[i]=a}}return r}function S(e,n,r){if(e!==void 0){if(typeof e==`number`&&Number.isSafeInteger(e)&&e>=1&&e<=r)return e;throw new t(`INVALID_PAGE_REQUEST`,{field:n,value:typeof e==`number`||typeof e==`string`?String(e):e===null?`null`:typeof e})}}function C(e,t){return b.every(n=>e[n]===t[n])}function w(e){return{collection:e.collection,category:e.category,type:e.type,additionalKey:e.additionalKey,symbol:e.symbol,decimals:e.decimals,name:e.name,image:e.image,description:e.description,network:e.network,...e.contractAddress===void 0?{}:{contractAddress:e.contractAddress}}}function T(e){return e.reduce((e,t)=>e.plus(t.quantity),new y(0))}var E=class{constructor(n){e(this,`transport`,void 0);let{gatewayBaseUrl:r,httpRequestor:o}=n;if(typeof r!=`string`)throw new t(`INVALID_READS_OPTION`,{option:`gatewayBaseUrl`});if(o!==void 0&&typeof o!=`function`)throw new t(`INVALID_READS_OPTION`,{option:`httpRequestor`});this.transport={gatewayBaseUrl:r.replace(/\/+$/u,``),requestor:o??i,timeoutMs:a(n.requestTimeoutMs??3e4,`requestTimeoutMs`),wire:n.wire}}async fetchBalances(e){let t=r(e.owner,`owner`),n=x(e,``),i=await _(this.transport,`FetchBalances`,{owner:t,...n},h(n.collection)),a=c(i);if(a===void 0||a.some(e=>e.owner!==t))throw g(`FetchBalances`,i);return a}async fetchTokenBalance(e){let t=s(e.tokenClassKey,`tokenClassKey`),n=(await this.fetchBalances({owner:e.owner,...t})).find(e=>C(e,t));if(n===void 0)return;let r=Date.now(),i=t=>e.includeExpiredHolds===!0?[...t]:t.filter(e=>e.expires===0||e.expires>r),a=i(n.lockedHolds),o=i(n.inUseHolds),c=T(a),l=T(o);return{owner:n.owner,tokenClassKey:t,quantity:n.quantity,lockedHolds:a,inUseHolds:o,lockedQuantity:c.toFixed(),inUseQuantity:l.toFixed(),availableQuantity:new y(n.quantity).minus(c).minus(l).toFixed(),instanceIds:n.instanceIds}}async fetchNftBalances(e){return(await this.fetchBalances(e)).filter(e=>e.instanceIds.length>0)}fetchTokenClasses(e){return this.readClasses(`FetchTokenClasses`,e)}fetchTokenClassesWithSupply(e){return this.readClasses(`FetchTokenClassesWithSupply`,e)}async fetchTokenClass(e){let[t]=await this.readClasses(`FetchTokenClasses`,[e]);return t}async fetchTokenDetails(e){return w(await this.fetchTokenClass(e))}async fetchTokenClassesPage(e={}){let t=x(e,``);return this.readPage(`FetchTokenClassesWithPagination`,t,e,f)}async fetchAllTokenClasses(e={},t={}){let n=x(e,``);return this.readAllPages(`FetchTokenClassesWithPagination`,t,e=>this.readPage(`FetchTokenClassesWithPagination`,n,e,f))}fetchNftCollectionAuthorizationsPage(e={}){return this.readPage(`FetchNftCollectionAuthorizationsWithPagination`,{},e,l)}fetchAllNftCollectionAuthorizations(e={}){return this.readAllPages(`FetchNftCollectionAuthorizationsWithPagination`,e,e=>this.fetchNftCollectionAuthorizationsPage(e))}async fetchPublicKey(e){let t=r(e,`user`),n;try{n=await _(this.transport,`GetPublicKey`,{user:t})}catch(e){if(D(e))return;throw e}let i=d(n);if(i===void 0)throw g(`GetPublicKey`,n);return i}async readClasses(e,n){let r=Array.isArray(n)?n.length:0,i=v.tokenClasses;if(r<1||r>i)throw new t(`INVALID_TOKEN_BATCH`,{method:e,count:r,max:i});let a=n.map((e,t)=>s(e,`tokenClassKeys[${t}]`)),c;try{c=await _(this.transport,e,{tokenClasses:a})}catch(e){throw O(e)??e}let l=p(c);if(l===void 0)throw g(e,c);return a.map(e=>{let n=l.find(t=>C(t,e));if(n===void 0)throw new t(`TOKEN_CLASS_NOT_FOUND`,{tokenClassKey:o(e)},{body:c,write:!1});return n})}async readPage(e,n,r,i){let a=S(r.limit,`limit`,v.pageSize),{bookmark:o}=r;if(o!==void 0&&typeof o!=`string`)throw new t(`INVALID_PAGE_REQUEST`,{field:`bookmark`,value:typeof o});let s=await _(this.transport,e,{...n,...o===void 0||o===``?{}:{bookmark:o},...a===void 0?{}:{limit:a}}),c=u(s,i);if(c===void 0)throw g(e,s);return c}async readAllPages(e,n,r){let i=S(n.maxPages,`maxPages`,1e4)??v.maxPages,a=S(n.pageSize,`pageSize`,v.pageSize),o=[],s;for(let t=0;t<i;t+=1){let t=await r({...s===void 0?{}:{bookmark:s},...a===void 0?{}:{limit:a}});if(o.push(...t.results),t.nextPageBookmark===void 0)return o;if(t.nextPageBookmark===s)throw g(e,t);s=t.nextPageBookmark}throw new t(`PAGINATION_LIMIT_EXCEEDED`,{method:e,maxPages:i},{write:!1})}};function D(e){return!n(e,`GATEWAY_HTTP_ERROR`)||e.status!==404?!1:m(e.body)?.ErrorKey===`PK_NOT_FOUND`}function O(e){if(!n(e,`GATEWAY_HTTP_ERROR`)||e.status!==404)return;let r=m(e.body);if(r?.ErrorKey!==`TOKEN_CLASS_NOT_FOUND`)return;let i=r.ErrorPayload,a=typeof i==`object`&&i?i.tokenClassKey:void 0;return new t(`TOKEN_CLASS_NOT_FOUND`,{tokenClassKey:typeof a==`string`?a:``},{status:e.status,body:e.body,url:e.url,write:!1,cause:e})}export{E as GatewayReads,w as tokenDetailsOf};
1
+ import e from"../_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/defineProperty.js";import{GalaSDKError as t,isGalaError as n}from"../classes/gala_sdk_error.js";import{galaChainUserRef as r}from"../writes/identity.js";import{fetchRequestor as i,validateTimeoutMs as a}from"../utils/transport.js";import{compositeKeyOf as o}from"../utils/class_key.js";import{chainErrorOf as s,channelOf as c,invalidAnswer as l,readGateway as u}from"./request.js";import{tokenClassKeyOf as d}from"../writes/token_ref.js";import{parseBalances as f,parseNftCollectionAuthorization as p,parsePage as m,parsePublicKey as h,parseTokenClass as g,parseTokenClasses as _}from"./parse.js";import{GATEWAY_READ_LIMITS as v}from"./types.js";import y from"bignumber.js";const b=[`collection`,`category`,`type`,`additionalKey`];function x(e,n){let r={};for(let i of b){let a=e[i];if(a!==void 0){if(typeof a!=`string`||a===``)throw new t(`INVALID_TOKEN_REFERENCE`,{field:`${n}${i}`,reason:`bad_class_key`});r[i]=a}}return r}function S(e,n,r){if(e!==void 0){if(typeof e==`number`&&Number.isSafeInteger(e)&&e>=1&&e<=r)return e;throw new t(`INVALID_PAGE_REQUEST`,{field:n,value:typeof e==`number`||typeof e==`string`?String(e):e===null?`null`:typeof e})}}function C(e,t){return b.every(n=>e[n]===t[n])}function w(e){return{collection:e.collection,category:e.category,type:e.type,additionalKey:e.additionalKey,symbol:e.symbol,decimals:e.decimals,name:e.name,image:e.image,description:e.description,network:e.network,...e.contractAddress===void 0?{}:{contractAddress:e.contractAddress}}}function T(e){return e.reduce((e,t)=>e.plus(t.quantity),new y(0))}var E=class{constructor(n){e(this,`transport`,void 0);let{gatewayBaseUrl:r,httpRequestor:o}=n;if(typeof r!=`string`)throw new t(`INVALID_READS_OPTION`,{option:`gatewayBaseUrl`});if(o!==void 0&&typeof o!=`function`)throw new t(`INVALID_READS_OPTION`,{option:`httpRequestor`});this.transport={gatewayBaseUrl:r.replace(/\/+$/u,``),requestor:o??i,timeoutMs:a(n.requestTimeoutMs??3e4,`requestTimeoutMs`),wire:n.wire}}async fetchBalances(e){let t=r(e.owner,`owner`),n=x(e,``),i=await u(this.transport,`FetchBalances`,{owner:t,...n},c(n.collection)),a=f(i);if(a===void 0||a.some(e=>e.owner!==t))throw l(`FetchBalances`,i);return a}async fetchTokenBalance(e){let t=d(e.tokenClassKey,`tokenClassKey`),n=(await this.fetchBalances({owner:e.owner,...t})).find(e=>C(e,t));if(n===void 0)return;let r=Date.now(),i=t=>e.includeExpiredHolds===!0?[...t]:t.filter(e=>e.expires===0||e.expires>r),a=i(n.lockedHolds),o=i(n.inUseHolds),s=T(a),c=T(o);return{owner:n.owner,tokenClassKey:t,quantity:n.quantity,lockedHolds:a,inUseHolds:o,lockedQuantity:s.toFixed(),inUseQuantity:c.toFixed(),availableQuantity:new y(n.quantity).minus(s).minus(c).toFixed(),instanceIds:n.instanceIds}}async fetchNftBalances(e){return(await this.fetchBalances(e)).filter(e=>e.instanceIds.length>0)}fetchTokenClasses(e){return this.readClasses(`FetchTokenClasses`,e)}fetchTokenClassesWithSupply(e){return this.readClasses(`FetchTokenClassesWithSupply`,e)}async fetchTokenClass(e){let[t]=await this.readClasses(`FetchTokenClasses`,[e]);return t}async fetchTokenDetails(e){return w(await this.fetchTokenClass(e))}async fetchTokenClassesPage(e={}){let t=x(e,``);return this.readPage(`FetchTokenClassesWithPagination`,t,e,g)}async fetchAllTokenClasses(e={},t={}){let n=x(e,``);return this.readAllPages(`FetchTokenClassesWithPagination`,t,e=>this.readPage(`FetchTokenClassesWithPagination`,n,e,g))}fetchNftCollectionAuthorizationsPage(e={}){return this.readPage(`FetchNftCollectionAuthorizationsWithPagination`,{},e,p)}fetchAllNftCollectionAuthorizations(e={}){return this.readAllPages(`FetchNftCollectionAuthorizationsWithPagination`,e,e=>this.fetchNftCollectionAuthorizationsPage(e))}async fetchPublicKey(e){let t=r(e,`user`),n;try{n=await u(this.transport,`GetPublicKey`,{user:t})}catch(e){if(D(e))return;throw e}let i=h(n);if(i===void 0)throw l(`GetPublicKey`,n);return i}async readClasses(e,n){let r=Array.isArray(n)?n.length:0,i=v.tokenClasses;if(r<1||r>i)throw new t(`INVALID_TOKEN_BATCH`,{method:e,count:r,max:i});let a=n.map((e,t)=>d(e,`tokenClassKeys[${t}]`)),s;try{s=await u(this.transport,e,{tokenClasses:a})}catch(e){throw O(e)??e}let c=_(s);if(c===void 0)throw l(e,s);return a.map(e=>{let n=c.find(t=>C(t,e));if(n===void 0)throw new t(`TOKEN_CLASS_NOT_FOUND`,{tokenClassKey:o(e)},{body:s,write:!1});return n})}async readPage(e,n,r,i){let a=S(r.limit,`limit`,v.pageSize),{bookmark:o}=r;if(o!==void 0&&typeof o!=`string`)throw new t(`INVALID_PAGE_REQUEST`,{field:`bookmark`,value:typeof o});let s=await u(this.transport,e,{...n,...o===void 0||o===``?{}:{bookmark:o},...a===void 0?{}:{limit:a}}),c=m(s,i);if(c===void 0)throw l(e,s);return c}async readAllPages(e,n,r){let i=S(n.maxPages,`maxPages`,1e4)??v.maxPages,a=S(n.pageSize,`pageSize`,v.pageSize),o=[],s;for(let t=0;t<i;t+=1){let t=await r({...s===void 0?{}:{bookmark:s},...a===void 0?{}:{limit:a}});if(o.push(...t.results),t.nextPageBookmark===void 0)return o;if(t.nextPageBookmark===s)throw l(e,t);s=t.nextPageBookmark}throw new t(`PAGINATION_LIMIT_EXCEEDED`,{method:e,maxPages:i},{write:!1})}};function D(e){return!n(e,`GATEWAY_HTTP_ERROR`)||e.status!==404?!1:s(e.body)?.ErrorKey===`PK_NOT_FOUND`}function O(e){if(!n(e,`GATEWAY_HTTP_ERROR`)||e.status!==404)return;let r=s(e.body);if(r?.ErrorKey!==`TOKEN_CLASS_NOT_FOUND`)return;let i=r.ErrorPayload,a=typeof i==`object`&&i?i.tokenClassKey:void 0;return new t(`TOKEN_CLASS_NOT_FOUND`,{tokenClassKey:typeof a==`string`?a:``},{status:e.status,body:e.body,url:e.url,write:!1,cause:e})}export{E as GatewayReads,w as tokenDetailsOf};
2
2
  //# sourceMappingURL=gateway_reads.js.map
@@ -0,0 +1,2 @@
1
+ import{GalaSDKError as e}from"../classes/gala_sdk_error.js";import{galaChainUserRef as t}from"../writes/identity.js";function n(t,n){if(typeof t!=`string`)throw new e(`INVALID_NFT_INPUT`,{field:n,reason:`not_a_string`});if(t===``)throw new e(`INVALID_NFT_INPUT`,{field:n,reason:`empty`});if(!/^[a-zA-Z0-9]{3,50}$/u.test(t))throw new e(`INVALID_NFT_INPUT`,{field:n,reason:`bad_collection_name`});return t}function r(e){try{return t(e,`address`),!0}catch{return!1}}function i(e){return(r(e)?t(e,`address`):e).toLowerCase()}var a=class{constructor(e){this.reads=e}async fetchNftCollections(e){let n=t(e,`walletAddress`);return(await this.reads.fetchAllNftCollectionAuthorizations({pageSize:1e3})).filter(e=>e.authorizedUsers.some(e=>i(e)===i(n))).map(e=>({authorizedUser:n,collection:e.collection}))}async isNftCollectionAvailable(e){let t=n(e,`collection`);return!(await this.reads.fetchAllNftCollectionAuthorizations({pageSize:1e3})).some(e=>e.collection===t)}async fetchNftTokenClasses(e){return n(e.collection,`collection`),(await this.reads.fetchAllTokenClasses({collection:e.collection,category:e.category,type:e.type},{pageSize:1e3})).map(e=>({collection:e.collection,type:e.type,category:e.category,additionalKey:e.additionalKey,totalSupply:e.totalSupply,maxSupply:e.maxSupply,isNonFungible:e.isNonFungible,name:e.name,description:e.description,image:e.image,symbol:e.symbol,...e.rarity===void 0?{}:{rarity:e.rarity}}))}async fetchNftBalances(e,n){let r=t(e,`ownerAddress`);return(await this.reads.fetchNftBalances({owner:r,collection:n})).map(e=>({owner:e.owner,collection:e.collection,category:e.category,type:e.type,additionalKey:e.additionalKey,instanceIds:[...e.instanceIds],totalOwned:e.instanceIds.length}))}};export{a as NftCollectionReads};
2
+ //# sourceMappingURL=nft_collections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nft_collections.js","names":["collectionName","name","GalaSDKError","validAddress","galaChainUserRef","value","canonicalAddress","NftCollectionReads","reads","authorizedUser","walletAddress","row","user","collection","params","owner","ownerAddress","collectionFilter"],"sources":["../../../src/reads/nft_collections.ts"],"sourcesContent":["import { GalaSDKError } from '../classes/gala_sdk_error.js';\nimport { galaChainUserRef } from '../writes/identity.js';\nimport type { GatewayReads } from './gateway_reads.js';\n\nexport interface NftCollectionAuthorization {\n authorizedUser: string;\n collection: string;\n created?: number;\n}\nexport interface FetchNftTokenClassesParams {\n collection: string;\n type?: string;\n category?: string;\n}\nexport interface NftTokenClassWithSupply {\n collection: string;\n type: string;\n category: string;\n additionalKey: string;\n totalSupply: string;\n maxSupply?: string;\n isNonFungible: boolean;\n name?: string;\n description?: string;\n image?: string;\n symbol?: string;\n rarity?: string;\n}\nexport interface NftBalance {\n owner: string;\n collection: string;\n category: string;\n type: string;\n additionalKey: string;\n instanceIds: string[];\n totalOwned: number;\n}\n/** A read's collection name: 3 to 50 letters and digits. @throws GalaSDKError `INVALID_NFT_INPUT`. */\nfunction collectionName(name: unknown, field: string): string {\n if (typeof name !== 'string')\n throw new GalaSDKError('INVALID_NFT_INPUT', { field, reason: 'not_a_string' });\n if (name === '') throw new GalaSDKError('INVALID_NFT_INPUT', { field, reason: 'empty' });\n if (!/^[a-zA-Z0-9]{3,50}$/u.test(name)) {\n throw new GalaSDKError('INVALID_NFT_INPUT', { field, reason: 'bad_collection_name' });\n }\n return name;\n}\nfunction validAddress(value: unknown): boolean {\n try {\n galaChainUserRef(value, 'address');\n return true;\n } catch {\n return false;\n }\n}\nfunction canonicalAddress(value: string): string {\n return (validAddress(value) ? galaChainUserRef(value, 'address') : value).toLowerCase();\n}\n/** NFT collection reads in Launchpad result shapes, using a shared gateway reader. */\nexport class NftCollectionReads {\n constructor(private readonly reads: GatewayReads) {}\n public async fetchNftCollections(walletAddress: string): Promise<NftCollectionAuthorization[]> {\n const authorizedUser = galaChainUserRef(walletAddress, 'walletAddress');\n return (await this.reads.fetchAllNftCollectionAuthorizations({ pageSize: 1000 }))\n .filter((row) =>\n row.authorizedUsers.some(\n (user) => canonicalAddress(user) === canonicalAddress(authorizedUser),\n ),\n )\n .map((row) => ({ authorizedUser, collection: row.collection }));\n }\n public async isNftCollectionAvailable(name: string): Promise<boolean> {\n const collection = collectionName(name, 'collection');\n return !(await this.reads.fetchAllNftCollectionAuthorizations({ pageSize: 1000 })).some(\n (row) => row.collection === collection,\n );\n }\n public async fetchNftTokenClasses(\n params: FetchNftTokenClassesParams,\n ): Promise<NftTokenClassWithSupply[]> {\n collectionName(params.collection, 'collection');\n return (\n await this.reads.fetchAllTokenClasses(\n { collection: params.collection, category: params.category, type: params.type },\n { pageSize: 1000 },\n )\n ).map((row) => ({\n collection: row.collection,\n type: row.type,\n category: row.category,\n additionalKey: row.additionalKey,\n totalSupply: row.totalSupply,\n maxSupply: row.maxSupply,\n isNonFungible: row.isNonFungible,\n name: row.name,\n description: row.description,\n image: row.image,\n symbol: row.symbol,\n ...(row.rarity === undefined ? {} : { rarity: row.rarity }),\n }));\n }\n public async fetchNftBalances(\n ownerAddress: string,\n collectionFilter?: string,\n ): Promise<NftBalance[]> {\n const owner = galaChainUserRef(ownerAddress, 'ownerAddress');\n return (\n await this.reads.fetchNftBalances({\n owner,\n collection: collectionFilter,\n })\n ).map((row) => ({\n owner: row.owner,\n collection: row.collection,\n category: row.category,\n type: row.type,\n additionalKey: row.additionalKey,\n instanceIds: [...row.instanceIds],\n totalOwned: row.instanceIds.length,\n }));\n }\n}\n"],"mappings":"A,qHAsCA,SAASA,EAAe,EAAe,EAAuB,CAC5D,GAAI,OAAOC,GAAS,SAClB,MAAM,IAAIC,EAAa,oBAAqB,CAAE,QAAO,OAAQ,cAAe,CAAC,EAC/E,GAAID,IAAS,GAAI,MAAM,IAAIC,EAAa,oBAAqB,CAAE,QAAO,OAAQ,OAAQ,CAAC,EACvF,GAAI,CAAC,uBAAuB,KAAKD,CAAI,EACnC,MAAM,IAAIC,EAAa,oBAAqB,CAAE,QAAO,OAAQ,qBAAsB,CAAC,EAEtF,OAAOD,CACT,CACA,SAASE,EAAa,EAAyB,CAC7C,GAAI,CAEF,OADAC,EAAiBC,EAAO,SAAS,EAC1B,EACT,MAAQ,CACN,MAAO,EACT,CACF,CACA,SAASC,EAAiB,EAAuB,CAC/C,OAAQH,EAAaE,CAAK,EAAID,EAAiBC,EAAO,SAAS,EAAIA,EAAA,CAAO,YAAY,CACxF,CAEA,IAAaE,EAAb,KAAgC,CAC9B,YAAY,EAAsC,CAArB,KAAA,MAAAC,CAAsB,CACnD,MAAa,oBAAoB,EAA8D,CAC7F,IAAMC,EAAiBL,EAAiBM,EAAe,eAAe,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Y,MAC9B,EAAE,CACJ,CACF,E"}
@@ -0,0 +1,2 @@
1
+ function e(){return`10000`}function t(){return`1000`}function n(n){let r=`0`,i={};if(n.claimCollection){let t=e();i.collectionClaim=t,r=String(BigInt(r)+BigInt(t))}if((n.createTokenClasses??0)>0){let e=n.createTokenClasses,a=t();i.tokenClassCreate=a,i.tokenClassCount=e,r=String(BigInt(r)+BigInt(a)*BigInt(e))}return{totalFee:r,breakdown:i}}export{n as estimateNftOperationFees,e as getNftCollectionClaimFee,t as getNftTokenClassCreateFee};
2
+ //# sourceMappingURL=nft_fees.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nft_fees.js","names":["getNftCollectionClaimFee","getNftTokenClassCreateFee","estimateNftOperationFees","totalFee","breakdown","params","fee","count"],"sources":["../../../src/reads/nft_fees.ts"],"sourcesContent":["/** Fixed GalaChain NFT operation fees, denominated in GALA. */\nexport interface EstimateNftFeesParams {\n claimCollection?: boolean;\n createTokenClasses?: number;\n}\n\nexport interface NftFeeBreakdown {\n collectionClaim?: string;\n tokenClassCreate?: string;\n tokenClassCount?: number;\n mintFee?: string;\n}\n\nexport interface NftFeeEstimate {\n totalFee: string;\n breakdown: NftFeeBreakdown;\n}\n\nexport function getNftCollectionClaimFee(): string {\n return '10000';\n}\n\nexport function getNftTokenClassCreateFee(): string {\n return '1000';\n}\n\n/** Calculate the fixed fees for the requested collection and token-class operations. */\nexport function estimateNftOperationFees(params: EstimateNftFeesParams): NftFeeEstimate {\n let totalFee = '0';\n const breakdown: NftFeeBreakdown = {};\n if (params.claimCollection) {\n const fee = getNftCollectionClaimFee();\n breakdown.collectionClaim = fee;\n totalFee = String(BigInt(totalFee) + BigInt(fee));\n }\n if ((params.createTokenClasses ?? 0) > 0) {\n const count = params.createTokenClasses!;\n const fee = getNftTokenClassCreateFee();\n breakdown.tokenClassCreate = fee;\n breakdown.tokenClassCount = count;\n totalFee = String(BigInt(totalFee) + BigInt(fee) * BigInt(count));\n }\n return { totalFee, breakdown };\n}\n"],"mappings":"AAkBA,SAAgBA,GAAmC,CACjD,MAAO,OACT,CAEA,SAAgBC,GAAoC,CAClD,MAAO,MACT,CAGA,SAAgBC,EAAyB,EAA+C,CACtF,IAAIC,EAAW,IACTC,EAA6B,CAAC,EACpC,GAAIC,EAAO,gBAAiB,CAC1B,IAAMC,EAAMN,EAAyB,EACrC,EAAU,gBAAkBM,EAC5B,EAAW,OAAO,OAAOH,CAAQ,EAAI,OAAOG,CAAG,CAAC,CAClD,CACA,IAAKD,EAAO,oBAAsB,GAAK,EAAG,CACxC,IAAME,EAAQF,EAAO,mBACfC,EAAML,EAA0B,EACtC,EAAU,iBAAmBK,EAC7B,EAAU,gBAAkBC,EAC5B,EAAW,OAAO,OAAOJ,CAAQ,EAAI,OAAOG,CAAG,EAAI,OAAOC,CAAK,CAAC,CAClE,CACA,MAAO,CAAE,WAAU,WAAU,CAC/B,C"}
@@ -1,2 +1,2 @@
1
- import{GalaSDKError as e}from"../classes/gala_sdk_error.js";import{buildRequestHeaders as t,readResponseBody as n,requestWithTimeout as r}from"../utils/transport.js";const i={FetchBalances:`token-contract`,FetchTokenClasses:`token-contract`,FetchTokenClassesWithSupply:`token-contract`,FetchTokenClassesWithPagination:`token-contract`,FetchNftCollectionAuthorizationsWithPagination:`token-contract`,GetPublicKey:`public-key-contract`},a=/* @__PURE__ */ new Set([`GetPublicKey`]);function o(e){return e!==void 0&&/^\$?music$/iu.test(e)?`music`:`asset`}function s(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function c(e,t){let n=e?.[t];return typeof n==`string`?n:``}function l(e){if(!s(e))return;let t=e.error;return s(t)?t:e}async function u(a,o,s,c=`asset`){let l=`${a.gatewayBaseUrl}/api/${c}/${i[o]}/${o}`,u=await r(a.requestor,l,{method:`POST`,headers:t(a.wire,{json:!0}),body:JSON.stringify(s)},a.timeoutMs,{write:!1}),f;try{f=await n(u)}catch(t){throw new e(`TRANSPORT_ERROR`,{url:l},{url:l,cause:t,write:!1})}return d(o,l,u,f)}function d(t,n,r,i){let o={status:r.status,body:i,url:n,write:!1},u=s(i)?i:void 0,d=u?.Status;if(typeof d==`number`&&d!==1)throw new e(`GATEWAY_READ_REJECTED`,{method:t,chainStatus:d,errorKey:c(u,`ErrorKey`),serverMessage:c(u,`Message`)},o);if(!r.ok){let n=l(i);throw new e(`GATEWAY_HTTP_ERROR`,{method:t,status:r.status,serverMessage:c(n,`Message`)||c(u,`message`)},o)}let f=d===1||d===void 0&&a.has(t);if(u===void 0||!f||!(`Data`in u))throw new e(`GATEWAY_READ_RESPONSE_INVALID`,{method:t},o);return u.Data}function f(t,n){return new e(`GATEWAY_READ_RESPONSE_INVALID`,{method:t},{body:n,write:!1})}export{l as chainErrorOf,o as channelOf,f as invalidAnswer,u as readGateway};
1
+ import{GalaSDKError as e}from"../classes/gala_sdk_error.js";import{buildRequestHeaders as t,readResponseBody as n,requestWithTimeout as r}from"../utils/transport.js";const i={FetchBalances:`token-contract`,FetchTokenClasses:`token-contract`,FetchTokenClassesWithSupply:`token-contract`,FetchTokenClassesWithPagination:`token-contract`,FetchNftCollectionAuthorizationsWithPagination:`token-contract`,GetPublicKey:`public-key-contract`},a=/* @__PURE__ */ new Set([`GetPublicKey`]);function o(e){return e!==void 0&&/^\$?music$/iu.test(e)?`music`:`asset`}function s(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function c(e,t){let n=e?.[t];return typeof n==`string`?n:``}function l(e){if(!s(e))return;let t=e.error;return s(t)?t:e}async function u(a,o,s,c=`asset`){let l=`${a.gatewayBaseUrl}/api/${c}/${i[o]}/${o}`,u=await r(a.requestor,l,{method:`POST`,headers:t(a.wire,{json:!0}),body:JSON.stringify(s)},a.timeoutMs,{write:!1}),f;try{f=await n(u)}catch(t){throw new e(`TRANSPORT_ERROR`,{url:l},{url:l,cause:t,write:!1})}return d(o,l,u,f)}function d(t,n,r,i){let o={status:r.status,body:i,url:n,write:!1},u=s(i)?i:void 0,d=u?.Status;if(typeof d==`number`&&d!==1)throw new e(`GATEWAY_READ_REJECTED`,{method:t,chainStatus:d,errorKey:c(u,`ErrorKey`),serverMessage:c(u,`Message`)},o);if(!r.ok){let n=l(i);throw new e(`GATEWAY_HTTP_ERROR`,{method:t,status:r.status,serverMessage:c(n,`Message`)||c(u,`message`)},o)}let f=d===1||d===void 0&&a.has(t);if(u===void 0||!f||!(`Data`in u))throw new e(`GATEWAY_READ_RESPONSE_INVALID`,{method:t},o);return u.Data}function f(t,n){return new e(`GATEWAY_READ_RESPONSE_INVALID`,{method:t},{body:n,write:!1})}export{l as chainErrorOf,o as channelOf,d as dataOf,f as invalidAnswer,u as readGateway};
2
2
  //# sourceMappingURL=request.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","names":["CONTRACT_OF","ANSWERED_WITHOUT_STATUS","channelOf","collection","isRecord","value","stringField","record","key","chainErrorOf","body","nested","\"error\"","readGateway","url","transport","channel","method","response","requestWithTimeout","buildRequestHeaders","answer","readResponseBody","cause","GalaSDKError","dataOf","context","envelope","chainStatus","\"Status\"","chainError","statusAccepted","\"Data\"","invalidAnswer","data"],"sources":["../../../src/reads/request.ts"],"sourcesContent":["import { GalaSDKError, type GalaErrorContext } from '../classes/gala_sdk_error.js';\nimport type { HTTPResponse, HttpRequestor } from '../types/http_requestor.js';\nimport type { WireOptions } from '../types/wire.js';\nimport { buildRequestHeaders, readResponseBody, requestWithTimeout } from '../utils/transport.js';\nimport type { GatewayReadMethod } from './types.js';\n\n/** What every read is sent with. */\nexport interface ReadTransport {\n readonly gatewayBaseUrl: string;\n readonly requestor: HttpRequestor;\n readonly timeoutMs: number;\n readonly wire: WireOptions | undefined;\n}\n\n/** The gateway channel a token lives on. */\nexport type GatewayChannel = 'asset' | 'music';\n\n/** The chaincode contract each read method belongs to (part of its URL). */\nconst CONTRACT_OF: Readonly<Record<GatewayReadMethod, 'token-contract' | 'public-key-contract'>> = {\n FetchBalances: 'token-contract',\n FetchTokenClasses: 'token-contract',\n FetchTokenClassesWithSupply: 'token-contract',\n FetchTokenClassesWithPagination: 'token-contract',\n FetchNftCollectionAuthorizationsWithPagination: 'token-contract',\n GetPublicKey: 'public-key-contract',\n};\n\n/**\n * Methods whose successful answer carries no `Status`: the connect-api GalaChain proxies answer\n * `GetPublicKey` with `{ Data: { publicKey } }` only (recorded 2026-10-14, prod and stage,\n * `tests/fixtures/public-key-recorded.json`). A `Status` they do send is still checked.\n */\nconst ANSWERED_WITHOUT_STATUS: ReadonlySet<GatewayReadMethod> = new Set<GatewayReadMethod>([\n 'GetPublicKey',\n]);\n\n/**\n * The channel of a collection: `$MUSIC` (and `MUSIC`, any case) lives on the gateway's `music`\n * channel, every other collection (`$GMUSIC` included) on `asset`.\n */\nexport function channelOf(collection: string | undefined): GatewayChannel {\n return collection !== undefined && /^\\$?music$/iu.test(collection) ? 'music' : 'asset';\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction stringField(record: Record<string, unknown> | undefined, key: string): string {\n const value = record?.[key];\n return typeof value === 'string' ? value : '';\n}\n\n/**\n * The chain's error object of a refused answer: GalaChain's gateway nests it as\n * `{ error: { Status: 0, ErrorKey, Message, ErrorPayload }, message }`; an older answer carries\n * `Status` / `ErrorKey` / `Message` at the top.\n */\nexport function chainErrorOf(body: unknown): Record<string, unknown> | undefined {\n if (!isRecord(body)) return undefined;\n const nested = body['error'];\n return isRecord(nested) ? nested : body;\n}\n\n/**\n * POSTs one read and returns the chain's `Data`. Reads change nothing, so every failure is a READ's\n * (`error.write === false`) and a retry is always safe:\n *\n * - no answer: `REQUEST_TIMEOUT` / `TRANSPORT_ERROR`, both `write: false` (an app requestor's\n * own rejection passes through unchanged: it is the app's error); a body that broke off is\n * `TRANSPORT_ERROR`;\n * - a numeric top-level `Status` other than 1, in any HTTP status: `GATEWAY_READ_REJECTED`;\n * - any other non-2xx: `GATEWAY_HTTP_ERROR` (`params.status`; the chain's refusal is `error.body`);\n * - a 2xx that is not `{ Status: 1, Data }` (for `GetPublicKey`, whose answer carries no\n * `Status`, not `{ Data }`): `GATEWAY_READ_RESPONSE_INVALID`.\n */\nexport async function readGateway(\n transport: ReadTransport,\n method: GatewayReadMethod,\n body: Record<string, unknown>,\n channel: GatewayChannel = 'asset',\n): Promise<unknown> {\n const url = `${transport.gatewayBaseUrl}/api/${channel}/${CONTRACT_OF[method]}/${method}`;\n const response = await requestWithTimeout(\n transport.requestor,\n url,\n {\n method: 'POST',\n headers: buildRequestHeaders(transport.wire, { json: true }),\n body: JSON.stringify(body),\n },\n transport.timeoutMs,\n { write: false },\n );\n let answer: unknown;\n try {\n answer = await readResponseBody(response);\n } catch (cause: unknown) {\n // The answer's headers arrived and its body broke off: nothing usable was read.\n throw new GalaSDKError('TRANSPORT_ERROR', { url }, { url, cause, write: false });\n }\n return dataOf(method, url, response, answer);\n}\n\nfunction dataOf(\n method: GatewayReadMethod,\n url: string,\n response: HTTPResponse,\n answer: unknown,\n): unknown {\n const context: GalaErrorContext = { status: response.status, body: answer, url, write: false };\n const envelope = isRecord(answer) ? answer : undefined;\n const chainStatus = envelope?.['Status'];\n if (typeof chainStatus === 'number' && chainStatus !== 1) {\n throw new GalaSDKError(\n 'GATEWAY_READ_REJECTED',\n {\n method,\n chainStatus,\n errorKey: stringField(envelope, 'ErrorKey'),\n serverMessage: stringField(envelope, 'Message'),\n },\n context,\n );\n }\n if (!response.ok) {\n const chainError = chainErrorOf(answer);\n throw new GalaSDKError(\n 'GATEWAY_HTTP_ERROR',\n {\n method,\n status: response.status,\n serverMessage: stringField(chainError, 'Message') || stringField(envelope, 'message'),\n },\n context,\n );\n }\n const statusAccepted =\n chainStatus === 1 || (chainStatus === undefined && ANSWERED_WITHOUT_STATUS.has(method));\n if (envelope === undefined || !statusAccepted || !('Data' in envelope)) {\n throw new GalaSDKError('GATEWAY_READ_RESPONSE_INVALID', { method }, context);\n }\n return envelope['Data'];\n}\n\n/** The error for a 2xx whose `Data` is not what `method` answers. */\nexport function invalidAnswer(\n method: GatewayReadMethod,\n data: unknown,\n): GalaSDKError<'GATEWAY_READ_RESPONSE_INVALID'> {\n return new GalaSDKError(\n 'GATEWAY_READ_RESPONSE_INVALID',\n { method },\n { body: data, write: false },\n );\n}\n"],"mappings":"A,sKAkBA,MAAMA,EAA6F,CACjG,cAAe,iBACf,kBAAmB,iBACnB,4BAA6B,iBAC7B,gCAAiC,iBACjC,+CAAgD,iBAChD,aAAc,qBAChB,EAOMC,kBAA0D,IAAI,IAAuB,CACzF,cACF,CAAC,EAMD,SAAgBC,EAAU,EAAgD,CACxE,OAAOC,IAAe,IAAA,IAAa,eAAe,KAAKA,CAAU,EAAI,QAAU,OACjF,CAEA,SAASC,EAAS,EAAkD,CAClE,OAAO,OAAOC,GAAU,YAAYA,GAAkB,CAAC,MAAM,QAAQA,CAAK,CAC5E,CAEA,SAASC,EAAY,EAA6C,EAAqB,CACrF,IAAMD,EAAQE,IAASC,GACvB,OAAO,OAAOH,GAAU,SAAWA,EAAQ,EAC7C,CAOA,SAAgBI,EAAa,EAAoD,CAC/E,GAAI,CAACL,EAASM,CAAI,EAAG,OACrB,IAAMC,EAASD,EAAKE,MACpB,OAAOR,EAASO,CAAM,EAAIA,EAASD,CACrC,CAcA,eAAsBG,EACpB,EACA,EACA,EACA,EAA0B,QACR,CAClB,IAAMC,EAAM,GAAGC,EAAU,eAAe,OAAOC,EAAQ,GAAGhB,EAAYiB,GAAQ,GAAGA,IAC3EC,EAAW,MAAMC,EACrBJ,EAAU,UACVD,EACA,CACE,OAAQ,OACR,QAASM,EAAoBL,EAAU,KAAM,CAAE,KAAM,EAAK,CAAC,EAC3D,KAAM,KAAK,UAAUL,CAAI,CAC3B,EACAK,EAAU,UACV,CAAE,MAAO,EAAM,CACjB,EACIM,EACJ,GAAI,CACF,EAAS,MAAMC,EAAiBJ,CAAQ,CAC1C,OAASK,EAAgB,CAEvB,MAAM,IAAIC,EAAa,kBAAmB,CAAE,KAAI,EAAG,CAAE,MAAK,QAAO,MAAO,EAAM,CAAC,CACjF,CACA,OAAOC,EAAOR,EAAQH,EAAKI,EAAUG,CAAM,CAC7C,CAEA,SAASI,EACP,EACA,EACA,EACA,EACS,CACT,IAAMC,EAA4B,CAAE,OAAQR,EAAS,OAAQ,KAAMG,EAAQ,MAAK,MAAO,EAAM,EACvFM,EAAWvB,EAASiB,CAAM,EAAIA,EAAS,IAAA,GACvCO,EAAcD,GAAWE,OAC/B,GAAI,OAAOD,GAAgB,UAAYA,IAAgB,EACrD,MAAM,IAAIJ,EACR,wBACA,CACE,SACA,cACA,SAAUlB,EAAYqB,EAAU,UAAU,EAC1C,cAAerB,EAAYqB,EAAU,SAAS,CAChD,EACAD,CACF,EAEF,GAAI,CAACR,EAAS,GAAI,CAChB,IAAMY,EAAarB,EAAaY,CAAM,EACtC,MAAM,IAAIG,EACR,qBACA,CACE,SACA,OAAQN,EAAS,OACjB,cAAeZ,EAAYwB,EAAY,SAAS,GAAKxB,EAAYqB,EAAU,SAAS,CACtF,EACAD,CACF,CACF,CACA,IAAMK,EACJH,IAAgB,GAAMA,IAAgB,IAAA,IAAa3B,EAAwB,IAAIgB,CAAM,EACvF,GAAIU,IAAa,IAAA,IAAa,CAACI,GAAkB,EAAE,SAAUJ,GAC3D,MAAM,IAAIH,EAAa,gCAAiC,CAAE,QAAO,EAAGE,CAAO,EAE7E,OAAOC,EAASK,IAClB,CAGA,SAAgBC,EACd,EACA,EAC+C,CAC/C,OAAO,IAAIT,EACT,gCACA,CAAE,QAAO,EACT,CAAE,KAAMU,EAAM,MAAO,EAAM,CAC7B,CACF,C"}
1
+ {"version":3,"file":"request.js","names":["CONTRACT_OF","ANSWERED_WITHOUT_STATUS","channelOf","collection","isRecord","value","stringField","record","key","chainErrorOf","body","nested","\"error\"","readGateway","url","transport","channel","method","response","requestWithTimeout","buildRequestHeaders","answer","readResponseBody","cause","GalaSDKError","dataOf","context","envelope","chainStatus","\"Status\"","chainError","statusAccepted","\"Data\"","invalidAnswer","data"],"sources":["../../../src/reads/request.ts"],"sourcesContent":["import { GalaSDKError, type GalaErrorContext } from '../classes/gala_sdk_error.js';\nimport type { HTTPResponse, HttpRequestor } from '../types/http_requestor.js';\nimport type { WireOptions } from '../types/wire.js';\nimport { buildRequestHeaders, readResponseBody, requestWithTimeout } from '../utils/transport.js';\nimport type { GatewayReadMethod } from './types.js';\n\n/** What every read is sent with. */\nexport interface ReadTransport {\n readonly gatewayBaseUrl: string;\n readonly requestor: HttpRequestor;\n readonly timeoutMs: number;\n readonly wire: WireOptions | undefined;\n}\n\n/** The gateway channel a token lives on. */\nexport type GatewayChannel = 'asset' | 'music';\n\n/** The chaincode contract each read method belongs to (part of its URL). */\nconst CONTRACT_OF: Readonly<Record<GatewayReadMethod, 'token-contract' | 'public-key-contract'>> = {\n FetchBalances: 'token-contract',\n FetchTokenClasses: 'token-contract',\n FetchTokenClassesWithSupply: 'token-contract',\n FetchTokenClassesWithPagination: 'token-contract',\n FetchNftCollectionAuthorizationsWithPagination: 'token-contract',\n GetPublicKey: 'public-key-contract',\n};\n\n/**\n * Methods whose successful answer carries no `Status`: the connect-api GalaChain proxies answer\n * `GetPublicKey` with `{ Data: { publicKey } }` only (recorded 2026-10-14, prod and stage,\n * `tests/fixtures/public-key-recorded.json`). A `Status` they do send is still checked.\n */\nconst ANSWERED_WITHOUT_STATUS: ReadonlySet<string> = new Set<string>(['GetPublicKey']);\n\n/**\n * The channel of a collection: `$MUSIC` (and `MUSIC`, any case) lives on the gateway's `music`\n * channel, every other collection (`$GMUSIC` included) on `asset`.\n */\nexport function channelOf(collection: string | undefined): GatewayChannel {\n return collection !== undefined && /^\\$?music$/iu.test(collection) ? 'music' : 'asset';\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction stringField(record: Record<string, unknown> | undefined, key: string): string {\n const value = record?.[key];\n return typeof value === 'string' ? value : '';\n}\n\n/**\n * The chain's error object of a refused answer: GalaChain's gateway nests it as\n * `{ error: { Status: 0, ErrorKey, Message, ErrorPayload }, message }`; an older answer carries\n * `Status` / `ErrorKey` / `Message` at the top.\n */\nexport function chainErrorOf(body: unknown): Record<string, unknown> | undefined {\n if (!isRecord(body)) return undefined;\n const nested = body['error'];\n return isRecord(nested) ? nested : body;\n}\n\n/**\n * POSTs one read and returns the chain's `Data`. Reads change nothing, so every failure is a READ's\n * (`error.write === false`) and a retry is always safe:\n *\n * - no answer: `REQUEST_TIMEOUT` / `TRANSPORT_ERROR`, both `write: false` (an app requestor's\n * own rejection passes through unchanged: it is the app's error); a body that broke off is\n * `TRANSPORT_ERROR`;\n * - a numeric top-level `Status` other than 1, in any HTTP status: `GATEWAY_READ_REJECTED`;\n * - any other non-2xx: `GATEWAY_HTTP_ERROR` (`params.status`; the chain's refusal is `error.body`);\n * - a 2xx that is not `{ Status: 1, Data }` (for `GetPublicKey`, whose answer carries no\n * `Status`, not `{ Data }`): `GATEWAY_READ_RESPONSE_INVALID`.\n */\nexport async function readGateway(\n transport: ReadTransport,\n method: GatewayReadMethod,\n body: Record<string, unknown>,\n channel: GatewayChannel = 'asset',\n): Promise<unknown> {\n const url = `${transport.gatewayBaseUrl}/api/${channel}/${CONTRACT_OF[method]}/${method}`;\n const response = await requestWithTimeout(\n transport.requestor,\n url,\n {\n method: 'POST',\n headers: buildRequestHeaders(transport.wire, { json: true }),\n body: JSON.stringify(body),\n },\n transport.timeoutMs,\n { write: false },\n );\n let answer: unknown;\n try {\n answer = await readResponseBody(response);\n } catch (cause: unknown) {\n // The answer's headers arrived and its body broke off: nothing usable was read.\n throw new GalaSDKError('TRANSPORT_ERROR', { url }, { url, cause, write: false });\n }\n return dataOf(method, url, response, answer);\n}\n\n/**\n * The chain's `Data` of a read-like answer, or the error for one that is not (see\n * {@link readGateway} for the codes). Also the reading of a signed DryRun answer, which changes\n * nothing either, so it names its own `method` (a string, not a read method).\n */\nexport function dataOf(\n method: string,\n url: string,\n response: HTTPResponse,\n answer: unknown,\n): unknown {\n const context: GalaErrorContext = { status: response.status, body: answer, url, write: false };\n const envelope = isRecord(answer) ? answer : undefined;\n const chainStatus = envelope?.['Status'];\n if (typeof chainStatus === 'number' && chainStatus !== 1) {\n throw new GalaSDKError(\n 'GATEWAY_READ_REJECTED',\n {\n method,\n chainStatus,\n errorKey: stringField(envelope, 'ErrorKey'),\n serverMessage: stringField(envelope, 'Message'),\n },\n context,\n );\n }\n if (!response.ok) {\n const chainError = chainErrorOf(answer);\n throw new GalaSDKError(\n 'GATEWAY_HTTP_ERROR',\n {\n method,\n status: response.status,\n serverMessage: stringField(chainError, 'Message') || stringField(envelope, 'message'),\n },\n context,\n );\n }\n const statusAccepted =\n chainStatus === 1 || (chainStatus === undefined && ANSWERED_WITHOUT_STATUS.has(method));\n if (envelope === undefined || !statusAccepted || !('Data' in envelope)) {\n throw new GalaSDKError('GATEWAY_READ_RESPONSE_INVALID', { method }, context);\n }\n return envelope['Data'];\n}\n\n/** The error for a 2xx whose `Data` is not what `method` answers. */\nexport function invalidAnswer(\n method: GatewayReadMethod,\n data: unknown,\n): GalaSDKError<'GATEWAY_READ_RESPONSE_INVALID'> {\n return new GalaSDKError(\n 'GATEWAY_READ_RESPONSE_INVALID',\n { method },\n { body: data, write: false },\n );\n}\n"],"mappings":"A,sKAkBA,MAAMA,EAA6F,CACjG,cAAe,iBACf,kBAAmB,iBACnB,4BAA6B,iBAC7B,gCAAiC,iBACjC,+CAAgD,iBAChD,aAAc,qBAChB,EAOMC,kBAA+C,IAAI,IAAY,CAAC,cAAc,CAAC,EAMrF,SAAgBC,EAAU,EAAgD,CACxE,OAAOC,IAAe,IAAA,IAAa,eAAe,KAAKA,CAAU,EAAI,QAAU,OACjF,CAEA,SAASC,EAAS,EAAkD,CAClE,OAAO,OAAOC,GAAU,YAAYA,GAAkB,CAAC,MAAM,QAAQA,CAAK,CAC5E,CAEA,SAASC,EAAY,EAA6C,EAAqB,CACrF,IAAMD,EAAQE,IAASC,GACvB,OAAO,OAAOH,GAA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