@t2000/cli 0.22.25 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +11 -97
  2. package/dist/{ccip-JEEJV65M.js → ccip-XP27NGI7.js} +3 -3
  3. package/dist/{chunk-A5X4KG7U.js → chunk-3I6VJOM6.js} +210 -970
  4. package/dist/chunk-3I6VJOM6.js.map +1 -0
  5. package/dist/chunk-4N76GQCL.js +35382 -0
  6. package/dist/chunk-4N76GQCL.js.map +1 -0
  7. package/dist/{chunk-XOAZJ42V.js → chunk-DWOZSUBE.js} +588 -584
  8. package/dist/{chunk-XOAZJ42V.js.map → chunk-DWOZSUBE.js.map} +1 -1
  9. package/dist/chunk-EI3GHTKX.js +968 -0
  10. package/dist/chunk-EI3GHTKX.js.map +1 -0
  11. package/dist/{chunk-EEPD7SHV.js → chunk-TYYJRUQI.js} +15755 -15918
  12. package/dist/chunk-TYYJRUQI.js.map +1 -0
  13. package/dist/client-5KJQTN5X.js +84 -0
  14. package/dist/client-5KJQTN5X.js.map +1 -0
  15. package/dist/{client-R3NRAXMD.js → client-IXUBQ3HM.js} +334 -638
  16. package/dist/client-IXUBQ3HM.js.map +1 -0
  17. package/dist/{dist-LKHCKFGY.js → dist-E7HUP73Q.js} +5 -29
  18. package/dist/{dist-ZTFOTMJO.js → dist-W4Q4YXD7.js} +4200 -603
  19. package/dist/dist-W4Q4YXD7.js.map +1 -0
  20. package/dist/index.js +29 -1016
  21. package/dist/index.js.map +1 -1
  22. package/package.json +5 -6
  23. package/dist/chunk-77SWBATH.js +0 -204
  24. package/dist/chunk-77SWBATH.js.map +0 -1
  25. package/dist/chunk-A5X4KG7U.js.map +0 -1
  26. package/dist/chunk-EEPD7SHV.js.map +0 -1
  27. package/dist/chunk-FM4762OE.js +0 -77733
  28. package/dist/chunk-FM4762OE.js.map +0 -1
  29. package/dist/client-CK5OR2TP.js +0 -746
  30. package/dist/client-CK5OR2TP.js.map +0 -1
  31. package/dist/client-R3NRAXMD.js.map +0 -1
  32. package/dist/dist-ZTFOTMJO.js.map +0 -1
  33. /package/dist/{ccip-JEEJV65M.js.map → ccip-XP27NGI7.js.map} +0 -0
  34. /package/dist/{dist-LKHCKFGY.js.map → dist-E7HUP73Q.js.map} +0 -0
@@ -117,7 +117,7 @@ function IntentMessage(T) {
117
117
  value: T
118
118
  });
119
119
  }
