@aptos-labs/ts-sdk 7.2.0 → 7.4.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 (259) hide show
  1. package/LICENSE +43 -43
  2. package/README.md +36 -20
  3. package/dist/account/AbstractKeylessAccount.d.ts.map +1 -1
  4. package/dist/account/AbstractKeylessAccount.js.map +1 -1
  5. package/dist/account/AbstractedAccount.d.ts.map +1 -1
  6. package/dist/account/Account.d.ts.map +1 -1
  7. package/dist/account/Account.js.map +1 -1
  8. package/dist/account/AccountUtils.js.map +1 -1
  9. package/dist/account/DerivableAbstractedAccount.d.ts.map +1 -1
  10. package/dist/account/DerivableAbstractedAccount.js.map +1 -1
  11. package/dist/account/Ed25519Account.d.ts.map +1 -1
  12. package/dist/account/EphemeralKeyPair.d.ts.map +1 -1
  13. package/dist/account/EphemeralKeyPair.js.map +1 -1
  14. package/dist/account/FederatedKeylessAccount.d.ts.map +1 -1
  15. package/dist/account/KeylessAccount.d.ts.map +1 -1
  16. package/dist/account/MultiEd25519Account.d.ts.map +1 -1
  17. package/dist/account/MultiKeyAccount.d.ts.map +1 -1
  18. package/dist/account/SingleKeyAccount.d.ts.map +1 -1
  19. package/dist/account/SingleKeyAccount.js.map +1 -1
  20. package/dist/api/account/abstraction.d.ts +10 -0
  21. package/dist/api/account/abstraction.d.ts.map +1 -1
  22. package/dist/api/account/abstraction.js +19 -6
  23. package/dist/api/account/abstraction.js.map +1 -1
  24. package/dist/api/account.d.ts.map +1 -1
  25. package/dist/api/account.js.map +1 -1
  26. package/dist/api/ans.d.ts +9 -0
  27. package/dist/api/ans.d.ts.map +1 -1
  28. package/dist/api/ans.js +5 -0
  29. package/dist/api/ans.js.map +1 -1
  30. package/dist/api/aptos.d.ts.map +1 -1
  31. package/dist/api/aptosConfig.d.ts +12 -0
  32. package/dist/api/aptosConfig.d.ts.map +1 -1
  33. package/dist/api/aptosConfig.js +13 -0
  34. package/dist/api/aptosConfig.js.map +1 -1
  35. package/dist/api/coin.d.ts +2 -0
  36. package/dist/api/coin.d.ts.map +1 -1
  37. package/dist/api/coin.js +1 -0
  38. package/dist/api/coin.js.map +1 -1
  39. package/dist/api/digitalAsset.d.ts +30 -0
  40. package/dist/api/digitalAsset.d.ts.map +1 -1
  41. package/dist/api/digitalAsset.js +15 -0
  42. package/dist/api/digitalAsset.js.map +1 -1
  43. package/dist/api/faucet.d.ts.map +1 -1
  44. package/dist/api/faucet.js.map +1 -1
  45. package/dist/api/fungibleAsset.d.ts +4 -0
  46. package/dist/api/fungibleAsset.d.ts.map +1 -1
  47. package/dist/api/fungibleAsset.js +2 -0
  48. package/dist/api/fungibleAsset.js.map +1 -1
  49. package/dist/api/general.d.ts.map +1 -1
  50. package/dist/api/keyless.d.ts +38 -1
  51. package/dist/api/keyless.d.ts.map +1 -1
  52. package/dist/api/keyless.js +29 -1
  53. package/dist/api/keyless.js.map +1 -1
  54. package/dist/api/object.d.ts.map +1 -1
  55. package/dist/api/object.js.map +1 -1
  56. package/dist/api/staking.d.ts.map +1 -1
  57. package/dist/api/staking.js.map +1 -1
  58. package/dist/api/table.d.ts.map +1 -1
  59. package/dist/api/transaction.d.ts +41 -1
  60. package/dist/api/transaction.d.ts.map +1 -1
  61. package/dist/api/transaction.js +42 -2
  62. package/dist/api/transaction.js.map +1 -1
  63. package/dist/api/transactionSubmission/build.d.ts +7 -5
  64. package/dist/api/transactionSubmission/build.d.ts.map +1 -1
  65. package/dist/api/transactionSubmission/build.js +13 -5
  66. package/dist/api/transactionSubmission/build.js.map +1 -1
  67. package/dist/api/transactionSubmission/management.d.ts.map +1 -1
  68. package/dist/api/transactionSubmission/sign.d.ts.map +1 -1
  69. package/dist/api/transactionSubmission/simulate.d.ts +7 -3
  70. package/dist/api/transactionSubmission/simulate.d.ts.map +1 -1
  71. package/dist/api/transactionSubmission/simulate.js +7 -3
  72. package/dist/api/transactionSubmission/simulate.js.map +1 -1
  73. package/dist/api/transactionSubmission/submit.d.ts.map +1 -1
  74. package/dist/bcs/deserializer.d.ts.map +1 -1
  75. package/dist/bcs/serializable/entryFunctionBytes.d.ts.map +1 -1
  76. package/dist/bcs/serializable/fixedBytes.d.ts.map +1 -1
  77. package/dist/bcs/serializable/movePrimitives.d.ts.map +1 -1
  78. package/dist/bcs/serializable/moveStructs.d.ts +72 -28
  79. package/dist/bcs/serializable/moveStructs.d.ts.map +1 -1
  80. package/dist/bcs/serializable/moveStructs.js +76 -28
  81. package/dist/bcs/serializable/moveStructs.js.map +1 -1
  82. package/dist/bcs/serializer.d.ts.map +1 -1
  83. package/dist/bcs/serializer.js.map +1 -1
  84. package/dist/cli/localNode.d.ts.map +1 -1
  85. package/dist/cli/localNode.js +16 -3
  86. package/dist/cli/localNode.js.map +1 -1
  87. package/dist/cli/move.d.ts.map +1 -1
  88. package/dist/cli/move.js.map +1 -1
  89. package/dist/client/core.d.ts +3 -0
  90. package/dist/client/core.d.ts.map +1 -1
  91. package/dist/client/core.js +116 -9
  92. package/dist/client/core.js.map +1 -1
  93. package/dist/core/account/utils/address.d.ts.map +1 -1
  94. package/dist/core/accountAddress.d.ts.map +1 -1
  95. package/dist/core/accountAddress.js.map +1 -1
  96. package/dist/core/authenticationKey.d.ts.map +1 -1
  97. package/dist/core/authenticationKey.js.map +1 -1
  98. package/dist/core/common.d.ts.map +1 -1
  99. package/dist/core/crypto/abstraction.d.ts.map +1 -1
  100. package/dist/core/crypto/ed25519.d.ts.map +1 -1
  101. package/dist/core/crypto/ed25519.js.map +1 -1
  102. package/dist/core/crypto/encryption/ciphertext.d.ts.map +1 -1
  103. package/dist/core/crypto/encryption/symmetric.d.ts.map +1 -1
  104. package/dist/core/crypto/encryption/symmetric.js.map +1 -1
  105. package/dist/core/crypto/ephemeral.d.ts.map +1 -1
  106. package/dist/core/crypto/federatedKeyless.d.ts.map +1 -1
  107. package/dist/core/crypto/hdKey.d.ts.map +1 -1
  108. package/dist/core/crypto/keyless.d.ts.map +1 -1
  109. package/dist/core/crypto/keyless.js.map +1 -1
  110. package/dist/core/crypto/multiEd25519.d.ts.map +1 -1
  111. package/dist/core/crypto/multiEd25519.js.map +1 -1
  112. package/dist/core/crypto/multiKey.d.ts.map +1 -1
  113. package/dist/core/crypto/multiKey.js.map +1 -1
  114. package/dist/core/crypto/privateKey.d.ts.map +1 -1
  115. package/dist/core/crypto/privateKey.js.map +1 -1
  116. package/dist/core/crypto/publicKey.d.ts.map +1 -1
  117. package/dist/core/crypto/secp256k1.d.ts.map +1 -1
  118. package/dist/core/crypto/secp256k1.js.map +1 -1
  119. package/dist/core/crypto/secp256r1.d.ts.map +1 -1
  120. package/dist/core/crypto/secp256r1.js.map +1 -1
  121. package/dist/core/crypto/signature.d.ts.map +1 -1
  122. package/dist/core/crypto/singleKey.d.ts.map +1 -1
  123. package/dist/core/crypto/singleKey.js.map +1 -1
  124. package/dist/core/crypto/utils.d.ts.map +1 -1
  125. package/dist/core/hex.d.ts.map +1 -1
  126. package/dist/errors/index.d.ts.map +1 -1
  127. package/dist/functions/keyless.d.ts +1 -1
  128. package/dist/functions/keyless.d.ts.map +1 -1
  129. package/dist/functions/keyless.js +1 -1
  130. package/dist/functions/keyless.js.map +1 -1
  131. package/dist/functions/transaction.d.ts +1 -1
  132. package/dist/functions/transaction.d.ts.map +1 -1
  133. package/dist/functions/transaction.js +1 -1
  134. package/dist/functions/transaction.js.map +1 -1
  135. package/dist/internal/abstraction.d.ts +35 -0
  136. package/dist/internal/abstraction.d.ts.map +1 -1
  137. package/dist/internal/abstraction.js +38 -3
  138. package/dist/internal/abstraction.js.map +1 -1
  139. package/dist/internal/account.d.ts +6 -0
  140. package/dist/internal/account.d.ts.map +1 -1
  141. package/dist/internal/account.js +55 -37
  142. package/dist/internal/account.js.map +1 -1
  143. package/dist/internal/ans.d.ts +11 -0
  144. package/dist/internal/ans.d.ts.map +1 -1
  145. package/dist/internal/ans.js +18 -6
  146. package/dist/internal/ans.js.map +1 -1
  147. package/dist/internal/coin.d.ts +2 -0
  148. package/dist/internal/coin.d.ts.map +1 -1
  149. package/dist/internal/coin.js +3 -1
  150. package/dist/internal/coin.js.map +1 -1
  151. package/dist/internal/digitalAsset.d.ts +30 -0
  152. package/dist/internal/digitalAsset.d.ts.map +1 -1
  153. package/dist/internal/digitalAsset.js +45 -15
  154. package/dist/internal/digitalAsset.js.map +1 -1
  155. package/dist/internal/fungibleAsset.d.ts +4 -0
  156. package/dist/internal/fungibleAsset.d.ts.map +1 -1
  157. package/dist/internal/fungibleAsset.js +6 -2
  158. package/dist/internal/fungibleAsset.js.map +1 -1
  159. package/dist/internal/keyless.d.ts +39 -1
  160. package/dist/internal/keyless.d.ts.map +1 -1
  161. package/dist/internal/keyless.js +71 -13
  162. package/dist/internal/keyless.js.map +1 -1
  163. package/dist/internal/transaction.d.ts +24 -1
  164. package/dist/internal/transaction.d.ts.map +1 -1
  165. package/dist/internal/transaction.js +125 -4
  166. package/dist/internal/transaction.js.map +1 -1
  167. package/dist/internal/transactionSubmission.d.ts +2 -0
  168. package/dist/internal/transactionSubmission.d.ts.map +1 -1
  169. package/dist/internal/transactionSubmission.js +3 -1
  170. package/dist/internal/transactionSubmission.js.map +1 -1
  171. package/dist/transactions/authenticator/account.d.ts.map +1 -1
  172. package/dist/transactions/authenticator/transaction.d.ts.map +1 -1
  173. package/dist/transactions/instances/chainId.d.ts.map +1 -1
  174. package/dist/transactions/instances/encryptedPayload.d.ts.map +1 -1
  175. package/dist/transactions/instances/encryptedPayload.js.map +1 -1
  176. package/dist/transactions/instances/identifier.d.ts.map +1 -1
  177. package/dist/transactions/instances/moduleId.d.ts.map +1 -1
  178. package/dist/transactions/instances/multiAgentTransaction.d.ts.map +1 -1
  179. package/dist/transactions/instances/rawTransaction.d.ts.map +1 -1
  180. package/dist/transactions/instances/rotationProofChallenge.d.ts.map +1 -1
  181. package/dist/transactions/instances/signedTransaction.d.ts.map +1 -1
  182. package/dist/transactions/instances/simpleTransaction.d.ts.map +1 -1
  183. package/dist/transactions/instances/transactionPayload.d.ts.map +1 -1
  184. package/dist/transactions/management/accountSequenceNumber.d.ts.map +1 -1
  185. package/dist/transactions/management/asyncQueue.d.ts.map +1 -1
  186. package/dist/transactions/management/transactionWorker.d.ts +10 -6
  187. package/dist/transactions/management/transactionWorker.d.ts.map +1 -1
  188. package/dist/transactions/management/transactionWorker.js +28 -24
  189. package/dist/transactions/management/transactionWorker.js.map +1 -1
  190. package/dist/transactions/transactionBuilder/index.d.ts +1 -0
  191. package/dist/transactions/transactionBuilder/index.d.ts.map +1 -1
  192. package/dist/transactions/transactionBuilder/index.js +1 -0
  193. package/dist/transactions/transactionBuilder/index.js.map +1 -1
  194. package/dist/transactions/transactionBuilder/scriptAbi.d.ts +10 -0
  195. package/dist/transactions/transactionBuilder/scriptAbi.d.ts.map +1 -0
  196. package/dist/transactions/transactionBuilder/scriptAbi.js +863 -0
  197. package/dist/transactions/transactionBuilder/scriptAbi.js.map +1 -0
  198. package/dist/transactions/transactionBuilder/structEnumParser.d.ts.map +1 -1
  199. package/dist/transactions/transactionBuilder/structEnumParser.js.map +1 -1
  200. package/dist/transactions/transactionBuilder/transactionBuilder.d.ts +7 -2
  201. package/dist/transactions/transactionBuilder/transactionBuilder.d.ts.map +1 -1
  202. package/dist/transactions/transactionBuilder/transactionBuilder.js +65 -1
  203. package/dist/transactions/transactionBuilder/transactionBuilder.js.map +1 -1
  204. package/dist/transactions/typeTag/index.d.ts.map +1 -1
  205. package/dist/transactions/typeTag/index.js.map +1 -1
  206. package/dist/transactions/typeTag/parser.d.ts.map +1 -1
  207. package/dist/transactions/typeTag/parser.js.map +1 -1
  208. package/dist/transactions/types.d.ts +9 -4
  209. package/dist/transactions/types.d.ts.map +1 -1
  210. package/dist/types/generated/queries.d.ts.map +1 -1
  211. package/dist/types/generated/queries.js.map +1 -1
  212. package/dist/types/keyless.d.ts +2 -2
  213. package/dist/types/keyless.d.ts.map +1 -1
  214. package/dist/types/types.d.ts +7 -2
  215. package/dist/types/types.d.ts.map +1 -1
  216. package/dist/types/types.js.map +1 -1
  217. package/dist/utils/const.d.ts +11 -0
  218. package/dist/utils/const.d.ts.map +1 -1
  219. package/dist/utils/const.js +11 -0
  220. package/dist/utils/const.js.map +1 -1
  221. package/dist/utils/helpers.d.ts.map +1 -1
  222. package/dist/utils/helpers.js.map +1 -1
  223. package/dist/utils/runtime.js.map +1 -1
  224. package/dist/version.d.ts +1 -1
  225. package/dist/version.js +1 -1
  226. package/package.json +27 -25
  227. package/src/api/account/abstraction.ts +23 -6
  228. package/src/api/ans.ts +9 -0
  229. package/src/api/aptosConfig.ts +14 -0
  230. package/src/api/coin.ts +2 -0
  231. package/src/api/digitalAsset.ts +30 -0
  232. package/src/api/fungibleAsset.ts +4 -0
  233. package/src/api/keyless.ts +39 -1
  234. package/src/api/transaction.ts +48 -1
  235. package/src/api/transactionSubmission/build.ts +16 -6
  236. package/src/api/transactionSubmission/simulate.ts +7 -3
  237. package/src/bcs/serializable/moveStructs.ts +80 -28
  238. package/src/cli/localNode.ts +17 -3
  239. package/src/client/core.ts +150 -10
  240. package/src/functions/keyless.ts +1 -0
  241. package/src/functions/transaction.ts +1 -0
  242. package/src/internal/abstraction.ts +41 -3
  243. package/src/internal/account.ts +60 -38
  244. package/src/internal/ans.ts +24 -6
  245. package/src/internal/coin.ts +4 -1
  246. package/src/internal/digitalAsset.ts +60 -9
  247. package/src/internal/fungibleAsset.ts +8 -2
  248. package/src/internal/keyless.ts +91 -14
  249. package/src/internal/transaction.ts +154 -4
  250. package/src/internal/transactionSubmission.ts +4 -1
  251. package/src/transactions/management/transactionWorker.ts +35 -23
  252. package/src/transactions/transactionBuilder/index.ts +1 -0
  253. package/src/transactions/transactionBuilder/scriptAbi.ts +1145 -0
  254. package/src/transactions/transactionBuilder/transactionBuilder.ts +97 -6
  255. package/src/transactions/types.ts +10 -4
  256. package/src/types/keyless.ts +2 -2
  257. package/src/types/types.ts +8 -2
  258. package/src/utils/const.ts +12 -0
  259. package/src/version.ts +1 -1
