@mysten/sui 2.16.2 → 2.16.3
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/CHANGELOG.md +13 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/bcs/index.d.mts +20 -20
- package/dist/client/core-resolver.mjs +21 -12
- package/dist/client/core-resolver.mjs.map +1 -1
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
- package/dist/transactions/Transaction.d.mts +10 -10
- package/dist/transactions/data/internal.d.mts +109 -109
- package/dist/transactions/data/internal.d.mts.map +1 -1
- package/dist/transactions/data/v1.d.mts +220 -220
- package/dist/transactions/data/v1.d.mts.map +1 -1
- package/dist/transactions/data/v2.d.mts +16 -16
- package/dist/transactions/data/v2.d.mts.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/dist/zklogin/bcs.d.mts.map +1 -1
- package/package.json +1 -1
- package/src/client/core-resolver.ts +48 -13
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @mysten/sui.js
|
|
2
2
|
|
|
3
|
+
## 2.16.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5900ad5: Always pass a `ValidDuring` expiration as a simulate-only override when the resolver has
|
|
8
|
+
to compute a gas budget and the caller hasn't set an expiration. The simulate inside
|
|
9
|
+
`setGasBudget` runs with `payment: []`, and the validator's replay-protection check rejects
|
|
10
|
+
payment-less transactions that lack both a `ValidDuring` expiration and an address-owned input.
|
|
11
|
+
Previously this affected gasless / free-tier PTBs over JSON-RPC ("Transactions must either have
|
|
12
|
+
address-owned inputs, or a ValidDuring expiration with at most two epochs of validity"); it also
|
|
13
|
+
affects any PTB whose only inputs are shared objects, pure args, or balance withdrawals. The
|
|
14
|
+
override is scoped to the simulate request — the final transaction's expiration is unchanged.
|
|
15
|
+
|
|
3
16
|
## 2.16.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/bcs/bcs.d.mts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { TypeTag as TypeTag$1 } from "./types.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _mysten_bcs823 from "@mysten/bcs";
|
|
3
3
|
import { BcsType } from "@mysten/bcs";
|
|
4
4
|
|
|
5
5
|
//#region src/bcs/bcs.d.ts
|
|
6
6
|
declare const TypeTag: BcsType<string, string | TypeTag$1, string>;
|
|
7
|
-
declare function IntentMessage<T extends BcsType<any>>(T: T):
|
|
8
|
-
intent:
|
|
9
|
-
scope:
|
|
7
|
+
declare function IntentMessage<T extends BcsType<any>>(T: T): _mysten_bcs823.BcsStruct<{
|
|
8
|
+
intent: _mysten_bcs823.BcsStruct<{
|
|
9
|
+
scope: _mysten_bcs823.BcsEnum<{
|
|
10
10
|
TransactionData: null;
|
|
11
11
|
TransactionEffects: null;
|
|
12
12
|
CheckpointSummary: null;
|
|
13
13
|
PersonalMessage: null;
|
|
14
14
|
}, "IntentScope">;
|
|
15
|
-
version:
|
|
15
|
+
version: _mysten_bcs823.BcsEnum<{
|
|
16
16
|
V0: null;
|
|
17
17
|
}, "IntentVersion">;
|
|
18
|
-
appId:
|
|
18
|
+
appId: _mysten_bcs823.BcsEnum<{
|
|
19
19
|
Sui: null;
|
|
20
20
|
}, "AppId">;
|
|
21
21
|
}, string>;
|
package/dist/bcs/index.d.mts
CHANGED
|
@@ -545,7 +545,7 @@ declare const suiBcs: {
|
|
|
545
545
|
version: string;
|
|
546
546
|
digest: string;
|
|
547
547
|
};
|
|
548
|
-
}, "
|
|
548
|
+
}, "ImmOrOwnedObject" | "SharedObject" | "Receiving">;
|
|
549
549
|
FundsWithdrawal: {
|
|
550
550
|
reservation: {
|
|
551
551
|
MaxAmountU64: string;
|
|
@@ -560,7 +560,7 @@ declare const suiBcs: {
|
|
|
560
560
|
Sponsor: true;
|
|
561
561
|
}, "Sender" | "Sponsor">;
|
|
562
562
|
};
|
|
563
|
-
}, "
|
|
563
|
+
}, "Pure" | "Object" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
|
|
564
564
|
Pure: {
|
|
565
565
|
bytes: string | Uint8Array<ArrayBufferLike>;
|
|
566
566
|
};
|
|
@@ -793,7 +793,7 @@ declare const suiBcs: {
|
|
|
793
793
|
TransactionEffects: true;
|
|
794
794
|
CheckpointSummary: true;
|
|
795
795
|
PersonalMessage: true;
|
|
796
|
-
}, "
|
|
796
|
+
}, "TransactionData" | "TransactionEffects" | "CheckpointSummary" | "PersonalMessage">;
|
|
797
797
|
version: {
|
|
798
798
|
V0: true;
|
|
799
799
|
$kind: "V0";
|
|
@@ -827,7 +827,7 @@ declare const suiBcs: {
|
|
|
827
827
|
version: string;
|
|
828
828
|
digest: string;
|
|
829
829
|
};
|
|
830
|
-
}, "
|
|
830
|
+
}, "ImmOrOwnedObject" | "SharedObject" | "Receiving">;
|
|
831
831
|
FundsWithdrawal: {
|
|
832
832
|
reservation: {
|
|
833
833
|
MaxAmountU64: string;
|
|
@@ -842,7 +842,7 @@ declare const suiBcs: {
|
|
|
842
842
|
Sponsor: true;
|
|
843
843
|
}, "Sender" | "Sponsor">;
|
|
844
844
|
};
|
|
845
|
-
}, "
|
|
845
|
+
}, "Pure" | "Object" | "FundsWithdrawal">[];
|
|
846
846
|
commands: _mysten_bcs0.EnumOutputShapeWithKeys<{
|
|
847
847
|
MoveCall: {
|
|
848
848
|
package: string;
|
|
@@ -950,7 +950,7 @@ declare const suiBcs: {
|
|
|
950
950
|
chain: string;
|
|
951
951
|
nonce: number;
|
|
952
952
|
};
|
|
953
|
-
}, "
|
|
953
|
+
}, "None" | "Epoch" | "ValidDuring">;
|
|
954
954
|
};
|
|
955
955
|
$kind: "V1";
|
|
956
956
|
};
|
|
@@ -1193,7 +1193,7 @@ declare const suiBcs: {
|
|
|
1193
1193
|
version: string;
|
|
1194
1194
|
digest: string;
|
|
1195
1195
|
};
|
|
1196
|
-
}, "
|
|
1196
|
+
}, "ImmOrOwnedObject" | "SharedObject" | "Receiving">;
|
|
1197
1197
|
FundsWithdrawal: {
|
|
1198
1198
|
reservation: {
|
|
1199
1199
|
MaxAmountU64: string;
|
|
@@ -1208,7 +1208,7 @@ declare const suiBcs: {
|
|
|
1208
1208
|
Sponsor: true;
|
|
1209
1209
|
}, "Sender" | "Sponsor">;
|
|
1210
1210
|
};
|
|
1211
|
-
}, "
|
|
1211
|
+
}, "Pure" | "Object" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
|
|
1212
1212
|
Pure: {
|
|
1213
1213
|
bytes: string | Uint8Array<ArrayBufferLike>;
|
|
1214
1214
|
};
|
|
@@ -1508,7 +1508,7 @@ declare const suiBcs: {
|
|
|
1508
1508
|
version: string;
|
|
1509
1509
|
digest: string;
|
|
1510
1510
|
};
|
|
1511
|
-
}, "
|
|
1511
|
+
}, "ImmOrOwnedObject" | "SharedObject" | "Receiving">;
|
|
1512
1512
|
FundsWithdrawal: {
|
|
1513
1513
|
reservation: {
|
|
1514
1514
|
MaxAmountU64: string;
|
|
@@ -1523,7 +1523,7 @@ declare const suiBcs: {
|
|
|
1523
1523
|
Sponsor: true;
|
|
1524
1524
|
}, "Sender" | "Sponsor">;
|
|
1525
1525
|
};
|
|
1526
|
-
}, "
|
|
1526
|
+
}, "Pure" | "Object" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
|
|
1527
1527
|
Pure: {
|
|
1528
1528
|
bytes: string | Uint8Array<ArrayBufferLike>;
|
|
1529
1529
|
};
|
|
@@ -1799,7 +1799,7 @@ declare const suiBcs: {
|
|
|
1799
1799
|
version: string;
|
|
1800
1800
|
digest: string;
|
|
1801
1801
|
};
|
|
1802
|
-
}, "
|
|
1802
|
+
}, "ImmOrOwnedObject" | "SharedObject" | "Receiving">;
|
|
1803
1803
|
FundsWithdrawal: {
|
|
1804
1804
|
reservation: {
|
|
1805
1805
|
MaxAmountU64: string;
|
|
@@ -1814,7 +1814,7 @@ declare const suiBcs: {
|
|
|
1814
1814
|
Sponsor: true;
|
|
1815
1815
|
}, "Sender" | "Sponsor">;
|
|
1816
1816
|
};
|
|
1817
|
-
}, "
|
|
1817
|
+
}, "Pure" | "Object" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
|
|
1818
1818
|
Pure: {
|
|
1819
1819
|
bytes: string | Uint8Array<ArrayBufferLike>;
|
|
1820
1820
|
};
|
|
@@ -2271,7 +2271,7 @@ declare const suiBcs: {
|
|
|
2271
2271
|
startVersion: string;
|
|
2272
2272
|
owner: string;
|
|
2273
2273
|
};
|
|
2274
|
-
}, "AddressOwner" | "
|
|
2274
|
+
}, "AddressOwner" | "ObjectOwner" | "Shared" | "Immutable" | "ConsensusAddressOwner">][], Iterable<readonly [{
|
|
2275
2275
|
objectId: string | Uint8Array<ArrayBufferLike>;
|
|
2276
2276
|
version: string | number | bigint;
|
|
2277
2277
|
digest: string;
|
|
@@ -2304,7 +2304,7 @@ declare const suiBcs: {
|
|
|
2304
2304
|
startVersion: string;
|
|
2305
2305
|
owner: string;
|
|
2306
2306
|
};
|
|
2307
|
-
}, "AddressOwner" | "
|
|
2307
|
+
}, "AddressOwner" | "ObjectOwner" | "Shared" | "Immutable" | "ConsensusAddressOwner">][], Iterable<readonly [{
|
|
2308
2308
|
objectId: string | Uint8Array<ArrayBufferLike>;
|
|
2309
2309
|
version: string | number | bigint;
|
|
2310
2310
|
digest: string;
|
|
@@ -2337,7 +2337,7 @@ declare const suiBcs: {
|
|
|
2337
2337
|
startVersion: string;
|
|
2338
2338
|
owner: string;
|
|
2339
2339
|
};
|
|
2340
|
-
}, "AddressOwner" | "
|
|
2340
|
+
}, "AddressOwner" | "ObjectOwner" | "Shared" | "Immutable" | "ConsensusAddressOwner">][], Iterable<readonly [{
|
|
2341
2341
|
objectId: string | Uint8Array<ArrayBufferLike>;
|
|
2342
2342
|
version: string | number | bigint;
|
|
2343
2343
|
digest: string;
|
|
@@ -2604,7 +2604,7 @@ declare const suiBcs: {
|
|
|
2604
2604
|
startVersion: string;
|
|
2605
2605
|
owner: string;
|
|
2606
2606
|
};
|
|
2607
|
-
}, "AddressOwner" | "
|
|
2607
|
+
}, "AddressOwner" | "ObjectOwner" | "Shared" | "Immutable" | "ConsensusAddressOwner">];
|
|
2608
2608
|
}, "NotExist" | "Exist">;
|
|
2609
2609
|
outputState: _mysten_bcs0.EnumOutputShapeWithKeys<{
|
|
2610
2610
|
NotExist: true;
|
|
@@ -2619,7 +2619,7 @@ declare const suiBcs: {
|
|
|
2619
2619
|
startVersion: string;
|
|
2620
2620
|
owner: string;
|
|
2621
2621
|
};
|
|
2622
|
-
}, "AddressOwner" | "
|
|
2622
|
+
}, "AddressOwner" | "ObjectOwner" | "Shared" | "Immutable" | "ConsensusAddressOwner">];
|
|
2623
2623
|
PackageWrite: [string, string];
|
|
2624
2624
|
AccumulatorWriteV1: {
|
|
2625
2625
|
address: {
|
|
@@ -2705,7 +2705,7 @@ declare const suiBcs: {
|
|
|
2705
2705
|
ReadConsensusStreamEnded: string;
|
|
2706
2706
|
Cancelled: string;
|
|
2707
2707
|
PerEpochConfig: true;
|
|
2708
|
-
}, "
|
|
2708
|
+
}, "ReadOnlyRoot" | "MutateConsensusStreamEnded" | "ReadConsensusStreamEnded" | "Cancelled" | "PerEpochConfig">][], Iterable<readonly [string | Uint8Array<ArrayBufferLike>, _mysten_bcs0.EnumInputShape<{
|
|
2709
2709
|
ReadOnlyRoot: readonly [string | number | bigint, string];
|
|
2710
2710
|
MutateConsensusStreamEnded: string | number | bigint;
|
|
2711
2711
|
ReadConsensusStreamEnded: string | number | bigint;
|
|
@@ -2751,7 +2751,7 @@ declare const suiBcs: {
|
|
|
2751
2751
|
version: string;
|
|
2752
2752
|
digest: string;
|
|
2753
2753
|
};
|
|
2754
|
-
}, "
|
|
2754
|
+
}, "ImmOrOwnedObject" | "SharedObject" | "Receiving">;
|
|
2755
2755
|
FundsWithdrawal: {
|
|
2756
2756
|
reservation: {
|
|
2757
2757
|
MaxAmountU64: string;
|
|
@@ -2766,7 +2766,7 @@ declare const suiBcs: {
|
|
|
2766
2766
|
Sponsor: true;
|
|
2767
2767
|
}, "Sender" | "Sponsor">;
|
|
2768
2768
|
};
|
|
2769
|
-
}, "
|
|
2769
|
+
}, "Pure" | "Object" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
|
|
2770
2770
|
Pure: {
|
|
2771
2771
|
bytes: string | Uint8Array<ArrayBufferLike>;
|
|
2772
2772
|
};
|
|
@@ -39,7 +39,9 @@ async function coreClientResolveTransactionPlugin(transactionData, options, next
|
|
|
39
39
|
const withdrawalOwner = input.FundsWithdrawal.withdrawFrom.Sender ? transactionData.sender : gasPayer;
|
|
40
40
|
if (withdrawalOwner && normalizeSuiAddress(withdrawalOwner) === normalizedGasPayer && input.FundsWithdrawal.reservation.$kind === "MaxAmountU64") withdrawals += BigInt(input.FundsWithdrawal.reservation.MaxAmountU64);
|
|
41
41
|
}
|
|
42
|
-
const
|
|
42
|
+
const needsSimulateExpiration = !options.onlyTransactionKind && !transactionData.expiration && !transactionData.gasData.budget;
|
|
43
|
+
const needsSystemState = needsGasPrice || needsPayment && usesGasCoin || needsSimulateExpiration;
|
|
44
|
+
const needsChainId = needsPayment && usesGasCoin || needsSimulateExpiration;
|
|
43
45
|
const [, systemStateResult, balanceResult, coinsResult, chainIdResult] = await Promise.all([
|
|
44
46
|
normalizeInputs(transactionData, client),
|
|
45
47
|
needsSystemState ? client.core.getCurrentSystemState() : null,
|
|
@@ -48,13 +50,14 @@ async function coreClientResolveTransactionPlugin(transactionData, options, next
|
|
|
48
50
|
owner: gasPayer,
|
|
49
51
|
coinType: SUI_TYPE_ARG
|
|
50
52
|
}) : null,
|
|
51
|
-
|
|
53
|
+
needsChainId ? client.core.getChainIdentifier() : null
|
|
52
54
|
]);
|
|
53
55
|
await resolveObjectReferences(transactionData, client);
|
|
54
56
|
if (!options.onlyTransactionKind) {
|
|
55
57
|
const systemState = systemStateResult?.systemState ?? null;
|
|
58
|
+
const chainIdentifier = chainIdResult?.chainIdentifier ?? null;
|
|
56
59
|
if (systemState && !transactionData.gasData.price) transactionData.gasData.price = systemState.referenceGasPrice;
|
|
57
|
-
await setGasBudget(transactionData, client);
|
|
60
|
+
await setGasBudget(transactionData, client, needsSimulateExpiration && systemState && chainIdentifier ? buildValidDuringExpiration(systemState, chainIdentifier) : void 0);
|
|
58
61
|
if (needsPayment) {
|
|
59
62
|
if (!balanceResult || !coinsResult) throw new Error("Could not resolve gas payment: a gas owner or sender must be set to fetch balance and coins.");
|
|
60
63
|
setGasPayment({
|
|
@@ -64,21 +67,24 @@ async function coreClientResolveTransactionPlugin(transactionData, options, next
|
|
|
64
67
|
usesGasCoin,
|
|
65
68
|
withdrawals,
|
|
66
69
|
gasPayer,
|
|
67
|
-
chainIdentifier
|
|
70
|
+
chainIdentifier,
|
|
68
71
|
epoch: systemState?.epoch ?? null
|
|
69
72
|
});
|
|
70
73
|
}
|
|
71
|
-
if (!transactionData.expiration && transactionData.gasData.payment?.length === 0) await setExpiration(transactionData, client, systemState,
|
|
74
|
+
if (!transactionData.expiration && transactionData.gasData.payment?.length === 0) await setExpiration(transactionData, client, systemState, chainIdentifier);
|
|
72
75
|
}
|
|
73
76
|
return await next();
|
|
74
77
|
}
|
|
75
|
-
async function setGasBudget(transactionData, client) {
|
|
78
|
+
async function setGasBudget(transactionData, client, simulateExpiration) {
|
|
76
79
|
if (transactionData.gasData.budget) return;
|
|
77
80
|
const simulateResult = await client.core.simulateTransaction({
|
|
78
|
-
transaction: transactionData.build({ overrides: {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
transaction: transactionData.build({ overrides: {
|
|
82
|
+
gasData: {
|
|
83
|
+
budget: String(MAX_GAS),
|
|
84
|
+
payment: []
|
|
85
|
+
},
|
|
86
|
+
...simulateExpiration && { expiration: simulateExpiration }
|
|
87
|
+
} }),
|
|
82
88
|
include: { effects: true }
|
|
83
89
|
});
|
|
84
90
|
if (simulateResult.$kind === "FailedTransaction") {
|
|
@@ -115,8 +121,11 @@ function setGasPayment({ transactionData, balance, coins, usesGasCoin, withdrawa
|
|
|
115
121
|
}
|
|
116
122
|
async function setExpiration(transactionData, client, systemState, existingChainIdentifier = null) {
|
|
117
123
|
const [chainIdentifier, resolvedSystemState] = await Promise.all([existingChainIdentifier ?? client.core.getChainIdentifier().then((r) => r.chainIdentifier), systemState ?? client.core.getCurrentSystemState().then((r) => r.systemState)]);
|
|
118
|
-
|
|
119
|
-
|
|
124
|
+
transactionData.expiration = buildValidDuringExpiration(resolvedSystemState, chainIdentifier);
|
|
125
|
+
}
|
|
126
|
+
function buildValidDuringExpiration(systemState, chainIdentifier) {
|
|
127
|
+
const currentEpoch = BigInt(systemState.epoch);
|
|
128
|
+
return {
|
|
120
129
|
$kind: "ValidDuring",
|
|
121
130
|
ValidDuring: {
|
|
122
131
|
minEpoch: String(currentEpoch),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-resolver.mjs","names":[],"sources":["../../src/client/core-resolver.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n\tnormalizeSuiAddress,\n\tnormalizeSuiObjectId,\n\tnormalizeStructTag,\n\tSUI_TYPE_ARG,\n} from '../utils/index.js';\nimport { createCoinReservationRef } from '../utils/coin-reservation.js';\nimport type { ClientWithCoreApi } from './core.js';\nimport type { CallArg, Command } from '../transactions/data/internal.js';\nimport type { SuiClientTypes } from './types.js';\nimport { SimulationError } from './errors.js';\nimport { Inputs } from '../transactions/Inputs.js';\nimport { getPureBcsSchema, isTxContext } from '../transactions/serializer.js';\nimport type { TransactionDataBuilder } from '../transactions/TransactionData.js';\nimport { chunk } from '@mysten/utils';\nimport type { BuildTransactionOptions } from '../transactions/index.js';\n\n// The maximum objects that can be fetched at once using multiGetObjects.\nconst MAX_OBJECTS_PER_FETCH = 50;\n\n// An amount of gas (in gas units) that is added to transactions as an overhead to ensure transactions do not fail.\nconst GAS_SAFE_OVERHEAD = 1000n;\nconst MAX_GAS = 50_000_000_000;\n\n/** Compute a gas budget from gasUsed effects data. */\nexport function computeGasBudget(\n\tgasUsed: { computationCost: string; storageCost: string; storageRebate: string },\n\tgasPrice: bigint | string = 1n,\n): string {\n\tconst safeOverhead = GAS_SAFE_OVERHEAD * BigInt(gasPrice);\n\tconst baseComputationCostWithOverhead = BigInt(gasUsed.computationCost) + safeOverhead;\n\tconst gasBudget =\n\t\tbaseComputationCostWithOverhead + BigInt(gasUsed.storageCost) - BigInt(gasUsed.storageRebate);\n\treturn String(\n\t\tgasBudget > baseComputationCostWithOverhead ? gasBudget : baseComputationCostWithOverhead,\n\t);\n}\n\nfunction getClient(options: BuildTransactionOptions): ClientWithCoreApi {\n\tif (!options.client) {\n\t\tthrow new Error(\n\t\t\t`No sui client passed to Transaction#build, but transaction data was not sufficient to build offline.`,\n\t\t);\n\t}\n\treturn options.client;\n}\n\nexport async function coreClientResolveTransactionPlugin(\n\ttransactionData: TransactionDataBuilder,\n\toptions: BuildTransactionOptions,\n\tnext: () => Promise<void>,\n) {\n\tconst client = getClient(options);\n\n\tconst needsGasPrice = !options.onlyTransactionKind && !transactionData.gasData.price;\n\tconst needsPayment = !options.onlyTransactionKind && !transactionData.gasData.payment;\n\tconst gasPayer = transactionData.gasData.owner ?? transactionData.sender;\n\n\tlet usesGasCoin = false;\n\tlet withdrawals = 0n;\n\n\ttransactionData.mapArguments((arg) => {\n\t\tif (arg.$kind === 'GasCoin') usesGasCoin = true;\n\t\treturn arg;\n\t});\n\n\tconst normalizedGasPayer = gasPayer ? normalizeSuiAddress(gasPayer) : null;\n\tfor (const input of transactionData.inputs) {\n\t\tif (input.$kind !== 'FundsWithdrawal' || !normalizedGasPayer) continue;\n\t\tif (normalizeStructTag(input.FundsWithdrawal.typeArg.Balance) !== SUI_TYPE_ARG) continue;\n\n\t\tconst withdrawalOwner = input.FundsWithdrawal.withdrawFrom.Sender\n\t\t\t? transactionData.sender\n\t\t\t: gasPayer;\n\t\tif (\n\t\t\twithdrawalOwner &&\n\t\t\tnormalizeSuiAddress(withdrawalOwner) === normalizedGasPayer &&\n\t\t\tinput.FundsWithdrawal.reservation.$kind === 'MaxAmountU64'\n\t\t) {\n\t\t\twithdrawals += BigInt(input.FundsWithdrawal.reservation.MaxAmountU64);\n\t\t}\n\t}\n\n\tconst needsSystemState = needsGasPrice || (needsPayment && usesGasCoin);\n\tconst [, systemStateResult, balanceResult, coinsResult, chainIdResult] = await Promise.all([\n\t\tnormalizeInputs(transactionData, client),\n\t\tneedsSystemState ? client.core.getCurrentSystemState() : null,\n\t\tneedsPayment && gasPayer ? client.core.getBalance({ owner: gasPayer }) : null,\n\t\tneedsPayment && gasPayer\n\t\t\t? client.core.listCoins({ owner: gasPayer, coinType: SUI_TYPE_ARG })\n\t\t\t: null,\n\t\tneedsPayment && usesGasCoin ? client.core.getChainIdentifier() : null,\n\t]);\n\n\tawait resolveObjectReferences(transactionData, client);\n\n\tif (!options.onlyTransactionKind) {\n\t\tconst systemState = systemStateResult?.systemState ?? null;\n\n\t\tif (systemState && !transactionData.gasData.price) {\n\t\t\ttransactionData.gasData.price = systemState.referenceGasPrice;\n\t\t}\n\n\t\tawait setGasBudget(transactionData, client);\n\n\t\tif (needsPayment) {\n\t\t\tif (!balanceResult || !coinsResult) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Could not resolve gas payment: a gas owner or sender must be set to fetch balance and coins.',\n\t\t\t\t);\n\t\t\t}\n\t\t\tsetGasPayment({\n\t\t\t\ttransactionData,\n\t\t\t\tbalance: balanceResult,\n\t\t\t\tcoins: coinsResult,\n\t\t\t\tusesGasCoin,\n\t\t\t\twithdrawals,\n\t\t\t\tgasPayer: gasPayer!,\n\t\t\t\tchainIdentifier: chainIdResult?.chainIdentifier ?? null,\n\t\t\t\tepoch: systemState?.epoch ?? null,\n\t\t\t});\n\t\t}\n\n\t\tif (!transactionData.expiration && transactionData.gasData.payment?.length === 0) {\n\t\t\tawait setExpiration(\n\t\t\t\ttransactionData,\n\t\t\t\tclient,\n\t\t\t\tsystemState,\n\t\t\t\tchainIdResult?.chainIdentifier ?? null,\n\t\t\t);\n\t\t}\n\t}\n\n\treturn await next();\n}\n\nasync function setGasBudget(transactionData: TransactionDataBuilder, client: ClientWithCoreApi) {\n\tif (transactionData.gasData.budget) {\n\t\treturn;\n\t}\n\n\tconst simulateResult = await client.core.simulateTransaction({\n\t\ttransaction: transactionData.build({\n\t\t\toverrides: {\n\t\t\t\tgasData: {\n\t\t\t\t\tbudget: String(MAX_GAS),\n\t\t\t\t\tpayment: [],\n\t\t\t\t},\n\t\t\t},\n\t\t}),\n\t\tinclude: { effects: true },\n\t});\n\n\tif (simulateResult.$kind === 'FailedTransaction') {\n\t\tconst executionError = simulateResult.FailedTransaction.status.error ?? undefined;\n\t\tconst errorMessage = executionError?.message ?? 'Unknown error';\n\t\tthrow new SimulationError(`Transaction resolution failed: ${errorMessage}`, {\n\t\t\tcause: simulateResult,\n\t\t\texecutionError,\n\t\t});\n\t}\n\n\ttransactionData.gasData.budget = computeGasBudget(\n\t\tsimulateResult.Transaction.effects!.gasUsed,\n\t\ttransactionData.gasData.price ? String(transactionData.gasData.price) : undefined,\n\t);\n}\n\nfunction setGasPayment({\n\ttransactionData,\n\tbalance,\n\tcoins,\n\tusesGasCoin,\n\twithdrawals,\n\tgasPayer,\n\tchainIdentifier,\n\tepoch,\n}: {\n\ttransactionData: TransactionDataBuilder;\n\tbalance: SuiClientTypes.GetBalanceResponse;\n\tcoins: SuiClientTypes.ListCoinsResponse;\n\tusesGasCoin: boolean;\n\twithdrawals: bigint;\n\tgasPayer: string;\n\tchainIdentifier: string | null;\n\tepoch: string | null;\n}) {\n\tconst budget = BigInt(transactionData.gasData.budget!);\n\tconst addressBalance = BigInt(balance.balance.addressBalance);\n\n\tif (budget === 0n || (!usesGasCoin && addressBalance >= budget + withdrawals)) {\n\t\ttransactionData.gasData.payment = [];\n\t\treturn;\n\t}\n\n\tconst filteredCoins = coins.objects.filter((coin) => {\n\t\tconst matchingInput = transactionData.inputs.find((input) => {\n\t\t\tif (input.Object?.ImmOrOwnedObject) {\n\t\t\t\treturn coin.objectId === input.Object.ImmOrOwnedObject.objectId;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t});\n\n\t\treturn !matchingInput;\n\t});\n\n\tconst paymentCoins = filteredCoins.map((coin) => ({\n\t\tobjectId: coin.objectId,\n\t\tdigest: coin.digest,\n\t\tversion: coin.version,\n\t}));\n\n\tconst reservationAmount = addressBalance - withdrawals;\n\n\tif (usesGasCoin && reservationAmount > 0n && chainIdentifier && epoch) {\n\t\ttransactionData.gasData.payment = [\n\t\t\tcreateCoinReservationRef(reservationAmount, gasPayer, chainIdentifier, epoch),\n\t\t\t...paymentCoins,\n\t\t];\n\t} else if (!filteredCoins.length) {\n\t\tthrow new Error('No valid gas coins found for the transaction.');\n\t} else {\n\t\ttransactionData.gasData.payment = paymentCoins;\n\t}\n}\n\ninterface SystemStateData {\n\tepoch: string;\n\treferenceGasPrice: string;\n}\n\nasync function setExpiration(\n\ttransactionData: TransactionDataBuilder,\n\tclient: ClientWithCoreApi,\n\tsystemState: SystemStateData | null,\n\texistingChainIdentifier: string | null = null,\n) {\n\tconst [chainIdentifier, resolvedSystemState] = await Promise.all([\n\t\texistingChainIdentifier ?? client.core.getChainIdentifier().then((r) => r.chainIdentifier),\n\t\tsystemState ?? client.core.getCurrentSystemState().then((r) => r.systemState),\n\t]);\n\tconst currentEpoch = BigInt(resolvedSystemState.epoch);\n\n\ttransactionData.expiration = {\n\t\t$kind: 'ValidDuring',\n\t\tValidDuring: {\n\t\t\tminEpoch: String(currentEpoch),\n\t\t\tmaxEpoch: String(currentEpoch + 1n),\n\t\t\tminTimestamp: null,\n\t\t\tmaxTimestamp: null,\n\t\t\tchain: chainIdentifier,\n\t\t\tnonce: (Math.random() * 0x100000000) >>> 0,\n\t\t},\n\t};\n}\n\nasync function resolveObjectReferences(\n\ttransactionData: TransactionDataBuilder,\n\tclient: ClientWithCoreApi,\n) {\n\t// Keep track of the object references that will need to be resolved at the end of the transaction.\n\t// We keep the input by-reference to avoid needing to re-resolve it:\n\tconst objectsToResolve = transactionData.inputs.filter((input) => {\n\t\treturn (\n\t\t\tinput.UnresolvedObject &&\n\t\t\t!(input.UnresolvedObject.version || input.UnresolvedObject?.initialSharedVersion)\n\t\t);\n\t}) as Extract<CallArg, { UnresolvedObject: unknown }>[];\n\n\tconst dedupedIds = [\n\t\t...new Set(\n\t\t\tobjectsToResolve.map((input) => normalizeSuiObjectId(input.UnresolvedObject.objectId)),\n\t\t),\n\t];\n\n\tconst objectChunks = dedupedIds.length ? chunk(dedupedIds, MAX_OBJECTS_PER_FETCH) : [];\n\tconst resolved = (\n\t\tawait Promise.all(\n\t\t\tobjectChunks.map((chunkIds) =>\n\t\t\t\tclient.core.getObjects({\n\t\t\t\t\tobjectIds: chunkIds,\n\t\t\t\t}),\n\t\t\t),\n\t\t)\n\t).flatMap((result) => result.objects);\n\n\tconst responsesById = new Map(\n\t\tdedupedIds.map((id, index) => {\n\t\t\treturn [id, resolved[index]];\n\t\t}),\n\t);\n\n\tconst invalidObjects = Array.from(responsesById)\n\t\t.filter(([_, obj]) => obj instanceof Error)\n\t\t.map(([_, obj]) => (obj as Error).message);\n\n\tif (invalidObjects.length) {\n\t\tthrow new Error(`The following input objects are invalid: ${invalidObjects.join(', ')}`);\n\t}\n\n\tconst objects = resolved.map((object) => {\n\t\tif (object instanceof Error) {\n\t\t\tthrow new Error(`Failed to fetch object: ${object.message}`);\n\t\t}\n\t\tconst owner = object.owner;\n\t\tconst initialSharedVersion =\n\t\t\towner && typeof owner === 'object'\n\t\t\t\t? owner.$kind === 'Shared'\n\t\t\t\t\t? owner.Shared.initialSharedVersion\n\t\t\t\t\t: owner.$kind === 'ConsensusAddressOwner'\n\t\t\t\t\t\t? owner.ConsensusAddressOwner.startVersion\n\t\t\t\t\t\t: null\n\t\t\t\t: null;\n\n\t\treturn {\n\t\t\tobjectId: object.objectId,\n\t\t\tdigest: object.digest,\n\t\t\tversion: object.version,\n\t\t\tinitialSharedVersion,\n\t\t};\n\t});\n\n\tconst objectsById = new Map(\n\t\tdedupedIds.map((id, index) => {\n\t\t\treturn [id, objects[index]];\n\t\t}),\n\t);\n\n\tfor (const [index, input] of transactionData.inputs.entries()) {\n\t\tif (!input.UnresolvedObject) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet updated: CallArg | undefined;\n\t\tconst id = normalizeSuiAddress(input.UnresolvedObject.objectId);\n\t\tconst object = objectsById.get(id);\n\n\t\tif (input.UnresolvedObject.initialSharedVersion ?? object?.initialSharedVersion) {\n\t\t\tupdated = Inputs.SharedObjectRef({\n\t\t\t\tobjectId: id,\n\t\t\t\tinitialSharedVersion:\n\t\t\t\t\tinput.UnresolvedObject.initialSharedVersion || object?.initialSharedVersion!,\n\t\t\t\tmutable: input.UnresolvedObject.mutable || isUsedAsMutable(transactionData, index),\n\t\t\t});\n\t\t} else if (isUsedAsReceiving(transactionData, index)) {\n\t\t\tupdated = Inputs.ReceivingRef(\n\t\t\t\t{\n\t\t\t\t\tobjectId: id,\n\t\t\t\t\tdigest: input.UnresolvedObject.digest ?? object?.digest!,\n\t\t\t\t\tversion: input.UnresolvedObject.version ?? object?.version!,\n\t\t\t\t}!,\n\t\t\t);\n\t\t}\n\n\t\ttransactionData.inputs[transactionData.inputs.indexOf(input)] =\n\t\t\tupdated ??\n\t\t\tInputs.ObjectRef({\n\t\t\t\tobjectId: id,\n\t\t\t\tdigest: input.UnresolvedObject.digest ?? object?.digest!,\n\t\t\t\tversion: input.UnresolvedObject.version ?? object?.version!,\n\t\t\t});\n\t}\n}\n\nasync function normalizeInputs(transactionData: TransactionDataBuilder, client: ClientWithCoreApi) {\n\tconst { inputs, commands } = transactionData;\n\tconst moveCallsToResolve: Extract<Command, { MoveCall: unknown }>['MoveCall'][] = [];\n\tconst moveFunctionsToResolve = new Set<string>();\n\n\tcommands.forEach((command) => {\n\t\t// Special case move call:\n\t\tif (command.MoveCall) {\n\t\t\t// Determine if any of the arguments require encoding.\n\t\t\t// - If they don't, then this is good to go.\n\t\t\t// - If they do, then we need to fetch the normalized move module.\n\n\t\t\t// If we already know the argument types, we don't need to resolve them again\n\t\t\tif (command.MoveCall._argumentTypes) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst inputs = command.MoveCall.arguments.map((arg) => {\n\t\t\t\tif (arg.$kind === 'Input') {\n\t\t\t\t\treturn transactionData.inputs[arg.Input];\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t});\n\t\t\tconst needsResolution = inputs.some(\n\t\t\t\t(input) =>\n\t\t\t\t\tinput?.UnresolvedPure ||\n\t\t\t\t\t(input?.UnresolvedObject && typeof input?.UnresolvedObject.mutable !== 'boolean'),\n\t\t\t);\n\n\t\t\tif (needsResolution) {\n\t\t\t\tconst functionName = `${command.MoveCall.package}::${command.MoveCall.module}::${command.MoveCall.function}`;\n\t\t\t\tmoveFunctionsToResolve.add(functionName);\n\t\t\t\tmoveCallsToResolve.push(command.MoveCall);\n\t\t\t}\n\t\t}\n\t});\n\n\tconst moveFunctionParameters = new Map<string, SuiClientTypes.OpenSignature[]>();\n\tif (moveFunctionsToResolve.size > 0) {\n\t\tawait Promise.all(\n\t\t\t[...moveFunctionsToResolve].map(async (functionName) => {\n\t\t\t\tconst [packageId, moduleName, name] = functionName.split('::');\n\t\t\t\tconst { function: def } = await client.core.getMoveFunction({\n\t\t\t\t\tpackageId,\n\t\t\t\t\tmoduleName,\n\t\t\t\t\tname,\n\t\t\t\t});\n\n\t\t\t\tmoveFunctionParameters.set(functionName, def.parameters);\n\t\t\t}),\n\t\t);\n\t}\n\n\tif (moveCallsToResolve.length) {\n\t\tawait Promise.all(\n\t\t\tmoveCallsToResolve.map(async (moveCall) => {\n\t\t\t\tconst parameters = moveFunctionParameters.get(\n\t\t\t\t\t`${moveCall.package}::${moveCall.module}::${moveCall.function}`,\n\t\t\t\t);\n\n\t\t\t\tif (!parameters) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Entry functions can have a mutable reference to an instance of the TxContext\n\t\t\t\t// struct defined in the TxContext module as the last parameter. The caller of\n\t\t\t\t// the function does not need to pass it in as an argument.\n\t\t\t\tconst hasTxContext = parameters.length > 0 && isTxContext(parameters.at(-1)!);\n\t\t\t\tconst params = hasTxContext ? parameters.slice(0, parameters.length - 1) : parameters;\n\n\t\t\t\tmoveCall._argumentTypes = params;\n\t\t\t}),\n\t\t);\n\t}\n\n\tcommands.forEach((command) => {\n\t\tif (!command.MoveCall) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst moveCall = command.MoveCall;\n\t\tconst fnName = `${moveCall.package}::${moveCall.module}::${moveCall.function}`;\n\t\tconst params = moveCall._argumentTypes;\n\n\t\tif (!params) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (params.length !== command.MoveCall.arguments.length) {\n\t\t\tthrow new Error(`Incorrect number of arguments for ${fnName}`);\n\t\t}\n\n\t\tparams.forEach((param, i) => {\n\t\t\tconst arg = moveCall.arguments[i];\n\t\t\tif (arg.$kind !== 'Input') return;\n\t\t\tconst input = inputs[arg.Input];\n\n\t\t\t// Skip if the input is already resolved\n\t\t\tif (!input.UnresolvedPure && !input.UnresolvedObject) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst inputValue = input.UnresolvedPure?.value ?? input.UnresolvedObject?.objectId!;\n\n\t\t\tconst schema = getPureBcsSchema(param.body);\n\t\t\tif (schema) {\n\t\t\t\targ.type = 'pure';\n\t\t\t\tinputs[inputs.indexOf(input)] = Inputs.Pure(schema.serialize(inputValue));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (typeof inputValue !== 'string') {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Expect the argument to be an object id string, got ${JSON.stringify(\n\t\t\t\t\t\tinputValue,\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\t2,\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\targ.type = 'object';\n\t\t\tconst unresolvedObject: typeof input = input.UnresolvedPure\n\t\t\t\t? {\n\t\t\t\t\t\t$kind: 'UnresolvedObject',\n\t\t\t\t\t\tUnresolvedObject: {\n\t\t\t\t\t\t\tobjectId: inputValue,\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t: input;\n\n\t\t\tinputs[arg.Input] = unresolvedObject;\n\t\t});\n\t});\n}\n\nfunction isUsedAsMutable(transactionData: TransactionDataBuilder, index: number) {\n\tlet usedAsMutable = false;\n\n\ttransactionData.getInputUses(index, (arg, tx) => {\n\t\tif (tx.MoveCall && tx.MoveCall._argumentTypes) {\n\t\t\tconst argIndex = tx.MoveCall.arguments.indexOf(arg);\n\t\t\tusedAsMutable =\n\t\t\t\ttx.MoveCall._argumentTypes[argIndex].reference !== 'immutable' || usedAsMutable;\n\t\t}\n\n\t\tif (\n\t\t\ttx.$kind === 'MakeMoveVec' ||\n\t\t\ttx.$kind === 'MergeCoins' ||\n\t\t\ttx.$kind === 'SplitCoins' ||\n\t\t\ttx.$kind === 'TransferObjects'\n\t\t) {\n\t\t\tusedAsMutable = true;\n\t\t}\n\t});\n\n\treturn usedAsMutable;\n}\n\nfunction isUsedAsReceiving(transactionData: TransactionDataBuilder, index: number) {\n\tlet usedAsReceiving = false;\n\n\ttransactionData.getInputUses(index, (arg, tx) => {\n\t\tif (tx.MoveCall && tx.MoveCall._argumentTypes) {\n\t\t\tconst argIndex = tx.MoveCall.arguments.indexOf(arg);\n\t\t\tusedAsReceiving = isReceivingType(tx.MoveCall._argumentTypes[argIndex]) || usedAsReceiving;\n\t\t}\n\t});\n\n\treturn usedAsReceiving;\n}\n\nconst RECEIVING_TYPE =\n\t'0x0000000000000000000000000000000000000000000000000000000000000002::transfer::Receiving';\n\nfunction isReceivingType(type: SuiClientTypes.OpenSignature): boolean {\n\tif (type.body.$kind !== 'datatype') {\n\t\treturn false;\n\t}\n\n\treturn type.body.datatype.typeName === RECEIVING_TYPE;\n}\n"],"mappings":";;;;;;;;;AAqBA,MAAM,wBAAwB;AAG9B,MAAM,oBAAoB;AAC1B,MAAM,UAAU;;AAGhB,SAAgB,iBACf,SACA,WAA4B,IACnB;CACT,MAAM,eAAe,oBAAoB,OAAO,SAAS;CACzD,MAAM,kCAAkC,OAAO,QAAQ,gBAAgB,GAAG;CAC1E,MAAM,YACL,kCAAkC,OAAO,QAAQ,YAAY,GAAG,OAAO,QAAQ,cAAc;AAC9F,QAAO,OACN,YAAY,kCAAkC,YAAY,gCAC1D;;AAGF,SAAS,UAAU,SAAqD;AACvE,KAAI,CAAC,QAAQ,OACZ,OAAM,IAAI,MACT,uGACA;AAEF,QAAO,QAAQ;;AAGhB,eAAsB,mCACrB,iBACA,SACA,MACC;CACD,MAAM,SAAS,UAAU,QAAQ;CAEjC,MAAM,gBAAgB,CAAC,QAAQ,uBAAuB,CAAC,gBAAgB,QAAQ;CAC/E,MAAM,eAAe,CAAC,QAAQ,uBAAuB,CAAC,gBAAgB,QAAQ;CAC9E,MAAM,WAAW,gBAAgB,QAAQ,SAAS,gBAAgB;CAElE,IAAI,cAAc;CAClB,IAAI,cAAc;AAElB,iBAAgB,cAAc,QAAQ;AACrC,MAAI,IAAI,UAAU,UAAW,eAAc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,eAAe;;AAGpE,MACC,GAAG,UAAU,iBACb,GAAG,UAAU,gBACb,GAAG,UAAU,gBACb,GAAG,UAAU,kBAEb,iBAAgB;GAEhB;AAEF,QAAO;;AAGR,SAAS,kBAAkB,iBAAyC,OAAe;CAClF,IAAI,kBAAkB;AAEtB,iBAAgB,aAAa,QAAQ,KAAK,OAAO;AAChD,MAAI,GAAG,YAAY,GAAG,SAAS,gBAAgB;GAC9C,MAAM,WAAW,GAAG,SAAS,UAAU,QAAQ,IAAI;AACnD,qBAAkB,gBAAgB,GAAG,SAAS,eAAe,UAAU,IAAI;;GAE3E;AAEF,QAAO;;AAGR,MAAM,iBACL;AAED,SAAS,gBAAgB,MAA6C;AACrE,KAAI,KAAK,KAAK,UAAU,WACvB,QAAO;AAGR,QAAO,KAAK,KAAK,SAAS,aAAa"}
|
|
1
|
+
{"version":3,"file":"core-resolver.mjs","names":[],"sources":["../../src/client/core-resolver.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n\tnormalizeSuiAddress,\n\tnormalizeSuiObjectId,\n\tnormalizeStructTag,\n\tSUI_TYPE_ARG,\n} from '../utils/index.js';\nimport { createCoinReservationRef } from '../utils/coin-reservation.js';\nimport type { ClientWithCoreApi } from './core.js';\nimport type { CallArg, Command } from '../transactions/data/internal.js';\nimport type { SuiClientTypes } from './types.js';\nimport { SimulationError } from './errors.js';\nimport { Inputs } from '../transactions/Inputs.js';\nimport { getPureBcsSchema, isTxContext } from '../transactions/serializer.js';\nimport type { TransactionDataBuilder } from '../transactions/TransactionData.js';\nimport { chunk } from '@mysten/utils';\nimport type { BuildTransactionOptions } from '../transactions/index.js';\n\n// The maximum objects that can be fetched at once using multiGetObjects.\nconst MAX_OBJECTS_PER_FETCH = 50;\n\n// An amount of gas (in gas units) that is added to transactions as an overhead to ensure transactions do not fail.\nconst GAS_SAFE_OVERHEAD = 1000n;\nconst MAX_GAS = 50_000_000_000;\n\n/** Compute a gas budget from gasUsed effects data. */\nexport function computeGasBudget(\n\tgasUsed: { computationCost: string; storageCost: string; storageRebate: string },\n\tgasPrice: bigint | string = 1n,\n): string {\n\tconst safeOverhead = GAS_SAFE_OVERHEAD * BigInt(gasPrice);\n\tconst baseComputationCostWithOverhead = BigInt(gasUsed.computationCost) + safeOverhead;\n\tconst gasBudget =\n\t\tbaseComputationCostWithOverhead + BigInt(gasUsed.storageCost) - BigInt(gasUsed.storageRebate);\n\treturn String(\n\t\tgasBudget > baseComputationCostWithOverhead ? gasBudget : baseComputationCostWithOverhead,\n\t);\n}\n\nfunction getClient(options: BuildTransactionOptions): ClientWithCoreApi {\n\tif (!options.client) {\n\t\tthrow new Error(\n\t\t\t`No sui client passed to Transaction#build, but transaction data was not sufficient to build offline.`,\n\t\t);\n\t}\n\treturn options.client;\n}\n\nexport async function coreClientResolveTransactionPlugin(\n\ttransactionData: TransactionDataBuilder,\n\toptions: BuildTransactionOptions,\n\tnext: () => Promise<void>,\n) {\n\tconst client = getClient(options);\n\n\tconst needsGasPrice = !options.onlyTransactionKind && !transactionData.gasData.price;\n\tconst needsPayment = !options.onlyTransactionKind && !transactionData.gasData.payment;\n\tconst gasPayer = transactionData.gasData.owner ?? transactionData.sender;\n\n\tlet usesGasCoin = false;\n\tlet withdrawals = 0n;\n\n\ttransactionData.mapArguments((arg) => {\n\t\tif (arg.$kind === 'GasCoin') usesGasCoin = true;\n\t\treturn arg;\n\t});\n\n\tconst normalizedGasPayer = gasPayer ? normalizeSuiAddress(gasPayer) : null;\n\tfor (const input of transactionData.inputs) {\n\t\tif (input.$kind !== 'FundsWithdrawal' || !normalizedGasPayer) continue;\n\t\tif (normalizeStructTag(input.FundsWithdrawal.typeArg.Balance) !== SUI_TYPE_ARG) continue;\n\n\t\tconst withdrawalOwner = input.FundsWithdrawal.withdrawFrom.Sender\n\t\t\t? transactionData.sender\n\t\t\t: gasPayer;\n\t\tif (\n\t\t\twithdrawalOwner &&\n\t\t\tnormalizeSuiAddress(withdrawalOwner) === normalizedGasPayer &&\n\t\t\tinput.FundsWithdrawal.reservation.$kind === 'MaxAmountU64'\n\t\t) {\n\t\t\twithdrawals += BigInt(input.FundsWithdrawal.reservation.MaxAmountU64);\n\t\t}\n\t}\n\n\t// `setGasBudget` simulates with `payment: []` whenever it has to compute a\n\t// budget (i.e. one wasn't preset). The validator's replay-protection check\n\t// then requires either a `ValidDuring` expiration or at least one\n\t// \"address-owned\" input — an `ImmOrOwnedMoveObject` whose owner is\n\t// `AddressOwner`, which we can't tell from `Immutable` without owner info we\n\t// don't track. Provide a simulate-only `ValidDuring` whenever we'll actually\n\t// simulate and one isn't user-set.\n\tconst needsSimulateExpiration =\n\t\t!options.onlyTransactionKind && !transactionData.expiration && !transactionData.gasData.budget;\n\tconst needsSystemState =\n\t\tneedsGasPrice || (needsPayment && usesGasCoin) || needsSimulateExpiration;\n\tconst needsChainId = (needsPayment && usesGasCoin) || needsSimulateExpiration;\n\tconst [, systemStateResult, balanceResult, coinsResult, chainIdResult] = await Promise.all([\n\t\tnormalizeInputs(transactionData, client),\n\t\tneedsSystemState ? client.core.getCurrentSystemState() : null,\n\t\tneedsPayment && gasPayer ? client.core.getBalance({ owner: gasPayer }) : null,\n\t\tneedsPayment && gasPayer\n\t\t\t? client.core.listCoins({ owner: gasPayer, coinType: SUI_TYPE_ARG })\n\t\t\t: null,\n\t\tneedsChainId ? client.core.getChainIdentifier() : null,\n\t]);\n\n\tawait resolveObjectReferences(transactionData, client);\n\n\tif (!options.onlyTransactionKind) {\n\t\tconst systemState = systemStateResult?.systemState ?? null;\n\t\tconst chainIdentifier = chainIdResult?.chainIdentifier ?? null;\n\n\t\tif (systemState && !transactionData.gasData.price) {\n\t\t\ttransactionData.gasData.price = systemState.referenceGasPrice;\n\t\t}\n\n\t\tconst simulateExpiration =\n\t\t\tneedsSimulateExpiration && systemState && chainIdentifier\n\t\t\t\t? buildValidDuringExpiration(systemState, chainIdentifier)\n\t\t\t\t: undefined;\n\n\t\tawait setGasBudget(transactionData, client, simulateExpiration);\n\n\t\tif (needsPayment) {\n\t\t\tif (!balanceResult || !coinsResult) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Could not resolve gas payment: a gas owner or sender must be set to fetch balance and coins.',\n\t\t\t\t);\n\t\t\t}\n\t\t\tsetGasPayment({\n\t\t\t\ttransactionData,\n\t\t\t\tbalance: balanceResult,\n\t\t\t\tcoins: coinsResult,\n\t\t\t\tusesGasCoin,\n\t\t\t\twithdrawals,\n\t\t\t\tgasPayer: gasPayer!,\n\t\t\t\tchainIdentifier,\n\t\t\t\tepoch: systemState?.epoch ?? null,\n\t\t\t});\n\t\t}\n\n\t\tif (!transactionData.expiration && transactionData.gasData.payment?.length === 0) {\n\t\t\tawait setExpiration(transactionData, client, systemState, chainIdentifier);\n\t\t}\n\t}\n\n\treturn await next();\n}\n\nasync function setGasBudget(\n\ttransactionData: TransactionDataBuilder,\n\tclient: ClientWithCoreApi,\n\tsimulateExpiration?: ValidDuringExpiration,\n) {\n\tif (transactionData.gasData.budget) {\n\t\treturn;\n\t}\n\n\tconst simulateResult = await client.core.simulateTransaction({\n\t\ttransaction: transactionData.build({\n\t\t\toverrides: {\n\t\t\t\tgasData: {\n\t\t\t\t\tbudget: String(MAX_GAS),\n\t\t\t\t\tpayment: [],\n\t\t\t\t},\n\t\t\t\t...(simulateExpiration && { expiration: simulateExpiration }),\n\t\t\t},\n\t\t}),\n\t\tinclude: { effects: true },\n\t});\n\n\tif (simulateResult.$kind === 'FailedTransaction') {\n\t\tconst executionError = simulateResult.FailedTransaction.status.error ?? undefined;\n\t\tconst errorMessage = executionError?.message ?? 'Unknown error';\n\t\tthrow new SimulationError(`Transaction resolution failed: ${errorMessage}`, {\n\t\t\tcause: simulateResult,\n\t\t\texecutionError,\n\t\t});\n\t}\n\n\ttransactionData.gasData.budget = computeGasBudget(\n\t\tsimulateResult.Transaction.effects!.gasUsed,\n\t\ttransactionData.gasData.price ? String(transactionData.gasData.price) : undefined,\n\t);\n}\n\nfunction setGasPayment({\n\ttransactionData,\n\tbalance,\n\tcoins,\n\tusesGasCoin,\n\twithdrawals,\n\tgasPayer,\n\tchainIdentifier,\n\tepoch,\n}: {\n\ttransactionData: TransactionDataBuilder;\n\tbalance: SuiClientTypes.GetBalanceResponse;\n\tcoins: SuiClientTypes.ListCoinsResponse;\n\tusesGasCoin: boolean;\n\twithdrawals: bigint;\n\tgasPayer: string;\n\tchainIdentifier: string | null;\n\tepoch: string | null;\n}) {\n\tconst budget = BigInt(transactionData.gasData.budget!);\n\tconst addressBalance = BigInt(balance.balance.addressBalance);\n\n\tif (budget === 0n || (!usesGasCoin && addressBalance >= budget + withdrawals)) {\n\t\ttransactionData.gasData.payment = [];\n\t\treturn;\n\t}\n\n\tconst filteredCoins = coins.objects.filter((coin) => {\n\t\tconst matchingInput = transactionData.inputs.find((input) => {\n\t\t\tif (input.Object?.ImmOrOwnedObject) {\n\t\t\t\treturn coin.objectId === input.Object.ImmOrOwnedObject.objectId;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t});\n\n\t\treturn !matchingInput;\n\t});\n\n\tconst paymentCoins = filteredCoins.map((coin) => ({\n\t\tobjectId: coin.objectId,\n\t\tdigest: coin.digest,\n\t\tversion: coin.version,\n\t}));\n\n\tconst reservationAmount = addressBalance - withdrawals;\n\n\tif (usesGasCoin && reservationAmount > 0n && chainIdentifier && epoch) {\n\t\ttransactionData.gasData.payment = [\n\t\t\tcreateCoinReservationRef(reservationAmount, gasPayer, chainIdentifier, epoch),\n\t\t\t...paymentCoins,\n\t\t];\n\t} else if (!filteredCoins.length) {\n\t\tthrow new Error('No valid gas coins found for the transaction.');\n\t} else {\n\t\ttransactionData.gasData.payment = paymentCoins;\n\t}\n}\n\ninterface SystemStateData {\n\tepoch: string;\n\treferenceGasPrice: string;\n}\n\nasync function setExpiration(\n\ttransactionData: TransactionDataBuilder,\n\tclient: ClientWithCoreApi,\n\tsystemState: SystemStateData | null,\n\texistingChainIdentifier: string | null = null,\n) {\n\tconst [chainIdentifier, resolvedSystemState] = await Promise.all([\n\t\texistingChainIdentifier ?? client.core.getChainIdentifier().then((r) => r.chainIdentifier),\n\t\tsystemState ?? client.core.getCurrentSystemState().then((r) => r.systemState),\n\t]);\n\ttransactionData.expiration = buildValidDuringExpiration(resolvedSystemState, chainIdentifier);\n}\n\ntype ValidDuringExpiration = {\n\t$kind: 'ValidDuring';\n\tValidDuring: {\n\t\tminEpoch: string;\n\t\tmaxEpoch: string;\n\t\tminTimestamp: null;\n\t\tmaxTimestamp: null;\n\t\tchain: string;\n\t\tnonce: number;\n\t};\n};\n\nfunction buildValidDuringExpiration(\n\tsystemState: SystemStateData,\n\tchainIdentifier: string,\n): ValidDuringExpiration {\n\tconst currentEpoch = BigInt(systemState.epoch);\n\treturn {\n\t\t$kind: 'ValidDuring',\n\t\tValidDuring: {\n\t\t\tminEpoch: String(currentEpoch),\n\t\t\tmaxEpoch: String(currentEpoch + 1n),\n\t\t\tminTimestamp: null,\n\t\t\tmaxTimestamp: null,\n\t\t\tchain: chainIdentifier,\n\t\t\tnonce: (Math.random() * 0x100000000) >>> 0,\n\t\t},\n\t};\n}\n\nasync function resolveObjectReferences(\n\ttransactionData: TransactionDataBuilder,\n\tclient: ClientWithCoreApi,\n) {\n\t// Keep track of the object references that will need to be resolved at the end of the transaction.\n\t// We keep the input by-reference to avoid needing to re-resolve it:\n\tconst objectsToResolve = transactionData.inputs.filter((input) => {\n\t\treturn (\n\t\t\tinput.UnresolvedObject &&\n\t\t\t!(input.UnresolvedObject.version || input.UnresolvedObject?.initialSharedVersion)\n\t\t);\n\t}) as Extract<CallArg, { UnresolvedObject: unknown }>[];\n\n\tconst dedupedIds = [\n\t\t...new Set(\n\t\t\tobjectsToResolve.map((input) => normalizeSuiObjectId(input.UnresolvedObject.objectId)),\n\t\t),\n\t];\n\n\tconst objectChunks = dedupedIds.length ? chunk(dedupedIds, MAX_OBJECTS_PER_FETCH) : [];\n\tconst resolved = (\n\t\tawait Promise.all(\n\t\t\tobjectChunks.map((chunkIds) =>\n\t\t\t\tclient.core.getObjects({\n\t\t\t\t\tobjectIds: chunkIds,\n\t\t\t\t}),\n\t\t\t),\n\t\t)\n\t).flatMap((result) => result.objects);\n\n\tconst responsesById = new Map(\n\t\tdedupedIds.map((id, index) => {\n\t\t\treturn [id, resolved[index]];\n\t\t}),\n\t);\n\n\tconst invalidObjects = Array.from(responsesById)\n\t\t.filter(([_, obj]) => obj instanceof Error)\n\t\t.map(([_, obj]) => (obj as Error).message);\n\n\tif (invalidObjects.length) {\n\t\tthrow new Error(`The following input objects are invalid: ${invalidObjects.join(', ')}`);\n\t}\n\n\tconst objects = resolved.map((object) => {\n\t\tif (object instanceof Error) {\n\t\t\tthrow new Error(`Failed to fetch object: ${object.message}`);\n\t\t}\n\t\tconst owner = object.owner;\n\t\tconst initialSharedVersion =\n\t\t\towner && typeof owner === 'object'\n\t\t\t\t? owner.$kind === 'Shared'\n\t\t\t\t\t? owner.Shared.initialSharedVersion\n\t\t\t\t\t: owner.$kind === 'ConsensusAddressOwner'\n\t\t\t\t\t\t? owner.ConsensusAddressOwner.startVersion\n\t\t\t\t\t\t: null\n\t\t\t\t: null;\n\n\t\treturn {\n\t\t\tobjectId: object.objectId,\n\t\t\tdigest: object.digest,\n\t\t\tversion: object.version,\n\t\t\tinitialSharedVersion,\n\t\t};\n\t});\n\n\tconst objectsById = new Map(\n\t\tdedupedIds.map((id, index) => {\n\t\t\treturn [id, objects[index]];\n\t\t}),\n\t);\n\n\tfor (const [index, input] of transactionData.inputs.entries()) {\n\t\tif (!input.UnresolvedObject) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet updated: CallArg | undefined;\n\t\tconst id = normalizeSuiAddress(input.UnresolvedObject.objectId);\n\t\tconst object = objectsById.get(id);\n\n\t\tif (input.UnresolvedObject.initialSharedVersion ?? object?.initialSharedVersion) {\n\t\t\tupdated = Inputs.SharedObjectRef({\n\t\t\t\tobjectId: id,\n\t\t\t\tinitialSharedVersion:\n\t\t\t\t\tinput.UnresolvedObject.initialSharedVersion || object?.initialSharedVersion!,\n\t\t\t\tmutable: input.UnresolvedObject.mutable || isUsedAsMutable(transactionData, index),\n\t\t\t});\n\t\t} else if (isUsedAsReceiving(transactionData, index)) {\n\t\t\tupdated = Inputs.ReceivingRef(\n\t\t\t\t{\n\t\t\t\t\tobjectId: id,\n\t\t\t\t\tdigest: input.UnresolvedObject.digest ?? object?.digest!,\n\t\t\t\t\tversion: input.UnresolvedObject.version ?? object?.version!,\n\t\t\t\t}!,\n\t\t\t);\n\t\t}\n\n\t\ttransactionData.inputs[transactionData.inputs.indexOf(input)] =\n\t\t\tupdated ??\n\t\t\tInputs.ObjectRef({\n\t\t\t\tobjectId: id,\n\t\t\t\tdigest: input.UnresolvedObject.digest ?? object?.digest!,\n\t\t\t\tversion: input.UnresolvedObject.version ?? object?.version!,\n\t\t\t});\n\t}\n}\n\nasync function normalizeInputs(transactionData: TransactionDataBuilder, client: ClientWithCoreApi) {\n\tconst { inputs, commands } = transactionData;\n\tconst moveCallsToResolve: Extract<Command, { MoveCall: unknown }>['MoveCall'][] = [];\n\tconst moveFunctionsToResolve = new Set<string>();\n\n\tcommands.forEach((command) => {\n\t\t// Special case move call:\n\t\tif (command.MoveCall) {\n\t\t\t// Determine if any of the arguments require encoding.\n\t\t\t// - If they don't, then this is good to go.\n\t\t\t// - If they do, then we need to fetch the normalized move module.\n\n\t\t\t// If we already know the argument types, we don't need to resolve them again\n\t\t\tif (command.MoveCall._argumentTypes) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst inputs = command.MoveCall.arguments.map((arg) => {\n\t\t\t\tif (arg.$kind === 'Input') {\n\t\t\t\t\treturn transactionData.inputs[arg.Input];\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t});\n\t\t\tconst needsResolution = inputs.some(\n\t\t\t\t(input) =>\n\t\t\t\t\tinput?.UnresolvedPure ||\n\t\t\t\t\t(input?.UnresolvedObject && typeof input?.UnresolvedObject.mutable !== 'boolean'),\n\t\t\t);\n\n\t\t\tif (needsResolution) {\n\t\t\t\tconst functionName = `${command.MoveCall.package}::${command.MoveCall.module}::${command.MoveCall.function}`;\n\t\t\t\tmoveFunctionsToResolve.add(functionName);\n\t\t\t\tmoveCallsToResolve.push(command.MoveCall);\n\t\t\t}\n\t\t}\n\t});\n\n\tconst moveFunctionParameters = new Map<string, SuiClientTypes.OpenSignature[]>();\n\tif (moveFunctionsToResolve.size > 0) {\n\t\tawait Promise.all(\n\t\t\t[...moveFunctionsToResolve].map(async (functionName) => {\n\t\t\t\tconst [packageId, moduleName, name] = functionName.split('::');\n\t\t\t\tconst { function: def } = await client.core.getMoveFunction({\n\t\t\t\t\tpackageId,\n\t\t\t\t\tmoduleName,\n\t\t\t\t\tname,\n\t\t\t\t});\n\n\t\t\t\tmoveFunctionParameters.set(functionName, def.parameters);\n\t\t\t}),\n\t\t);\n\t}\n\n\tif (moveCallsToResolve.length) {\n\t\tawait Promise.all(\n\t\t\tmoveCallsToResolve.map(async (moveCall) => {\n\t\t\t\tconst parameters = moveFunctionParameters.get(\n\t\t\t\t\t`${moveCall.package}::${moveCall.module}::${moveCall.function}`,\n\t\t\t\t);\n\n\t\t\t\tif (!parameters) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Entry functions can have a mutable reference to an instance of the TxContext\n\t\t\t\t// struct defined in the TxContext module as the last parameter. The caller of\n\t\t\t\t// the function does not need to pass it in as an argument.\n\t\t\t\tconst hasTxContext = parameters.length > 0 && isTxContext(parameters.at(-1)!);\n\t\t\t\tconst params = hasTxContext ? parameters.slice(0, parameters.length - 1) : parameters;\n\n\t\t\t\tmoveCall._argumentTypes = params;\n\t\t\t}),\n\t\t);\n\t}\n\n\tcommands.forEach((command) => {\n\t\tif (!command.MoveCall) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst moveCall = command.MoveCall;\n\t\tconst fnName = `${moveCall.package}::${moveCall.module}::${moveCall.function}`;\n\t\tconst params = moveCall._argumentTypes;\n\n\t\tif (!params) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (params.length !== command.MoveCall.arguments.length) {\n\t\t\tthrow new Error(`Incorrect number of arguments for ${fnName}`);\n\t\t}\n\n\t\tparams.forEach((param, i) => {\n\t\t\tconst arg = moveCall.arguments[i];\n\t\t\tif (arg.$kind !== 'Input') return;\n\t\t\tconst input = inputs[arg.Input];\n\n\t\t\t// Skip if the input is already resolved\n\t\t\tif (!input.UnresolvedPure && !input.UnresolvedObject) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst inputValue = input.UnresolvedPure?.value ?? input.UnresolvedObject?.objectId!;\n\n\t\t\tconst schema = getPureBcsSchema(param.body);\n\t\t\tif (schema) {\n\t\t\t\targ.type = 'pure';\n\t\t\t\tinputs[inputs.indexOf(input)] = Inputs.Pure(schema.serialize(inputValue));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (typeof inputValue !== 'string') {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Expect the argument to be an object id string, got ${JSON.stringify(\n\t\t\t\t\t\tinputValue,\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\t2,\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\targ.type = 'object';\n\t\t\tconst unresolvedObject: typeof input = input.UnresolvedPure\n\t\t\t\t? {\n\t\t\t\t\t\t$kind: 'UnresolvedObject',\n\t\t\t\t\t\tUnresolvedObject: {\n\t\t\t\t\t\t\tobjectId: inputValue,\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t: input;\n\n\t\t\tinputs[arg.Input] = unresolvedObject;\n\t\t});\n\t});\n}\n\nfunction isUsedAsMutable(transactionData: TransactionDataBuilder, index: number) {\n\tlet usedAsMutable = false;\n\n\ttransactionData.getInputUses(index, (arg, tx) => {\n\t\tif (tx.MoveCall && tx.MoveCall._argumentTypes) {\n\t\t\tconst argIndex = tx.MoveCall.arguments.indexOf(arg);\n\t\t\tusedAsMutable =\n\t\t\t\ttx.MoveCall._argumentTypes[argIndex].reference !== 'immutable' || usedAsMutable;\n\t\t}\n\n\t\tif (\n\t\t\ttx.$kind === 'MakeMoveVec' ||\n\t\t\ttx.$kind === 'MergeCoins' ||\n\t\t\ttx.$kind === 'SplitCoins' ||\n\t\t\ttx.$kind === 'TransferObjects'\n\t\t) {\n\t\t\tusedAsMutable = true;\n\t\t}\n\t});\n\n\treturn usedAsMutable;\n}\n\nfunction isUsedAsReceiving(transactionData: TransactionDataBuilder, index: number) {\n\tlet usedAsReceiving = false;\n\n\ttransactionData.getInputUses(index, (arg, tx) => {\n\t\tif (tx.MoveCall && tx.MoveCall._argumentTypes) {\n\t\t\tconst argIndex = tx.MoveCall.arguments.indexOf(arg);\n\t\t\tusedAsReceiving = isReceivingType(tx.MoveCall._argumentTypes[argIndex]) || usedAsReceiving;\n\t\t}\n\t});\n\n\treturn usedAsReceiving;\n}\n\nconst RECEIVING_TYPE =\n\t'0x0000000000000000000000000000000000000000000000000000000000000002::transfer::Receiving';\n\nfunction isReceivingType(type: SuiClientTypes.OpenSignature): boolean {\n\tif (type.body.$kind !== 'datatype') {\n\t\treturn false;\n\t}\n\n\treturn type.body.datatype.typeName === RECEIVING_TYPE;\n}\n"],"mappings":";;;;;;;;;AAqBA,MAAM,wBAAwB;AAG9B,MAAM,oBAAoB;AAC1B,MAAM,UAAU;;AAGhB,SAAgB,iBACf,SACA,WAA4B,IACnB;CACT,MAAM,eAAe,oBAAoB,OAAO,SAAS;CACzD,MAAM,kCAAkC,OAAO,QAAQ,gBAAgB,GAAG;CAC1E,MAAM,YACL,kCAAkC,OAAO,QAAQ,YAAY,GAAG,OAAO,QAAQ,cAAc;AAC9F,QAAO,OACN,YAAY,kCAAkC,YAAY,gCAC1D;;AAGF,SAAS,UAAU,SAAqD;AACvE,KAAI,CAAC,QAAQ,OACZ,OAAM,IAAI,MACT,uGACA;AAEF,QAAO,QAAQ;;AAGhB,eAAsB,mCACrB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AAM,SAAS,iBAAiB,MAAM,KAAK;AAC3C,OAAI,QAAQ;AACX,QAAI,OAAO;AACX,WAAO,OAAO,QAAQ,MAAM,IAAI,OAAO,KAAK,OAAO,UAAU,WAAW,CAAC;AACzE;;AAGD,OAAI,OAAO,eAAe,SACzB,OAAM,IAAI,MACT,sDAAsD,KAAK,UAC1D,YACA,MACA,EACA,GACD;AAGF,OAAI,OAAO;GACX,MAAM,mBAAiC,MAAM,iBAC1C;IACA,OAAO;IACP,kBAAkB,EACjB,UAAU,YACV;IACD,GACA;AAEH,UAAO,IAAI,SAAS;IACnB;GACD;;AAGH,SAAS,gBAAgB,iBAAyC,OAAe;CAChF,IAAI,gBAAgB;AAEpB,iBAAgB,aAAa,QAAQ,KAAK,OAAO;AAChD,MAAI,GAAG,YAAY,GAAG,SAAS,gBAAgB;GAC9C,MAAM,WAAW,GAAG,SAAS,UAAU,QAAQ,IAAI;AACnD,mBACC,GAAG,SAAS,eAAe,UAAU,cAAc,eAAe;;AAGpE,MACC,GAAG,UAAU,iBACb,GAAG,UAAU,gBACb,GAAG,UAAU,gBACb,GAAG,UAAU,kBAEb,iBAAgB;GAEhB;AAEF,QAAO;;AAGR,SAAS,kBAAkB,iBAAyC,OAAe;CAClF,IAAI,kBAAkB;AAEtB,iBAAgB,aAAa,QAAQ,KAAK,OAAO;AAChD,MAAI,GAAG,YAAY,GAAG,SAAS,gBAAgB;GAC9C,MAAM,WAAW,GAAG,SAAS,UAAU,QAAQ,IAAI;AACnD,qBAAkB,gBAAgB,GAAG,SAAS,eAAe,UAAU,IAAI;;GAE3E;AAEF,QAAO;;AAGR,MAAM,iBACL;AAED,SAAS,gBAAgB,MAA6C;AACrE,KAAI,KAAK,KAAK,UAAU,WACvB,QAAO;AAGR,QAAO,KAAK,KAAK,SAAS,aAAa"}
|
|
@@ -23,6 +23,12 @@ declare function toSerializedSignature({
|
|
|
23
23
|
* Decodes a serialized signature into its constituent components: the signature scheme, the actual signature, and the public key
|
|
24
24
|
*/
|
|
25
25
|
declare function parseSerializedSignature(serializedSignature: string): {
|
|
26
|
+
serializedSignature: string;
|
|
27
|
+
signatureScheme: "ED25519" | "Secp256k1" | "Secp256r1";
|
|
28
|
+
signature: Uint8Array<ArrayBuffer>;
|
|
29
|
+
publicKey: Uint8Array<ArrayBuffer>;
|
|
30
|
+
bytes: Uint8Array<ArrayBuffer>;
|
|
31
|
+
} | {
|
|
26
32
|
signatureScheme: "Passkey";
|
|
27
33
|
serializedSignature: string;
|
|
28
34
|
signature: Uint8Array<ArrayBufferLike>;
|
|
@@ -30,12 +36,6 @@ declare function parseSerializedSignature(serializedSignature: string): {
|
|
|
30
36
|
clientDataJson: string;
|
|
31
37
|
userSignature: Uint8Array<ArrayBuffer>;
|
|
32
38
|
publicKey: Uint8Array<ArrayBuffer>;
|
|
33
|
-
} | {
|
|
34
|
-
serializedSignature: string;
|
|
35
|
-
signatureScheme: "ED25519" | "Secp256k1" | "Secp256r1";
|
|
36
|
-
signature: Uint8Array<ArrayBuffer>;
|
|
37
|
-
publicKey: Uint8Array<ArrayBuffer>;
|
|
38
|
-
bytes: Uint8Array<ArrayBuffer>;
|
|
39
39
|
} | {
|
|
40
40
|
serializedSignature: string;
|
|
41
41
|
signatureScheme: "ZkLogin";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BatchGetObjectsRequest, BatchGetObjectsResponse, BatchGetTransactionsRequest, BatchGetTransactionsResponse, GetCheckpointRequest, GetCheckpointResponse, GetEpochRequest, GetEpochResponse, GetObjectRequest, GetObjectResponse, GetServiceInfoRequest, GetServiceInfoResponse, GetTransactionRequest, GetTransactionResponse } from "./ledger_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime0 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc0 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/ledger_service.client.d.ts
|
|
@@ -45,9 +45,9 @@ interface ILedgerServiceClient {
|
|
|
45
45
|
declare class LedgerServiceClient implements ILedgerServiceClient, ServiceInfo {
|
|
46
46
|
private readonly _transport;
|
|
47
47
|
typeName: string;
|
|
48
|
-
methods:
|
|
48
|
+
methods: _protobuf_ts_runtime_rpc0.MethodInfo<any, any>[];
|
|
49
49
|
options: {
|
|
50
|
-
[extensionName: string]:
|
|
50
|
+
[extensionName: string]: _protobuf_ts_runtime0.JsonValue;
|
|
51
51
|
};
|
|
52
52
|
constructor(_transport: RpcTransport);
|
|
53
53
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetDatatypeRequest, GetDatatypeResponse, GetFunctionRequest, GetFunctionResponse, GetPackageRequest, GetPackageResponse, ListPackageVersionsRequest, ListPackageVersionsResponse } from "./move_package_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime5 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc5 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/move_package_service.client.d.ts
|
|
@@ -31,9 +31,9 @@ interface IMovePackageServiceClient {
|
|
|
31
31
|
declare class MovePackageServiceClient implements IMovePackageServiceClient, ServiceInfo {
|
|
32
32
|
private readonly _transport;
|
|
33
33
|
typeName: string;
|
|
34
|
-
methods:
|
|
34
|
+
methods: _protobuf_ts_runtime_rpc5.MethodInfo<any, any>[];
|
|
35
35
|
options: {
|
|
36
|
-
[extensionName: string]:
|
|
36
|
+
[extensionName: string]: _protobuf_ts_runtime5.JsonValue;
|
|
37
37
|
};
|
|
38
38
|
constructor(_transport: RpcTransport);
|
|
39
39
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LookupNameRequest, LookupNameResponse, ReverseLookupNameRequest, ReverseLookupNameResponse } from "./name_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime1 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc1 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/name_service.client.d.ts
|
|
@@ -23,9 +23,9 @@ interface INameServiceClient {
|
|
|
23
23
|
declare class NameServiceClient implements INameServiceClient, ServiceInfo {
|
|
24
24
|
private readonly _transport;
|
|
25
25
|
typeName: string;
|
|
26
|
-
methods:
|
|
26
|
+
methods: _protobuf_ts_runtime_rpc1.MethodInfo<any, any>[];
|
|
27
27
|
options: {
|
|
28
|
-
[extensionName: string]:
|
|
28
|
+
[extensionName: string]: _protobuf_ts_runtime1.JsonValue;
|
|
29
29
|
};
|
|
30
30
|
constructor(_transport: RpcTransport);
|
|
31
31
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VerifySignatureRequest, VerifySignatureResponse } from "./signature_verification_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime2 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc2 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.ts
|
|
@@ -21,9 +21,9 @@ interface ISignatureVerificationServiceClient {
|
|
|
21
21
|
declare class SignatureVerificationServiceClient implements ISignatureVerificationServiceClient, ServiceInfo {
|
|
22
22
|
private readonly _transport;
|
|
23
23
|
typeName: string;
|
|
24
|
-
methods:
|
|
24
|
+
methods: _protobuf_ts_runtime_rpc2.MethodInfo<any, any>[];
|
|
25
25
|
options: {
|
|
26
|
-
[extensionName: string]:
|
|
26
|
+
[extensionName: string]: _protobuf_ts_runtime2.JsonValue;
|
|
27
27
|
};
|
|
28
28
|
constructor(_transport: RpcTransport);
|
|
29
29
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetBalanceRequest, GetBalanceResponse, GetCoinInfoRequest, GetCoinInfoResponse, ListBalancesRequest, ListBalancesResponse, ListDynamicFieldsRequest, ListDynamicFieldsResponse, ListOwnedObjectsRequest, ListOwnedObjectsResponse } from "./state_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime3 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc3 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/state_service.client.d.ts
|
|
@@ -35,9 +35,9 @@ interface IStateServiceClient {
|
|
|
35
35
|
declare class StateServiceClient implements IStateServiceClient, ServiceInfo {
|
|
36
36
|
private readonly _transport;
|
|
37
37
|
typeName: string;
|
|
38
|
-
methods:
|
|
38
|
+
methods: _protobuf_ts_runtime_rpc3.MethodInfo<any, any>[];
|
|
39
39
|
options: {
|
|
40
|
-
[extensionName: string]:
|
|
40
|
+
[extensionName: string]: _protobuf_ts_runtime3.JsonValue;
|
|
41
41
|
};
|
|
42
42
|
constructor(_transport: RpcTransport);
|
|
43
43
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SubscribeCheckpointsRequest, SubscribeCheckpointsResponse } from "./subscription_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime4 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc4 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServerStreamingCall, ServiceInfo } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/subscription_service.client.d.ts
|
|
@@ -31,9 +31,9 @@ interface ISubscriptionServiceClient {
|
|
|
31
31
|
declare class SubscriptionServiceClient implements ISubscriptionServiceClient, ServiceInfo {
|
|
32
32
|
private readonly _transport;
|
|
33
33
|
typeName: string;
|
|
34
|
-
methods:
|
|
34
|
+
methods: _protobuf_ts_runtime_rpc4.MethodInfo<any, any>[];
|
|
35
35
|
options: {
|
|
36
|
-
[extensionName: string]:
|
|
36
|
+
[extensionName: string]: _protobuf_ts_runtime4.JsonValue;
|
|
37
37
|
};
|
|
38
38
|
constructor(_transport: RpcTransport);
|
|
39
39
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExecuteTransactionRequest, ExecuteTransactionResponse, SimulateTransactionRequest, SimulateTransactionResponse } from "./transaction_execution_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime0 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc0 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.ts
|
|
@@ -23,9 +23,9 @@ interface ITransactionExecutionServiceClient {
|
|
|
23
23
|
declare class TransactionExecutionServiceClient implements ITransactionExecutionServiceClient, ServiceInfo {
|
|
24
24
|
private readonly _transport;
|
|
25
25
|
typeName: string;
|
|
26
|
-
methods:
|
|
26
|
+
methods: _protobuf_ts_runtime_rpc0.MethodInfo<any, any>[];
|
|
27
27
|
options: {
|
|
28
|
-
[extensionName: string]:
|
|
28
|
+
[extensionName: string]: _protobuf_ts_runtime0.JsonValue;
|
|
29
29
|
};
|
|
30
30
|
constructor(_transport: RpcTransport);
|
|
31
31
|
/**
|