@t2000/cli 0.22.22 → 0.22.23

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.
Files changed (43) hide show
  1. package/dist/{ccip-3TXHQUZ5.js → ccip-JEEJV65M.js} +3 -3
  2. package/dist/{chunk-3W7OQGNS.js → chunk-3XUF7GM3.js} +21 -42
  3. package/dist/chunk-3XUF7GM3.js.map +1 -0
  4. package/dist/chunk-77SWBATH.js +204 -0
  5. package/dist/chunk-77SWBATH.js.map +1 -0
  6. package/dist/{chunk-ML6HST4W.js → chunk-A5X4KG7U.js} +1878 -341
  7. package/dist/chunk-A5X4KG7U.js.map +1 -0
  8. package/dist/{chunk-VREOXJUB.js → chunk-EEPD7SHV.js} +15455 -14941
  9. package/dist/chunk-EEPD7SHV.js.map +1 -0
  10. package/dist/chunk-KHIL2KNW.js +4016 -0
  11. package/dist/chunk-KHIL2KNW.js.map +1 -0
  12. package/dist/{chunk-ZNF5QSAT.js → chunk-RN7Z6TWD.js} +33444 -24623
  13. package/dist/chunk-RN7Z6TWD.js.map +1 -0
  14. package/dist/{chunk-AB65Y674.js → chunk-V7PXDEKG.js} +2 -2
  15. package/dist/chunk-V7PXDEKG.js.map +1 -0
  16. package/dist/client-I4SGZLVD.js +746 -0
  17. package/dist/client-I4SGZLVD.js.map +1 -0
  18. package/dist/{client-SYS6Z5RX.js → client-R3NRAXMD.js} +5715 -2933
  19. package/dist/client-R3NRAXMD.js.map +1 -0
  20. package/dist/{dist-73ESA7QZ.js → dist-FDS4MNUV.js} +135 -4160
  21. package/dist/dist-FDS4MNUV.js.map +1 -0
  22. package/dist/{dist-IANNA5N7.js → dist-G5YKLWC5.js} +5 -5
  23. package/dist/{esm-IQVNJILX.js → esm-QBJBHFZA.js} +11 -11
  24. package/dist/esm-QBJBHFZA.js.map +1 -0
  25. package/dist/index.js +48 -36
  26. package/dist/index.js.map +1 -1
  27. package/package.json +4 -4
  28. package/dist/chunk-3W7OQGNS.js.map +0 -1
  29. package/dist/chunk-AB65Y674.js.map +0 -1
  30. package/dist/chunk-H66DC3S3.js +0 -1908
  31. package/dist/chunk-H66DC3S3.js.map +0 -1
  32. package/dist/chunk-IHPSFXUW.js +0 -5002
  33. package/dist/chunk-IHPSFXUW.js.map +0 -1
  34. package/dist/chunk-ML6HST4W.js.map +0 -1
  35. package/dist/chunk-VREOXJUB.js.map +0 -1
  36. package/dist/chunk-ZNF5QSAT.js.map +0 -1
  37. package/dist/client-4DBCJNJO.js +0 -117
  38. package/dist/client-4DBCJNJO.js.map +0 -1
  39. package/dist/client-SYS6Z5RX.js.map +0 -1
  40. package/dist/dist-73ESA7QZ.js.map +0 -1
  41. package/dist/esm-IQVNJILX.js.map +0 -1
  42. /package/dist/{ccip-3TXHQUZ5.js.map → ccip-JEEJV65M.js.map} +0 -0
  43. /package/dist/{dist-IANNA5N7.js.map → dist-G5YKLWC5.js.map} +0 -0
