@gala-chain/gala-core-sdk 1.1.0-beta.9 → 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.
- package/README.md +48 -2
- package/dist/browser/classes/error_catalog.js +1 -1
- package/dist/browser/classes/error_catalog.js.map +1 -1
- package/dist/browser/classes/error_phase_table.js +1 -1
- package/dist/browser/classes/error_phase_table.js.map +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/reads/gateway_reads.js +1 -1
- package/dist/browser/reads/nft_collections.js +2 -0
- package/dist/browser/reads/nft_collections.js.map +1 -0
- package/dist/browser/reads/nft_fees.js +2 -0
- package/dist/browser/reads/nft_fees.js.map +1 -0
- package/dist/browser/reads/request.js +1 -1
- package/dist/browser/reads/request.js.map +1 -1
- package/dist/browser/utils/transport.js +1 -1
- package/dist/browser/version.js +1 -1
- package/dist/browser/version.js.map +1 -1
- package/dist/browser/writes/gateway_writes.js +1 -1
- package/dist/browser/writes/gateway_writes.js.map +1 -1
- package/dist/browser/writes/nft.js +2 -0
- package/dist/browser/writes/nft.js.map +1 -0
- package/dist/browser/writes/nft_fee.js +2 -0
- package/dist/browser/writes/nft_fee.js.map +1 -0
- package/dist/browser/writes/submit.js +1 -1
- package/dist/browser/writes/submit.js.map +1 -1
- package/dist/browser/writes/types.js.map +1 -1
- package/dist/index.cjs +716 -134
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +255 -3
- package/dist/index.d.ts +255 -3
- package/dist/index.mjs +709 -135
- package/dist/index.mjs.map +1 -1
- 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$
|
|
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$
|
|
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$
|
|
1017
|
+
return isRecord$7(value) && typeof value["code"] === "string" && isRecord$7(value["params"]) && !Array.isArray(value["params"]);
|
|
995
1018
|
}
|
|
996
1019
|
|
|
997
1020
|
//#endregion
|
|
@@ -2700,12 +2723,12 @@ const TEXT_KEYS = [
|
|
|
2700
2723
|
];
|
|
2701
2724
|
/** Wallet errors nest their text at most a level or two deep; the bound also stops a cyclic object. */
|
|
2702
2725
|
const MAX_TEXT_DEPTH = 3;
|
|
2703
|
-
function isRecord$
|
|
2726
|
+
function isRecord$6(value) {
|
|
2704
2727
|
return typeof value === "object" && value !== null;
|
|
2705
2728
|
}
|
|
2706
2729
|
function textsOf(value, depth = 0) {
|
|
2707
2730
|
if (typeof value === "string") return [value];
|
|
2708
|
-
if (!isRecord$
|
|
2731
|
+
if (!isRecord$6(value) || depth >= MAX_TEXT_DEPTH) return [];
|
|
2709
2732
|
return TEXT_KEYS.flatMap((key) => textsOf(value[key], depth + 1));
|
|
2710
2733
|
}
|
|
2711
2734
|
function wordsADecline(text) {
|
|
@@ -2748,7 +2771,7 @@ function isWalletUserRejection(value) {
|
|
|
2748
2771
|
if (value.code === "SIGNING_FAILED") return value.params["reason"] === "user_rejected";
|
|
2749
2772
|
return !hasGalaErrorBrand(value) && REJECTION_CODES.includes(value.code);
|
|
2750
2773
|
}
|
|
2751
|
-
if (isRecord$
|
|
2774
|
+
if (isRecord$6(value)) {
|
|
2752
2775
|
if (REJECTION_CODES.includes(value["code"]) || value["name"] === REJECTION_NAME) return true;
|
|
2753
2776
|
}
|
|
2754
2777
|
return textsOf(value).some(wordsADecline);
|
|
@@ -2840,7 +2863,7 @@ async function signPreSendFor(signer, contractPath, method, dto) {
|
|
|
2840
2863
|
* fallback. It is the version in the default `User-Agent` (`GalaChain-SDK/<version>`) of every SDK
|
|
2841
2864
|
* request, whichever product SDK sends it.
|
|
2842
2865
|
*/
|
|
2843
|
-
const GALA_CORE_SDK_VERSION = "1.
|
|
2866
|
+
const GALA_CORE_SDK_VERSION = "1.2.0-beta.1";
|
|
2844
2867
|
|
|
2845
2868
|
//#endregion
|
|
2846
2869
|
//#region src/utils/transport.ts
|
|
@@ -2901,7 +2924,7 @@ function buildRequestHeaders(wire, parts = {}) {
|
|
|
2901
2924
|
entries.set(name.toLowerCase(), [name, value]);
|
|
2902
2925
|
}
|
|
2903
2926
|
};
|
|
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.
|
|
2927
|
+
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.1"}` });
|
|
2905
2928
|
put(parts.defaults);
|
|
2906
2929
|
put(wire === null || wire === void 0 ? void 0 : wire.headers);
|
|
2907
2930
|
if (parts.json === true && !entries.has("content-type")) put({ "Content-Type": "application/json" });
|
|
@@ -3004,7 +3027,7 @@ function hasHeaderGetter(headers) {
|
|
|
3004
3027
|
|
|
3005
3028
|
//#endregion
|
|
3006
3029
|
//#region src/utils/axios_requestor.ts
|
|
3007
|
-
function isRecord$
|
|
3030
|
+
function isRecord$5(value) {
|
|
3008
3031
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3009
3032
|
}
|
|
3010
3033
|
/**
|
|
@@ -3012,10 +3035,10 @@ function isRecord$3(value) {
|
|
|
3012
3035
|
* for ECONNREFUSED). That is a transport failure, not an HTTP answer.
|
|
3013
3036
|
*/
|
|
3014
3037
|
function isAxiosLikeResponse(value) {
|
|
3015
|
-
return isRecord$
|
|
3038
|
+
return isRecord$5(value) && typeof value["status"] === "number";
|
|
3016
3039
|
}
|
|
3017
3040
|
function readAxiosHeader(headers, name) {
|
|
3018
|
-
if (!isRecord$
|
|
3041
|
+
if (!isRecord$5(headers)) return null;
|
|
3019
3042
|
const getter = headers["get"];
|
|
3020
3043
|
if (typeof getter === "function") {
|
|
3021
3044
|
const value = getter.call(headers, name);
|
|
@@ -3096,16 +3119,16 @@ function httpRequestorFromAxios(instance, options) {
|
|
|
3096
3119
|
*/
|
|
3097
3120
|
function isTransportRejection(error, rejectOnHttpError) {
|
|
3098
3121
|
if (!rejectOnHttpError) return true;
|
|
3099
|
-
return isRecord$
|
|
3122
|
+
return isRecord$5(error) && error["isAxiosError"] === true && error["response"] === void 0;
|
|
3100
3123
|
}
|
|
3101
3124
|
|
|
3102
3125
|
//#endregion
|
|
3103
3126
|
//#region src/utils/ethers_provider.ts
|
|
3104
|
-
function isRecord$
|
|
3127
|
+
function isRecord$4(value) {
|
|
3105
3128
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3106
3129
|
}
|
|
3107
3130
|
function isTypedDataTypes(value) {
|
|
3108
|
-
return isRecord$
|
|
3131
|
+
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
3132
|
}
|
|
3110
3133
|
function malformed(method) {
|
|
3111
3134
|
return new GalaSDKError("MALFORMED_WALLET_REQUEST", { method });
|
|
@@ -3119,9 +3142,9 @@ function readTypedDataRequest(params) {
|
|
|
3119
3142
|
} catch {
|
|
3120
3143
|
throw malformed("eth_signTypedData_v4");
|
|
3121
3144
|
}
|
|
3122
|
-
if (!isRecord$
|
|
3145
|
+
if (!isRecord$4(payload)) throw malformed("eth_signTypedData_v4");
|
|
3123
3146
|
const { domain, types, message } = payload;
|
|
3124
|
-
if (!isRecord$
|
|
3147
|
+
if (!isRecord$4(domain) || !isTypedDataTypes(types) || !isRecord$4(message)) throw malformed("eth_signTypedData_v4");
|
|
3125
3148
|
return {
|
|
3126
3149
|
domain,
|
|
3127
3150
|
types: stripEip712DomainType(types),
|
|
@@ -3250,7 +3273,7 @@ const FAILURE_OUTCOMES = [
|
|
|
3250
3273
|
|
|
3251
3274
|
//#endregion
|
|
3252
3275
|
//#region src/utils/failure_view.ts
|
|
3253
|
-
function isRecord$
|
|
3276
|
+
function isRecord$3(value) {
|
|
3254
3277
|
return typeof value === "object" && value !== null;
|
|
3255
3278
|
}
|
|
3256
3279
|
/**
|
|
@@ -3268,12 +3291,12 @@ function isRecord$1(value) {
|
|
|
3268
3291
|
* ```
|
|
3269
3292
|
*/
|
|
3270
3293
|
function toFailureView(value) {
|
|
3271
|
-
if (!isRecord$
|
|
3294
|
+
if (!isRecord$3(value)) return void 0;
|
|
3272
3295
|
const { code, params, status, phase, uniqueKey, write, outcome, retryable, shadow, notFound } = value;
|
|
3273
3296
|
if (typeof code !== "string" || code === "") return void 0;
|
|
3274
3297
|
return {
|
|
3275
3298
|
code,
|
|
3276
|
-
params: isRecord$
|
|
3299
|
+
params: isRecord$3(params) && !Array.isArray(params) ? params : void 0,
|
|
3277
3300
|
status: typeof status === "number" && Number.isFinite(status) ? status : void 0,
|
|
3278
3301
|
phase: GALA_ERROR_PHASES.find((known) => known === phase),
|
|
3279
3302
|
uniqueKey: typeof uniqueKey === "string" && uniqueKey !== "" ? uniqueKey : void 0,
|
|
@@ -3734,10 +3757,315 @@ function unlockTokenDto(owner, tokens, uniqueKey, name) {
|
|
|
3734
3757
|
};
|
|
3735
3758
|
}
|
|
3736
3759
|
|
|
3760
|
+
//#endregion
|
|
3761
|
+
//#region src/writes/nft.ts
|
|
3762
|
+
/**
|
|
3763
|
+
* The NFT methods of GalaChain's token contract that `GatewayWrites` signs and submits, as a closed
|
|
3764
|
+
* set: claim a collection name (`GrantNftCollectionAuthorization`), create the NFT collection's
|
|
3765
|
+
* token class (`CreateNftCollection`), mint NFTs, granting the minter its own mint allowance in
|
|
3766
|
+
* the same transaction (`MintTokenWithAllowance`) or against an allowance it already holds
|
|
3767
|
+
* (`MintToken`).
|
|
3768
|
+
*/
|
|
3769
|
+
const NFT_WRITE_METHODS = [
|
|
3770
|
+
"GrantNftCollectionAuthorization",
|
|
3771
|
+
"CreateNftCollection",
|
|
3772
|
+
"MintTokenWithAllowance",
|
|
3773
|
+
"MintToken"
|
|
3774
|
+
];
|
|
3775
|
+
/** The most NFTs one mint may create (the chain's `MintTokenDto.MAX_NFT_MINT_SIZE`). */
|
|
3776
|
+
const NFT_MINT_LIMIT = 1e3;
|
|
3777
|
+
/** The `additionalKey` an NFT token class carries when its creator names none (GalaChain's `none`). */
|
|
3778
|
+
const NFT_DEFAULT_ADDITIONAL_KEY = "none";
|
|
3779
|
+
function refuse(field, reason) {
|
|
3780
|
+
return new GalaSDKError("INVALID_NFT_INPUT", {
|
|
3781
|
+
field,
|
|
3782
|
+
reason
|
|
3783
|
+
});
|
|
3784
|
+
}
|
|
3785
|
+
/** True when `value` holds an ASCII or C1 control character (the NUL of chain composite keys among them). */
|
|
3786
|
+
function hasControlCharacter(value) {
|
|
3787
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
3788
|
+
const code = value.charCodeAt(index);
|
|
3789
|
+
if (code <= 31 || code >= 127 && code <= 159) return true;
|
|
3790
|
+
}
|
|
3791
|
+
return false;
|
|
3792
|
+
}
|
|
3793
|
+
/**
|
|
3794
|
+
* One part of a token class key (collection, category, type, additionalKey): a non-empty string
|
|
3795
|
+
* with no control character (the chain's composite keys are NUL-separated), no `|` (the key's own
|
|
3796
|
+
* separator) and no surrounding whitespace. Returned exactly as written, never trimmed.
|
|
3797
|
+
*
|
|
3798
|
+
* @throws GalaSDKError `INVALID_NFT_INPUT`.
|
|
3799
|
+
*/
|
|
3800
|
+
function nftClassPart(value, field) {
|
|
3801
|
+
if (typeof value !== "string") throw refuse(field, "not_a_string");
|
|
3802
|
+
if (value.trim() === "") throw refuse(field, "empty");
|
|
3803
|
+
if (value.trim() !== value || value.includes("|") || hasControlCharacter(value)) throw refuse(field, "bad_characters");
|
|
3804
|
+
return value;
|
|
3805
|
+
}
|
|
3806
|
+
/** A non-empty free-text field (name, description, image, ...), exactly as written. */
|
|
3807
|
+
function nftText(value, field) {
|
|
3808
|
+
if (typeof value !== "string") throw refuse(field, "not_a_string");
|
|
3809
|
+
if (value.trim() === "") throw refuse(field, "empty");
|
|
3810
|
+
return value;
|
|
3811
|
+
}
|
|
3812
|
+
/** A string that may be empty (the symbol). */
|
|
3813
|
+
function nftString(value, field) {
|
|
3814
|
+
if (typeof value !== "string") throw refuse(field, "not_a_string");
|
|
3815
|
+
return value;
|
|
3816
|
+
}
|
|
3817
|
+
const WHOLE_NUMBER = /^[1-9][0-9]{0,37}$/u;
|
|
3818
|
+
/**
|
|
3819
|
+
* A positive whole number written as a decimal string (no sign, fraction, exponent, separators or
|
|
3820
|
+
* leading zero), returned as written. A JS number is refused: the chain receives strings.
|
|
3821
|
+
*/
|
|
3822
|
+
function nftWholeNumber(value, field) {
|
|
3823
|
+
if (typeof value !== "string" || !WHOLE_NUMBER.test(value)) throw refuse(field, "not_a_positive_whole_number");
|
|
3824
|
+
return value;
|
|
3825
|
+
}
|
|
3826
|
+
/** The quantity of a mint: a positive whole number of at most {@link NFT_MINT_LIMIT}. */
|
|
3827
|
+
function nftMintQuantity(value, field) {
|
|
3828
|
+
const quantity = nftWholeNumber(value, field);
|
|
3829
|
+
if (new BigNumber(quantity).isGreaterThan(1e3)) throw refuse(field, "above_mint_limit");
|
|
3830
|
+
return quantity;
|
|
3831
|
+
}
|
|
3832
|
+
/** The token class a write names, every part checked; `additionalKey` defaults to `none`. */
|
|
3833
|
+
function nftTokenClass(input) {
|
|
3834
|
+
return {
|
|
3835
|
+
collection: nftClassPart(input.collection, "collection"),
|
|
3836
|
+
category: nftClassPart(input.category, "category"),
|
|
3837
|
+
type: nftClassPart(input.type, "type"),
|
|
3838
|
+
additionalKey: nftClassPart(input.additionalKey ?? "none", "additionalKey")
|
|
3839
|
+
};
|
|
3840
|
+
}
|
|
3841
|
+
/** The authorities of a create: one or more user references, each in its one gateway spelling. */
|
|
3842
|
+
function nftAuthorities(value) {
|
|
3843
|
+
if (!Array.isArray(value) || value.length === 0) throw refuse("authorities", "bad_authorities");
|
|
3844
|
+
return value.map((authority, index) => galaChainUserRef(authority, `authorities[${index}]`));
|
|
3845
|
+
}
|
|
3846
|
+
const PUBLIC_KEY = /^(?:0x)?(?:(?:02|03)[0-9a-fA-F]{64}|04[0-9a-fA-F]{128})$/u;
|
|
3847
|
+
/**
|
|
3848
|
+
* The public key a DryRun simulates the caller as: a secp256k1 key in hex, compressed (33 bytes) or
|
|
3849
|
+
* uncompressed (65 bytes), with or without `0x`. The chain refuses a DryRun that names no caller.
|
|
3850
|
+
*/
|
|
3851
|
+
function nftCallerPublicKey(value) {
|
|
3852
|
+
if (typeof value !== "string" || !PUBLIC_KEY.test(value)) throw refuse("callerPublicKey", "bad_public_key");
|
|
3853
|
+
return value;
|
|
3854
|
+
}
|
|
3855
|
+
/** The unsigned `GrantNftCollectionAuthorization` DTO. */
|
|
3856
|
+
function claimNftCollectionDto(collection, authorizedUser, uniqueKey) {
|
|
3857
|
+
return {
|
|
3858
|
+
collection,
|
|
3859
|
+
authorizedUser,
|
|
3860
|
+
uniqueKey
|
|
3861
|
+
};
|
|
3862
|
+
}
|
|
3863
|
+
/** The unsigned `CreateNftCollection` DTO: the fields the caller gave, none the caller left out. */
|
|
3864
|
+
function createNftCollectionDto(tokenClass, fields, uniqueKey) {
|
|
3865
|
+
return {
|
|
3866
|
+
...tokenClass,
|
|
3867
|
+
name: fields.name,
|
|
3868
|
+
symbol: fields.symbol,
|
|
3869
|
+
description: fields.description,
|
|
3870
|
+
image: fields.image,
|
|
3871
|
+
maxSupply: fields.maxSupply,
|
|
3872
|
+
...fields.maxCapacity === void 0 ? {} : { maxCapacity: fields.maxCapacity },
|
|
3873
|
+
...fields.metadataAddress === void 0 ? {} : { metadataAddress: fields.metadataAddress },
|
|
3874
|
+
...fields.contractAddress === void 0 ? {} : { contractAddress: fields.contractAddress },
|
|
3875
|
+
...fields.rarity === void 0 ? {} : { rarity: fields.rarity },
|
|
3876
|
+
...fields.authorities === void 0 ? {} : { authorities: [...fields.authorities] },
|
|
3877
|
+
uniqueKey
|
|
3878
|
+
};
|
|
3879
|
+
}
|
|
3880
|
+
/**
|
|
3881
|
+
* The unsigned mint DTO. `MintTokenWithAllowance` names instance `"0"` (the allowance it grants
|
|
3882
|
+
* itself covers the class's mint, not one NFT); `MintToken` carries no instance.
|
|
3883
|
+
*/
|
|
3884
|
+
function mintNftDto(method, tokenClass, owner, quantity, uniqueKey) {
|
|
3885
|
+
return {
|
|
3886
|
+
tokenClass,
|
|
3887
|
+
owner,
|
|
3888
|
+
...method === "MintTokenWithAllowance" ? { tokenInstance: "0" } : {},
|
|
3889
|
+
quantity,
|
|
3890
|
+
uniqueKey
|
|
3891
|
+
};
|
|
3892
|
+
}
|
|
3893
|
+
function isRecord$2(value) {
|
|
3894
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3895
|
+
}
|
|
3896
|
+
/** The error for a write GalaChain accepted whose answer does not say what the write did. */
|
|
3897
|
+
function unreadable(method, uniqueKey, body) {
|
|
3898
|
+
return new GalaSDKError("GATEWAY_RESPONSE_INVALID", { method }, {
|
|
3899
|
+
body,
|
|
3900
|
+
uniqueKey
|
|
3901
|
+
});
|
|
3902
|
+
}
|
|
3903
|
+
function sameClass(value, tokenClass) {
|
|
3904
|
+
return value["collection"] === tokenClass.collection && value["category"] === tokenClass.category && value["type"] === tokenClass.type && value["additionalKey"] === tokenClass.additionalKey;
|
|
3905
|
+
}
|
|
3906
|
+
/**
|
|
3907
|
+
* The collection and authorized users a claim answered. Fails closed: an answer for another
|
|
3908
|
+
* collection, or one that authorizes nobody, is not the claim that was sent.
|
|
3909
|
+
*/
|
|
3910
|
+
function claimedCollection(receipt, collection) {
|
|
3911
|
+
const data = receipt.data;
|
|
3912
|
+
const users = isRecord$2(data) ? data["authorizedUsers"] : void 0;
|
|
3913
|
+
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);
|
|
3914
|
+
return {
|
|
3915
|
+
...receipt,
|
|
3916
|
+
collection,
|
|
3917
|
+
authorizedUsers: users
|
|
3918
|
+
};
|
|
3919
|
+
}
|
|
3920
|
+
/** The token class a create answered; an answer naming another class is not the create that was sent. */
|
|
3921
|
+
function createdTokenClass(receipt, tokenClass) {
|
|
3922
|
+
const data = receipt.data;
|
|
3923
|
+
if (!isRecord$2(data) || !sameClass(data, tokenClass)) throw unreadable(receipt.method, receipt.uniqueKey, receipt.body);
|
|
3924
|
+
return {
|
|
3925
|
+
...receipt,
|
|
3926
|
+
tokenClass: { ...tokenClass }
|
|
3927
|
+
};
|
|
3928
|
+
}
|
|
3929
|
+
const INSTANCE_ID = /^[0-9]+$/u;
|
|
3930
|
+
/**
|
|
3931
|
+
* The NFT instances a mint answered, never synthesized: as many as were asked for, each of the
|
|
3932
|
+
* class that was named, each with a whole-number instance, none twice.
|
|
3933
|
+
*/
|
|
3934
|
+
function mintedInstances(receipt, tokenClass, quantity) {
|
|
3935
|
+
const data = receipt.data;
|
|
3936
|
+
const instances = [];
|
|
3937
|
+
if (Array.isArray(data)) for (const item of data) {
|
|
3938
|
+
const instance = isRecord$2(item) ? item["instance"] : void 0;
|
|
3939
|
+
if (!isRecord$2(item) || !sameClass(item, tokenClass) || typeof instance !== "string") break;
|
|
3940
|
+
if (!INSTANCE_ID.test(instance)) break;
|
|
3941
|
+
instances.push({
|
|
3942
|
+
...tokenClass,
|
|
3943
|
+
instance
|
|
3944
|
+
});
|
|
3945
|
+
}
|
|
3946
|
+
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);
|
|
3947
|
+
return {
|
|
3948
|
+
...receipt,
|
|
3949
|
+
tokenInstances: instances
|
|
3950
|
+
};
|
|
3951
|
+
}
|
|
3952
|
+
|
|
3953
|
+
//#endregion
|
|
3954
|
+
//#region src/reads/request.ts
|
|
3955
|
+
/** The chaincode contract each read method belongs to (part of its URL). */
|
|
3956
|
+
const CONTRACT_OF = {
|
|
3957
|
+
FetchBalances: "token-contract",
|
|
3958
|
+
FetchTokenClasses: "token-contract",
|
|
3959
|
+
FetchTokenClassesWithSupply: "token-contract",
|
|
3960
|
+
FetchTokenClassesWithPagination: "token-contract",
|
|
3961
|
+
FetchNftCollectionAuthorizationsWithPagination: "token-contract",
|
|
3962
|
+
GetPublicKey: "public-key-contract"
|
|
3963
|
+
};
|
|
3964
|
+
/**
|
|
3965
|
+
* Methods whose successful answer carries no `Status`: the connect-api GalaChain proxies answer
|
|
3966
|
+
* `GetPublicKey` with `{ Data: { publicKey } }` only (recorded 2026-10-14, prod and stage,
|
|
3967
|
+
* `tests/fixtures/public-key-recorded.json`). A `Status` they do send is still checked.
|
|
3968
|
+
*/
|
|
3969
|
+
const ANSWERED_WITHOUT_STATUS = /* @__PURE__ */ new Set(["GetPublicKey"]);
|
|
3970
|
+
/**
|
|
3971
|
+
* The channel of a collection: `$MUSIC` (and `MUSIC`, any case) lives on the gateway's `music`
|
|
3972
|
+
* channel, every other collection (`$GMUSIC` included) on `asset`.
|
|
3973
|
+
*/
|
|
3974
|
+
function channelOf(collection) {
|
|
3975
|
+
return collection !== void 0 && /^\$?music$/iu.test(collection) ? "music" : "asset";
|
|
3976
|
+
}
|
|
3977
|
+
function isRecord$1(value) {
|
|
3978
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3979
|
+
}
|
|
3980
|
+
function stringField$2(record, key) {
|
|
3981
|
+
const value = record === null || record === void 0 ? void 0 : record[key];
|
|
3982
|
+
return typeof value === "string" ? value : "";
|
|
3983
|
+
}
|
|
3984
|
+
/**
|
|
3985
|
+
* The chain's error object of a refused answer: GalaChain's gateway nests it as
|
|
3986
|
+
* `{ error: { Status: 0, ErrorKey, Message, ErrorPayload }, message }`; an older answer carries
|
|
3987
|
+
* `Status` / `ErrorKey` / `Message` at the top.
|
|
3988
|
+
*/
|
|
3989
|
+
function chainErrorOf(body) {
|
|
3990
|
+
if (!isRecord$1(body)) return void 0;
|
|
3991
|
+
const nested = body["error"];
|
|
3992
|
+
return isRecord$1(nested) ? nested : body;
|
|
3993
|
+
}
|
|
3994
|
+
/**
|
|
3995
|
+
* POSTs one read and returns the chain's `Data`. Reads change nothing, so every failure is a READ's
|
|
3996
|
+
* (`error.write === false`) and a retry is always safe:
|
|
3997
|
+
*
|
|
3998
|
+
* - no answer: `REQUEST_TIMEOUT` / `TRANSPORT_ERROR`, both `write: false` (an app requestor's
|
|
3999
|
+
* own rejection passes through unchanged: it is the app's error); a body that broke off is
|
|
4000
|
+
* `TRANSPORT_ERROR`;
|
|
4001
|
+
* - a numeric top-level `Status` other than 1, in any HTTP status: `GATEWAY_READ_REJECTED`;
|
|
4002
|
+
* - any other non-2xx: `GATEWAY_HTTP_ERROR` (`params.status`; the chain's refusal is `error.body`);
|
|
4003
|
+
* - a 2xx that is not `{ Status: 1, Data }` (for `GetPublicKey`, whose answer carries no
|
|
4004
|
+
* `Status`, not `{ Data }`): `GATEWAY_READ_RESPONSE_INVALID`.
|
|
4005
|
+
*/
|
|
4006
|
+
async function readGateway(transport, method, body, channel = "asset") {
|
|
4007
|
+
const url = `${transport.gatewayBaseUrl}/api/${channel}/${CONTRACT_OF[method]}/${method}`;
|
|
4008
|
+
const response = await requestWithTimeout(transport.requestor, url, {
|
|
4009
|
+
method: "POST",
|
|
4010
|
+
headers: buildRequestHeaders(transport.wire, { json: true }),
|
|
4011
|
+
body: JSON.stringify(body)
|
|
4012
|
+
}, transport.timeoutMs, { write: false });
|
|
4013
|
+
let answer;
|
|
4014
|
+
try {
|
|
4015
|
+
answer = await readResponseBody(response);
|
|
4016
|
+
} catch (cause) {
|
|
4017
|
+
throw new GalaSDKError("TRANSPORT_ERROR", { url }, {
|
|
4018
|
+
url,
|
|
4019
|
+
cause,
|
|
4020
|
+
write: false
|
|
4021
|
+
});
|
|
4022
|
+
}
|
|
4023
|
+
return dataOf(method, url, response, answer);
|
|
4024
|
+
}
|
|
4025
|
+
/**
|
|
4026
|
+
* The chain's `Data` of a read-like answer, or the error for one that is not (see
|
|
4027
|
+
* {@link readGateway} for the codes). Also the reading of a signed DryRun answer, which changes
|
|
4028
|
+
* nothing either, so it names its own `method` (a string, not a read method).
|
|
4029
|
+
*/
|
|
4030
|
+
function dataOf(method, url, response, answer) {
|
|
4031
|
+
const context = {
|
|
4032
|
+
status: response.status,
|
|
4033
|
+
body: answer,
|
|
4034
|
+
url,
|
|
4035
|
+
write: false
|
|
4036
|
+
};
|
|
4037
|
+
const envelope = isRecord$1(answer) ? answer : void 0;
|
|
4038
|
+
const chainStatus = envelope === null || envelope === void 0 ? void 0 : envelope["Status"];
|
|
4039
|
+
if (typeof chainStatus === "number" && chainStatus !== 1) throw new GalaSDKError("GATEWAY_READ_REJECTED", {
|
|
4040
|
+
method,
|
|
4041
|
+
chainStatus,
|
|
4042
|
+
errorKey: stringField$2(envelope, "ErrorKey"),
|
|
4043
|
+
serverMessage: stringField$2(envelope, "Message")
|
|
4044
|
+
}, context);
|
|
4045
|
+
if (!response.ok) {
|
|
4046
|
+
const chainError = chainErrorOf(answer);
|
|
4047
|
+
throw new GalaSDKError("GATEWAY_HTTP_ERROR", {
|
|
4048
|
+
method,
|
|
4049
|
+
status: response.status,
|
|
4050
|
+
serverMessage: stringField$2(chainError, "Message") || stringField$2(envelope, "message")
|
|
4051
|
+
}, context);
|
|
4052
|
+
}
|
|
4053
|
+
const statusAccepted = chainStatus === 1 || chainStatus === void 0 && ANSWERED_WITHOUT_STATUS.has(method);
|
|
4054
|
+
if (envelope === void 0 || !statusAccepted || !("Data" in envelope)) throw new GalaSDKError("GATEWAY_READ_RESPONSE_INVALID", { method }, context);
|
|
4055
|
+
return envelope["Data"];
|
|
4056
|
+
}
|
|
4057
|
+
/** The error for a 2xx whose `Data` is not what `method` answers. */
|
|
4058
|
+
function invalidAnswer(method, data) {
|
|
4059
|
+
return new GalaSDKError("GATEWAY_READ_RESPONSE_INVALID", { method }, {
|
|
4060
|
+
body: data,
|
|
4061
|
+
write: false
|
|
4062
|
+
});
|
|
4063
|
+
}
|
|
4064
|
+
|
|
3737
4065
|
//#endregion
|
|
3738
4066
|
//#region src/writes/submit.ts
|
|
3739
4067
|
/** The contract every write of this module is sent to (its URL path and its `dtoOperation`). */
|
|
3740
|
-
const TOKEN_CONTRACT = "asset/token-contract";
|
|
4068
|
+
const TOKEN_CONTRACT$1 = "asset/token-contract";
|
|
3741
4069
|
/**
|
|
3742
4070
|
* The fields a signer may add next to the DTO: the signature and, for the wallet schemes, the
|
|
3743
4071
|
* personal-sign `prefix` and the EIP-712 `types` / `domain`. Nothing else: a signer that inserts a
|
|
@@ -3767,9 +4095,9 @@ function carriesExactlyTheDto(builtDto, signed) {
|
|
|
3767
4095
|
* `SIGNING_FAILED` (pre-send: nothing was transmitted, a retry is safe).
|
|
3768
4096
|
*/
|
|
3769
4097
|
async function signedPayload(signer, method, dto) {
|
|
3770
|
-
const operated = withDtoOperation(TOKEN_CONTRACT, method, dto);
|
|
4098
|
+
const operated = withDtoOperation(TOKEN_CONTRACT$1, method, dto);
|
|
3771
4099
|
const builtDto = serialize(operated);
|
|
3772
|
-
const signed = await signPreSendFor(signer, TOKEN_CONTRACT, method, operated);
|
|
4100
|
+
const signed = await signPreSendFor(signer, TOKEN_CONTRACT$1, method, operated);
|
|
3773
4101
|
let payload;
|
|
3774
4102
|
try {
|
|
3775
4103
|
payload = carriesExactlyTheDto(builtDto, signed) ? JSON.stringify(signed) : void 0;
|
|
@@ -3851,11 +4179,13 @@ function receiptOf(method, uniqueKey, url, response, body) {
|
|
|
3851
4179
|
};
|
|
3852
4180
|
const envelope = typeof body === "object" && body !== null && !Array.isArray(body) ? body : void 0;
|
|
3853
4181
|
const chainStatus = envelope === null || envelope === void 0 ? void 0 : envelope["Status"];
|
|
3854
|
-
|
|
4182
|
+
const refusal = chainErrorOf(body);
|
|
4183
|
+
const refusalStatus = refusal === null || refusal === void 0 ? void 0 : refusal["Status"];
|
|
4184
|
+
if (typeof refusalStatus === "number" && refusalStatus !== 1) throw new GalaSDKError("GATEWAY_WRITE_REJECTED", {
|
|
3855
4185
|
method,
|
|
3856
|
-
chainStatus,
|
|
3857
|
-
errorKey: stringField$1(
|
|
3858
|
-
serverMessage: stringField$1(
|
|
4186
|
+
chainStatus: refusalStatus,
|
|
4187
|
+
errorKey: stringField$1(refusal, "ErrorKey"),
|
|
4188
|
+
serverMessage: stringField$1(refusal, "Message")
|
|
3859
4189
|
}, context);
|
|
3860
4190
|
if (!response.ok) throw new GalaSDKError("GATEWAY_HTTP_ERROR", {
|
|
3861
4191
|
method,
|
|
@@ -3880,11 +4210,123 @@ function receiptOf(method, uniqueKey, url, response, body) {
|
|
|
3880
4210
|
*/
|
|
3881
4211
|
async function submitWrite(transport, method, dto, uniqueKey) {
|
|
3882
4212
|
const payload = await signedPayload(transport.signer, method, dto);
|
|
3883
|
-
const url = `${transport.gatewayBaseUrl}/api/${TOKEN_CONTRACT}/${method}`;
|
|
4213
|
+
const url = `${transport.gatewayBaseUrl}/api/${TOKEN_CONTRACT$1}/${method}`;
|
|
3884
4214
|
const { response, body } = await post(transport, method, url, payload, uniqueKey);
|
|
3885
4215
|
return receiptOf(method, uniqueKey, url, response, body);
|
|
3886
4216
|
}
|
|
3887
4217
|
|
|
4218
|
+
//#endregion
|
|
4219
|
+
//#region src/writes/nft_fee.ts
|
|
4220
|
+
/** The contract every NFT write, and the DryRun that prices it, is sent to. */
|
|
4221
|
+
const TOKEN_CONTRACT = "asset/token-contract";
|
|
4222
|
+
/** The key prefix of the chain's fee receipts: the channel's (`GCFR`) and the paying user's (`GCUR`). */
|
|
4223
|
+
const CHANNEL_RECEIPT = "\0GCFR\0";
|
|
4224
|
+
const USER_RECEIPT = "\0GCUR\0";
|
|
4225
|
+
function isRecord(value) {
|
|
4226
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4227
|
+
}
|
|
4228
|
+
function stringField(record, key) {
|
|
4229
|
+
const value = record[key];
|
|
4230
|
+
return typeof value === "string" ? value : "";
|
|
4231
|
+
}
|
|
4232
|
+
/**
|
|
4233
|
+
* Reads a simulated write's fee from its DryRun `Data`. The simulated write must have SUCCEEDED
|
|
4234
|
+
* (`response.Status` 1): a write the chain would refuse still writes its fee receipt in the
|
|
4235
|
+
* simulation, and quoting that as the price of a write that will not happen would be a lie, so a
|
|
4236
|
+
* refusal (`PAYMENT_REQUIRED`, `INSUFFICIENT_MINT_ALLOWANCE`, ...) is `GATEWAY_READ_REJECTED`.
|
|
4237
|
+
*
|
|
4238
|
+
* The fee is what the paying user's receipts (`GCUR`) add up to; the channel receipt (`GCFR`) the
|
|
4239
|
+
* chain writes beside each is the same payment seen from the channel, so it is counted only when
|
|
4240
|
+
* no user receipt exists. No receipt at all is a fee of `"0"`: the write is free.
|
|
4241
|
+
*
|
|
4242
|
+
* @throws GalaSDKError `GATEWAY_READ_REJECTED` (the simulated write failed), `GATEWAY_READ_RESPONSE_INVALID`
|
|
4243
|
+
* (an answer that is not a DryRun result, or a receipt with no readable quantity).
|
|
4244
|
+
*/
|
|
4245
|
+
function feeQuoteOf(method, data, context) {
|
|
4246
|
+
const invalid = () => new GalaSDKError("GATEWAY_READ_RESPONSE_INVALID", { method: "DryRun" }, {
|
|
4247
|
+
...context,
|
|
4248
|
+
body: data
|
|
4249
|
+
});
|
|
4250
|
+
if (!isRecord(data) || !isRecord(data["response"]) || !isRecord(data["writes"])) throw invalid();
|
|
4251
|
+
const response = data["response"];
|
|
4252
|
+
if (response["Status"] !== 1) throw new GalaSDKError("GATEWAY_READ_REJECTED", {
|
|
4253
|
+
method: "DryRun",
|
|
4254
|
+
chainStatus: typeof response["Status"] === "number" ? response["Status"] : 0,
|
|
4255
|
+
errorKey: stringField(response, "ErrorKey"),
|
|
4256
|
+
serverMessage: stringField(response, "Message")
|
|
4257
|
+
}, {
|
|
4258
|
+
...context,
|
|
4259
|
+
body: response
|
|
4260
|
+
});
|
|
4261
|
+
const user = [];
|
|
4262
|
+
const channel = [];
|
|
4263
|
+
for (const [key, value] of Object.entries(data["writes"])) {
|
|
4264
|
+
const target = key.startsWith(USER_RECEIPT) ? user : key.startsWith(CHANNEL_RECEIPT) ? channel : void 0;
|
|
4265
|
+
if (target === void 0) continue;
|
|
4266
|
+
let receipt;
|
|
4267
|
+
try {
|
|
4268
|
+
receipt = typeof value === "string" ? JSON.parse(value) : void 0;
|
|
4269
|
+
} catch {
|
|
4270
|
+
throw invalid();
|
|
4271
|
+
}
|
|
4272
|
+
const quantity = isRecord(receipt) ? receipt["quantity"] : void 0;
|
|
4273
|
+
const feeCode = isRecord(receipt) ? receipt["feeCode"] : void 0;
|
|
4274
|
+
if (typeof quantity !== "string" || typeof feeCode !== "string") throw invalid();
|
|
4275
|
+
const amount = new BigNumber(quantity);
|
|
4276
|
+
if (!amount.isFinite() || amount.isNegative()) throw invalid();
|
|
4277
|
+
target.push({
|
|
4278
|
+
feeCode,
|
|
4279
|
+
quantity
|
|
4280
|
+
});
|
|
4281
|
+
}
|
|
4282
|
+
const receipts = user.length > 0 ? user : channel;
|
|
4283
|
+
return {
|
|
4284
|
+
method,
|
|
4285
|
+
fee: receipts.reduce((sum, receipt) => sum.plus(receipt.quantity), new BigNumber(0)).toFixed(),
|
|
4286
|
+
feeToken: "GALA",
|
|
4287
|
+
receipts
|
|
4288
|
+
};
|
|
4289
|
+
}
|
|
4290
|
+
/**
|
|
4291
|
+
* Prices `dto` as `method` with the gateway's DryRun: a signed wrapper
|
|
4292
|
+
* `{ callerPublicKey, method, dto, uniqueKey }` (the inner DTO travels unsigned, as an object, with
|
|
4293
|
+
* no `dtoOperation`: a DryRun runs it inside the wrapper, which is what is signed for `DryRun`)
|
|
4294
|
+
* and nothing is written to the chain. A DryRun changes nothing, so every failure of it is a
|
|
4295
|
+
* READ's (`write: false`) and a retry is safe.
|
|
4296
|
+
*
|
|
4297
|
+
* @throws GalaSDKError the signer's pre-send `SIGNING_FAILED`; `REQUEST_TIMEOUT` / `TRANSPORT_ERROR`
|
|
4298
|
+
* (`write: false`); `GATEWAY_HTTP_ERROR`; `GATEWAY_READ_REJECTED`; `GATEWAY_READ_RESPONSE_INVALID`.
|
|
4299
|
+
*/
|
|
4300
|
+
async function quoteNftFee(transport, uniqueKeyPrefix, callerPublicKey, method, dto) {
|
|
4301
|
+
const payload = await signedPayload(transport.signer, "DryRun", {
|
|
4302
|
+
callerPublicKey,
|
|
4303
|
+
method,
|
|
4304
|
+
dto,
|
|
4305
|
+
uniqueKey: createUniqueKey(uniqueKeyPrefix)
|
|
4306
|
+
});
|
|
4307
|
+
const url = `${transport.gatewayBaseUrl}/api/${TOKEN_CONTRACT}/DryRun`;
|
|
4308
|
+
const response = await requestWithTimeout(transport.requestor, url, {
|
|
4309
|
+
method: "POST",
|
|
4310
|
+
headers: buildRequestHeaders(transport.wire, { json: true }),
|
|
4311
|
+
body: payload
|
|
4312
|
+
}, transport.timeoutMs, { write: false });
|
|
4313
|
+
let answer;
|
|
4314
|
+
try {
|
|
4315
|
+
answer = await readResponseBody(response);
|
|
4316
|
+
} catch (cause) {
|
|
4317
|
+
throw new GalaSDKError("TRANSPORT_ERROR", { url }, {
|
|
4318
|
+
url,
|
|
4319
|
+
cause,
|
|
4320
|
+
write: false
|
|
4321
|
+
});
|
|
4322
|
+
}
|
|
4323
|
+
return feeQuoteOf(method, dataOf("DryRun", url, response, answer), {
|
|
4324
|
+
status: response.status,
|
|
4325
|
+
url,
|
|
4326
|
+
write: false
|
|
4327
|
+
});
|
|
4328
|
+
}
|
|
4329
|
+
|
|
3888
4330
|
//#endregion
|
|
3889
4331
|
//#region src/writes/token_ref.ts
|
|
3890
4332
|
/** A plain decimal: digits, optionally a fraction. No sign, exponent, hex, spaces or separators. */
|
|
@@ -4182,6 +4624,131 @@ var GatewayWrites = class {
|
|
|
4182
4624
|
const tokens = await this.resolveAll(checked);
|
|
4183
4625
|
return this.submit("UnlockToken", unlockTokenDto(this.walletAddress, tokens, uniqueKey, name), uniqueKey);
|
|
4184
4626
|
}
|
|
4627
|
+
/**
|
|
4628
|
+
* Claim an NFT collection name: authorize `authorizedUser` (default the writer) to create token
|
|
4629
|
+
* classes under it. The chain charges its claim fee (see {@link estimateNftFee}) and refuses a
|
|
4630
|
+
* name that is taken, whatever its casing.
|
|
4631
|
+
*
|
|
4632
|
+
* @throws GalaSDKError pre-send: `INVALID_NFT_INPUT`, `INVALID_WALLET_ADDRESS`,
|
|
4633
|
+
* `INVALID_UNIQUE_KEY`, `SIGNING_FAILED`; in flight: `GATEWAY_WRITE_OUTCOME_UNKNOWN` (check
|
|
4634
|
+
* `error.uniqueKey`; never resend under a fresh key); post-send: `GATEWAY_WRITE_REJECTED`,
|
|
4635
|
+
* `GATEWAY_HTTP_ERROR`, `GATEWAY_RESPONSE_INVALID` (also an answer for another collection).
|
|
4636
|
+
*/
|
|
4637
|
+
async claimNftCollection(input) {
|
|
4638
|
+
const prepared = this.prepareClaim(input);
|
|
4639
|
+
const receipt = await submitWrite(this.transport, "GrantNftCollectionAuthorization", prepared.dto, prepared.uniqueKey);
|
|
4640
|
+
return claimedCollection(receipt, prepared.collection);
|
|
4641
|
+
}
|
|
4642
|
+
/**
|
|
4643
|
+
* Create the token class of an NFT collection the writer is authorized for (`CreateNftCollection`).
|
|
4644
|
+
*
|
|
4645
|
+
* @throws GalaSDKError as {@link claimNftCollection}.
|
|
4646
|
+
*/
|
|
4647
|
+
async createNftCollection(input) {
|
|
4648
|
+
const prepared = this.prepareCreate(input);
|
|
4649
|
+
const receipt = await submitWrite(this.transport, "CreateNftCollection", prepared.dto, prepared.uniqueKey);
|
|
4650
|
+
return createdTokenClass(receipt, prepared.tokenClass);
|
|
4651
|
+
}
|
|
4652
|
+
/**
|
|
4653
|
+
* Mint 1 to 1000 NFTs of a token class the writer is a token authority of, to `owner` (default
|
|
4654
|
+
* the writer). The receipt lists the instances the chain created, as the chain answered them.
|
|
4655
|
+
*
|
|
4656
|
+
* @throws GalaSDKError as {@link claimNftCollection}.
|
|
4657
|
+
*/
|
|
4658
|
+
async mintNft(input) {
|
|
4659
|
+
const prepared = this.prepareMint(input);
|
|
4660
|
+
const receipt = await submitWrite(this.transport, prepared.method, prepared.dto, prepared.uniqueKey);
|
|
4661
|
+
return mintedInstances(receipt, prepared.tokenClass, prepared.quantity);
|
|
4662
|
+
}
|
|
4663
|
+
/**
|
|
4664
|
+
* What GalaChain's DryRun says an NFT write would cost, for the same input the write takes,
|
|
4665
|
+
* checked the same way, and with nothing written to the chain. The fee is the network's own
|
|
4666
|
+
* figure for this environment (it differs between stage and mainnet), never a constant.
|
|
4667
|
+
*
|
|
4668
|
+
* `callerPublicKey` is the writer's secp256k1 public key (hex): the chain's DryRun needs a caller
|
|
4669
|
+
* and a signer is not asked for its key. A write the chain would refuse (no authorization, no
|
|
4670
|
+
* balance, no mint allowance) is `GATEWAY_READ_REJECTED`, never a fee.
|
|
4671
|
+
*
|
|
4672
|
+
* @throws GalaSDKError the input checks of the write; `INVALID_NFT_INPUT` for a bad key;
|
|
4673
|
+
* `SIGNING_FAILED`; `REQUEST_TIMEOUT` / `TRANSPORT_ERROR` (`write: false`); `GATEWAY_HTTP_ERROR`;
|
|
4674
|
+
* `GATEWAY_READ_REJECTED`; `GATEWAY_READ_RESPONSE_INVALID`.
|
|
4675
|
+
*/
|
|
4676
|
+
async estimateNftFee(request, options) {
|
|
4677
|
+
const callerPublicKey = nftCallerPublicKey(options.callerPublicKey);
|
|
4678
|
+
const prepared = this.prepareFeeRequest(request);
|
|
4679
|
+
return await quoteNftFee(this.transport, this.uniqueKeyPrefix, callerPublicKey, prepared.method, prepared.dto);
|
|
4680
|
+
}
|
|
4681
|
+
prepareFeeRequest(request) {
|
|
4682
|
+
switch (request.write) {
|
|
4683
|
+
case "claimNftCollection": {
|
|
4684
|
+
const { dto } = this.prepareClaim(request);
|
|
4685
|
+
return {
|
|
4686
|
+
method: "GrantNftCollectionAuthorization",
|
|
4687
|
+
dto
|
|
4688
|
+
};
|
|
4689
|
+
}
|
|
4690
|
+
case "createNftCollection": {
|
|
4691
|
+
const { dto } = this.prepareCreate(request);
|
|
4692
|
+
return {
|
|
4693
|
+
method: "CreateNftCollection",
|
|
4694
|
+
dto
|
|
4695
|
+
};
|
|
4696
|
+
}
|
|
4697
|
+
case "mintNft": {
|
|
4698
|
+
const { method, dto } = this.prepareMint(request);
|
|
4699
|
+
return {
|
|
4700
|
+
method,
|
|
4701
|
+
dto
|
|
4702
|
+
};
|
|
4703
|
+
}
|
|
4704
|
+
}
|
|
4705
|
+
}
|
|
4706
|
+
/** Everything a claim needs, every input checked before the key is spent. */
|
|
4707
|
+
prepareClaim(input) {
|
|
4708
|
+
const collection = nftClassPart(input.collection, "collection");
|
|
4709
|
+
const authorizedUser = input.authorizedUser === void 0 ? this.walletAddress : galaChainUserRef(input.authorizedUser, "authorizedUser");
|
|
4710
|
+
const uniqueKey = this.uniqueKeyOf(input.uniqueKey);
|
|
4711
|
+
return {
|
|
4712
|
+
collection,
|
|
4713
|
+
uniqueKey,
|
|
4714
|
+
dto: claimNftCollectionDto(collection, authorizedUser, uniqueKey)
|
|
4715
|
+
};
|
|
4716
|
+
}
|
|
4717
|
+
prepareCreate(input) {
|
|
4718
|
+
const tokenClass = nftTokenClass(input);
|
|
4719
|
+
const fields = {
|
|
4720
|
+
name: nftText(input.name, "name"),
|
|
4721
|
+
symbol: nftString(input.symbol, "symbol"),
|
|
4722
|
+
description: nftText(input.description, "description"),
|
|
4723
|
+
image: nftText(input.image, "image"),
|
|
4724
|
+
maxSupply: nftWholeNumber(input.maxSupply, "maxSupply"),
|
|
4725
|
+
maxCapacity: input.maxCapacity === void 0 ? void 0 : nftWholeNumber(input.maxCapacity, "maxCapacity"),
|
|
4726
|
+
metadataAddress: input.metadataAddress === void 0 ? void 0 : nftText(input.metadataAddress, "metadataAddress"),
|
|
4727
|
+
contractAddress: input.contractAddress === void 0 ? void 0 : nftText(input.contractAddress, "contractAddress"),
|
|
4728
|
+
rarity: input.rarity === void 0 ? void 0 : nftText(input.rarity, "rarity"),
|
|
4729
|
+
authorities: input.authorities === void 0 ? void 0 : nftAuthorities(input.authorities)
|
|
4730
|
+
};
|
|
4731
|
+
const uniqueKey = this.uniqueKeyOf(input.uniqueKey);
|
|
4732
|
+
return {
|
|
4733
|
+
tokenClass,
|
|
4734
|
+
uniqueKey,
|
|
4735
|
+
dto: createNftCollectionDto(tokenClass, fields, uniqueKey)
|
|
4736
|
+
};
|
|
4737
|
+
}
|
|
4738
|
+
prepareMint(input) {
|
|
4739
|
+
const tokenClass = nftTokenClass(input);
|
|
4740
|
+
const quantity = nftMintQuantity(input.quantity, "quantity");
|
|
4741
|
+
const owner = input.owner === void 0 ? this.walletAddress : galaChainUserRef(input.owner, "owner");
|
|
4742
|
+
const method = input.existingAllowance === true ? "MintToken" : "MintTokenWithAllowance";
|
|
4743
|
+
const uniqueKey = this.uniqueKeyOf(input.uniqueKey);
|
|
4744
|
+
return {
|
|
4745
|
+
method,
|
|
4746
|
+
tokenClass,
|
|
4747
|
+
quantity,
|
|
4748
|
+
uniqueKey,
|
|
4749
|
+
dto: mintNftDto(method, tokenClass, owner, quantity, uniqueKey)
|
|
4750
|
+
};
|
|
4751
|
+
}
|
|
4185
4752
|
/** The caller's key, checked, or a fresh one. */
|
|
4186
4753
|
uniqueKeyOf(given) {
|
|
4187
4754
|
if (given === void 0) return createUniqueKey(this.uniqueKeyPrefix);
|
|
@@ -4392,113 +4959,6 @@ function parsePage(value, parse) {
|
|
|
4392
4959
|
};
|
|
4393
4960
|
}
|
|
4394
4961
|
|
|
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
4962
|
//#endregion
|
|
4503
4963
|
//#region src/reads/types.ts
|
|
4504
4964
|
/**
|
|
@@ -4877,6 +5337,120 @@ function notFoundOf(error) {
|
|
|
4877
5337
|
});
|
|
4878
5338
|
}
|
|
4879
5339
|
|
|
5340
|
+
//#endregion
|
|
5341
|
+
//#region src/reads/nft_collections.ts
|
|
5342
|
+
/** A read's collection name: 3 to 50 letters and digits. @throws GalaSDKError `INVALID_NFT_INPUT`. */
|
|
5343
|
+
function collectionName(name, field) {
|
|
5344
|
+
if (typeof name !== "string") throw new GalaSDKError("INVALID_NFT_INPUT", {
|
|
5345
|
+
field,
|
|
5346
|
+
reason: "not_a_string"
|
|
5347
|
+
});
|
|
5348
|
+
if (name === "") throw new GalaSDKError("INVALID_NFT_INPUT", {
|
|
5349
|
+
field,
|
|
5350
|
+
reason: "empty"
|
|
5351
|
+
});
|
|
5352
|
+
if (!/^[a-zA-Z0-9]{3,50}$/u.test(name)) throw new GalaSDKError("INVALID_NFT_INPUT", {
|
|
5353
|
+
field,
|
|
5354
|
+
reason: "bad_collection_name"
|
|
5355
|
+
});
|
|
5356
|
+
return name;
|
|
5357
|
+
}
|
|
5358
|
+
function validAddress(value) {
|
|
5359
|
+
try {
|
|
5360
|
+
galaChainUserRef(value, "address");
|
|
5361
|
+
return true;
|
|
5362
|
+
} catch {
|
|
5363
|
+
return false;
|
|
5364
|
+
}
|
|
5365
|
+
}
|
|
5366
|
+
function canonicalAddress(value) {
|
|
5367
|
+
return (validAddress(value) ? galaChainUserRef(value, "address") : value).toLowerCase();
|
|
5368
|
+
}
|
|
5369
|
+
/** NFT collection reads in Launchpad result shapes, using a shared gateway reader. */
|
|
5370
|
+
var NftCollectionReads = class {
|
|
5371
|
+
reads;
|
|
5372
|
+
constructor(reads) {
|
|
5373
|
+
this.reads = reads;
|
|
5374
|
+
}
|
|
5375
|
+
async fetchNftCollections(walletAddress) {
|
|
5376
|
+
const authorizedUser = galaChainUserRef(walletAddress, "walletAddress");
|
|
5377
|
+
return (await this.reads.fetchAllNftCollectionAuthorizations({ pageSize: 1e3 })).filter((row) => row.authorizedUsers.some((user) => canonicalAddress(user) === canonicalAddress(authorizedUser))).map((row) => ({
|
|
5378
|
+
authorizedUser,
|
|
5379
|
+
collection: row.collection
|
|
5380
|
+
}));
|
|
5381
|
+
}
|
|
5382
|
+
async isNftCollectionAvailable(name) {
|
|
5383
|
+
const collection = collectionName(name, "collection");
|
|
5384
|
+
return !(await this.reads.fetchAllNftCollectionAuthorizations({ pageSize: 1e3 })).some((row) => row.collection === collection);
|
|
5385
|
+
}
|
|
5386
|
+
async fetchNftTokenClasses(params) {
|
|
5387
|
+
collectionName(params.collection, "collection");
|
|
5388
|
+
return (await this.reads.fetchAllTokenClasses({
|
|
5389
|
+
collection: params.collection,
|
|
5390
|
+
category: params.category,
|
|
5391
|
+
type: params.type
|
|
5392
|
+
}, { pageSize: 1e3 })).map((row) => ({
|
|
5393
|
+
collection: row.collection,
|
|
5394
|
+
type: row.type,
|
|
5395
|
+
category: row.category,
|
|
5396
|
+
additionalKey: row.additionalKey,
|
|
5397
|
+
totalSupply: row.totalSupply,
|
|
5398
|
+
maxSupply: row.maxSupply,
|
|
5399
|
+
isNonFungible: row.isNonFungible,
|
|
5400
|
+
name: row.name,
|
|
5401
|
+
description: row.description,
|
|
5402
|
+
image: row.image,
|
|
5403
|
+
symbol: row.symbol,
|
|
5404
|
+
...row.rarity === void 0 ? {} : { rarity: row.rarity }
|
|
5405
|
+
}));
|
|
5406
|
+
}
|
|
5407
|
+
async fetchNftBalances(ownerAddress, collectionFilter) {
|
|
5408
|
+
const owner = galaChainUserRef(ownerAddress, "ownerAddress");
|
|
5409
|
+
return (await this.reads.fetchNftBalances({
|
|
5410
|
+
owner,
|
|
5411
|
+
collection: collectionFilter
|
|
5412
|
+
})).map((row) => ({
|
|
5413
|
+
owner: row.owner,
|
|
5414
|
+
collection: row.collection,
|
|
5415
|
+
category: row.category,
|
|
5416
|
+
type: row.type,
|
|
5417
|
+
additionalKey: row.additionalKey,
|
|
5418
|
+
instanceIds: [...row.instanceIds],
|
|
5419
|
+
totalOwned: row.instanceIds.length
|
|
5420
|
+
}));
|
|
5421
|
+
}
|
|
5422
|
+
};
|
|
5423
|
+
|
|
5424
|
+
//#endregion
|
|
5425
|
+
//#region src/reads/nft_fees.ts
|
|
5426
|
+
function getNftCollectionClaimFee() {
|
|
5427
|
+
return "10000";
|
|
5428
|
+
}
|
|
5429
|
+
function getNftTokenClassCreateFee() {
|
|
5430
|
+
return "1000";
|
|
5431
|
+
}
|
|
5432
|
+
/** Calculate the fixed fees for the requested collection and token-class operations. */
|
|
5433
|
+
function estimateNftOperationFees(params) {
|
|
5434
|
+
let totalFee = "0";
|
|
5435
|
+
const breakdown = {};
|
|
5436
|
+
if (params.claimCollection) {
|
|
5437
|
+
const fee = getNftCollectionClaimFee();
|
|
5438
|
+
breakdown.collectionClaim = fee;
|
|
5439
|
+
totalFee = String(BigInt(totalFee) + BigInt(fee));
|
|
5440
|
+
}
|
|
5441
|
+
if ((params.createTokenClasses ?? 0) > 0) {
|
|
5442
|
+
const count = params.createTokenClasses;
|
|
5443
|
+
const fee = getNftTokenClassCreateFee();
|
|
5444
|
+
breakdown.tokenClassCreate = fee;
|
|
5445
|
+
breakdown.tokenClassCount = count;
|
|
5446
|
+
totalFee = String(BigInt(totalFee) + BigInt(fee) * BigInt(count));
|
|
5447
|
+
}
|
|
5448
|
+
return {
|
|
5449
|
+
totalFee,
|
|
5450
|
+
breakdown
|
|
5451
|
+
};
|
|
5452
|
+
}
|
|
5453
|
+
|
|
4880
5454
|
//#endregion
|
|
4881
5455
|
//#region src/config/environments.ts
|
|
4882
5456
|
/**
|
|
@@ -4898,5 +5472,5 @@ const GALA_CHAIN_ENVIRONMENTS = Object.freeze({
|
|
|
4898
5472
|
});
|
|
4899
5473
|
|
|
4900
5474
|
//#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 };
|
|
5475
|
+
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_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
5476
|
//# sourceMappingURL=index.mjs.map
|