@aptos-labs/ts-sdk 7.3.0 → 7.5.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 (144) hide show
  1. package/LICENSE +43 -43
  2. package/README.md +19 -20
  3. package/dist/api/account/abstraction.d.ts +10 -0
  4. package/dist/api/account/abstraction.d.ts.map +1 -1
  5. package/dist/api/account/abstraction.js +19 -6
  6. package/dist/api/account/abstraction.js.map +1 -1
  7. package/dist/api/ans.d.ts +9 -0
  8. package/dist/api/ans.d.ts.map +1 -1
  9. package/dist/api/ans.js +5 -0
  10. package/dist/api/ans.js.map +1 -1
  11. package/dist/api/coin.d.ts +2 -0
  12. package/dist/api/coin.d.ts.map +1 -1
  13. package/dist/api/coin.js +1 -0
  14. package/dist/api/coin.js.map +1 -1
  15. package/dist/api/digitalAsset.d.ts +30 -0
  16. package/dist/api/digitalAsset.d.ts.map +1 -1
  17. package/dist/api/digitalAsset.js +15 -0
  18. package/dist/api/digitalAsset.js.map +1 -1
  19. package/dist/api/fungibleAsset.d.ts +4 -0
  20. package/dist/api/fungibleAsset.d.ts.map +1 -1
  21. package/dist/api/fungibleAsset.js +2 -0
  22. package/dist/api/fungibleAsset.js.map +1 -1
  23. package/dist/api/keyless.d.ts +38 -1
  24. package/dist/api/keyless.d.ts.map +1 -1
  25. package/dist/api/keyless.js +29 -1
  26. package/dist/api/keyless.js.map +1 -1
  27. package/dist/api/transaction.d.ts +41 -1
  28. package/dist/api/transaction.d.ts.map +1 -1
  29. package/dist/api/transaction.js +42 -2
  30. package/dist/api/transaction.js.map +1 -1
  31. package/dist/api/transactionSubmission/build.d.ts +7 -5
  32. package/dist/api/transactionSubmission/build.d.ts.map +1 -1
  33. package/dist/api/transactionSubmission/build.js +13 -5
  34. package/dist/api/transactionSubmission/build.js.map +1 -1
  35. package/dist/api/transactionSubmission/simulate.d.ts +7 -3
  36. package/dist/api/transactionSubmission/simulate.d.ts.map +1 -1
  37. package/dist/api/transactionSubmission/simulate.js +7 -3
  38. package/dist/api/transactionSubmission/simulate.js.map +1 -1
  39. package/dist/bcs/serializable/moveStructs.d.ts +72 -28
  40. package/dist/bcs/serializable/moveStructs.d.ts.map +1 -1
  41. package/dist/bcs/serializable/moveStructs.js +76 -28
  42. package/dist/bcs/serializable/moveStructs.js.map +1 -1
  43. package/dist/functions/keyless.d.ts +1 -1
  44. package/dist/functions/keyless.d.ts.map +1 -1
  45. package/dist/functions/keyless.js +1 -1
  46. package/dist/functions/keyless.js.map +1 -1
  47. package/dist/functions/transaction.d.ts +1 -1
  48. package/dist/functions/transaction.d.ts.map +1 -1
  49. package/dist/functions/transaction.js +1 -1
  50. package/dist/functions/transaction.js.map +1 -1
  51. package/dist/internal/abstraction.d.ts +35 -0
  52. package/dist/internal/abstraction.d.ts.map +1 -1
  53. package/dist/internal/abstraction.js +38 -3
  54. package/dist/internal/abstraction.js.map +1 -1
  55. package/dist/internal/account.d.ts +6 -0
  56. package/dist/internal/account.d.ts.map +1 -1
  57. package/dist/internal/account.js +55 -37
  58. package/dist/internal/account.js.map +1 -1
  59. package/dist/internal/ans.d.ts +11 -0
  60. package/dist/internal/ans.d.ts.map +1 -1
  61. package/dist/internal/ans.js +19 -7
  62. package/dist/internal/ans.js.map +1 -1
  63. package/dist/internal/coin.d.ts +2 -0
  64. package/dist/internal/coin.d.ts.map +1 -1
  65. package/dist/internal/coin.js +3 -1
  66. package/dist/internal/coin.js.map +1 -1
  67. package/dist/internal/digitalAsset.d.ts +30 -0
  68. package/dist/internal/digitalAsset.d.ts.map +1 -1
  69. package/dist/internal/digitalAsset.js +45 -15
  70. package/dist/internal/digitalAsset.js.map +1 -1
  71. package/dist/internal/fungibleAsset.d.ts +4 -0
  72. package/dist/internal/fungibleAsset.d.ts.map +1 -1
  73. package/dist/internal/fungibleAsset.js +6 -2
  74. package/dist/internal/fungibleAsset.js.map +1 -1
  75. package/dist/internal/keyless.d.ts +39 -1
  76. package/dist/internal/keyless.d.ts.map +1 -1
  77. package/dist/internal/keyless.js +71 -13
  78. package/dist/internal/keyless.js.map +1 -1
  79. package/dist/internal/transaction.d.ts +24 -1
  80. package/dist/internal/transaction.d.ts.map +1 -1
  81. package/dist/internal/transaction.js +125 -4
  82. package/dist/internal/transaction.js.map +1 -1
  83. package/dist/internal/transactionSubmission.d.ts +2 -0
  84. package/dist/internal/transactionSubmission.d.ts.map +1 -1
  85. package/dist/internal/transactionSubmission.js +3 -1
  86. package/dist/internal/transactionSubmission.js.map +1 -1
  87. package/dist/transactions/management/transactionWorker.d.ts +10 -6
  88. package/dist/transactions/management/transactionWorker.d.ts.map +1 -1
  89. package/dist/transactions/management/transactionWorker.js +28 -24
  90. package/dist/transactions/management/transactionWorker.js.map +1 -1
  91. package/dist/transactions/transactionBuilder/index.d.ts +1 -0
  92. package/dist/transactions/transactionBuilder/index.d.ts.map +1 -1
  93. package/dist/transactions/transactionBuilder/index.js +1 -0
  94. package/dist/transactions/transactionBuilder/index.js.map +1 -1
  95. package/dist/transactions/transactionBuilder/scriptAbi.d.ts +10 -0
  96. package/dist/transactions/transactionBuilder/scriptAbi.d.ts.map +1 -0
  97. package/dist/transactions/transactionBuilder/scriptAbi.js +863 -0
  98. package/dist/transactions/transactionBuilder/scriptAbi.js.map +1 -0
  99. package/dist/transactions/transactionBuilder/transactionBuilder.d.ts.map +1 -1
  100. package/dist/transactions/transactionBuilder/transactionBuilder.js +65 -1
  101. package/dist/transactions/transactionBuilder/transactionBuilder.js.map +1 -1
  102. package/dist/transactions/types.d.ts +9 -4
  103. package/dist/transactions/types.d.ts.map +1 -1
  104. package/dist/types/keyless.d.ts +2 -2
  105. package/dist/types/keyless.d.ts.map +1 -1
  106. package/dist/types/types.d.ts +2 -2
  107. package/dist/types/types.d.ts.map +1 -1
  108. package/dist/utils/const.d.ts +11 -0
  109. package/dist/utils/const.d.ts.map +1 -1
  110. package/dist/utils/const.js +11 -0
  111. package/dist/utils/const.js.map +1 -1
  112. package/dist/version.d.ts +1 -1
  113. package/dist/version.js +1 -1
  114. package/package.json +26 -25
  115. package/src/api/account/abstraction.ts +23 -6
  116. package/src/api/ans.ts +9 -0
  117. package/src/api/coin.ts +2 -0
  118. package/src/api/digitalAsset.ts +30 -0
  119. package/src/api/fungibleAsset.ts +4 -0
  120. package/src/api/keyless.ts +39 -1
  121. package/src/api/transaction.ts +48 -1
  122. package/src/api/transactionSubmission/build.ts +16 -6
  123. package/src/api/transactionSubmission/simulate.ts +7 -3
  124. package/src/bcs/serializable/moveStructs.ts +80 -28
  125. package/src/functions/keyless.ts +1 -0
  126. package/src/functions/transaction.ts +1 -0
  127. package/src/internal/abstraction.ts +41 -3
  128. package/src/internal/account.ts +60 -38
  129. package/src/internal/ans.ts +25 -7
  130. package/src/internal/coin.ts +4 -1
  131. package/src/internal/digitalAsset.ts +60 -9
  132. package/src/internal/fungibleAsset.ts +8 -2
  133. package/src/internal/keyless.ts +91 -14
  134. package/src/internal/transaction.ts +154 -4
  135. package/src/internal/transactionSubmission.ts +4 -1
  136. package/src/transactions/management/transactionWorker.ts +35 -23
  137. package/src/transactions/transactionBuilder/index.ts +1 -0
  138. package/src/transactions/transactionBuilder/scriptAbi.ts +1145 -0
  139. package/src/transactions/transactionBuilder/transactionBuilder.ts +91 -6
  140. package/src/transactions/types.ts +10 -4
  141. package/src/types/keyless.ts +2 -2
  142. package/src/types/types.ts +2 -2
  143. package/src/utils/const.ts +12 -0
  144. package/src/version.ts +1 -1