@@ -0,0 +1,4016 @@
1
+ import { createRequire as __createRequire } from 'module'; import { fileURLToPath as __fileURLToPath } from 'url'; import { dirname as __pathDirname } from 'path'; const require = __createRequire(import.meta.url); const __filename = __fileURLToPath(import.meta.url); const __dirname = __pathDirname(__filename);
2
+ import {
3
+ BcsEnum,
4
+ BcsStruct,
5
+ BcsTuple,
6
+ BcsType,
7
+ DataLoader,
8
+ SUI_ADDRESS_LENGTH,
9
+ bcs,
10
+ blake2b,
11
+ chunk,
12
+ compareBcsBytes,
13
+ fromBase58,
14
+ fromBase64,
15
+ fromHex,
16
+ init_blake2,
17
+ init_dist,
18
+ init_dist2,
19
+ init_move_registry,
20
+ init_sui_types,
21
+ isSerializedBcs,
22
+ isValidNamedPackage,
23
+ isValidNamedType,
24
+ isValidSuiAddress,
25
+ normalizeStructTag,
26
+ normalizeSuiAddress,
27
+ normalizeSuiObjectId,
28
+ parseStructTag,
29
+ splitGenericParameters,
30
+ toBase58,
31
+ toBase64,
32
+ toHex
33
+ } from "./chunk-3XUF7GM3.js";
34
+ import {
35
+ __esm,
36
+ __export
37
+ } from "./chunk-YPWSCLE3.js";
38
+
39
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/bcs/type-tag-serializer.mjs
40
+ function normalizeTypeTag(type) {
41
+ return TypeTagSerializer.tagToString(TypeTagSerializer.parseFromStr(type));
42
+ }
43
+ var VECTOR_REGEX, STRUCT_REGEX, TypeTagSerializer;
44
+ var init_type_tag_serializer = __esm({
45
+ "../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/bcs/type-tag-serializer.mjs"() {
46
+ "use strict";
47
+ init_sui_types();
48
+ init_dist2();
49
+ VECTOR_REGEX = /^vector<(.+)>$/;
50
+ STRUCT_REGEX = /^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;
51
+ TypeTagSerializer = class TypeTagSerializer2 {
52
+ static parseFromStr(str, normalizeAddress = false) {
53
+ if (str === "address") return { address: null };
54
+ else if (str === "bool") return { bool: null };
55
+ else if (str === "u8") return { u8: null };
56
+ else if (str === "u16") return { u16: null };
57
+ else if (str === "u32") return { u32: null };
58
+ else if (str === "u64") return { u64: null };
59
+ else if (str === "u128") return { u128: null };
60
+ else if (str === "u256") return { u256: null };
61
+ else if (str === "signer") return { signer: null };
62
+ const vectorMatch = str.match(VECTOR_REGEX);
63
+ if (vectorMatch) return { vector: TypeTagSerializer2.parseFromStr(vectorMatch[1], normalizeAddress) };
64
+ const structMatch = str.match(STRUCT_REGEX);
65
+ if (structMatch) return { struct: {
66
+ address: normalizeAddress ? normalizeSuiAddress(structMatch[1]) : structMatch[1],
67
+ module: structMatch[2],
68
+ name: structMatch[3],
69
+ typeParams: structMatch[5] === void 0 ? [] : TypeTagSerializer2.parseStructTypeArgs(structMatch[5], normalizeAddress)
70
+ } };
71
+ throw new Error(`Encountered unexpected token when parsing type args for ${str}`);
72
+ }
73
+ static parseStructTypeArgs(str, normalizeAddress = false) {
74
+ return splitGenericParameters(str).map((tok) => TypeTagSerializer2.parseFromStr(tok, normalizeAddress));
75
+ }
76
+ static tagToString(tag) {
77
+ if ("bool" in tag) return "bool";
78
+ if ("u8" in tag) return "u8";
79
+ if ("u16" in tag) return "u16";
80
+ if ("u32" in tag) return "u32";
81
+ if ("u64" in tag) return "u64";
82
+ if ("u128" in tag) return "u128";
83
+ if ("u256" in tag) return "u256";
84
+ if ("address" in tag) return "address";
85
+ if ("signer" in tag) return "signer";
86
+ if ("vector" in tag) return `vector<${TypeTagSerializer2.tagToString(tag.vector)}>`;
87
+ if ("struct" in tag) {
88
+ const struct = tag.struct;
89
+ const typeParams = struct.typeParams.map(TypeTagSerializer2.tagToString).join(", ");
90
+ return `${struct.address}::${struct.module}::${struct.name}${typeParams ? `<${typeParams}>` : ""}`;
91
+ }
92
+ throw new Error("Invalid TypeTag");
93
+ }
94
+ };
95
+ }
96
+ });
97
+
98
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/bcs/bcs.mjs
99
+ function unsafe_u64(options) {
100
+ return bcs.u64({
101
+ name: "unsafe_u64",
102
+ ...options
103
+ }).transform({
104
+ input: (val) => val,
105
+ output: (val) => Number(val)
106
+ });
107
+ }
108
+ function optionEnum(type) {
109
+ return bcs.enum("Option", {
110
+ None: null,
111
+ Some: type
112
+ });
113
+ }
114
+ function IntentMessage(T) {
115
+ return bcs.struct(`IntentMessage<${T.name}>`, {
116
+ intent: Intent,
117
+ value: T
118
+ });
119
+ }
120
+ var Address, ObjectDigest, SuiObjectRef, SharedObjectRef, ObjectArg, Owner, Reservation, WithdrawalType, WithdrawFrom, FundsWithdrawal, CallArg, InnerTypeTag, TypeTag, Argument, ProgrammableMoveCall, Command, ProgrammableTransaction, TransactionKind, ValidDuring, TransactionExpiration, StructTag, GasData, TransactionDataV1, TransactionData, IntentScope, IntentVersion, AppId, Intent, CompressedSignature, PublicKey, MultiSigPkMap, MultiSigPublicKey, MultiSig, base64String, SenderSignedTransaction, SenderSignedData, PasskeyAuthenticator, MoveObjectType, TypeOrigin, UpgradeInfo, MovePackage, MoveObject, Data, ObjectInner;
121
+ var init_bcs = __esm({
122
+ "../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/bcs/bcs.mjs"() {
123
+ "use strict";
124
+ init_sui_types();
125
+ init_type_tag_serializer();
126
+ init_dist2();
127
+ Address = bcs.bytes(SUI_ADDRESS_LENGTH).transform({
128
+ validate: (val) => {
129
+ const address = typeof val === "string" ? val : toHex(val);
130
+ if (!address || !isValidSuiAddress(normalizeSuiAddress(address))) throw new Error(`Invalid Sui address ${address}`);
131
+ },
132
+ input: (val) => typeof val === "string" ? fromHex(normalizeSuiAddress(val)) : val,
133
+ output: (val) => normalizeSuiAddress(toHex(val))
134
+ });
135
+ ObjectDigest = bcs.byteVector().transform({
136
+ name: "ObjectDigest",
137
+ input: (value) => fromBase58(value),
138
+ output: (value) => toBase58(new Uint8Array(value)),
139
+ validate: (value) => {
140
+ if (fromBase58(value).length !== 32) throw new Error("ObjectDigest must be 32 bytes");
141
+ }
142
+ });
143
+ SuiObjectRef = bcs.struct("SuiObjectRef", {
144
+ objectId: Address,
145
+ version: bcs.u64(),
146
+ digest: ObjectDigest
147
+ });
148
+ SharedObjectRef = bcs.struct("SharedObjectRef", {
149
+ objectId: Address,
150
+ initialSharedVersion: bcs.u64(),
151
+ mutable: bcs.bool()
152
+ });
153
+ ObjectArg = bcs.enum("ObjectArg", {
154
+ ImmOrOwnedObject: SuiObjectRef,
155
+ SharedObject: SharedObjectRef,
156
+ Receiving: SuiObjectRef
157
+ });
158
+ Owner = bcs.enum("Owner", {
159
+ AddressOwner: Address,
160
+ ObjectOwner: Address,
161
+ Shared: bcs.struct("Shared", { initialSharedVersion: bcs.u64() }),
162
+ Immutable: null,
163
+ ConsensusAddressOwner: bcs.struct("ConsensusAddressOwner", {
164
+ startVersion: bcs.u64(),
165
+ owner: Address
166
+ })
167
+ });
168
+ Reservation = bcs.enum("Reservation", { MaxAmountU64: bcs.u64() });
169
+ WithdrawalType = bcs.enum("WithdrawalType", { Balance: bcs.lazy(() => TypeTag) });
170
+ WithdrawFrom = bcs.enum("WithdrawFrom", {
171
+ Sender: null,
172
+ Sponsor: null
173
+ });
174
+ FundsWithdrawal = bcs.struct("FundsWithdrawal", {
175
+ reservation: Reservation,
176
+ typeArg: WithdrawalType,
177
+ withdrawFrom: WithdrawFrom
178
+ });
179
+ CallArg = bcs.enum("CallArg", {
180
+ Pure: bcs.struct("Pure", { bytes: bcs.byteVector().transform({
181
+ input: (val) => typeof val === "string" ? fromBase64(val) : val,
182
+ output: (val) => toBase64(new Uint8Array(val))
183
+ }) }),
184
+ Object: ObjectArg,
185
+ FundsWithdrawal
186
+ });
187
+ InnerTypeTag = bcs.enum("TypeTag", {
188
+ bool: null,
189
+ u8: null,
190
+ u64: null,
191
+ u128: null,
192
+ address: null,
193
+ signer: null,
194
+ vector: bcs.lazy(() => InnerTypeTag),
195
+ struct: bcs.lazy(() => StructTag),
196
+ u16: null,
197
+ u32: null,
198
+ u256: null
199
+ });
200
+ TypeTag = InnerTypeTag.transform({
201
+ input: (typeTag) => typeof typeTag === "string" ? TypeTagSerializer.parseFromStr(typeTag, true) : typeTag,
202
+ output: (typeTag) => TypeTagSerializer.tagToString(typeTag)
203
+ });
204
+ Argument = bcs.enum("Argument", {
205
+ GasCoin: null,
206
+ Input: bcs.u16(),
207
+ Result: bcs.u16(),
208
+ NestedResult: bcs.tuple([bcs.u16(), bcs.u16()])
209
+ });
210
+ ProgrammableMoveCall = bcs.struct("ProgrammableMoveCall", {
211
+ package: Address,
212
+ module: bcs.string(),
213
+ function: bcs.string(),
214
+ typeArguments: bcs.vector(TypeTag),
215
+ arguments: bcs.vector(Argument)
216
+ });
217
+ Command = bcs.enum("Command", {
218
+ MoveCall: ProgrammableMoveCall,
219
+ TransferObjects: bcs.struct("TransferObjects", {
220
+ objects: bcs.vector(Argument),
221
+ address: Argument
222
+ }),
223
+ SplitCoins: bcs.struct("SplitCoins", {
224
+ coin: Argument,
225
+ amounts: bcs.vector(Argument)
226
+ }),
227
+ MergeCoins: bcs.struct("MergeCoins", {
228
+ destination: Argument,
229
+ sources: bcs.vector(Argument)
230
+ }),
231
+ Publish: bcs.struct("Publish", {
232
+ modules: bcs.vector(bcs.byteVector().transform({
233
+ input: (val) => typeof val === "string" ? fromBase64(val) : val,
234
+ output: (val) => toBase64(new Uint8Array(val))
235
+ })),
236
+ dependencies: bcs.vector(Address)
237
+ }),
238
+ MakeMoveVec: bcs.struct("MakeMoveVec", {
239
+ type: optionEnum(TypeTag).transform({
240
+ input: (val) => val === null ? { None: true } : { Some: val },
241
+ output: (val) => val.Some ?? null
242
+ }),
243
+ elements: bcs.vector(Argument)
244
+ }),
245
+ Upgrade: bcs.struct("Upgrade", {
246
+ modules: bcs.vector(bcs.byteVector().transform({
247
+ input: (val) => typeof val === "string" ? fromBase64(val) : val,
248
+ output: (val) => toBase64(new Uint8Array(val))
249
+ })),
250
+ dependencies: bcs.vector(Address),
251
+ package: Address,
252
+ ticket: Argument
253
+ })
254
+ });
255
+ ProgrammableTransaction = bcs.struct("ProgrammableTransaction", {
256
+ inputs: bcs.vector(CallArg),
257
+ commands: bcs.vector(Command)
258
+ });
259
+ TransactionKind = bcs.enum("TransactionKind", {
260
+ ProgrammableTransaction,
261
+ ChangeEpoch: null,
262
+ Genesis: null,
263
+ ConsensusCommitPrologue: null
264
+ });
265
+ ValidDuring = bcs.struct("ValidDuring", {
266
+ minEpoch: bcs.option(bcs.u64()),
267
+ maxEpoch: bcs.option(bcs.u64()),
268
+ minTimestamp: bcs.option(bcs.u64()),
269
+ maxTimestamp: bcs.option(bcs.u64()),
270
+ chain: ObjectDigest,
271
+ nonce: bcs.u32()
272
+ });
273
+ TransactionExpiration = bcs.enum("TransactionExpiration", {
274
+ None: null,
275
+ Epoch: unsafe_u64(),
276
+ ValidDuring
277
+ });
278
+ StructTag = bcs.struct("StructTag", {
279
+ address: Address,
280
+ module: bcs.string(),
281
+ name: bcs.string(),
282
+ typeParams: bcs.vector(InnerTypeTag)
283
+ });
284
+ GasData = bcs.struct("GasData", {
285
+ payment: bcs.vector(SuiObjectRef),
286
+ owner: Address,
287
+ price: bcs.u64(),
288
+ budget: bcs.u64()
289
+ });
290
+ TransactionDataV1 = bcs.struct("TransactionDataV1", {
291
+ kind: TransactionKind,
292
+ sender: Address,
293
+ gasData: GasData,
294
+ expiration: TransactionExpiration
295
+ });
296
+ TransactionData = bcs.enum("TransactionData", { V1: TransactionDataV1 });
297
+ IntentScope = bcs.enum("IntentScope", {
298
+ TransactionData: null,
299
+ TransactionEffects: null,
300
+ CheckpointSummary: null,
301
+ PersonalMessage: null
302
+ });
303
+ IntentVersion = bcs.enum("IntentVersion", { V0: null });
304
+ AppId = bcs.enum("AppId", { Sui: null });
305
+ Intent = bcs.struct("Intent", {
306
+ scope: IntentScope,
307
+ version: IntentVersion,
308
+ appId: AppId
309
+ });
310
+ CompressedSignature = bcs.enum("CompressedSignature", {
311
+ ED25519: bcs.bytes(64),
312
+ Secp256k1: bcs.bytes(64),
313
+ Secp256r1: bcs.bytes(64),
314
+ ZkLogin: bcs.byteVector(),
315
+ Passkey: bcs.byteVector()
316
+ });
317
+ PublicKey = bcs.enum("PublicKey", {
318
+ ED25519: bcs.bytes(32),
319
+ Secp256k1: bcs.bytes(33),
320
+ Secp256r1: bcs.bytes(33),
321
+ ZkLogin: bcs.byteVector(),
322
+ Passkey: bcs.bytes(33)
323
+ });
324
+ MultiSigPkMap = bcs.struct("MultiSigPkMap", {
325
+ pubKey: PublicKey,
326
+ weight: bcs.u8()
327
+ });
328
+ MultiSigPublicKey = bcs.struct("MultiSigPublicKey", {
329
+ pk_map: bcs.vector(MultiSigPkMap),
330
+ threshold: bcs.u16()
331
+ });
332
+ MultiSig = bcs.struct("MultiSig", {
333
+ sigs: bcs.vector(CompressedSignature),
334
+ bitmap: bcs.u16(),
335
+ multisig_pk: MultiSigPublicKey
336
+ });
337
+ base64String = bcs.byteVector().transform({
338
+ input: (val) => typeof val === "string" ? fromBase64(val) : val,
339
+ output: (val) => toBase64(new Uint8Array(val))
340
+ });
341
+ SenderSignedTransaction = bcs.struct("SenderSignedTransaction", {
342
+ intentMessage: IntentMessage(TransactionData),
343
+ txSignatures: bcs.vector(base64String)
344
+ });
345
+ SenderSignedData = bcs.vector(SenderSignedTransaction, { name: "SenderSignedData" });
346
+ PasskeyAuthenticator = bcs.struct("PasskeyAuthenticator", {
347
+ authenticatorData: bcs.byteVector(),
348
+ clientDataJson: bcs.string(),
349
+ userSignature: bcs.byteVector()
350
+ });
351
+ MoveObjectType = bcs.enum("MoveObjectType", {
352
+ Other: StructTag,
353
+ GasCoin: null,
354
+ StakedSui: null,
355
+ Coin: TypeTag,
356
+ AccumulatorBalanceWrapper: null
357
+ });
358
+ TypeOrigin = bcs.struct("TypeOrigin", {
359
+ moduleName: bcs.string(),
360
+ datatypeName: bcs.string(),
361
+ package: Address
362
+ });
363
+ UpgradeInfo = bcs.struct("UpgradeInfo", {
364
+ upgradedId: Address,
365
+ upgradedVersion: bcs.u64()
366
+ });
367
+ MovePackage = bcs.struct("MovePackage", {
368
+ id: Address,
369
+ version: bcs.u64(),
370
+ moduleMap: bcs.map(bcs.string(), bcs.byteVector()),
371
+ typeOriginTable: bcs.vector(TypeOrigin),
372
+ linkageTable: bcs.map(Address, UpgradeInfo)
373
+ });
374
+ MoveObject = bcs.struct("MoveObject", {
375
+ type: MoveObjectType,
376
+ hasPublicTransfer: bcs.bool(),
377
+ version: bcs.u64(),
378
+ contents: bcs.byteVector()
379
+ });
380
+ Data = bcs.enum("Data", {
381
+ Move: MoveObject,
382
+ Package: MovePackage
383
+ });
384
+ ObjectInner = bcs.struct("ObjectInner", {
385
+ data: Data,
386
+ owner: Owner,
387
+ previousTransaction: ObjectDigest,
388
+ storageRebate: bcs.u64()
389
+ });
390
+ }
391
+ });
392
+
393
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/bcs/effects.mjs
394
+ var PackageUpgradeError, ModuleId, MoveLocation, CommandArgumentError, TypeArgumentError, ExecutionFailureStatus, ExecutionStatus, GasCostSummary, TransactionEffectsV1, VersionDigest, ObjectIn, AccumulatorAddress, AccumulatorOperation, AccumulatorValue, AccumulatorWriteV1, ObjectOut, IDOperation, EffectsObjectChange, UnchangedConsensusKind, TransactionEffectsV2, TransactionEffects;
395
+ var init_effects = __esm({
396
+ "../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/bcs/effects.mjs"() {
397
+ "use strict";
398
+ init_bcs();
399
+ init_dist2();
400
+ PackageUpgradeError = bcs.enum("PackageUpgradeError", {
401
+ UnableToFetchPackage: bcs.struct("UnableToFetchPackage", { packageId: Address }),
402
+ NotAPackage: bcs.struct("NotAPackage", { objectId: Address }),
403
+ IncompatibleUpgrade: null,
404
+ DigestDoesNotMatch: bcs.struct("DigestDoesNotMatch", { digest: bcs.byteVector() }),
405
+ UnknownUpgradePolicy: bcs.struct("UnknownUpgradePolicy", { policy: bcs.u8() }),
406
+ PackageIDDoesNotMatch: bcs.struct("PackageIDDoesNotMatch", {
407
+ packageId: Address,
408
+ ticketId: Address
409
+ })
410
+ });
411
+ ModuleId = bcs.struct("ModuleId", {
412
+ address: Address,
413
+ name: bcs.string()
414
+ });
415
+ MoveLocation = bcs.struct("MoveLocation", {
416
+ module: ModuleId,
417
+ function: bcs.u16(),
418
+ instruction: bcs.u16(),
419
+ functionName: bcs.option(bcs.string())
420
+ });
421
+ CommandArgumentError = bcs.enum("CommandArgumentError", {
422
+ TypeMismatch: null,
423
+ InvalidBCSBytes: null,
424
+ InvalidUsageOfPureArg: null,
425
+ InvalidArgumentToPrivateEntryFunction: null,
426
+ IndexOutOfBounds: bcs.struct("IndexOutOfBounds", { idx: bcs.u16() }),
427
+ SecondaryIndexOutOfBounds: bcs.struct("SecondaryIndexOutOfBounds", {
428
+ resultIdx: bcs.u16(),
429
+ secondaryIdx: bcs.u16()
430
+ }),
431
+ InvalidResultArity: bcs.struct("InvalidResultArity", { resultIdx: bcs.u16() }),
432
+ InvalidGasCoinUsage: null,
433
+ InvalidValueUsage: null,
434
+ InvalidObjectByValue: null,
435
+ InvalidObjectByMutRef: null,
436
+ SharedObjectOperationNotAllowed: null,
437
+ InvalidArgumentArity: null,
438
+ InvalidTransferObject: null,
439
+ InvalidMakeMoveVecNonObjectArgument: null,
440
+ ArgumentWithoutValue: null,
441
+ CannotMoveBorrowedValue: null,
442
+ CannotWriteToExtendedReference: null,
443
+ InvalidReferenceArgument: null
444
+ });
445
+ TypeArgumentError = bcs.enum("TypeArgumentError", {
446
+ TypeNotFound: null,
447
+ ConstraintNotSatisfied: null
448
+ });
449
+ ExecutionFailureStatus = bcs.enum("ExecutionFailureStatus", {
450
+ InsufficientGas: null,
451
+ InvalidGasObject: null,
452
+ InvariantViolation: null,
453
+ FeatureNotYetSupported: null,
454
+ MoveObjectTooBig: bcs.struct("MoveObjectTooBig", {
455
+ objectSize: bcs.u64(),
456
+ maxObjectSize: bcs.u64()
457
+ }),
458
+ MovePackageTooBig: bcs.struct("MovePackageTooBig", {
459
+ objectSize: bcs.u64(),
460
+ maxObjectSize: bcs.u64()
461
+ }),
462
+ CircularObjectOwnership: bcs.struct("CircularObjectOwnership", { object: Address }),
463
+ InsufficientCoinBalance: null,
464
+ CoinBalanceOverflow: null,
465
+ PublishErrorNonZeroAddress: null,
466
+ SuiMoveVerificationError: null,
467
+ MovePrimitiveRuntimeError: bcs.option(MoveLocation),
468
+ MoveAbort: bcs.tuple([MoveLocation, bcs.u64()]),
469
+ VMVerificationOrDeserializationError: null,
470
+ VMInvariantViolation: null,
471
+ FunctionNotFound: null,
472
+ ArityMismatch: null,
473
+ TypeArityMismatch: null,
474
+ NonEntryFunctionInvoked: null,
475
+ CommandArgumentError: bcs.struct("CommandArgumentError", {
476
+ argIdx: bcs.u16(),
477
+ kind: CommandArgumentError
478
+ }),
479
+ TypeArgumentError: bcs.struct("TypeArgumentError", {
480
+ argumentIdx: bcs.u16(),
481
+ kind: TypeArgumentError
482
+ }),
483
+ UnusedValueWithoutDrop: bcs.struct("UnusedValueWithoutDrop", {
484
+ resultIdx: bcs.u16(),
485
+ secondaryIdx: bcs.u16()
486
+ }),
487
+ InvalidPublicFunctionReturnType: bcs.struct("InvalidPublicFunctionReturnType", { idx: bcs.u16() }),
488
+ InvalidTransferObject: null,
489
+ EffectsTooLarge: bcs.struct("EffectsTooLarge", {
490
+ currentSize: bcs.u64(),
491
+ maxSize: bcs.u64()
492
+ }),
493
+ PublishUpgradeMissingDependency: null,
494
+ PublishUpgradeDependencyDowngrade: null,
495
+ PackageUpgradeError: bcs.struct("PackageUpgradeError", { upgradeError: PackageUpgradeError }),
496
+ WrittenObjectsTooLarge: bcs.struct("WrittenObjectsTooLarge", {
497
+ currentSize: bcs.u64(),
498
+ maxSize: bcs.u64()
499
+ }),
500
+ CertificateDenied: null,
501
+ SuiMoveVerificationTimedout: null,
502
+ SharedObjectOperationNotAllowed: null,
503
+ InputObjectDeleted: null,
504
+ ExecutionCancelledDueToSharedObjectCongestion: bcs.struct("ExecutionCancelledDueToSharedObjectCongestion", { congested_objects: bcs.vector(Address) }),
505
+ AddressDeniedForCoin: bcs.struct("AddressDeniedForCoin", {
506
+ address: Address,
507
+ coinType: bcs.string()
508
+ }),
509
+ CoinTypeGlobalPause: bcs.struct("CoinTypeGlobalPause", { coinType: bcs.string() }),
510
+ ExecutionCancelledDueToRandomnessUnavailable: null,
511
+ MoveVectorElemTooBig: bcs.struct("MoveVectorElemTooBig", {
512
+ valueSize: bcs.u64(),
513
+ maxScaledSize: bcs.u64()
514
+ }),
515
+ MoveRawValueTooBig: bcs.struct("MoveRawValueTooBig", {
516
+ valueSize: bcs.u64(),
517
+ maxScaledSize: bcs.u64()
518
+ }),
519
+ InvalidLinkage: null,
520
+ InsufficientBalanceForWithdraw: null,
521
+ NonExclusiveWriteInputObjectModified: bcs.struct("NonExclusiveWriteInputObjectModified", { id: Address })
522
+ });
523
+ ExecutionStatus = bcs.enum("ExecutionStatus", {
524
+ Success: null,
525
+ Failure: bcs.struct("Failure", {
526
+ error: ExecutionFailureStatus,
527
+ command: bcs.option(bcs.u64())
528
+ })
529
+ });
530
+ GasCostSummary = bcs.struct("GasCostSummary", {
531
+ computationCost: bcs.u64(),
532
+ storageCost: bcs.u64(),
533
+ storageRebate: bcs.u64(),
534
+ nonRefundableStorageFee: bcs.u64()
535
+ });
536
+ TransactionEffectsV1 = bcs.struct("TransactionEffectsV1", {
537
+ status: ExecutionStatus,
538
+ executedEpoch: bcs.u64(),
539
+ gasUsed: GasCostSummary,
540
+ modifiedAtVersions: bcs.vector(bcs.tuple([Address, bcs.u64()])),
541
+ sharedObjects: bcs.vector(SuiObjectRef),
542
+ transactionDigest: ObjectDigest,
543
+ created: bcs.vector(bcs.tuple([SuiObjectRef, Owner])),
544
+ mutated: bcs.vector(bcs.tuple([SuiObjectRef, Owner])),
545
+ unwrapped: bcs.vector(bcs.tuple([SuiObjectRef, Owner])),
546
+ deleted: bcs.vector(SuiObjectRef),
547
+ unwrappedThenDeleted: bcs.vector(SuiObjectRef),
548
+ wrapped: bcs.vector(SuiObjectRef),
549
+ gasObject: bcs.tuple([SuiObjectRef, Owner]),
550
+ eventsDigest: bcs.option(ObjectDigest),
551
+ dependencies: bcs.vector(ObjectDigest)
552
+ });
553
+ VersionDigest = bcs.tuple([bcs.u64(), ObjectDigest]);
554
+ ObjectIn = bcs.enum("ObjectIn", {
555
+ NotExist: null,
556
+ Exist: bcs.tuple([VersionDigest, Owner])
557
+ });
558
+ AccumulatorAddress = bcs.struct("AccumulatorAddress", {
559
+ address: Address,
560
+ ty: TypeTag
561
+ });
562
+ AccumulatorOperation = bcs.enum("AccumulatorOperation", {
563
+ Merge: null,
564
+ Split: null
565
+ });
566
+ AccumulatorValue = bcs.enum("AccumulatorValue", {
567
+ Integer: bcs.u64(),
568
+ IntegerTuple: bcs.tuple([bcs.u64(), bcs.u64()]),
569
+ EventDigest: bcs.vector(bcs.tuple([bcs.u64(), ObjectDigest]))
570
+ });
571
+ AccumulatorWriteV1 = bcs.struct("AccumulatorWriteV1", {
572
+ address: AccumulatorAddress,
573
+ operation: AccumulatorOperation,
574
+ value: AccumulatorValue
575
+ });
576
+ ObjectOut = bcs.enum("ObjectOut", {
577
+ NotExist: null,
578
+ ObjectWrite: bcs.tuple([ObjectDigest, Owner]),
579
+ PackageWrite: VersionDigest,
580
+ AccumulatorWriteV1
581
+ });
582
+ IDOperation = bcs.enum("IDOperation", {
583
+ None: null,
584
+ Created: null,
585
+ Deleted: null
586
+ });
587
+ EffectsObjectChange = bcs.struct("EffectsObjectChange", {
588
+ inputState: ObjectIn,
589
+ outputState: ObjectOut,
590
+ idOperation: IDOperation
591
+ });
592
+ UnchangedConsensusKind = bcs.enum("UnchangedConsensusKind", {
593
+ ReadOnlyRoot: VersionDigest,
594
+ MutateConsensusStreamEnded: bcs.u64(),
595
+ ReadConsensusStreamEnded: bcs.u64(),
596
+ Cancelled: bcs.u64(),
597
+ PerEpochConfig: null
598
+ });
599
+ TransactionEffectsV2 = bcs.struct("TransactionEffectsV2", {
600
+ status: ExecutionStatus,
601
+ executedEpoch: bcs.u64(),
602
+ gasUsed: GasCostSummary,
603
+ transactionDigest: ObjectDigest,
604
+ gasObjectIndex: bcs.option(bcs.u32()),
605
+ eventsDigest: bcs.option(ObjectDigest),
606
+ dependencies: bcs.vector(ObjectDigest),
607
+ lamportVersion: bcs.u64(),
608
+ changedObjects: bcs.vector(bcs.tuple([Address, EffectsObjectChange])),
609
+ unchangedConsensusObjects: bcs.vector(bcs.tuple([Address, UnchangedConsensusKind])),
610
+ auxDataDigest: bcs.option(ObjectDigest)
611
+ });
612
+ TransactionEffects = bcs.enum("TransactionEffects", {
613
+ V1: TransactionEffectsV1,
614
+ V2: TransactionEffectsV2
615
+ });
616
+ }
617
+ });
618
+
619
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/bcs/pure.mjs
620
+ function pureBcsSchemaFromTypeName(name) {
621
+ switch (name) {
622
+ case "u8":
623
+ return bcs.u8();
624
+ case "u16":
625
+ return bcs.u16();
626
+ case "u32":
627
+ return bcs.u32();
628
+ case "u64":
629
+ return bcs.u64();
630
+ case "u128":
631
+ return bcs.u128();
632
+ case "u256":
633
+ return bcs.u256();
634
+ case "bool":
635
+ return bcs.bool();
636
+ case "string":
637
+ return bcs.string();
638
+ case "id":
639
+ case "address":
640
+ return Address;
641
+ }
642
+ const generic = name.match(/^(vector|option)<(.+)>$/);
643
+ if (generic) {
644
+ const [kind, inner] = generic.slice(1);
645
+ if (kind === "vector") return bcs.vector(pureBcsSchemaFromTypeName(inner));
646
+ else return bcs.option(pureBcsSchemaFromTypeName(inner));
647
+ }
648
+ throw new Error(`Invalid Pure type name: ${name}`);
649
+ }
650
+ var init_pure = __esm({
651
+ "../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/bcs/pure.mjs"() {
652
+ "use strict";
653
+ init_bcs();
654
+ init_dist2();
655
+ }
656
+ });
657
+
658
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/bcs/index.mjs
659
+ var bcs_exports = {};
660
+ __export(bcs_exports, {
661
+ BcsEnum: () => BcsEnum,
662
+ BcsStruct: () => BcsStruct,
663
+ BcsTuple: () => BcsTuple,
664
+ BcsType: () => BcsType,
665
+ TypeTagSerializer: () => TypeTagSerializer,
666
+ bcs: () => suiBcs,
667
+ compareBcsBytes: () => compareBcsBytes,
668
+ pureBcsSchemaFromTypeName: () => pureBcsSchemaFromTypeName
669
+ });
670
+ var suiBcs;
671
+ var init_bcs2 = __esm({
672
+ "../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/bcs/index.mjs"() {
673
+ "use strict";
674
+ init_type_tag_serializer();
675
+ init_bcs();
676
+ init_effects();
677
+ init_pure();
678
+ init_dist2();
679
+ suiBcs = {
680
+ ...bcs,
681
+ U8: bcs.u8(),
682
+ U16: bcs.u16(),
683
+ U32: bcs.u32(),
684
+ U64: bcs.u64(),
685
+ U128: bcs.u128(),
686
+ U256: bcs.u256(),
687
+ ULEB128: bcs.uleb128(),
688
+ Bool: bcs.bool(),
689
+ String: bcs.string(),
690
+ Address,
691
+ AppId,
692
+ Argument,
693
+ CallArg,
694
+ Command,
695
+ CompressedSignature,
696
+ Data,
697
+ GasData,
698
+ Intent,
699
+ IntentMessage,
700
+ IntentScope,
701
+ IntentVersion,
702
+ MoveObject,
703
+ MoveObjectType,
704
+ MovePackage,
705
+ MultiSig,
706
+ MultiSigPkMap,
707
+ MultiSigPublicKey,
708
+ Object: ObjectInner,
709
+ ObjectArg,
710
+ ObjectDigest,
711
+ Owner,
712
+ PasskeyAuthenticator,
713
+ ProgrammableMoveCall,
714
+ ProgrammableTransaction,
715
+ PublicKey,
716
+ SenderSignedData,
717
+ SenderSignedTransaction,
718
+ SharedObjectRef,
719
+ StructTag,
720
+ SuiObjectRef,
721
+ TransactionData,
722
+ TransactionDataV1,
723
+ TransactionEffects,
724
+ TransactionExpiration,
725
+ TransactionKind,
726
+ TypeOrigin,
727
+ TypeTag,
728
+ UpgradeInfo
729
+ };
730
+ }
731
+ });
732
+
733
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/utils/constants.mjs
734
+ var SUI_DECIMALS, MIST_PER_SUI, MOVE_STDLIB_ADDRESS, SUI_FRAMEWORK_ADDRESS, SUI_SYSTEM_ADDRESS, SUI_CLOCK_OBJECT_ID, SUI_SYSTEM_MODULE_NAME, SUI_TYPE_ARG, SUI_SYSTEM_STATE_OBJECT_ID, SUI_RANDOM_OBJECT_ID, SUI_COIN_REGISTRY_OBJECT_ID, SUI_DENY_LIST_OBJECT_ID;
735
+ var init_constants = __esm({
736
+ "../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/utils/constants.mjs"() {
737
+ "use strict";
738
+ SUI_DECIMALS = 9;
739
+ MIST_PER_SUI = BigInt(1e9);
740
+ MOVE_STDLIB_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000001";
741
+ SUI_FRAMEWORK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000002";
742
+ SUI_SYSTEM_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000003";
743
+ SUI_CLOCK_OBJECT_ID = "0x0000000000000000000000000000000000000000000000000000000000000006";
744
+ SUI_SYSTEM_MODULE_NAME = "sui_system";
745
+ SUI_TYPE_ARG = `${SUI_FRAMEWORK_ADDRESS}::sui::SUI`;
746
+ SUI_SYSTEM_STATE_OBJECT_ID = "0x0000000000000000000000000000000000000000000000000000000000000005";
747
+ SUI_RANDOM_OBJECT_ID = "0x0000000000000000000000000000000000000000000000000000000000000008";
748
+ SUI_COIN_REGISTRY_OBJECT_ID = "0x000000000000000000000000000000000000000000000000000000000000000c";
749
+ SUI_DENY_LIST_OBJECT_ID = "0x0000000000000000000000000000000000000000000000000000000000000403";
750
+ }
751
+ });
752
+
753
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/Transaction.mjs
754
+ init_sui_types();
755
+
756
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/data/internal.mjs
757
+ init_sui_types();
758
+
759
+ // ../../node_modules/.pnpm/valibot@1.3.1_typescript@5.9.3/node_modules/valibot/dist/index.mjs
760
+ var store$4;
761
+ // @__NO_SIDE_EFFECTS__
762
+ function getGlobalConfig(config$1) {
763
+ return {
764
+ lang: config$1?.lang ?? store$4?.lang,
765
+ message: config$1?.message,
766
+ abortEarly: config$1?.abortEarly ?? store$4?.abortEarly,
767
+ abortPipeEarly: config$1?.abortPipeEarly ?? store$4?.abortPipeEarly
768
+ };
769
+ }
770
+ var store$3;
771
+ // @__NO_SIDE_EFFECTS__
772
+ function getGlobalMessage(lang) {
773
+ return store$3?.get(lang);
774
+ }
775
+ var store$2;
776
+ // @__NO_SIDE_EFFECTS__
777
+ function getSchemaMessage(lang) {
778
+ return store$2?.get(lang);
779
+ }
780
+ var store$1;
781
+ // @__NO_SIDE_EFFECTS__
782
+ function getSpecificMessage(reference, lang) {
783
+ return store$1?.get(reference)?.get(lang);
784
+ }
785
+ // @__NO_SIDE_EFFECTS__
786
+ function _stringify(input) {
787
+ const type = typeof input;
788
+ if (type === "string") return `"${input}"`;
789
+ if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
790
+ if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
791
+ return type;
792
+ }
793
+ function _addIssue(context, label, dataset, config$1, other) {
794
+ const input = other && "input" in other ? other.input : dataset.value;
795
+ const expected = other?.expected ?? context.expects ?? null;
796
+ const received = other?.received ?? /* @__PURE__ */ _stringify(input);
797
+ const issue = {
798
+ kind: context.kind,
799
+ type: context.type,
800
+ input,
801
+ expected,
802
+ received,
803
+ message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
804
+ requirement: context.requirement,
805
+ path: other?.path,
806
+ issues: other?.issues,
807
+ lang: config$1.lang,
808
+ abortEarly: config$1.abortEarly,
809
+ abortPipeEarly: config$1.abortPipeEarly
810
+ };
811
+ const isSchema = context.kind === "schema";
812
+ const message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
813
+ if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
814
+ if (isSchema) dataset.typed = false;
815
+ if (dataset.issues) dataset.issues.push(issue);
816
+ else dataset.issues = [issue];
817
+ }
818
+ // @__NO_SIDE_EFFECTS__
819
+ function _getStandardProps(context) {
820
+ return {
821
+ version: 1,
822
+ vendor: "valibot",
823
+ validate(value$1) {
824
+ return context["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig());
825
+ }
826
+ };
827
+ }
828
+ // @__NO_SIDE_EFFECTS__
829
+ function _isValidObjectKey(object$1, key) {
830
+ return Object.hasOwn(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
831
+ }
832
+ // @__NO_SIDE_EFFECTS__
833
+ function _joinExpects(values$1, separator) {
834
+ const list = [...new Set(values$1)];
835
+ if (list.length > 1) return `(${list.join(` ${separator} `)})`;
836
+ return list[0] ?? "never";
837
+ }
838
+ var ValiError = class extends Error {
839
+ /**
840
+ * Creates a Valibot error with useful information.
841
+ *
842
+ * @param issues The error issues.
843
+ */
844
+ constructor(issues) {
845
+ super(issues[0].message);
846
+ this.name = "ValiError";
847
+ this.issues = issues;
848
+ }
849
+ };
850
+ // @__NO_SIDE_EFFECTS__
851
+ function check(requirement, message$1) {
852
+ return {
853
+ kind: "validation",
854
+ type: "check",
855
+ reference: check,
856
+ async: false,
857
+ expects: null,
858
+ requirement,
859
+ message: message$1,
860
+ "~run"(dataset, config$1) {
861
+ if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "input", dataset, config$1);
862
+ return dataset;
863
+ }
864
+ };
865
+ }
866
+ // @__NO_SIDE_EFFECTS__
867
+ function integer(message$1) {
868
+ return {
869
+ kind: "validation",
870
+ type: "integer",
871
+ reference: integer,
872
+ async: false,
873
+ expects: null,
874
+ requirement: Number.isInteger,
875
+ message: message$1,
876
+ "~run"(dataset, config$1) {
877
+ if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "integer", dataset, config$1);
878
+ return dataset;
879
+ }
880
+ };
881
+ }
882
+ // @__NO_SIDE_EFFECTS__
883
+ function transform(operation) {
884
+ return {
885
+ kind: "transformation",
886
+ type: "transform",
887
+ reference: transform,
888
+ async: false,
889
+ operation,
890
+ "~run"(dataset) {
891
+ dataset.value = this.operation(dataset.value);
892
+ return dataset;
893
+ }
894
+ };
895
+ }
896
+ // @__NO_SIDE_EFFECTS__
897
+ function getFallback(schema, dataset, config$1) {
898
+ return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
899
+ }
900
+ // @__NO_SIDE_EFFECTS__
901
+ function getDefault(schema, dataset, config$1) {
902
+ return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
903
+ }
904
+ // @__NO_SIDE_EFFECTS__
905
+ function is(schema, input) {
906
+ return !schema["~run"]({ value: input }, { abortEarly: true }).issues;
907
+ }
908
+ // @__NO_SIDE_EFFECTS__
909
+ function array(item, message$1) {
910
+ return {
911
+ kind: "schema",
912
+ type: "array",
913
+ reference: array,
914
+ expects: "Array",
915
+ async: false,
916
+ item,
917
+ message: message$1,
918
+ get "~standard"() {
919
+ return /* @__PURE__ */ _getStandardProps(this);
920
+ },
921
+ "~run"(dataset, config$1) {
922
+ const input = dataset.value;
923
+ if (Array.isArray(input)) {
924
+ dataset.typed = true;
925
+ dataset.value = [];
926
+ for (let key = 0; key < input.length; key++) {
927
+ const value$1 = input[key];
928
+ const itemDataset = this.item["~run"]({ value: value$1 }, config$1);
929
+ if (itemDataset.issues) {
930
+ const pathItem = {
931
+ type: "array",
932
+ origin: "value",
933
+ input,
934
+ key,
935
+ value: value$1
936
+ };
937
+ for (const issue of itemDataset.issues) {
938
+ if (issue.path) issue.path.unshift(pathItem);
939
+ else issue.path = [pathItem];
940
+ dataset.issues?.push(issue);
941
+ }
942
+ if (!dataset.issues) dataset.issues = itemDataset.issues;
943
+ if (config$1.abortEarly) {
944
+ dataset.typed = false;
945
+ break;
946
+ }
947
+ }
948
+ if (!itemDataset.typed) dataset.typed = false;
949
+ dataset.value.push(itemDataset.value);
950
+ }
951
+ } else _addIssue(this, "type", dataset, config$1);
952
+ return dataset;
953
+ }
954
+ };
955
+ }
956
+ // @__NO_SIDE_EFFECTS__
957
+ function bigint(message$1) {
958
+ return {
959
+ kind: "schema",
960
+ type: "bigint",
961
+ reference: bigint,
962
+ expects: "bigint",
963
+ async: false,
964
+ message: message$1,
965
+ get "~standard"() {
966
+ return /* @__PURE__ */ _getStandardProps(this);
967
+ },
968
+ "~run"(dataset, config$1) {
969
+ if (typeof dataset.value === "bigint") dataset.typed = true;
970
+ else _addIssue(this, "type", dataset, config$1);
971
+ return dataset;
972
+ }
973
+ };
974
+ }
975
+ // @__NO_SIDE_EFFECTS__
976
+ function boolean(message$1) {
977
+ return {
978
+ kind: "schema",
979
+ type: "boolean",
980
+ reference: boolean,
981
+ expects: "boolean",
982
+ async: false,
983
+ message: message$1,
984
+ get "~standard"() {
985
+ return /* @__PURE__ */ _getStandardProps(this);
986
+ },
987
+ "~run"(dataset, config$1) {
988
+ if (typeof dataset.value === "boolean") dataset.typed = true;
989
+ else _addIssue(this, "type", dataset, config$1);
990
+ return dataset;
991
+ }
992
+ };
993
+ }
994
+ // @__NO_SIDE_EFFECTS__
995
+ function lazy(getter) {
996
+ return {
997
+ kind: "schema",
998
+ type: "lazy",
999
+ reference: lazy,
1000
+ expects: "unknown",
1001
+ async: false,
1002
+ getter,
1003
+ get "~standard"() {
1004
+ return /* @__PURE__ */ _getStandardProps(this);
1005
+ },
1006
+ "~run"(dataset, config$1) {
1007
+ return this.getter(dataset.value)["~run"](dataset, config$1);
1008
+ }
1009
+ };
1010
+ }
1011
+ // @__NO_SIDE_EFFECTS__
1012
+ function literal(literal_, message$1) {
1013
+ return {
1014
+ kind: "schema",
1015
+ type: "literal",
1016
+ reference: literal,
1017
+ expects: /* @__PURE__ */ _stringify(literal_),
1018
+ async: false,
1019
+ literal: literal_,
1020
+ message: message$1,
1021
+ get "~standard"() {
1022
+ return /* @__PURE__ */ _getStandardProps(this);
1023
+ },
1024
+ "~run"(dataset, config$1) {
1025
+ if (dataset.value === this.literal) dataset.typed = true;
1026
+ else _addIssue(this, "type", dataset, config$1);
1027
+ return dataset;
1028
+ }
1029
+ };
1030
+ }
1031
+ // @__NO_SIDE_EFFECTS__
1032
+ function nullable(wrapped, default_) {
1033
+ return {
1034
+ kind: "schema",
1035
+ type: "nullable",
1036
+ reference: nullable,
1037
+ expects: `(${wrapped.expects} | null)`,
1038
+ async: false,
1039
+ wrapped,
1040
+ default: default_,
1041
+ get "~standard"() {
1042
+ return /* @__PURE__ */ _getStandardProps(this);
1043
+ },
1044
+ "~run"(dataset, config$1) {
1045
+ if (dataset.value === null) {
1046
+ if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
1047
+ if (dataset.value === null) {
1048
+ dataset.typed = true;
1049
+ return dataset;
1050
+ }
1051
+ }
1052
+ return this.wrapped["~run"](dataset, config$1);
1053
+ }
1054
+ };
1055
+ }
1056
+ // @__NO_SIDE_EFFECTS__
1057
+ function nullish(wrapped, default_) {
1058
+ return {
1059
+ kind: "schema",
1060
+ type: "nullish",
1061
+ reference: nullish,
1062
+ expects: `(${wrapped.expects} | null | undefined)`,
1063
+ async: false,
1064
+ wrapped,
1065
+ default: default_,
1066
+ get "~standard"() {
1067
+ return /* @__PURE__ */ _getStandardProps(this);
1068
+ },
1069
+ "~run"(dataset, config$1) {
1070
+ if (dataset.value === null || dataset.value === void 0) {
1071
+ if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
1072
+ if (dataset.value === null || dataset.value === void 0) {
1073
+ dataset.typed = true;
1074
+ return dataset;
1075
+ }
1076
+ }
1077
+ return this.wrapped["~run"](dataset, config$1);
1078
+ }
1079
+ };
1080
+ }
1081
+ // @__NO_SIDE_EFFECTS__
1082
+ function number(message$1) {
1083
+ return {
1084
+ kind: "schema",
1085
+ type: "number",
1086
+ reference: number,
1087
+ expects: "number",
1088
+ async: false,
1089
+ message: message$1,
1090
+ get "~standard"() {
1091
+ return /* @__PURE__ */ _getStandardProps(this);
1092
+ },
1093
+ "~run"(dataset, config$1) {
1094
+ if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
1095
+ else _addIssue(this, "type", dataset, config$1);
1096
+ return dataset;
1097
+ }
1098
+ };
1099
+ }
1100
+ // @__NO_SIDE_EFFECTS__
1101
+ function object(entries$1, message$1) {
1102
+ return {
1103
+ kind: "schema",
1104
+ type: "object",
1105
+ reference: object,
1106
+ expects: "Object",
1107
+ async: false,
1108
+ entries: entries$1,
1109
+ message: message$1,
1110
+ get "~standard"() {
1111
+ return /* @__PURE__ */ _getStandardProps(this);
1112
+ },
1113
+ "~run"(dataset, config$1) {
1114
+ const input = dataset.value;
1115
+ if (input && typeof input === "object") {
1116
+ dataset.typed = true;
1117
+ dataset.value = {};
1118
+ for (const key in this.entries) {
1119
+ const valueSchema = this.entries[key];
1120
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
1121
+ const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
1122
+ const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
1123
+ if (valueDataset.issues) {
1124
+ const pathItem = {
1125
+ type: "object",
1126
+ origin: "value",
1127
+ input,
1128
+ key,
1129
+ value: value$1
1130
+ };
1131
+ for (const issue of valueDataset.issues) {
1132
+ if (issue.path) issue.path.unshift(pathItem);
1133
+ else issue.path = [pathItem];
1134
+ dataset.issues?.push(issue);
1135
+ }
1136
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
1137
+ if (config$1.abortEarly) {
1138
+ dataset.typed = false;
1139
+ break;
1140
+ }
1141
+ }
1142
+ if (!valueDataset.typed) dataset.typed = false;
1143
+ dataset.value[key] = valueDataset.value;
1144
+ } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
1145
+ else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
1146
+ _addIssue(this, "key", dataset, config$1, {
1147
+ input: void 0,
1148
+ expected: `"${key}"`,
1149
+ path: [{
1150
+ type: "object",
1151
+ origin: "key",
1152
+ input,
1153
+ key,
1154
+ value: input[key]
1155
+ }]
1156
+ });
1157
+ if (config$1.abortEarly) break;
1158
+ }
1159
+ }
1160
+ } else _addIssue(this, "type", dataset, config$1);
1161
+ return dataset;
1162
+ }
1163
+ };
1164
+ }
1165
+ // @__NO_SIDE_EFFECTS__
1166
+ function optional(wrapped, default_) {
1167
+ return {
1168
+ kind: "schema",
1169
+ type: "optional",
1170
+ reference: optional,
1171
+ expects: `(${wrapped.expects} | undefined)`,
1172
+ async: false,
1173
+ wrapped,
1174
+ default: default_,
1175
+ get "~standard"() {
1176
+ return /* @__PURE__ */ _getStandardProps(this);
1177
+ },
1178
+ "~run"(dataset, config$1) {
1179
+ if (dataset.value === void 0) {
1180
+ if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
1181
+ if (dataset.value === void 0) {
1182
+ dataset.typed = true;
1183
+ return dataset;
1184
+ }
1185
+ }
1186
+ return this.wrapped["~run"](dataset, config$1);
1187
+ }
1188
+ };
1189
+ }
1190
+ // @__NO_SIDE_EFFECTS__
1191
+ function record(key, value$1, message$1) {
1192
+ return {
1193
+ kind: "schema",
1194
+ type: "record",
1195
+ reference: record,
1196
+ expects: "Object",
1197
+ async: false,
1198
+ key,
1199
+ value: value$1,
1200
+ message: message$1,
1201
+ get "~standard"() {
1202
+ return /* @__PURE__ */ _getStandardProps(this);
1203
+ },
1204
+ "~run"(dataset, config$1) {
1205
+ const input = dataset.value;
1206
+ if (input && typeof input === "object") {
1207
+ dataset.typed = true;
1208
+ dataset.value = {};
1209
+ for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
1210
+ const entryValue = input[entryKey];
1211
+ const keyDataset = this.key["~run"]({ value: entryKey }, config$1);
1212
+ if (keyDataset.issues) {
1213
+ const pathItem = {
1214
+ type: "object",
1215
+ origin: "key",
1216
+ input,
1217
+ key: entryKey,
1218
+ value: entryValue
1219
+ };
1220
+ for (const issue of keyDataset.issues) {
1221
+ issue.path = [pathItem];
1222
+ dataset.issues?.push(issue);
1223
+ }
1224
+ if (!dataset.issues) dataset.issues = keyDataset.issues;
1225
+ if (config$1.abortEarly) {
1226
+ dataset.typed = false;
1227
+ break;
1228
+ }
1229
+ }
1230
+ const valueDataset = this.value["~run"]({ value: entryValue }, config$1);
1231
+ if (valueDataset.issues) {
1232
+ const pathItem = {
1233
+ type: "object",
1234
+ origin: "value",
1235
+ input,
1236
+ key: entryKey,
1237
+ value: entryValue
1238
+ };
1239
+ for (const issue of valueDataset.issues) {
1240
+ if (issue.path) issue.path.unshift(pathItem);
1241
+ else issue.path = [pathItem];
1242
+ dataset.issues?.push(issue);
1243
+ }
1244
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
1245
+ if (config$1.abortEarly) {
1246
+ dataset.typed = false;
1247
+ break;
1248
+ }
1249
+ }
1250
+ if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
1251
+ if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
1252
+ }
1253
+ } else _addIssue(this, "type", dataset, config$1);
1254
+ return dataset;
1255
+ }
1256
+ };
1257
+ }
1258
+ // @__NO_SIDE_EFFECTS__
1259
+ function string(message$1) {
1260
+ return {
1261
+ kind: "schema",
1262
+ type: "string",
1263
+ reference: string,
1264
+ expects: "string",
1265
+ async: false,
1266
+ message: message$1,
1267
+ get "~standard"() {
1268
+ return /* @__PURE__ */ _getStandardProps(this);
1269
+ },
1270
+ "~run"(dataset, config$1) {
1271
+ if (typeof dataset.value === "string") dataset.typed = true;
1272
+ else _addIssue(this, "type", dataset, config$1);
1273
+ return dataset;
1274
+ }
1275
+ };
1276
+ }
1277
+ // @__NO_SIDE_EFFECTS__
1278
+ function tuple(items, message$1) {
1279
+ return {
1280
+ kind: "schema",
1281
+ type: "tuple",
1282
+ reference: tuple,
1283
+ expects: "Array",
1284
+ async: false,
1285
+ items,
1286
+ message: message$1,
1287
+ get "~standard"() {
1288
+ return /* @__PURE__ */ _getStandardProps(this);
1289
+ },
1290
+ "~run"(dataset, config$1) {
1291
+ const input = dataset.value;
1292
+ if (Array.isArray(input)) {
1293
+ dataset.typed = true;
1294
+ dataset.value = [];
1295
+ for (let key = 0; key < this.items.length; key++) {
1296
+ const value$1 = input[key];
1297
+ const itemDataset = this.items[key]["~run"]({ value: value$1 }, config$1);
1298
+ if (itemDataset.issues) {
1299
+ const pathItem = {
1300
+ type: "array",
1301
+ origin: "value",
1302
+ input,
1303
+ key,
1304
+ value: value$1
1305
+ };
1306
+ for (const issue of itemDataset.issues) {
1307
+ if (issue.path) issue.path.unshift(pathItem);
1308
+ else issue.path = [pathItem];
1309
+ dataset.issues?.push(issue);
1310
+ }
1311
+ if (!dataset.issues) dataset.issues = itemDataset.issues;
1312
+ if (config$1.abortEarly) {
1313
+ dataset.typed = false;
1314
+ break;
1315
+ }
1316
+ }
1317
+ if (!itemDataset.typed) dataset.typed = false;
1318
+ dataset.value.push(itemDataset.value);
1319
+ }
1320
+ } else _addIssue(this, "type", dataset, config$1);
1321
+ return dataset;
1322
+ }
1323
+ };
1324
+ }
1325
+ // @__NO_SIDE_EFFECTS__
1326
+ function _subIssues(datasets) {
1327
+ let issues;
1328
+ if (datasets) for (const dataset of datasets) if (issues) issues.push(...dataset.issues);
1329
+ else issues = dataset.issues;
1330
+ return issues;
1331
+ }
1332
+ // @__NO_SIDE_EFFECTS__
1333
+ function union(options, message$1) {
1334
+ return {
1335
+ kind: "schema",
1336
+ type: "union",
1337
+ reference: union,
1338
+ expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
1339
+ async: false,
1340
+ options,
1341
+ message: message$1,
1342
+ get "~standard"() {
1343
+ return /* @__PURE__ */ _getStandardProps(this);
1344
+ },
1345
+ "~run"(dataset, config$1) {
1346
+ let validDataset;
1347
+ let typedDatasets;
1348
+ let untypedDatasets;
1349
+ for (const schema of this.options) {
1350
+ const optionDataset = schema["~run"]({ value: dataset.value }, config$1);
1351
+ if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
1352
+ else typedDatasets = [optionDataset];
1353
+ else {
1354
+ validDataset = optionDataset;
1355
+ break;
1356
+ }
1357
+ else if (untypedDatasets) untypedDatasets.push(optionDataset);
1358
+ else untypedDatasets = [optionDataset];
1359
+ }
1360
+ if (validDataset) return validDataset;
1361
+ if (typedDatasets) {
1362
+ if (typedDatasets.length === 1) return typedDatasets[0];
1363
+ _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
1364
+ dataset.typed = true;
1365
+ } else if (untypedDatasets?.length === 1) return untypedDatasets[0];
1366
+ else _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
1367
+ return dataset;
1368
+ }
1369
+ };
1370
+ }
1371
+ // @__NO_SIDE_EFFECTS__
1372
+ function unknown() {
1373
+ return {
1374
+ kind: "schema",
1375
+ type: "unknown",
1376
+ reference: unknown,
1377
+ expects: "unknown",
1378
+ async: false,
1379
+ get "~standard"() {
1380
+ return /* @__PURE__ */ _getStandardProps(this);
1381
+ },
1382
+ "~run"(dataset) {
1383
+ dataset.typed = true;
1384
+ return dataset;
1385
+ }
1386
+ };
1387
+ }
1388
+ function parse(schema, input, config$1) {
1389
+ const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
1390
+ if (dataset.issues) throw new ValiError(dataset.issues);
1391
+ return dataset.value;
1392
+ }
1393
+ // @__NO_SIDE_EFFECTS__
1394
+ function pipe(...pipe$1) {
1395
+ return {
1396
+ ...pipe$1[0],
1397
+ pipe: pipe$1,
1398
+ get "~standard"() {
1399
+ return /* @__PURE__ */ _getStandardProps(this);
1400
+ },
1401
+ "~run"(dataset, config$1) {
1402
+ for (const item of pipe$1) if (item.kind !== "metadata") {
1403
+ if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
1404
+ dataset.typed = false;
1405
+ break;
1406
+ }
1407
+ if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = item["~run"](dataset, config$1);
1408
+ }
1409
+ return dataset;
1410
+ }
1411
+ };
1412
+ }
1413
+
1414
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/data/internal.mjs
1415
+ function safeEnum(options) {
1416
+ return union(Object.keys(options).map((key) => withKind(key, object({ [key]: options[key] }))));
1417
+ }
1418
+ function withKind(key, schema) {
1419
+ return pipe(object({
1420
+ ...schema.entries,
1421
+ $kind: optional(literal(key))
1422
+ }), transform((value) => ({
1423
+ ...value,
1424
+ $kind: key
1425
+ })));
1426
+ }
1427
+ var SuiAddress = pipe(string(), transform((value) => normalizeSuiAddress(value)), check(isValidSuiAddress));
1428
+ var ObjectID = SuiAddress;
1429
+ var BCSBytes = string();
1430
+ var JsonU64 = pipe(union([string(), pipe(number(), integer())]), check((val) => {
1431
+ try {
1432
+ BigInt(val);
1433
+ return BigInt(val) >= 0 && BigInt(val) <= 18446744073709551615n;
1434
+ } catch {
1435
+ return false;
1436
+ }
1437
+ }, "Invalid u64"));
1438
+ var U32 = pipe(number(), integer(), check((val) => val >= 0 && val < 2 ** 32, "Invalid u32"));
1439
+ var ObjectRefSchema = object({
1440
+ objectId: SuiAddress,
1441
+ version: JsonU64,
1442
+ digest: string()
1443
+ });
1444
+ var ArgumentSchema = union([
1445
+ withKind("GasCoin", object({ GasCoin: literal(true) })),
1446
+ withKind("Input", object({
1447
+ Input: pipe(number(), integer()),
1448
+ type: optional(union([
1449
+ literal("pure"),
1450
+ literal("object"),
1451
+ literal("withdrawal")
1452
+ ]))
1453
+ })),
1454
+ withKind("Result", object({ Result: pipe(number(), integer()) })),
1455
+ withKind("NestedResult", object({ NestedResult: tuple([pipe(number(), integer()), pipe(number(), integer())]) }))
1456
+ ]);
1457
+ var GasDataSchema = object({
1458
+ budget: nullable(JsonU64),
1459
+ price: nullable(JsonU64),
1460
+ owner: nullable(SuiAddress),
1461
+ payment: nullable(array(ObjectRefSchema))
1462
+ });
1463
+ var StructTagSchema = object({
1464
+ address: string(),
1465
+ module: string(),
1466
+ name: string(),
1467
+ typeParams: array(string())
1468
+ });
1469
+ var OpenSignatureBodySchema = union([
1470
+ object({ $kind: literal("address") }),
1471
+ object({ $kind: literal("bool") }),
1472
+ object({ $kind: literal("u8") }),
1473
+ object({ $kind: literal("u16") }),
1474
+ object({ $kind: literal("u32") }),
1475
+ object({ $kind: literal("u64") }),
1476
+ object({ $kind: literal("u128") }),
1477
+ object({ $kind: literal("u256") }),
1478
+ object({ $kind: literal("unknown") }),
1479
+ object({
1480
+ $kind: literal("vector"),
1481
+ vector: lazy(() => OpenSignatureBodySchema)
1482
+ }),
1483
+ object({
1484
+ $kind: literal("datatype"),
1485
+ datatype: object({
1486
+ typeName: string(),
1487
+ typeParameters: array(lazy(() => OpenSignatureBodySchema))
1488
+ })
1489
+ }),
1490
+ object({
1491
+ $kind: literal("typeParameter"),
1492
+ index: pipe(number(), integer())
1493
+ })
1494
+ ]);
1495
+ var OpenSignatureSchema = object({
1496
+ reference: nullable(union([
1497
+ literal("mutable"),
1498
+ literal("immutable"),
1499
+ literal("unknown")
1500
+ ])),
1501
+ body: OpenSignatureBodySchema
1502
+ });
1503
+ var ProgrammableMoveCallSchema = object({
1504
+ package: ObjectID,
1505
+ module: string(),
1506
+ function: string(),
1507
+ typeArguments: array(string()),
1508
+ arguments: array(ArgumentSchema),
1509
+ _argumentTypes: optional(nullable(array(OpenSignatureSchema)))
1510
+ });
1511
+ var $Intent = object({
1512
+ name: string(),
1513
+ inputs: record(string(), union([ArgumentSchema, array(ArgumentSchema)])),
1514
+ data: record(string(), unknown())
1515
+ });
1516
+ var CommandSchema = safeEnum({
1517
+ MoveCall: ProgrammableMoveCallSchema,
1518
+ TransferObjects: object({
1519
+ objects: array(ArgumentSchema),
1520
+ address: ArgumentSchema
1521
+ }),
1522
+ SplitCoins: object({
1523
+ coin: ArgumentSchema,
1524
+ amounts: array(ArgumentSchema)
1525
+ }),
1526
+ MergeCoins: object({
1527
+ destination: ArgumentSchema,
1528
+ sources: array(ArgumentSchema)
1529
+ }),
1530
+ Publish: object({
1531
+ modules: array(BCSBytes),
1532
+ dependencies: array(ObjectID)
1533
+ }),
1534
+ MakeMoveVec: object({
1535
+ type: nullable(string()),
1536
+ elements: array(ArgumentSchema)
1537
+ }),
1538
+ Upgrade: object({
1539
+ modules: array(BCSBytes),
1540
+ dependencies: array(ObjectID),
1541
+ package: ObjectID,
1542
+ ticket: ArgumentSchema
1543
+ }),
1544
+ $Intent
1545
+ });
1546
+ var ObjectArgSchema = safeEnum({
1547
+ ImmOrOwnedObject: ObjectRefSchema,
1548
+ SharedObject: object({
1549
+ objectId: ObjectID,
1550
+ initialSharedVersion: JsonU64,
1551
+ mutable: boolean()
1552
+ }),
1553
+ Receiving: ObjectRefSchema
1554
+ });
1555
+ var ReservationSchema = safeEnum({ MaxAmountU64: JsonU64 });
1556
+ var WithdrawalTypeArgSchema = safeEnum({ Balance: string() });
1557
+ var WithdrawFromSchema = safeEnum({
1558
+ Sender: literal(true),
1559
+ Sponsor: literal(true)
1560
+ });
1561
+ var FundsWithdrawalArgSchema = object({
1562
+ reservation: ReservationSchema,
1563
+ typeArg: WithdrawalTypeArgSchema,
1564
+ withdrawFrom: WithdrawFromSchema
1565
+ });
1566
+ var CallArgSchema = safeEnum({
1567
+ Object: ObjectArgSchema,
1568
+ Pure: object({ bytes: BCSBytes }),
1569
+ UnresolvedPure: object({ value: unknown() }),
1570
+ UnresolvedObject: object({
1571
+ objectId: ObjectID,
1572
+ version: optional(nullable(JsonU64)),
1573
+ digest: optional(nullable(string())),
1574
+ initialSharedVersion: optional(nullable(JsonU64)),
1575
+ mutable: optional(nullable(boolean()))
1576
+ }),
1577
+ FundsWithdrawal: FundsWithdrawalArgSchema
1578
+ });
1579
+ var NormalizedCallArg = safeEnum({
1580
+ Object: ObjectArgSchema,
1581
+ Pure: object({ bytes: BCSBytes })
1582
+ });
1583
+ var ValidDuringSchema = object({
1584
+ minEpoch: nullable(JsonU64),
1585
+ maxEpoch: nullable(JsonU64),
1586
+ minTimestamp: nullable(JsonU64),
1587
+ maxTimestamp: nullable(JsonU64),
1588
+ chain: string(),
1589
+ nonce: U32
1590
+ });
1591
+ var TransactionExpiration2 = safeEnum({
1592
+ None: literal(true),
1593
+ Epoch: JsonU64,
1594
+ ValidDuring: ValidDuringSchema
1595
+ });
1596
+ var TransactionDataSchema = object({
1597
+ version: literal(2),
1598
+ sender: nullish(SuiAddress),
1599
+ expiration: nullish(TransactionExpiration2),
1600
+ gasData: GasDataSchema,
1601
+ inputs: array(CallArgSchema),
1602
+ commands: array(CommandSchema)
1603
+ });
1604
+
1605
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/data/v1.mjs
1606
+ init_type_tag_serializer();
1607
+ init_dist2();
1608
+ var ObjectRef = object({
1609
+ digest: string(),
1610
+ objectId: string(),
1611
+ version: union([
1612
+ pipe(number(), integer()),
1613
+ string(),
1614
+ bigint()
1615
+ ])
1616
+ });
1617
+ var ObjectArg2 = safeEnum({
1618
+ ImmOrOwned: ObjectRef,
1619
+ Shared: object({
1620
+ objectId: ObjectID,
1621
+ initialSharedVersion: JsonU64,
1622
+ mutable: boolean()
1623
+ }),
1624
+ Receiving: ObjectRef
1625
+ });
1626
+ var NormalizedCallArg2 = safeEnum({
1627
+ Object: ObjectArg2,
1628
+ Pure: array(pipe(number(), integer()))
1629
+ });
1630
+ var TransactionInput = union([object({
1631
+ kind: literal("Input"),
1632
+ index: pipe(number(), integer()),
1633
+ value: unknown(),
1634
+ type: optional(literal("object"))
1635
+ }), object({
1636
+ kind: literal("Input"),
1637
+ index: pipe(number(), integer()),
1638
+ value: unknown(),
1639
+ type: literal("pure")
1640
+ })]);
1641
+ var TransactionExpiration3 = union([object({ Epoch: pipe(number(), integer()) }), object({ None: nullable(literal(true)) })]);
1642
+ var StringEncodedBigint = pipe(union([
1643
+ number(),
1644
+ string(),
1645
+ bigint()
1646
+ ]), check((val) => {
1647
+ if (![
1648
+ "string",
1649
+ "number",
1650
+ "bigint"
1651
+ ].includes(typeof val)) return false;
1652
+ try {
1653
+ BigInt(val);
1654
+ return true;
1655
+ } catch {
1656
+ return false;
1657
+ }
1658
+ }));
1659
+ var TypeTag2 = union([
1660
+ object({ bool: nullable(literal(true)) }),
1661
+ object({ u8: nullable(literal(true)) }),
1662
+ object({ u64: nullable(literal(true)) }),
1663
+ object({ u128: nullable(literal(true)) }),
1664
+ object({ address: nullable(literal(true)) }),
1665
+ object({ signer: nullable(literal(true)) }),
1666
+ object({ vector: lazy(() => TypeTag2) }),
1667
+ object({ struct: lazy(() => StructTag2) }),
1668
+ object({ u16: nullable(literal(true)) }),
1669
+ object({ u32: nullable(literal(true)) }),
1670
+ object({ u256: nullable(literal(true)) })
1671
+ ]);
1672
+ var StructTag2 = object({
1673
+ address: string(),
1674
+ module: string(),
1675
+ name: string(),
1676
+ typeParams: array(TypeTag2)
1677
+ });
1678
+ var GasConfig = object({
1679
+ budget: optional(StringEncodedBigint),
1680
+ price: optional(StringEncodedBigint),
1681
+ payment: optional(array(ObjectRef)),
1682
+ owner: optional(string())
1683
+ });
1684
+ var TransactionArgumentTypes = [
1685
+ TransactionInput,
1686
+ object({ kind: literal("GasCoin") }),
1687
+ object({
1688
+ kind: literal("Result"),
1689
+ index: pipe(number(), integer())
1690
+ }),
1691
+ object({
1692
+ kind: literal("NestedResult"),
1693
+ index: pipe(number(), integer()),
1694
+ resultIndex: pipe(number(), integer())
1695
+ })
1696
+ ];
1697
+ var TransactionArgument = union([...TransactionArgumentTypes]);
1698
+ var MoveCallTransaction = object({
1699
+ kind: literal("MoveCall"),
1700
+ target: pipe(string(), check((target) => target.split("::").length === 3)),
1701
+ typeArguments: array(string()),
1702
+ arguments: array(TransactionArgument)
1703
+ });
1704
+ var TransferObjectsTransaction = object({
1705
+ kind: literal("TransferObjects"),
1706
+ objects: array(TransactionArgument),
1707
+ address: TransactionArgument
1708
+ });
1709
+ var SplitCoinsTransaction = object({
1710
+ kind: literal("SplitCoins"),
1711
+ coin: TransactionArgument,
1712
+ amounts: array(TransactionArgument)
1713
+ });
1714
+ var MergeCoinsTransaction = object({
1715
+ kind: literal("MergeCoins"),
1716
+ destination: TransactionArgument,
1717
+ sources: array(TransactionArgument)
1718
+ });
1719
+ var MakeMoveVecTransaction = object({
1720
+ kind: literal("MakeMoveVec"),
1721
+ type: union([object({ Some: TypeTag2 }), object({ None: nullable(literal(true)) })]),
1722
+ objects: array(TransactionArgument)
1723
+ });
1724
+ var TransactionType = union([...[
1725
+ MoveCallTransaction,
1726
+ TransferObjectsTransaction,
1727
+ SplitCoinsTransaction,
1728
+ MergeCoinsTransaction,
1729
+ object({
1730
+ kind: literal("Publish"),
1731
+ modules: array(array(pipe(number(), integer()))),
1732
+ dependencies: array(string())
1733
+ }),
1734
+ object({
1735
+ kind: literal("Upgrade"),
1736
+ modules: array(array(pipe(number(), integer()))),
1737
+ dependencies: array(string()),
1738
+ packageId: string(),
1739
+ ticket: TransactionArgument
1740
+ }),
1741
+ MakeMoveVecTransaction
1742
+ ]]);
1743
+ var SerializedTransactionDataV1 = object({
1744
+ version: literal(1),
1745
+ sender: optional(string()),
1746
+ expiration: nullish(TransactionExpiration3),
1747
+ gasConfig: GasConfig,
1748
+ inputs: array(TransactionInput),
1749
+ transactions: array(TransactionType)
1750
+ });
1751
+ function serializeV1TransactionData(transactionData) {
1752
+ const inputs = transactionData.inputs.map((input, index) => {
1753
+ if (input.Object) return {
1754
+ kind: "Input",
1755
+ index,
1756
+ value: { Object: input.Object.ImmOrOwnedObject ? { ImmOrOwned: input.Object.ImmOrOwnedObject } : input.Object.Receiving ? { Receiving: {
1757
+ digest: input.Object.Receiving.digest,
1758
+ version: input.Object.Receiving.version,
1759
+ objectId: input.Object.Receiving.objectId
1760
+ } } : { Shared: {
1761
+ mutable: input.Object.SharedObject.mutable,
1762
+ initialSharedVersion: input.Object.SharedObject.initialSharedVersion,
1763
+ objectId: input.Object.SharedObject.objectId
1764
+ } } },
1765
+ type: "object"
1766
+ };
1767
+ if (input.Pure) return {
1768
+ kind: "Input",
1769
+ index,
1770
+ value: { Pure: Array.from(fromBase64(input.Pure.bytes)) },
1771
+ type: "pure"
1772
+ };
1773
+ if (input.UnresolvedPure) return {
1774
+ kind: "Input",
1775
+ type: "pure",
1776
+ index,
1777
+ value: input.UnresolvedPure.value
1778
+ };
1779
+ if (input.UnresolvedObject) return {
1780
+ kind: "Input",
1781
+ type: "object",
1782
+ index,
1783
+ value: input.UnresolvedObject.objectId
1784
+ };
1785
+ throw new Error("Invalid input");
1786
+ });
1787
+ return {
1788
+ version: 1,
1789
+ sender: transactionData.sender ?? void 0,
1790
+ expiration: transactionData.expiration?.$kind === "Epoch" ? { Epoch: Number(transactionData.expiration.Epoch) } : transactionData.expiration ? { None: true } : null,
1791
+ gasConfig: {
1792
+ owner: transactionData.gasData.owner ?? void 0,
1793
+ budget: transactionData.gasData.budget ?? void 0,
1794
+ price: transactionData.gasData.price ?? void 0,
1795
+ payment: transactionData.gasData.payment ?? void 0
1796
+ },
1797
+ inputs,
1798
+ transactions: transactionData.commands.map((command) => {
1799
+ if (command.MakeMoveVec) return {
1800
+ kind: "MakeMoveVec",
1801
+ type: command.MakeMoveVec.type === null ? { None: true } : { Some: TypeTagSerializer.parseFromStr(command.MakeMoveVec.type) },
1802
+ objects: command.MakeMoveVec.elements.map((arg) => convertTransactionArgument(arg, inputs))
1803
+ };
1804
+ if (command.MergeCoins) return {
1805
+ kind: "MergeCoins",
1806
+ destination: convertTransactionArgument(command.MergeCoins.destination, inputs),
1807
+ sources: command.MergeCoins.sources.map((arg) => convertTransactionArgument(arg, inputs))
1808
+ };
1809
+ if (command.MoveCall) return {
1810
+ kind: "MoveCall",
1811
+ target: `${command.MoveCall.package}::${command.MoveCall.module}::${command.MoveCall.function}`,
1812
+ typeArguments: command.MoveCall.typeArguments,
1813
+ arguments: command.MoveCall.arguments.map((arg) => convertTransactionArgument(arg, inputs))
1814
+ };
1815
+ if (command.Publish) return {
1816
+ kind: "Publish",
1817
+ modules: command.Publish.modules.map((mod) => Array.from(fromBase64(mod))),
1818
+ dependencies: command.Publish.dependencies
1819
+ };
1820
+ if (command.SplitCoins) return {
1821
+ kind: "SplitCoins",
1822
+ coin: convertTransactionArgument(command.SplitCoins.coin, inputs),
1823
+ amounts: command.SplitCoins.amounts.map((arg) => convertTransactionArgument(arg, inputs))
1824
+ };
1825
+ if (command.TransferObjects) return {
1826
+ kind: "TransferObjects",
1827
+ objects: command.TransferObjects.objects.map((arg) => convertTransactionArgument(arg, inputs)),
1828
+ address: convertTransactionArgument(command.TransferObjects.address, inputs)
1829
+ };
1830
+ if (command.Upgrade) return {
1831
+ kind: "Upgrade",
1832
+ modules: command.Upgrade.modules.map((mod) => Array.from(fromBase64(mod))),
1833
+ dependencies: command.Upgrade.dependencies,
1834
+ packageId: command.Upgrade.package,
1835
+ ticket: convertTransactionArgument(command.Upgrade.ticket, inputs)
1836
+ };
1837
+ throw new Error(`Unknown transaction ${Object.keys(command)}`);
1838
+ })
1839
+ };
1840
+ }
1841
+ function convertTransactionArgument(arg, inputs) {
1842
+ if (arg.$kind === "GasCoin") return { kind: "GasCoin" };
1843
+ if (arg.$kind === "Result") return {
1844
+ kind: "Result",
1845
+ index: arg.Result
1846
+ };
1847
+ if (arg.$kind === "NestedResult") return {
1848
+ kind: "NestedResult",
1849
+ index: arg.NestedResult[0],
1850
+ resultIndex: arg.NestedResult[1]
1851
+ };
1852
+ if (arg.$kind === "Input") return inputs[arg.Input];
1853
+ throw new Error(`Invalid argument ${Object.keys(arg)}`);
1854
+ }
1855
+ function transactionDataFromV1(data) {
1856
+ return parse(TransactionDataSchema, {
1857
+ version: 2,
1858
+ sender: data.sender ?? null,
1859
+ expiration: data.expiration ? "Epoch" in data.expiration ? { Epoch: data.expiration.Epoch } : { None: true } : null,
1860
+ gasData: {
1861
+ owner: data.gasConfig.owner ?? null,
1862
+ budget: data.gasConfig.budget?.toString() ?? null,
1863
+ price: data.gasConfig.price?.toString() ?? null,
1864
+ payment: data.gasConfig.payment?.map((ref) => ({
1865
+ digest: ref.digest,
1866
+ objectId: ref.objectId,
1867
+ version: ref.version.toString()
1868
+ })) ?? null
1869
+ },
1870
+ inputs: data.inputs.map((input) => {
1871
+ if (input.kind === "Input") {
1872
+ if (is(NormalizedCallArg2, input.value)) {
1873
+ const value = parse(NormalizedCallArg2, input.value);
1874
+ if (value.Object) {
1875
+ if (value.Object.ImmOrOwned) return { Object: { ImmOrOwnedObject: {
1876
+ objectId: value.Object.ImmOrOwned.objectId,
1877
+ version: String(value.Object.ImmOrOwned.version),
1878
+ digest: value.Object.ImmOrOwned.digest
1879
+ } } };
1880
+ if (value.Object.Shared) return { Object: { SharedObject: {
1881
+ mutable: value.Object.Shared.mutable ?? null,
1882
+ initialSharedVersion: value.Object.Shared.initialSharedVersion,
1883
+ objectId: value.Object.Shared.objectId
1884
+ } } };
1885
+ if (value.Object.Receiving) return { Object: { Receiving: {
1886
+ digest: value.Object.Receiving.digest,
1887
+ version: String(value.Object.Receiving.version),
1888
+ objectId: value.Object.Receiving.objectId
1889
+ } } };
1890
+ throw new Error("Invalid object input");
1891
+ }
1892
+ return { Pure: { bytes: toBase64(new Uint8Array(value.Pure)) } };
1893
+ }
1894
+ if (input.type === "object") return { UnresolvedObject: { objectId: input.value } };
1895
+ return { UnresolvedPure: { value: input.value } };
1896
+ }
1897
+ throw new Error("Invalid input");
1898
+ }),
1899
+ commands: data.transactions.map((transaction) => {
1900
+ switch (transaction.kind) {
1901
+ case "MakeMoveVec":
1902
+ return { MakeMoveVec: {
1903
+ type: "Some" in transaction.type ? TypeTagSerializer.tagToString(transaction.type.Some) : null,
1904
+ elements: transaction.objects.map((arg) => parseV1TransactionArgument(arg))
1905
+ } };
1906
+ case "MergeCoins":
1907
+ return { MergeCoins: {
1908
+ destination: parseV1TransactionArgument(transaction.destination),
1909
+ sources: transaction.sources.map((arg) => parseV1TransactionArgument(arg))
1910
+ } };
1911
+ case "MoveCall": {
1912
+ const [pkg, mod, fn] = transaction.target.split("::");
1913
+ return { MoveCall: {
1914
+ package: pkg,
1915
+ module: mod,
1916
+ function: fn,
1917
+ typeArguments: transaction.typeArguments,
1918
+ arguments: transaction.arguments.map((arg) => parseV1TransactionArgument(arg))
1919
+ } };
1920
+ }
1921
+ case "Publish":
1922
+ return { Publish: {
1923
+ modules: transaction.modules.map((mod) => toBase64(Uint8Array.from(mod))),
1924
+ dependencies: transaction.dependencies
1925
+ } };
1926
+ case "SplitCoins":
1927
+ return { SplitCoins: {
1928
+ coin: parseV1TransactionArgument(transaction.coin),
1929
+ amounts: transaction.amounts.map((arg) => parseV1TransactionArgument(arg))
1930
+ } };
1931
+ case "TransferObjects":
1932
+ return { TransferObjects: {
1933
+ objects: transaction.objects.map((arg) => parseV1TransactionArgument(arg)),
1934
+ address: parseV1TransactionArgument(transaction.address)
1935
+ } };
1936
+ case "Upgrade":
1937
+ return { Upgrade: {
1938
+ modules: transaction.modules.map((mod) => toBase64(Uint8Array.from(mod))),
1939
+ dependencies: transaction.dependencies,
1940
+ package: transaction.packageId,
1941
+ ticket: parseV1TransactionArgument(transaction.ticket)
1942
+ } };
1943
+ }
1944
+ throw new Error(`Unknown transaction ${Object.keys(transaction)}`);
1945
+ })
1946
+ });
1947
+ }
1948
+ function parseV1TransactionArgument(arg) {
1949
+ switch (arg.kind) {
1950
+ case "GasCoin":
1951
+ return { GasCoin: true };
1952
+ case "Result":
1953
+ return { Result: arg.index };
1954
+ case "NestedResult":
1955
+ return { NestedResult: [arg.index, arg.resultIndex] };
1956
+ case "Input":
1957
+ return { Input: arg.index };
1958
+ }
1959
+ }
1960
+
1961
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/utils.mjs
1962
+ init_sui_types();
1963
+ function getIdFromCallArg(arg) {
1964
+ if (typeof arg === "string") return normalizeSuiAddress(arg);
1965
+ if (arg.Object) {
1966
+ if (arg.Object.ImmOrOwnedObject) return normalizeSuiAddress(arg.Object.ImmOrOwnedObject.objectId);
1967
+ if (arg.Object.Receiving) return normalizeSuiAddress(arg.Object.Receiving.objectId);
1968
+ return normalizeSuiAddress(arg.Object.SharedObject.objectId);
1969
+ }
1970
+ if (arg.UnresolvedObject) return normalizeSuiAddress(arg.UnresolvedObject.objectId);
1971
+ }
1972
+ function remapCommandArguments(command, inputMapping, commandMapping) {
1973
+ const remapArg = (arg) => {
1974
+ switch (arg.$kind) {
1975
+ case "Input": {
1976
+ const newInputIndex = inputMapping.get(arg.Input);
1977
+ if (newInputIndex === void 0) throw new Error(`Input ${arg.Input} not found in input mapping`);
1978
+ return {
1979
+ ...arg,
1980
+ Input: newInputIndex
1981
+ };
1982
+ }
1983
+ case "Result": {
1984
+ const newCommandIndex = commandMapping.get(arg.Result);
1985
+ if (newCommandIndex !== void 0) return {
1986
+ ...arg,
1987
+ Result: newCommandIndex
1988
+ };
1989
+ return arg;
1990
+ }
1991
+ case "NestedResult": {
1992
+ const newCommandIndex = commandMapping.get(arg.NestedResult[0]);
1993
+ if (newCommandIndex !== void 0) return {
1994
+ ...arg,
1995
+ NestedResult: [newCommandIndex, arg.NestedResult[1]]
1996
+ };
1997
+ return arg;
1998
+ }
1999
+ default:
2000
+ return arg;
2001
+ }
2002
+ };
2003
+ switch (command.$kind) {
2004
+ case "MoveCall":
2005
+ command.MoveCall.arguments = command.MoveCall.arguments.map(remapArg);
2006
+ break;
2007
+ case "TransferObjects":
2008
+ command.TransferObjects.objects = command.TransferObjects.objects.map(remapArg);
2009
+ command.TransferObjects.address = remapArg(command.TransferObjects.address);
2010
+ break;
2011
+ case "SplitCoins":
2012
+ command.SplitCoins.coin = remapArg(command.SplitCoins.coin);
2013
+ command.SplitCoins.amounts = command.SplitCoins.amounts.map(remapArg);
2014
+ break;
2015
+ case "MergeCoins":
2016
+ command.MergeCoins.destination = remapArg(command.MergeCoins.destination);
2017
+ command.MergeCoins.sources = command.MergeCoins.sources.map(remapArg);
2018
+ break;
2019
+ case "MakeMoveVec":
2020
+ command.MakeMoveVec.elements = command.MakeMoveVec.elements.map(remapArg);
2021
+ break;
2022
+ case "Upgrade":
2023
+ command.Upgrade.ticket = remapArg(command.Upgrade.ticket);
2024
+ break;
2025
+ case "$Intent": {
2026
+ const inputs = command.$Intent.inputs;
2027
+ command.$Intent.inputs = {};
2028
+ for (const [key, value] of Object.entries(inputs)) command.$Intent.inputs[key] = Array.isArray(value) ? value.map(remapArg) : remapArg(value);
2029
+ break;
2030
+ }
2031
+ case "Publish":
2032
+ break;
2033
+ }
2034
+ }
2035
+
2036
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/TransactionData.mjs
2037
+ init_sui_types();
2038
+ init_bcs2();
2039
+
2040
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/hash.mjs
2041
+ init_blake2();
2042
+ function hashTypedData(typeTag, data) {
2043
+ const typeTagBytes = Array.from(`${typeTag}::`).map((e) => e.charCodeAt(0));
2044
+ const dataWithTag = new Uint8Array(typeTagBytes.length + data.length);
2045
+ dataWithTag.set(typeTagBytes);
2046
+ dataWithTag.set(data, typeTagBytes.length);
2047
+ return blake2b(dataWithTag, { dkLen: 32 });
2048
+ }
2049
+
2050
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/TransactionData.mjs
2051
+ init_dist2();
2052
+ function prepareSuiAddress(address) {
2053
+ return normalizeSuiAddress(address).replace("0x", "");
2054
+ }
2055
+ var TransactionDataBuilder = class TransactionDataBuilder2 {
2056
+ static fromKindBytes(bytes) {
2057
+ const programmableTx = suiBcs.TransactionKind.parse(bytes).ProgrammableTransaction;
2058
+ if (!programmableTx) throw new Error("Unable to deserialize from bytes.");
2059
+ return TransactionDataBuilder2.restore({
2060
+ version: 2,
2061
+ sender: null,
2062
+ expiration: null,
2063
+ gasData: {
2064
+ budget: null,
2065
+ owner: null,
2066
+ payment: null,
2067
+ price: null
2068
+ },
2069
+ inputs: programmableTx.inputs,
2070
+ commands: programmableTx.commands
2071
+ });
2072
+ }
2073
+ static fromBytes(bytes) {
2074
+ const data = suiBcs.TransactionData.parse(bytes)?.V1;
2075
+ const programmableTx = data.kind.ProgrammableTransaction;
2076
+ if (!data || !programmableTx) throw new Error("Unable to deserialize from bytes.");
2077
+ return TransactionDataBuilder2.restore({
2078
+ version: 2,
2079
+ sender: data.sender,
2080
+ expiration: data.expiration,
2081
+ gasData: data.gasData,
2082
+ inputs: programmableTx.inputs,
2083
+ commands: programmableTx.commands
2084
+ });
2085
+ }
2086
+ static restore(data) {
2087
+ if (data.version === 2) return new TransactionDataBuilder2(parse(TransactionDataSchema, data));
2088
+ else return new TransactionDataBuilder2(parse(TransactionDataSchema, transactionDataFromV1(data)));
2089
+ }
2090
+ /**
2091
+ * Generate transaction digest.
2092
+ *
2093
+ * @param bytes BCS serialized transaction data
2094
+ * @returns transaction digest.
2095
+ */
2096
+ static getDigestFromBytes(bytes) {
2097
+ return toBase58(hashTypedData("TransactionData", bytes));
2098
+ }
2099
+ constructor(clone) {
2100
+ this.version = 2;
2101
+ this.sender = clone?.sender ?? null;
2102
+ this.expiration = clone?.expiration ?? null;
2103
+ this.inputs = clone?.inputs ?? [];
2104
+ this.commands = clone?.commands ?? [];
2105
+ this.gasData = clone?.gasData ?? {
2106
+ budget: null,
2107
+ price: null,
2108
+ owner: null,
2109
+ payment: null
2110
+ };
2111
+ }
2112
+ build({ maxSizeBytes = Infinity, overrides, onlyTransactionKind } = {}) {
2113
+ const inputs = this.inputs;
2114
+ const commands = this.commands;
2115
+ const kind = { ProgrammableTransaction: {
2116
+ inputs,
2117
+ commands
2118
+ } };
2119
+ if (onlyTransactionKind) return suiBcs.TransactionKind.serialize(kind, { maxSize: maxSizeBytes }).toBytes();
2120
+ const expiration = overrides?.expiration ?? this.expiration;
2121
+ const sender = overrides?.sender ?? this.sender;
2122
+ const gasData = {
2123
+ ...this.gasData,
2124
+ ...overrides?.gasData
2125
+ };
2126
+ if (!sender) throw new Error("Missing transaction sender");
2127
+ if (!gasData.budget) throw new Error("Missing gas budget");
2128
+ if (!gasData.payment) throw new Error("Missing gas payment");
2129
+ if (!gasData.price) throw new Error("Missing gas price");
2130
+ const transactionData = {
2131
+ sender: prepareSuiAddress(sender),
2132
+ expiration: expiration ? expiration : { None: true },
2133
+ gasData: {
2134
+ payment: gasData.payment,
2135
+ owner: prepareSuiAddress(this.gasData.owner ?? sender),
2136
+ price: BigInt(gasData.price),
2137
+ budget: BigInt(gasData.budget)
2138
+ },
2139
+ kind: { ProgrammableTransaction: {
2140
+ inputs,
2141
+ commands
2142
+ } }
2143
+ };
2144
+ return suiBcs.TransactionData.serialize({ V1: transactionData }, { maxSize: maxSizeBytes }).toBytes();
2145
+ }
2146
+ addInput(type, arg) {
2147
+ const index = this.inputs.length;
2148
+ this.inputs.push(arg);
2149
+ return {
2150
+ Input: index,
2151
+ type,
2152
+ $kind: "Input"
2153
+ };
2154
+ }
2155
+ getInputUses(index, fn) {
2156
+ this.mapArguments((arg, command) => {
2157
+ if (arg.$kind === "Input" && arg.Input === index) fn(arg, command);
2158
+ return arg;
2159
+ });
2160
+ }
2161
+ mapCommandArguments(index, fn) {
2162
+ const command = this.commands[index];
2163
+ switch (command.$kind) {
2164
+ case "MoveCall":
2165
+ command.MoveCall.arguments = command.MoveCall.arguments.map((arg) => fn(arg, command, index));
2166
+ break;
2167
+ case "TransferObjects":
2168
+ command.TransferObjects.objects = command.TransferObjects.objects.map((arg) => fn(arg, command, index));
2169
+ command.TransferObjects.address = fn(command.TransferObjects.address, command, index);
2170
+ break;
2171
+ case "SplitCoins":
2172
+ command.SplitCoins.coin = fn(command.SplitCoins.coin, command, index);
2173
+ command.SplitCoins.amounts = command.SplitCoins.amounts.map((arg) => fn(arg, command, index));
2174
+ break;
2175
+ case "MergeCoins":
2176
+ command.MergeCoins.destination = fn(command.MergeCoins.destination, command, index);
2177
+ command.MergeCoins.sources = command.MergeCoins.sources.map((arg) => fn(arg, command, index));
2178
+ break;
2179
+ case "MakeMoveVec":
2180
+ command.MakeMoveVec.elements = command.MakeMoveVec.elements.map((arg) => fn(arg, command, index));
2181
+ break;
2182
+ case "Upgrade":
2183
+ command.Upgrade.ticket = fn(command.Upgrade.ticket, command, index);
2184
+ break;
2185
+ case "$Intent":
2186
+ const inputs = command.$Intent.inputs;
2187
+ command.$Intent.inputs = {};
2188
+ for (const [key, value] of Object.entries(inputs)) command.$Intent.inputs[key] = Array.isArray(value) ? value.map((arg) => fn(arg, command, index)) : fn(value, command, index);
2189
+ break;
2190
+ case "Publish":
2191
+ break;
2192
+ default:
2193
+ throw new Error(`Unexpected transaction kind: ${command.$kind}`);
2194
+ }
2195
+ }
2196
+ mapArguments(fn) {
2197
+ for (const commandIndex of this.commands.keys()) this.mapCommandArguments(commandIndex, fn);
2198
+ }
2199
+ replaceCommand(index, replacement, resultIndex = index) {
2200
+ if (!Array.isArray(replacement)) {
2201
+ this.commands[index] = replacement;
2202
+ return;
2203
+ }
2204
+ const sizeDiff = replacement.length - 1;
2205
+ this.commands.splice(index, 1, ...structuredClone(replacement));
2206
+ this.mapArguments((arg, _command, commandIndex) => {
2207
+ if (commandIndex < index + replacement.length) return arg;
2208
+ if (typeof resultIndex !== "number") {
2209
+ if (arg.$kind === "Result" && arg.Result === index || arg.$kind === "NestedResult" && arg.NestedResult[0] === index) if (!("NestedResult" in arg) || arg.NestedResult[1] === 0) return parse(ArgumentSchema, structuredClone(resultIndex));
2210
+ else throw new Error(`Cannot replace command ${index} with a specific result type: NestedResult[${index}, ${arg.NestedResult[1]}] references a nested element that cannot be mapped to the replacement result`);
2211
+ }
2212
+ switch (arg.$kind) {
2213
+ case "Result":
2214
+ if (arg.Result === index && typeof resultIndex === "number") arg.Result = resultIndex;
2215
+ if (arg.Result > index) arg.Result += sizeDiff;
2216
+ break;
2217
+ case "NestedResult":
2218
+ if (arg.NestedResult[0] === index && typeof resultIndex === "number") return {
2219
+ $kind: "NestedResult",
2220
+ NestedResult: [resultIndex, arg.NestedResult[1]]
2221
+ };
2222
+ if (arg.NestedResult[0] > index) arg.NestedResult[0] += sizeDiff;
2223
+ break;
2224
+ }
2225
+ return arg;
2226
+ });
2227
+ }
2228
+ replaceCommandWithTransaction(index, otherTransaction, result) {
2229
+ if (result.$kind !== "Result" && result.$kind !== "NestedResult") throw new Error("Result must be of kind Result or NestedResult");
2230
+ this.insertTransaction(index, otherTransaction);
2231
+ this.replaceCommand(index + otherTransaction.commands.length, [], "Result" in result ? { NestedResult: [result.Result + index, 0] } : { NestedResult: [result.NestedResult[0] + index, result.NestedResult[1]] });
2232
+ }
2233
+ insertTransaction(atCommandIndex, otherTransaction) {
2234
+ const inputMapping = /* @__PURE__ */ new Map();
2235
+ const commandMapping = /* @__PURE__ */ new Map();
2236
+ for (let i = 0; i < otherTransaction.inputs.length; i++) {
2237
+ const otherInput = otherTransaction.inputs[i];
2238
+ const id = getIdFromCallArg(otherInput);
2239
+ let existingIndex = -1;
2240
+ if (id !== void 0) {
2241
+ existingIndex = this.inputs.findIndex((input) => getIdFromCallArg(input) === id);
2242
+ if (existingIndex !== -1 && this.inputs[existingIndex].Object?.SharedObject && otherInput.Object?.SharedObject) this.inputs[existingIndex].Object.SharedObject.mutable = this.inputs[existingIndex].Object.SharedObject.mutable || otherInput.Object.SharedObject.mutable;
2243
+ }
2244
+ if (existingIndex !== -1) inputMapping.set(i, existingIndex);
2245
+ else {
2246
+ const newIndex = this.inputs.length;
2247
+ this.inputs.push(otherInput);
2248
+ inputMapping.set(i, newIndex);
2249
+ }
2250
+ }
2251
+ for (let i = 0; i < otherTransaction.commands.length; i++) commandMapping.set(i, atCommandIndex + i);
2252
+ const remappedCommands = [];
2253
+ for (let i = 0; i < otherTransaction.commands.length; i++) {
2254
+ const command = structuredClone(otherTransaction.commands[i]);
2255
+ remapCommandArguments(command, inputMapping, commandMapping);
2256
+ remappedCommands.push(command);
2257
+ }
2258
+ this.commands.splice(atCommandIndex, 0, ...remappedCommands);
2259
+ const sizeDiff = remappedCommands.length;
2260
+ if (sizeDiff > 0) this.mapArguments((arg, _command, commandIndex) => {
2261
+ if (commandIndex >= atCommandIndex && commandIndex < atCommandIndex + remappedCommands.length) return arg;
2262
+ switch (arg.$kind) {
2263
+ case "Result":
2264
+ if (arg.Result >= atCommandIndex) arg.Result += sizeDiff;
2265
+ break;
2266
+ case "NestedResult":
2267
+ if (arg.NestedResult[0] >= atCommandIndex) arg.NestedResult[0] += sizeDiff;
2268
+ break;
2269
+ }
2270
+ return arg;
2271
+ });
2272
+ }
2273
+ getDigest() {
2274
+ const bytes = this.build({ onlyTransactionKind: false });
2275
+ return TransactionDataBuilder2.getDigestFromBytes(bytes);
2276
+ }
2277
+ snapshot() {
2278
+ return parse(TransactionDataSchema, this);
2279
+ }
2280
+ shallowClone() {
2281
+ return new TransactionDataBuilder2({
2282
+ version: this.version,
2283
+ sender: this.sender,
2284
+ expiration: this.expiration,
2285
+ gasData: { ...this.gasData },
2286
+ inputs: [...this.inputs],
2287
+ commands: [...this.commands]
2288
+ });
2289
+ }
2290
+ applyResolvedData(resolved) {
2291
+ if (!this.sender) this.sender = resolved.sender ?? null;
2292
+ if (!this.expiration) this.expiration = resolved.expiration ?? null;
2293
+ if (!this.gasData.budget) this.gasData.budget = resolved.gasData.budget;
2294
+ if (!this.gasData.owner) this.gasData.owner = resolved.gasData.owner ?? null;
2295
+ if (!this.gasData.payment) this.gasData.payment = resolved.gasData.payment;
2296
+ if (!this.gasData.price) this.gasData.price = resolved.gasData.price;
2297
+ for (let i = 0; i < this.inputs.length; i++) {
2298
+ const input = this.inputs[i];
2299
+ const resolvedInput = resolved.inputs[i];
2300
+ switch (input.$kind) {
2301
+ case "UnresolvedPure":
2302
+ if (resolvedInput.$kind !== "Pure") throw new Error(`Expected input at index ${i} to resolve to a Pure argument, but got ${JSON.stringify(resolvedInput)}`);
2303
+ this.inputs[i] = resolvedInput;
2304
+ break;
2305
+ case "UnresolvedObject":
2306
+ if (resolvedInput.$kind !== "Object") throw new Error(`Expected input at index ${i} to resolve to an Object argument, but got ${JSON.stringify(resolvedInput)}`);
2307
+ if (resolvedInput.Object.$kind === "ImmOrOwnedObject" || resolvedInput.Object.$kind === "Receiving") {
2308
+ const original = input.UnresolvedObject;
2309
+ const resolved$1 = resolvedInput.Object.ImmOrOwnedObject ?? resolvedInput.Object.Receiving;
2310
+ if (normalizeSuiAddress(original.objectId) !== normalizeSuiAddress(resolved$1.objectId) || original.version != null && original.version !== resolved$1.version || original.digest != null && original.digest !== resolved$1.digest || original.mutable != null || original.initialSharedVersion != null) throw new Error(`Input at index ${i} did not match unresolved object. ${JSON.stringify(original)} is not compatible with ${JSON.stringify(resolved$1)}`);
2311
+ } else if (resolvedInput.Object.$kind === "SharedObject") {
2312
+ const original = input.UnresolvedObject;
2313
+ const resolved$1 = resolvedInput.Object.SharedObject;
2314
+ if (normalizeSuiAddress(original.objectId) !== normalizeSuiAddress(resolved$1.objectId) || original.initialSharedVersion != null && original.initialSharedVersion !== resolved$1.initialSharedVersion || original.mutable != null && original.mutable !== resolved$1.mutable || original.version != null || original.digest != null) throw new Error(`Input at index ${i} did not match unresolved object. ${JSON.stringify(original)} is not compatible with ${JSON.stringify(resolved$1)}`);
2315
+ } else throw new Error(`Input at index ${i} resolved to an unexpected Object kind: ${JSON.stringify(resolvedInput.Object)}`);
2316
+ this.inputs[i] = resolvedInput;
2317
+ break;
2318
+ }
2319
+ }
2320
+ }
2321
+ };
2322
+
2323
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/Commands.mjs
2324
+ init_sui_types();
2325
+ init_dist2();
2326
+ var TransactionCommands = {
2327
+ MoveCall(input) {
2328
+ const [pkg, mod = "", fn = ""] = "target" in input ? input.target.split("::") : [
2329
+ input.package,
2330
+ input.module,
2331
+ input.function
2332
+ ];
2333
+ return {
2334
+ $kind: "MoveCall",
2335
+ MoveCall: {
2336
+ package: pkg,
2337
+ module: mod,
2338
+ function: fn,
2339
+ typeArguments: input.typeArguments ?? [],
2340
+ arguments: input.arguments ?? []
2341
+ }
2342
+ };
2343
+ },
2344
+ TransferObjects(objects, address) {
2345
+ return {
2346
+ $kind: "TransferObjects",
2347
+ TransferObjects: {
2348
+ objects: objects.map((o) => parse(ArgumentSchema, o)),
2349
+ address: parse(ArgumentSchema, address)
2350
+ }
2351
+ };
2352
+ },
2353
+ SplitCoins(coin, amounts) {
2354
+ return {
2355
+ $kind: "SplitCoins",
2356
+ SplitCoins: {
2357
+ coin: parse(ArgumentSchema, coin),
2358
+ amounts: amounts.map((o) => parse(ArgumentSchema, o))
2359
+ }
2360
+ };
2361
+ },
2362
+ MergeCoins(destination, sources) {
2363
+ return {
2364
+ $kind: "MergeCoins",
2365
+ MergeCoins: {
2366
+ destination: parse(ArgumentSchema, destination),
2367
+ sources: sources.map((o) => parse(ArgumentSchema, o))
2368
+ }
2369
+ };
2370
+ },
2371
+ Publish({ modules, dependencies }) {
2372
+ return {
2373
+ $kind: "Publish",
2374
+ Publish: {
2375
+ modules: modules.map((module) => typeof module === "string" ? module : toBase64(new Uint8Array(module))),
2376
+ dependencies: dependencies.map((dep) => normalizeSuiObjectId(dep))
2377
+ }
2378
+ };
2379
+ },
2380
+ Upgrade({ modules, dependencies, package: packageId, ticket }) {
2381
+ return {
2382
+ $kind: "Upgrade",
2383
+ Upgrade: {
2384
+ modules: modules.map((module) => typeof module === "string" ? module : toBase64(new Uint8Array(module))),
2385
+ dependencies: dependencies.map((dep) => normalizeSuiObjectId(dep)),
2386
+ package: packageId,
2387
+ ticket: parse(ArgumentSchema, ticket)
2388
+ }
2389
+ };
2390
+ },
2391
+ MakeMoveVec({ type, elements }) {
2392
+ return {
2393
+ $kind: "MakeMoveVec",
2394
+ MakeMoveVec: {
2395
+ type: type ?? null,
2396
+ elements: elements.map((o) => parse(ArgumentSchema, o))
2397
+ }
2398
+ };
2399
+ },
2400
+ Intent({ name, inputs = {}, data = {} }) {
2401
+ return {
2402
+ $kind: "$Intent",
2403
+ $Intent: {
2404
+ name,
2405
+ inputs: Object.fromEntries(Object.entries(inputs).map(([key, value]) => [key, Array.isArray(value) ? value.map((o) => parse(ArgumentSchema, o)) : parse(ArgumentSchema, value)])),
2406
+ data
2407
+ }
2408
+ };
2409
+ }
2410
+ };
2411
+
2412
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/data/v2.mjs
2413
+ function enumUnion(options) {
2414
+ return union(Object.entries(options).map(([key, value]) => object({ [key]: value })));
2415
+ }
2416
+ var Argument2 = enumUnion({
2417
+ GasCoin: literal(true),
2418
+ Input: pipe(number(), integer()),
2419
+ Result: pipe(number(), integer()),
2420
+ NestedResult: tuple([pipe(number(), integer()), pipe(number(), integer())])
2421
+ });
2422
+ var GasData2 = object({
2423
+ budget: nullable(JsonU64),
2424
+ price: nullable(JsonU64),
2425
+ owner: nullable(SuiAddress),
2426
+ payment: nullable(array(ObjectRefSchema))
2427
+ });
2428
+ var ProgrammableMoveCall2 = object({
2429
+ package: ObjectID,
2430
+ module: string(),
2431
+ function: string(),
2432
+ typeArguments: array(string()),
2433
+ arguments: array(Argument2)
2434
+ });
2435
+ var $Intent2 = object({
2436
+ name: string(),
2437
+ inputs: record(string(), union([Argument2, array(Argument2)])),
2438
+ data: record(string(), unknown())
2439
+ });
2440
+ var Command2 = enumUnion({
2441
+ MoveCall: ProgrammableMoveCall2,
2442
+ TransferObjects: object({
2443
+ objects: array(Argument2),
2444
+ address: Argument2
2445
+ }),
2446
+ SplitCoins: object({
2447
+ coin: Argument2,
2448
+ amounts: array(Argument2)
2449
+ }),
2450
+ MergeCoins: object({
2451
+ destination: Argument2,
2452
+ sources: array(Argument2)
2453
+ }),
2454
+ Publish: object({
2455
+ modules: array(BCSBytes),
2456
+ dependencies: array(ObjectID)
2457
+ }),
2458
+ MakeMoveVec: object({
2459
+ type: nullable(string()),
2460
+ elements: array(Argument2)
2461
+ }),
2462
+ Upgrade: object({
2463
+ modules: array(BCSBytes),
2464
+ dependencies: array(ObjectID),
2465
+ package: ObjectID,
2466
+ ticket: Argument2
2467
+ }),
2468
+ $Intent: $Intent2
2469
+ });
2470
+ var CallArg2 = enumUnion({
2471
+ Object: enumUnion({
2472
+ ImmOrOwnedObject: ObjectRefSchema,
2473
+ SharedObject: object({
2474
+ objectId: ObjectID,
2475
+ initialSharedVersion: JsonU64,
2476
+ mutable: boolean()
2477
+ }),
2478
+ Receiving: ObjectRefSchema
2479
+ }),
2480
+ Pure: object({ bytes: BCSBytes }),
2481
+ UnresolvedPure: object({ value: unknown() }),
2482
+ UnresolvedObject: object({
2483
+ objectId: ObjectID,
2484
+ version: optional(nullable(JsonU64)),
2485
+ digest: optional(nullable(string())),
2486
+ initialSharedVersion: optional(nullable(JsonU64)),
2487
+ mutable: optional(nullable(boolean()))
2488
+ }),
2489
+ FundsWithdrawal: FundsWithdrawalArgSchema
2490
+ });
2491
+ var TransactionExpiration4 = enumUnion({
2492
+ None: literal(true),
2493
+ Epoch: JsonU64,
2494
+ ValidDuring: ValidDuringSchema
2495
+ });
2496
+ var SerializedTransactionDataV2Schema = object({
2497
+ version: literal(2),
2498
+ sender: nullish(SuiAddress),
2499
+ expiration: nullish(TransactionExpiration4),
2500
+ gasData: GasData2,
2501
+ inputs: array(CallArg2),
2502
+ commands: array(Command2),
2503
+ digest: optional(nullable(string()))
2504
+ });
2505
+
2506
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/Inputs.mjs
2507
+ init_sui_types();
2508
+ init_dist2();
2509
+ function Pure(data) {
2510
+ return {
2511
+ $kind: "Pure",
2512
+ Pure: { bytes: data instanceof Uint8Array ? toBase64(data) : data.toBase64() }
2513
+ };
2514
+ }
2515
+ var Inputs = {
2516
+ Pure,
2517
+ ObjectRef({ objectId, digest, version }) {
2518
+ return {
2519
+ $kind: "Object",
2520
+ Object: {
2521
+ $kind: "ImmOrOwnedObject",
2522
+ ImmOrOwnedObject: {
2523
+ digest,
2524
+ version,
2525
+ objectId: normalizeSuiAddress(objectId)
2526
+ }
2527
+ }
2528
+ };
2529
+ },
2530
+ SharedObjectRef({ objectId, mutable, initialSharedVersion }) {
2531
+ return {
2532
+ $kind: "Object",
2533
+ Object: {
2534
+ $kind: "SharedObject",
2535
+ SharedObject: {
2536
+ mutable,
2537
+ initialSharedVersion,
2538
+ objectId: normalizeSuiAddress(objectId)
2539
+ }
2540
+ }
2541
+ };
2542
+ },
2543
+ ReceivingRef({ objectId, digest, version }) {
2544
+ return {
2545
+ $kind: "Object",
2546
+ Object: {
2547
+ $kind: "Receiving",
2548
+ Receiving: {
2549
+ digest,
2550
+ version,
2551
+ objectId: normalizeSuiAddress(objectId)
2552
+ }
2553
+ }
2554
+ };
2555
+ },
2556
+ FundsWithdrawal({ reservation, typeArg, withdrawFrom }) {
2557
+ return {
2558
+ $kind: "FundsWithdrawal",
2559
+ FundsWithdrawal: {
2560
+ reservation,
2561
+ typeArg,
2562
+ withdrawFrom
2563
+ }
2564
+ };
2565
+ }
2566
+ };
2567
+
2568
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/resolve.mjs
2569
+ init_bcs2();
2570
+
2571
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/client/core-resolver.mjs
2572
+ init_sui_types();
2573
+
2574
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/client/errors.mjs
2575
+ var SuiClientError = class extends Error {
2576
+ };
2577
+ var SimulationError = class extends SuiClientError {
2578
+ constructor(message, options) {
2579
+ super(message, { cause: options?.cause });
2580
+ this.executionError = options?.executionError;
2581
+ }
2582
+ };
2583
+ var ObjectError = class ObjectError2 extends SuiClientError {
2584
+ constructor(code, message) {
2585
+ super(message);
2586
+ this.code = code;
2587
+ }
2588
+ static fromResponse(response, objectId) {
2589
+ switch (response.code) {
2590
+ case "notExists":
2591
+ return new ObjectError2(response.code, `Object ${response.object_id} does not exist`);
2592
+ case "dynamicFieldNotFound":
2593
+ return new ObjectError2(response.code, `Dynamic field not found for object ${response.parent_object_id}`);
2594
+ case "deleted":
2595
+ return new ObjectError2(response.code, `Object ${response.object_id} has been deleted`);
2596
+ case "displayError":
2597
+ return new ObjectError2(response.code, `Display error: ${response.error}`);
2598
+ case "unknown":
2599
+ default:
2600
+ return new ObjectError2(response.code, `Unknown error while loading object${objectId ? ` ${objectId}` : ""}`);
2601
+ }
2602
+ }
2603
+ };
2604
+
2605
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/client/core-resolver.mjs
2606
+ init_constants();
2607
+
2608
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/serializer.mjs
2609
+ init_sui_types();
2610
+ init_bcs2();
2611
+ init_constants();
2612
+ function parseTypeName(typeName) {
2613
+ const parts = typeName.split("::");
2614
+ if (parts.length !== 3) throw new Error(`Invalid type name format: ${typeName}`);
2615
+ return {
2616
+ package: parts[0],
2617
+ module: parts[1],
2618
+ name: parts[2]
2619
+ };
2620
+ }
2621
+ function isTxContext(param) {
2622
+ if (param.body.$kind !== "datatype") return false;
2623
+ const { package: pkg, module, name } = parseTypeName(param.body.datatype.typeName);
2624
+ return normalizeSuiAddress(pkg) === SUI_FRAMEWORK_ADDRESS && module === "tx_context" && name === "TxContext";
2625
+ }
2626
+ function getPureBcsSchema(typeSignature) {
2627
+ switch (typeSignature.$kind) {
2628
+ case "address":
2629
+ return suiBcs.Address;
2630
+ case "bool":
2631
+ return suiBcs.Bool;
2632
+ case "u8":
2633
+ return suiBcs.U8;
2634
+ case "u16":
2635
+ return suiBcs.U16;
2636
+ case "u32":
2637
+ return suiBcs.U32;
2638
+ case "u64":
2639
+ return suiBcs.U64;
2640
+ case "u128":
2641
+ return suiBcs.U128;
2642
+ case "u256":
2643
+ return suiBcs.U256;
2644
+ case "vector": {
2645
+ if (typeSignature.vector.$kind === "u8") return suiBcs.byteVector().transform({
2646
+ input: (val) => typeof val === "string" ? new TextEncoder().encode(val) : val,
2647
+ output: (val) => val
2648
+ });
2649
+ const type = getPureBcsSchema(typeSignature.vector);
2650
+ return type ? suiBcs.vector(type) : null;
2651
+ }
2652
+ case "datatype": {
2653
+ const { package: pkg, module, name } = parseTypeName(typeSignature.datatype.typeName);
2654
+ const normalizedPkg = normalizeSuiAddress(pkg);
2655
+ if (normalizedPkg === MOVE_STDLIB_ADDRESS) {
2656
+ if (module === "ascii" && name === "String") return suiBcs.String;
2657
+ if (module === "string" && name === "String") return suiBcs.String;
2658
+ if (module === "option" && name === "Option") {
2659
+ const type = getPureBcsSchema(typeSignature.datatype.typeParameters[0]);
2660
+ return type ? suiBcs.vector(type) : null;
2661
+ }
2662
+ }
2663
+ if (normalizedPkg === SUI_FRAMEWORK_ADDRESS) {
2664
+ if (module === "object" && name === "ID") return suiBcs.Address;
2665
+ }
2666
+ return null;
2667
+ }
2668
+ case "typeParameter":
2669
+ case "unknown":
2670
+ return null;
2671
+ }
2672
+ }
2673
+
2674
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/client/core-resolver.mjs
2675
+ init_dist();
2676
+ var MAX_OBJECTS_PER_FETCH = 50;
2677
+ var GAS_SAFE_OVERHEAD = 1000n;
2678
+ var MAX_GAS = 5e10;
2679
+ function getClient(options) {
2680
+ if (!options.client) throw new Error(`No sui client passed to Transaction#build, but transaction data was not sufficient to build offline.`);
2681
+ return options.client;
2682
+ }
2683
+ async function coreClientResolveTransactionPlugin(transactionData, options, next) {
2684
+ const client = getClient(options);
2685
+ await normalizeInputs(transactionData, client);
2686
+ await resolveObjectReferences(transactionData, client);
2687
+ if (!options.onlyTransactionKind) await setGasData(transactionData, client);
2688
+ return await next();
2689
+ }
2690
+ async function setGasData(transactionData, client) {
2691
+ let systemState = null;
2692
+ if (!transactionData.gasData.price) {
2693
+ systemState = (await client.core.getCurrentSystemState()).systemState;
2694
+ transactionData.gasData.price = systemState.referenceGasPrice;
2695
+ }
2696
+ await setGasBudget(transactionData, client);
2697
+ await setGasPayment(transactionData, client);
2698
+ if (!transactionData.expiration) await setExpiration(transactionData, client, systemState);
2699
+ }
2700
+ async function setGasBudget(transactionData, client) {
2701
+ if (transactionData.gasData.budget) return;
2702
+ const simulateResult = await client.core.simulateTransaction({
2703
+ transaction: transactionData.build({ overrides: { gasData: {
2704
+ budget: String(MAX_GAS),
2705
+ payment: []
2706
+ } } }),
2707
+ include: { effects: true }
2708
+ });
2709
+ if (simulateResult.$kind === "FailedTransaction") {
2710
+ const executionError = simulateResult.FailedTransaction.status.error ?? void 0;
2711
+ throw new SimulationError(`Transaction resolution failed: ${executionError?.message ?? "Unknown error"}`, {
2712
+ cause: simulateResult,
2713
+ executionError
2714
+ });
2715
+ }
2716
+ const gasUsed = simulateResult.Transaction.effects.gasUsed;
2717
+ const safeOverhead = GAS_SAFE_OVERHEAD * BigInt(transactionData.gasData.price || 1n);
2718
+ const baseComputationCostWithOverhead = BigInt(gasUsed.computationCost) + safeOverhead;
2719
+ const gasBudget = baseComputationCostWithOverhead + BigInt(gasUsed.storageCost) - BigInt(gasUsed.storageRebate);
2720
+ transactionData.gasData.budget = String(gasBudget > baseComputationCostWithOverhead ? gasBudget : baseComputationCostWithOverhead);
2721
+ }
2722
+ async function setGasPayment(transactionData, client) {
2723
+ if (!transactionData.gasData.payment) {
2724
+ const gasPayer = transactionData.gasData.owner ?? transactionData.sender;
2725
+ if (!gasPayer) throw new Error("Either a gas owner or sender must be set to determine gas payment.");
2726
+ const normalizedGasPayer = normalizeSuiAddress(gasPayer);
2727
+ let usesGasCoin = false;
2728
+ let withdrawals = 0n;
2729
+ transactionData.mapArguments((arg) => {
2730
+ if (arg.$kind === "GasCoin") usesGasCoin = true;
2731
+ else if (arg.$kind === "Input") {
2732
+ const input = transactionData.inputs[arg.Input];
2733
+ if (input.$kind === "FundsWithdrawal") {
2734
+ const withdrawalOwner = input.FundsWithdrawal.withdrawFrom.Sender ? transactionData.sender : gasPayer;
2735
+ if (withdrawalOwner && normalizeSuiAddress(withdrawalOwner) === normalizedGasPayer) {
2736
+ if (input.FundsWithdrawal.reservation.$kind === "MaxAmountU64") withdrawals += BigInt(input.FundsWithdrawal.reservation.MaxAmountU64);
2737
+ }
2738
+ }
2739
+ }
2740
+ return arg;
2741
+ });
2742
+ const [suiBalance, coins] = await Promise.all([usesGasCoin ? null : client.core.getBalance({ owner: gasPayer }), client.core.listCoins({
2743
+ owner: gasPayer,
2744
+ coinType: SUI_TYPE_ARG
2745
+ })]);
2746
+ if (suiBalance?.balance.addressBalance && BigInt(suiBalance.balance.addressBalance) >= BigInt(transactionData.gasData.budget || "0") + withdrawals) {
2747
+ transactionData.gasData.payment = [];
2748
+ return;
2749
+ }
2750
+ const paymentCoins = coins.objects.filter((coin) => {
2751
+ return !transactionData.inputs.find((input) => {
2752
+ if (input.Object?.ImmOrOwnedObject) return coin.objectId === input.Object.ImmOrOwnedObject.objectId;
2753
+ return false;
2754
+ });
2755
+ }).map((coin) => parse(ObjectRefSchema, {
2756
+ objectId: coin.objectId,
2757
+ digest: coin.digest,
2758
+ version: coin.version
2759
+ }));
2760
+ if (!paymentCoins.length) throw new Error("No valid gas coins found for the transaction.");
2761
+ transactionData.gasData.payment = paymentCoins;
2762
+ }
2763
+ }
2764
+ async function setExpiration(transactionData, client, existingSystemState) {
2765
+ if (transactionData.expiration || hasVersionedInputs(transactionData)) return;
2766
+ const [systemState, { chainIdentifier }] = await Promise.all([existingSystemState ?? client.core.getCurrentSystemState().then((r) => r.systemState), client.core.getChainIdentifier()]);
2767
+ const currentEpoch = BigInt(systemState.epoch);
2768
+ transactionData.expiration = {
2769
+ $kind: "ValidDuring",
2770
+ ValidDuring: {
2771
+ minEpoch: String(currentEpoch),
2772
+ maxEpoch: String(currentEpoch + 1n),
2773
+ minTimestamp: null,
2774
+ maxTimestamp: null,
2775
+ chain: chainIdentifier,
2776
+ nonce: Math.random() * 4294967296 >>> 0
2777
+ }
2778
+ };
2779
+ }
2780
+ function hasVersionedInputs(transactionData) {
2781
+ if (transactionData.gasData.payment?.length) return true;
2782
+ return transactionData.inputs.some((input) => input.Object?.ImmOrOwnedObject || input.UnresolvedObject && input.UnresolvedObject.version);
2783
+ }
2784
+ async function resolveObjectReferences(transactionData, client) {
2785
+ const objectsToResolve = transactionData.inputs.filter((input) => {
2786
+ return input.UnresolvedObject && !(input.UnresolvedObject.version || input.UnresolvedObject?.initialSharedVersion);
2787
+ });
2788
+ const dedupedIds = [...new Set(objectsToResolve.map((input) => normalizeSuiObjectId(input.UnresolvedObject.objectId)))];
2789
+ const objectChunks = dedupedIds.length ? chunk(dedupedIds, MAX_OBJECTS_PER_FETCH) : [];
2790
+ const resolved = (await Promise.all(objectChunks.map((chunkIds) => client.core.getObjects({ objectIds: chunkIds })))).flatMap((result) => result.objects);
2791
+ const responsesById = new Map(dedupedIds.map((id, index) => {
2792
+ return [id, resolved[index]];
2793
+ }));
2794
+ const invalidObjects = Array.from(responsesById).filter(([_, obj]) => obj instanceof Error).map(([_, obj]) => obj.message);
2795
+ if (invalidObjects.length) throw new Error(`The following input objects are invalid: ${invalidObjects.join(", ")}`);
2796
+ const objects = resolved.map((object$1) => {
2797
+ if (object$1 instanceof Error) throw new Error(`Failed to fetch object: ${object$1.message}`);
2798
+ const owner = object$1.owner;
2799
+ const initialSharedVersion = owner && typeof owner === "object" ? owner.$kind === "Shared" ? owner.Shared.initialSharedVersion : owner.$kind === "ConsensusAddressOwner" ? owner.ConsensusAddressOwner.startVersion : null : null;
2800
+ return {
2801
+ objectId: object$1.objectId,
2802
+ digest: object$1.digest,
2803
+ version: object$1.version,
2804
+ initialSharedVersion
2805
+ };
2806
+ });
2807
+ const objectsById = new Map(dedupedIds.map((id, index) => {
2808
+ return [id, objects[index]];
2809
+ }));
2810
+ for (const [index, input] of transactionData.inputs.entries()) {
2811
+ if (!input.UnresolvedObject) continue;
2812
+ let updated;
2813
+ const id = normalizeSuiAddress(input.UnresolvedObject.objectId);
2814
+ const object$1 = objectsById.get(id);
2815
+ if (input.UnresolvedObject.initialSharedVersion ?? object$1?.initialSharedVersion) updated = Inputs.SharedObjectRef({
2816
+ objectId: id,
2817
+ initialSharedVersion: input.UnresolvedObject.initialSharedVersion || object$1?.initialSharedVersion,
2818
+ mutable: input.UnresolvedObject.mutable || isUsedAsMutable(transactionData, index)
2819
+ });
2820
+ else if (isUsedAsReceiving(transactionData, index)) updated = Inputs.ReceivingRef({
2821
+ objectId: id,
2822
+ digest: input.UnresolvedObject.digest ?? object$1?.digest,
2823
+ version: input.UnresolvedObject.version ?? object$1?.version
2824
+ });
2825
+ transactionData.inputs[transactionData.inputs.indexOf(input)] = updated ?? Inputs.ObjectRef({
2826
+ objectId: id,
2827
+ digest: input.UnresolvedObject.digest ?? object$1?.digest,
2828
+ version: input.UnresolvedObject.version ?? object$1?.version
2829
+ });
2830
+ }
2831
+ }
2832
+ async function normalizeInputs(transactionData, client) {
2833
+ const { inputs, commands } = transactionData;
2834
+ const moveCallsToResolve = [];
2835
+ const moveFunctionsToResolve = /* @__PURE__ */ new Set();
2836
+ commands.forEach((command) => {
2837
+ if (command.MoveCall) {
2838
+ if (command.MoveCall._argumentTypes) return;
2839
+ if (command.MoveCall.arguments.map((arg) => {
2840
+ if (arg.$kind === "Input") return transactionData.inputs[arg.Input];
2841
+ return null;
2842
+ }).some((input) => input?.UnresolvedPure || input?.UnresolvedObject && typeof input?.UnresolvedObject.mutable !== "boolean")) {
2843
+ const functionName = `${command.MoveCall.package}::${command.MoveCall.module}::${command.MoveCall.function}`;
2844
+ moveFunctionsToResolve.add(functionName);
2845
+ moveCallsToResolve.push(command.MoveCall);
2846
+ }
2847
+ }
2848
+ });
2849
+ const moveFunctionParameters = /* @__PURE__ */ new Map();
2850
+ if (moveFunctionsToResolve.size > 0) await Promise.all([...moveFunctionsToResolve].map(async (functionName) => {
2851
+ const [packageId, moduleName, name] = functionName.split("::");
2852
+ const { function: def } = await client.core.getMoveFunction({
2853
+ packageId,
2854
+ moduleName,
2855
+ name
2856
+ });
2857
+ moveFunctionParameters.set(functionName, def.parameters);
2858
+ }));
2859
+ if (moveCallsToResolve.length) await Promise.all(moveCallsToResolve.map(async (moveCall) => {
2860
+ const parameters = moveFunctionParameters.get(`${moveCall.package}::${moveCall.module}::${moveCall.function}`);
2861
+ if (!parameters) return;
2862
+ moveCall._argumentTypes = parameters.length > 0 && isTxContext(parameters.at(-1)) ? parameters.slice(0, parameters.length - 1) : parameters;
2863
+ }));
2864
+ commands.forEach((command) => {
2865
+ if (!command.MoveCall) return;
2866
+ const moveCall = command.MoveCall;
2867
+ const fnName = `${moveCall.package}::${moveCall.module}::${moveCall.function}`;
2868
+ const params = moveCall._argumentTypes;
2869
+ if (!params) return;
2870
+ if (params.length !== command.MoveCall.arguments.length) throw new Error(`Incorrect number of arguments for ${fnName}`);
2871
+ params.forEach((param, i) => {
2872
+ const arg = moveCall.arguments[i];
2873
+ if (arg.$kind !== "Input") return;
2874
+ const input = inputs[arg.Input];
2875
+ if (!input.UnresolvedPure && !input.UnresolvedObject) return;
2876
+ const inputValue = input.UnresolvedPure?.value ?? input.UnresolvedObject?.objectId;
2877
+ const schema = getPureBcsSchema(param.body);
2878
+ if (schema) {
2879
+ arg.type = "pure";
2880
+ inputs[inputs.indexOf(input)] = Inputs.Pure(schema.serialize(inputValue));
2881
+ return;
2882
+ }
2883
+ if (typeof inputValue !== "string") throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(inputValue, null, 2)}`);
2884
+ arg.type = "object";
2885
+ const unresolvedObject = input.UnresolvedPure ? {
2886
+ $kind: "UnresolvedObject",
2887
+ UnresolvedObject: { objectId: inputValue }
2888
+ } : input;
2889
+ inputs[arg.Input] = unresolvedObject;
2890
+ });
2891
+ });
2892
+ }
2893
+ function isUsedAsMutable(transactionData, index) {
2894
+ let usedAsMutable = false;
2895
+ transactionData.getInputUses(index, (arg, tx) => {
2896
+ if (tx.MoveCall && tx.MoveCall._argumentTypes) {
2897
+ const argIndex = tx.MoveCall.arguments.indexOf(arg);
2898
+ usedAsMutable = tx.MoveCall._argumentTypes[argIndex].reference !== "immutable" || usedAsMutable;
2899
+ }
2900
+ if (tx.$kind === "MakeMoveVec" || tx.$kind === "MergeCoins" || tx.$kind === "SplitCoins" || tx.$kind === "TransferObjects") usedAsMutable = true;
2901
+ });
2902
+ return usedAsMutable;
2903
+ }
2904
+ function isUsedAsReceiving(transactionData, index) {
2905
+ let usedAsReceiving = false;
2906
+ transactionData.getInputUses(index, (arg, tx) => {
2907
+ if (tx.MoveCall && tx.MoveCall._argumentTypes) {
2908
+ const argIndex = tx.MoveCall.arguments.indexOf(arg);
2909
+ usedAsReceiving = isReceivingType(tx.MoveCall._argumentTypes[argIndex]) || usedAsReceiving;
2910
+ }
2911
+ });
2912
+ return usedAsReceiving;
2913
+ }
2914
+ var RECEIVING_TYPE = "0x0000000000000000000000000000000000000000000000000000000000000002::transfer::Receiving";
2915
+ function isReceivingType(type) {
2916
+ if (type.body.$kind !== "datatype") return false;
2917
+ return type.body.datatype.typeName === RECEIVING_TYPE;
2918
+ }
2919
+
2920
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/resolve.mjs
2921
+ function needsTransactionResolution(data, options) {
2922
+ if (data.inputs.some((input) => {
2923
+ return input.UnresolvedObject || input.UnresolvedPure;
2924
+ })) return true;
2925
+ if (!options.onlyTransactionKind) {
2926
+ if (!data.gasData.price || !data.gasData.budget || !data.gasData.payment) return true;
2927
+ if (data.gasData.payment.length === 0 && !data.expiration) return true;
2928
+ }
2929
+ return false;
2930
+ }
2931
+ async function resolveTransactionPlugin(transactionData, options, next) {
2932
+ normalizeRawArguments(transactionData);
2933
+ if (!needsTransactionResolution(transactionData, options)) {
2934
+ await validate(transactionData);
2935
+ return next();
2936
+ }
2937
+ return (getClient2(options).core?.resolveTransactionPlugin() ?? coreClientResolveTransactionPlugin)(transactionData, options, async () => {
2938
+ await validate(transactionData);
2939
+ await next();
2940
+ });
2941
+ }
2942
+ function validate(transactionData) {
2943
+ transactionData.inputs.forEach((input, index) => {
2944
+ if (input.$kind !== "Object" && input.$kind !== "Pure" && input.$kind !== "FundsWithdrawal") throw new Error(`Input at index ${index} has not been resolved. Expected a Pure, Object, or FundsWithdrawal input, but found ${JSON.stringify(input)}`);
2945
+ });
2946
+ }
2947
+ function getClient2(options) {
2948
+ if (!options.client) throw new Error(`No sui client passed to Transaction#build, but transaction data was not sufficient to build offline.`);
2949
+ return options.client;
2950
+ }
2951
+ function normalizeRawArguments(transactionData) {
2952
+ for (const command of transactionData.commands) switch (command.$kind) {
2953
+ case "SplitCoins":
2954
+ command.SplitCoins.amounts.forEach((amount) => {
2955
+ normalizeRawArgument(amount, suiBcs.U64, transactionData);
2956
+ });
2957
+ break;
2958
+ case "TransferObjects":
2959
+ normalizeRawArgument(command.TransferObjects.address, suiBcs.Address, transactionData);
2960
+ break;
2961
+ }
2962
+ }
2963
+ function normalizeRawArgument(arg, schema, transactionData) {
2964
+ if (arg.$kind !== "Input") return;
2965
+ const input = transactionData.inputs[arg.Input];
2966
+ if (input.$kind !== "UnresolvedPure") return;
2967
+ transactionData.inputs[arg.Input] = Inputs.Pure(schema.serialize(input.UnresolvedPure.value));
2968
+ }
2969
+
2970
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/object.mjs
2971
+ init_constants();
2972
+ function createObjectMethods(makeObject) {
2973
+ function object2(value) {
2974
+ return makeObject(value);
2975
+ }
2976
+ object2.system = (options) => {
2977
+ const mutable = options?.mutable;
2978
+ if (mutable !== void 0) return object2(Inputs.SharedObjectRef({
2979
+ objectId: SUI_SYSTEM_STATE_OBJECT_ID,
2980
+ initialSharedVersion: 1,
2981
+ mutable
2982
+ }));
2983
+ return object2({
2984
+ $kind: "UnresolvedObject",
2985
+ UnresolvedObject: {
2986
+ objectId: SUI_SYSTEM_STATE_OBJECT_ID,
2987
+ initialSharedVersion: 1
2988
+ }
2989
+ });
2990
+ };
2991
+ object2.clock = () => object2(Inputs.SharedObjectRef({
2992
+ objectId: SUI_CLOCK_OBJECT_ID,
2993
+ initialSharedVersion: 1,
2994
+ mutable: false
2995
+ }));
2996
+ object2.random = () => object2({
2997
+ $kind: "UnresolvedObject",
2998
+ UnresolvedObject: {
2999
+ objectId: SUI_RANDOM_OBJECT_ID,
3000
+ mutable: false
3001
+ }
3002
+ });
3003
+ object2.denyList = (options) => {
3004
+ return object2({
3005
+ $kind: "UnresolvedObject",
3006
+ UnresolvedObject: {
3007
+ objectId: SUI_DENY_LIST_OBJECT_ID,
3008
+ mutable: options?.mutable
3009
+ }
3010
+ });
3011
+ };
3012
+ object2.option = ({ type, value }) => (tx) => tx.moveCall({
3013
+ typeArguments: [type],
3014
+ target: `${MOVE_STDLIB_ADDRESS}::option::${value === null ? "none" : "some"}`,
3015
+ arguments: value === null ? [] : [tx.object(value)]
3016
+ });
3017
+ return object2;
3018
+ }
3019
+
3020
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/pure.mjs
3021
+ init_pure();
3022
+ init_bcs2();
3023
+ init_dist2();
3024
+ function createPure(makePure) {
3025
+ function pure(typeOrSerializedValue, value) {
3026
+ if (typeof typeOrSerializedValue === "string") return makePure(pureBcsSchemaFromTypeName(typeOrSerializedValue).serialize(value));
3027
+ if (typeOrSerializedValue instanceof Uint8Array || isSerializedBcs(typeOrSerializedValue)) return makePure(typeOrSerializedValue);
3028
+ throw new Error("tx.pure must be called either a bcs type name, or a serialized bcs value");
3029
+ }
3030
+ pure.u8 = (value) => makePure(suiBcs.U8.serialize(value));
3031
+ pure.u16 = (value) => makePure(suiBcs.U16.serialize(value));
3032
+ pure.u32 = (value) => makePure(suiBcs.U32.serialize(value));
3033
+ pure.u64 = (value) => makePure(suiBcs.U64.serialize(value));
3034
+ pure.u128 = (value) => makePure(suiBcs.U128.serialize(value));
3035
+ pure.u256 = (value) => makePure(suiBcs.U256.serialize(value));
3036
+ pure.bool = (value) => makePure(suiBcs.Bool.serialize(value));
3037
+ pure.string = (value) => makePure(suiBcs.String.serialize(value));
3038
+ pure.address = (value) => makePure(suiBcs.Address.serialize(value));
3039
+ pure.id = pure.address;
3040
+ pure.vector = (type, value) => {
3041
+ return makePure(suiBcs.vector(pureBcsSchemaFromTypeName(type)).serialize(value));
3042
+ };
3043
+ pure.option = (type, value) => {
3044
+ return makePure(suiBcs.option(pureBcsSchemaFromTypeName(type)).serialize(value));
3045
+ };
3046
+ return pure;
3047
+ }
3048
+
3049
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/client/mvr.mjs
3050
+ init_move_registry();
3051
+ init_sui_types();
3052
+
3053
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/version.mjs
3054
+ var PACKAGE_VERSION = "2.11.0";
3055
+ var TARGETED_RPC_VERSION = "1.69.0";
3056
+
3057
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/client/mvr.mjs
3058
+ init_dist();
3059
+ var NAME_SEPARATOR = "/";
3060
+ var MVR_API_HEADER = { "Mvr-Source": `@mysten/sui@${PACKAGE_VERSION}` };
3061
+ var MvrClient = class {
3062
+ #cache;
3063
+ #url;
3064
+ #pageSize;
3065
+ #overrides;
3066
+ constructor({ cache, url, pageSize = 50, overrides }) {
3067
+ this.#cache = cache;
3068
+ this.#url = url;
3069
+ this.#pageSize = pageSize;
3070
+ this.#overrides = {
3071
+ packages: overrides?.packages,
3072
+ types: overrides?.types
3073
+ };
3074
+ validateOverrides(this.#overrides);
3075
+ }
3076
+ get #mvrPackageDataLoader() {
3077
+ return this.#cache.readSync(["#mvrPackageDataLoader", this.#url ?? ""], () => {
3078
+ const loader = new DataLoader(async (packages) => {
3079
+ if (!this.#url) throw new Error(`MVR Api URL is not set for the current client (resolving ${packages.join(", ")})`);
3080
+ const resolved = await this.#resolvePackages(packages);
3081
+ return packages.map((pkg) => resolved[pkg] ?? /* @__PURE__ */ new Error(`Failed to resolve package: ${pkg}`));
3082
+ });
3083
+ const overrides = this.#overrides?.packages;
3084
+ if (overrides) for (const [pkg, id] of Object.entries(overrides)) loader.prime(pkg, id);
3085
+ return loader;
3086
+ });
3087
+ }
3088
+ get #mvrTypeDataLoader() {
3089
+ return this.#cache.readSync(["#mvrTypeDataLoader", this.#url ?? ""], () => {
3090
+ const loader = new DataLoader(async (types) => {
3091
+ if (!this.#url) throw new Error(`MVR Api URL is not set for the current client (resolving ${types.join(", ")})`);
3092
+ const resolved = await this.#resolveTypes(types);
3093
+ return types.map((type) => resolved[type] ?? /* @__PURE__ */ new Error(`Failed to resolve type: ${type}`));
3094
+ });
3095
+ const overrides = this.#overrides?.types;
3096
+ if (overrides) for (const [type, id] of Object.entries(overrides)) loader.prime(type, id);
3097
+ return loader;
3098
+ });
3099
+ }
3100
+ async #resolvePackages(packages) {
3101
+ if (packages.length === 0) return {};
3102
+ const batches = chunk(packages, this.#pageSize);
3103
+ const results = {};
3104
+ await Promise.all(batches.map(async (batch) => {
3105
+ const data = await this.#fetch("/v1/resolution/bulk", { names: batch });
3106
+ if (!data?.resolution) return;
3107
+ for (const pkg of Object.keys(data?.resolution)) {
3108
+ const pkgData = data.resolution[pkg]?.package_id;
3109
+ if (!pkgData) continue;
3110
+ results[pkg] = pkgData;
3111
+ }
3112
+ }));
3113
+ return results;
3114
+ }
3115
+ async #resolveTypes(types) {
3116
+ if (types.length === 0) return {};
3117
+ const batches = chunk(types, this.#pageSize);
3118
+ const results = {};
3119
+ await Promise.all(batches.map(async (batch) => {
3120
+ const data = await this.#fetch("/v1/struct-definition/bulk", { types: batch });
3121
+ if (!data?.resolution) return;
3122
+ for (const type of Object.keys(data?.resolution)) {
3123
+ const typeData = data.resolution[type]?.type_tag;
3124
+ if (!typeData) continue;
3125
+ results[type] = typeData;
3126
+ }
3127
+ }));
3128
+ return results;
3129
+ }
3130
+ async #fetch(url, body) {
3131
+ if (!this.#url) throw new Error("MVR Api URL is not set for the current client");
3132
+ const response = await fetch(`${this.#url}${url}`, {
3133
+ method: "POST",
3134
+ headers: {
3135
+ "Content-Type": "application/json",
3136
+ ...MVR_API_HEADER
3137
+ },
3138
+ body: JSON.stringify(body)
3139
+ });
3140
+ if (!response.ok) {
3141
+ const errorBody = await response.json().catch(() => ({}));
3142
+ throw new Error(`Failed to resolve types: ${errorBody?.message}`);
3143
+ }
3144
+ return response.json();
3145
+ }
3146
+ async resolvePackage({ package: name }) {
3147
+ if (!hasMvrName(name)) return { package: name };
3148
+ return { package: await this.#mvrPackageDataLoader.load(name) };
3149
+ }
3150
+ async resolveType({ type }) {
3151
+ if (!hasMvrName(type)) return { type };
3152
+ const mvrTypes = [...extractMvrTypes(type)];
3153
+ const resolvedTypes = await this.#mvrTypeDataLoader.loadMany(mvrTypes);
3154
+ const typeMap = {};
3155
+ for (let i = 0; i < mvrTypes.length; i++) {
3156
+ const resolvedType = resolvedTypes[i];
3157
+ if (resolvedType instanceof Error) throw resolvedType;
3158
+ typeMap[mvrTypes[i]] = resolvedType;
3159
+ }
3160
+ return { type: replaceMvrNames(type, typeMap) };
3161
+ }
3162
+ async resolve({ types = [], packages = [] }) {
3163
+ const mvrTypes = /* @__PURE__ */ new Set();
3164
+ for (const type of types ?? []) extractMvrTypes(type, mvrTypes);
3165
+ const typesArray = [...mvrTypes];
3166
+ const [resolvedTypes, resolvedPackages] = await Promise.all([typesArray.length > 0 ? this.#mvrTypeDataLoader.loadMany(typesArray) : [], packages.length > 0 ? this.#mvrPackageDataLoader.loadMany(packages) : []]);
3167
+ const typeMap = { ...this.#overrides?.types };
3168
+ for (const [i, type] of typesArray.entries()) {
3169
+ const resolvedType = resolvedTypes[i];
3170
+ if (resolvedType instanceof Error) throw resolvedType;
3171
+ typeMap[type] = resolvedType;
3172
+ }
3173
+ const replacedTypes = {};
3174
+ for (const type of types ?? []) replacedTypes[type] = { type: replaceMvrNames(type, typeMap) };
3175
+ const replacedPackages = {};
3176
+ for (const [i, pkg] of (packages ?? []).entries()) {
3177
+ const resolvedPkg = this.#overrides?.packages?.[pkg] ?? resolvedPackages[i];
3178
+ if (resolvedPkg instanceof Error) throw resolvedPkg;
3179
+ replacedPackages[pkg] = { package: resolvedPkg };
3180
+ }
3181
+ return {
3182
+ types: replacedTypes,
3183
+ packages: replacedPackages
3184
+ };
3185
+ }
3186
+ };
3187
+ function validateOverrides(overrides) {
3188
+ if (overrides?.packages) for (const [pkg, id] of Object.entries(overrides.packages)) {
3189
+ if (!isValidNamedPackage(pkg)) throw new Error(`Invalid package name: ${pkg}`);
3190
+ if (!isValidSuiAddress(normalizeSuiAddress(id))) throw new Error(`Invalid package ID: ${id}`);
3191
+ }
3192
+ if (overrides?.types) for (const [type, val] of Object.entries(overrides.types)) {
3193
+ if (parseStructTag(type).typeParams.length > 0) throw new Error("Type overrides must be first-level only. If you want to supply generic types, just pass each type individually.");
3194
+ if (!isValidSuiAddress(parseStructTag(val).address)) throw new Error(`Invalid type: ${val}`);
3195
+ }
3196
+ }
3197
+ function extractMvrTypes(type, types = /* @__PURE__ */ new Set()) {
3198
+ if (typeof type === "string" && !hasMvrName(type)) return types;
3199
+ const tag = isStructTag(type) ? type : parseStructTag(type);
3200
+ if (hasMvrName(tag.address)) types.add(`${tag.address}::${tag.module}::${tag.name}`);
3201
+ for (const param of tag.typeParams) extractMvrTypes(param, types);
3202
+ return types;
3203
+ }
3204
+ function replaceMvrNames(tag, typeCache) {
3205
+ const type = isStructTag(tag) ? tag : parseStructTag(tag);
3206
+ const cacheHit = typeCache[`${type.address}::${type.module}::${type.name}`];
3207
+ return normalizeStructTag({
3208
+ ...type,
3209
+ address: cacheHit ? cacheHit.split("::")[0] : type.address,
3210
+ typeParams: type.typeParams.map((param) => replaceMvrNames(param, typeCache))
3211
+ });
3212
+ }
3213
+ function hasMvrName(nameOrType) {
3214
+ return nameOrType.includes(NAME_SEPARATOR) || nameOrType.includes("@") || nameOrType.includes(".sui");
3215
+ }
3216
+ function isStructTag(type) {
3217
+ return typeof type === "object" && "address" in type && "module" in type && "name" in type && "typeParams" in type;
3218
+ }
3219
+ function findNamesInTransaction(builder) {
3220
+ const packages = /* @__PURE__ */ new Set();
3221
+ const types = /* @__PURE__ */ new Set();
3222
+ for (const command of builder.commands) switch (command.$kind) {
3223
+ case "MakeMoveVec":
3224
+ if (command.MakeMoveVec.type) getNamesFromTypeList([command.MakeMoveVec.type]).forEach((type) => {
3225
+ types.add(type);
3226
+ });
3227
+ break;
3228
+ case "MoveCall":
3229
+ const moveCall = command.MoveCall;
3230
+ const pkg = moveCall.package.split("::")[0];
3231
+ if (hasMvrName(pkg)) {
3232
+ if (!isValidNamedPackage(pkg)) throw new Error(`Invalid package name: ${pkg}`);
3233
+ packages.add(pkg);
3234
+ }
3235
+ getNamesFromTypeList(moveCall.typeArguments ?? []).forEach((type) => {
3236
+ types.add(type);
3237
+ });
3238
+ break;
3239
+ default:
3240
+ break;
3241
+ }
3242
+ return {
3243
+ packages: [...packages],
3244
+ types: [...types]
3245
+ };
3246
+ }
3247
+ function replaceNames(builder, resolved) {
3248
+ for (const command of builder.commands) {
3249
+ if (command.MakeMoveVec?.type) {
3250
+ if (!hasMvrName(command.MakeMoveVec.type)) continue;
3251
+ if (!resolved.types[command.MakeMoveVec.type]) throw new Error(`No resolution found for type: ${command.MakeMoveVec.type}`);
3252
+ command.MakeMoveVec.type = resolved.types[command.MakeMoveVec.type].type;
3253
+ }
3254
+ const tx = command.MoveCall;
3255
+ if (!tx) continue;
3256
+ const nameParts = tx.package.split("::");
3257
+ const name = nameParts[0];
3258
+ if (hasMvrName(name) && !resolved.packages[name]) throw new Error(`No address found for package: ${name}`);
3259
+ if (hasMvrName(name)) {
3260
+ nameParts[0] = resolved.packages[name].package;
3261
+ tx.package = nameParts.join("::");
3262
+ }
3263
+ const types = tx.typeArguments;
3264
+ if (!types) continue;
3265
+ for (let i = 0; i < types.length; i++) {
3266
+ if (!hasMvrName(types[i])) continue;
3267
+ if (!resolved.types[types[i]]) throw new Error(`No resolution found for type: ${types[i]}`);
3268
+ types[i] = resolved.types[types[i]].type;
3269
+ }
3270
+ tx.typeArguments = types;
3271
+ }
3272
+ }
3273
+ function getNamesFromTypeList(types) {
3274
+ const names = /* @__PURE__ */ new Set();
3275
+ for (const type of types) if (hasMvrName(type)) {
3276
+ if (!isValidNamedType(type)) throw new Error(`Invalid type with names: ${type}`);
3277
+ names.add(type);
3278
+ }
3279
+ return names;
3280
+ }
3281
+
3282
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/plugins/NamedPackagesPlugin.mjs
3283
+ function namedPackagesPlugin() {
3284
+ return async (transactionData, buildOptions, next) => {
3285
+ const names = findNamesInTransaction(transactionData);
3286
+ if (names.types.length === 0 && names.packages.length === 0) return next();
3287
+ if (!buildOptions.client) throw new Error(`Transaction contains MVR names but no client was provided to resolve them. Please pass a client to Transaction#build()`);
3288
+ replaceNames(transactionData, await buildOptions.client.core.mvr.resolve({
3289
+ types: names.types,
3290
+ packages: names.packages
3291
+ }));
3292
+ await next();
3293
+ };
3294
+ }
3295
+
3296
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/intents/CoinWithBalance.mjs
3297
+ init_sui_types();
3298
+ init_bcs2();
3299
+ var COIN_WITH_BALANCE = "CoinWithBalance";
3300
+ var SUI_TYPE = normalizeStructTag("0x2::sui::SUI");
3301
+ function coinWithBalance({ type = SUI_TYPE, balance, useGasCoin = true }) {
3302
+ let coinResult = null;
3303
+ return (tx) => {
3304
+ if (coinResult) return coinResult;
3305
+ tx.addIntentResolver(COIN_WITH_BALANCE, resolveCoinBalance);
3306
+ const coinType = type === "gas" ? type : normalizeStructTag(type);
3307
+ coinResult = tx.add(TransactionCommands.Intent({
3308
+ name: COIN_WITH_BALANCE,
3309
+ inputs: {},
3310
+ data: {
3311
+ type: coinType === SUI_TYPE && useGasCoin ? "gas" : coinType,
3312
+ balance: BigInt(balance)
3313
+ }
3314
+ }));
3315
+ return coinResult;
3316
+ };
3317
+ }
3318
+ var CoinWithBalanceData = object({
3319
+ type: string(),
3320
+ balance: bigint()
3321
+ });
3322
+ async function resolveCoinBalance(transactionData, buildOptions, next) {
3323
+ const coinTypes = /* @__PURE__ */ new Set();
3324
+ const totalByType = /* @__PURE__ */ new Map();
3325
+ if (!transactionData.sender) throw new Error("Sender must be set to resolve CoinWithBalance");
3326
+ for (const command of transactionData.commands) if (command.$kind === "$Intent" && command.$Intent.name === COIN_WITH_BALANCE) {
3327
+ const { type, balance } = parse(CoinWithBalanceData, command.$Intent.data);
3328
+ if (type !== "gas" && balance > 0n) coinTypes.add(type);
3329
+ totalByType.set(type, (totalByType.get(type) ?? 0n) + balance);
3330
+ }
3331
+ const usedIds = /* @__PURE__ */ new Set();
3332
+ for (const input of transactionData.inputs) {
3333
+ if (input.Object?.ImmOrOwnedObject) usedIds.add(input.Object.ImmOrOwnedObject.objectId);
3334
+ if (input.UnresolvedObject?.objectId) usedIds.add(input.UnresolvedObject.objectId);
3335
+ }
3336
+ const coinsByType = /* @__PURE__ */ new Map();
3337
+ const addressBalanceByType = /* @__PURE__ */ new Map();
3338
+ const client = buildOptions.client;
3339
+ if (!client) throw new Error("Client must be provided to build or serialize transactions with CoinWithBalance intents");
3340
+ await Promise.all([...[...coinTypes].map(async (coinType) => {
3341
+ const { coins, addressBalance } = await getCoinsAndBalanceOfType({
3342
+ coinType,
3343
+ balance: totalByType.get(coinType),
3344
+ client,
3345
+ owner: transactionData.sender,
3346
+ usedIds
3347
+ });
3348
+ coinsByType.set(coinType, coins);
3349
+ addressBalanceByType.set(coinType, addressBalance);
3350
+ }), totalByType.has("gas") ? await client.core.getBalance({
3351
+ owner: transactionData.sender,
3352
+ coinType: SUI_TYPE
3353
+ }).then(({ balance }) => {
3354
+ addressBalanceByType.set("gas", BigInt(balance.addressBalance));
3355
+ }) : null]);
3356
+ const mergedCoins = /* @__PURE__ */ new Map();
3357
+ for (const [index, transaction] of transactionData.commands.entries()) {
3358
+ if (transaction.$kind !== "$Intent" || transaction.$Intent.name !== COIN_WITH_BALANCE) continue;
3359
+ const { type, balance } = transaction.$Intent.data;
3360
+ if (balance === 0n) {
3361
+ transactionData.replaceCommand(index, TransactionCommands.MoveCall({
3362
+ target: "0x2::coin::zero",
3363
+ typeArguments: [type === "gas" ? SUI_TYPE : type]
3364
+ }));
3365
+ continue;
3366
+ }
3367
+ const commands = [];
3368
+ if (addressBalanceByType.get(type) >= totalByType.get(type)) commands.push(TransactionCommands.MoveCall({
3369
+ target: "0x2::coin::redeem_funds",
3370
+ typeArguments: [type === "gas" ? SUI_TYPE : type],
3371
+ arguments: [transactionData.addInput("withdrawal", Inputs.FundsWithdrawal({
3372
+ reservation: {
3373
+ $kind: "MaxAmountU64",
3374
+ MaxAmountU64: String(balance)
3375
+ },
3376
+ typeArg: {
3377
+ $kind: "Balance",
3378
+ Balance: type === "gas" ? SUI_TYPE : type
3379
+ },
3380
+ withdrawFrom: {
3381
+ $kind: "Sender",
3382
+ Sender: true
3383
+ }
3384
+ }))]
3385
+ }));
3386
+ else {
3387
+ if (!mergedCoins.has(type)) {
3388
+ const addressBalance = addressBalanceByType.get(type) ?? 0n;
3389
+ const coinType = type === "gas" ? SUI_TYPE : type;
3390
+ let baseCoin;
3391
+ let restCoins;
3392
+ if (type === "gas") {
3393
+ baseCoin = {
3394
+ $kind: "GasCoin",
3395
+ GasCoin: true
3396
+ };
3397
+ restCoins = [];
3398
+ } else [baseCoin, ...restCoins] = coinsByType.get(type).map((coin) => transactionData.addInput("object", Inputs.ObjectRef({
3399
+ objectId: coin.objectId,
3400
+ digest: coin.digest,
3401
+ version: coin.version
3402
+ })));
3403
+ if (addressBalance > 0n) {
3404
+ commands.push(TransactionCommands.MoveCall({
3405
+ target: "0x2::coin::redeem_funds",
3406
+ typeArguments: [coinType],
3407
+ arguments: [transactionData.addInput("withdrawal", Inputs.FundsWithdrawal({
3408
+ reservation: {
3409
+ $kind: "MaxAmountU64",
3410
+ MaxAmountU64: String(addressBalance)
3411
+ },
3412
+ typeArg: {
3413
+ $kind: "Balance",
3414
+ Balance: coinType
3415
+ },
3416
+ withdrawFrom: {
3417
+ $kind: "Sender",
3418
+ Sender: true
3419
+ }
3420
+ }))]
3421
+ }));
3422
+ commands.push(TransactionCommands.MergeCoins(baseCoin, [{
3423
+ $kind: "Result",
3424
+ Result: index + commands.length - 1
3425
+ }, ...restCoins]));
3426
+ } else if (restCoins.length > 0) commands.push(TransactionCommands.MergeCoins(baseCoin, restCoins));
3427
+ mergedCoins.set(type, baseCoin);
3428
+ }
3429
+ commands.push(TransactionCommands.SplitCoins(mergedCoins.get(type), [transactionData.addInput("pure", Inputs.Pure(suiBcs.u64().serialize(balance)))]));
3430
+ }
3431
+ transactionData.replaceCommand(index, commands);
3432
+ transactionData.mapArguments((arg, _command, commandIndex) => {
3433
+ if (commandIndex >= index && commandIndex < index + commands.length) return arg;
3434
+ if (arg.$kind === "Result" && arg.Result === index) return {
3435
+ $kind: "NestedResult",
3436
+ NestedResult: [index + commands.length - 1, 0]
3437
+ };
3438
+ return arg;
3439
+ });
3440
+ }
3441
+ return next();
3442
+ }
3443
+ async function getCoinsAndBalanceOfType({ coinType, balance, client, owner, usedIds }) {
3444
+ let remainingBalance = balance;
3445
+ const coins = [];
3446
+ const balanceRequest = client.core.getBalance({
3447
+ owner,
3448
+ coinType
3449
+ }).then(({ balance: balance$1 }) => {
3450
+ remainingBalance -= BigInt(balance$1.addressBalance);
3451
+ return balance$1;
3452
+ });
3453
+ const [allCoins, balanceResponse] = await Promise.all([loadMoreCoins(), balanceRequest]);
3454
+ if (BigInt(balanceResponse.balance) < balance) throw new Error(`Insufficient balance of ${coinType} for owner ${owner}. Required: ${balance}, Available: ${balance - remainingBalance}`);
3455
+ return {
3456
+ coins: allCoins,
3457
+ balance: BigInt(balanceResponse.coinBalance),
3458
+ addressBalance: BigInt(balanceResponse.addressBalance),
3459
+ coinBalance: BigInt(balanceResponse.coinBalance)
3460
+ };
3461
+ async function loadMoreCoins(cursor = null) {
3462
+ const { objects, hasNextPage, cursor: nextCursor } = await client.core.listCoins({
3463
+ owner,
3464
+ coinType,
3465
+ cursor
3466
+ });
3467
+ await balanceRequest;
3468
+ if (remainingBalance > 0n) {
3469
+ for (const coin of objects) {
3470
+ if (usedIds.has(coin.objectId)) continue;
3471
+ const coinBalance = BigInt(coin.balance);
3472
+ coins.push(coin);
3473
+ remainingBalance -= coinBalance;
3474
+ if (remainingBalance <= 0) break;
3475
+ }
3476
+ if (hasNextPage) return loadMoreCoins(nextCursor);
3477
+ }
3478
+ return coins;
3479
+ }
3480
+ }
3481
+
3482
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/Transaction.mjs
3483
+ init_dist2();
3484
+ function createTransactionResult(index, length = Infinity) {
3485
+ const baseResult = {
3486
+ $kind: "Result",
3487
+ get Result() {
3488
+ return typeof index === "function" ? index() : index;
3489
+ }
3490
+ };
3491
+ const nestedResults = [];
3492
+ const nestedResultFor = (resultIndex) => nestedResults[resultIndex] ??= {
3493
+ $kind: "NestedResult",
3494
+ get NestedResult() {
3495
+ return [typeof index === "function" ? index() : index, resultIndex];
3496
+ }
3497
+ };
3498
+ return new Proxy(baseResult, {
3499
+ set() {
3500
+ throw new Error("The transaction result is a proxy, and does not support setting properties directly");
3501
+ },
3502
+ get(target, property) {
3503
+ if (property in target) return Reflect.get(target, property);
3504
+ if (property === Symbol.iterator) return function* () {
3505
+ let i = 0;
3506
+ while (i < length) {
3507
+ yield nestedResultFor(i);
3508
+ i++;
3509
+ }
3510
+ };
3511
+ if (typeof property === "symbol") return;
3512
+ const resultIndex = parseInt(property, 10);
3513
+ if (Number.isNaN(resultIndex) || resultIndex < 0) return;
3514
+ return nestedResultFor(resultIndex);
3515
+ }
3516
+ });
3517
+ }
3518
+ var TRANSACTION_BRAND = /* @__PURE__ */ Symbol.for("@mysten/transaction");
3519
+ function isTransaction(obj) {
3520
+ return !!obj && typeof obj === "object" && obj[TRANSACTION_BRAND] === true;
3521
+ }
3522
+ var Transaction = class Transaction2 {
3523
+ #serializationPlugins;
3524
+ #buildPlugins;
3525
+ #intentResolvers = /* @__PURE__ */ new Map();
3526
+ #inputSection = [];
3527
+ #commandSection = [];
3528
+ #availableResults = /* @__PURE__ */ new Set();
3529
+ #pendingPromises = /* @__PURE__ */ new Set();
3530
+ #added = /* @__PURE__ */ new Map();
3531
+ /**
3532
+ * Converts from a serialize transaction kind (built with `build({ onlyTransactionKind: true })`) to a `Transaction` class.
3533
+ * Supports either a byte array, or base64-encoded bytes.
3534
+ */
3535
+ static fromKind(serialized) {
3536
+ const tx = new Transaction2();
3537
+ tx.#data = TransactionDataBuilder.fromKindBytes(typeof serialized === "string" ? fromBase64(serialized) : serialized);
3538
+ tx.#inputSection = tx.#data.inputs.slice();
3539
+ tx.#commandSection = tx.#data.commands.slice();
3540
+ tx.#availableResults = new Set(tx.#commandSection.map((_, i) => i));
3541
+ return tx;
3542
+ }
3543
+ /**
3544
+ * Converts from a serialized transaction format to a `Transaction` class.
3545
+ * There are two supported serialized formats:
3546
+ * - A string returned from `Transaction#serialize`. The serialized format must be compatible, or it will throw an error.
3547
+ * - A byte array (or base64-encoded bytes) containing BCS transaction data.
3548
+ */
3549
+ static from(transaction) {
3550
+ const newTransaction = new Transaction2();
3551
+ if (isTransaction(transaction)) newTransaction.#data = TransactionDataBuilder.restore(transaction.getData());
3552
+ else if (typeof transaction !== "string" || !transaction.startsWith("{")) newTransaction.#data = TransactionDataBuilder.fromBytes(typeof transaction === "string" ? fromBase64(transaction) : transaction);
3553
+ else newTransaction.#data = TransactionDataBuilder.restore(JSON.parse(transaction));
3554
+ newTransaction.#inputSection = newTransaction.#data.inputs.slice();
3555
+ newTransaction.#commandSection = newTransaction.#data.commands.slice();
3556
+ newTransaction.#availableResults = new Set(newTransaction.#commandSection.map((_, i) => i));
3557
+ if (!newTransaction.isPreparedForSerialization({ supportedIntents: [COIN_WITH_BALANCE] })) throw new Error("Transaction has unresolved intents or async thunks. Call `prepareForSerialization` before copying.");
3558
+ if (newTransaction.#data.commands.some((cmd) => cmd.$Intent?.name === COIN_WITH_BALANCE)) newTransaction.addIntentResolver(COIN_WITH_BALANCE, resolveCoinBalance);
3559
+ return newTransaction;
3560
+ }
3561
+ addSerializationPlugin(step) {
3562
+ this.#serializationPlugins.push(step);
3563
+ }
3564
+ addBuildPlugin(step) {
3565
+ this.#buildPlugins.push(step);
3566
+ }
3567
+ addIntentResolver(intent, resolver) {
3568
+ if (this.#intentResolvers.has(intent) && this.#intentResolvers.get(intent) !== resolver) throw new Error(`Intent resolver for ${intent} already exists`);
3569
+ this.#intentResolvers.set(intent, resolver);
3570
+ }
3571
+ setSender(sender) {
3572
+ this.#data.sender = sender;
3573
+ }
3574
+ /**
3575
+ * Sets the sender only if it has not already been set.
3576
+ * This is useful for sponsored transaction flows where the sender may not be the same as the signer address.
3577
+ */
3578
+ setSenderIfNotSet(sender) {
3579
+ if (!this.#data.sender) this.#data.sender = sender;
3580
+ }
3581
+ setExpiration(expiration) {
3582
+ this.#data.expiration = expiration ? parse(TransactionExpiration2, expiration) : null;
3583
+ }
3584
+ setGasPrice(price) {
3585
+ this.#data.gasData.price = String(price);
3586
+ }
3587
+ setGasBudget(budget) {
3588
+ this.#data.gasData.budget = String(budget);
3589
+ }
3590
+ setGasBudgetIfNotSet(budget) {
3591
+ if (this.#data.gasData.budget == null) this.#data.gasData.budget = String(budget);
3592
+ }
3593
+ setGasOwner(owner) {
3594
+ this.#data.gasData.owner = owner;
3595
+ }
3596
+ setGasPayment(payments) {
3597
+ this.#data.gasData.payment = payments.map((payment) => parse(ObjectRefSchema, payment));
3598
+ }
3599
+ #data;
3600
+ /** Get a snapshot of the transaction data, in JSON form: */
3601
+ getData() {
3602
+ return this.#data.snapshot();
3603
+ }
3604
+ get [TRANSACTION_BRAND]() {
3605
+ return true;
3606
+ }
3607
+ get pure() {
3608
+ Object.defineProperty(this, "pure", {
3609
+ enumerable: false,
3610
+ value: createPure((value) => {
3611
+ if (isSerializedBcs(value)) return this.#addInput("pure", {
3612
+ $kind: "Pure",
3613
+ Pure: { bytes: value.toBase64() }
3614
+ });
3615
+ return this.#addInput("pure", is(NormalizedCallArg, value) ? parse(NormalizedCallArg, value) : value instanceof Uint8Array ? Inputs.Pure(value) : {
3616
+ $kind: "UnresolvedPure",
3617
+ UnresolvedPure: { value }
3618
+ });
3619
+ })
3620
+ });
3621
+ return this.pure;
3622
+ }
3623
+ constructor() {
3624
+ this.object = createObjectMethods((value) => {
3625
+ if (typeof value === "function") return this.object(this.add(value));
3626
+ if (typeof value === "object" && is(ArgumentSchema, value)) return value;
3627
+ const id = getIdFromCallArg(value);
3628
+ const inserted = this.#data.inputs.find((i) => id === getIdFromCallArg(i));
3629
+ if (inserted?.Object?.SharedObject && typeof value === "object" && value.Object?.SharedObject) inserted.Object.SharedObject.mutable = inserted.Object.SharedObject.mutable || value.Object.SharedObject.mutable;
3630
+ return inserted ? {
3631
+ $kind: "Input",
3632
+ Input: this.#data.inputs.indexOf(inserted),
3633
+ type: "object"
3634
+ } : this.#addInput("object", typeof value === "string" ? {
3635
+ $kind: "UnresolvedObject",
3636
+ UnresolvedObject: { objectId: normalizeSuiAddress(value) }
3637
+ } : value);
3638
+ });
3639
+ this.#data = new TransactionDataBuilder();
3640
+ this.#buildPlugins = [];
3641
+ this.#serializationPlugins = [];
3642
+ }
3643
+ /** Returns an argument for the gas coin, to be used in a transaction. */
3644
+ get gas() {
3645
+ return {
3646
+ $kind: "GasCoin",
3647
+ GasCoin: true
3648
+ };
3649
+ }
3650
+ /**
3651
+ * Add a new object input to the transaction using the fully-resolved object reference.
3652
+ * If you only have an object ID, use `builder.object(id)` instead.
3653
+ */
3654
+ objectRef(...args) {
3655
+ return this.object(Inputs.ObjectRef(...args));
3656
+ }
3657
+ /**
3658
+ * Add a new receiving input to the transaction using the fully-resolved object reference.
3659
+ * If you only have an object ID, use `builder.object(id)` instead.
3660
+ */
3661
+ receivingRef(...args) {
3662
+ return this.object(Inputs.ReceivingRef(...args));
3663
+ }
3664
+ /**
3665
+ * Add a new shared object input to the transaction using the fully-resolved shared object reference.
3666
+ * If you only have an object ID, use `builder.object(id)` instead.
3667
+ */
3668
+ sharedObjectRef(...args) {
3669
+ return this.object(Inputs.SharedObjectRef(...args));
3670
+ }
3671
+ #fork() {
3672
+ const fork = new Transaction2();
3673
+ fork.#data = this.#data;
3674
+ fork.#serializationPlugins = this.#serializationPlugins;
3675
+ fork.#buildPlugins = this.#buildPlugins;
3676
+ fork.#intentResolvers = this.#intentResolvers;
3677
+ fork.#pendingPromises = this.#pendingPromises;
3678
+ fork.#availableResults = new Set(this.#availableResults);
3679
+ fork.#added = this.#added;
3680
+ this.#inputSection.push(fork.#inputSection);
3681
+ this.#commandSection.push(fork.#commandSection);
3682
+ return fork;
3683
+ }
3684
+ add(command) {
3685
+ if (typeof command === "function") {
3686
+ if (this.#added.has(command)) return this.#added.get(command);
3687
+ const fork = this.#fork();
3688
+ const result = command(fork);
3689
+ if (!(result && typeof result === "object" && "then" in result)) {
3690
+ this.#availableResults = fork.#availableResults;
3691
+ this.#added.set(command, result);
3692
+ return result;
3693
+ }
3694
+ const placeholder = this.#addCommand({
3695
+ $kind: "$Intent",
3696
+ $Intent: {
3697
+ name: "AsyncTransactionThunk",
3698
+ inputs: {},
3699
+ data: {
3700
+ resultIndex: this.#data.commands.length,
3701
+ result: null
3702
+ }
3703
+ }
3704
+ });
3705
+ this.#pendingPromises.add(Promise.resolve(result).then((result$1) => {
3706
+ placeholder.$Intent.data.result = result$1;
3707
+ }));
3708
+ const txResult = createTransactionResult(() => placeholder.$Intent.data.resultIndex);
3709
+ this.#added.set(command, txResult);
3710
+ return txResult;
3711
+ } else this.#addCommand(command);
3712
+ return createTransactionResult(this.#data.commands.length - 1);
3713
+ }
3714
+ #addCommand(command) {
3715
+ const resultIndex = this.#data.commands.length;
3716
+ this.#commandSection.push(command);
3717
+ this.#availableResults.add(resultIndex);
3718
+ this.#data.commands.push(command);
3719
+ this.#data.mapCommandArguments(resultIndex, (arg) => {
3720
+ if (arg.$kind === "Result" && !this.#availableResults.has(arg.Result)) throw new Error(`Result { Result: ${arg.Result} } is not available to use in the current transaction`);
3721
+ if (arg.$kind === "NestedResult" && !this.#availableResults.has(arg.NestedResult[0])) throw new Error(`Result { NestedResult: [${arg.NestedResult[0]}, ${arg.NestedResult[1]}] } is not available to use in the current transaction`);
3722
+ if (arg.$kind === "Input" && arg.Input >= this.#data.inputs.length) throw new Error(`Input { Input: ${arg.Input} } references an input that does not exist in the current transaction`);
3723
+ return arg;
3724
+ });
3725
+ return command;
3726
+ }
3727
+ #addInput(type, input) {
3728
+ this.#inputSection.push(input);
3729
+ return this.#data.addInput(type, input);
3730
+ }
3731
+ #normalizeTransactionArgument(arg) {
3732
+ if (isSerializedBcs(arg)) return this.pure(arg);
3733
+ return this.#resolveArgument(arg);
3734
+ }
3735
+ #resolveArgument(arg) {
3736
+ if (typeof arg === "function") {
3737
+ const resolved = this.add(arg);
3738
+ if (typeof resolved === "function") return this.#resolveArgument(resolved);
3739
+ return parse(ArgumentSchema, resolved);
3740
+ }
3741
+ return parse(ArgumentSchema, arg);
3742
+ }
3743
+ splitCoins(coin, amounts) {
3744
+ const command = TransactionCommands.SplitCoins(typeof coin === "string" ? this.object(coin) : this.#resolveArgument(coin), amounts.map((amount) => typeof amount === "number" || typeof amount === "bigint" || typeof amount === "string" ? this.pure.u64(amount) : this.#normalizeTransactionArgument(amount)));
3745
+ this.#addCommand(command);
3746
+ return createTransactionResult(this.#data.commands.length - 1, amounts.length);
3747
+ }
3748
+ mergeCoins(destination, sources) {
3749
+ return this.add(TransactionCommands.MergeCoins(this.object(destination), sources.map((src) => this.object(src))));
3750
+ }
3751
+ publish({ modules, dependencies }) {
3752
+ return this.add(TransactionCommands.Publish({
3753
+ modules,
3754
+ dependencies
3755
+ }));
3756
+ }
3757
+ upgrade({ modules, dependencies, package: packageId, ticket }) {
3758
+ return this.add(TransactionCommands.Upgrade({
3759
+ modules,
3760
+ dependencies,
3761
+ package: packageId,
3762
+ ticket: this.object(ticket)
3763
+ }));
3764
+ }
3765
+ moveCall({ arguments: args, ...input }) {
3766
+ return this.add(TransactionCommands.MoveCall({
3767
+ ...input,
3768
+ arguments: args?.map((arg) => this.#normalizeTransactionArgument(arg))
3769
+ }));
3770
+ }
3771
+ transferObjects(objects, address) {
3772
+ return this.add(TransactionCommands.TransferObjects(objects.map((obj) => this.object(obj)), typeof address === "string" ? this.pure.address(address) : this.#normalizeTransactionArgument(address)));
3773
+ }
3774
+ makeMoveVec({ type, elements }) {
3775
+ return this.add(TransactionCommands.MakeMoveVec({
3776
+ type,
3777
+ elements: elements.map((obj) => this.object(obj))
3778
+ }));
3779
+ }
3780
+ /**
3781
+ * Create a FundsWithdrawal input for withdrawing Balance<T> from an address balance accumulator.
3782
+ * This is used for gas payments from address balances.
3783
+ *
3784
+ * @param options.amount - The Amount to withdraw (u64).
3785
+ * @param options.type - The balance type (e.g., "0x2::sui::SUI"). Defaults to SUI.
3786
+ */
3787
+ withdrawal({ amount, type }) {
3788
+ const input = {
3789
+ $kind: "FundsWithdrawal",
3790
+ FundsWithdrawal: {
3791
+ reservation: {
3792
+ $kind: "MaxAmountU64",
3793
+ MaxAmountU64: String(amount)
3794
+ },
3795
+ typeArg: {
3796
+ $kind: "Balance",
3797
+ Balance: type ?? "0x2::sui::SUI"
3798
+ },
3799
+ withdrawFrom: {
3800
+ $kind: "Sender",
3801
+ Sender: true
3802
+ }
3803
+ }
3804
+ };
3805
+ return this.#addInput("object", input);
3806
+ }
3807
+ /**
3808
+ * @deprecated Use toJSON instead.
3809
+ * For synchronous serialization, you can use `getData()`
3810
+ * */
3811
+ serialize() {
3812
+ return JSON.stringify(serializeV1TransactionData(this.#data.snapshot()));
3813
+ }
3814
+ async toJSON(options = {}) {
3815
+ await this.prepareForSerialization(options);
3816
+ const fullyResolved = this.isFullyResolved();
3817
+ return JSON.stringify(parse(SerializedTransactionDataV2Schema, fullyResolved ? {
3818
+ ...this.#data.snapshot(),
3819
+ digest: this.#data.getDigest()
3820
+ } : this.#data.snapshot()), (_key, value) => typeof value === "bigint" ? value.toString() : value, 2);
3821
+ }
3822
+ /** Build the transaction to BCS bytes, and sign it with the provided keypair. */
3823
+ async sign(options) {
3824
+ const { signer, ...buildOptions } = options;
3825
+ const bytes = await this.build(buildOptions);
3826
+ return signer.signTransaction(bytes);
3827
+ }
3828
+ /**
3829
+ * Checks if the transaction is prepared for serialization to JSON.
3830
+ * This means:
3831
+ * - All async thunks have been fully resolved
3832
+ * - All transaction intents have been resolved (unless in supportedIntents)
3833
+ *
3834
+ * Unlike `isFullyResolved()`, this does not require the sender, gas payment,
3835
+ * budget, or object versions to be set.
3836
+ */
3837
+ isPreparedForSerialization(options = {}) {
3838
+ if (this.#pendingPromises.size > 0) return false;
3839
+ if (this.#data.commands.some((cmd) => cmd.$Intent && !options.supportedIntents?.includes(cmd.$Intent.name))) return false;
3840
+ return true;
3841
+ }
3842
+ /**
3843
+ * Ensures that:
3844
+ * - All objects have been fully resolved to a specific version
3845
+ * - All pure inputs have been serialized to bytes
3846
+ * - All async thunks have been fully resolved
3847
+ * - All transaction intents have been resolved
3848
+ * - The gas payment, budget, and price have been set
3849
+ * - The transaction sender has been set
3850
+ *
3851
+ * When true, the transaction will always be built to the same bytes and digest (unless the transaction is mutated)
3852
+ */
3853
+ isFullyResolved() {
3854
+ if (!this.isPreparedForSerialization()) return false;
3855
+ if (!this.#data.sender) return false;
3856
+ if (needsTransactionResolution(this.#data, {})) return false;
3857
+ return true;
3858
+ }
3859
+ /** Build the transaction to BCS bytes. */
3860
+ async build(options = {}) {
3861
+ await this.prepareForSerialization(options);
3862
+ await this.#prepareBuild(options);
3863
+ return this.#data.build({ onlyTransactionKind: options.onlyTransactionKind });
3864
+ }
3865
+ /** Derive transaction digest */
3866
+ async getDigest(options = {}) {
3867
+ await this.prepareForSerialization(options);
3868
+ await this.#prepareBuild(options);
3869
+ return this.#data.getDigest();
3870
+ }
3871
+ /**
3872
+ * Prepare the transaction by validating the transaction data and resolving all inputs
3873
+ * so that it can be built into bytes.
3874
+ */
3875
+ async #prepareBuild(options) {
3876
+ if (!options.onlyTransactionKind && !this.#data.sender) throw new Error("Missing transaction sender");
3877
+ await this.#runPlugins([...this.#buildPlugins, resolveTransactionPlugin], options);
3878
+ }
3879
+ async #runPlugins(plugins, options) {
3880
+ try {
3881
+ const createNext = (i) => {
3882
+ if (i >= plugins.length) return () => {
3883
+ };
3884
+ const plugin = plugins[i];
3885
+ return async () => {
3886
+ const next = createNext(i + 1);
3887
+ let calledNext = false;
3888
+ let nextResolved = false;
3889
+ await plugin(this.#data, options, async () => {
3890
+ if (calledNext) throw new Error(`next() was call multiple times in TransactionPlugin ${i}`);
3891
+ calledNext = true;
3892
+ await next();
3893
+ nextResolved = true;
3894
+ });
3895
+ if (!calledNext) throw new Error(`next() was not called in TransactionPlugin ${i}`);
3896
+ if (!nextResolved) throw new Error(`next() was not awaited in TransactionPlugin ${i}`);
3897
+ };
3898
+ };
3899
+ await createNext(0)();
3900
+ } finally {
3901
+ this.#inputSection = this.#data.inputs.slice();
3902
+ this.#commandSection = this.#data.commands.slice();
3903
+ this.#availableResults = new Set(this.#commandSection.map((_, i) => i));
3904
+ }
3905
+ }
3906
+ async #waitForPendingTasks() {
3907
+ while (this.#pendingPromises.size > 0) {
3908
+ const newPromise = Promise.all(this.#pendingPromises);
3909
+ this.#pendingPromises.clear();
3910
+ this.#pendingPromises.add(newPromise);
3911
+ await newPromise;
3912
+ this.#pendingPromises.delete(newPromise);
3913
+ }
3914
+ }
3915
+ #sortCommandsAndInputs() {
3916
+ const unorderedCommands = this.#data.commands;
3917
+ const unorderedInputs = this.#data.inputs;
3918
+ const orderedCommands = this.#commandSection.flat(Infinity);
3919
+ const orderedInputs = this.#inputSection.flat(Infinity);
3920
+ if (orderedCommands.length !== unorderedCommands.length) throw new Error("Unexpected number of commands found in transaction data");
3921
+ if (orderedInputs.length !== unorderedInputs.length) throw new Error("Unexpected number of inputs found in transaction data");
3922
+ const filteredCommands = orderedCommands.filter((cmd) => cmd.$Intent?.name !== "AsyncTransactionThunk");
3923
+ this.#data.commands = filteredCommands;
3924
+ this.#data.inputs = orderedInputs;
3925
+ this.#commandSection = filteredCommands;
3926
+ this.#inputSection = orderedInputs;
3927
+ this.#availableResults = new Set(filteredCommands.map((_, i) => i));
3928
+ function getOriginalIndex(index) {
3929
+ const command = unorderedCommands[index];
3930
+ if (command.$Intent?.name === "AsyncTransactionThunk") {
3931
+ const result = command.$Intent.data.result;
3932
+ if (result == null) throw new Error("AsyncTransactionThunk has not been resolved");
3933
+ return getOriginalIndex(result.Result);
3934
+ }
3935
+ const updated = filteredCommands.indexOf(command);
3936
+ if (updated === -1) throw new Error("Unable to find original index for command");
3937
+ return updated;
3938
+ }
3939
+ this.#data.mapArguments((arg) => {
3940
+ if (arg.$kind === "Input") {
3941
+ const updated = orderedInputs.indexOf(unorderedInputs[arg.Input]);
3942
+ if (updated === -1) throw new Error("Input has not been resolved");
3943
+ return {
3944
+ ...arg,
3945
+ Input: updated
3946
+ };
3947
+ } else if (arg.$kind === "Result") {
3948
+ const updated = getOriginalIndex(arg.Result);
3949
+ return {
3950
+ ...arg,
3951
+ Result: updated
3952
+ };
3953
+ } else if (arg.$kind === "NestedResult") {
3954
+ const updated = getOriginalIndex(arg.NestedResult[0]);
3955
+ return {
3956
+ ...arg,
3957
+ NestedResult: [updated, arg.NestedResult[1]]
3958
+ };
3959
+ }
3960
+ return arg;
3961
+ });
3962
+ for (const [i, cmd] of unorderedCommands.entries()) if (cmd.$Intent?.name === "AsyncTransactionThunk") try {
3963
+ cmd.$Intent.data.resultIndex = getOriginalIndex(i);
3964
+ } catch {
3965
+ }
3966
+ }
3967
+ async prepareForSerialization(options) {
3968
+ await this.#waitForPendingTasks();
3969
+ this.#sortCommandsAndInputs();
3970
+ const intents = /* @__PURE__ */ new Set();
3971
+ for (const command of this.#data.commands) if (command.$Intent) intents.add(command.$Intent.name);
3972
+ const steps = [...this.#serializationPlugins];
3973
+ for (const intent of intents) {
3974
+ if (options.supportedIntents?.includes(intent)) continue;
3975
+ if (!this.#intentResolvers.has(intent)) throw new Error(`Missing intent resolver for ${intent}`);
3976
+ steps.push(this.#intentResolvers.get(intent));
3977
+ }
3978
+ steps.push(namedPackagesPlugin());
3979
+ await this.#runPlugins(steps, options);
3980
+ }
3981
+ };
3982
+
3983
+ export {
3984
+ TypeTagSerializer,
3985
+ normalizeTypeTag,
3986
+ init_type_tag_serializer,
3987
+ ExecutionStatus,
3988
+ init_effects,
3989
+ suiBcs,
3990
+ bcs_exports,
3991
+ init_bcs2 as init_bcs,
3992
+ TransactionDataBuilder,
3993
+ SUI_DECIMALS,
3994
+ MIST_PER_SUI,
3995
+ MOVE_STDLIB_ADDRESS,
3996
+ SUI_FRAMEWORK_ADDRESS,
3997
+ SUI_SYSTEM_ADDRESS,
3998
+ SUI_CLOCK_OBJECT_ID,
3999
+ SUI_SYSTEM_MODULE_NAME,
4000
+ SUI_TYPE_ARG,
4001
+ SUI_SYSTEM_STATE_OBJECT_ID,
4002
+ SUI_RANDOM_OBJECT_ID,
4003
+ SUI_COIN_REGISTRY_OBJECT_ID,
4004
+ SUI_DENY_LIST_OBJECT_ID,
4005
+ init_constants,
4006
+ coinWithBalance,
4007
+ ObjectError,
4008
+ coreClientResolveTransactionPlugin,
4009
+ PACKAGE_VERSION,
4010
+ TARGETED_RPC_VERSION,
4011
+ MvrClient,
4012
+ hasMvrName,
4013
+ isTransaction,
4014
+ Transaction
4015
+ };
4016
+ //# sourceMappingURL=chunk-KHIL2KNW.js.map