@gala-chain/gala-core-sdk 1.1.0-beta.9 → 1.2.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +48 -2
  2. package/dist/bridge.cjs +1 -11
  3. package/dist/bridge.cjs.map +1 -1
  4. package/dist/bridge.mjs +1 -11
  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 +1 -1
  21. package/dist/browser/utils/dto_operation.js.map +1 -1
  22. package/dist/browser/utils/transport.js +1 -1
  23. package/dist/browser/version.js +1 -1
  24. package/dist/browser/version.js.map +1 -1
  25. package/dist/browser/writes/gateway_writes.js +1 -1
  26. package/dist/browser/writes/gateway_writes.js.map +1 -1
  27. package/dist/browser/writes/identity.js +1 -1
  28. package/dist/browser/writes/identity.js.map +1 -1
  29. package/dist/browser/writes/nft.js +2 -0
  30. package/dist/browser/writes/nft.js.map +1 -0
  31. package/dist/browser/writes/nft_fee.js +2 -0
  32. package/dist/browser/writes/nft_fee.js.map +1 -0
  33. package/dist/browser/writes/submit.js +1 -1
  34. package/dist/browser/writes/submit.js.map +1 -1
  35. package/dist/browser/writes/types.js.map +1 -1
  36. package/dist/index.cjs +761 -141
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.cts +284 -7
  39. package/dist/index.d.ts +284 -7
  40. package/dist/index.mjs +753 -142
  41. package/dist/index.mjs.map +1 -1
  42. package/package.json +32 -30
package/dist/index.mjs CHANGED
@@ -56,6 +56,20 @@ const INVALID_TOKEN_REFERENCE_REASONS = [
56
56
  "bad_instance"
57
57
  ];
58
58
  /**
59
+ * Why an NFT read's, write's or fee quote's input is refused (`INVALID_NFT_INPUT.params.reason`).
60
+ * A token for the app to map to its own text.
61
+ */
62
+ const INVALID_NFT_INPUT_REASONS = [
63
+ "not_a_string",
64
+ "empty",
65
+ "bad_characters",
66
+ "not_a_positive_whole_number",
67
+ "above_mint_limit",
68
+ "bad_public_key",
69
+ "bad_authorities",
70
+ "bad_collection_name"
71
+ ];
72
+ /**
59
73
  * The `GatewayWrites` options that are refused when missing or of the wrong type
60
74
  * (`INVALID_WRITES_OPTION.params.option`). `walletAddress`, `requestTimeoutMs` and
61
75
  * `uniqueKeyPrefix` have codes of their own (`INVALID_WALLET_ADDRESS`, `INVALID_TIMEOUT`,
@@ -536,6 +550,14 @@ const GALA_ERROR_CATALOG = {
536
550
  template: "The lock name must be a string (got a {valueType}).",
537
551
  params: { valueType: "string" }
538
552
  },
553
+ INVALID_NFT_INPUT: {
554
+ phase: "pre_send",
555
+ template: "Invalid NFT input {field}: {reason}.",
556
+ params: {
557
+ field: "string",
558
+ reason: INVALID_NFT_INPUT_REASONS
559
+ }
560
+ },
539
561
  NO_TOKEN_NAME_RESOLVER: {
540
562
  phase: "pre_send",
541
563
  template: "The token name \"{tokenName}\" cannot be resolved: no tokenNameResolver is configured. Pass its tokenClassKey instead.",
@@ -887,6 +909,7 @@ const GALA_ERROR_PHASE_BY_CODE = {
887
909
  INVALID_TOKEN_BATCH: "pre_send",
888
910
  INVALID_LOCK_EXPIRES: "pre_send",
889
911
  INVALID_LOCK_NAME: "pre_send",
912
+ INVALID_NFT_INPUT: "pre_send",
890
913
  NO_TOKEN_NAME_RESOLVER: "pre_send",
891
914
  TOKEN_NAME_RESOLUTION_FAILED: "pre_send",
892
915
  GATEWAY_WRITE_OUTCOME_UNKNOWN: "in_flight",
@@ -970,12 +993,12 @@ const GALA_ERROR_PHASES = [
970
993
  * recognise each other's errors, which `instanceof` cannot do.
971
994
  */
972
995
  const GALA_ERROR_BRAND = Symbol.for("@gala-chain/gala-core-sdk/error");