@@ -3,6 +3,7 @@
3
3
 
4
4
  import { AptosConfig } from "./aptosConfig.js";
5
5
  import {
6
+ enrichTransactionWithTableItemData,
6
7
  getGasPriceEstimation,
7
8
  getTransactionByHash,
8
9
  getTransactionByVersion,
@@ -94,7 +95,7 @@ import { rotateAuthKey, rotateAuthKeyUnverified } from "../internal/account.js";
94
95
  *
95
96
  * // Send a transaction from Alice's account to Bob's account
96
97
  * const txn = await aptos.transaction.build.simple({
97
- * sender: alice.accountAddress,
98
+ * sender: alice,
98
99
  * data: {
99
100
  * // All transactions on Aptos are implemented via smart contracts.
100
101
  * function: "0x1::aptos_account::transfer",
@@ -275,6 +276,44 @@ export class Transaction {
275
276
  });
276
277
  }
277
278
 
279
+ /**
280
+ * Populates missing decoded data on write and delete table-item changes in a
281
+ * committed transaction response.
282
+ *
283
+ * Fullnodes generally return `null` for table item `data`. This method queries
284
+ * the indexer for the decoded rows and table metadata, then mutates and returns
285
+ * the supplied transaction. Already-decoded changes are preserved.
286
+ *
287
+ * @param args - The arguments for enriching the transaction.
288
+ * @param args.transaction - The committed transaction response to enrich.
289
+ * @returns The supplied transaction with available table item data populated.
290
+ *
291
+ * @example
292
+ * ```typescript
293
+ * import { Aptos, AptosConfig, Network, isUserTransactionResponse } from "@aptos-labs/ts-sdk";
294
+ *
295
+ * const aptos = new Aptos(new AptosConfig({ network: Network.MAINNET }));
296
+ *
297
+ * async function runExample() {
298
+ * const transaction = await aptos.getTransactionByVersion({ ledgerVersion: 563060087 });
299
+ * if (isUserTransactionResponse(transaction)) {
300
+ * await aptos.enrichTransactionWithTableItemData({ transaction });
301
+ * console.log(transaction.changes);
302
+ * }
303
+ * }
304
+ * runExample();
305
+ * ```
306
+ * @group Transaction
307
+ */
308
+ async enrichTransactionWithTableItemData<T extends CommittedTransactionResponse>(args: {
309
+ transaction: T;
310
+ }): Promise<T> {
311
+ return enrichTransactionWithTableItemData({
312
+ aptosConfig: this.config,
313
+ ...args,
314
+ });
315
+ }
316
+
278
317
  /**
279
318
  * Defines if the specified transaction is currently in a pending state.
280
319
  * This function helps you determine the status of a transaction using its hash.
@@ -438,6 +477,7 @@ export class Transaction {
438
477
  * @param args.account The publisher account.
439
478
  * @param args.metadataBytes The package metadata bytes.
440
479
  * @param args.moduleBytecode An array of the bytecode of each module in the package in compiler output order.
480
+ * @param args.withFeePayer Whether to build a sponsored transaction.
441
481
  * @param args.options Optional settings for generating the transaction.
442
482
  *
443
483
  * @returns A SimpleTransaction that can be simulated or submitted to the chain.
@@ -471,6 +511,7 @@ export class Transaction {
471
511
  account: AccountAddressInput;
472
512
  metadataBytes: HexInput;
473
513
  moduleBytecode: Array<HexInput>;
514
+ withFeePayer?: boolean;
474
515
  options?: InputGenerateTransactionOptions;
475
516
  }): Promise<SimpleTransaction> {
476
517
  return publicPackageTransaction({ aptosConfig: this.config, ...args });
@@ -484,6 +525,8 @@ export class Transaction {
484
525
  * @param args.fromAccount - The account from which the authentication key will be rotated.
485
526
  * @param args.toAccount - (Optional) The target account to rotate to. Required if not using toNewPrivateKey.
486
527
  * @param args.toNewPrivateKey - (Optional) The new private key to rotate to. Required if not using toAccount.
528
+ * @param args.withFeePayer - Whether to build a sponsored transaction.
529
+ * @param args.options - Optional settings for generating the transaction.
487
530
  *
488
531
  * @remarks
489
532
  * This function supports three modes of rotation:
@@ -515,6 +558,7 @@ export class Transaction {
515
558
  async rotateAuthKey(
516
559
  args: {
517
560
  fromAccount: Account;
561
+ withFeePayer?: boolean;
518
562
  options?: InputGenerateTransactionOptions;
519
563
  } & ({ toAccount: Ed25519Account | MultiEd25519Account } | { toNewPrivateKey: Ed25519PrivateKey }),
520
564
  ): Promise<SimpleTransaction> {
@@ -531,6 +575,8 @@ export class Transaction {
531
575
  * @param args - The arguments for rotating the authentication key.
532
576
  * @param args.fromAccount - The account from which the authentication key will be rotated.
533
577
  * @param args.toNewPublicKey - The new public key to rotate to.
578
+ * @param args.withFeePayer - Whether to build a sponsored transaction.
579
+ * @param args.options - Optional settings for generating the transaction.
534
580
  *
535
581
  * @returns A simple transaction object that can be submitted to the network.
536
582
  *
@@ -552,6 +598,7 @@ export class Transaction {
552
598
  */
553
599
  async rotateAuthKeyUnverified(args: {
554
600
  fromAccount: Account;
601
+ withFeePayer?: boolean;
555
602
  options?: InputGenerateTransactionOptions;
556
603
  toNewPublicKey: AccountPublicKey;
557
604
  }): Promise<SimpleTransaction> {
@@ -1,6 +1,7 @@
1
1
  // Copyright © Aptos Foundation
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import type { Account } from "../../account/index.js";
4
5
  import { AccountAddressInput } from "../../core/index.js";
5
6
  import { generateTransaction } from "../../internal/transactionSubmission.js";
6
7
  import { InputGenerateTransactionPayloadData, InputGenerateTransactionOptions } from "../../transactions/index.js";
@@ -8,6 +9,10 @@ import { MultiAgentTransaction } from "../../transactions/instances/multiAgentTr
8
9
  import { SimpleTransaction } from "../../transactions/instances/simpleTransaction.js";
9
10
  import { AptosConfig } from "../aptosConfig.js";
10
11
 
12
+ function accountAddressInput(input: Account | AccountAddressInput): AccountAddressInput {
13
+ return typeof input === "object" && "accountAddress" in input ? input.accountAddress : input;
14
+ }
15
+
11
16
  /**
12
17
  * A class to handle all `Build` transaction operations.
13
18
  * @group Implementation
@@ -53,7 +58,7 @@ export class Build {
53
58
  *
54
59
  * This function allows you to create a transaction with specified sender and data.
55
60
  *
56
- * @param args.sender - The sender account address.
61
+ * @param args.sender - The sender account or account address.
57
62
  * @param args.data - The transaction data.
58
63
  * @param args.options - Optional transaction configurations.
59
64
  * @param args.withFeePayer - Whether there is a fee payer for the transaction.
@@ -62,15 +67,16 @@ export class Build {
62
67
  *
63
68
  * @example
64
69
  * ```typescript
65
- * import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
70
+ * import { Account, Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
66
71
  *
67
72
  * const config = new AptosConfig({ network: Network.TESTNET });
68
73
  * const aptos = new Aptos(config);
74
+ * const sender = Account.generate();
69
75
  *
70
76
  * async function runExample() {
71
77
  * // Build a simple transaction
72
- * const transaction = await aptos.transaction.simple({
73
- * sender: "0x1", // replace with a real sender account address
78
+ * const transaction = await aptos.transaction.build.simple({
79
+ * sender,
74
80
  * data: {
75
81
  * function: "0x1::aptos_account::transfer",
76
82
  * functionArguments: ["0x2", 100], // replace with a real destination account address
@@ -88,12 +94,16 @@ export class Build {
88
94
  * @group Implementation
89
95
  */
90
96
  async simple(args: {
91
- sender: AccountAddressInput;
97
+ sender: Account | AccountAddressInput;
92
98
  data: InputGenerateTransactionPayloadData;
93
99
  options?: InputGenerateTransactionOptions;
94
100
  withFeePayer?: boolean;
95
101
  }): Promise<SimpleTransaction> {
96
- return generateTransaction({ aptosConfig: this.config, ...args });
102
+ return generateTransaction({
103
+ aptosConfig: this.config,
104
+ ...args,
105
+ sender: accountAddressInput(args.sender),
106
+ });
97
107
  }
98
108
 
99
109
  /**
@@ -48,8 +48,13 @@ export class Simulate {
48
48
  * Simulates a transaction based on the provided parameters and returns the result.
49
49
  * This function helps you understand the outcome of a transaction before executing it on the blockchain.
50
50
  *
51
+ * To pre-check a multisig proposal, build its entry function directly with the multisig address as sender and
52
+ * `withFeePayer: true`, then omit `signerPublicKey` and `feePayerPublicKey`. The simulation uses no-account
53
+ * authenticators to skip authentication-key validation, so the proposal does not need to exist on-chain.
54
+ *
51
55
  * @param args - The parameters for simulating the transaction.
52
- * @param args.signerPublicKey - The public key of the signer for the transaction (optional).
56
+ * @param args.signerPublicKey - Optional public key used to validate the signer's authentication key.
57
+ * Omit it to simulate with the sender address already embedded in the transaction.
53
58
  * @param args.transaction - The raw transaction data to simulate.
54
59
  * @param args.feePayerPublicKey - The public key of the fee payer (optional).
55
60
  * @param args.options - Additional options for simulating the transaction (optional).
@@ -78,7 +83,7 @@ export class Simulate {
78
83
  *
79
84
  * // 1. Build the transaction to preview the impact of it
80
85
  * const transaction = await aptos.transaction.build.simple({
81
- * sender: sender.accountAddress,
86
+ * sender,
82
87
  * data: {
83
88
  * // All transactions on Aptos are implemented via smart contracts.
84
89
  * function: "0x1::aptos_account::transfer",
@@ -88,7 +93,6 @@ export class Simulate {
88
93
  *
89
94
  * // 2. Simulate to see what would happen if we execute this transaction
90
95
  * const [userTransactionResponse] = await aptos.transaction.simulate.simple({
91
- * signerPublicKey: sender.publicKey,
92
96
  * transaction,
93
97
  * });
94
98
  * console.log(userTransactionResponse);
@@ -6,6 +6,7 @@ import { Serializable, Serializer, serializeEntryFunctionBytesCompat } from "../
6
6
  import { Deserializable, Deserializer } from "../deserializer.js";
7
7
  import { AnyNumber, HexInput, ScriptTransactionArgumentVariants } from "../../types/index.js";
8
8
  import { Hex } from "../../core/hex.js";
9
+ import { AccountAddress, AccountAddressInput } from "../../core/accountAddress.js";
9
10
  import { EntryFunctionArgument, TransactionArgument } from "../../transactions/instances/transactionArgument.js";
10
11
  import { TEXT_ENCODER } from "../../utils/const.js";
11
12
 
@@ -376,6 +377,23 @@ export class MoveVector<T extends Serializable & EntryFunctionArgument>
376
377
  return new MoveVector<MoveString>(values.map((v) => new MoveString(v)));
377
378
  }
378
379
 
380
+ /**
381
+ * Factory method to generate a MoveVector<AccountAddress> from an array of `AccountAddressInput` values.
382
+ *
383
+ * @param values - The values used to fill the MoveVector.
384
+ * @returns A MoveVector<AccountAddress> with the inner values.
385
+ *
386
+ * @example
387
+ * ```typescript
388
+ * const v = MoveVector.Address(["0x1", "0x2"]);
389
+ * ```
390
+ * @group Implementation
391
+ * @category BCS
392
+ */
393
+ static Address(values: Array<AccountAddressInput>): MoveVector<AccountAddress> {
394
+ return new MoveVector<AccountAddress>(values.map((v) => AccountAddress.from(v)));
395
+ }
396
+
379
397
  /**
380
398
  * Serializes the current object using the provided serializer.
381
399
  * This function will serialize the value if it is present.
@@ -575,13 +593,14 @@ export class MoveOption<T extends Serializable & EntryFunctionArgument>
575
593
  }
576
594
 
577
595
  /**
578
- * Factory method to generate a MoveOption<U8> from a `number` or `undefined`.
596
+ * Factory method to generate a MoveOption<U8> from a `number`, `undefined`, or `null`.
579
597
  *
580
598
  * @example
581
599
  * MoveOption.U8(1).isSome() === true;
582
600
  * MoveOption.U8().isSome() === false;
583
601
  * MoveOption.U8(undefined).isSome() === false;
584
- * @param value the value used to fill the MoveOption. If `value` is undefined
602
+ * MoveOption.U8(null).isSome() === false;
603
+ * @param value the value used to fill the MoveOption. If `value` is undefined or null
585
604
  * the resulting MoveOption's .isSome() method will return false.
586
605
  * @returns a MoveOption<U8> with an inner value `value`
587
606
  * @group Implementation
@@ -592,13 +611,14 @@ export class MoveOption<T extends Serializable & EntryFunctionArgument>
592
611
  }
593
612
 
594
613
  /**
595
- * Factory method to generate a MoveOption<U16> from a `number` or `undefined`.
614
+ * Factory method to generate a MoveOption<U16> from a `number`, `undefined`, or `null`.
596
615
  *
597
616
  * @example
598
617
  * MoveOption.U16(1).isSome() === true;
599
618
  * MoveOption.U16().isSome() === false;
600
619
  * MoveOption.U16(undefined).isSome() === false;
601
- * @param value the value used to fill the MoveOption. If `value` is undefined
620
+ * MoveOption.U16(null).isSome() === false;
621
+ * @param value the value used to fill the MoveOption. If `value` is undefined or null
602
622
  * the resulting MoveOption's .isSome() method will return false.
603
623
  * @returns a MoveOption<U16> with an inner value `value`
604
624
  * @group Implementation
@@ -609,13 +629,14 @@ export class MoveOption<T extends Serializable & EntryFunctionArgument>
609
629
  }
610
630
 
611
631
  /**
612
- * Factory method to generate a MoveOption<U32> from a `number` or `undefined`.
632
+ * Factory method to generate a MoveOption<U32> from a `number`, `undefined`, or `null`.
613
633
  *
614
634
  * @example
615
635
  * MoveOption.U32(1).isSome() === true;
616
636
  * MoveOption.U32().isSome() === false;
617
637
  * MoveOption.U32(undefined).isSome() === false;
618
- * @param value the value used to fill the MoveOption. If `value` is undefined
638
+ * MoveOption.U32(null).isSome() === false;
639
+ * @param value the value used to fill the MoveOption. If `value` is undefined or null
619
640
  * the resulting MoveOption's .isSome() method will return false.
620
641
  * @returns a MoveOption<U32> with an inner value `value`
621
642
  * @group Implementation
@@ -626,13 +647,14 @@ export class MoveOption<T extends Serializable & EntryFunctionArgument>
626
647
  }
627
648
 
628
649
  /**
629
- * Factory method to generate a MoveOption<U64> from a `number` or a `bigint` or `undefined`.
650
+ * Factory method to generate a MoveOption<U64> from a `number`, `bigint`, `undefined`, or `null`.
630
651
  *
631
652
  * @example
632
653
  * MoveOption.U64(1).isSome() === true;
633
654
  * MoveOption.U64().isSome() === false;
634
655
  * MoveOption.U64(undefined).isSome() === false;
635
- * @param value the value used to fill the MoveOption. If `value` is undefined
656
+ * MoveOption.U64(null).isSome() === false;
657
+ * @param value the value used to fill the MoveOption. If `value` is undefined or null
636
658
  * the resulting MoveOption's .isSome() method will return false.
637
659
  * @returns a MoveOption<U64> with an inner value `value`
638
660
  * @group Implementation
@@ -643,13 +665,14 @@ export class MoveOption<T extends Serializable & EntryFunctionArgument>
643
665
  }
644
666
 
645
667
  /**
646
- * Factory method to generate a MoveOption<U128> from a `number` or a `bigint` or `undefined`.
668
+ * Factory method to generate a MoveOption<U128> from a `number`, `bigint`, `undefined`, or `null`.
647
669
  *
648
670
  * @example
649
671
  * MoveOption.U128(1).isSome() === true;
650
672
  * MoveOption.U128().isSome() === false;
651
673
  * MoveOption.U128(undefined).isSome() === false;
652
- * @param value the value used to fill the MoveOption. If `value` is undefined
674
+ * MoveOption.U128(null).isSome() === false;
675
+ * @param value the value used to fill the MoveOption. If `value` is undefined or null
653
676
  * the resulting MoveOption's .isSome() method will return false.
654
677
  * @returns a MoveOption<U128> with an inner value `value`
655
678
  * @group Implementation
@@ -660,13 +683,14 @@ export class MoveOption<T extends Serializable & EntryFunctionArgument>
660
683
  }
661
684
 
662
685
  /**
663
- * Factory method to generate a MoveOption<U256> from a `number` or a `bigint` or `undefined`.
686
+ * Factory method to generate a MoveOption<U256> from a `number`, `bigint`, `undefined`, or `null`.
664
687
  *
665
688
  * @example
666
689
  * MoveOption.U256(1).isSome() === true;
667
690
  * MoveOption.U256().isSome() === false;
668
691
  * MoveOption.U256(undefined).isSome() === false;
669
- * @param value the value used to fill the MoveOption. If `value` is undefined
692
+ * MoveOption.U256(null).isSome() === false;
693
+ * @param value the value used to fill the MoveOption. If `value` is undefined or null
670
694
  * the resulting MoveOption's .isSome() method will return false.
671
695
  * @returns a MoveOption<U256> with an inner value `value`
672
696
  * @group Implementation
@@ -677,13 +701,14 @@ export class MoveOption<T extends Serializable & EntryFunctionArgument>
677
701
  }
678
702
 
679
703
  /**
680
- * Factory method to generate a MoveOption<Bool> from a `boolean` or `undefined`.
704
+ * Factory method to generate a MoveOption<Bool> from a `boolean`, `undefined`, or `null`.
681
705
  *
682
706
  * @example
683
707
  * MoveOption.Bool(true).isSome() === true;
684
708
  * MoveOption.Bool().isSome() === false;
685
709
  * MoveOption.Bool(undefined).isSome() === false;
686
- * @param value the value used to fill the MoveOption. If `value` is undefined
710
+ * MoveOption.Bool(null).isSome() === false;
711
+ * @param value the value used to fill the MoveOption. If `value` is undefined or null
687
712
  * the resulting MoveOption's .isSome() method will return false.
688
713
  * @returns a MoveOption<Bool> with an inner value `value`
689
714
  * @group Implementation
@@ -694,13 +719,14 @@ export class MoveOption<T extends Serializable & EntryFunctionArgument>
694
719
  }
695
720
 
696
721
  /**
697
- * Factory method to generate a MoveOption<I8> from a `number` or `undefined`.
722
+ * Factory method to generate a MoveOption<I8> from a `number`, `undefined`, or `null`.
698
723
  *
699
724
  * @example
700
725
  * MoveOption.I8(1).isSome() === true;
701
726
  * MoveOption.I8().isSome() === false;
702
727
  * MoveOption.I8(undefined).isSome() === false;
703
- * @param value the value used to fill the MoveOption. If `value` is undefined
728
+ * MoveOption.I8(null).isSome() === false;
729
+ * @param value the value used to fill the MoveOption. If `value` is undefined or null
704
730
  * the resulting MoveOption's .isSome() method will return false.
705
731
  * @returns a MoveOption<I8> with an inner value `value`
706
732
  * @group Implementation
@@ -711,13 +737,14 @@ export class MoveOption<T extends Serializable & EntryFunctionArgument>
711
737
  }
712
738
 
713
739
  /**
714
- * Factory method to generate a MoveOption<I16> from a `number` or `undefined`.
740
+ * Factory method to generate a MoveOption<I16> from a `number`, `undefined`, or `null`.
715
741
  *
716
742
  * @example
717
743
  * MoveOption.I16(1).isSome() === true;
718
744
  * MoveOption.I16().isSome() === false;
719
745
  * MoveOption.I16(undefined).isSome() === false;
720
- * @param value the value used to fill the MoveOption. If `value` is undefined
746
+ * MoveOption.I16(null).isSome() === false;
747
+ * @param value the value used to fill the MoveOption. If `value` is undefined or null
721
748
  * the resulting MoveOption's .isSome() method will return false.
722
749
  * @returns a MoveOption<I16> with an inner value `value`
723
750
  * @group Implementation
@@ -728,13 +755,14 @@ export class MoveOption<T extends Serializable & EntryFunctionArgument>
728
755
  }
729
756
 
730
757
  /**
731
- * Factory method to generate a MoveOption<I32> from a `number` or `undefined`.
758
+ * Factory method to generate a MoveOption<I32> from a `number`, `undefined`, or `null`.
732
759
  *
733
760
  * @example
734
761
  * MoveOption.I32(1).isSome() === true;
735
762
  * MoveOption.I32().isSome() === false;
736
763
  * MoveOption.I32(undefined).isSome() === false;
737
- * @param value the value used to fill the MoveOption. If `value` is undefined
764
+ * MoveOption.I32(null).isSome() === false;
765
+ * @param value the value used to fill the MoveOption. If `value` is undefined or null
738
766
  * the resulting MoveOption's .isSome() method will return false.
739
767
  * @returns a MoveOption<I32> with an inner value `value`
740
768
  * @group Implementation
@@ -745,13 +773,14 @@ export class MoveOption<T extends Serializable & EntryFunctionArgument>
745
773
  }
746
774
 
747
775
  /**
748
- * Factory method to generate a MoveOption<I64> from a `number` or a `bigint` or `undefined`.
776
+ * Factory method to generate a MoveOption<I64> from a `number`, `bigint`, `undefined`, or `null`.
749
777
  *
750
778
  * @example
751
779
  * MoveOption.I64(1).isSome() === true;
752
780
  * MoveOption.I64().isSome() === false;
753
781
  * MoveOption.I64(undefined).isSome() === false;
754
- * @param value the value used to fill the MoveOption. If `value` is undefined
782
+ * MoveOption.I64(null).isSome() === false;
783
+ * @param value the value used to fill the MoveOption. If `value` is undefined or null
755
784
  * the resulting MoveOption's .isSome() method will return false.
756
785
  * @returns a MoveOption<I64> with an inner value `value`
757
786
  * @group Implementation
@@ -762,13 +791,14 @@ export class MoveOption<T extends Serializable & EntryFunctionArgument>
762
791
  }
763
792
 
764
793
  /**
765
- * Factory method to generate a MoveOption<I128> from a `number` or a `bigint` or `undefined`.
794
+ * Factory method to generate a MoveOption<I128> from a `number`, `bigint`, `undefined`, or `null`.
766
795
  *
767
796
  * @example
768
797
  * MoveOption.I128(1).isSome() === true;
769
798
  * MoveOption.I128().isSome() === false;
770
799
  * MoveOption.I128(undefined).isSome() === false;
771
- * @param value the value used to fill the MoveOption. If `value` is undefined
800
+ * MoveOption.I128(null).isSome() === false;
801
+ * @param value the value used to fill the MoveOption. If `value` is undefined or null
772
802
  * the resulting MoveOption's .isSome() method will return false.
773
803
  * @returns a MoveOption<I128> with an inner value `value`
774
804
  * @group Implementation
@@ -779,13 +809,14 @@ export class MoveOption<T extends Serializable & EntryFunctionArgument>
779
809
  }
780
810
 
781
811
  /**
782
- * Factory method to generate a MoveOption<I256> from a `number` or a `bigint` or `undefined`.
812
+ * Factory method to generate a MoveOption<I256> from a `number`, `bigint`, `undefined`, or `null`.
783
813
  *
784
814
  * @example
785
815
  * MoveOption.I256(1).isSome() === true;
786
816
  * MoveOption.I256().isSome() === false;
787
817
  * MoveOption.I256(undefined).isSome() === false;
788
- * @param value the value used to fill the MoveOption. If `value` is undefined
818
+ * MoveOption.I256(null).isSome() === false;
819
+ * @param value the value used to fill the MoveOption. If `value` is undefined or null
789
820
  * the resulting MoveOption's .isSome() method will return false.
790
821
  * @returns a MoveOption<I256> with an inner value `value`
791
822
  * @group Implementation
@@ -796,14 +827,15 @@ export class MoveOption<T extends Serializable & EntryFunctionArgument>
796
827
  }
797
828
 
798
829
  /**
799
- * Factory method to generate a MoveOption<MoveString> from a `string` or `undefined`.
830
+ * Factory method to generate a MoveOption<MoveString> from a `string`, `undefined`, or `null`.
800
831
  *
801
832
  * @example
802
833
  * MoveOption.MoveString("hello").isSome() === true;
803
834
  * MoveOption.MoveString("").isSome() === true;
804
835
  * MoveOption.MoveString().isSome() === false;
805
836
  * MoveOption.MoveString(undefined).isSome() === false;
806
- * @param value the value used to fill the MoveOption. If `value` is undefined
837
+ * MoveOption.MoveString(null).isSome() === false;
838
+ * @param value the value used to fill the MoveOption. If `value` is undefined or null
807
839
  * the resulting MoveOption's .isSome() method will return false.
808
840
  * @returns a MoveOption<MoveString> with an inner value `value`
809
841
  * @group Implementation
@@ -813,6 +845,26 @@ export class MoveOption<T extends Serializable & EntryFunctionArgument>
813
845
  return new MoveOption<MoveString>(value !== null && value !== undefined ? new MoveString(value) : undefined);
814
846
  }
815
847
 
848
+ /**
849
+ * Factory method to generate a MoveOption<AccountAddress> from an `AccountAddressInput`, `undefined`, or `null`.
850
+ *
851
+ * @example
852
+ * MoveOption.Address("0x1").isSome() === true;
853
+ * MoveOption.Address().isSome() === false;
854
+ * MoveOption.Address(undefined).isSome() === false;
855
+ * MoveOption.Address(null).isSome() === false;
856
+ * @param value the value used to fill the MoveOption. If `value` is undefined or null
857
+ * the resulting MoveOption's .isSome() method will return false.
858
+ * @returns a MoveOption<AccountAddress> with an inner value `value`
859
+ * @group Implementation
860
+ * @category BCS
861
+ */
862
+ static Address(value?: AccountAddressInput | null): MoveOption<AccountAddress> {
863
+ return new MoveOption<AccountAddress>(
864
+ value !== null && value !== undefined ? AccountAddress.from(value) : undefined,
865
+ );
866
+ }
867
+
816
868
  static deserialize<U extends Serializable & EntryFunctionArgument>(
817
869
  deserializer: Deserializer,
818
870
  cls: Deserializable<U>,
@@ -9,6 +9,7 @@
9
9
  // Standalone functions
10
10
  export {
11
11
  getPepper,
12
+ getPepperAndAddress,
12
13
  getProof,
13
14
  deriveKeylessAccount,
14
15
  updateFederatedKeylessJwkSetTransaction,
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  export {
5
+ enrichTransactionWithTableItemData,
5
6
  getTransactions,
6
7
  getGasPriceEstimation,
7
8
  getTransactionByVersion,
@@ -11,17 +11,30 @@ import { MoveFunctionId } from "../types/index.js";
11
11
  import { AptosConfig } from "../api/aptosConfig.js";
12
12
  import { getFunctionParts } from "../utils/helpers.js";
13
13
 
14
+ /**
15
+ * Builds a transaction that adds a dispatchable authentication function to an account.
16
+ *
17
+ * @param args - The arguments for adding the authentication function.
18
+ * @param args.aptosConfig - The Aptos configuration to use.
19
+ * @param args.sender - The account to add the authentication function to.
20
+ * @param args.authenticationFunction - The authentication function to add.
21
+ * @param args.withFeePayer - Whether to build a fee-payer transaction.
22
+ * @param args.options - Optional transaction generation options.
23
+ * @group Implementation
24
+ */
14
25
  export async function addAuthenticationFunctionTransaction(args: {
15
26
  aptosConfig: AptosConfig;
16
27
  sender: AccountAddressInput;
17
28
  authenticationFunction: MoveFunctionId;
29
+ withFeePayer?: boolean;
18
30
  options?: InputGenerateTransactionOptions;
19
31
  }): Promise<SimpleTransaction> {
20
- const { aptosConfig, sender, authenticationFunction, options } = args;
32
+ const { aptosConfig, sender, authenticationFunction, withFeePayer, options } = args;
21
33
  const { moduleAddress, moduleName, functionName } = getFunctionParts(authenticationFunction);
22
34
  return generateTransaction({
23
35
  aptosConfig,
24
36
  sender,
37
+ withFeePayer,
25
38
  data: {
26
39
  function: "0x1::account_abstraction::add_authentication_function",
27
40
  typeArguments: [],
@@ -35,17 +48,30 @@ export async function addAuthenticationFunctionTransaction(args: {
35
48
  });
36
49
  }
37
50
 
51
+ /**
52
+ * Builds a transaction that removes a dispatchable authentication function from an account.
53
+ *
54
+ * @param args - The arguments for removing the authentication function.
55
+ * @param args.aptosConfig - The Aptos configuration to use.
56
+ * @param args.sender - The account to remove the authentication function from.
57
+ * @param args.authenticationFunction - The authentication function to remove.
58
+ * @param args.withFeePayer - Whether to build a fee-payer transaction.
59
+ * @param args.options - Optional transaction generation options.
60
+ * @group Implementation
61
+ */
38
62
  export async function removeAuthenticationFunctionTransaction(args: {
39
63
  aptosConfig: AptosConfig;
40
64
  sender: AccountAddressInput;
41
65
  authenticationFunction: MoveFunctionId;
66
+ withFeePayer?: boolean;
42
67
  options?: InputGenerateTransactionOptions;
43
68
  }) {
44
- const { aptosConfig, sender, authenticationFunction, options } = args;
69
+ const { aptosConfig, sender, authenticationFunction, withFeePayer, options } = args;
45
70
  const { moduleAddress, moduleName, functionName } = getFunctionParts(authenticationFunction);
46
71
  return generateTransaction({
47
72
  aptosConfig,
48
73
  sender,
74
+ withFeePayer,
49
75
  data: {
50
76
  function: "0x1::account_abstraction::remove_authentication_function",
51
77
  typeArguments: [],
@@ -59,15 +85,27 @@ export async function removeAuthenticationFunctionTransaction(args: {
59
85
  });
60
86
  }
61
87
 
88
+ /**
89
+ * Builds a transaction that removes the dispatchable authenticator from an account.
90
+ *
91
+ * @param args - The arguments for removing the authenticator.
92
+ * @param args.aptosConfig - The Aptos configuration to use.
93
+ * @param args.sender - The account to remove the authenticator from.
94
+ * @param args.withFeePayer - Whether to build a fee-payer transaction.
95
+ * @param args.options - Optional transaction generation options.
96
+ * @group Implementation
97
+ */
62
98
  export async function removeDispatchableAuthenticatorTransaction(args: {
63
99
  aptosConfig: AptosConfig;
64
100
  sender: AccountAddressInput;
101
+ withFeePayer?: boolean;
65
102
  options?: InputGenerateTransactionOptions;
66
103
  }) {
67
- const { aptosConfig, sender, options } = args;
104
+ const { aptosConfig, sender, withFeePayer, options } = args;
68
105
  return generateTransaction({
69
106
  aptosConfig,
70
107
  sender,
108
+ withFeePayer,
71
109
  data: {
72
110
  function: "0x1::account_abstraction::remove_authenticator",
73
111
  typeArguments: [],