@mysten/sui 2.17.0 → 2.19.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 +29 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/bcs/index.d.mts +20 -20
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/transactions/Transaction.d.mts +25 -11
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/transactions/Transaction.mjs +8 -3
- package/dist/transactions/Transaction.mjs.map +1 -1
- package/dist/transactions/index.d.mts +2 -2
- package/dist/verify/index.d.mts +2 -2
- package/dist/verify/index.mjs +2 -2
- package/dist/verify/verify.d.mts +21 -1
- package/dist/verify/verify.d.mts.map +1 -1
- package/dist/verify/verify.mjs +49 -14
- package/dist/verify/verify.mjs.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/jwt-utils.d.mts.map +1 -1
- package/dist/zklogin/jwt-utils.mjs.map +1 -1
- package/dist/zklogin/utils.d.mts.map +1 -1
- package/dist/zklogin/utils.mjs +9 -0
- package/dist/zklogin/utils.mjs.map +1 -1
- package/docs/bcs.md +11 -6
- package/docs/clients/core.md +10 -9
- package/docs/clients/grpc.md +1 -1
- package/docs/index.md +176 -22
- package/docs/llms-index.md +6 -9
- package/docs/migrations/0.38.md +2 -2
- package/docs/migrations/sui-1.0.md +2 -2
- package/docs/migrations/sui-2.0/dapp-kit.md +5 -1
- package/docs/migrations/sui-2.0/json-rpc-migration.md +76 -33
- package/docs/plugins.md +29 -5
- package/docs/transactions/basics.md +279 -0
- package/docs/transactions/coins-and-balances.md +293 -0
- package/docs/transactions/offline.md +192 -0
- package/docs/transactions/reference.md +380 -0
- package/docs/transactions/signing-and-execution.md +401 -0
- package/package.json +26 -26
- package/src/transactions/Transaction.ts +36 -5
- package/src/transactions/index.ts +1 -0
- package/src/verify/index.ts +3 -0
- package/src/verify/verify.ts +68 -34
- package/src/version.ts +1 -1
- package/src/zklogin/jwt-utils.ts +3 -0
- package/src/zklogin/utils.ts +17 -0
- package/docs/faucet.md +0 -26
- package/docs/hello-sui.md +0 -115
- package/docs/install.md +0 -61
- package/docs/transaction-building/basics.md +0 -299
- package/docs/transaction-building/gas.md +0 -61
- package/docs/transaction-building/intents.md +0 -62
- package/docs/transaction-building/offline.md +0 -73
- package/docs/transaction-building/sponsored-transactions.md +0 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @mysten/sui.js
|
|
2
2
|
|
|
3
|
+
## 2.19.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2be98ce: Add `isValidSignature`, `isValidPersonalMessageSignature`, and
|
|
8
|
+
`isValidTransactionSignature` to `@mysten/sui/verify` — boolean-returning siblings of the existing
|
|
9
|
+
`verify*` functions, taking the same arguments. They return `false` for a malformed or invalid
|
|
10
|
+
signature (or one that doesn't match a supplied `address`) instead of throwing, while still
|
|
11
|
+
letting a genuine environmental failure during verification (e.g. a zkLogin JWK/epoch lookup)
|
|
12
|
+
propagate. The `verify*` functions now delegate to these.
|
|
13
|
+
|
|
14
|
+
## 2.18.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- b093d05: `Transaction.from` now accepts an optional `intentResolvers` option, a map of intent
|
|
19
|
+
names to resolvers. This lets you synchronously copy a transaction that still contains unresolved
|
|
20
|
+
custom intents without first awaiting `prepareForSerialization`. Built-in intents (such as
|
|
21
|
+
`CoinWithBalance`) continue to be handled automatically.
|
|
22
|
+
- bbf63cb: Updated dependencies
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- 4ca4c66: zkLogin: `genAddressSeed` now rejects key claim name, value, or aud that contain a JSON
|
|
27
|
+
escape (`"`, `\`, or a control character).
|
|
28
|
+
- Updated dependencies [bbf63cb]
|
|
29
|
+
- @mysten/bcs@2.1.0
|
|
30
|
+
- @mysten/utils@0.4.0
|
|
31
|
+
|
|
3
32
|
## 2.17.0
|
|
4
33
|
|
|
5
34
|
### Minor 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
|
};
|
|
@@ -23,12 +23,6 @@ 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
|
-
} | {
|
|
32
26
|
signatureScheme: "Passkey";
|
|
33
27
|
serializedSignature: string;
|
|
34
28
|
signature: Uint8Array<ArrayBufferLike>;
|
|
@@ -36,6 +30,12 @@ declare function parseSerializedSignature(serializedSignature: string): {
|
|
|
36
30
|
clientDataJson: string;
|
|
37
31
|
userSignature: Uint8Array<ArrayBuffer>;
|
|
38
32
|
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";
|
|
@@ -8,7 +8,7 @@ import { createPure } from "./pure.mjs";
|
|
|
8
8
|
import { SignatureWithBytes, Signer } from "../cryptography/keypair.mjs";
|
|
9
9
|
import "../cryptography/index.mjs";
|
|
10
10
|
import { ClientWithCoreApi } from "../client/core.mjs";
|
|
11
|
-
import * as
|
|
11
|
+
import * as _mysten_bcs1124 from "@mysten/bcs";
|
|
12
12
|
import { SerializedBcs } from "@mysten/bcs";
|
|
13
13
|
import { InferInput } from "valibot";
|
|
14
14
|
|
|
@@ -40,6 +40,16 @@ type TransactionObjectInput = string | CallArg | TransactionObjectArgument;
|
|
|
40
40
|
type TransactionLike = {
|
|
41
41
|
getData(): unknown;
|
|
42
42
|
};
|
|
43
|
+
interface TransactionCopyOptions {
|
|
44
|
+
/**
|
|
45
|
+
* A map of intent names to resolvers for any custom intents used in the transaction being copied.
|
|
46
|
+
*
|
|
47
|
+
* Built-in intents (such as `CoinWithBalance`) are handled automatically. Providing resolvers for
|
|
48
|
+
* custom intents lets `Transaction.from` copy a transaction synchronously even when it still
|
|
49
|
+
* contains unresolved intents, without first awaiting `prepareForSerialization`.
|
|
50
|
+
*/
|
|
51
|
+
intentResolvers?: Record<string, TransactionPlugin>;
|
|
52
|
+
}
|
|
43
53
|
/**
|
|
44
54
|
* Transaction Builder
|
|
45
55
|
*/
|
|
@@ -56,8 +66,12 @@ declare class Transaction {
|
|
|
56
66
|
* There are two supported serialized formats:
|
|
57
67
|
* - A string returned from `Transaction#serialize`. The serialized format must be compatible, or it will throw an error.
|
|
58
68
|
* - A byte array (or base64-encoded bytes) containing BCS transaction data.
|
|
69
|
+
*
|
|
70
|
+
* When copying an in-memory transaction that uses custom intents, pass resolvers for those intents
|
|
71
|
+
* via `options.intentResolvers` so the copy can be created synchronously without first awaiting
|
|
72
|
+
* `prepareForSerialization`. Built-in intents (such as `CoinWithBalance`) are handled automatically.
|
|
59
73
|
*/
|
|
60
|
-
static from(transaction: string | Uint8Array | TransactionLike): Transaction;
|
|
74
|
+
static from(transaction: string | Uint8Array | TransactionLike, options?: TransactionCopyOptions): Transaction;
|
|
61
75
|
addSerializationPlugin(step: TransactionPlugin): void;
|
|
62
76
|
addBuildPlugin(step: TransactionPlugin): void;
|
|
63
77
|
addIntentResolver(intent: string, resolver: TransactionPlugin): void;
|
|
@@ -77,7 +91,7 @@ declare class Transaction {
|
|
|
77
91
|
getData(): {
|
|
78
92
|
version: 2;
|
|
79
93
|
sender?: string | null | undefined;
|
|
80
|
-
expiration?:
|
|
94
|
+
expiration?: _mysten_bcs1124.EnumOutputShapeWithKeys<{
|
|
81
95
|
None: true;
|
|
82
96
|
Epoch: string | number;
|
|
83
97
|
ValidDuring: {
|
|
@@ -88,7 +102,7 @@ declare class Transaction {
|
|
|
88
102
|
chain: string;
|
|
89
103
|
nonce: number;
|
|
90
104
|
};
|
|
91
|
-
}, "
|
|
105
|
+
}, "None" | "Epoch" | "ValidDuring"> | null | undefined;
|
|
92
106
|
gasData: {
|
|
93
107
|
budget: string | number | null;
|
|
94
108
|
price: string | number | null;
|
|
@@ -99,8 +113,8 @@ declare class Transaction {
|
|
|
99
113
|
digest: string;
|
|
100
114
|
}[] | null;
|
|
101
115
|
};
|
|
102
|
-
inputs:
|
|
103
|
-
Object:
|
|
116
|
+
inputs: _mysten_bcs1124.EnumOutputShapeWithKeys<{
|
|
117
|
+
Object: _mysten_bcs1124.EnumOutputShapeWithKeys<{
|
|
104
118
|
ImmOrOwnedObject: {
|
|
105
119
|
objectId: string;
|
|
106
120
|
version: string | number;
|
|
@@ -116,7 +130,7 @@ declare class Transaction {
|
|
|
116
130
|
version: string | number;
|
|
117
131
|
digest: string;
|
|
118
132
|
};
|
|
119
|
-
}, "
|
|
133
|
+
}, "ImmOrOwnedObject" | "SharedObject" | "Receiving">;
|
|
120
134
|
Pure: {
|
|
121
135
|
bytes: string;
|
|
122
136
|
};
|
|
@@ -139,13 +153,13 @@ declare class Transaction {
|
|
|
139
153
|
Balance: string;
|
|
140
154
|
$kind: "Balance";
|
|
141
155
|
};
|
|
142
|
-
withdrawFrom:
|
|
156
|
+
withdrawFrom: _mysten_bcs1124.EnumOutputShapeWithKeys<{
|
|
143
157
|
Sender: true;
|
|
144
158
|
Sponsor: true;
|
|
145
159
|
}, "Sender" | "Sponsor">;
|
|
146
160
|
};
|
|
147
|
-
}, "
|
|
148
|
-
commands:
|
|
161
|
+
}, "Pure" | "Object" | "FundsWithdrawal" | "UnresolvedPure" | "UnresolvedObject">[];
|
|
162
|
+
commands: _mysten_bcs1124.EnumOutputShapeWithKeys<{
|
|
149
163
|
MoveCall: {
|
|
150
164
|
package: string;
|
|
151
165
|
module: string;
|
|
@@ -514,5 +528,5 @@ declare class Transaction {
|
|
|
514
528
|
prepareForSerialization(options: SerializeTransactionOptions): Promise<void>;
|
|
515
529
|
}
|
|
516
530
|
//#endregion
|
|
517
|
-
export { AsyncTransactionThunk, Transaction, TransactionObjectArgument, TransactionObjectInput, TransactionResult, isTransaction };
|
|
531
|
+
export { AsyncTransactionThunk, Transaction, TransactionCopyOptions, TransactionObjectArgument, TransactionObjectInput, TransactionResult, isTransaction };
|
|
518
532
|
//# sourceMappingURL=Transaction.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.d.mts","names":[],"sources":["../../src/transactions/Transaction.ts"],"mappings":";;;;;;;;;;;;;;;KAyCY,yBAAA,GACT,OAAA,CAAQ,UAAA,QAAkB,cAAA;EAAmB,KAAA;EAAgB,IAAA;AAAA,OAE7D,EAAA,EAAI,WAAA,KACC,OAAA,CAAQ,UAAA,QAAkB,cAAA;EAAmB,KAAA;EAAgB,IAAA;AAAA,MAClE,qBAAA,CAAsB,yBAAA;AAAA,KAEb,iBAAA,GAAoB,OAAA,CAAQ,QAAA;EAAY,MAAA;AAAA,KACnD,OAAA,CAAQ,QAAA;EAAY,YAAA;AAAA;AA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yBAAA;EAAA,IACR,iBAAA;EAUD,QAAA,CAAA;IACC,SAAA,EAAW,IAAA;IAAA,GACR;EAAA;IAGD,OAAA;IACA,MAAA;IACA,QAAA;IACA,SAAA,IAAa,mBAAA,GAAsB,aAAA;IACnC,aAAA;EAAA;IAGA,MAAA;IACA,SAAA,IAAa,mBAAA,GAAsB,aAAA;IACnC,aAAA;EAAA,IACC,iBAAA;EAQJ,eAAA,CACC,OAAA,GAAU,yBAAA,cACV,OAAA,EAAS,mBAAA,GAAsB,aAAA,iBAA2B,iBAAA;EAW3D,WAAA,CAAA;IACC,IAAA;IACA;EAAA;IAEA,QAAA,GAAW,yBAAA;IACX,IAAA;EAAA,IACA,iBAAA;;;;;;;;EAgBD,UAAA,CAAA;IAAa,MAAA;IAAQ;EAAA;IAAU,MAAA;IAAkC,IAAA;EAAA;IAChE,KAAA;IACA,KAAA;IACA,IAAA;EAAA;;;;;EAuBD,SAAA,CAAA;EAIM,MAAA,CAAO,OAAA,GAAS,2BAAA,GAAmC,OAAA;;EAmBnD,IAAA,CAAK,OAAA,EAAS,WAAA,GAAc,OAAA,CAAQ,kBAAA;;;;;;;;;;EAe1C,0BAAA,CAA2B,OAAA;IAAW,gBAAA;EAAA;;;;;;;;;;;;EA2BtC,eAAA,CAAA;;EAiBM,KAAA,CAAM,OAAA,GAAS,uBAAA,GAA+B,OAAA,CAAQ,UAAA,CAAW,WAAA;EA7btE;EAscK,SAAA,CACL,OAAA;IACC,MAAA,GAAS,iBAAA;EAAA,IAER,OAAA;EAsJG,uBAAA,CAAwB,OAAA,EAAS,2BAAA,GAA2B,OAAA;AAAA"}
|
|
@@ -82,8 +82,12 @@ var Transaction = class Transaction {
|
|
|
82
82
|
* There are two supported serialized formats:
|
|
83
83
|
* - A string returned from `Transaction#serialize`. The serialized format must be compatible, or it will throw an error.
|
|
84
84
|
* - A byte array (or base64-encoded bytes) containing BCS transaction data.
|
|
85
|
+
*
|
|
86
|
+
* When copying an in-memory transaction that uses custom intents, pass resolvers for those intents
|
|
87
|
+
* via `options.intentResolvers` so the copy can be created synchronously without first awaiting
|
|
88
|
+
* `prepareForSerialization`. Built-in intents (such as `CoinWithBalance`) are handled automatically.
|
|
85
89
|
*/
|
|
86
|
-
static from(transaction) {
|
|
90
|
+
static from(transaction, options = {}) {
|
|
87
91
|
const newTransaction = new Transaction();
|
|
88
92
|
if (isTransaction(transaction)) newTransaction.#data = TransactionDataBuilder.restore(transaction.getData());
|
|
89
93
|
else if (typeof transaction !== "string" || !transaction.startsWith("{")) newTransaction.#data = TransactionDataBuilder.fromBytes(typeof transaction === "string" ? fromBase64(transaction) : transaction);
|
|
@@ -91,8 +95,9 @@ var Transaction = class Transaction {
|
|
|
91
95
|
newTransaction.#inputSection = newTransaction.#data.inputs.slice();
|
|
92
96
|
newTransaction.#commandSection = newTransaction.#data.commands.slice();
|
|
93
97
|
newTransaction.#availableResults = new Set(newTransaction.#commandSection.map((_, i) => i));
|
|
94
|
-
|
|
95
|
-
if (newTransaction
|
|
98
|
+
const intentResolvers = new Map([[COIN_WITH_BALANCE, resolveCoinBalance], ...Object.entries(options.intentResolvers ?? {})]);
|
|
99
|
+
if (!newTransaction.isPreparedForSerialization({ supportedIntents: [...intentResolvers.keys()] })) throw new Error("Transaction has unresolved intents or async thunks. Provide resolvers for any custom intents via the `intentResolvers` option, or call `prepareForSerialization` before copying.");
|
|
100
|
+
for (const [intent, resolver] of intentResolvers) newTransaction.addIntentResolver(intent, resolver);
|
|
96
101
|
return newTransaction;
|
|
97
102
|
}
|
|
98
103
|
addSerializationPlugin(step) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.mjs","names":["#data","#inputSection","#commandSection","#availableResults","#serializationPlugins","#buildPlugins","#intentResolvers","#addInput","#pendingPromises","#added","#fork","#addCommand","result","#resolveArgument","#normalizeTransactionArgument","#prepareBuild","#runPlugins","#waitForPendingTasks","#sortCommandsAndInputs"],"sources":["../../src/transactions/Transaction.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { SerializedBcs } from '@mysten/bcs';\nimport { fromBase64, isSerializedBcs } from '@mysten/bcs';\nimport type { InferInput } from 'valibot';\nimport { is, parse } from 'valibot';\n\nimport type { SignatureWithBytes, Signer } from '../cryptography/index.js';\nimport { normalizeSuiAddress } from '../utils/sui-types.js';\nimport type { TransactionArgument } from './Commands.js';\nimport { TransactionCommands } from './Commands.js';\nimport type { CallArg, Command, Argument, ObjectRef } from './data/internal.js';\nimport {\n\tArgumentSchema,\n\tNormalizedCallArg,\n\tObjectRefSchema,\n\tTransactionExpiration,\n} from './data/internal.js';\nimport { serializeV1TransactionData } from './data/v1.js';\nimport { SerializedTransactionDataV2Schema } from './data/v2.js';\nimport { Inputs } from './Inputs.js';\nimport { needsTransactionResolution, resolveTransactionPlugin } from './resolve.js';\nimport type {\n\tBuildTransactionOptions,\n\tSerializeTransactionOptions,\n\tTransactionPlugin,\n} from './resolve.js';\nimport { createObjectMethods } from './object.js';\nimport { createPure } from './pure.js';\nimport { TransactionDataBuilder } from './TransactionData.js';\nimport { getIdFromCallArg } from './utils.js';\nimport { namedPackagesPlugin } from './plugins/NamedPackagesPlugin.js';\nimport {\n\tCOIN_WITH_BALANCE,\n\tresolveCoinBalance,\n\tcoinWithBalance,\n\tcreateBalance,\n} from './intents/CoinWithBalance.js';\nimport type { ClientWithCoreApi } from '../client/core.js';\n\nexport type TransactionObjectArgument =\n\t| Exclude<InferInput<typeof ArgumentSchema>, { Input: unknown; type?: 'pure' }>\n\t| ((\n\t\t\ttx: Transaction,\n\t ) => Exclude<InferInput<typeof ArgumentSchema>, { Input: unknown; type?: 'pure' }>)\n\t| AsyncTransactionThunk<TransactionResultArgument>;\n\nexport type TransactionResult = Extract<Argument, { Result: unknown }> &\n\tExtract<Argument, { NestedResult: unknown }>[];\n\nexport type TransactionResultArgument =\n\t| Extract<Argument, { Result: unknown }>\n\t| readonly Extract<Argument, { NestedResult: unknown }>[];\n\nexport type AsyncTransactionThunk<\n\tT extends TransactionResultArgument | void = TransactionResultArgument | void,\n> = (tx: Transaction) => Promise<T | void>;\n\nfunction createTransactionResult(\n\tindex: number | (() => number),\n\tlength = Infinity,\n): TransactionResult {\n\tconst baseResult = {\n\t\t$kind: 'Result' as const,\n\t\tget Result() {\n\t\t\treturn typeof index === 'function' ? index() : index;\n\t\t},\n\t};\n\n\tconst nestedResults: {\n\t\t$kind: 'NestedResult';\n\t\tNestedResult: [number, number];\n\t}[] = [];\n\tconst nestedResultFor = (\n\t\tresultIndex: number,\n\t): {\n\t\t$kind: 'NestedResult';\n\t\tNestedResult: [number, number];\n\t} =>\n\t\t(nestedResults[resultIndex] ??= {\n\t\t\t$kind: 'NestedResult' as const,\n\t\t\tget NestedResult() {\n\t\t\t\treturn [typeof index === 'function' ? index() : index, resultIndex] as [number, number];\n\t\t\t},\n\t\t});\n\n\treturn new Proxy(baseResult, {\n\t\tset() {\n\t\t\tthrow new Error(\n\t\t\t\t'The transaction result is a proxy, and does not support setting properties directly',\n\t\t\t);\n\t\t},\n\t\t// TODO: Instead of making this return a concrete argument, we should ideally\n\t\t// make it reference-based (so that this gets resolved at build-time), which\n\t\t// allows re-ordering transactions.\n\t\tget(target, property) {\n\t\t\t// This allows this transaction argument to be used in the singular form:\n\t\t\tif (property in target) {\n\t\t\t\treturn Reflect.get(target, property);\n\t\t\t}\n\n\t\t\t// Support destructuring:\n\t\t\tif (property === Symbol.iterator) {\n\t\t\t\treturn function* () {\n\t\t\t\t\tlet i = 0;\n\t\t\t\t\twhile (i < length) {\n\t\t\t\t\t\tyield nestedResultFor(i);\n\t\t\t\t\t\ti++;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (typeof property === 'symbol') return;\n\n\t\t\tconst resultIndex = parseInt(property, 10);\n\t\t\tif (Number.isNaN(resultIndex) || resultIndex < 0) return;\n\t\t\treturn nestedResultFor(resultIndex);\n\t\t},\n\t}) as TransactionResult;\n}\n\nconst TRANSACTION_BRAND = Symbol.for('@mysten/transaction') as never;\n\ninterface SignOptions extends BuildTransactionOptions {\n\tsigner: Signer;\n}\n\nexport function isTransaction(obj: unknown): obj is TransactionLike {\n\treturn !!obj && typeof obj === 'object' && (obj as any)[TRANSACTION_BRAND] === true;\n}\n\nexport type TransactionObjectInput = string | CallArg | TransactionObjectArgument;\n\ntype InputSection = (CallArg | InputSection)[];\ntype CommandSection = (Command | CommandSection)[];\n\ntype TransactionLike = {\n\tgetData(): unknown;\n};\n\n/**\n * Transaction Builder\n */\nexport class Transaction {\n\t#serializationPlugins: TransactionPlugin[];\n\t#buildPlugins: TransactionPlugin[];\n\t#intentResolvers = new Map<string, TransactionPlugin>();\n\t#inputSection: InputSection = [];\n\t#commandSection: CommandSection = [];\n\t#availableResults: Set<number> = new Set();\n\t#pendingPromises = new Set<Promise<unknown>>();\n\t#added = new Map<(...args: any[]) => unknown, unknown>();\n\n\t/**\n\t * Converts from a serialize transaction kind (built with `build({ onlyTransactionKind: true })`) to a `Transaction` class.\n\t * Supports either a byte array, or base64-encoded bytes.\n\t */\n\tstatic fromKind(serialized: string | Uint8Array) {\n\t\tconst tx = new Transaction();\n\n\t\ttx.#data = TransactionDataBuilder.fromKindBytes(\n\t\t\ttypeof serialized === 'string' ? fromBase64(serialized) : serialized,\n\t\t);\n\n\t\ttx.#inputSection = tx.#data.inputs.slice();\n\t\ttx.#commandSection = tx.#data.commands.slice();\n\t\ttx.#availableResults = new Set(tx.#commandSection.map((_, i) => i));\n\n\t\treturn tx;\n\t}\n\n\t/**\n\t * Converts from a serialized transaction format to a `Transaction` class.\n\t * There are two supported serialized formats:\n\t * - A string returned from `Transaction#serialize`. The serialized format must be compatible, or it will throw an error.\n\t * - A byte array (or base64-encoded bytes) containing BCS transaction data.\n\t */\n\tstatic from(transaction: string | Uint8Array | TransactionLike) {\n\t\tconst newTransaction = new Transaction();\n\n\t\tif (isTransaction(transaction)) {\n\t\t\tnewTransaction.#data = TransactionDataBuilder.restore(\n\t\t\t\ttransaction.getData() as InferInput<typeof SerializedTransactionDataV2Schema>,\n\t\t\t);\n\t\t} else if (typeof transaction !== 'string' || !transaction.startsWith('{')) {\n\t\t\tnewTransaction.#data = TransactionDataBuilder.fromBytes(\n\t\t\t\ttypeof transaction === 'string' ? fromBase64(transaction) : transaction,\n\t\t\t);\n\t\t} else {\n\t\t\tnewTransaction.#data = TransactionDataBuilder.restore(JSON.parse(transaction));\n\t\t}\n\n\t\tnewTransaction.#inputSection = newTransaction.#data.inputs.slice();\n\t\tnewTransaction.#commandSection = newTransaction.#data.commands.slice();\n\t\tnewTransaction.#availableResults = new Set(newTransaction.#commandSection.map((_, i) => i));\n\n\t\tif (!newTransaction.isPreparedForSerialization({ supportedIntents: [COIN_WITH_BALANCE] })) {\n\t\t\tthrow new Error(\n\t\t\t\t'Transaction has unresolved intents or async thunks. Call `prepareForSerialization` before copying.',\n\t\t\t);\n\t\t}\n\n\t\tif (newTransaction.#data.commands.some((cmd) => cmd.$Intent?.name === COIN_WITH_BALANCE)) {\n\t\t\tnewTransaction.addIntentResolver(COIN_WITH_BALANCE, resolveCoinBalance);\n\t\t}\n\n\t\treturn newTransaction;\n\t}\n\n\taddSerializationPlugin(step: TransactionPlugin) {\n\t\tthis.#serializationPlugins.push(step);\n\t}\n\n\taddBuildPlugin(step: TransactionPlugin) {\n\t\tthis.#buildPlugins.push(step);\n\t}\n\n\taddIntentResolver(intent: string, resolver: TransactionPlugin) {\n\t\tif (this.#intentResolvers.has(intent) && this.#intentResolvers.get(intent) !== resolver) {\n\t\t\tthrow new Error(`Intent resolver for ${intent} already exists`);\n\t\t}\n\n\t\tthis.#intentResolvers.set(intent, resolver);\n\t}\n\n\tsetSender(sender: string) {\n\t\tthis.#data.sender = sender;\n\t}\n\t/**\n\t * Sets the sender only if it has not already been set.\n\t * This is useful for sponsored transaction flows where the sender may not be the same as the signer address.\n\t */\n\tsetSenderIfNotSet(sender: string) {\n\t\tif (!this.#data.sender) {\n\t\t\tthis.#data.sender = sender;\n\t\t}\n\t}\n\tsetExpiration(expiration?: InferInput<typeof TransactionExpiration> | null) {\n\t\tthis.#data.expiration = expiration ? parse(TransactionExpiration, expiration) : null;\n\t}\n\tsetGasPrice(price: number | bigint | string) {\n\t\tthis.#data.gasData.price = String(price);\n\t}\n\tsetGasBudget(budget: number | bigint | string) {\n\t\tthis.#data.gasData.budget = String(budget);\n\t}\n\n\tsetGasBudgetIfNotSet(budget: number | bigint | string) {\n\t\tif (this.#data.gasData.budget == null) {\n\t\t\tthis.#data.gasData.budget = String(budget);\n\t\t}\n\t}\n\n\tsetGasOwner(owner: string) {\n\t\tthis.#data.gasData.owner = owner;\n\t}\n\tsetGasPayment(payments: ObjectRef[]) {\n\t\tthis.#data.gasData.payment = payments.map((payment) => parse(ObjectRefSchema, payment));\n\t}\n\n\t#data: TransactionDataBuilder;\n\n\t/** Get a snapshot of the transaction data, in JSON form: */\n\tgetData() {\n\t\treturn this.#data.snapshot();\n\t}\n\n\t// Used to brand transaction classes so that they can be identified, even between multiple copies\n\t// of the builder.\n\tget [TRANSACTION_BRAND]() {\n\t\treturn true;\n\t}\n\n\t// Temporary workaround for the wallet interface accidentally serializing transactions via postMessage\n\tget pure(): ReturnType<typeof createPure<Argument>> {\n\t\tObject.defineProperty(this, 'pure', {\n\t\t\tenumerable: false,\n\t\t\tvalue: createPure<Argument>((value): Argument => {\n\t\t\t\tif (isSerializedBcs(value)) {\n\t\t\t\t\treturn this.#addInput('pure', {\n\t\t\t\t\t\t$kind: 'Pure',\n\t\t\t\t\t\tPure: {\n\t\t\t\t\t\t\tbytes: value.toBase64(),\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// TODO: we can also do some deduplication here\n\t\t\t\treturn this.#addInput(\n\t\t\t\t\t'pure',\n\t\t\t\t\tis(NormalizedCallArg, value)\n\t\t\t\t\t\t? parse(NormalizedCallArg, value)\n\t\t\t\t\t\t: value instanceof Uint8Array\n\t\t\t\t\t\t\t? Inputs.Pure(value)\n\t\t\t\t\t\t\t: { $kind: 'UnresolvedPure', UnresolvedPure: { value } },\n\t\t\t\t);\n\t\t\t}),\n\t\t});\n\n\t\treturn this.pure;\n\t}\n\n\tconstructor() {\n\t\tthis.#data = new TransactionDataBuilder();\n\t\tthis.#buildPlugins = [];\n\t\tthis.#serializationPlugins = [];\n\t}\n\n\t/** Returns an argument for the gas coin, to be used in a transaction. */\n\tget gas() {\n\t\treturn { $kind: 'GasCoin' as const, GasCoin: true as const };\n\t}\n\n\t/**\n\t * Creates a coin of the specified type and balance.\n\t * Sourced from address balance when available, falling back to owned coins.\n\t */\n\tcoin({\n\t\ttype,\n\t\tbalance,\n\t\tuseGasCoin,\n\t}: {\n\t\tbalance: bigint | number;\n\t\ttype?: string;\n\t\tuseGasCoin?: boolean;\n\t}): TransactionResult {\n\t\treturn this.add(coinWithBalance({ type, balance, useGasCoin }));\n\t}\n\n\t/**\n\t * Creates a Balance object of the specified type and balance.\n\t * Sourced from address balance when available, falling back to owned coins.\n\t */\n\tbalance({\n\t\ttype,\n\t\tbalance,\n\t\tuseGasCoin,\n\t}: {\n\t\tbalance: bigint | number;\n\t\ttype?: string;\n\t\tuseGasCoin?: boolean;\n\t}): TransactionResult {\n\t\treturn this.add(createBalance({ type, balance, useGasCoin }));\n\t}\n\n\t/**\n\t * Add a new object input to the transaction.\n\t */\n\tobject: ReturnType<\n\t\ttypeof createObjectMethods<{ $kind: 'Input'; Input: number; type?: 'object' }>\n\t> = createObjectMethods(\n\t\t(value: TransactionObjectInput): { $kind: 'Input'; Input: number; type?: 'object' } => {\n\t\t\tif (typeof value === 'function') {\n\t\t\t\treturn this.object(this.add(value as (tx: Transaction) => TransactionObjectArgument));\n\t\t\t}\n\n\t\t\tif (typeof value === 'object' && is(ArgumentSchema, value)) {\n\t\t\t\treturn value as { $kind: 'Input'; Input: number; type?: 'object' };\n\t\t\t}\n\n\t\t\tconst id = getIdFromCallArg(value);\n\n\t\t\tconst inserted = this.#data.inputs.find((i) => id === getIdFromCallArg(i));\n\n\t\t\t// Upgrade shared object inputs to mutable if needed:\n\t\t\tif (\n\t\t\t\tinserted?.Object?.SharedObject &&\n\t\t\t\ttypeof value === 'object' &&\n\t\t\t\tvalue.Object?.SharedObject\n\t\t\t) {\n\t\t\t\tinserted.Object.SharedObject.mutable =\n\t\t\t\t\tinserted.Object.SharedObject.mutable || value.Object.SharedObject.mutable;\n\t\t\t}\n\n\t\t\treturn inserted\n\t\t\t\t? { $kind: 'Input', Input: this.#data.inputs.indexOf(inserted), type: 'object' }\n\t\t\t\t: this.#addInput(\n\t\t\t\t\t\t'object',\n\t\t\t\t\t\ttypeof value === 'string'\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t$kind: 'UnresolvedObject',\n\t\t\t\t\t\t\t\t\tUnresolvedObject: { objectId: normalizeSuiAddress(value) },\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: value,\n\t\t\t\t\t);\n\t\t},\n\t);\n\n\t/**\n\t * Add a new object input to the transaction using the fully-resolved object reference.\n\t * If you only have an object ID, use `builder.object(id)` instead.\n\t */\n\tobjectRef(...args: Parameters<(typeof Inputs)['ObjectRef']>) {\n\t\treturn this.object(Inputs.ObjectRef(...args));\n\t}\n\n\t/**\n\t * Add a new receiving input to the transaction using the fully-resolved object reference.\n\t * If you only have an object ID, use `builder.object(id)` instead.\n\t */\n\treceivingRef(...args: Parameters<(typeof Inputs)['ReceivingRef']>) {\n\t\treturn this.object(Inputs.ReceivingRef(...args));\n\t}\n\n\t/**\n\t * Add a new shared object input to the transaction using the fully-resolved shared object reference.\n\t * If you only have an object ID, use `builder.object(id)` instead.\n\t */\n\tsharedObjectRef(...args: Parameters<(typeof Inputs)['SharedObjectRef']>) {\n\t\treturn this.object(Inputs.SharedObjectRef(...args));\n\t}\n\n\t#fork() {\n\t\tconst fork = new Transaction();\n\n\t\tfork.#data = this.#data;\n\t\tfork.#serializationPlugins = this.#serializationPlugins;\n\t\tfork.#buildPlugins = this.#buildPlugins;\n\t\tfork.#intentResolvers = this.#intentResolvers;\n\t\tfork.#pendingPromises = this.#pendingPromises;\n\t\tfork.#availableResults = new Set(this.#availableResults);\n\t\tfork.#added = this.#added;\n\t\tthis.#inputSection.push(fork.#inputSection);\n\t\tthis.#commandSection.push(fork.#commandSection);\n\n\t\treturn fork;\n\t}\n\n\t/** Add a transaction to the transaction */\n\n\tadd<T extends Command>(command: T): TransactionResult;\n\tadd<T extends void | TransactionResultArgument | TransactionArgument | Command>(\n\t\tthunk: (tx: Transaction) => T,\n\t): T;\n\tadd<T extends TransactionResultArgument | void>(\n\t\tasyncTransactionThunk: AsyncTransactionThunk<T>,\n\t): T;\n\tadd(command: Command | AsyncTransactionThunk | ((tx: Transaction) => unknown)): unknown {\n\t\tif (typeof command === 'function') {\n\t\t\tif (this.#added.has(command)) {\n\t\t\t\treturn this.#added.get(command);\n\t\t\t}\n\n\t\t\tconst fork = this.#fork();\n\t\t\tconst result = command(fork);\n\n\t\t\tif (!(result && typeof result === 'object' && 'then' in result)) {\n\t\t\t\tthis.#availableResults = fork.#availableResults;\n\t\t\t\tthis.#added.set(command, result);\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tconst placeholder = this.#addCommand({\n\t\t\t\t$kind: '$Intent',\n\t\t\t\t$Intent: {\n\t\t\t\t\tname: 'AsyncTransactionThunk',\n\t\t\t\t\tinputs: {},\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tresultIndex: this.#data.commands.length,\n\t\t\t\t\t\tresult: null as TransactionResult | null,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tthis.#pendingPromises.add(\n\t\t\t\tPromise.resolve(result as Promise<TransactionResult>).then((result) => {\n\t\t\t\t\tplaceholder.$Intent.data.result = result;\n\t\t\t\t}),\n\t\t\t);\n\t\t\tconst txResult = createTransactionResult(() => placeholder.$Intent.data.resultIndex);\n\t\t\tthis.#added.set(command, txResult);\n\t\t\treturn txResult;\n\t\t} else {\n\t\t\tthis.#addCommand(command);\n\t\t}\n\n\t\treturn createTransactionResult(this.#data.commands.length - 1);\n\t}\n\n\t#addCommand<T extends Command>(command: T) {\n\t\tconst resultIndex = this.#data.commands.length;\n\t\tthis.#commandSection.push(command);\n\t\tthis.#availableResults.add(resultIndex);\n\t\tthis.#data.commands.push(command);\n\n\t\tthis.#data.mapCommandArguments(resultIndex, (arg) => {\n\t\t\tif (arg.$kind === 'Result' && !this.#availableResults.has(arg.Result)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Result { Result: ${arg.Result} } is not available to use in the current transaction`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (arg.$kind === 'NestedResult' && !this.#availableResults.has(arg.NestedResult[0])) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Result { NestedResult: [${arg.NestedResult[0]}, ${arg.NestedResult[1]}] } is not available to use in the current transaction`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (arg.$kind === 'Input' && arg.Input >= this.#data.inputs.length) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Input { Input: ${arg.Input} } references an input that does not exist in the current transaction`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn arg;\n\t\t});\n\n\t\treturn command;\n\t}\n\n\t#addInput<T extends 'pure' | 'object'>(type: T, input: CallArg) {\n\t\tthis.#inputSection.push(input);\n\t\treturn this.#data.addInput(type, input);\n\t}\n\n\t#normalizeTransactionArgument(arg: TransactionArgument | SerializedBcs<any>) {\n\t\tif (isSerializedBcs(arg)) {\n\t\t\treturn this.pure(arg);\n\t\t}\n\n\t\treturn this.#resolveArgument(arg as TransactionArgument);\n\t}\n\n\t#resolveArgument(arg: TransactionArgument): Argument {\n\t\tif (typeof arg === 'function') {\n\t\t\tconst resolved = this.add(arg as never);\n\n\t\t\tif (typeof resolved === 'function') {\n\t\t\t\treturn this.#resolveArgument(resolved);\n\t\t\t}\n\n\t\t\treturn parse(ArgumentSchema, resolved);\n\t\t}\n\n\t\treturn parse(ArgumentSchema, arg);\n\t}\n\n\t// Method shorthands:\n\n\tsplitCoins<\n\t\tconst Amounts extends (TransactionArgument | SerializedBcs<any> | number | string | bigint)[],\n\t>(coin: TransactionObjectArgument | string, amounts: Amounts) {\n\t\tconst command = TransactionCommands.SplitCoins(\n\t\t\ttypeof coin === 'string' ? this.object(coin) : this.#resolveArgument(coin),\n\t\t\tamounts.map((amount) =>\n\t\t\t\ttypeof amount === 'number' || typeof amount === 'bigint' || typeof amount === 'string'\n\t\t\t\t\t? this.pure.u64(amount)\n\t\t\t\t\t: this.#normalizeTransactionArgument(amount),\n\t\t\t),\n\t\t);\n\t\tthis.#addCommand(command);\n\t\treturn createTransactionResult(this.#data.commands.length - 1, amounts.length) as Extract<\n\t\t\tArgument,\n\t\t\t{ Result: unknown }\n\t\t> & {\n\t\t\t[K in keyof Amounts]: Extract<Argument, { NestedResult: unknown }>;\n\t\t};\n\t}\n\tmergeCoins(\n\t\tdestination: TransactionObjectArgument | string,\n\t\tsources: (TransactionObjectArgument | string)[],\n\t) {\n\t\treturn this.add(\n\t\t\tTransactionCommands.MergeCoins(\n\t\t\t\tthis.object(destination),\n\t\t\t\tsources.map((src) => this.object(src)),\n\t\t\t),\n\t\t);\n\t}\n\tpublish({ modules, dependencies }: { modules: number[][] | string[]; dependencies: string[] }) {\n\t\treturn this.add(\n\t\t\tTransactionCommands.Publish({\n\t\t\t\tmodules,\n\t\t\t\tdependencies,\n\t\t\t}),\n\t\t);\n\t}\n\tupgrade({\n\t\tmodules,\n\t\tdependencies,\n\t\tpackage: packageId,\n\t\tticket,\n\t}: {\n\t\tmodules: number[][] | string[];\n\t\tdependencies: string[];\n\t\tpackage: string;\n\t\tticket: TransactionObjectArgument | string;\n\t}) {\n\t\treturn this.add(\n\t\t\tTransactionCommands.Upgrade({\n\t\t\t\tmodules,\n\t\t\t\tdependencies,\n\t\t\t\tpackage: packageId,\n\t\t\t\tticket: this.object(ticket),\n\t\t\t}),\n\t\t);\n\t}\n\tmoveCall({\n\t\targuments: args,\n\t\t...input\n\t}:\n\t\t| {\n\t\t\t\tpackage: string;\n\t\t\t\tmodule: string;\n\t\t\t\tfunction: string;\n\t\t\t\targuments?: (TransactionArgument | SerializedBcs<any>)[];\n\t\t\t\ttypeArguments?: string[];\n\t\t }\n\t\t| {\n\t\t\t\ttarget: string;\n\t\t\t\targuments?: (TransactionArgument | SerializedBcs<any>)[];\n\t\t\t\ttypeArguments?: string[];\n\t\t }) {\n\t\treturn this.add(\n\t\t\tTransactionCommands.MoveCall({\n\t\t\t\t...input,\n\t\t\t\targuments: args?.map((arg) => this.#normalizeTransactionArgument(arg)),\n\t\t\t} as Parameters<typeof TransactionCommands.MoveCall>[0]),\n\t\t);\n\t}\n\ttransferObjects(\n\t\tobjects: (TransactionObjectArgument | string)[],\n\t\taddress: TransactionArgument | SerializedBcs<any> | string,\n\t) {\n\t\treturn this.add(\n\t\t\tTransactionCommands.TransferObjects(\n\t\t\t\tobjects.map((obj) => this.object(obj)),\n\t\t\t\ttypeof address === 'string'\n\t\t\t\t\t? this.pure.address(address)\n\t\t\t\t\t: this.#normalizeTransactionArgument(address),\n\t\t\t),\n\t\t);\n\t}\n\tmakeMoveVec({\n\t\ttype,\n\t\telements,\n\t}: {\n\t\telements: (TransactionObjectArgument | string)[];\n\t\ttype?: string;\n\t}) {\n\t\treturn this.add(\n\t\t\tTransactionCommands.MakeMoveVec({\n\t\t\t\ttype,\n\t\t\t\telements: elements.map((obj) => this.object(obj)),\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * Create a FundsWithdrawal input for withdrawing Balance<T> from an address balance accumulator.\n\t * This is used for gas payments from address balances.\n\t *\n\t * @param options.amount - The Amount to withdraw (u64).\n\t * @param options.type - The balance type (e.g., \"0x2::sui::SUI\"). Defaults to SUI.\n\t */\n\twithdrawal({ amount, type }: { amount: number | bigint | string; type?: string | null }): {\n\t\t$kind: 'Input';\n\t\tInput: number;\n\t\ttype?: 'object';\n\t} {\n\t\tconst input: CallArg = {\n\t\t\t$kind: 'FundsWithdrawal',\n\t\t\tFundsWithdrawal: {\n\t\t\t\t// TODO: support entire balance withdrawals once supported\n\t\t\t\treservation: { $kind: 'MaxAmountU64', MaxAmountU64: String(amount) },\n\t\t\t\ttypeArg: { $kind: 'Balance', Balance: type ?? '0x2::sui::SUI' },\n\t\t\t\twithdrawFrom:\n\t\t\t\t\t// fromSponsor === true\n\t\t\t\t\t// \t? { $kind: 'Sponsor', Sponsor: true } :\n\t\t\t\t\t// TODO: currently only supporting withdrawals from sender\n\t\t\t\t\t{ $kind: 'Sender', Sender: true },\n\t\t\t},\n\t\t};\n\n\t\treturn this.#addInput('object', input);\n\t}\n\n\t/**\n\t * @deprecated Use toJSON instead.\n\t * For synchronous serialization, you can use `getData()`\n\t * */\n\tserialize() {\n\t\treturn JSON.stringify(serializeV1TransactionData(this.#data.snapshot()));\n\t}\n\n\tasync toJSON(options: SerializeTransactionOptions = {}): Promise<string> {\n\t\tawait this.prepareForSerialization(options);\n\t\tconst fullyResolved = this.isFullyResolved();\n\t\treturn JSON.stringify(\n\t\t\tparse(\n\t\t\t\tSerializedTransactionDataV2Schema,\n\t\t\t\tfullyResolved\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...this.#data.snapshot(),\n\t\t\t\t\t\t\tdigest: this.#data.getDigest(),\n\t\t\t\t\t\t}\n\t\t\t\t\t: this.#data.snapshot(),\n\t\t\t),\n\t\t\t(_key, value) => (typeof value === 'bigint' ? value.toString() : value),\n\t\t\t2,\n\t\t);\n\t}\n\n\t/** Build the transaction to BCS bytes, and sign it with the provided keypair. */\n\tasync sign(options: SignOptions): Promise<SignatureWithBytes> {\n\t\tconst { signer, ...buildOptions } = options;\n\t\tconst bytes = await this.build(buildOptions);\n\t\treturn signer.signTransaction(bytes);\n\t}\n\n\t/**\n\t * Checks if the transaction is prepared for serialization to JSON.\n\t * This means:\n\t * - All async thunks have been fully resolved\n\t * - All transaction intents have been resolved (unless in supportedIntents)\n\t *\n\t * Unlike `isFullyResolved()`, this does not require the sender, gas payment,\n\t * budget, or object versions to be set.\n\t */\n\tisPreparedForSerialization(options: { supportedIntents?: string[] } = {}) {\n\t\tif (this.#pendingPromises.size > 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (\n\t\t\tthis.#data.commands.some(\n\t\t\t\t(cmd) => cmd.$Intent && !options.supportedIntents?.includes(cmd.$Intent.name),\n\t\t\t)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Ensures that:\n\t * - All objects have been fully resolved to a specific version\n\t * - All pure inputs have been serialized to bytes\n\t * - All async thunks have been fully resolved\n\t * - All transaction intents have been resolved\n\t * \t- The gas payment, budget, and price have been set\n\t * - The transaction sender has been set\n\t *\n\t * When true, the transaction will always be built to the same bytes and digest (unless the transaction is mutated)\n\t */\n\tisFullyResolved() {\n\t\tif (!this.isPreparedForSerialization()) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!this.#data.sender) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (needsTransactionResolution(this.#data, {})) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/** Build the transaction to BCS bytes. */\n\tasync build(options: BuildTransactionOptions = {}): Promise<Uint8Array<ArrayBuffer>> {\n\t\tawait this.prepareForSerialization(options);\n\t\tawait this.#prepareBuild(options);\n\t\treturn this.#data.build({\n\t\t\tonlyTransactionKind: options.onlyTransactionKind,\n\t\t});\n\t}\n\n\t/** Derive transaction digest */\n\tasync getDigest(\n\t\toptions: {\n\t\t\tclient?: ClientWithCoreApi;\n\t\t} = {},\n\t): Promise<string> {\n\t\tawait this.prepareForSerialization(options);\n\t\tawait this.#prepareBuild(options);\n\t\treturn this.#data.getDigest();\n\t}\n\n\t/**\n\t * Prepare the transaction by validating the transaction data and resolving all inputs\n\t * so that it can be built into bytes.\n\t */\n\tasync #prepareBuild(options: BuildTransactionOptions) {\n\t\tif (!options.onlyTransactionKind && !this.#data.sender) {\n\t\t\tthrow new Error('Missing transaction sender');\n\t\t}\n\n\t\tawait this.#runPlugins([...this.#buildPlugins, resolveTransactionPlugin], options);\n\t}\n\n\tasync #runPlugins(plugins: TransactionPlugin[], options: SerializeTransactionOptions) {\n\t\ttry {\n\t\t\tconst createNext = (i: number) => {\n\t\t\t\tif (i >= plugins.length) {\n\t\t\t\t\treturn () => {};\n\t\t\t\t}\n\t\t\t\tconst plugin = plugins[i];\n\n\t\t\t\treturn async () => {\n\t\t\t\t\tconst next = createNext(i + 1);\n\t\t\t\t\tlet calledNext = false;\n\t\t\t\t\tlet nextResolved = false;\n\n\t\t\t\t\tawait plugin(this.#data, options, async () => {\n\t\t\t\t\t\tif (calledNext) {\n\t\t\t\t\t\t\tthrow new Error(`next() was call multiple times in TransactionPlugin ${i}`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcalledNext = true;\n\n\t\t\t\t\t\tawait next();\n\n\t\t\t\t\t\tnextResolved = true;\n\t\t\t\t\t});\n\n\t\t\t\t\tif (!calledNext) {\n\t\t\t\t\t\tthrow new Error(`next() was not called in TransactionPlugin ${i}`);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!nextResolved) {\n\t\t\t\t\t\tthrow new Error(`next() was not awaited in TransactionPlugin ${i}`);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t};\n\n\t\t\tawait createNext(0)();\n\t\t} finally {\n\t\t\tthis.#inputSection = this.#data.inputs.slice();\n\t\t\tthis.#commandSection = this.#data.commands.slice();\n\t\t\tthis.#availableResults = new Set(this.#commandSection.map((_, i) => i));\n\t\t}\n\t}\n\n\tasync #waitForPendingTasks() {\n\t\twhile (this.#pendingPromises.size > 0) {\n\t\t\tconst newPromise = Promise.all(this.#pendingPromises);\n\t\t\tthis.#pendingPromises.clear();\n\t\t\tthis.#pendingPromises.add(newPromise);\n\t\t\tawait newPromise;\n\t\t\tthis.#pendingPromises.delete(newPromise);\n\t\t}\n\t}\n\n\t#sortCommandsAndInputs() {\n\t\tconst unorderedCommands = this.#data.commands;\n\t\tconst unorderedInputs = this.#data.inputs;\n\n\t\tconst orderedCommands = (this.#commandSection as Command[]).flat(Infinity);\n\t\tconst orderedInputs = (this.#inputSection as CallArg[]).flat(Infinity);\n\n\t\tif (orderedCommands.length !== unorderedCommands.length) {\n\t\t\tthrow new Error('Unexpected number of commands found in transaction data');\n\t\t}\n\n\t\tif (orderedInputs.length !== unorderedInputs.length) {\n\t\t\tthrow new Error('Unexpected number of inputs found in transaction data');\n\t\t}\n\n\t\tconst filteredCommands = orderedCommands.filter(\n\t\t\t(cmd) => cmd.$Intent?.name !== 'AsyncTransactionThunk',\n\t\t);\n\n\t\tthis.#data.commands = filteredCommands;\n\t\tthis.#data.inputs = orderedInputs;\n\t\tthis.#commandSection = filteredCommands;\n\t\tthis.#inputSection = orderedInputs;\n\t\tthis.#availableResults = new Set(filteredCommands.map((_, i) => i));\n\n\t\tfunction getOriginalIndex(index: number): number {\n\t\t\tconst command = unorderedCommands[index];\n\t\t\tif (command.$Intent?.name === 'AsyncTransactionThunk') {\n\t\t\t\tconst result = command.$Intent.data.result as TransactionResult | null;\n\n\t\t\t\tif (result == null) {\n\t\t\t\t\tthrow new Error('AsyncTransactionThunk has not been resolved');\n\t\t\t\t}\n\n\t\t\t\treturn getOriginalIndex(result.Result);\n\t\t\t}\n\n\t\t\tconst updated = filteredCommands.indexOf(command);\n\n\t\t\tif (updated === -1) {\n\t\t\t\tthrow new Error('Unable to find original index for command');\n\t\t\t}\n\n\t\t\treturn updated;\n\t\t}\n\n\t\tthis.#data.mapArguments((arg) => {\n\t\t\tif (arg.$kind === 'Input') {\n\t\t\t\tconst updated = orderedInputs.indexOf(unorderedInputs[arg.Input]);\n\n\t\t\t\tif (updated === -1) {\n\t\t\t\t\tthrow new Error('Input has not been resolved');\n\t\t\t\t}\n\n\t\t\t\treturn { ...arg, Input: updated };\n\t\t\t} else if (arg.$kind === 'Result') {\n\t\t\t\tconst updated = getOriginalIndex(arg.Result);\n\n\t\t\t\treturn { ...arg, Result: updated };\n\t\t\t} else if (arg.$kind === 'NestedResult') {\n\t\t\t\tconst updated = getOriginalIndex(arg.NestedResult[0]);\n\n\t\t\t\treturn { ...arg, NestedResult: [updated, arg.NestedResult[1]] };\n\t\t\t}\n\n\t\t\treturn arg;\n\t\t});\n\n\t\tfor (const [i, cmd] of unorderedCommands.entries()) {\n\t\t\tif (cmd.$Intent?.name === 'AsyncTransactionThunk') {\n\t\t\t\ttry {\n\t\t\t\t\tcmd.$Intent.data.resultIndex = getOriginalIndex(i);\n\t\t\t\t} catch {\n\t\t\t\t\t// If async thunk did not return a result, this will error, but is safe to ignore\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tasync prepareForSerialization(options: SerializeTransactionOptions) {\n\t\tawait this.#waitForPendingTasks();\n\t\tthis.#sortCommandsAndInputs();\n\t\tconst intents = new Set<string>();\n\t\tfor (const command of this.#data.commands) {\n\t\t\tif (command.$Intent) {\n\t\t\t\tintents.add(command.$Intent.name);\n\t\t\t}\n\t\t}\n\n\t\tconst steps = [...this.#serializationPlugins];\n\n\t\tfor (const intent of intents) {\n\t\t\tif (options.supportedIntents?.includes(intent)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!this.#intentResolvers.has(intent)) {\n\t\t\t\tthrow new Error(`Missing intent resolver for ${intent}`);\n\t\t\t}\n\n\t\t\tsteps.push(this.#intentResolvers.get(intent)!);\n\t\t}\n\n\t\tsteps.push(namedPackagesPlugin());\n\n\t\tawait this.#runPlugins(steps, options);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA2DA,SAAS,wBACR,OACA,SAAS,UACW;CACpB,MAAM,aAAa;EAClB,OAAO;EACP,IAAI,SAAS;AACZ,UAAO,OAAO,UAAU,aAAa,OAAO,GAAG;;EAEhD;CAED,MAAM,gBAGA,EAAE;CACR,MAAM,mBACL,gBAKC,cAAc,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AAM,MAAKiB,qBAAsB;AACjC,QAAKC,uBAAwB;EAC7B,MAAM,0BAAU,IAAI,KAAa;AACjC,OAAK,MAAM,WAAW,MAAKlB,KAAM,SAChC,KAAI,QAAQ,QACX,SAAQ,IAAI,QAAQ,QAAQ,KAAK;EAInC,MAAM,QAAQ,CAAC,GAAG,MAAKI,qBAAsB;AAE7C,OAAK,MAAM,UAAU,SAAS;AAC7B,OAAI,QAAQ,kBAAkB,SAAS,OAAO,CAC7C;AAGD,OAAI,CAAC,MAAKE,gBAAiB,IAAI,OAAO,CACrC,OAAM,IAAI,MAAM,+BAA+B,SAAS;AAGzD,SAAM,KAAK,MAAKA,gBAAiB,IAAI,OAAO,CAAE;;AAG/C,QAAM,KAAK,qBAAqB,CAAC;AAEjC,QAAM,MAAKU,WAAY,OAAO,QAAQ"}
|
|
1
|
+
{"version":3,"file":"Transaction.mjs","names":["#data","#inputSection","#commandSection","#availableResults","#serializationPlugins","#buildPlugins","#intentResolvers","#addInput","#pendingPromises","#added","#fork","#addCommand","result","#resolveArgument","#normalizeTransactionArgument","#prepareBuild","#runPlugins","#waitForPendingTasks","#sortCommandsAndInputs"],"sources":["../../src/transactions/Transaction.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { SerializedBcs } from '@mysten/bcs';\nimport { fromBase64, isSerializedBcs } from '@mysten/bcs';\nimport type { InferInput } from 'valibot';\nimport { is, parse } from 'valibot';\n\nimport type { SignatureWithBytes, Signer } from '../cryptography/index.js';\nimport { normalizeSuiAddress } from '../utils/sui-types.js';\nimport type { TransactionArgument } from './Commands.js';\nimport { TransactionCommands } from './Commands.js';\nimport type { CallArg, Command, Argument, ObjectRef } from './data/internal.js';\nimport {\n\tArgumentSchema,\n\tNormalizedCallArg,\n\tObjectRefSchema,\n\tTransactionExpiration,\n} from './data/internal.js';\nimport { serializeV1TransactionData } from './data/v1.js';\nimport { SerializedTransactionDataV2Schema } from './data/v2.js';\nimport { Inputs } from './Inputs.js';\nimport { needsTransactionResolution, resolveTransactionPlugin } from './resolve.js';\nimport type {\n\tBuildTransactionOptions,\n\tSerializeTransactionOptions,\n\tTransactionPlugin,\n} from './resolve.js';\nimport { createObjectMethods } from './object.js';\nimport { createPure } from './pure.js';\nimport { TransactionDataBuilder } from './TransactionData.js';\nimport { getIdFromCallArg } from './utils.js';\nimport { namedPackagesPlugin } from './plugins/NamedPackagesPlugin.js';\nimport {\n\tCOIN_WITH_BALANCE,\n\tresolveCoinBalance,\n\tcoinWithBalance,\n\tcreateBalance,\n} from './intents/CoinWithBalance.js';\nimport type { ClientWithCoreApi } from '../client/core.js';\n\nexport type TransactionObjectArgument =\n\t| Exclude<InferInput<typeof ArgumentSchema>, { Input: unknown; type?: 'pure' }>\n\t| ((\n\t\t\ttx: Transaction,\n\t ) => Exclude<InferInput<typeof ArgumentSchema>, { Input: unknown; type?: 'pure' }>)\n\t| AsyncTransactionThunk<TransactionResultArgument>;\n\nexport type TransactionResult = Extract<Argument, { Result: unknown }> &\n\tExtract<Argument, { NestedResult: unknown }>[];\n\nexport type TransactionResultArgument =\n\t| Extract<Argument, { Result: unknown }>\n\t| readonly Extract<Argument, { NestedResult: unknown }>[];\n\nexport type AsyncTransactionThunk<\n\tT extends TransactionResultArgument | void = TransactionResultArgument | void,\n> = (tx: Transaction) => Promise<T | void>;\n\nfunction createTransactionResult(\n\tindex: number | (() => number),\n\tlength = Infinity,\n): TransactionResult {\n\tconst baseResult = {\n\t\t$kind: 'Result' as const,\n\t\tget Result() {\n\t\t\treturn typeof index === 'function' ? index() : index;\n\t\t},\n\t};\n\n\tconst nestedResults: {\n\t\t$kind: 'NestedResult';\n\t\tNestedResult: [number, number];\n\t}[] = [];\n\tconst nestedResultFor = (\n\t\tresultIndex: number,\n\t): {\n\t\t$kind: 'NestedResult';\n\t\tNestedResult: [number, number];\n\t} =>\n\t\t(nestedResults[resultIndex] ??= {\n\t\t\t$kind: 'NestedResult' as const,\n\t\t\tget NestedResult() {\n\t\t\t\treturn [typeof index === 'function' ? index() : index, resultIndex] as [number, number];\n\t\t\t},\n\t\t});\n\n\treturn new Proxy(baseResult, {\n\t\tset() {\n\t\t\tthrow new Error(\n\t\t\t\t'The transaction result is a proxy, and does not support setting properties directly',\n\t\t\t);\n\t\t},\n\t\t// TODO: Instead of making this return a concrete argument, we should ideally\n\t\t// make it reference-based (so that this gets resolved at build-time), which\n\t\t// allows re-ordering transactions.\n\t\tget(target, property) {\n\t\t\t// This allows this transaction argument to be used in the singular form:\n\t\t\tif (property in target) {\n\t\t\t\treturn Reflect.get(target, property);\n\t\t\t}\n\n\t\t\t// Support destructuring:\n\t\t\tif (property === Symbol.iterator) {\n\t\t\t\treturn function* () {\n\t\t\t\t\tlet i = 0;\n\t\t\t\t\twhile (i < length) {\n\t\t\t\t\t\tyield nestedResultFor(i);\n\t\t\t\t\t\ti++;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (typeof property === 'symbol') return;\n\n\t\t\tconst resultIndex = parseInt(property, 10);\n\t\t\tif (Number.isNaN(resultIndex) || resultIndex < 0) return;\n\t\t\treturn nestedResultFor(resultIndex);\n\t\t},\n\t}) as TransactionResult;\n}\n\nconst TRANSACTION_BRAND = Symbol.for('@mysten/transaction') as never;\n\ninterface SignOptions extends BuildTransactionOptions {\n\tsigner: Signer;\n}\n\nexport function isTransaction(obj: unknown): obj is TransactionLike {\n\treturn !!obj && typeof obj === 'object' && (obj as any)[TRANSACTION_BRAND] === true;\n}\n\nexport type TransactionObjectInput = string | CallArg | TransactionObjectArgument;\n\ntype InputSection = (CallArg | InputSection)[];\ntype CommandSection = (Command | CommandSection)[];\n\ntype TransactionLike = {\n\tgetData(): unknown;\n};\n\nexport interface TransactionCopyOptions {\n\t/**\n\t * A map of intent names to resolvers for any custom intents used in the transaction being copied.\n\t *\n\t * Built-in intents (such as `CoinWithBalance`) are handled automatically. Providing resolvers for\n\t * custom intents lets `Transaction.from` copy a transaction synchronously even when it still\n\t * contains unresolved intents, without first awaiting `prepareForSerialization`.\n\t */\n\tintentResolvers?: Record<string, TransactionPlugin>;\n}\n\n/**\n * Transaction Builder\n */\nexport class Transaction {\n\t#serializationPlugins: TransactionPlugin[];\n\t#buildPlugins: TransactionPlugin[];\n\t#intentResolvers = new Map<string, TransactionPlugin>();\n\t#inputSection: InputSection = [];\n\t#commandSection: CommandSection = [];\n\t#availableResults: Set<number> = new Set();\n\t#pendingPromises = new Set<Promise<unknown>>();\n\t#added = new Map<(...args: any[]) => unknown, unknown>();\n\n\t/**\n\t * Converts from a serialize transaction kind (built with `build({ onlyTransactionKind: true })`) to a `Transaction` class.\n\t * Supports either a byte array, or base64-encoded bytes.\n\t */\n\tstatic fromKind(serialized: string | Uint8Array) {\n\t\tconst tx = new Transaction();\n\n\t\ttx.#data = TransactionDataBuilder.fromKindBytes(\n\t\t\ttypeof serialized === 'string' ? fromBase64(serialized) : serialized,\n\t\t);\n\n\t\ttx.#inputSection = tx.#data.inputs.slice();\n\t\ttx.#commandSection = tx.#data.commands.slice();\n\t\ttx.#availableResults = new Set(tx.#commandSection.map((_, i) => i));\n\n\t\treturn tx;\n\t}\n\n\t/**\n\t * Converts from a serialized transaction format to a `Transaction` class.\n\t * There are two supported serialized formats:\n\t * - A string returned from `Transaction#serialize`. The serialized format must be compatible, or it will throw an error.\n\t * - A byte array (or base64-encoded bytes) containing BCS transaction data.\n\t *\n\t * When copying an in-memory transaction that uses custom intents, pass resolvers for those intents\n\t * via `options.intentResolvers` so the copy can be created synchronously without first awaiting\n\t * `prepareForSerialization`. Built-in intents (such as `CoinWithBalance`) are handled automatically.\n\t */\n\tstatic from(\n\t\ttransaction: string | Uint8Array | TransactionLike,\n\t\toptions: TransactionCopyOptions = {},\n\t) {\n\t\tconst newTransaction = new Transaction();\n\n\t\tif (isTransaction(transaction)) {\n\t\t\tnewTransaction.#data = TransactionDataBuilder.restore(\n\t\t\t\ttransaction.getData() as InferInput<typeof SerializedTransactionDataV2Schema>,\n\t\t\t);\n\t\t} else if (typeof transaction !== 'string' || !transaction.startsWith('{')) {\n\t\t\tnewTransaction.#data = TransactionDataBuilder.fromBytes(\n\t\t\t\ttypeof transaction === 'string' ? fromBase64(transaction) : transaction,\n\t\t\t);\n\t\t} else {\n\t\t\tnewTransaction.#data = TransactionDataBuilder.restore(JSON.parse(transaction));\n\t\t}\n\n\t\tnewTransaction.#inputSection = newTransaction.#data.inputs.slice();\n\t\tnewTransaction.#commandSection = newTransaction.#data.commands.slice();\n\t\tnewTransaction.#availableResults = new Set(newTransaction.#commandSection.map((_, i) => i));\n\n\t\t// Built-in intents are resolvable by default. Caller-supplied resolvers cover custom intents,\n\t\t// and take precedence so a built-in resolver can be overridden if needed.\n\t\tconst intentResolvers = new Map<string, TransactionPlugin>([\n\t\t\t[COIN_WITH_BALANCE, resolveCoinBalance],\n\t\t\t...Object.entries(options.intentResolvers ?? {}),\n\t\t]);\n\n\t\tif (\n\t\t\t!newTransaction.isPreparedForSerialization({\n\t\t\t\tsupportedIntents: [...intentResolvers.keys()],\n\t\t\t})\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t'Transaction has unresolved intents or async thunks. Provide resolvers for any custom intents via the `intentResolvers` option, or call `prepareForSerialization` before copying.',\n\t\t\t);\n\t\t}\n\n\t\t// Register every resolver so the copy can resolve its intents on build. Resolvers for intents\n\t\t// that aren't present are harmless — a resolver only runs when its intent appears in the data.\n\t\tfor (const [intent, resolver] of intentResolvers) {\n\t\t\tnewTransaction.addIntentResolver(intent, resolver);\n\t\t}\n\n\t\treturn newTransaction;\n\t}\n\n\taddSerializationPlugin(step: TransactionPlugin) {\n\t\tthis.#serializationPlugins.push(step);\n\t}\n\n\taddBuildPlugin(step: TransactionPlugin) {\n\t\tthis.#buildPlugins.push(step);\n\t}\n\n\taddIntentResolver(intent: string, resolver: TransactionPlugin) {\n\t\tif (this.#intentResolvers.has(intent) && this.#intentResolvers.get(intent) !== resolver) {\n\t\t\tthrow new Error(`Intent resolver for ${intent} already exists`);\n\t\t}\n\n\t\tthis.#intentResolvers.set(intent, resolver);\n\t}\n\n\tsetSender(sender: string) {\n\t\tthis.#data.sender = sender;\n\t}\n\t/**\n\t * Sets the sender only if it has not already been set.\n\t * This is useful for sponsored transaction flows where the sender may not be the same as the signer address.\n\t */\n\tsetSenderIfNotSet(sender: string) {\n\t\tif (!this.#data.sender) {\n\t\t\tthis.#data.sender = sender;\n\t\t}\n\t}\n\tsetExpiration(expiration?: InferInput<typeof TransactionExpiration> | null) {\n\t\tthis.#data.expiration = expiration ? parse(TransactionExpiration, expiration) : null;\n\t}\n\tsetGasPrice(price: number | bigint | string) {\n\t\tthis.#data.gasData.price = String(price);\n\t}\n\tsetGasBudget(budget: number | bigint | string) {\n\t\tthis.#data.gasData.budget = String(budget);\n\t}\n\n\tsetGasBudgetIfNotSet(budget: number | bigint | string) {\n\t\tif (this.#data.gasData.budget == null) {\n\t\t\tthis.#data.gasData.budget = String(budget);\n\t\t}\n\t}\n\n\tsetGasOwner(owner: string) {\n\t\tthis.#data.gasData.owner = owner;\n\t}\n\tsetGasPayment(payments: ObjectRef[]) {\n\t\tthis.#data.gasData.payment = payments.map((payment) => parse(ObjectRefSchema, payment));\n\t}\n\n\t#data: TransactionDataBuilder;\n\n\t/** Get a snapshot of the transaction data, in JSON form: */\n\tgetData() {\n\t\treturn this.#data.snapshot();\n\t}\n\n\t// Used to brand transaction classes so that they can be identified, even between multiple copies\n\t// of the builder.\n\tget [TRANSACTION_BRAND]() {\n\t\treturn true;\n\t}\n\n\t// Temporary workaround for the wallet interface accidentally serializing transactions via postMessage\n\tget pure(): ReturnType<typeof createPure<Argument>> {\n\t\tObject.defineProperty(this, 'pure', {\n\t\t\tenumerable: false,\n\t\t\tvalue: createPure<Argument>((value): Argument => {\n\t\t\t\tif (isSerializedBcs(value)) {\n\t\t\t\t\treturn this.#addInput('pure', {\n\t\t\t\t\t\t$kind: 'Pure',\n\t\t\t\t\t\tPure: {\n\t\t\t\t\t\t\tbytes: value.toBase64(),\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// TODO: we can also do some deduplication here\n\t\t\t\treturn this.#addInput(\n\t\t\t\t\t'pure',\n\t\t\t\t\tis(NormalizedCallArg, value)\n\t\t\t\t\t\t? parse(NormalizedCallArg, value)\n\t\t\t\t\t\t: value instanceof Uint8Array\n\t\t\t\t\t\t\t? Inputs.Pure(value)\n\t\t\t\t\t\t\t: { $kind: 'UnresolvedPure', UnresolvedPure: { value } },\n\t\t\t\t);\n\t\t\t}),\n\t\t});\n\n\t\treturn this.pure;\n\t}\n\n\tconstructor() {\n\t\tthis.#data = new TransactionDataBuilder();\n\t\tthis.#buildPlugins = [];\n\t\tthis.#serializationPlugins = [];\n\t}\n\n\t/** Returns an argument for the gas coin, to be used in a transaction. */\n\tget gas() {\n\t\treturn { $kind: 'GasCoin' as const, GasCoin: true as const };\n\t}\n\n\t/**\n\t * Creates a coin of the specified type and balance.\n\t * Sourced from address balance when available, falling back to owned coins.\n\t */\n\tcoin({\n\t\ttype,\n\t\tbalance,\n\t\tuseGasCoin,\n\t}: {\n\t\tbalance: bigint | number;\n\t\ttype?: string;\n\t\tuseGasCoin?: boolean;\n\t}): TransactionResult {\n\t\treturn this.add(coinWithBalance({ type, balance, useGasCoin }));\n\t}\n\n\t/**\n\t * Creates a Balance object of the specified type and balance.\n\t * Sourced from address balance when available, falling back to owned coins.\n\t */\n\tbalance({\n\t\ttype,\n\t\tbalance,\n\t\tuseGasCoin,\n\t}: {\n\t\tbalance: bigint | number;\n\t\ttype?: string;\n\t\tuseGasCoin?: boolean;\n\t}): TransactionResult {\n\t\treturn this.add(createBalance({ type, balance, useGasCoin }));\n\t}\n\n\t/**\n\t * Add a new object input to the transaction.\n\t */\n\tobject: ReturnType<\n\t\ttypeof createObjectMethods<{ $kind: 'Input'; Input: number; type?: 'object' }>\n\t> = createObjectMethods(\n\t\t(value: TransactionObjectInput): { $kind: 'Input'; Input: number; type?: 'object' } => {\n\t\t\tif (typeof value === 'function') {\n\t\t\t\treturn this.object(this.add(value as (tx: Transaction) => TransactionObjectArgument));\n\t\t\t}\n\n\t\t\tif (typeof value === 'object' && is(ArgumentSchema, value)) {\n\t\t\t\treturn value as { $kind: 'Input'; Input: number; type?: 'object' };\n\t\t\t}\n\n\t\t\tconst id = getIdFromCallArg(value);\n\n\t\t\tconst inserted = this.#data.inputs.find((i) => id === getIdFromCallArg(i));\n\n\t\t\t// Upgrade shared object inputs to mutable if needed:\n\t\t\tif (\n\t\t\t\tinserted?.Object?.SharedObject &&\n\t\t\t\ttypeof value === 'object' &&\n\t\t\t\tvalue.Object?.SharedObject\n\t\t\t) {\n\t\t\t\tinserted.Object.SharedObject.mutable =\n\t\t\t\t\tinserted.Object.SharedObject.mutable || value.Object.SharedObject.mutable;\n\t\t\t}\n\n\t\t\treturn inserted\n\t\t\t\t? { $kind: 'Input', Input: this.#data.inputs.indexOf(inserted), type: 'object' }\n\t\t\t\t: this.#addInput(\n\t\t\t\t\t\t'object',\n\t\t\t\t\t\ttypeof value === 'string'\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t$kind: 'UnresolvedObject',\n\t\t\t\t\t\t\t\t\tUnresolvedObject: { objectId: normalizeSuiAddress(value) },\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: value,\n\t\t\t\t\t);\n\t\t},\n\t);\n\n\t/**\n\t * Add a new object input to the transaction using the fully-resolved object reference.\n\t * If you only have an object ID, use `builder.object(id)` instead.\n\t */\n\tobjectRef(...args: Parameters<(typeof Inputs)['ObjectRef']>) {\n\t\treturn this.object(Inputs.ObjectRef(...args));\n\t}\n\n\t/**\n\t * Add a new receiving input to the transaction using the fully-resolved object reference.\n\t * If you only have an object ID, use `builder.object(id)` instead.\n\t */\n\treceivingRef(...args: Parameters<(typeof Inputs)['ReceivingRef']>) {\n\t\treturn this.object(Inputs.ReceivingRef(...args));\n\t}\n\n\t/**\n\t * Add a new shared object input to the transaction using the fully-resolved shared object reference.\n\t * If you only have an object ID, use `builder.object(id)` instead.\n\t */\n\tsharedObjectRef(...args: Parameters<(typeof Inputs)['SharedObjectRef']>) {\n\t\treturn this.object(Inputs.SharedObjectRef(...args));\n\t}\n\n\t#fork() {\n\t\tconst fork = new Transaction();\n\n\t\tfork.#data = this.#data;\n\t\tfork.#serializationPlugins = this.#serializationPlugins;\n\t\tfork.#buildPlugins = this.#buildPlugins;\n\t\tfork.#intentResolvers = this.#intentResolvers;\n\t\tfork.#pendingPromises = this.#pendingPromises;\n\t\tfork.#availableResults = new Set(this.#availableResults);\n\t\tfork.#added = this.#added;\n\t\tthis.#inputSection.push(fork.#inputSection);\n\t\tthis.#commandSection.push(fork.#commandSection);\n\n\t\treturn fork;\n\t}\n\n\t/** Add a transaction to the transaction */\n\n\tadd<T extends Command>(command: T): TransactionResult;\n\tadd<T extends void | TransactionResultArgument | TransactionArgument | Command>(\n\t\tthunk: (tx: Transaction) => T,\n\t): T;\n\tadd<T extends TransactionResultArgument | void>(\n\t\tasyncTransactionThunk: AsyncTransactionThunk<T>,\n\t): T;\n\tadd(command: Command | AsyncTransactionThunk | ((tx: Transaction) => unknown)): unknown {\n\t\tif (typeof command === 'function') {\n\t\t\tif (this.#added.has(command)) {\n\t\t\t\treturn this.#added.get(command);\n\t\t\t}\n\n\t\t\tconst fork = this.#fork();\n\t\t\tconst result = command(fork);\n\n\t\t\tif (!(result && typeof result === 'object' && 'then' in result)) {\n\t\t\t\tthis.#availableResults = fork.#availableResults;\n\t\t\t\tthis.#added.set(command, result);\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tconst placeholder = this.#addCommand({\n\t\t\t\t$kind: '$Intent',\n\t\t\t\t$Intent: {\n\t\t\t\t\tname: 'AsyncTransactionThunk',\n\t\t\t\t\tinputs: {},\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tresultIndex: this.#data.commands.length,\n\t\t\t\t\t\tresult: null as TransactionResult | null,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tthis.#pendingPromises.add(\n\t\t\t\tPromise.resolve(result as Promise<TransactionResult>).then((result) => {\n\t\t\t\t\tplaceholder.$Intent.data.result = result;\n\t\t\t\t}),\n\t\t\t);\n\t\t\tconst txResult = createTransactionResult(() => placeholder.$Intent.data.resultIndex);\n\t\t\tthis.#added.set(command, txResult);\n\t\t\treturn txResult;\n\t\t} else {\n\t\t\tthis.#addCommand(command);\n\t\t}\n\n\t\treturn createTransactionResult(this.#data.commands.length - 1);\n\t}\n\n\t#addCommand<T extends Command>(command: T) {\n\t\tconst resultIndex = this.#data.commands.length;\n\t\tthis.#commandSection.push(command);\n\t\tthis.#availableResults.add(resultIndex);\n\t\tthis.#data.commands.push(command);\n\n\t\tthis.#data.mapCommandArguments(resultIndex, (arg) => {\n\t\t\tif (arg.$kind === 'Result' && !this.#availableResults.has(arg.Result)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Result { Result: ${arg.Result} } is not available to use in the current transaction`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (arg.$kind === 'NestedResult' && !this.#availableResults.has(arg.NestedResult[0])) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Result { NestedResult: [${arg.NestedResult[0]}, ${arg.NestedResult[1]}] } is not available to use in the current transaction`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (arg.$kind === 'Input' && arg.Input >= this.#data.inputs.length) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Input { Input: ${arg.Input} } references an input that does not exist in the current transaction`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn arg;\n\t\t});\n\n\t\treturn command;\n\t}\n\n\t#addInput<T extends 'pure' | 'object'>(type: T, input: CallArg) {\n\t\tthis.#inputSection.push(input);\n\t\treturn this.#data.addInput(type, input);\n\t}\n\n\t#normalizeTransactionArgument(arg: TransactionArgument | SerializedBcs<any>) {\n\t\tif (isSerializedBcs(arg)) {\n\t\t\treturn this.pure(arg);\n\t\t}\n\n\t\treturn this.#resolveArgument(arg as TransactionArgument);\n\t}\n\n\t#resolveArgument(arg: TransactionArgument): Argument {\n\t\tif (typeof arg === 'function') {\n\t\t\tconst resolved = this.add(arg as never);\n\n\t\t\tif (typeof resolved === 'function') {\n\t\t\t\treturn this.#resolveArgument(resolved);\n\t\t\t}\n\n\t\t\treturn parse(ArgumentSchema, resolved);\n\t\t}\n\n\t\treturn parse(ArgumentSchema, arg);\n\t}\n\n\t// Method shorthands:\n\n\tsplitCoins<\n\t\tconst Amounts extends (TransactionArgument | SerializedBcs<any> | number | string | bigint)[],\n\t>(coin: TransactionObjectArgument | string, amounts: Amounts) {\n\t\tconst command = TransactionCommands.SplitCoins(\n\t\t\ttypeof coin === 'string' ? this.object(coin) : this.#resolveArgument(coin),\n\t\t\tamounts.map((amount) =>\n\t\t\t\ttypeof amount === 'number' || typeof amount === 'bigint' || typeof amount === 'string'\n\t\t\t\t\t? this.pure.u64(amount)\n\t\t\t\t\t: this.#normalizeTransactionArgument(amount),\n\t\t\t),\n\t\t);\n\t\tthis.#addCommand(command);\n\t\treturn createTransactionResult(this.#data.commands.length - 1, amounts.length) as Extract<\n\t\t\tArgument,\n\t\t\t{ Result: unknown }\n\t\t> & {\n\t\t\t[K in keyof Amounts]: Extract<Argument, { NestedResult: unknown }>;\n\t\t};\n\t}\n\tmergeCoins(\n\t\tdestination: TransactionObjectArgument | string,\n\t\tsources: (TransactionObjectArgument | string)[],\n\t) {\n\t\treturn this.add(\n\t\t\tTransactionCommands.MergeCoins(\n\t\t\t\tthis.object(destination),\n\t\t\t\tsources.map((src) => this.object(src)),\n\t\t\t),\n\t\t);\n\t}\n\tpublish({ modules, dependencies }: { modules: number[][] | string[]; dependencies: string[] }) {\n\t\treturn this.add(\n\t\t\tTransactionCommands.Publish({\n\t\t\t\tmodules,\n\t\t\t\tdependencies,\n\t\t\t}),\n\t\t);\n\t}\n\tupgrade({\n\t\tmodules,\n\t\tdependencies,\n\t\tpackage: packageId,\n\t\tticket,\n\t}: {\n\t\tmodules: number[][] | string[];\n\t\tdependencies: string[];\n\t\tpackage: string;\n\t\tticket: TransactionObjectArgument | string;\n\t}) {\n\t\treturn this.add(\n\t\t\tTransactionCommands.Upgrade({\n\t\t\t\tmodules,\n\t\t\t\tdependencies,\n\t\t\t\tpackage: packageId,\n\t\t\t\tticket: this.object(ticket),\n\t\t\t}),\n\t\t);\n\t}\n\tmoveCall({\n\t\targuments: args,\n\t\t...input\n\t}:\n\t\t| {\n\t\t\t\tpackage: string;\n\t\t\t\tmodule: string;\n\t\t\t\tfunction: string;\n\t\t\t\targuments?: (TransactionArgument | SerializedBcs<any>)[];\n\t\t\t\ttypeArguments?: string[];\n\t\t }\n\t\t| {\n\t\t\t\ttarget: string;\n\t\t\t\targuments?: (TransactionArgument | SerializedBcs<any>)[];\n\t\t\t\ttypeArguments?: string[];\n\t\t }) {\n\t\treturn this.add(\n\t\t\tTransactionCommands.MoveCall({\n\t\t\t\t...input,\n\t\t\t\targuments: args?.map((arg) => this.#normalizeTransactionArgument(arg)),\n\t\t\t} as Parameters<typeof TransactionCommands.MoveCall>[0]),\n\t\t);\n\t}\n\ttransferObjects(\n\t\tobjects: (TransactionObjectArgument | string)[],\n\t\taddress: TransactionArgument | SerializedBcs<any> | string,\n\t) {\n\t\treturn this.add(\n\t\t\tTransactionCommands.TransferObjects(\n\t\t\t\tobjects.map((obj) => this.object(obj)),\n\t\t\t\ttypeof address === 'string'\n\t\t\t\t\t? this.pure.address(address)\n\t\t\t\t\t: this.#normalizeTransactionArgument(address),\n\t\t\t),\n\t\t);\n\t}\n\tmakeMoveVec({\n\t\ttype,\n\t\telements,\n\t}: {\n\t\telements: (TransactionObjectArgument | string)[];\n\t\ttype?: string;\n\t}) {\n\t\treturn this.add(\n\t\t\tTransactionCommands.MakeMoveVec({\n\t\t\t\ttype,\n\t\t\t\telements: elements.map((obj) => this.object(obj)),\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * Create a FundsWithdrawal input for withdrawing Balance<T> from an address balance accumulator.\n\t * This is used for gas payments from address balances.\n\t *\n\t * @param options.amount - The Amount to withdraw (u64).\n\t * @param options.type - The balance type (e.g., \"0x2::sui::SUI\"). Defaults to SUI.\n\t */\n\twithdrawal({ amount, type }: { amount: number | bigint | string; type?: string | null }): {\n\t\t$kind: 'Input';\n\t\tInput: number;\n\t\ttype?: 'object';\n\t} {\n\t\tconst input: CallArg = {\n\t\t\t$kind: 'FundsWithdrawal',\n\t\t\tFundsWithdrawal: {\n\t\t\t\t// TODO: support entire balance withdrawals once supported\n\t\t\t\treservation: { $kind: 'MaxAmountU64', MaxAmountU64: String(amount) },\n\t\t\t\ttypeArg: { $kind: 'Balance', Balance: type ?? '0x2::sui::SUI' },\n\t\t\t\twithdrawFrom:\n\t\t\t\t\t// fromSponsor === true\n\t\t\t\t\t// \t? { $kind: 'Sponsor', Sponsor: true } :\n\t\t\t\t\t// TODO: currently only supporting withdrawals from sender\n\t\t\t\t\t{ $kind: 'Sender', Sender: true },\n\t\t\t},\n\t\t};\n\n\t\treturn this.#addInput('object', input);\n\t}\n\n\t/**\n\t * @deprecated Use toJSON instead.\n\t * For synchronous serialization, you can use `getData()`\n\t * */\n\tserialize() {\n\t\treturn JSON.stringify(serializeV1TransactionData(this.#data.snapshot()));\n\t}\n\n\tasync toJSON(options: SerializeTransactionOptions = {}): Promise<string> {\n\t\tawait this.prepareForSerialization(options);\n\t\tconst fullyResolved = this.isFullyResolved();\n\t\treturn JSON.stringify(\n\t\t\tparse(\n\t\t\t\tSerializedTransactionDataV2Schema,\n\t\t\t\tfullyResolved\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...this.#data.snapshot(),\n\t\t\t\t\t\t\tdigest: this.#data.getDigest(),\n\t\t\t\t\t\t}\n\t\t\t\t\t: this.#data.snapshot(),\n\t\t\t),\n\t\t\t(_key, value) => (typeof value === 'bigint' ? value.toString() : value),\n\t\t\t2,\n\t\t);\n\t}\n\n\t/** Build the transaction to BCS bytes, and sign it with the provided keypair. */\n\tasync sign(options: SignOptions): Promise<SignatureWithBytes> {\n\t\tconst { signer, ...buildOptions } = options;\n\t\tconst bytes = await this.build(buildOptions);\n\t\treturn signer.signTransaction(bytes);\n\t}\n\n\t/**\n\t * Checks if the transaction is prepared for serialization to JSON.\n\t * This means:\n\t * - All async thunks have been fully resolved\n\t * - All transaction intents have been resolved (unless in supportedIntents)\n\t *\n\t * Unlike `isFullyResolved()`, this does not require the sender, gas payment,\n\t * budget, or object versions to be set.\n\t */\n\tisPreparedForSerialization(options: { supportedIntents?: string[] } = {}) {\n\t\tif (this.#pendingPromises.size > 0) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (\n\t\t\tthis.#data.commands.some(\n\t\t\t\t(cmd) => cmd.$Intent && !options.supportedIntents?.includes(cmd.$Intent.name),\n\t\t\t)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Ensures that:\n\t * - All objects have been fully resolved to a specific version\n\t * - All pure inputs have been serialized to bytes\n\t * - All async thunks have been fully resolved\n\t * - All transaction intents have been resolved\n\t * \t- The gas payment, budget, and price have been set\n\t * - The transaction sender has been set\n\t *\n\t * When true, the transaction will always be built to the same bytes and digest (unless the transaction is mutated)\n\t */\n\tisFullyResolved() {\n\t\tif (!this.isPreparedForSerialization()) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!this.#data.sender) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (needsTransactionResolution(this.#data, {})) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/** Build the transaction to BCS bytes. */\n\tasync build(options: BuildTransactionOptions = {}): Promise<Uint8Array<ArrayBuffer>> {\n\t\tawait this.prepareForSerialization(options);\n\t\tawait this.#prepareBuild(options);\n\t\treturn this.#data.build({\n\t\t\tonlyTransactionKind: options.onlyTransactionKind,\n\t\t});\n\t}\n\n\t/** Derive transaction digest */\n\tasync getDigest(\n\t\toptions: {\n\t\t\tclient?: ClientWithCoreApi;\n\t\t} = {},\n\t): Promise<string> {\n\t\tawait this.prepareForSerialization(options);\n\t\tawait this.#prepareBuild(options);\n\t\treturn this.#data.getDigest();\n\t}\n\n\t/**\n\t * Prepare the transaction by validating the transaction data and resolving all inputs\n\t * so that it can be built into bytes.\n\t */\n\tasync #prepareBuild(options: BuildTransactionOptions) {\n\t\tif (!options.onlyTransactionKind && !this.#data.sender) {\n\t\t\tthrow new Error('Missing transaction sender');\n\t\t}\n\n\t\tawait this.#runPlugins([...this.#buildPlugins, resolveTransactionPlugin], options);\n\t}\n\n\tasync #runPlugins(plugins: TransactionPlugin[], options: SerializeTransactionOptions) {\n\t\ttry {\n\t\t\tconst createNext = (i: number) => {\n\t\t\t\tif (i >= plugins.length) {\n\t\t\t\t\treturn () => {};\n\t\t\t\t}\n\t\t\t\tconst plugin = plugins[i];\n\n\t\t\t\treturn async () => {\n\t\t\t\t\tconst next = createNext(i + 1);\n\t\t\t\t\tlet calledNext = false;\n\t\t\t\t\tlet nextResolved = false;\n\n\t\t\t\t\tawait plugin(this.#data, options, async () => {\n\t\t\t\t\t\tif (calledNext) {\n\t\t\t\t\t\t\tthrow new Error(`next() was call multiple times in TransactionPlugin ${i}`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcalledNext = true;\n\n\t\t\t\t\t\tawait next();\n\n\t\t\t\t\t\tnextResolved = true;\n\t\t\t\t\t});\n\n\t\t\t\t\tif (!calledNext) {\n\t\t\t\t\t\tthrow new Error(`next() was not called in TransactionPlugin ${i}`);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!nextResolved) {\n\t\t\t\t\t\tthrow new Error(`next() was not awaited in TransactionPlugin ${i}`);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t};\n\n\t\t\tawait createNext(0)();\n\t\t} finally {\n\t\t\tthis.#inputSection = this.#data.inputs.slice();\n\t\t\tthis.#commandSection = this.#data.commands.slice();\n\t\t\tthis.#availableResults = new Set(this.#commandSection.map((_, i) => i));\n\t\t}\n\t}\n\n\tasync #waitForPendingTasks() {\n\t\twhile (this.#pendingPromises.size > 0) {\n\t\t\tconst newPromise = Promise.all(this.#pendingPromises);\n\t\t\tthis.#pendingPromises.clear();\n\t\t\tthis.#pendingPromises.add(newPromise);\n\t\t\tawait newPromise;\n\t\t\tthis.#pendingPromises.delete(newPromise);\n\t\t}\n\t}\n\n\t#sortCommandsAndInputs() {\n\t\tconst unorderedCommands = this.#data.commands;\n\t\tconst unorderedInputs = this.#data.inputs;\n\n\t\tconst orderedCommands = (this.#commandSection as Command[]).flat(Infinity);\n\t\tconst orderedInputs = (this.#inputSection as CallArg[]).flat(Infinity);\n\n\t\tif (orderedCommands.length !== unorderedCommands.length) {\n\t\t\tthrow new Error('Unexpected number of commands found in transaction data');\n\t\t}\n\n\t\tif (orderedInputs.length !== unorderedInputs.length) {\n\t\t\tthrow new Error('Unexpected number of inputs found in transaction data');\n\t\t}\n\n\t\tconst filteredCommands = orderedCommands.filter(\n\t\t\t(cmd) => cmd.$Intent?.name !== 'AsyncTransactionThunk',\n\t\t);\n\n\t\tthis.#data.commands = filteredCommands;\n\t\tthis.#data.inputs = orderedInputs;\n\t\tthis.#commandSection = filteredCommands;\n\t\tthis.#inputSection = orderedInputs;\n\t\tthis.#availableResults = new Set(filteredCommands.map((_, i) => i));\n\n\t\tfunction getOriginalIndex(index: number): number {\n\t\t\tconst command = unorderedCommands[index];\n\t\t\tif (command.$Intent?.name === 'AsyncTransactionThunk') {\n\t\t\t\tconst result = command.$Intent.data.result as TransactionResult | null;\n\n\t\t\t\tif (result == null) {\n\t\t\t\t\tthrow new Error('AsyncTransactionThunk has not been resolved');\n\t\t\t\t}\n\n\t\t\t\treturn getOriginalIndex(result.Result);\n\t\t\t}\n\n\t\t\tconst updated = filteredCommands.indexOf(command);\n\n\t\t\tif (updated === -1) {\n\t\t\t\tthrow new Error('Unable to find original index for command');\n\t\t\t}\n\n\t\t\treturn updated;\n\t\t}\n\n\t\tthis.#data.mapArguments((arg) => {\n\t\t\tif (arg.$kind === 'Input') {\n\t\t\t\tconst updated = orderedInputs.indexOf(unorderedInputs[arg.Input]);\n\n\t\t\t\tif (updated === -1) {\n\t\t\t\t\tthrow new Error('Input has not been resolved');\n\t\t\t\t}\n\n\t\t\t\treturn { ...arg, Input: updated };\n\t\t\t} else if (arg.$kind === 'Result') {\n\t\t\t\tconst updated = getOriginalIndex(arg.Result);\n\n\t\t\t\treturn { ...arg, Result: updated };\n\t\t\t} else if (arg.$kind === 'NestedResult') {\n\t\t\t\tconst updated = getOriginalIndex(arg.NestedResult[0]);\n\n\t\t\t\treturn { ...arg, NestedResult: [updated, arg.NestedResult[1]] };\n\t\t\t}\n\n\t\t\treturn arg;\n\t\t});\n\n\t\tfor (const [i, cmd] of unorderedCommands.entries()) {\n\t\t\tif (cmd.$Intent?.name === 'AsyncTransactionThunk') {\n\t\t\t\ttry {\n\t\t\t\t\tcmd.$Intent.data.resultIndex = getOriginalIndex(i);\n\t\t\t\t} catch {\n\t\t\t\t\t// If async thunk did not return a result, this will error, but is safe to ignore\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tasync prepareForSerialization(options: SerializeTransactionOptions) {\n\t\tawait this.#waitForPendingTasks();\n\t\tthis.#sortCommandsAndInputs();\n\t\tconst intents = new Set<string>();\n\t\tfor (const command of this.#data.commands) {\n\t\t\tif (command.$Intent) {\n\t\t\t\tintents.add(command.$Intent.name);\n\t\t\t}\n\t\t}\n\n\t\tconst steps = [...this.#serializationPlugins];\n\n\t\tfor (const intent of intents) {\n\t\t\tif (options.supportedIntents?.includes(intent)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!this.#intentResolvers.has(intent)) {\n\t\t\t\tthrow new Error(`Missing intent resolver for ${intent}`);\n\t\t\t}\n\n\t\t\tsteps.push(this.#intentResolvers.get(intent)!);\n\t\t}\n\n\t\tsteps.push(namedPackagesPlugin());\n\n\t\tawait this.#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