@mysten/sui 2.14.0 → 2.15.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/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @mysten/sui.js
2
2
 
3
+ ## 2.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 43b2670: Re-export `GrpcWebFetchTransport`, `GrpcWebOptions`, and `RpcTransport` from
8
+ `@mysten/sui/grpc` so users can configure custom transports without adding `@protobuf-ts/*` as
9
+ direct dependencies.
10
+
11
+ ### Patch Changes
12
+
13
+ - ef0b8a7: Error when mixing SUI CoinWithBalance intents that use the gas coin with ones that set
14
+ useGasCoin: false in the same transaction, preventing potential double-counting of address
15
+ balance.
16
+
17
+ ## 2.14.1
18
+
19
+ ### Patch Changes
20
+
21
+ - 2d57e9c: Fix `normalizeStructTag` to reject top-level vector type strings with a clear error.
22
+ Previously, calling `normalizeStructTag('vector<0x2::sui::SUI>')` would produce a corrupted result
23
+ because the vector string was passed directly to `parseStructTag`, which misinterpreted it. The
24
+ function now throws an error directing callers to use `normalizeTypeTag` instead.
25
+ - a3f2b49: Remove coin reservation feature flag check from core resolver
26
+
3
27
  ## 2.14.0
4
28
 
5
29
  ### Minor Changes
@@ -545,7 +545,7 @@ declare const suiBcs: {
545
545
  version: string;
546
546
  digest: string;
547
547
  };