@@ -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: [],
@@ -951,48 +951,41 @@ async function doesAccountExistAtAddress(args: {
951
951
  }): Promise<boolean> {
952
952
  const { aptosConfig, accountAddress, options } = args;
953
953
  try {
954
- // Get the account resources and the balance of the account. We need to check both because
955
- // an account resource can exist with 0 balance and a balance can exist without an account resource (light accounts).
956
- const [accountResource, ownedObjects] = await Promise.all([
957
- getResourceFallible<{ authentication_key: string }>({
958
- aptosConfig,
959
- accountAddress,
960
- resourceType: "0x1::account::Account",
961
- }),
962
- getAccountOwnedObjects({
963
- aptosConfig,
964
- accountAddress,
965
- options: {
966
- limit: 1,
967
- },
968
- }),
969
- ]);
954
+ // Check the account resource first. For standard accounts this is sufficient proof of
955
+ // existence, and querying owned objects in parallel used to fail the whole check when
956
+ // the indexer `current_objects` query timed out.
957
+ const accountResource = await getResourceFallible<{ authentication_key: string }>({
958
+ aptosConfig,
959
+ accountAddress,
960
+ resourceType: "0x1::account::Account",
961
+ });
970
962
 
971
- // If the account resource is not found and the balance is 0, then the account does not exist.
972
- if (!accountResource && ownedObjects.length === 0) {
973
- return false;
963
+ if (accountResource) {
964
+ if (!options?.withAuthKey) {
965
+ return true;
966
+ }
967
+ return accountResource.authentication_key === options.withAuthKey.toString();
974
968
  }
975
969
 
976
- // If no auth key is provided as an argument, return true.
977
- if (!options?.withAuthKey) {
978
- return true;
979
- }
970
+ // No account resource: still treat light accounts (objects but no resource) as existing.
971
+ const ownedObjects = await getAccountOwnedObjects({
972
+ aptosConfig,
973
+ accountAddress,
974
+ options: {
975
+ limit: 1,
976
+ },
977
+ });
980
978
 
981
- // Get the auth key from the account resource if it exists. If the account resource does not exist,
982
- // then the auth key is the account address by default.
983
- let authKey;
984
- if (accountResource) {
985
- authKey = accountResource.authentication_key;
986
- } else {
987
- authKey = accountAddress.toStringLong();
979
+ if (ownedObjects.length === 0) {
980
+ return false;
988
981
  }
989
982
 
990
- if (authKey !== options.withAuthKey.toString()) {
991
- return false;
983
+ if (!options?.withAuthKey) {
984
+ return true;
992
985
  }
993
986
 
994
- // Else the account exists and the auth key matches.
995
- return true;
987
+ // Light accounts have no resource, so the auth key is the account address by convention.
988
+ return accountAddress.toStringLong() === options.withAuthKey.toString();
996
989
  } catch (error: any) {
997
990
  throw new Error(`Error while checking if account exists at ${accountAddress.toString()}: ${error}`);
998
991
  }
@@ -1028,6 +1021,8 @@ function rotateAuthKeyAbi(): EntryFunctionABI {
1028
1021
  * @param args.fromAccount - The account from which the authentication key will be rotated.
1029
1022
  * @param args.toAccount - (Optional) The target account to rotate to. Required if not using toNewPrivateKey.
1030
1023
  * @param args.toNewPrivateKey - (Optional) The new private key to rotate to. Required if not using toAccount.
1024
+ * @param args.withFeePayer - Whether to build a sponsored transaction.
1025
+ * @param args.options - Optional settings for generating the transaction.
1031
1026
  *
1032
1027
  * @remarks
1033
1028
  * This function supports three modes of rotation:
@@ -1043,15 +1038,17 @@ export async function rotateAuthKey(
1043
1038
  args: {
1044
1039
  aptosConfig: AptosConfig;
1045
1040
  fromAccount: Account;
1041
+ withFeePayer?: boolean;
1046
1042
  options?: InputGenerateTransactionOptions;
1047
1043
  } & ({ toAccount: Ed25519Account | MultiEd25519Account } | { toNewPrivateKey: Ed25519PrivateKey }),
1048
1044
  ): Promise<SimpleTransaction> {
1049
- const { aptosConfig, fromAccount, options } = args;
1045
+ const { aptosConfig, fromAccount, withFeePayer, options } = args;
1050
1046
  if ("toNewPrivateKey" in args) {
1051
1047
  return rotateAuthKeyWithChallenge({
1052
1048
  aptosConfig,
1053
1049
  fromAccount,
1054
1050
  toNewPrivateKey: args.toNewPrivateKey,
1051
+ withFeePayer,
1055
1052
  options,
1056
1053
  });
1057
1054
  }
@@ -1061,22 +1058,42 @@ export async function rotateAuthKey(
1061
1058
  aptosConfig,
1062
1059
  fromAccount,
1063
1060
  toNewPrivateKey: args.toAccount.privateKey,
1061
+ withFeePayer,
1064
1062
  options,
1065
1063
  });
1066
1064
  }
1067
- return rotateAuthKeyWithChallenge({ aptosConfig, fromAccount, toAccount: args.toAccount, options });
1065
+ return rotateAuthKeyWithChallenge({
1066
+ aptosConfig,
1067
+ fromAccount,
1068
+ toAccount: args.toAccount,
1069
+ withFeePayer,
1070
+ options,
1071
+ });
1068
1072
  }
1069
1073
  throw new Error("Invalid arguments");
1070
1074
  }
1071
1075
 
1076
+ /**
1077
+ * Builds a challenge-based authentication-key rotation transaction.
1078
+ *
1079
+ * @param args - The arguments for the challenge-based rotation.
1080
+ * @param args.aptosConfig - The configuration settings for the Aptos network.
1081
+ * @param args.fromAccount - The account whose authentication key will be rotated.
1082
+ * @param args.toAccount - The optional target multi-signature account.
1083
+ * @param args.toNewPrivateKey - The optional target private key.
1084
+ * @param args.withFeePayer - Whether to build a sponsored transaction.
1085
+ * @param args.options - Optional settings for generating the transaction.
1086
+ * @returns A transaction that rotates the authentication key.
1087
+ */
1072
1088
  async function rotateAuthKeyWithChallenge(
1073
1089
  args: {
1074
1090
  aptosConfig: AptosConfig;
1075
1091
  fromAccount: Account;
1092
+ withFeePayer?: boolean;
1076
1093
  options?: InputGenerateTransactionOptions;
1077
1094
  } & ({ toNewPrivateKey: Ed25519PrivateKey } | { toAccount: MultiEd25519Account }),
1078
1095
  ): Promise<SimpleTransaction> {
1079
- const { aptosConfig, fromAccount, options } = args;
1096
+ const { aptosConfig, fromAccount, withFeePayer, options } = args;
1080
1097
  const accountInfo = await getInfo({
1081
1098
  aptosConfig,
1082
1099
  accountAddress: fromAccount.accountAddress,
@@ -1105,6 +1122,7 @@ async function rotateAuthKeyWithChallenge(
1105
1122
  return generateTransaction({
1106
1123
  aptosConfig,
1107
1124
  sender: fromAccount.accountAddress,
1125
+ withFeePayer,
1108
1126
  data: {
1109
1127
  function: "0x1::account::rotate_authentication_key",
1110
1128
  functionArguments: [
@@ -1139,6 +1157,8 @@ function rotateAuthKeyUnverifiedAbi(): EntryFunctionABI {
1139
1157
  * @param args.aptosConfig - The configuration settings for the Aptos network.
1140
1158
  * @param args.fromAccount - The account from which the authentication key will be rotated.
1141
1159
  * @param args.toNewPublicKey - The new public key to rotate to.
1160
+ * @param args.withFeePayer - Whether to build a sponsored transaction.
1161
+ * @param args.options - Optional settings for generating the transaction.
1142
1162
  * @returns A simple transaction object that can be submitted to the network.
1143
1163
  * @throws Error if the rotation fails or verification fails.
1144
1164
  *
@@ -1148,13 +1168,15 @@ export async function rotateAuthKeyUnverified(args: {
1148
1168
  aptosConfig: AptosConfig;
1149
1169
  fromAccount: Account;
1150
1170
  toNewPublicKey: AccountPublicKey;
1171
+ withFeePayer?: boolean;
1151
1172
  options?: InputGenerateTransactionOptions;
1152
1173
  }): Promise<SimpleTransaction> {
1153
- const { aptosConfig, fromAccount, toNewPublicKey, options } = args;
1174
+ const { aptosConfig, fromAccount, toNewPublicKey, withFeePayer, options } = args;
1154
1175
 
1155
1176
  return generateTransaction({
1156
1177
  aptosConfig,
1157
1178
  sender: fromAccount.accountAddress,
1179
+ withFeePayer,
1158
1180
  data: {
1159
1181
  function: "0x1::account::rotate_authentication_key_from_public_key",
1160
1182
  functionArguments: [
@@ -166,7 +166,7 @@ function getRouterAddress(aptosConfig: AptosConfig): string {
166
166
  }
167
167
 
168
168
  const unwrapOption = <T>(option: any): T | undefined => {
169
- if (!!option && typeof option === "object" && "vec" in option && Array.isArray(option.vec)) {
169
+ if (option && typeof option === "object" && "vec" in option && Array.isArray(option.vec)) {
170
170
  return option.vec[0];
171
171
  }
172
172
 
@@ -213,6 +213,7 @@ export async function getOwnerAddress(args: {
213
213
  * @param transferable - Whether the name can be transferred to another owner.
214
214
  * @param toAddress - The address that will be set as the owner_address of the name.
215
215
  * @param targetAddress - The address that this name will resolve to.
216
+ * @param withFeePayer - Whether to build a fee-payer transaction.
216
217
  * @group Implementation
217
218
  */
218
219
  export interface RegisterNameParameters {
@@ -226,6 +227,7 @@ export interface RegisterNameParameters {
226
227
  transferable?: boolean;
227
228
  toAddress?: AccountAddressInput;
228
229
  targetAddress?: AccountAddressInput;
230
+ withFeePayer?: boolean;
229
231
  options?: InputGenerateTransactionOptions;
230
232
  }
231
233
 
@@ -240,6 +242,7 @@ export interface RegisterNameParameters {
240
242
  * @param args.sender - The account details of the sender initiating the registration.
241
243
  * @param args.targetAddress - The target address for the registration, which is the address the name will resolve to.
242
244
  * @param args.toAddress - The address that will be set as the owner_address in records, defaults to sender if not provided.
245
+ * @param args.withFeePayer - Whether to build a fee-payer transaction.
243
246
  * @param args.options - Additional options for the registration process.
244
247
  * @param args.transferable - Indicates whether the registered name is transferable to another account.
245
248
  *
@@ -253,7 +256,7 @@ export interface RegisterNameParameters {
253
256
  export async function registerName(
254
257
  args: RegisterNameParameters,
255
258
  ): Promise<{ transaction: SimpleTransaction; data: InputEntryFunctionData }> {
256
- const { aptosConfig, expiration, name, sender, targetAddress, toAddress, options, transferable } = args;
259
+ const { aptosConfig, expiration, name, sender, targetAddress, toAddress, withFeePayer, options, transferable } = args;
257
260
  const routerAddress = getRouterAddress(aptosConfig);
258
261
  const { domainName, subdomainName } = isValidANSName(name);
259
262
 
@@ -288,6 +291,7 @@ export async function registerName(
288
291
  aptosConfig,
289
292
  sender: AccountAddress.from(sender).toString(),
290
293
  data,
294
+ withFeePayer,
291
295
  options,
292
296
  });
293
297
 
@@ -331,6 +335,7 @@ export async function registerName(
331
335
  aptosConfig,
332
336
  sender: AccountAddress.from(sender).toString(),
333
337
  data,
338
+ withFeePayer,
334
339
  options,
335
340
  });
336
341
 
@@ -411,6 +416,7 @@ export async function getPrimaryName(args: {
411
416
  * @param args.aptosConfig - The Aptos configuration object.
412
417
  * @param args.sender - The account that is sending the transaction.
413
418
  * @param args.name - The name to set as the primary name. If omitted, the function will clear the primary name.
419
+ * @param args.withFeePayer - Whether to build a fee-payer transaction.
414
420
  * @param args.options - Optional transaction generation options.
415
421
  * @returns A transaction object representing the operation.
416
422
  * @group Implementation
@@ -419,9 +425,10 @@ export async function setPrimaryName(args: {
419
425
  aptosConfig: AptosConfig;
420
426
  sender: AccountAddressInput;
421
427
  name?: string;
428
+ withFeePayer?: boolean;
422
429
  options?: InputGenerateTransactionOptions;
423
430
  }): Promise<{ transaction: SimpleTransaction; data: InputEntryFunctionData }> {
424
- const { aptosConfig, sender, name, options } = args;
431
+ const { aptosConfig, sender, name, withFeePayer, options } = args;
425
432
  const routerAddress = getRouterAddress(aptosConfig);
426
433
 
427
434
  if (!name) {
@@ -434,6 +441,7 @@ export async function setPrimaryName(args: {
434
441
  aptosConfig,
435
442
  sender: AccountAddress.from(sender).toString(),
436
443
  data,
444
+ withFeePayer,
437
445
  options,
438
446
  });
439
447
 
@@ -454,6 +462,7 @@ export async function setPrimaryName(args: {
454
462
  aptosConfig,
455
463
  sender: AccountAddress.from(sender).toString(),
456
464
  data,
465
+ withFeePayer,
457
466
  options,
458
467
  });
459
468
 
@@ -503,6 +512,7 @@ export async function getTargetAddress(args: {
503
512
  * @param args.sender - The account that is sending the transaction.
504
513
  * @param args.name - The name of the domain or subdomain to be set.
505
514
  * @param args.address - The address to be associated with the domain or subdomain.
515
+ * @param args.withFeePayer - Whether to build a fee-payer transaction.
506
516
  * @param args.options - Optional parameters for generating the transaction.
507
517
  *
508
518
  * @returns A transaction object representing the set target address operation.
@@ -513,9 +523,10 @@ export async function setTargetAddress(args: {
513
523
  sender: AccountAddressInput;
514
524
  name: string;
515
525
  address: AccountAddressInput;
526
+ withFeePayer?: boolean;
516
527
  options?: InputGenerateTransactionOptions;
517
528
  }): Promise<{ transaction: SimpleTransaction; data: InputEntryFunctionData }> {
518
- const { aptosConfig, sender, name, address, options } = args;
529
+ const { aptosConfig, sender, name, address, withFeePayer, options } = args;
519
530
  const routerAddress = getRouterAddress(aptosConfig);
520
531
  const { domainName, subdomainName } = isValidANSName(name);
521
532
 
@@ -528,6 +539,7 @@ export async function setTargetAddress(args: {
528
539
  aptosConfig,
529
540
  sender: AccountAddress.from(sender).toString(),
530
541
  data,
542
+ withFeePayer,
531
543
  options,
532
544
  });
533
545
 
@@ -545,6 +557,7 @@ export async function setTargetAddress(args: {
545
557
  * @param args.aptosConfig - The configuration settings for the Aptos network.
546
558
  * @param args.sender - The account that is sending the transaction.
547
559
  * @param args.name - The name of the domain or subdomain to clear the target address for.
560
+ * @param args.withFeePayer - Whether to build a fee-payer transaction.
548
561
  * @param args.options - Optional parameters for generating the transaction.
549
562
  *
550
563
  * @returns A transaction object representing the clear target address operation.
@@ -554,9 +567,10 @@ export async function clearTargetAddress(args: {
554
567
  aptosConfig: AptosConfig;
555
568
  sender: AccountAddressInput;
556
569
  name: string;
570
+ withFeePayer?: boolean;
557
571
  options?: InputGenerateTransactionOptions;
558
572
  }): Promise<{ transaction: SimpleTransaction; data: InputEntryFunctionData }> {
559
- const { aptosConfig, sender, name, options } = args;
573
+ const { aptosConfig, sender, name, withFeePayer, options } = args;
560
574
  const routerAddress = getRouterAddress(aptosConfig);
561
575
  const { domainName, subdomainName } = isValidANSName(name);
562
576
 
@@ -569,6 +583,7 @@ export async function clearTargetAddress(args: {
569
583
  aptosConfig,
570
584
  sender: AccountAddress.from(sender).toString(),
571
585
  data,
586
+ withFeePayer,
572
587
  options,
573
588
  });
574
589
 
@@ -920,6 +935,7 @@ export async function getANSGracePeriod(args: { aptosConfig: AptosConfig }): Pro
920
935
  * @param args.sender - The account that is sending the renewal transaction.
921
936
  * @param args.name - The name of the domain to renew.
922
937
  * @param args.years - The number of years to renew the domain for. Currently, only 1 year renewals are supported. (optional, default is 1)
938
+ * @param args.withFeePayer - Whether to build a fee-payer transaction.
923
939
  * @param args.options - Additional options for generating the transaction. (optional)
924
940
  * @throws Error if the name contains a subdomain or if the years parameter is not equal to 1.
925
941
  * @group Implementation
@@ -929,9 +945,10 @@ export async function renewDomain(args: {
929
945
  sender: AccountAddressInput;
930
946
  name: string;
931
947
  years?: 1;
948
+ withFeePayer?: boolean;
932
949
  options?: InputGenerateTransactionOptions;
933
950
  }): Promise<{ transaction: SimpleTransaction; data: InputEntryFunctionData }> {
934
- const { aptosConfig, sender, name, years = 1, options } = args;
951
+ const { aptosConfig, sender, name, years = 1, withFeePayer, options } = args;
935
952
  const routerAddress = getRouterAddress(aptosConfig);
936
953
  const renewalDuration = years * 31536000;
937
954
  const { domainName, subdomainName } = isValidANSName(name);
@@ -953,6 +970,7 @@ export async function renewDomain(args: {
953
970
  aptosConfig,
954
971
  sender: AccountAddress.from(sender).toString(),
955
972
  data,
973
+ withFeePayer,
956
974
  options,
957
975
  });
958
976
 
@@ -22,6 +22,7 @@ const coinTransferAbi: EntryFunctionABI = {
22
22
  * @param args.recipient - The address of the account receiving the coins.
23
23
  * @param args.amount - The amount of coins to transfer.
24
24
  * @param args.coinType - (Optional) The type of coin to transfer, defaults to Aptos Coin if not specified.
25
+ * @param args.withFeePayer - Whether to build a fee-payer transaction.
25
26
  * @param args.options - (Optional) Options for generating the transaction.
26
27
  * @group Implementation
27
28
  */
@@ -31,9 +32,10 @@ export async function transferCoinTransaction(args: {
31
32
  recipient: AccountAddressInput;
32
33
  amount: AnyNumber;
33
34
  coinType?: MoveStructId;
35
+ withFeePayer?: boolean;
34
36
  options?: InputGenerateTransactionOptions;
35
37
  }): Promise<SimpleTransaction> {
36
- const { aptosConfig, sender, recipient, amount, coinType, options } = args;
38
+ const { aptosConfig, sender, recipient, amount, coinType, withFeePayer, options } = args;
37
39
  const coinStructType = coinType ?? APTOS_COIN;
38
40
  return generateTransaction({
39
41
  aptosConfig,
@@ -44,6 +46,7 @@ export async function transferCoinTransaction(args: {
44
46
  functionArguments: [recipient, amount],
45
47
  abi: coinTransferAbi,
46
48
  },
49
+ withFeePayer,
47
50
  options,
48
51
  });
49
52
  }