973
- function isRecord$5(value) {
996
+ function isRecord$7(value) {
974
997
  return typeof value === "object" && value !== null;
975
998
  }
976
999
  /** True when `value` carries the SDK error brand (a real `GalaSDKError`, from any copy of the SDK). */
977
1000
  function hasGalaErrorBrand(value) {
978
- return isRecord$5(value) && value[GALA_ERROR_BRAND] === true;
1001
+ return isRecord$7(value) && value[GALA_ERROR_BRAND] === true;
979
1002
  }
980
1003
  /**
981
1004
  * True when `value` is an SDK error (it carries the brand) or a plain-object VIEW of one: a string
@@ -991,7 +1014,7 @@ function hasGalaErrorBrand(value) {
991
1014
  */
992
1015
  function isGalaErrorLike(value) {
993
1016
  if (hasGalaErrorBrand(value)) return true;
994
- return isRecord$5(value) && typeof value["code"] === "string" && isRecord$5(value["params"]) && !Array.isArray(value["params"]);
1017
+ return isRecord$7(value) && typeof value["code"] === "string" && isRecord$7(value["params"]) && !Array.isArray(value["params"]);
995
1018
  }
996
1019
 
997
1020
  //#endregion
@@ -1194,6 +1217,15 @@ const CLIENT_ALIAS = /^client\|[A-Za-z0-9_-]+$/u;
1194
1217
  /** `eth|0x...`: not a user reference. An `eth|` reference is followed by the digits alone. */
1195
1218
  const ETH_WITH_0X = /^eth\|0[xX](.*)$/su;
1196
1219
  /**
1220
+ * `value` with the part before its first `|` lower-cased and everything after it exactly as written (a value with no
1221
+ * `|` is returned as is): `Client|X` is the account `client|X`, `ETH|<hex>` is `eth|<hex>`. The scheme is
1222
+ * case-insensitive, an alias id is not (launchpad-sdk's `userRef` follows the same rule).
1223
+ */
1224
+ function lowerScheme(value) {
1225
+ const pipe = value.indexOf("|");
1226
+ return pipe < 0 ? value : `${value.slice(0, pipe).toLowerCase()}${value.slice(pipe)}`;
1227
+ }
1228
+ /**
1197
1229
  * Refuses `eth|0x...` (any digits, any casing of the `0x`) with `INVALID_ETH_USER_REF_PREFIX`,
1198
1230
  * naming the correct spelling. `eth|0x...` is not an address form: GalaChain's `eth|` reference is
1199
1231
  * followed by the 40 hex digits only. A bare `0x<40 hex>` is a different, normal thing (an
@@ -1205,7 +1237,7 @@ const ETH_WITH_0X = /^eth\|0[xX](.*)$/su;
1205
1237
  function assertNoEthZeroXPrefix(value, field) {
1206
1238
  var _ETH_WITH_0X$exec;
1207
1239
  if (typeof value !== "string") return;
1208
- const rest = (_ETH_WITH_0X$exec = ETH_WITH_0X.exec(value)) === null || _ETH_WITH_0X$exec === void 0 ? void 0 : _ETH_WITH_0X$exec[1];
1240
+ const rest = (_ETH_WITH_0X$exec = ETH_WITH_0X.exec(lowerScheme(value))) === null || _ETH_WITH_0X$exec === void 0 ? void 0 : _ETH_WITH_0X$exec[1];
1209
1241
  if (rest === void 0) return;
1210
1242
  const checksummed = /^[0-9a-fA-F]{40}$/u.test(rest) ? checksumEthereumAddress(rest) : void 0;
1211
1243
  throw new GalaSDKError("INVALID_ETH_USER_REF_PREFIX", {
@@ -1227,7 +1259,9 @@ function assertNoEthZeroXPrefix(value, field) {
1227
1259
  * - `eth|0x<hex>` is NOT an address form: an `eth|` reference is followed by the digits alone.
1228
1260
  * It is refused before anything is signed or sent (see {@link assertNoEthZeroXPrefix}). A bare
1229
1261
  * `0x<40 hex>` is an ordinary Ethereum address and is converted to `eth|<EIP-55 digits>`.
1230
- * - `client|<id>` (`A-Za-z0-9_-`): a GalaChain alias, kept exactly as written.
1262
+ * - `client|<id>` (`A-Za-z0-9_-`): a GalaChain alias, kept exactly as written after the scheme.
1263
+ * - The scheme (before the first `|`) is accepted in any case and sent lower case (`Client|X` -> `client|X`,
1264
+ * `ETH|<hex>` -> `eth|<hex>`); everything after the `|` keeps its case.
1231
1265
  *
1232
1266
  * Anything else is refused before anything is signed or sent (fail closed): an unknown spelling
1233
1267
  * could name an account nobody holds.
@@ -1239,8 +1273,9 @@ function galaChainUserRef(value, field) {
1239
1273
  assertNoEthZeroXPrefix(value, field);
1240
1274
  if (typeof value === "string") {
1241
1275
  var _ACCOUNT$exec;
1242
- if (CLIENT_ALIAS.test(value)) return value;
1243
- const digits = (_ACCOUNT$exec = ACCOUNT.exec(value)) === null || _ACCOUNT$exec === void 0 ? void 0 : _ACCOUNT$exec[1];
1276
+ const spelled = lowerScheme(value);
1277
+ if (CLIENT_ALIAS.test(spelled)) return spelled;
1278
+ const digits = (_ACCOUNT$exec = ACCOUNT.exec(spelled)) === null || _ACCOUNT$exec === void 0 ? void 0 : _ACCOUNT$exec[1];
1244
1279
  const account = digits === void 0 ? void 0 : checksumEthereumAddress(digits);
1245
1280
  if (account !== void 0) return `eth|${account.slice(2)}`;
1246
1281
  }
@@ -2543,8 +2578,8 @@ async function signTypedDataPayload(privateKey, payload) {
2543
2578
  * `dtoOperationMap` (the `dtoOperation` / API path table of the GalaChain platform team,
2544
2579
  * 2026-10-27). The chain refuses a signed DTO whose `dtoOperation` is not exactly the operation it
2545
2580
  * is called through ("The dto was signed to call X operation, but the current operation is Y"), so
2546
- * the URL a write is POSTed to and the `dtoOperation` it carries both come from this one table and
2547
- * can never disagree.
2581
+ * the URL a write is POSTed to and the `dtoOperation` it carries both come from this one table
2582
+ * (the platform's rows, plus the chain's own deviations in `CHAIN_METHOD_OPERATIONS`).
2548
2583
  *
2549
2584
  * `dtoOperation` is a SIGNED field: it is part of the DTO before the signer sees it, never added by
2550
2585
  * a signer or after the signature.
@@ -2614,7 +2649,30 @@ const CHAIN_CONTRACT_OPERATION_PREFIXES = {
2614
2649
  "vox/resources-contract": "vox_vox_VOXResourceToken"
2615
2650
  };
2616
2651
  /**
2617
- * The `dtoOperation` of `method` on the contract served at `contractPath`.
2652
+ * Where the chain enforces an operation other than the platform table's, keyed `<contract path>:<method>`. The ONE
2653
+ * place such a deviation lives: every consumer (core's bridge-out signing, the wrap flow, Connect, the product SDKs)
2654
+ * asks `dtoOperationOf`, so nobody hard-codes the exception.
2655
+ *
2656
+ * - `RequestTokenBridgeOut`: the table maps `asset/bridge-contract` to bridge-chaincode, but a RequestTokenBridgeOut
2657
+ * is a TOKEN contract call. Verified on stage (2026-11-02): signed under
2658
+ * `asset-channel_bridge-chaincode_BridgeContract:RequestTokenBridgeOut` the chain answers "signed to call ...
2659
+ * BridgeContract:RequestTokenBridgeOut, but the current operation is
2660
+ * asset-channel_basic-asset_GalaChainToken:RequestTokenBridgeOut", and it accepts the token contract's.
2661
+ * - `GrantAllowance`: the grants embedded in a `BridgeTokenOut` are signed as
2662
+ * `asset-channel_bridge-chaincode_GalaChainToken:GrantAllowance`, which the table has no row for. Observed in
2663
+ * GalaConnect-signed stage traffic; this SDK does not sign it and it was not re-verified against the chain.
2664
+ *
2665
+ * `asset/bridge-contract:BridgeTokenOut` is NOT here: the table's `BridgeContract:BridgeTokenOut` is what was seen
2666
+ * live on stage for the external-chain bridge (GalaConnect-signed). The token contracts' own `BridgeTokenOut`
2667
+ * (`asset/token-contract`, `music/token-contract`, the channel move) is their plain prefix.
2668
+ */
2669
+ const CHAIN_METHOD_OPERATIONS = {
2670
+ "asset/bridge-contract:RequestTokenBridgeOut": "asset-channel_basic-asset_GalaChainToken:RequestTokenBridgeOut",
2671
+ "asset/bridge-contract:GrantAllowance": "asset-channel_bridge-chaincode_GalaChainToken:GrantAllowance"
2672
+ };
2673
+ /**
2674
+ * The `dtoOperation` of `method` on the contract served at `contractPath`: the chain's own
2675
+ * (`CHAIN_METHOD_OPERATIONS`) where it deviates from the platform table, else the table's prefix plus `:<method>`.
2618
2676
  *
2619
2677
  * `ChainContractPath` is only a type: a plain-JS caller, or a path built at runtime
2620
2678
  * (`${channel}/${contract}`), can name a contract the table does not have. That is refused here, before
@@ -2624,6 +2682,8 @@ const CHAIN_CONTRACT_OPERATION_PREFIXES = {
2624
2682
  * @throws GalaSDKError SIGNING_FAILED when `contractPath` is not in the table.
2625
2683
  */
2626
2684
  function dtoOperationOf(contractPath, method) {
2685
+ const methodKey = `${contractPath}:${method}`;
2686
+ if (Object.prototype.hasOwnProperty.call(CHAIN_METHOD_OPERATIONS, methodKey)) return CHAIN_METHOD_OPERATIONS[methodKey];
2627
2687
  const prefix = Object.prototype.hasOwnProperty.call(CHAIN_CONTRACT_OPERATION_PREFIXES, contractPath) ? CHAIN_CONTRACT_OPERATION_PREFIXES[contractPath] : void 0;
2628
2688
  if (prefix === void 0) throw new GalaSDKError("SIGNING_FAILED", {
2629
2689
  method,
@@ -2700,12 +2760,12 @@ const TEXT_KEYS = [
2700
2760
  ];
2701
2761
  /** Wallet errors nest their text at most a level or two deep; the bound also stops a cyclic object. */
2702
2762
  const MAX_TEXT_DEPTH = 3;
2703
- function isRecord$4(value) {
2763
+ function isRecord$6(value) {
2704
2764
  return typeof value === "object" && value !== null;
2705
2765
  }
2706
2766
  function textsOf(value, depth = 0) {
2707
2767
  if (typeof value === "string") return [value];
2708
- if (!isRecord$4(value) || depth >= MAX_TEXT_DEPTH) return [];
2768
+ if (!isRecord$6(value) || depth >= MAX_TEXT_DEPTH) return [];
2709
2769
  return TEXT_KEYS.flatMap((key) => textsOf(value[key], depth + 1));
2710
2770
  }
2711
2771
  function wordsADecline(text) {
@@ -2748,7 +2808,7 @@ function isWalletUserRejection(value) {
2748
2808
  if (value.code === "SIGNING_FAILED") return value.params["reason"] === "user_rejected";
2749
2809
  return !hasGalaErrorBrand(value) && REJECTION_CODES.includes(value.code);
2750
2810
  }
2751
- if (isRecord$4(value)) {
2811
+ if (isRecord$6(value)) {
2752
2812
  if (REJECTION_CODES.includes(value["code"]) || value["name"] === REJECTION_NAME) return true;
2753
2813
  }
2754
2814
  return textsOf(value).some(wordsADecline);
@@ -2840,7 +2900,7 @@ async function signPreSendFor(signer, contractPath, method, dto) {
2840
2900
  * fallback. It is the version in the default `User-Agent` (`GalaChain-SDK/<version>`) of every SDK
2841
2901
  * request, whichever product SDK sends it.
2842
2902
  */
2843
- const GALA_CORE_SDK_VERSION = "1.1.0-beta.9";
2903
+ const GALA_CORE_SDK_VERSION = "1.2.0-beta.2";
2844
2904
 
2845
2905
  //#endregion
2846
2906
  //#region src/utils/transport.ts
@@ -2901,7 +2961,7 @@ function buildRequestHeaders(wire, parts = {}) {
2901
2961
  entries.set(name.toLowerCase(), [name, value]);
2902
2962
  }
2903
2963
  };
2904
- if ((wire === null || wire === void 0 ? void 0 : wire.userAgent) !== false) put({ "User-Agent": (wire === null || wire === void 0 ? void 0 : wire.userAgent) ?? `GalaChain-SDK/${"1.1.0-beta.9"}` });
2964
+ if ((wire === null || wire === void 0 ? void 0 : wire.userAgent) !== false) put({ "User-Agent": (wire === null || wire === void 0 ? void 0 : wire.userAgent) ?? `GalaChain-SDK/${"1.2.0-beta.2"}` });
2905
2965
  put(parts.defaults);
2906
2966
  put(wire === null || wire === void 0 ? void 0 : wire.headers);
2907
2967
  if (parts.json === true && !entries.has("content-type")) put({ "Content-Type": "application/json" });
@@ -3004,7 +3064,7 @@ function hasHeaderGetter(headers) {
3004
3064
 
3005
3065
  //#endregion
3006
3066
  //#region src/utils/axios_requestor.ts
3007
- function isRecord$3(value) {
3067
+ function isRecord$5(value) {
3008
3068
  return typeof value === "object" && value !== null && !Array.isArray(value);
3009
3069
  }
3010
3070
  /**
@@ -3012,10 +3072,10 @@ function isRecord$3(value) {
3012
3072
  * for ECONNREFUSED). That is a transport failure, not an HTTP answer.
3013
3073
  */
3014
3074
  function isAxiosLikeResponse(value) {
3015
- return isRecord$3(value) && typeof value["status"] === "number";
3075
+ return isRecord$5(value) && typeof value["status"] === "number";
3016
3076
  }
3017
3077
  function readAxiosHeader(headers, name) {
3018
- if (!isRecord$3(headers)) return null;
3078
+ if (!isRecord$5(headers)) return null;
3019
3079
  const getter = headers["get"];
3020
3080
  if (typeof getter === "function") {
3021
3081
  const value = getter.call(headers, name);
@@ -3096,16 +3156,16 @@ function httpRequestorFromAxios(instance, options) {
3096
3156
  */
3097
3157
  function isTransportRejection(error, rejectOnHttpError) {
3098
3158
  if (!rejectOnHttpError) return true;
3099
- return isRecord$3(error) && error["isAxiosError"] === true && error["response"] === void 0;
3159
+ return isRecord$5(error) && error["isAxiosError"] === true && error["response"] === void 0;
3100
3160
  }
3101
3161
 
3102
3162
  //#endregion
3103
3163
  //#region src/utils/ethers_provider.ts
3104
- function isRecord$2(value) {
3164
+ function isRecord$4(value) {
3105
3165
  return typeof value === "object" && value !== null && !Array.isArray(value);
3106
3166
  }
3107
3167
  function isTypedDataTypes(value) {
3108
- return isRecord$2(value) && Object.values(value).every((fields) => Array.isArray(fields) && fields.every((field) => isRecord$2(field) && typeof field["name"] === "string" && typeof field["type"] === "string"));
3168
+ return isRecord$4(value) && Object.values(value).every((fields) => Array.isArray(fields) && fields.every((field) => isRecord$4(field) && typeof field["name"] === "string" && typeof field["type"] === "string"));
3109
3169
  }
3110
3170
  function malformed(method) {
3111
3171
  return new GalaSDKError("MALFORMED_WALLET_REQUEST", { method });
@@ -3119,9 +3179,9 @@ function readTypedDataRequest(params) {
3119
3179
  } catch {
3120
3180
  throw malformed("eth_signTypedData_v4");
3121
3181
  }
3122
- if (!isRecord$2(payload)) throw malformed("eth_signTypedData_v4");
3182
+ if (!isRecord$4(payload)) throw malformed("eth_signTypedData_v4");
3123
3183
  const { domain, types, message } = payload;
3124
- if (!isRecord$2(domain) || !isTypedDataTypes(types) || !isRecord$2(message)) throw malformed("eth_signTypedData_v4");
3184
+ if (!isRecord$4(domain) || !isTypedDataTypes(types) || !isRecord$4(message)) throw malformed("eth_signTypedData_v4");
3125
3185
  return {
3126
3186
  domain,
3127
3187
  types: stripEip712DomainType(types),
@@ -3250,7 +3310,7 @@ const FAILURE_OUTCOMES = [
3250
3310
 
3251
3311
  //#endregion
3252
3312
  //#region src/utils/failure_view.ts
3253
- function isRecord$1(value) {
3313
+ function isRecord$3(value) {
3254
3314
  return typeof value === "object" && value !== null;
3255
3315
  }
3256
3316
  /**
@@ -3268,12 +3328,12 @@ function isRecord$1(value) {
3268
3328
  * ```
3269
3329
  */
3270
3330
  function toFailureView(value) {
3271
- if (!isRecord$1(value)) return void 0;
3331
+ if (!isRecord$3(value)) return void 0;
3272
3332
  const { code, params, status, phase, uniqueKey, write, outcome, retryable, shadow, notFound } = value;
3273
3333
  if (typeof code !== "string" || code === "") return void 0;
3274
3334
  return {
3275
3335
  code,
3276
- params: isRecord$1(params) && !Array.isArray(params) ? params : void 0,
3336
+ params: isRecord$3(params) && !Array.isArray(params) ? params : void 0,
3277
3337
  status: typeof status === "number" && Number.isFinite(status) ? status : void 0,
3278
3338
  phase: GALA_ERROR_PHASES.find((known) => known === phase),
3279
3339
  uniqueKey: typeof uniqueKey === "string" && uniqueKey !== "" ? uniqueKey : void 0,
@@ -3734,10 +3794,315 @@ function unlockTokenDto(owner, tokens, uniqueKey, name) {
3734
3794
  };
3735
3795
  }
3736
3796
 
3797
+ //#endregion
3798
+ //#region src/writes/nft.ts
3799
+ /**
3800
+ * The NFT methods of GalaChain's token contract that `GatewayWrites` signs and submits, as a closed
3801
+ * set: claim a collection name (`GrantNftCollectionAuthorization`), create the NFT collection's
3802
+ * token class (`CreateNftCollection`), mint NFTs, granting the minter its own mint allowance in
3803
+ * the same transaction (`MintTokenWithAllowance`) or against an allowance it already holds
3804
+ * (`MintToken`).
3805
+ */
3806
+ const NFT_WRITE_METHODS = [
3807
+ "GrantNftCollectionAuthorization",
3808
+ "CreateNftCollection",
3809
+ "MintTokenWithAllowance",
3810
+ "MintToken"
3811
+ ];
3812
+ /** The most NFTs one mint may create (the chain's `MintTokenDto.MAX_NFT_MINT_SIZE`). */
3813
+ const NFT_MINT_LIMIT = 1e3;
3814
+ /** The `additionalKey` an NFT token class carries when its creator names none (GalaChain's `none`). */
3815
+ const NFT_DEFAULT_ADDITIONAL_KEY = "none";
3816
+ function refuse(field, reason) {
3817
+ return new GalaSDKError("INVALID_NFT_INPUT", {
3818
+ field,
3819
+ reason
3820
+ });
3821
+ }
3822
+ /** True when `value` holds an ASCII or C1 control character (the NUL of chain composite keys among them). */
3823
+ function hasControlCharacter(value) {
3824
+ for (let index = 0; index < value.length; index += 1) {
3825
+ const code = value.charCodeAt(index);
3826
+ if (code <= 31 || code >= 127 && code <= 159) return true;
3827
+ }
3828
+ return false;
3829
+ }
3830
+ /**
3831
+ * One part of a token class key (collection, category, type, additionalKey): a non-empty string
3832
+ * with no control character (the chain's composite keys are NUL-separated), no `|` (the key's own
3833
+ * separator) and no surrounding whitespace. Returned exactly as written, never trimmed.
3834
+ *
3835
+ * @throws GalaSDKError `INVALID_NFT_INPUT`.
3836
+ */
3837
+ function nftClassPart(value, field) {
3838
+ if (typeof value !== "string") throw refuse(field, "not_a_string");
3839
+ if (value.trim() === "") throw refuse(field, "empty");
3840
+ if (value.trim() !== value || value.includes("|") || hasControlCharacter(value)) throw refuse(field, "bad_characters");
3841
+ return value;
3842
+ }
3843
+ /** A non-empty free-text field (name, description, image, ...), exactly as written. */
3844
+ function nftText(value, field) {
3845
+ if (typeof value !== "string") throw refuse(field, "not_a_string");
3846
+ if (value.trim() === "") throw refuse(field, "empty");
3847
+ return value;
3848
+ }
3849
+ /** A string that may be empty (the symbol). */
3850
+ function nftString(value, field) {
3851
+ if (typeof value !== "string") throw refuse(field, "not_a_string");
3852
+ return value;
3853
+ }
3854
+ const WHOLE_NUMBER = /^[1-9][0-9]{0,37}$/u;
3855
+ /**
3856
+ * A positive whole number written as a decimal string (no sign, fraction, exponent, separators or
3857
+ * leading zero), returned as written. A JS number is refused: the chain receives strings.
3858
+ */
3859
+ function nftWholeNumber(value, field) {
3860
+ if (typeof value !== "string" || !WHOLE_NUMBER.test(value)) throw refuse(field, "not_a_positive_whole_number");
3861
+ return value;
3862
+ }
3863
+ /** The quantity of a mint: a positive whole number of at most {@link NFT_MINT_LIMIT}. */
3864
+ function nftMintQuantity(value, field) {
3865
+ const quantity = nftWholeNumber(value, field);
3866
+ if (new BigNumber(quantity).isGreaterThan(1e3)) throw refuse(field, "above_mint_limit");
3867
+ return quantity;
3868
+ }
3869
+ /** The token class a write names, every part checked; `additionalKey` defaults to `none`. */
3870
+ function nftTokenClass(input) {
3871
+ return {
3872
+ collection: nftClassPart(input.collection, "collection"),
3873
+ category: nftClassPart(input.category, "category"),
3874
+ type: nftClassPart(input.type, "type"),
3875
+ additionalKey: nftClassPart(input.additionalKey ?? "none", "additionalKey")
3876
+ };
3877
+ }
3878
+ /** The authorities of a create: one or more user references, each in its one gateway spelling. */
3879
+ function nftAuthorities(value) {
3880
+ if (!Array.isArray(value) || value.length === 0) throw refuse("authorities", "bad_authorities");
3881
+ return value.map((authority, index) => galaChainUserRef(authority, `authorities[${index}]`));
3882
+ }
3883
+ const PUBLIC_KEY = /^(?:0x)?(?:(?:02|03)[0-9a-fA-F]{64}|04[0-9a-fA-F]{128})$/u;
3884
+ /**
3885
+ * The public key a DryRun simulates the caller as: a secp256k1 key in hex, compressed (33 bytes) or
3886
+ * uncompressed (65 bytes), with or without `0x`. The chain refuses a DryRun that names no caller.
3887
+ */
3888
+ function nftCallerPublicKey(value) {
3889
+ if (typeof value !== "string" || !PUBLIC_KEY.test(value)) throw refuse("callerPublicKey", "bad_public_key");
3890
+ return value;
3891
+ }
3892
+ /** The unsigned `GrantNftCollectionAuthorization` DTO. */
3893
+ function claimNftCollectionDto(collection, authorizedUser, uniqueKey) {
3894
+ return {
3895
+ collection,
3896
+ authorizedUser,
3897
+ uniqueKey
3898
+ };
3899
+ }
3900
+ /** The unsigned `CreateNftCollection` DTO: the fields the caller gave, none the caller left out. */
3901
+ function createNftCollectionDto(tokenClass, fields, uniqueKey) {
3902
+ return {
3903
+ ...tokenClass,
3904
+ name: fields.name,
3905
+ symbol: fields.symbol,
3906
+ description: fields.description,
3907
+ image: fields.image,
3908
+ maxSupply: fields.maxSupply,
3909
+ ...fields.maxCapacity === void 0 ? {} : { maxCapacity: fields.maxCapacity },
3910
+ ...fields.metadataAddress === void 0 ? {} : { metadataAddress: fields.metadataAddress },
3911
+ ...fields.contractAddress === void 0 ? {} : { contractAddress: fields.contractAddress },
3912
+ ...fields.rarity === void 0 ? {} : { rarity: fields.rarity },
3913
+ ...fields.authorities === void 0 ? {} : { authorities: [...fields.authorities] },
3914
+ uniqueKey
3915
+ };
3916
+ }
3917
+ /**
3918
+ * The unsigned mint DTO. `MintTokenWithAllowance` names instance `"0"` (the allowance it grants
3919
+ * itself covers the class's mint, not one NFT); `MintToken` carries no instance.
3920
+ */
3921
+ function mintNftDto(method, tokenClass, owner, quantity, uniqueKey) {
3922
+ return {
3923
+ tokenClass,
3924
+ owner,
3925
+ ...method === "MintTokenWithAllowance" ? { tokenInstance: "0" } : {},
3926
+ quantity,
3927
+ uniqueKey
3928
+ };
3929
+ }
3930
+ function isRecord$2(value) {
3931
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3932
+ }
3933
+ /** The error for a write GalaChain accepted whose answer does not say what the write did. */
3934
+ function unreadable(method, uniqueKey, body) {
3935
+ return new GalaSDKError("GATEWAY_RESPONSE_INVALID", { method }, {
3936
+ body,
3937
+ uniqueKey
3938
+ });
3939
+ }
3940
+ function sameClass(value, tokenClass) {
3941
+ return value["collection"] === tokenClass.collection && value["category"] === tokenClass.category && value["type"] === tokenClass.type && value["additionalKey"] === tokenClass.additionalKey;
3942
+ }
3943
+ /**
3944
+ * The collection and authorized users a claim answered. Fails closed: an answer for another
3945
+ * collection, or one that authorizes nobody, is not the claim that was sent.
3946
+ */
3947
+ function claimedCollection(receipt, collection) {
3948
+ const data = receipt.data;
3949
+ const users = isRecord$2(data) ? data["authorizedUsers"] : void 0;
3950
+ if (!isRecord$2(data) || data["collection"] !== collection || !Array.isArray(users) || users.length === 0 || !users.every((user) => typeof user === "string")) throw unreadable(receipt.method, receipt.uniqueKey, receipt.body);
3951
+ return {
3952
+ ...receipt,
3953
+ collection,
3954
+ authorizedUsers: users
3955
+ };
3956
+ }
3957
+ /** The token class a create answered; an answer naming another class is not the create that was sent. */
3958
+ function createdTokenClass(receipt, tokenClass) {
3959
+ const data = receipt.data;
3960
+ if (!isRecord$2(data) || !sameClass(data, tokenClass)) throw unreadable(receipt.method, receipt.uniqueKey, receipt.body);
3961
+ return {
3962
+ ...receipt,
3963
+ tokenClass: { ...tokenClass }
3964
+ };
3965
+ }
3966
+ const INSTANCE_ID = /^[0-9]+$/u;
3967
+ /**
3968
+ * The NFT instances a mint answered, never synthesized: as many as were asked for, each of the
3969
+ * class that was named, each with a whole-number instance, none twice.
3970
+ */
3971
+ function mintedInstances(receipt, tokenClass, quantity) {
3972
+ const data = receipt.data;
3973
+ const instances = [];
3974
+ if (Array.isArray(data)) for (const item of data) {
3975
+ const instance = isRecord$2(item) ? item["instance"] : void 0;
3976
+ if (!isRecord$2(item) || !sameClass(item, tokenClass) || typeof instance !== "string") break;
3977
+ if (!INSTANCE_ID.test(instance)) break;
3978
+ instances.push({
3979
+ ...tokenClass,
3980
+ instance
3981
+ });
3982
+ }
3983
+ if (!Array.isArray(data) || instances.length !== data.length || instances.length !== Number(quantity) || new Set(instances.map((key) => key.instance)).size !== instances.length) throw unreadable(receipt.method, receipt.uniqueKey, receipt.body);
3984
+ return {
3985
+ ...receipt,
3986
+ tokenInstances: instances
3987
+ };
3988
+ }
3989
+
3990
+ //#endregion
3991
+ //#region src/reads/request.ts
3992
+ /** The chaincode contract each read method belongs to (part of its URL). */
3993
+ const CONTRACT_OF = {
3994
+ FetchBalances: "token-contract",
3995
+ FetchTokenClasses: "token-contract",
3996
+ FetchTokenClassesWithSupply: "token-contract",
3997
+ FetchTokenClassesWithPagination: "token-contract",
3998
+ FetchNftCollectionAuthorizationsWithPagination: "token-contract",
3999
+ GetPublicKey: "public-key-contract"
4000
+ };
4001
+ /**
4002
+ * Methods whose successful answer carries no `Status`: the connect-api GalaChain proxies answer
4003
+ * `GetPublicKey` with `{ Data: { publicKey } }` only (recorded 2026-10-14, prod and stage,
4004
+ * `tests/fixtures/public-key-recorded.json`). A `Status` they do send is still checked.
4005
+ */
4006
+ const ANSWERED_WITHOUT_STATUS = /* @__PURE__ */ new Set(["GetPublicKey"]);
4007
+ /**
4008
+ * The channel of a collection: `$MUSIC` (and `MUSIC`, any case) lives on the gateway's `music`
4009
+ * channel, every other collection (`$GMUSIC` included) on `asset`.
4010
+ */
4011
+ function channelOf(collection) {
4012
+ return collection !== void 0 && /^\$?music$/iu.test(collection) ? "music" : "asset";
4013
+ }
4014
+ function isRecord$1(value) {
4015
+ return typeof value === "object" && value !== null && !Array.isArray(value);
4016
+ }
4017
+ function stringField$2(record, key) {
4018
+ const value = record === null || record === void 0 ? void 0 : record[key];
4019
+ return typeof value === "string" ? value : "";
4020
+ }
4021
+ /**
4022
+ * The chain's error object of a refused answer: GalaChain's gateway nests it as
4023
+ * `{ error: { Status: 0, ErrorKey, Message, ErrorPayload }, message }`; an older answer carries
4024
+ * `Status` / `ErrorKey` / `Message` at the top.
4025
+ */
4026
+ function chainErrorOf(body) {
4027
+ if (!isRecord$1(body)) return void 0;
4028
+ const nested = body["error"];
4029
+ return isRecord$1(nested) ? nested : body;
4030
+ }
4031
+ /**
4032
+ * POSTs one read and returns the chain's `Data`. Reads change nothing, so every failure is a READ's
4033
+ * (`error.write === false`) and a retry is always safe:
4034
+ *
4035
+ * - no answer: `REQUEST_TIMEOUT` / `TRANSPORT_ERROR`, both `write: false` (an app requestor's
4036
+ * own rejection passes through unchanged: it is the app's error); a body that broke off is
4037
+ * `TRANSPORT_ERROR`;
4038
+ * - a numeric top-level `Status` other than 1, in any HTTP status: `GATEWAY_READ_REJECTED`;
4039
+ * - any other non-2xx: `GATEWAY_HTTP_ERROR` (`params.status`; the chain's refusal is `error.body`);
4040
+ * - a 2xx that is not `{ Status: 1, Data }` (for `GetPublicKey`, whose answer carries no
4041
+ * `Status`, not `{ Data }`): `GATEWAY_READ_RESPONSE_INVALID`.
4042
+ */
4043
+ async function readGateway(transport, method, body, channel = "asset") {
4044
+ const url = `${transport.gatewayBaseUrl}/api/${channel}/${CONTRACT_OF[method]}/${method}`;
4045
+ const response = await requestWithTimeout(transport.requestor, url, {
4046
+ method: "POST",
4047
+ headers: buildRequestHeaders(transport.wire, { json: true }),
4048
+ body: JSON.stringify(body)
4049
+ }, transport.timeoutMs, { write: false });
4050
+ let answer;
4051
+ try {
4052
+ answer = await readResponseBody(response);
4053
+ } catch (cause) {
4054
+ throw new GalaSDKError("TRANSPORT_ERROR", { url }, {
4055
+ url,
4056
+ cause,
4057
+ write: false
4058
+ });
4059
+ }
4060
+ return dataOf(method, url, response, answer);
4061
+ }
4062
+ /**
4063
+ * The chain's `Data` of a read-like answer, or the error for one that is not (see
4064
+ * {@link readGateway} for the codes). Also the reading of a signed DryRun answer, which changes
4065
+ * nothing either, so it names its own `method` (a string, not a read method).
4066
+ */
4067
+ function dataOf(method, url, response, answer) {
4068
+ const context = {
4069
+ status: response.status,
4070
+ body: answer,
4071
+ url,
4072
+ write: false
4073
+ };
4074
+ const envelope = isRecord$1(answer) ? answer : void 0;
4075
+ const chainStatus = envelope === null || envelope === void 0 ? void 0 : envelope["Status"];
4076
+ if (typeof chainStatus === "number" && chainStatus !== 1) throw new GalaSDKError("GATEWAY_READ_REJECTED", {
4077
+ method,
4078
+ chainStatus,
4079
+ errorKey: stringField$2(envelope, "ErrorKey"),
4080
+ serverMessage: stringField$2(envelope, "Message")
4081
+ }, context);
4082
+ if (!response.ok) {
4083
+ const chainError = chainErrorOf(answer);
4084
+ throw new GalaSDKError("GATEWAY_HTTP_ERROR", {
4085
+ method,
4086
+ status: response.status,
4087
+ serverMessage: stringField$2(chainError, "Message") || stringField$2(envelope, "message")
4088
+ }, context);
4089
+ }
4090
+ const statusAccepted = chainStatus === 1 || chainStatus === void 0 && ANSWERED_WITHOUT_STATUS.has(method);
4091
+ if (envelope === void 0 || !statusAccepted || !("Data" in envelope)) throw new GalaSDKError("GATEWAY_READ_RESPONSE_INVALID", { method }, context);
4092
+ return envelope["Data"];
4093
+ }
4094
+ /** The error for a 2xx whose `Data` is not what `method` answers. */
4095
+ function invalidAnswer(method, data) {
4096
+ return new GalaSDKError("GATEWAY_READ_RESPONSE_INVALID", { method }, {
4097
+ body: data,
4098
+ write: false
4099
+ });
4100
+ }
4101
+
3737
4102
  //#endregion
3738
4103
  //#region src/writes/submit.ts
3739
4104
  /** The contract every write of this module is sent to (its URL path and its `dtoOperation`). */
3740
- const TOKEN_CONTRACT = "asset/token-contract";
4105
+ const TOKEN_CONTRACT$1 = "asset/token-contract";
3741
4106
  /**
3742
4107
  * The fields a signer may add next to the DTO: the signature and, for the wallet schemes, the
3743
4108
  * personal-sign `prefix` and the EIP-712 `types` / `domain`. Nothing else: a signer that inserts a
@@ -3767,9 +4132,9 @@ function carriesExactlyTheDto(builtDto, signed) {
3767
4132
  * `SIGNING_FAILED` (pre-send: nothing was transmitted, a retry is safe).
3768
4133
  */
3769
4134
  async function signedPayload(signer, method, dto) {
3770
- const operated = withDtoOperation(TOKEN_CONTRACT, method, dto);
4135
+ const operated = withDtoOperation(TOKEN_CONTRACT$1, method, dto);
3771
4136
  const builtDto = serialize(operated);
3772
- const signed = await signPreSendFor(signer, TOKEN_CONTRACT, method, operated);
4137
+ const signed = await signPreSendFor(signer, TOKEN_CONTRACT$1, method, operated);
3773
4138
  let payload;
3774
4139
  try {
3775
4140
  payload = carriesExactlyTheDto(builtDto, signed) ? JSON.stringify(signed) : void 0;
@@ -3851,11 +4216,13 @@ function receiptOf(method, uniqueKey, url, response, body) {
3851
4216
  };
3852
4217
  const envelope = typeof body === "object" && body !== null && !Array.isArray(body) ? body : void 0;
3853
4218
  const chainStatus = envelope === null || envelope === void 0 ? void 0 : envelope["Status"];
3854
- if (typeof chainStatus === "number" && chainStatus !== 1) throw new GalaSDKError("GATEWAY_WRITE_REJECTED", {
4219
+ const refusal = chainErrorOf(body);
4220
+ const refusalStatus = refusal === null || refusal === void 0 ? void 0 : refusal["Status"];
4221
+ if (typeof refusalStatus === "number" && refusalStatus !== 1) throw new GalaSDKError("GATEWAY_WRITE_REJECTED", {
3855
4222
  method,
3856
- chainStatus,
3857
- errorKey: stringField$1(envelope, "ErrorKey"),
3858
- serverMessage: stringField$1(envelope, "Message")
4223
+ chainStatus: refusalStatus,
4224
+ errorKey: stringField$1(refusal, "ErrorKey"),
4225
+ serverMessage: stringField$1(refusal, "Message")
3859
4226
  }, context);
3860
4227
  if (!response.ok) throw new GalaSDKError("GATEWAY_HTTP_ERROR", {
3861
4228
  method,
@@ -3880,11 +4247,123 @@ function receiptOf(method, uniqueKey, url, response, body) {
3880
4247
  */
3881
4248
  async function submitWrite(transport, method, dto, uniqueKey) {
3882
4249
  const payload = await signedPayload(transport.signer, method, dto);
3883
- const url = `${transport.gatewayBaseUrl}/api/${TOKEN_CONTRACT}/${method}`;
4250
+ const url = `${transport.gatewayBaseUrl}/api/${TOKEN_CONTRACT$1}/${method}`;
3884
4251
  const { response, body } = await post(transport, method, url, payload, uniqueKey);
3885
4252
  return receiptOf(method, uniqueKey, url, response, body);
3886
4253
  }
3887
4254
 
4255
+ //#endregion
4256
+ //#region src/writes/nft_fee.ts
4257
+ /** The contract every NFT write, and the DryRun that prices it, is sent to. */
4258
+ const TOKEN_CONTRACT = "asset/token-contract";
4259
+ /** The key prefix of the chain's fee receipts: the channel's (`GCFR`) and the paying user's (`GCUR`). */
4260
+ const CHANNEL_RECEIPT = "\0GCFR\0";
4261
+ const USER_RECEIPT = "\0GCUR\0";
4262
+ function isRecord(value) {
4263
+ return typeof value === "object" && value !== null && !Array.isArray(value);
4264
+ }
4265
+ function stringField(record, key) {
4266
+ const value = record[key];
4267
+ return typeof value === "string" ? value : "";
4268
+ }
4269
+ /**
4270
+ * Reads a simulated write's fee from its DryRun `Data`. The simulated write must have SUCCEEDED
4271
+ * (`response.Status` 1): a write the chain would refuse still writes its fee receipt in the
4272
+ * simulation, and quoting that as the price of a write that will not happen would be a lie, so a
4273
+ * refusal (`PAYMENT_REQUIRED`, `INSUFFICIENT_MINT_ALLOWANCE`, ...) is `GATEWAY_READ_REJECTED`.
4274
+ *
4275
+ * The fee is what the paying user's receipts (`GCUR`) add up to; the channel receipt (`GCFR`) the
4276
+ * chain writes beside each is the same payment seen from the channel, so it is counted only when
4277
+ * no user receipt exists. No receipt at all is a fee of `"0"`: the write is free.
4278
+ *
4279
+ * @throws GalaSDKError `GATEWAY_READ_REJECTED` (the simulated write failed), `GATEWAY_READ_RESPONSE_INVALID`
4280
+ * (an answer that is not a DryRun result, or a receipt with no readable quantity).
4281
+ */
4282
+ function feeQuoteOf(method, data, context) {
4283
+ const invalid = () => new GalaSDKError("GATEWAY_READ_RESPONSE_INVALID", { method: "DryRun" }, {
4284
+ ...context,
4285
+ body: data
4286
+ });
4287
+ if (!isRecord(data) || !isRecord(data["response"]) || !isRecord(data["writes"])) throw invalid();
4288
+ const response = data["response"];
4289
+ if (response["Status"] !== 1) throw new GalaSDKError("GATEWAY_READ_REJECTED", {
4290
+ method: "DryRun",
4291
+ chainStatus: typeof response["Status"] === "number" ? response["Status"] : 0,
4292
+ errorKey: stringField(response, "ErrorKey"),
4293
+ serverMessage: stringField(response, "Message")
4294
+ }, {
4295
+ ...context,
4296
+ body: response
4297
+ });
4298
+ const user = [];
4299
+ const channel = [];
4300
+ for (const [key, value] of Object.entries(data["writes"])) {
4301
+ const target = key.startsWith(USER_RECEIPT) ? user : key.startsWith(CHANNEL_RECEIPT) ? channel : void 0;
4302
+ if (target === void 0) continue;
4303
+ let receipt;
4304
+ try {
4305
+ receipt = typeof value === "string" ? JSON.parse(value) : void 0;
4306
+ } catch {
4307
+ throw invalid();
4308
+ }
4309
+ const quantity = isRecord(receipt) ? receipt["quantity"] : void 0;
4310
+ const feeCode = isRecord(receipt) ? receipt["feeCode"] : void 0;
4311
+ if (typeof quantity !== "string" || typeof feeCode !== "string") throw invalid();
4312
+ const amount = new BigNumber(quantity);
4313
+ if (!amount.isFinite() || amount.isNegative()) throw invalid();
4314
+ target.push({
4315
+ feeCode,
4316
+ quantity
4317
+ });
4318
+ }
4319
+ const receipts = user.length > 0 ? user : channel;
4320
+ return {
4321
+ method,
4322
+ fee: receipts.reduce((sum, receipt) => sum.plus(receipt.quantity), new BigNumber(0)).toFixed(),
4323
+ feeToken: "GALA",
4324
+ receipts
4325
+ };
4326
+ }
4327
+ /**
4328
+ * Prices `dto` as `method` with the gateway's DryRun: a signed wrapper
4329
+ * `{ callerPublicKey, method, dto, uniqueKey }` (the inner DTO travels unsigned, as an object, with
4330
+ * no `dtoOperation`: a DryRun runs it inside the wrapper, which is what is signed for `DryRun`)
4331
+ * and nothing is written to the chain. A DryRun changes nothing, so every failure of it is a
4332
+ * READ's (`write: false`) and a retry is safe.
4333
+ *
4334
+ * @throws GalaSDKError the signer's pre-send `SIGNING_FAILED`; `REQUEST_TIMEOUT` / `TRANSPORT_ERROR`
4335
+ * (`write: false`); `GATEWAY_HTTP_ERROR`; `GATEWAY_READ_REJECTED`; `GATEWAY_READ_RESPONSE_INVALID`.
4336
+ */
4337
+ async function quoteNftFee(transport, uniqueKeyPrefix, callerPublicKey, method, dto) {
4338
+ const payload = await signedPayload(transport.signer, "DryRun", {
4339
+ callerPublicKey,
4340
+ method,
4341
+ dto,
4342
+ uniqueKey: createUniqueKey(uniqueKeyPrefix)
4343
+ });
4344
+ const url = `${transport.gatewayBaseUrl}/api/${TOKEN_CONTRACT}/DryRun`;
4345
+ const response = await requestWithTimeout(transport.requestor, url, {
4346
+ method: "POST",
4347
+ headers: buildRequestHeaders(transport.wire, { json: true }),
4348
+ body: payload
4349
+ }, transport.timeoutMs, { write: false });
4350
+ let answer;
4351
+ try {
4352
+ answer = await readResponseBody(response);
4353
+ } catch (cause) {
4354
+ throw new GalaSDKError("TRANSPORT_ERROR", { url }, {
4355
+ url,
4356
+ cause,
4357
+ write: false
4358
+ });
4359
+ }
4360
+ return feeQuoteOf(method, dataOf("DryRun", url, response, answer), {
4361
+ status: response.status,
4362
+ url,
4363
+ write: false
4364
+ });
4365
+ }
4366
+
3888
4367
  //#endregion
3889
4368
  //#region src/writes/token_ref.ts
3890
4369
  /** A plain decimal: digits, optionally a fraction. No sign, exponent, hex, spaces or separators. */
@@ -4182,6 +4661,131 @@ var GatewayWrites = class {
4182
4661
  const tokens = await this.resolveAll(checked);
4183
4662
  return this.submit("UnlockToken", unlockTokenDto(this.walletAddress, tokens, uniqueKey, name), uniqueKey);
4184
4663
  }
4664
+ /**
4665
+ * Claim an NFT collection name: authorize `authorizedUser` (default the writer) to create token
4666
+ * classes under it. The chain charges its claim fee (see {@link estimateNftFee}) and refuses a
4667
+ * name that is taken, whatever its casing.
4668
+ *
4669
+ * @throws GalaSDKError pre-send: `INVALID_NFT_INPUT`, `INVALID_WALLET_ADDRESS`,
4670
+ * `INVALID_UNIQUE_KEY`, `SIGNING_FAILED`; in flight: `GATEWAY_WRITE_OUTCOME_UNKNOWN` (check
4671
+ * `error.uniqueKey`; never resend under a fresh key); post-send: `GATEWAY_WRITE_REJECTED`,
4672
+ * `GATEWAY_HTTP_ERROR`, `GATEWAY_RESPONSE_INVALID` (also an answer for another collection).
4673
+ */
4674
+ async claimNftCollection(input) {
4675
+ const prepared = this.prepareClaim(input);
4676
+ const receipt = await submitWrite(this.transport, "GrantNftCollectionAuthorization", prepared.dto, prepared.uniqueKey);
4677
+ return claimedCollection(receipt, prepared.collection);
4678
+ }
4679
+ /**
4680
+ * Create the token class of an NFT collection the writer is authorized for (`CreateNftCollection`).
4681
+ *
4682
+ * @throws GalaSDKError as {@link claimNftCollection}.
4683
+ */
4684
+ async createNftCollection(input) {
4685
+ const prepared = this.prepareCreate(input);
4686
+ const receipt = await submitWrite(this.transport, "CreateNftCollection", prepared.dto, prepared.uniqueKey);
4687
+ return createdTokenClass(receipt, prepared.tokenClass);
4688
+ }
4689
+ /**
4690
+ * Mint 1 to 1000 NFTs of a token class the writer is a token authority of, to `owner` (default
4691
+ * the writer). The receipt lists the instances the chain created, as the chain answered them.
4692
+ *
4693
+ * @throws GalaSDKError as {@link claimNftCollection}.
4694
+ */
4695
+ async mintNft(input) {
4696
+ const prepared = this.prepareMint(input);
4697
+ const receipt = await submitWrite(this.transport, prepared.method, prepared.dto, prepared.uniqueKey);
4698
+ return mintedInstances(receipt, prepared.tokenClass, prepared.quantity);
4699
+ }
4700
+ /**
4701
+ * What GalaChain's DryRun says an NFT write would cost, for the same input the write takes,
4702
+ * checked the same way, and with nothing written to the chain. The fee is the network's own
4703
+ * figure for this environment (it differs between stage and mainnet), never a constant.
4704
+ *
4705
+ * `callerPublicKey` is the writer's secp256k1 public key (hex): the chain's DryRun needs a caller
4706
+ * and a signer is not asked for its key. A write the chain would refuse (no authorization, no
4707
+ * balance, no mint allowance) is `GATEWAY_READ_REJECTED`, never a fee.
4708
+ *
4709
+ * @throws GalaSDKError the input checks of the write; `INVALID_NFT_INPUT` for a bad key;
4710
+ * `SIGNING_FAILED`; `REQUEST_TIMEOUT` / `TRANSPORT_ERROR` (`write: false`); `GATEWAY_HTTP_ERROR`;
4711
+ * `GATEWAY_READ_REJECTED`; `GATEWAY_READ_RESPONSE_INVALID`.
4712
+ */
4713
+ async estimateNftFee(request, options) {
4714
+ const callerPublicKey = nftCallerPublicKey(options.callerPublicKey);
4715
+ const prepared = this.prepareFeeRequest(request);
4716
+ return await quoteNftFee(this.transport, this.uniqueKeyPrefix, callerPublicKey, prepared.method, prepared.dto);
4717
+ }
4718
+ prepareFeeRequest(request) {
4719
+ switch (request.write) {
4720
+ case "claimNftCollection": {
4721
+ const { dto } = this.prepareClaim(request);
4722
+ return {
4723
+ method: "GrantNftCollectionAuthorization",
4724
+ dto
4725
+ };
4726
+ }
4727
+ case "createNftCollection": {
4728
+ const { dto } = this.prepareCreate(request);
4729
+ return {
4730
+ method: "CreateNftCollection",
4731
+ dto
4732
+ };
4733
+ }
4734
+ case "mintNft": {
4735
+ const { method, dto } = this.prepareMint(request);
4736
+ return {
4737
+ method,
4738
+ dto
4739
+ };
4740
+ }
4741
+ }
4742
+ }
4743
+ /** Everything a claim needs, every input checked before the key is spent. */
4744
+ prepareClaim(input) {
4745
+ const collection = nftClassPart(input.collection, "collection");
4746
+ const authorizedUser = input.authorizedUser === void 0 ? this.walletAddress : galaChainUserRef(input.authorizedUser, "authorizedUser");
4747
+ const uniqueKey = this.uniqueKeyOf(input.uniqueKey);
4748
+ return {
4749
+ collection,
4750
+ uniqueKey,
4751
+ dto: claimNftCollectionDto(collection, authorizedUser, uniqueKey)
4752
+ };
4753
+ }
4754
+ prepareCreate(input) {
4755
+ const tokenClass = nftTokenClass(input);
4756
+ const fields = {
4757
+ name: nftText(input.name, "name"),
4758
+ symbol: nftString(input.symbol, "symbol"),
4759
+ description: nftText(input.description, "description"),
4760
+ image: nftText(input.image, "image"),
4761
+ maxSupply: nftWholeNumber(input.maxSupply, "maxSupply"),
4762
+ maxCapacity: input.maxCapacity === void 0 ? void 0 : nftWholeNumber(input.maxCapacity, "maxCapacity"),
4763
+ metadataAddress: input.metadataAddress === void 0 ? void 0 : nftText(input.metadataAddress, "metadataAddress"),
4764
+ contractAddress: input.contractAddress === void 0 ? void 0 : nftText(input.contractAddress, "contractAddress"),
4765
+ rarity: input.rarity === void 0 ? void 0 : nftText(input.rarity, "rarity"),
4766
+ authorities: input.authorities === void 0 ? void 0 : nftAuthorities(input.authorities)
4767
+ };
4768
+ const uniqueKey = this.uniqueKeyOf(input.uniqueKey);
4769
+ return {
4770
+ tokenClass,
4771
+ uniqueKey,
4772
+ dto: createNftCollectionDto(tokenClass, fields, uniqueKey)
4773
+ };
4774
+ }
4775
+ prepareMint(input) {
4776
+ const tokenClass = nftTokenClass(input);
4777
+ const quantity = nftMintQuantity(input.quantity, "quantity");
4778
+ const owner = input.owner === void 0 ? this.walletAddress : galaChainUserRef(input.owner, "owner");
4779
+ const method = input.existingAllowance === true ? "MintToken" : "MintTokenWithAllowance";
4780
+ const uniqueKey = this.uniqueKeyOf(input.uniqueKey);
4781
+ return {
4782
+ method,
4783
+ tokenClass,
4784
+ quantity,
4785
+ uniqueKey,
4786
+ dto: mintNftDto(method, tokenClass, owner, quantity, uniqueKey)
4787
+ };
4788
+ }
4185
4789
  /** The caller's key, checked, or a fresh one. */
4186
4790
  uniqueKeyOf(given) {
4187
4791
  if (given === void 0) return createUniqueKey(this.uniqueKeyPrefix);
@@ -4392,113 +4996,6 @@ function parsePage(value, parse) {
4392
4996
  };
4393
4997
  }
4394
4998
 
4395
- //#endregion
4396
- //#region src/reads/request.ts
4397
- /** The chaincode contract each read method belongs to (part of its URL). */
4398
- const CONTRACT_OF = {
4399
- FetchBalances: "token-contract",
4400
- FetchTokenClasses: "token-contract",
4401
- FetchTokenClassesWithSupply: "token-contract",
4402
- FetchTokenClassesWithPagination: "token-contract",
4403
- FetchNftCollectionAuthorizationsWithPagination: "token-contract",
4404
- GetPublicKey: "public-key-contract"
4405
- };
4406
- /**
4407
- * Methods whose successful answer carries no `Status`: the connect-api GalaChain proxies answer
4408
- * `GetPublicKey` with `{ Data: { publicKey } }` only (recorded 2026-10-14, prod and stage,
4409
- * `tests/fixtures/public-key-recorded.json`). A `Status` they do send is still checked.
4410
- */
4411
- const ANSWERED_WITHOUT_STATUS = /* @__PURE__ */ new Set(["GetPublicKey"]);
4412
- /**
4413
- * The channel of a collection: `$MUSIC` (and `MUSIC`, any case) lives on the gateway's `music`
4414
- * channel, every other collection (`$GMUSIC` included) on `asset`.
4415
- */
4416
- function channelOf(collection) {
4417
- return collection !== void 0 && /^\$?music$/iu.test(collection) ? "music" : "asset";
4418
- }
4419
- function isRecord(value) {
4420
- return typeof value === "object" && value !== null && !Array.isArray(value);
4421
- }
4422
- function stringField(record, key) {
4423
- const value = record === null || record === void 0 ? void 0 : record[key];
4424
- return typeof value === "string" ? value : "";
4425
- }
4426
- /**
4427
- * The chain's error object of a refused answer: GalaChain's gateway nests it as
4428
- * `{ error: { Status: 0, ErrorKey, Message, ErrorPayload }, message }`; an older answer carries
4429
- * `Status` / `ErrorKey` / `Message` at the top.
4430
- */
4431
- function chainErrorOf(body) {
4432
- if (!isRecord(body)) return void 0;
4433
- const nested = body["error"];
4434
- return isRecord(nested) ? nested : body;
4435
- }
4436
- /**
4437
- * POSTs one read and returns the chain's `Data`. Reads change nothing, so every failure is a READ's
4438
- * (`error.write === false`) and a retry is always safe:
4439
- *
4440
- * - no answer: `REQUEST_TIMEOUT` / `TRANSPORT_ERROR`, both `write: false` (an app requestor's
4441
- * own rejection passes through unchanged: it is the app's error); a body that broke off is
4442
- * `TRANSPORT_ERROR`;
4443
- * - a numeric top-level `Status` other than 1, in any HTTP status: `GATEWAY_READ_REJECTED`;
4444
- * - any other non-2xx: `GATEWAY_HTTP_ERROR` (`params.status`; the chain's refusal is `error.body`);
4445
- * - a 2xx that is not `{ Status: 1, Data }` (for `GetPublicKey`, whose answer carries no
4446
- * `Status`, not `{ Data }`): `GATEWAY_READ_RESPONSE_INVALID`.
4447
- */
4448
- async function readGateway(transport, method, body, channel = "asset") {
4449
- const url = `${transport.gatewayBaseUrl}/api/${channel}/${CONTRACT_OF[method]}/${method}`;
4450
- const response = await requestWithTimeout(transport.requestor, url, {
4451
- method: "POST",
4452
- headers: buildRequestHeaders(transport.wire, { json: true }),
4453
- body: JSON.stringify(body)
4454
- }, transport.timeoutMs, { write: false });
4455
- let answer;
4456
- try {
4457
- answer = await readResponseBody(response);
4458
- } catch (cause) {
4459
- throw new GalaSDKError("TRANSPORT_ERROR", { url }, {
4460
- url,
4461
- cause,
4462
- write: false
4463
- });
4464
- }
4465
- return dataOf(method, url, response, answer);
4466
- }
4467
- function dataOf(method, url, response, answer) {
4468
- const context = {
4469
- status: response.status,
4470
- body: answer,
4471
- url,
4472
- write: false
4473
- };
4474
- const envelope = isRecord(answer) ? answer : void 0;
4475
- const chainStatus = envelope === null || envelope === void 0 ? void 0 : envelope["Status"];
4476
- if (typeof chainStatus === "number" && chainStatus !== 1) throw new GalaSDKError("GATEWAY_READ_REJECTED", {
4477
- method,
4478
- chainStatus,
4479
- errorKey: stringField(envelope, "ErrorKey"),
4480
- serverMessage: stringField(envelope, "Message")
4481
- }, context);
4482
- if (!response.ok) {
4483
- const chainError = chainErrorOf(answer);
4484
- throw new GalaSDKError("GATEWAY_HTTP_ERROR", {
4485
- method,
4486
- status: response.status,
4487
- serverMessage: stringField(chainError, "Message") || stringField(envelope, "message")
4488
- }, context);
4489
- }
4490
- const statusAccepted = chainStatus === 1 || chainStatus === void 0 && ANSWERED_WITHOUT_STATUS.has(method);
4491
- if (envelope === void 0 || !statusAccepted || !("Data" in envelope)) throw new GalaSDKError("GATEWAY_READ_RESPONSE_INVALID", { method }, context);
4492
- return envelope["Data"];
4493
- }
4494
- /** The error for a 2xx whose `Data` is not what `method` answers. */
4495
- function invalidAnswer(method, data) {
4496
- return new GalaSDKError("GATEWAY_READ_RESPONSE_INVALID", { method }, {
4497
- body: data,
4498
- write: false
4499
- });
4500
- }
4501
-
4502
4999
  //#endregion
4503
5000
  //#region src/reads/types.ts
4504
5001
  /**
@@ -4877,6 +5374,120 @@ function notFoundOf(error) {
4877
5374
  });
4878
5375
  }
4879
5376
 
5377
+ //#endregion
5378
+ //#region src/reads/nft_collections.ts
5379
+ /** A read's collection name: 3 to 50 letters and digits. @throws GalaSDKError `INVALID_NFT_INPUT`. */
5380
+ function collectionName(name, field) {
5381
+ if (typeof name !== "string") throw new GalaSDKError("INVALID_NFT_INPUT", {
5382
+ field,
5383
+ reason: "not_a_string"
5384
+ });
5385
+ if (name === "") throw new GalaSDKError("INVALID_NFT_INPUT", {
5386
+ field,
5387
+ reason: "empty"
5388
+ });
5389
+ if (!/^[a-zA-Z0-9]{3,50}$/u.test(name)) throw new GalaSDKError("INVALID_NFT_INPUT", {
5390
+ field,
5391
+ reason: "bad_collection_name"
5392
+ });
5393
+ return name;
5394
+ }
5395
+ function validAddress(value) {
5396
+ try {
5397
+ galaChainUserRef(value, "address");
5398
+ return true;
5399
+ } catch {
5400
+ return false;
5401
+ }
5402
+ }
5403
+ function canonicalAddress(value) {
5404
+ return (validAddress(value) ? galaChainUserRef(value, "address") : value).toLowerCase();
5405
+ }
5406
+ /** NFT collection reads in Launchpad result shapes, using a shared gateway reader. */
5407
+ var NftCollectionReads = class {
5408
+ reads;
5409
+ constructor(reads) {
5410
+ this.reads = reads;
5411
+ }
5412
+ async fetchNftCollections(walletAddress) {
5413
+ const authorizedUser = galaChainUserRef(walletAddress, "walletAddress");
5414
+ return (await this.reads.fetchAllNftCollectionAuthorizations({ pageSize: 1e3 })).filter((row) => row.authorizedUsers.some((user) => canonicalAddress(user) === canonicalAddress(authorizedUser))).map((row) => ({
5415
+ authorizedUser,
5416
+ collection: row.collection
5417
+ }));
5418
+ }
5419
+ async isNftCollectionAvailable(name) {
5420
+ const collection = collectionName(name, "collection");
5421
+ return !(await this.reads.fetchAllNftCollectionAuthorizations({ pageSize: 1e3 })).some((row) => row.collection === collection);
5422
+ }
5423
+ async fetchNftTokenClasses(params) {
5424
+ collectionName(params.collection, "collection");
5425
+ return (await this.reads.fetchAllTokenClasses({
5426
+ collection: params.collection,
5427
+ category: params.category,
5428
+ type: params.type
5429
+ }, { pageSize: 1e3 })).map((row) => ({
5430
+ collection: row.collection,
5431
+ type: row.type,
5432
+ category: row.category,
5433
+ additionalKey: row.additionalKey,
5434
+ totalSupply: row.totalSupply,
5435
+ maxSupply: row.maxSupply,
5436
+ isNonFungible: row.isNonFungible,
5437
+ name: row.name,
5438
+ description: row.description,
5439
+ image: row.image,
5440
+ symbol: row.symbol,
5441
+ ...row.rarity === void 0 ? {} : { rarity: row.rarity }
5442
+ }));
5443
+ }
5444
+ async fetchNftBalances(ownerAddress, collectionFilter) {
5445
+ const owner = galaChainUserRef(ownerAddress, "ownerAddress");
5446
+ return (await this.reads.fetchNftBalances({
5447
+ owner,
5448
+ collection: collectionFilter
5449
+ })).map((row) => ({
5450
+ owner: row.owner,
5451
+ collection: row.collection,
5452
+ category: row.category,
5453
+ type: row.type,
5454
+ additionalKey: row.additionalKey,
5455
+ instanceIds: [...row.instanceIds],
5456
+ totalOwned: row.instanceIds.length
5457
+ }));
5458
+ }
5459
+ };
5460
+
5461
+ //#endregion
5462
+ //#region src/reads/nft_fees.ts
5463
+ function getNftCollectionClaimFee() {
5464
+ return "10000";
5465
+ }
5466
+ function getNftTokenClassCreateFee() {
5467
+ return "1000";
5468
+ }
5469
+ /** Calculate the fixed fees for the requested collection and token-class operations. */
5470
+ function estimateNftOperationFees(params) {
5471
+ let totalFee = "0";
5472
+ const breakdown = {};
5473
+ if (params.claimCollection) {
5474
+ const fee = getNftCollectionClaimFee();
5475
+ breakdown.collectionClaim = fee;
5476
+ totalFee = String(BigInt(totalFee) + BigInt(fee));
5477
+ }
5478
+ if ((params.createTokenClasses ?? 0) > 0) {
5479
+ const count = params.createTokenClasses;
5480
+ const fee = getNftTokenClassCreateFee();
5481
+ breakdown.tokenClassCreate = fee;
5482
+ breakdown.tokenClassCount = count;
5483
+ totalFee = String(BigInt(totalFee) + BigInt(fee) * BigInt(count));
5484
+ }
5485
+ return {
5486
+ totalFee,
5487
+ breakdown
5488
+ };
5489
+ }
5490
+
4880
5491
  //#endregion
4881
5492
  //#region src/config/environments.ts
4882
5493
  /**
@@ -4898,5 +5509,5 @@ const GALA_CHAIN_ENVIRONMENTS = Object.freeze({
4898
5509
  });
4899
5510
 
4900
5511
  //#endregion
4901
- export { BRIDGE_AMOUNT_PROBLEMS, BRIDGE_DEPOSIT_STEPS, BRIDGE_NETWORKS, BRIDGE_OUT_STEPS, BrowserWalletSigner, CHAIN_CONTRACT_OPERATION_PREFIXES, DEFAULT_UNIQUE_KEY_PREFIX, EIP712_CAPABLE_METHODS, FAILURE_OUTCOMES, GALA_CHAIN_ENVIRONMENTS, GALA_CORE_SDK_VERSION, GALA_ERROR_CATALOG, GALA_ERROR_PHASES, GALA_ERROR_PHASE_BY_CODE, GALA_TOKEN_CLASS_KEY, GATEWAY_READS_OPTIONS, GATEWAY_READ_LIMITS, GATEWAY_READ_METHODS, GATEWAY_WRITES_OPTIONS, GATEWAY_WRITE_BATCH_LIMITS, GATEWAY_WRITE_METHODS, GATEWAY_WRITE_OUTCOME_UNKNOWN_REASONS, GalaSDKError, GalaWalletSigner, GatewayReads, GatewayWrites, INVALID_PRIVATE_KEY_REASONS, INVALID_TOKEN_REFERENCE_REASONS, PAGE_REQUEST_FIELDS, PrivateKeySigner, SIGNING_FAILURE_REASONS, WALLET_CONNECTION_FAILURE_REASONS, WALLET_INPUT_PROBLEMS, WALLET_NOT_CONNECTED_REASONS, WALLET_PROVIDER_CONFIG_MISSING, WRAP_DIRECTIONS, WRAP_REFUSAL_REASONS, armTimeout, assertUniqueKey, buildEIP712Payload, buildQueryString, buildRequestHeaders, calculatePersonalSignPrefix, canonicalDecimalString, checksumEthereumAddress, compositeKeyOf, createLazyPrivateKeySigner, createUniqueKey, createWallet, dtoOperationOf, eip1193ProviderFromEthers, eip712DomainFor, ethAddressOfPrivateKey, ethereumAddressOfAccount, fetchRequestor, fixpointPrefixFor, galaChainUserRef, galaErrorTemplates, generateEIP712Types, getEthereumAddressFromPrivateKey, getPayloadToSign, getPublicKeyFromPrivateKey, hasGalaErrorBrand, hashTypedData, httpRequestorFromAxios, isFetchTransportFailure, isGalaCatalogCode, isGalaError, isGalaErrorLike, isTokenClassKey, isValidUniqueKey, isWalletUserRejection, isWriteView, normalizePrivateKey, numberParamOf, parseJson, personalSignPrefixFor, readBlockNumberHeader, readHeader, readResponseBody, readRetryAfter, renderGalaErrorTemplate, requestWithTimeout, resolvePersonalSignChainDtoPayload, resolveUniqueKeyPrefix, serialize, signChainDtoHash, signChainDtoNative, signChainDtoPersonalSign, signNative, signPersonalMessage, signPreSend, signPreSendFor, signRawObject, signSerializedNative, signTypedDataPayload, splitClassKey, stringParamOf, stripEip712DomainType, templatePlaceholders, toFailureView, tokenClassDollarKey, tokenDetailsOf, tryParseCompositeKey, tryParseTokenClassKey, validateTimeoutMs, validateWalletInput, walletDeclineCode, withDtoOperation, withGalaWalletIdentity, withPrivateKey };
5512
+ export { BRIDGE_AMOUNT_PROBLEMS, BRIDGE_DEPOSIT_STEPS, BRIDGE_NETWORKS, BRIDGE_OUT_STEPS, BrowserWalletSigner, CHAIN_CONTRACT_OPERATION_PREFIXES, CHAIN_METHOD_OPERATIONS, DEFAULT_UNIQUE_KEY_PREFIX, EIP712_CAPABLE_METHODS, FAILURE_OUTCOMES, GALA_CHAIN_ENVIRONMENTS, GALA_CORE_SDK_VERSION, GALA_ERROR_CATALOG, GALA_ERROR_PHASES, GALA_ERROR_PHASE_BY_CODE, GALA_TOKEN_CLASS_KEY, GATEWAY_READS_OPTIONS, GATEWAY_READ_LIMITS, GATEWAY_READ_METHODS, GATEWAY_WRITES_OPTIONS, GATEWAY_WRITE_BATCH_LIMITS, GATEWAY_WRITE_METHODS, GATEWAY_WRITE_OUTCOME_UNKNOWN_REASONS, GalaSDKError, GalaWalletSigner, GatewayReads, GatewayWrites, INVALID_NFT_INPUT_REASONS, INVALID_PRIVATE_KEY_REASONS, INVALID_TOKEN_REFERENCE_REASONS, NFT_DEFAULT_ADDITIONAL_KEY, NFT_MINT_LIMIT, NFT_WRITE_METHODS, NftCollectionReads, PAGE_REQUEST_FIELDS, PrivateKeySigner, SIGNING_FAILURE_REASONS, WALLET_CONNECTION_FAILURE_REASONS, WALLET_INPUT_PROBLEMS, WALLET_NOT_CONNECTED_REASONS, WALLET_PROVIDER_CONFIG_MISSING, WRAP_DIRECTIONS, WRAP_REFUSAL_REASONS, armTimeout, assertUniqueKey, buildEIP712Payload, buildQueryString, buildRequestHeaders, calculatePersonalSignPrefix, canonicalDecimalString, checksumEthereumAddress, compositeKeyOf, createLazyPrivateKeySigner, createUniqueKey, createWallet, dtoOperationOf, eip1193ProviderFromEthers, eip712DomainFor, estimateNftOperationFees, ethAddressOfPrivateKey, ethereumAddressOfAccount, fetchRequestor, fixpointPrefixFor, galaChainUserRef, galaErrorTemplates, generateEIP712Types, getEthereumAddressFromPrivateKey, getNftCollectionClaimFee, getNftTokenClassCreateFee, getPayloadToSign, getPublicKeyFromPrivateKey, hasGalaErrorBrand, hashTypedData, httpRequestorFromAxios, isFetchTransportFailure, isGalaCatalogCode, isGalaError, isGalaErrorLike, isTokenClassKey, isValidUniqueKey, isWalletUserRejection, isWriteView, normalizePrivateKey, numberParamOf, parseJson, personalSignPrefixFor, readBlockNumberHeader, readHeader, readResponseBody, readRetryAfter, renderGalaErrorTemplate, requestWithTimeout, resolvePersonalSignChainDtoPayload, resolveUniqueKeyPrefix, serialize, signChainDtoHash, signChainDtoNative, signChainDtoPersonalSign, signNative, signPersonalMessage, signPreSend, signPreSendFor, signRawObject, signSerializedNative, signTypedDataPayload, splitClassKey, stringParamOf, stripEip712DomainType, templatePlaceholders, toFailureView, tokenClassDollarKey, tokenDetailsOf, tryParseCompositeKey, tryParseTokenClassKey, validateTimeoutMs, validateWalletInput, walletDeclineCode, withDtoOperation, withGalaWalletIdentity, withPrivateKey };
4902
5513
  //# sourceMappingURL=index.mjs.map