@gala-chain/gala-core-sdk 1.0.0 → 1.1.0-beta.0
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 +4 -2
- package/dist/bridge.cjs +6 -1
- package/dist/bridge.cjs.map +1 -1
- package/dist/bridge.mjs +7 -2
- package/dist/bridge.mjs.map +1 -1
- package/dist/browser/bridge.js +1 -1
- package/dist/browser/bridge.js.map +1 -1
- package/dist/browser/classes/error_catalog.js.map +1 -1
- package/dist/browser/classes/error_phase_table.js.map +1 -1
- package/dist/browser/classes/error_phases.js.map +1 -1
- package/dist/browser/classes/gala_sdk_error.js +1 -1
- package/dist/browser/classes/gala_sdk_error.js.map +1 -1
- package/dist/browser/classes/signers.js +1 -1
- package/dist/browser/classes/signers.js.map +1 -1
- package/dist/browser/config/environments.js.map +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/providers.js.map +1 -1
- package/dist/browser/react.js.map +1 -1
- package/dist/browser/reads/gateway_reads.js +1 -1
- package/dist/browser/reads/gateway_reads.js.map +1 -1
- package/dist/browser/reads/parse.js.map +1 -1
- package/dist/browser/reads/request.js.map +1 -1
- package/dist/browser/reads/types.js.map +1 -1
- package/dist/browser/utils/axios_requestor.js.map +1 -1
- package/dist/browser/utils/chain_dto_signing.js.map +1 -1
- package/dist/browser/utils/class_key.js.map +1 -1
- package/dist/browser/utils/dto_operation.js +2 -0
- package/dist/browser/utils/dto_operation.js.map +1 -0
- package/dist/browser/utils/eip712.js.map +1 -1
- package/dist/browser/utils/error_brand.js.map +1 -1
- package/dist/browser/utils/eth_address.js.map +1 -1
- package/dist/browser/utils/ethers_provider.js.map +1 -1
- package/dist/browser/utils/failure_outcomes.js.map +1 -1
- package/dist/browser/utils/failure_view.js.map +1 -1
- package/dist/browser/utils/fetch_failure.js.map +1 -1
- package/dist/browser/utils/pre_send.js +1 -1
- package/dist/browser/utils/pre_send.js.map +1 -1
- package/dist/browser/utils/signing.js.map +1 -1
- package/dist/browser/utils/transport.js +1 -1
- package/dist/browser/utils/transport.js.map +1 -1
- package/dist/browser/utils/typed_data.js.map +1 -1
- package/dist/browser/utils/unique_key.js.map +1 -1
- package/dist/browser/utils/unique_key_syntax.js.map +1 -1
- package/dist/browser/utils/wallet_keys.js.map +1 -1
- package/dist/browser/utils/wallet_rejection.js.map +1 -1
- package/dist/browser/version.js +1 -1
- package/dist/browser/version.js.map +1 -1
- package/dist/browser/wallet.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/identity.js.map +1 -1
- package/dist/browser/writes/lock.js.map +1 -1
- package/dist/browser/writes/submit.js +1 -1
- package/dist/browser/writes/submit.js.map +1 -1
- package/dist/browser/writes/token_ref.js.map +1 -1
- package/dist/browser/writes/transfer.js.map +1 -1
- package/dist/browser/writes/types.js.map +1 -1
- package/dist/index.cjs +119 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +95 -3
- package/dist/index.d.ts +95 -3
- package/dist/index.mjs +117 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +30 -30
- /package/dist/browser/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/defineProperty.js +0 -0
- /package/dist/browser/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/toPrimitive.js +0 -0
- /package/dist/browser/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/toPropertyKey.js +0 -0
- /package/dist/browser/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/typeof.js +0 -0
package/dist/index.cjs
CHANGED
|
@@ -2549,6 +2549,110 @@ async function signTypedDataPayload(privateKey, payload) {
|
|
|
2549
2549
|
return withPrivateKey(privateKey, (key) => `0x${signHash(key, digest)}`);
|
|
2550
2550
|
}
|
|
2551
2551
|
|
|
2552
|
+
//#endregion
|
|
2553
|
+
//#region src/utils/dto_operation.ts
|
|
2554
|
+
/**
|
|
2555
|
+
* The chain's operation ids for the GalaChain contracts the gateway routes, from the gateway's
|
|
2556
|
+
* `dtoOperationMap` (the `dtoOperation` / API path table of the GalaChain platform team,
|
|
2557
|
+
* 2026-10-27). The chain refuses a signed DTO whose `dtoOperation` is not exactly the operation it
|
|
2558
|
+
* is called through ("The dto was signed to call X operation, but the current operation is Y"), so
|
|
2559
|
+
* the URL a write is POSTed to and the `dtoOperation` it carries both come from this one table and
|
|
2560
|
+
* can never disagree.
|
|
2561
|
+
*
|
|
2562
|
+
* `dtoOperation` is a SIGNED field: it is part of the DTO before the signer sees it, never added by
|
|
2563
|
+
* a signer or after the signature.
|
|
2564
|
+
*/
|
|
2565
|
+
/** `<channel>/<contract route>`: the path after `/api/` (or `/v1/chain/`) a contract is served at. */
|
|
2566
|
+
const CHAIN_CONTRACT_OPERATION_PREFIXES = {
|
|
2567
|
+
"asset/public-key-contract": "asset-channel_basic-asset_PublicKeyContract",
|
|
2568
|
+
"asset/token-contract": "asset-channel_basic-asset_GalaChainToken",
|
|
2569
|
+
"asset/fee-contract": "asset-channel_basic-asset_GalaChainFee",
|
|
2570
|
+
"asset/launchpad-contract": "asset-channel_basic-asset_Launchpad",
|
|
2571
|
+
"asset/dexv3-contract": "asset-channel_basic-asset_DexV3Contract",
|
|
2572
|
+
"asset/dex-contract": "asset-channel_basic-asset_GalaChainDex",
|
|
2573
|
+
"asset/registrar-contract": "asset-channel_basic-asset_RegistrarContract",
|
|
2574
|
+
"asset/staking-contract": "asset-channel_basic-asset_StakingContract",
|
|
2575
|
+
"asset/wallet-attributes-contract": "asset-channel_basic-asset_WalletAttributesContract",
|
|
2576
|
+
"asset/bridge-contract": "asset-channel_bridge-chaincode_BridgeContract",
|
|
2577
|
+
"asset/bridge-public-key-contract": "asset-channel_bridge-chaincode_PublicKeyContract",
|
|
2578
|
+
"asset/alm-contract": "asset-channel_basic-asset_ALMContract",
|
|
2579
|
+
"spidertanks/contract": "spidertanks-channel_spidertanks_SpiderTanks",
|
|
2580
|
+
"music/public-key-contract": "music_music_PublicKeyContract",
|
|
2581
|
+
"music/music-contract": "music_music_GalaMusic",
|
|
2582
|
+
"music/token-contract": "music_music_GalaChainToken",
|
|
2583
|
+
"pokergo/pokergo-contract": "pokergo_pokergo_PokerGo",
|
|
2584
|
+
"pokergo/public-key-contract": "pokergo_pokergo_PublicKeyContract",
|
|
2585
|
+
"pokergo/token-contract": "pokergo_pokergo_GalaChainToken",
|
|
2586
|
+
"championsarena/public-key-contract": "championsarena_championsarena_PublicKeyContract",
|
|
2587
|
+
"championsarena/champions-arena": "championsarena_championsarena_ChampionsArenaContract",
|
|
2588
|
+
"championsarena/token-contract": "championsarena_championsarena_GalaChainToken",
|
|
2589
|
+
"superior/public-key-contract": "superior_superior_PublicKeyContract",
|
|
2590
|
+
"superior/token-contract": "superior_superior_GalaChainToken",
|
|
2591
|
+
"superior/superior": "superior_superior_Product",
|
|
2592
|
+
"legacy/public-key-contract": "legacy_legacy_PublicKeyContract",
|
|
2593
|
+
"legacy/token-contract": "legacy_legacy_GalaChainToken",
|
|
2594
|
+
"legacy/legacy": "legacy_legacy_Legacy",
|
|
2595
|
+
"eternalparadox/public-key-contract": "eternalparadox_eternalparadox_PublicKeyContract",
|
|
2596
|
+
"eternalparadox/token-contract": "eternalparadox_eternalparadox_GalaChainToken",
|
|
2597
|
+
"eternalparadox/eternalparadox": "eternalparadox_eternalparadox_EternalParadox",
|
|
2598
|
+
"echoesofempire/public-key-contract": "echoesofempire_echoesofempire_PublicKeyContract",
|
|
2599
|
+
"echoesofempire/token-contract": "echoesofempire_echoesofempire_GalaChainToken",
|
|
2600
|
+
"echoesofempire/echoesofempire-contract": "echoesofempire_echoesofempire_EchoesOfEmpire",
|
|
2601
|
+
"node/public-key-contract": "node_node_PublicKeyContract",
|
|
2602
|
+
"node/token-contract": "node_node_GalaChainToken",
|
|
2603
|
+
"node/node-contract": "node_node_Product",
|
|
2604
|
+
"townstar/product-contract": "townstar_townstar_TownStar",
|
|
2605
|
+
"townstar/token-contract": "townstar_townstar_GalaChainToken",
|
|
2606
|
+
"townstar/public-key-contract": "townstar_townstar_PublicKeyContract",
|
|
2607
|
+
"mirandus/public-key-contract": "mirandus_mirandus_PublicKeyContract",
|
|
2608
|
+
"mirandus/token-contract": "mirandus_mirandus_GalaChainToken",
|
|
2609
|
+
"mirandus/mirandus-contract": "mirandus_mirandus_Product",
|
|
2610
|
+
"galafilm/public-key-contract": "galafilm_galafilm_PublicKeyContract",
|
|
2611
|
+
"galafilm/token-contract": "galafilm_galafilm_GalaChainToken",
|
|
2612
|
+
"galafilm/galafilm-contract": "galafilm_galafilm_Product",
|
|
2613
|
+
"lastexpedition/public-key-contract": "lastexpedition_lastexpedition_PublicKeyContract",
|
|
2614
|
+
"lastexpedition/token-contract": "lastexpedition_lastexpedition_GalaChainToken",
|
|
2615
|
+
"lastexpedition/lastexpedition-contract": "lastexpedition_lastexpedition_Product",
|
|
2616
|
+
"legendsreborn/public-key-contract": "legendsreborn_legendsreborn_PublicKeyContract",
|
|
2617
|
+
"legendsreborn/token-contract": "legendsreborn_legendsreborn_GalaChainToken",
|
|
2618
|
+
"legendsreborn/legendsreborn-contract": "legendsreborn_legendsreborn_Product",
|
|
2619
|
+
"thewalkingdeadempires/public-key-contract": "thewalkingdeadempires_thewalkingdeadempires_PublicKeyContract",
|
|
2620
|
+
"thewalkingdeadempires/token-contract": "thewalkingdeadempires_thewalkingdeadempires_GalaChainToken",
|
|
2621
|
+
"thewalkingdeadempires/thewalkingdeadempires-contract": "thewalkingdeadempires_thewalkingdeadempires_Product",
|
|
2622
|
+
"vox/public-key-contract": "vox_vox_PublicKeyContract",
|
|
2623
|
+
"vox/token-contract": "vox_vox_GalaChainToken",
|
|
2624
|
+
"vox/auction-contract": "vox_vox_AuctionContract",
|
|
2625
|
+
"vox/phase-contract": "vox_vox_PhaseContract",
|
|
2626
|
+
"vox/vox-contract": "vox_vox_VOXTokenContract",
|
|
2627
|
+
"vox/resources-contract": "vox_vox_VOXResourceToken"
|
|
2628
|
+
};
|
|
2629
|
+
/** The `dtoOperation` of `method` on the contract served at `contractPath`. */
|
|
2630
|
+
function dtoOperationOf(contractPath, method) {
|
|
2631
|
+
return `${CHAIN_CONTRACT_OPERATION_PREFIXES[contractPath]}:${method}`;
|
|
2632
|
+
}
|
|
2633
|
+
/**
|
|
2634
|
+
* `dto` with its `dtoOperation` set for `method` on `contractPath`. A DTO that already names a
|
|
2635
|
+
* different operation is refused: it was built for another call, and sending it would be rejected
|
|
2636
|
+
* by the chain after the signer had already signed it.
|
|
2637
|
+
*
|
|
2638
|
+
* @throws GalaSDKError SIGNING_FAILED when `dto.dtoOperation` is set and is not the operation of this call.
|
|
2639
|
+
*/
|
|
2640
|
+
function withDtoOperation(contractPath, method, dto) {
|
|
2641
|
+
const dtoOperation = dtoOperationOf(contractPath, method);
|
|
2642
|
+
const present = dto["dtoOperation"];
|
|
2643
|
+
if (present !== void 0 && present !== dtoOperation) throw new GalaSDKError("SIGNING_FAILED", {
|
|
2644
|
+
method,
|
|
2645
|
+
reason: "failed"
|
|
2646
|
+
}, { cause: {
|
|
2647
|
+
dtoOperation: present,
|
|
2648
|
+
expected: dtoOperation
|
|
2649
|
+
} });
|
|
2650
|
+
return {
|
|
2651
|
+
...dto,
|
|
2652
|
+
dtoOperation
|
|
2653
|
+
};
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2552
2656
|
//#endregion
|
|
2553
2657
|
//#region src/utils/wallet_rejection.ts
|
|
2554
2658
|
/**
|
|
@@ -2678,7 +2782,8 @@ function walletDeclineCode(value) {
|
|
|
2678
2782
|
* cannot know what the server did with the write.
|
|
2679
2783
|
*/
|
|
2680
2784
|
/**
|
|
2681
|
-
* Signs a DTO with the app's signer
|
|
2785
|
+
* Signs a DTO with the app's signer, after setting its `dtoOperation` to the operation of `method`
|
|
2786
|
+
* on the contract at `contractPath` (the chain refuses a DTO signed for another operation). Whatever the signer throws that is not already an SDK error
|
|
2682
2787
|
* (a locked wallet, an unreachable extension, a wallet that declined) is `SIGNING_FAILED`
|
|
2683
2788
|
* (`reason` `user_rejected` or `failed`, the original as `cause`), and a signer that returns
|
|
2684
2789
|
* something other than an object is `SIGNING_FAILED` too: both are pre-send, so a retry is safe.
|
|
@@ -2686,10 +2791,10 @@ function walletDeclineCode(value) {
|
|
|
2686
2791
|
*
|
|
2687
2792
|
* @throws GalaSDKError SIGNING_FAILED, or the SDK error the signer itself threw.
|
|
2688
2793
|
*/
|
|
2689
|
-
async function signPreSend(signer, method, dto) {
|
|
2794
|
+
async function signPreSend(signer, contractPath, method, dto) {
|
|
2690
2795
|
let signed;
|
|
2691
2796
|
try {
|
|
2692
|
-
signed = await signer.signObject(method, dto);
|
|
2797
|
+
signed = await signer.signObject(method, withDtoOperation(contractPath, method, dto));
|
|
2693
2798
|
} catch (cause) {
|
|
2694
2799
|
if (isGalaError(cause)) throw cause;
|
|
2695
2800
|
const reason = isWalletUserRejection(cause) ? "user_rejected" : "failed";
|
|
@@ -2715,7 +2820,7 @@ async function signPreSend(signer, method, dto) {
|
|
|
2715
2820
|
* fallback. It is the version in the default `User-Agent` (`GalaChain-SDK/<version>`) of every SDK
|
|
2716
2821
|
* request, whichever product SDK sends it.
|
|
2717
2822
|
*/
|
|
2718
|
-
const GALA_CORE_SDK_VERSION = "1.0.0";
|
|
2823
|
+
const GALA_CORE_SDK_VERSION = "1.1.0-beta.0";
|
|
2719
2824
|
|
|
2720
2825
|
//#endregion
|
|
2721
2826
|
//#region src/utils/transport.ts
|
|
@@ -2776,7 +2881,7 @@ function buildRequestHeaders(wire, parts = {}) {
|
|
|
2776
2881
|
entries.set(name.toLowerCase(), [name, value]);
|
|
2777
2882
|
}
|
|
2778
2883
|
};
|
|
2779
|
-
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.0.0"}` });
|
|
2884
|
+
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.0"}` });
|
|
2780
2885
|
put(parts.defaults);
|
|
2781
2886
|
put(wire === null || wire === void 0 ? void 0 : wire.headers);
|
|
2782
2887
|
if (parts.json === true && !entries.has("content-type")) put({ "Content-Type": "application/json" });
|
|
@@ -3611,6 +3716,8 @@ function unlockTokenDto(owner, tokens, uniqueKey, name) {
|
|
|
3611
3716
|
|
|
3612
3717
|
//#endregion
|
|
3613
3718
|
//#region src/writes/submit.ts
|
|
3719
|
+
/** The contract every write of this module is sent to (its URL path and its `dtoOperation`). */
|
|
3720
|
+
const TOKEN_CONTRACT = "asset/token-contract";
|
|
3614
3721
|
/**
|
|
3615
3722
|
* The fields a signer may add next to the DTO: the signature and, for the wallet schemes, the
|
|
3616
3723
|
* personal-sign `prefix` and the EIP-712 `types` / `domain`. Nothing else: a signer that inserts a
|
|
@@ -3640,8 +3747,9 @@ function carriesExactlyTheDto(builtDto, signed) {
|
|
|
3640
3747
|
* `SIGNING_FAILED` (pre-send: nothing was transmitted, a retry is safe).
|
|
3641
3748
|
*/
|
|
3642
3749
|
async function signedPayload(signer, method, dto) {
|
|
3643
|
-
const
|
|
3644
|
-
const
|
|
3750
|
+
const operated = withDtoOperation(TOKEN_CONTRACT, method, dto);
|
|
3751
|
+
const builtDto = serialize(operated);
|
|
3752
|
+
const signed = await signPreSend(signer, TOKEN_CONTRACT, method, operated);
|
|
3645
3753
|
let payload;
|
|
3646
3754
|
try {
|
|
3647
3755
|
payload = carriesExactlyTheDto(builtDto, signed) ? JSON.stringify(signed) : void 0;
|
|
@@ -3752,7 +3860,7 @@ function receiptOf(method, uniqueKey, url, response, body) {
|
|
|
3752
3860
|
*/
|
|
3753
3861
|
async function submitWrite(transport, method, dto, uniqueKey) {
|
|
3754
3862
|
const payload = await signedPayload(transport.signer, method, dto);
|
|
3755
|
-
const url = `${transport.gatewayBaseUrl}/api
|
|
3863
|
+
const url = `${transport.gatewayBaseUrl}/api/${TOKEN_CONTRACT}/${method}`;
|
|
3756
3864
|
const { response, body } = await post(transport, method, url, payload, uniqueKey);
|
|
3757
3865
|
return receiptOf(method, uniqueKey, url, response, body);
|
|
3758
3866
|
}
|
|
@@ -4772,6 +4880,7 @@ exports.BRIDGE_DEPOSIT_STEPS = BRIDGE_DEPOSIT_STEPS;
|
|
|
4772
4880
|
exports.BRIDGE_NETWORKS = BRIDGE_NETWORKS;
|
|
4773
4881
|
exports.BRIDGE_OUT_STEPS = BRIDGE_OUT_STEPS;
|
|
4774
4882
|
exports.BrowserWalletSigner = BrowserWalletSigner;
|
|
4883
|
+
exports.CHAIN_CONTRACT_OPERATION_PREFIXES = CHAIN_CONTRACT_OPERATION_PREFIXES;
|
|
4775
4884
|
exports.DEFAULT_UNIQUE_KEY_PREFIX = DEFAULT_UNIQUE_KEY_PREFIX;
|
|
4776
4885
|
exports.EIP712_CAPABLE_METHODS = EIP712_CAPABLE_METHODS;
|
|
4777
4886
|
exports.FAILURE_OUTCOMES = FAILURE_OUTCOMES;
|
|
@@ -4815,6 +4924,7 @@ exports.compositeKeyOf = compositeKeyOf;
|
|
|
4815
4924
|
exports.createLazyPrivateKeySigner = createLazyPrivateKeySigner;
|
|
4816
4925
|
exports.createUniqueKey = createUniqueKey;
|
|
4817
4926
|
exports.createWallet = createWallet;
|
|
4927
|
+
exports.dtoOperationOf = dtoOperationOf;
|
|
4818
4928
|
exports.eip1193ProviderFromEthers = eip1193ProviderFromEthers;
|
|
4819
4929
|
exports.eip712DomainFor = eip712DomainFor;
|
|
4820
4930
|
exports.ethAddressOfPrivateKey = ethAddressOfPrivateKey;
|
|
@@ -4872,6 +4982,7 @@ exports.tryParseTokenClassKey = tryParseTokenClassKey;
|
|
|
4872
4982
|
exports.validateTimeoutMs = validateTimeoutMs;
|
|
4873
4983
|
exports.validateWalletInput = validateWalletInput;
|
|
4874
4984
|
exports.walletDeclineCode = walletDeclineCode;
|
|
4985
|
+
exports.withDtoOperation = withDtoOperation;
|
|
4875
4986
|
exports.withGalaWalletIdentity = withGalaWalletIdentity;
|
|
4876
4987
|
exports.withPrivateKey = withPrivateKey;
|
|
4877
4988
|
//# sourceMappingURL=index.cjs.map
|