120
- var Address, ObjectDigest, SuiObjectRef, SharedObjectRef, ObjectArg2, Owner, Reservation, WithdrawalType, WithdrawFrom, FundsWithdrawal, CallArg, InnerTypeTag, TypeTag2, Argument, ProgrammableMoveCall, Command, ProgrammableTransaction, TransactionKind, ValidDuring, TransactionExpiration3, StructTag2, GasData, TransactionDataV1, TransactionData, IntentScope, IntentVersion, AppId, Intent, CompressedSignature, PublicKey, MultiSigPkMap, MultiSigPublicKey, MultiSig, base64String, SenderSignedTransaction, SenderSignedData, PasskeyAuthenticator, MoveObjectType, TypeOrigin, UpgradeInfo, MovePackage, MoveObject, Data, ObjectInner;
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
121
  var init_bcs = __esm({
122
122
  "../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/bcs/bcs.mjs"() {
123
123
  "use strict";
@@ -150,7 +150,7 @@ var init_bcs = __esm({
150
150
  initialSharedVersion: bcs.u64(),
151
151
  mutable: bcs.bool()
152
152
  });
153
- ObjectArg2 = bcs.enum("ObjectArg", {
153
+ ObjectArg = bcs.enum("ObjectArg", {
154
154
  ImmOrOwnedObject: SuiObjectRef,
155
155
  SharedObject: SharedObjectRef,
156
156
  Receiving: SuiObjectRef
@@ -166,7 +166,7 @@ var init_bcs = __esm({
166
166
  })
167
167
  });
168
168
  Reservation = bcs.enum("Reservation", { MaxAmountU64: bcs.u64() });
169
- WithdrawalType = bcs.enum("WithdrawalType", { Balance: bcs.lazy(() => TypeTag2) });
169
+ WithdrawalType = bcs.enum("WithdrawalType", { Balance: bcs.lazy(() => TypeTag) });
170
170
  WithdrawFrom = bcs.enum("WithdrawFrom", {
171
171
  Sender: null,
172
172
  Sponsor: null
@@ -181,7 +181,7 @@ var init_bcs = __esm({
181
181
  input: (val) => typeof val === "string" ? fromBase64(val) : val,
182
182
  output: (val) => toBase64(new Uint8Array(val))
183
183
  }) }),
184
- Object: ObjectArg2,
184
+ Object: ObjectArg,
185
185
  FundsWithdrawal
186
186
  });
187
187
  InnerTypeTag = bcs.enum("TypeTag", {
@@ -192,12 +192,12 @@ var init_bcs = __esm({
192
192
  address: null,
193
193
  signer: null,
194
194
  vector: bcs.lazy(() => InnerTypeTag),
195
- struct: bcs.lazy(() => StructTag2),
195
+ struct: bcs.lazy(() => StructTag),
196
196
  u16: null,
197
197
  u32: null,
198
198
  u256: null
199
199
  });
200
- TypeTag2 = InnerTypeTag.transform({
200
+ TypeTag = InnerTypeTag.transform({
201
201
  input: (typeTag) => typeof typeTag === "string" ? TypeTagSerializer.parseFromStr(typeTag, true) : typeTag,
202
202
  output: (typeTag) => TypeTagSerializer.tagToString(typeTag)
203
203
  });
@@ -211,7 +211,7 @@ var init_bcs = __esm({
211
211
  package: Address,
212
212
  module: bcs.string(),
213
213
  function: bcs.string(),
214
- typeArguments: bcs.vector(TypeTag2),
214
+ typeArguments: bcs.vector(TypeTag),
215
215
  arguments: bcs.vector(Argument)
216
216
  });
217
217
  Command = bcs.enum("Command", {
@@ -236,7 +236,7 @@ var init_bcs = __esm({
236
236
  dependencies: bcs.vector(Address)
237
237
  }),
238
238
  MakeMoveVec: bcs.struct("MakeMoveVec", {
239
- type: optionEnum(TypeTag2).transform({
239
+ type: optionEnum(TypeTag).transform({
240
240
  input: (val) => val === null ? { None: true } : { Some: val },
241
241
  output: (val) => val.Some ?? null
242
242
  }),
@@ -270,12 +270,12 @@ var init_bcs = __esm({
270
270
  chain: ObjectDigest,
271
271
  nonce: bcs.u32()
272
272
  });
273
- TransactionExpiration3 = bcs.enum("TransactionExpiration", {
273
+ TransactionExpiration = bcs.enum("TransactionExpiration", {
274
274
  None: null,
275
275
  Epoch: unsafe_u64(),
276
276
  ValidDuring
277
277
  });
278
- StructTag2 = bcs.struct("StructTag", {
278
+ StructTag = bcs.struct("StructTag", {
279
279
  address: Address,
280
280
  module: bcs.string(),
281
281
  name: bcs.string(),
@@ -291,7 +291,7 @@ var init_bcs = __esm({
291
291
  kind: TransactionKind,
292
292
  sender: Address,
293
293
  gasData: GasData,
294
- expiration: TransactionExpiration3
294
+ expiration: TransactionExpiration
295
295
  });
296
296
  TransactionData = bcs.enum("TransactionData", { V1: TransactionDataV1 });
297
297
  IntentScope = bcs.enum("IntentScope", {
@@ -349,10 +349,10 @@ var init_bcs = __esm({
349
349
  userSignature: bcs.byteVector()
350
350
  });
351
351
  MoveObjectType = bcs.enum("MoveObjectType", {
352
- Other: StructTag2,
352
+ Other: StructTag,
353
353
  GasCoin: null,
354
354
  StakedSui: null,
355
- Coin: TypeTag2,
355
+ Coin: TypeTag,
356
356
  AccumulatorBalanceWrapper: null
357
357
  });
358
358
  TypeOrigin = bcs.struct("TypeOrigin", {
@@ -557,7 +557,7 @@ var init_effects = __esm({
557
557
  });
558
558
  AccumulatorAddress = bcs.struct("AccumulatorAddress", {
559
559
  address: Address,
560
- ty: TypeTag2
560
+ ty: TypeTag
561
561
  });
562
562
  AccumulatorOperation = bcs.enum("AccumulatorOperation", {
563
563
  Merge: null,
@@ -706,7 +706,7 @@ var init_bcs2 = __esm({
706
706
  MultiSigPkMap,
707
707
  MultiSigPublicKey,
708
708
  Object: ObjectInner,
709
- ObjectArg: ObjectArg2,
709
+ ObjectArg,
710
710
  ObjectDigest,
711
711
  Owner,
712
712
  PasskeyAuthenticator,
@@ -716,15 +716,15 @@ var init_bcs2 = __esm({
716
716
  SenderSignedData,
717
717
  SenderSignedTransaction,
718
718
  SharedObjectRef,
719
- StructTag: StructTag2,
719
+ StructTag,
720
720
  SuiObjectRef,
721
721
  TransactionData,
722
722
  TransactionDataV1,
723
723
  TransactionEffects,
724
- TransactionExpiration: TransactionExpiration3,
724
+ TransactionExpiration,
725
725
  TransactionKind,
726
726
  TypeOrigin,
727
- TypeTag: TypeTag2,
727
+ TypeTag,
728
728
  UpgradeInfo
729
729
  };
730
730
  }
@@ -750,7 +750,11 @@ var init_constants = __esm({
750
750
  }
751
751
  });
752
752
 
753
- // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/Transaction.mjs
753
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/intents/CoinWithBalance.mjs
754
+ init_sui_types();
755
+ init_bcs2();
756
+
757
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/Commands.mjs
754
758
  init_sui_types();
755
759
 
756
760
  // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/data/internal.mjs
@@ -1588,7 +1592,7 @@ var ValidDuringSchema = object({
1588
1592
  chain: string(),
1589
1593
  nonce: U32
1590
1594
  });
1591
- var TransactionExpiration = safeEnum({
1595
+ var TransactionExpiration2 = safeEnum({
1592
1596
  None: literal(true),
1593
1597
  Epoch: JsonU64,
1594
1598
  ValidDuring: ValidDuringSchema
@@ -1596,234 +1600,571 @@ var TransactionExpiration = safeEnum({
1596
1600
  var TransactionDataSchema = object({
1597
1601
  version: literal(2),
1598
1602
  sender: nullish(SuiAddress),
1599
- expiration: nullish(TransactionExpiration),
1603
+ expiration: nullish(TransactionExpiration2),
1600
1604
  gasData: GasDataSchema,
1601
1605
  inputs: array(CallArgSchema),
1602
1606
  commands: array(CommandSchema)
1603
1607
  });
1604
1608
 
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();
1609
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/Commands.mjs
1607
1610
  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 ObjectArg = 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: ObjectArg,
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 TransactionExpiration2 = 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 TypeTag = 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(() => TypeTag) }),
1667
- object({ struct: lazy(() => StructTag) }),
1668
- object({ u16: nullable(literal(true)) }),
1669
- object({ u32: nullable(literal(true)) }),
1670
- object({ u256: nullable(literal(true)) })
1671
- ]);
1672
- var StructTag = object({
1673
- address: string(),
1674
- module: string(),
1675
- name: string(),
1676
- typeParams: array(TypeTag)
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: TypeTag }), 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(TransactionExpiration2),
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"
1611
+ var TransactionCommands = {
1612
+ MoveCall(input) {
1613
+ const [pkg, mod = "", fn = ""] = "target" in input ? input.target.split("::") : [
1614
+ input.package,
1615
+ input.module,
1616
+ input.function
1617
+ ];
1618
+ return {
1619
+ $kind: "MoveCall",
1620
+ MoveCall: {
1621
+ package: pkg,
1622
+ module: mod,
1623
+ function: fn,
1624
+ typeArguments: input.typeArguments ?? [],
1625
+ arguments: input.arguments ?? []
1626
+ }
1766
1627
  };
1767
- if (input.Pure) return {
1768
- kind: "Input",
1769
- index,
1770
- value: { Pure: Array.from(fromBase64(input.Pure.bytes)) },
1771
- type: "pure"
1628
+ },
1629
+ TransferObjects(objects, address) {
1630
+ return {
1631
+ $kind: "TransferObjects",
1632
+ TransferObjects: {
1633
+ objects: objects.map((o) => parse(ArgumentSchema, o)),
1634
+ address: parse(ArgumentSchema, address)
1635
+ }
1772
1636
  };
1773
- if (input.UnresolvedPure) return {
1774
- kind: "Input",
1775
- type: "pure",
1776
- index,
1777
- value: input.UnresolvedPure.value
1637
+ },
1638
+ SplitCoins(coin, amounts) {
1639
+ return {
1640
+ $kind: "SplitCoins",
1641
+ SplitCoins: {
1642
+ coin: parse(ArgumentSchema, coin),
1643
+ amounts: amounts.map((o) => parse(ArgumentSchema, o))
1644
+ }
1778
1645
  };
1779
- if (input.UnresolvedObject) return {
1780
- kind: "Input",
1781
- type: "object",
1782
- index,
1783
- value: input.UnresolvedObject.objectId
1646
+ },
1647
+ MergeCoins(destination, sources) {
1648
+ return {
1649
+ $kind: "MergeCoins",
1650
+ MergeCoins: {
1651
+ destination: parse(ArgumentSchema, destination),
1652
+ sources: sources.map((o) => parse(ArgumentSchema, o))
1653
+ }
1784
1654
  };
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",
1655
+ },
1656
+ Publish({ modules, dependencies }) {
1657
+ return {
1658
+ $kind: "Publish",
1659
+ Publish: {
1660
+ modules: modules.map((module) => typeof module === "string" ? module : toBase64(new Uint8Array(module))),
1661
+ dependencies: dependencies.map((dep) => normalizeSuiObjectId(dep))
1662
+ }
1663
+ };
1664
+ },
1665
+ Upgrade({ modules, dependencies, package: packageId, ticket }) {
1666
+ return {
1667
+ $kind: "Upgrade",
1668
+ Upgrade: {
1669
+ modules: modules.map((module) => typeof module === "string" ? module : toBase64(new Uint8Array(module))),
1670
+ dependencies: dependencies.map((dep) => normalizeSuiObjectId(dep)),
1671
+ package: packageId,
1672
+ ticket: parse(ArgumentSchema, ticket)
1673
+ }
1674
+ };
1675
+ },
1676
+ MakeMoveVec({ type, elements }) {
1677
+ return {
1678
+ $kind: "MakeMoveVec",
1679
+ MakeMoveVec: {
1680
+ type: type ?? null,
1681
+ elements: elements.map((o) => parse(ArgumentSchema, o))
1682
+ }
1683
+ };
1684
+ },
1685
+ Intent({ name, inputs = {}, data = {} }) {
1686
+ return {
1687
+ $kind: "$Intent",
1688
+ $Intent: {
1689
+ name,
1690
+ inputs: Object.fromEntries(Object.entries(inputs).map(([key, value]) => [key, Array.isArray(value) ? value.map((o) => parse(ArgumentSchema, o)) : parse(ArgumentSchema, value)])),
1691
+ data
1692
+ }
1693
+ };
1694
+ }
1695
+ };
1696
+
1697
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/Inputs.mjs
1698
+ init_sui_types();
1699
+ init_dist2();
1700
+ function Pure(data) {
1701
+ return {
1702
+ $kind: "Pure",
1703
+ Pure: { bytes: data instanceof Uint8Array ? toBase64(data) : data.toBase64() }
1704
+ };
1705
+ }
1706
+ var Inputs = {
1707
+ Pure,
1708
+ ObjectRef({ objectId, digest, version }) {
1709
+ return {
1710
+ $kind: "Object",
1711
+ Object: {
1712
+ $kind: "ImmOrOwnedObject",
1713
+ ImmOrOwnedObject: {
1714
+ digest,
1715
+ version,
1716
+ objectId: normalizeSuiAddress(objectId)
1717
+ }
1718
+ }
1719
+ };
1720
+ },
1721
+ SharedObjectRef({ objectId, mutable, initialSharedVersion }) {
1722
+ return {
1723
+ $kind: "Object",
1724
+ Object: {
1725
+ $kind: "SharedObject",
1726
+ SharedObject: {
1727
+ mutable,
1728
+ initialSharedVersion,
1729
+ objectId: normalizeSuiAddress(objectId)
1730
+ }
1731
+ }
1732
+ };
1733
+ },
1734
+ ReceivingRef({ objectId, digest, version }) {
1735
+ return {
1736
+ $kind: "Object",
1737
+ Object: {
1738
+ $kind: "Receiving",
1739
+ Receiving: {
1740
+ digest,
1741
+ version,
1742
+ objectId: normalizeSuiAddress(objectId)
1743
+ }
1744
+ }
1745
+ };
1746
+ },
1747
+ FundsWithdrawal({ reservation, typeArg, withdrawFrom }) {
1748
+ return {
1749
+ $kind: "FundsWithdrawal",
1750
+ FundsWithdrawal: {
1751
+ reservation,
1752
+ typeArg,
1753
+ withdrawFrom
1754
+ }
1755
+ };
1756
+ }
1757
+ };
1758
+
1759
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/intents/CoinWithBalance.mjs
1760
+ var COIN_WITH_BALANCE = "CoinWithBalance";
1761
+ var SUI_TYPE = normalizeStructTag("0x2::sui::SUI");
1762
+ function coinWithBalance({ type = SUI_TYPE, balance, useGasCoin = true }) {
1763
+ let coinResult = null;
1764
+ return (tx) => {
1765
+ if (coinResult) return coinResult;
1766
+ tx.addIntentResolver(COIN_WITH_BALANCE, resolveCoinBalance);
1767
+ const coinType = type === "gas" ? type : normalizeStructTag(type);
1768
+ coinResult = tx.add(TransactionCommands.Intent({
1769
+ name: COIN_WITH_BALANCE,
1770
+ inputs: {},
1771
+ data: {
1772
+ type: coinType === SUI_TYPE && useGasCoin ? "gas" : coinType,
1773
+ balance: BigInt(balance)
1774
+ }
1775
+ }));
1776
+ return coinResult;
1777
+ };
1778
+ }
1779
+ var CoinWithBalanceData = object({
1780
+ type: string(),
1781
+ balance: bigint()
1782
+ });
1783
+ async function resolveCoinBalance(transactionData, buildOptions, next) {
1784
+ const coinTypes = /* @__PURE__ */ new Set();
1785
+ const totalByType = /* @__PURE__ */ new Map();
1786
+ if (!transactionData.sender) throw new Error("Sender must be set to resolve CoinWithBalance");
1787
+ for (const command of transactionData.commands) if (command.$kind === "$Intent" && command.$Intent.name === COIN_WITH_BALANCE) {
1788
+ const { type, balance } = parse(CoinWithBalanceData, command.$Intent.data);
1789
+ if (type !== "gas" && balance > 0n) coinTypes.add(type);
1790
+ totalByType.set(type, (totalByType.get(type) ?? 0n) + balance);
1791
+ }
1792
+ const usedIds = /* @__PURE__ */ new Set();
1793
+ for (const input of transactionData.inputs) {
1794
+ if (input.Object?.ImmOrOwnedObject) usedIds.add(input.Object.ImmOrOwnedObject.objectId);
1795
+ if (input.UnresolvedObject?.objectId) usedIds.add(input.UnresolvedObject.objectId);
1796
+ }
1797
+ const coinsByType = /* @__PURE__ */ new Map();
1798
+ const addressBalanceByType = /* @__PURE__ */ new Map();
1799
+ const client = buildOptions.client;
1800
+ if (!client) throw new Error("Client must be provided to build or serialize transactions with CoinWithBalance intents");
1801
+ await Promise.all([...[...coinTypes].map(async (coinType) => {
1802
+ const { coins, addressBalance } = await getCoinsAndBalanceOfType({
1803
+ coinType,
1804
+ balance: totalByType.get(coinType),
1805
+ client,
1806
+ owner: transactionData.sender,
1807
+ usedIds
1808
+ });
1809
+ coinsByType.set(coinType, coins);
1810
+ addressBalanceByType.set(coinType, addressBalance);
1811
+ }), totalByType.has("gas") ? await client.core.getBalance({
1812
+ owner: transactionData.sender,
1813
+ coinType: SUI_TYPE
1814
+ }).then(({ balance }) => {
1815
+ addressBalanceByType.set("gas", BigInt(balance.addressBalance));
1816
+ }) : null]);
1817
+ const mergedCoins = /* @__PURE__ */ new Map();
1818
+ for (const [index, transaction] of transactionData.commands.entries()) {
1819
+ if (transaction.$kind !== "$Intent" || transaction.$Intent.name !== COIN_WITH_BALANCE) continue;
1820
+ const { type, balance } = transaction.$Intent.data;
1821
+ if (balance === 0n) {
1822
+ transactionData.replaceCommand(index, TransactionCommands.MoveCall({
1823
+ target: "0x2::coin::zero",
1824
+ typeArguments: [type === "gas" ? SUI_TYPE : type]
1825
+ }));
1826
+ continue;
1827
+ }
1828
+ const commands = [];
1829
+ if (addressBalanceByType.get(type) >= totalByType.get(type)) commands.push(TransactionCommands.MoveCall({
1830
+ target: "0x2::coin::redeem_funds",
1831
+ typeArguments: [type === "gas" ? SUI_TYPE : type],
1832
+ arguments: [transactionData.addInput("withdrawal", Inputs.FundsWithdrawal({
1833
+ reservation: {
1834
+ $kind: "MaxAmountU64",
1835
+ MaxAmountU64: String(balance)
1836
+ },
1837
+ typeArg: {
1838
+ $kind: "Balance",
1839
+ Balance: type === "gas" ? SUI_TYPE : type
1840
+ },
1841
+ withdrawFrom: {
1842
+ $kind: "Sender",
1843
+ Sender: true
1844
+ }
1845
+ }))]
1846
+ }));
1847
+ else {
1848
+ if (!mergedCoins.has(type)) {
1849
+ const addressBalance = addressBalanceByType.get(type) ?? 0n;
1850
+ const coinType = type === "gas" ? SUI_TYPE : type;
1851
+ let baseCoin;
1852
+ let restCoins;
1853
+ if (type === "gas") {
1854
+ baseCoin = {
1855
+ $kind: "GasCoin",
1856
+ GasCoin: true
1857
+ };
1858
+ restCoins = [];
1859
+ } else [baseCoin, ...restCoins] = coinsByType.get(type).map((coin) => transactionData.addInput("object", Inputs.ObjectRef({
1860
+ objectId: coin.objectId,
1861
+ digest: coin.digest,
1862
+ version: coin.version
1863
+ })));
1864
+ if (addressBalance > 0n) {
1865
+ commands.push(TransactionCommands.MoveCall({
1866
+ target: "0x2::coin::redeem_funds",
1867
+ typeArguments: [coinType],
1868
+ arguments: [transactionData.addInput("withdrawal", Inputs.FundsWithdrawal({
1869
+ reservation: {
1870
+ $kind: "MaxAmountU64",
1871
+ MaxAmountU64: String(addressBalance)
1872
+ },
1873
+ typeArg: {
1874
+ $kind: "Balance",
1875
+ Balance: coinType
1876
+ },
1877
+ withdrawFrom: {
1878
+ $kind: "Sender",
1879
+ Sender: true
1880
+ }
1881
+ }))]
1882
+ }));
1883
+ commands.push(TransactionCommands.MergeCoins(baseCoin, [{
1884
+ $kind: "Result",
1885
+ Result: index + commands.length - 1
1886
+ }, ...restCoins]));
1887
+ } else if (restCoins.length > 0) commands.push(TransactionCommands.MergeCoins(baseCoin, restCoins));
1888
+ mergedCoins.set(type, baseCoin);
1889
+ }
1890
+ commands.push(TransactionCommands.SplitCoins(mergedCoins.get(type), [transactionData.addInput("pure", Inputs.Pure(suiBcs.u64().serialize(balance)))]));
1891
+ }
1892
+ transactionData.replaceCommand(index, commands);
1893
+ transactionData.mapArguments((arg, _command, commandIndex) => {
1894
+ if (commandIndex >= index && commandIndex < index + commands.length) return arg;
1895
+ if (arg.$kind === "Result" && arg.Result === index) return {
1896
+ $kind: "NestedResult",
1897
+ NestedResult: [index + commands.length - 1, 0]
1898
+ };
1899
+ return arg;
1900
+ });
1901
+ }
1902
+ return next();
1903
+ }
1904
+ async function getCoinsAndBalanceOfType({ coinType, balance, client, owner, usedIds }) {
1905
+ let remainingBalance = balance;
1906
+ const coins = [];
1907
+ const balanceRequest = client.core.getBalance({
1908
+ owner,
1909
+ coinType
1910
+ }).then(({ balance: balance$1 }) => {
1911
+ remainingBalance -= BigInt(balance$1.addressBalance);
1912
+ return balance$1;
1913
+ });
1914
+ const [allCoins, balanceResponse] = await Promise.all([loadMoreCoins(), balanceRequest]);
1915
+ if (BigInt(balanceResponse.balance) < balance) throw new Error(`Insufficient balance of ${coinType} for owner ${owner}. Required: ${balance}, Available: ${balance - remainingBalance}`);
1916
+ return {
1917
+ coins: allCoins,
1918
+ balance: BigInt(balanceResponse.coinBalance),
1919
+ addressBalance: BigInt(balanceResponse.addressBalance),
1920
+ coinBalance: BigInt(balanceResponse.coinBalance)
1921
+ };
1922
+ async function loadMoreCoins(cursor = null) {
1923
+ const { objects, hasNextPage, cursor: nextCursor } = await client.core.listCoins({
1924
+ owner,
1925
+ coinType,
1926
+ cursor
1927
+ });
1928
+ await balanceRequest;
1929
+ if (remainingBalance > 0n) {
1930
+ for (const coin of objects) {
1931
+ if (usedIds.has(coin.objectId)) continue;
1932
+ const coinBalance = BigInt(coin.balance);
1933
+ coins.push(coin);
1934
+ remainingBalance -= coinBalance;
1935
+ if (remainingBalance <= 0) break;
1936
+ }
1937
+ if (hasNextPage) return loadMoreCoins(nextCursor);
1938
+ }
1939
+ return coins;
1940
+ }
1941
+ }
1942
+
1943
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/Transaction.mjs
1944
+ init_sui_types();
1945
+
1946
+ // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/data/v1.mjs
1947
+ init_type_tag_serializer();
1948
+ init_dist2();
1949
+ var ObjectRef = object({
1950
+ digest: string(),
1951
+ objectId: string(),
1952
+ version: union([
1953
+ pipe(number(), integer()),
1954
+ string(),
1955
+ bigint()
1956
+ ])
1957
+ });
1958
+ var ObjectArg2 = safeEnum({
1959
+ ImmOrOwned: ObjectRef,
1960
+ Shared: object({
1961
+ objectId: ObjectID,
1962
+ initialSharedVersion: JsonU64,
1963
+ mutable: boolean()
1964
+ }),
1965
+ Receiving: ObjectRef
1966
+ });
1967
+ var NormalizedCallArg2 = safeEnum({
1968
+ Object: ObjectArg2,
1969
+ Pure: array(pipe(number(), integer()))
1970
+ });
1971
+ var TransactionInput = union([object({
1972
+ kind: literal("Input"),
1973
+ index: pipe(number(), integer()),
1974
+ value: unknown(),
1975
+ type: optional(literal("object"))
1976
+ }), object({
1977
+ kind: literal("Input"),
1978
+ index: pipe(number(), integer()),
1979
+ value: unknown(),
1980
+ type: literal("pure")
1981
+ })]);
1982
+ var TransactionExpiration3 = union([object({ Epoch: pipe(number(), integer()) }), object({ None: nullable(literal(true)) })]);
1983
+ var StringEncodedBigint = pipe(union([
1984
+ number(),
1985
+ string(),
1986
+ bigint()
1987
+ ]), check((val) => {
1988
+ if (![
1989
+ "string",
1990
+ "number",
1991
+ "bigint"
1992
+ ].includes(typeof val)) return false;
1993
+ try {
1994
+ BigInt(val);
1995
+ return true;
1996
+ } catch {
1997
+ return false;
1998
+ }
1999
+ }));
2000
+ var TypeTag2 = union([
2001
+ object({ bool: nullable(literal(true)) }),
2002
+ object({ u8: nullable(literal(true)) }),
2003
+ object({ u64: nullable(literal(true)) }),
2004
+ object({ u128: nullable(literal(true)) }),
2005
+ object({ address: nullable(literal(true)) }),
2006
+ object({ signer: nullable(literal(true)) }),
2007
+ object({ vector: lazy(() => TypeTag2) }),
2008
+ object({ struct: lazy(() => StructTag2) }),
2009
+ object({ u16: nullable(literal(true)) }),
2010
+ object({ u32: nullable(literal(true)) }),
2011
+ object({ u256: nullable(literal(true)) })
2012
+ ]);
2013
+ var StructTag2 = object({
2014
+ address: string(),
2015
+ module: string(),
2016
+ name: string(),
2017
+ typeParams: array(TypeTag2)
2018
+ });
2019
+ var GasConfig = object({
2020
+ budget: optional(StringEncodedBigint),
2021
+ price: optional(StringEncodedBigint),
2022
+ payment: optional(array(ObjectRef)),
2023
+ owner: optional(string())
2024
+ });
2025
+ var TransactionArgumentTypes = [
2026
+ TransactionInput,
2027
+ object({ kind: literal("GasCoin") }),
2028
+ object({
2029
+ kind: literal("Result"),
2030
+ index: pipe(number(), integer())
2031
+ }),
2032
+ object({
2033
+ kind: literal("NestedResult"),
2034
+ index: pipe(number(), integer()),
2035
+ resultIndex: pipe(number(), integer())
2036
+ })
2037
+ ];
2038
+ var TransactionArgument = union([...TransactionArgumentTypes]);
2039
+ var MoveCallTransaction = object({
2040
+ kind: literal("MoveCall"),
2041
+ target: pipe(string(), check((target) => target.split("::").length === 3)),
2042
+ typeArguments: array(string()),
2043
+ arguments: array(TransactionArgument)
2044
+ });
2045
+ var TransferObjectsTransaction = object({
2046
+ kind: literal("TransferObjects"),
2047
+ objects: array(TransactionArgument),
2048
+ address: TransactionArgument
2049
+ });
2050
+ var SplitCoinsTransaction = object({
2051
+ kind: literal("SplitCoins"),
2052
+ coin: TransactionArgument,
2053
+ amounts: array(TransactionArgument)
2054
+ });
2055
+ var MergeCoinsTransaction = object({
2056
+ kind: literal("MergeCoins"),
2057
+ destination: TransactionArgument,
2058
+ sources: array(TransactionArgument)
2059
+ });
2060
+ var MakeMoveVecTransaction = object({
2061
+ kind: literal("MakeMoveVec"),
2062
+ type: union([object({ Some: TypeTag2 }), object({ None: nullable(literal(true)) })]),
2063
+ objects: array(TransactionArgument)
2064
+ });
2065
+ var TransactionType = union([...[
2066
+ MoveCallTransaction,
2067
+ TransferObjectsTransaction,
2068
+ SplitCoinsTransaction,
2069
+ MergeCoinsTransaction,
2070
+ object({
2071
+ kind: literal("Publish"),
2072
+ modules: array(array(pipe(number(), integer()))),
2073
+ dependencies: array(string())
2074
+ }),
2075
+ object({
2076
+ kind: literal("Upgrade"),
2077
+ modules: array(array(pipe(number(), integer()))),
2078
+ dependencies: array(string()),
2079
+ packageId: string(),
2080
+ ticket: TransactionArgument
2081
+ }),
2082
+ MakeMoveVecTransaction
2083
+ ]]);
2084
+ var SerializedTransactionDataV1 = object({
2085
+ version: literal(1),
2086
+ sender: optional(string()),
2087
+ expiration: nullish(TransactionExpiration3),
2088
+ gasConfig: GasConfig,
2089
+ inputs: array(TransactionInput),
2090
+ transactions: array(TransactionType)
2091
+ });
2092
+ function serializeV1TransactionData(transactionData) {
2093
+ const inputs = transactionData.inputs.map((input, index) => {
2094
+ if (input.Object) return {
2095
+ kind: "Input",
2096
+ index,
2097
+ value: { Object: input.Object.ImmOrOwnedObject ? { ImmOrOwned: input.Object.ImmOrOwnedObject } : input.Object.Receiving ? { Receiving: {
2098
+ digest: input.Object.Receiving.digest,
2099
+ version: input.Object.Receiving.version,
2100
+ objectId: input.Object.Receiving.objectId
2101
+ } } : { Shared: {
2102
+ mutable: input.Object.SharedObject.mutable,
2103
+ initialSharedVersion: input.Object.SharedObject.initialSharedVersion,
2104
+ objectId: input.Object.SharedObject.objectId
2105
+ } } },
2106
+ type: "object"
2107
+ };
2108
+ if (input.Pure) return {
2109
+ kind: "Input",
2110
+ index,
2111
+ value: { Pure: Array.from(fromBase64(input.Pure.bytes)) },
2112
+ type: "pure"
2113
+ };
2114
+ if (input.UnresolvedPure) return {
2115
+ kind: "Input",
2116
+ type: "pure",
2117
+ index,
2118
+ value: input.UnresolvedPure.value
2119
+ };
2120
+ if (input.UnresolvedObject) return {
2121
+ kind: "Input",
2122
+ type: "object",
2123
+ index,
2124
+ value: input.UnresolvedObject.objectId
2125
+ };
2126
+ throw new Error("Invalid input");
2127
+ });
2128
+ return {
2129
+ version: 1,
2130
+ sender: transactionData.sender ?? void 0,
2131
+ expiration: transactionData.expiration?.$kind === "Epoch" ? { Epoch: Number(transactionData.expiration.Epoch) } : transactionData.expiration ? { None: true } : null,
2132
+ gasConfig: {
2133
+ owner: transactionData.gasData.owner ?? void 0,
2134
+ budget: transactionData.gasData.budget ?? void 0,
2135
+ price: transactionData.gasData.price ?? void 0,
2136
+ payment: transactionData.gasData.payment ?? void 0
2137
+ },
2138
+ inputs,
2139
+ transactions: transactionData.commands.map((command) => {
2140
+ if (command.MakeMoveVec) return {
2141
+ kind: "MakeMoveVec",
2142
+ type: command.MakeMoveVec.type === null ? { None: true } : { Some: TypeTagSerializer.parseFromStr(command.MakeMoveVec.type) },
2143
+ objects: command.MakeMoveVec.elements.map((arg) => convertTransactionArgument(arg, inputs))
2144
+ };
2145
+ if (command.MergeCoins) return {
2146
+ kind: "MergeCoins",
2147
+ destination: convertTransactionArgument(command.MergeCoins.destination, inputs),
2148
+ sources: command.MergeCoins.sources.map((arg) => convertTransactionArgument(arg, inputs))
2149
+ };
2150
+ if (command.MoveCall) return {
2151
+ kind: "MoveCall",
2152
+ target: `${command.MoveCall.package}::${command.MoveCall.module}::${command.MoveCall.function}`,
2153
+ typeArguments: command.MoveCall.typeArguments,
2154
+ arguments: command.MoveCall.arguments.map((arg) => convertTransactionArgument(arg, inputs))
2155
+ };
2156
+ if (command.Publish) return {
2157
+ kind: "Publish",
2158
+ modules: command.Publish.modules.map((mod) => Array.from(fromBase64(mod))),
2159
+ dependencies: command.Publish.dependencies
2160
+ };
2161
+ if (command.SplitCoins) return {
2162
+ kind: "SplitCoins",
2163
+ coin: convertTransactionArgument(command.SplitCoins.coin, inputs),
2164
+ amounts: command.SplitCoins.amounts.map((arg) => convertTransactionArgument(arg, inputs))
2165
+ };
2166
+ if (command.TransferObjects) return {
2167
+ kind: "TransferObjects",
1827
2168
  objects: command.TransferObjects.objects.map((arg) => convertTransactionArgument(arg, inputs)),
1828
2169
  address: convertTransactionArgument(command.TransferObjects.address, inputs)
1829
2170
  };
@@ -2309,103 +2650,14 @@ var TransactionDataBuilder = class TransactionDataBuilder2 {
2309
2650
  const resolved$1 = resolvedInput.Object.ImmOrOwnedObject ?? resolvedInput.Object.Receiving;
2310
2651
  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
2652
  } 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
2653
+ const original = input.UnresolvedObject;
2654
+ const resolved$1 = resolvedInput.Object.SharedObject;
2655
+ 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)}`);
2656
+ } else throw new Error(`Input at index ${i} resolved to an unexpected Object kind: ${JSON.stringify(resolvedInput.Object)}`);
2657
+ this.inputs[i] = resolvedInput;
2658
+ break;
2407
2659
  }
2408
- };
2660
+ }
2409
2661
  }
2410
2662
  };
2411
2663
 
@@ -2503,68 +2755,6 @@ var SerializedTransactionDataV2Schema = object({
2503
2755
  digest: optional(nullable(string()))
2504
2756
  });
2505
2757
 
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
2758
  // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/resolve.mjs
2569
2759
  init_bcs2();
2570
2760
 
@@ -3293,192 +3483,6 @@ function namedPackagesPlugin() {
3293
3483
  };
3294
3484
  }
3295
3485
 
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
3486
  // ../../node_modules/.pnpm/@mysten+sui@2.11.0_typescript@5.9.3/node_modules/@mysten/sui/dist/transactions/Transaction.mjs
3483
3487
  init_dist2();
3484
3488
  function createTransactionResult(index, length = Infinity) {
@@ -3579,7 +3583,7 @@ var Transaction = class Transaction2 {
3579
3583
  if (!this.#data.sender) this.#data.sender = sender;
3580
3584
  }
3581
3585
  setExpiration(expiration) {
3582
- this.#data.expiration = expiration ? parse(TransactionExpiration, expiration) : null;
3586
+ this.#data.expiration = expiration ? parse(TransactionExpiration2, expiration) : null;
3583
3587
  }
3584
3588
  setGasPrice(price) {
3585
3589
  this.#data.gasData.price = String(price);
@@ -4013,4 +4017,4 @@ export {
4013
4017
  isTransaction,
4014
4018
  Transaction
4015
4019
  };
4016
- //# sourceMappingURL=chunk-XOAZJ42V.js.map
4020
+ //# sourceMappingURL=chunk-DWOZSUBE.js.map