548
- }, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
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
- }, "Object" | "Pure" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
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
- }, "TransactionEffects" | "TransactionData" | "CheckpointSummary" | "PersonalMessage">;
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
- }, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
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
- }, "Object" | "Pure" | "FundsWithdrawal">[];
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
- }, "Epoch" | "None" | "ValidDuring">;
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
- }, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
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
- }, "Object" | "Pure" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
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
- }, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
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
- }, "Object" | "Pure" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
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
- }, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
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
- }, "Object" | "Pure" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
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" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">][], Iterable<readonly [{
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" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">][], Iterable<readonly [{
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" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">][], Iterable<readonly [{
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" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">];
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" | "ConsensusAddressOwner" | "Immutable" | "ObjectOwner" | "Shared">];
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
- }, "MutateConsensusStreamEnded" | "PerEpochConfig" | "ReadConsensusStreamEnded" | "ReadOnlyRoot" | "Cancelled">][], Iterable<readonly [string | Uint8Array<ArrayBufferLike>, _mysten_bcs0.EnumInputShape<{
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
- }, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
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
- }, "Object" | "Pure" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
2769
+ }, "Pure" | "Object" | "FundsWithdrawal">[], Iterable<_mysten_bcs0.EnumInputShape<{
2770
2770
  Pure: {
2771
2771
  bytes: string | Uint8Array<ArrayBufferLike>;
2772
2772
  };
@@ -40,7 +40,7 @@ async function coreClientResolveTransactionPlugin(transactionData, options, next
40
40
  if (withdrawalOwner && normalizeSuiAddress(withdrawalOwner) === normalizedGasPayer && input.FundsWithdrawal.reservation.$kind === "MaxAmountU64") withdrawals += BigInt(input.FundsWithdrawal.reservation.MaxAmountU64);
41
41
  }
42
42
  const needsSystemState = needsGasPrice || needsPayment && usesGasCoin;
43
- const [, systemStateResult, balanceResult, coinsResult, protocolConfigResult, chainIdResult] = await Promise.all([
43
+ const [, systemStateResult, balanceResult, coinsResult, chainIdResult] = await Promise.all([
44
44
  normalizeInputs(transactionData, client),
45
45
  needsSystemState ? client.core.getCurrentSystemState() : null,
46
46
  needsPayment && gasPayer ? client.core.getBalance({ owner: gasPayer }) : null,
@@ -48,7 +48,6 @@ async function coreClientResolveTransactionPlugin(transactionData, options, next
48
48
  owner: gasPayer,
49
49
  coinType: SUI_TYPE_ARG
50
50
  }) : null,
51
- needsPayment && usesGasCoin ? client.core.getProtocolConfig() : null,
52
51
  needsPayment && usesGasCoin ? client.core.getChainIdentifier() : null
53
52
  ]);
54
53
  await resolveObjectReferences(transactionData, client);
@@ -64,7 +63,6 @@ async function coreClientResolveTransactionPlugin(transactionData, options, next
64
63
  coins: coinsResult,
65
64
  usesGasCoin,
66
65
  withdrawals,
67
- protocolConfig: protocolConfigResult?.protocolConfig,
68
66
  gasPayer,
69
67
  chainIdentifier: chainIdResult?.chainIdentifier ?? null,
70
68
  epoch: systemState?.epoch ?? null
@@ -92,7 +90,7 @@ async function setGasBudget(transactionData, client) {
92
90
  }
93
91
  transactionData.gasData.budget = computeGasBudget(simulateResult.Transaction.effects.gasUsed, transactionData.gasData.price ? String(transactionData.gasData.price) : void 0);
94
92
  }
95
- function setGasPayment({ transactionData, balance, coins, usesGasCoin, withdrawals, protocolConfig, gasPayer, chainIdentifier, epoch }) {
93
+ function setGasPayment({ transactionData, balance, coins, usesGasCoin, withdrawals, gasPayer, chainIdentifier, epoch }) {
96
94
  const budget = BigInt(transactionData.gasData.budget);
97
95
  const addressBalance = BigInt(balance.balance.addressBalance);
98
96
  if (budget === 0n || !usesGasCoin && addressBalance >= budget + withdrawals) {
@@ -111,7 +109,7 @@ function setGasPayment({ transactionData, balance, coins, usesGasCoin, withdrawa
111
109
  version: coin.version
112
110
  }));
113
111
  const reservationAmount = addressBalance - withdrawals;
114
- if (usesGasCoin && reservationAmount > 0n && protocolConfig?.featureFlags?.["enable_coin_reservation_obj_refs"] && chainIdentifier && epoch) transactionData.gasData.payment = [createCoinReservationRef(reservationAmount, gasPayer, chainIdentifier, epoch), ...paymentCoins];
112
+ if (usesGasCoin && reservationAmount > 0n && chainIdentifier && epoch) transactionData.gasData.payment = [createCoinReservationRef(reservationAmount, gasPayer, chainIdentifier, epoch), ...paymentCoins];
115
113
  else if (!filteredCoins.length) throw new Error("No valid gas coins found for the transaction.");
116
114
  else transactionData.gasData.payment = paymentCoins;
117
115
  }
@@ -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, protocolConfigResult, chainIdResult] =\n\t\tawait Promise.all([\n\t\t\tnormalizeInputs(transactionData, client),\n\t\t\tneedsSystemState ? client.core.getCurrentSystemState() : null,\n\t\t\tneedsPayment && gasPayer ? client.core.getBalance({ owner: gasPayer }) : null,\n\t\t\tneedsPayment && gasPayer\n\t\t\t\t? client.core.listCoins({ owner: gasPayer, coinType: SUI_TYPE_ARG })\n\t\t\t\t: null,\n\t\t\tneedsPayment && usesGasCoin ? client.core.getProtocolConfig() : null,\n\t\t\tneedsPayment && usesGasCoin ? client.core.getChainIdentifier() : null,\n\t\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\tprotocolConfig: protocolConfigResult?.protocolConfig,\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\tprotocolConfig,\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\tprotocolConfig: SuiClientTypes.ProtocolConfig | undefined;\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 (\n\t\tusesGasCoin &&\n\t\treservationAmount > 0n &&\n\t\tprotocolConfig?.featureFlags?.['enable_coin_reservation_obj_refs'] &&\n\t\tchainIdentifier &&\n\t\tepoch\n\t) {\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;AAC3C,SAAO;GACN;CAEF,MAAM,qBAAqB,WAAW,oBAAoB,SAAS,GAAG;AACtE,MAAK,MAAM,SAAS,gBAAgB,QAAQ;AAC3C,MAAI,MAAM,UAAU,qB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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\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,MA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1
  import { GrpcCoreClient, GrpcCoreClientOptions } from "./core.mjs";
2
2
  import { SuiGrpcClient, SuiGrpcClientOptions, isSuiGrpcClient } from "./client.mjs";
3
3
  import { types_d_exports } from "./proto/types.mjs";
4
- export { GrpcCoreClient, type GrpcCoreClientOptions, types_d_exports as GrpcTypes, SuiGrpcClient, type SuiGrpcClientOptions, isSuiGrpcClient };
4
+ import { GrpcWebFetchTransport, GrpcWebOptions } from "@protobuf-ts/grpcweb-transport";
5
+ import { RpcTransport } from "@protobuf-ts/runtime-rpc";
6
+ export { GrpcCoreClient, type GrpcCoreClientOptions, types_d_exports as GrpcTypes, GrpcWebFetchTransport, type GrpcWebOptions, type RpcTransport, SuiGrpcClient, type SuiGrpcClientOptions, isSuiGrpcClient };
@@ -1,5 +1,6 @@
1
1
  import { GrpcCoreClient } from "./core.mjs";
2
2
  import { SuiGrpcClient, isSuiGrpcClient } from "./client.mjs";
3
3
  import { types_exports } from "./proto/types.mjs";
4
+ import { GrpcWebFetchTransport } from "@protobuf-ts/grpcweb-transport";
4
5
 
5
- export { GrpcCoreClient, types_exports as GrpcTypes, SuiGrpcClient, isSuiGrpcClient };
6
+ export { GrpcCoreClient, types_exports as GrpcTypes, GrpcWebFetchTransport, SuiGrpcClient, isSuiGrpcClient };
@@ -1,6 +1,6 @@
1
1
  import { GetDatatypeRequest, GetDatatypeResponse, GetFunctionRequest, GetFunctionResponse, GetPackageRequest, GetPackageResponse, ListPackageVersionsRequest, ListPackageVersionsResponse } from "./move_package_service.mjs";
2
- import * as _protobuf_ts_runtime0 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc0 from "@protobuf-ts/runtime-rpc";
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/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: _protobuf_ts_runtime_rpc0.MethodInfo<any, any>[];
34
+ methods: _protobuf_ts_runtime_rpc2.MethodInfo<any, any>[];
35
35
  options: {
36
- [extensionName: string]: _protobuf_ts_runtime0.JsonValue;
36
+ [extensionName: string]: _protobuf_ts_runtime2.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 _protobuf_ts_runtime5 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc5 from "@protobuf-ts/runtime-rpc";
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/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: _protobuf_ts_runtime_rpc5.MethodInfo<any, any>[];
26
+ methods: _protobuf_ts_runtime_rpc0.MethodInfo<any, any>[];
27
27
  options: {
28
- [extensionName: string]: _protobuf_ts_runtime5.JsonValue;
28
+ [extensionName: string]: _protobuf_ts_runtime0.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 _protobuf_ts_runtime2 from "@protobuf-ts/runtime";
3
- import * as _protobuf_ts_runtime_rpc2 from "@protobuf-ts/runtime-rpc";
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/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: _protobuf_ts_runtime_rpc2.MethodInfo<any, any>[];
24
+ methods: _protobuf_ts_runtime_rpc5.MethodInfo<any, any>[];
25
25
  options: {
26
- [extensionName: string]: _protobuf_ts_runtime2.JsonValue;
26
+ [extensionName: string]: _protobuf_ts_runtime5.JsonValue;
27
27
  };
28
28
  constructor(_transport: RpcTransport);
29
29
  /**
@@ -88,7 +88,7 @@ declare class Transaction {
88
88
  chain: string;
89
89
  nonce: number;
90
90
  };
91
- }, "Epoch" | "None" | "ValidDuring"> | null | undefined;
91
+ }, "None" | "Epoch" | "ValidDuring"> | null | undefined;
92
92
  gasData: {
93
93
  budget: string | number | null;
94
94
  price: string | number | null;
@@ -116,7 +116,7 @@ declare class Transaction {
116
116
  version: string | number;
117
117
  digest: string;
118
118
  };
119
- }, "Receiving" | "ImmOrOwnedObject" | "SharedObject">;
119
+ }, "ImmOrOwnedObject" | "SharedObject" | "Receiving">;
120
120
  Pure: {
121
121
  bytes: string;
122
122
  };
@@ -144,7 +144,7 @@ declare class Transaction {
144
144
  Sponsor: true;
145
145
  }, "Sender" | "Sponsor">;
146
146
  };
147
- }, "Object" | "Pure" | "FundsWithdrawal" | "UnresolvedPure" | "UnresolvedObject">[];
147
+ }, "Pure" | "Object" | "FundsWithdrawal" | "UnresolvedPure" | "UnresolvedObject">[];
148
148
  commands: _mysten_bcs1124.EnumOutputShapeWithKeys<{
149
149
  MoveCall: {
150
150
  package: string;