@aptos-labs/ts-sdk 5.2.1 → 6.0.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 (314) hide show
  1. package/dist/common/{account-Dxsj5MIn.d.ts → account-Dpz_N9h-.d.ts} +7 -2
  2. package/dist/common/{chunk-3KK6QRXD.js → chunk-4RHBBU7C.js} +3 -3
  3. package/dist/common/{chunk-3KK6QRXD.js.map → chunk-4RHBBU7C.js.map} +1 -1
  4. package/dist/common/cli/index.d.ts +1 -1
  5. package/dist/common/cli/index.js +1 -1
  6. package/dist/common/cli/index.js.map +1 -1
  7. package/dist/common/index.d.ts +198 -28
  8. package/dist/common/index.js +37 -32
  9. package/dist/common/index.js.map +1 -1
  10. package/dist/esm/{Ed25519Account-DIIE2Drw.d.mts → Ed25519Account-BW_kXHC2.d.mts} +1 -1
  11. package/dist/esm/account/AbstractKeylessAccount.d.mts +3 -3
  12. package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
  13. package/dist/esm/account/AbstractedAccount.d.mts +2 -2
  14. package/dist/esm/account/AbstractedAccount.mjs +1 -1
  15. package/dist/esm/account/Account.d.mts +2 -2
  16. package/dist/esm/account/Account.mjs +1 -1
  17. package/dist/esm/account/AccountUtils.d.mts +3 -3
  18. package/dist/esm/account/AccountUtils.mjs +1 -1
  19. package/dist/esm/account/DerivableAbstractedAccount.d.mts +2 -2
  20. package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
  21. package/dist/esm/account/Ed25519Account.d.mts +2 -2
  22. package/dist/esm/account/Ed25519Account.mjs +1 -1
  23. package/dist/esm/account/EphemeralKeyPair.d.mts +1 -1
  24. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  25. package/dist/esm/account/FederatedKeylessAccount.d.mts +3 -3
  26. package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
  27. package/dist/esm/account/KeylessAccount.d.mts +3 -3
  28. package/dist/esm/account/KeylessAccount.mjs +1 -1
  29. package/dist/esm/account/MultiEd25519Account.d.mts +2 -2
  30. package/dist/esm/account/MultiEd25519Account.mjs +1 -1
  31. package/dist/esm/account/MultiKeyAccount.d.mts +3 -3
  32. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  33. package/dist/esm/account/SingleKeyAccount.d.mts +2 -2
  34. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  35. package/dist/esm/account/index.d.mts +3 -3
  36. package/dist/esm/account/index.mjs +1 -1
  37. package/dist/esm/account/utils.d.mts +1 -1
  38. package/dist/esm/account/utils.mjs +1 -1
  39. package/dist/esm/{account-CMR8C31P.d.mts → account-CcxnCdYZ.d.mts} +1 -1
  40. package/dist/esm/api/account/abstraction.d.mts +1 -1
  41. package/dist/esm/api/account/abstraction.mjs +1 -1
  42. package/dist/esm/api/account.d.mts +2 -2
  43. package/dist/esm/api/account.mjs +1 -1
  44. package/dist/esm/api/ans.d.mts +92 -26
  45. package/dist/esm/api/ans.mjs +1 -1
  46. package/dist/esm/api/aptos.d.mts +4 -3
  47. package/dist/esm/api/aptos.mjs +1 -1
  48. package/dist/esm/api/aptosConfig.d.mts +1 -1
  49. package/dist/esm/api/coin.d.mts +1 -1
  50. package/dist/esm/api/coin.mjs +1 -1
  51. package/dist/esm/api/digitalAsset.d.mts +2 -2
  52. package/dist/esm/api/digitalAsset.mjs +1 -1
  53. package/dist/esm/api/faucet.d.mts +1 -1
  54. package/dist/esm/api/faucet.mjs +1 -1
  55. package/dist/esm/api/fungibleAsset.d.mts +2 -2
  56. package/dist/esm/api/fungibleAsset.mjs +1 -1
  57. package/dist/esm/api/general.d.mts +1 -1
  58. package/dist/esm/api/general.mjs +1 -1
  59. package/dist/esm/api/index.d.mts +4 -3
  60. package/dist/esm/api/index.mjs +1 -1
  61. package/dist/esm/api/keyless.d.mts +3 -3
  62. package/dist/esm/api/keyless.mjs +1 -1
  63. package/dist/esm/api/object.d.mts +1 -1
  64. package/dist/esm/api/object.mjs +1 -1
  65. package/dist/esm/api/staking.d.mts +1 -1
  66. package/dist/esm/api/staking.mjs +1 -1
  67. package/dist/esm/api/table.d.mts +1 -1
  68. package/dist/esm/api/table.mjs +1 -1
  69. package/dist/esm/api/transaction.d.mts +2 -2
  70. package/dist/esm/api/transaction.mjs +1 -1
  71. package/dist/esm/api/transactionSubmission/build.d.mts +1 -1
  72. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  73. package/dist/esm/api/transactionSubmission/helpers.d.mts +1 -1
  74. package/dist/esm/api/transactionSubmission/management.d.mts +2 -2
  75. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  76. package/dist/esm/api/transactionSubmission/sign.d.mts +2 -2
  77. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  78. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  79. package/dist/esm/api/transactionSubmission/simulate.d.mts +1 -1
  80. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  81. package/dist/esm/api/transactionSubmission/submit.d.mts +1 -1
  82. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  83. package/dist/esm/api/utils.d.mts +1 -1
  84. package/dist/esm/api/utils.mjs +1 -1
  85. package/dist/esm/bcs/consts.d.mts +1 -1
  86. package/dist/esm/bcs/deserializer.d.mts +1 -1
  87. package/dist/esm/bcs/index.d.mts +1 -1
  88. package/dist/esm/bcs/index.mjs +1 -1
  89. package/dist/esm/bcs/serializable/entryFunctionBytes.d.mts +1 -1
  90. package/dist/esm/bcs/serializable/fixedBytes.d.mts +1 -1
  91. package/dist/esm/bcs/serializable/movePrimitives.d.mts +1 -1
  92. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  93. package/dist/esm/bcs/serializable/moveStructs.d.mts +1 -1
  94. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  95. package/dist/esm/bcs/serializer.d.mts +1 -1
  96. package/dist/esm/chunk-2DPQMXUG.mjs +4 -0
  97. package/dist/esm/chunk-2DPQMXUG.mjs.map +1 -0
  98. package/dist/esm/{chunk-VO3JD6U6.mjs → chunk-2LCPW76G.mjs} +2 -2
  99. package/dist/esm/{chunk-GRF3NBRO.mjs → chunk-52PWWLJJ.mjs} +2 -2
  100. package/dist/esm/{chunk-3GNYDMRA.mjs → chunk-76SVQZDX.mjs} +2 -2
  101. package/dist/esm/{chunk-Z6PXP6MJ.mjs → chunk-BGZDJ5SM.mjs} +2 -2
  102. package/dist/esm/{chunk-DLD62OFZ.mjs → chunk-CUXCVNES.mjs} +2 -2
  103. package/dist/esm/chunk-DE5K76I2.mjs +1 -0
  104. package/dist/esm/{chunk-EIQBQ62N.mjs → chunk-F3NI6N7R.mjs} +2 -2
  105. package/dist/esm/chunk-FW6UHAQV.mjs +2 -0
  106. package/dist/esm/{chunk-VS5NYRHW.mjs.map → chunk-FW6UHAQV.mjs.map} +1 -1
  107. package/dist/esm/{chunk-C622NWP7.mjs → chunk-JN65XG2P.mjs} +2 -2
  108. package/dist/esm/{chunk-UL777LTI.mjs → chunk-LS2HRAVW.mjs} +24 -19
  109. package/dist/esm/chunk-LS2HRAVW.mjs.map +1 -0
  110. package/dist/esm/chunk-NP2IAUME.mjs +2 -0
  111. package/dist/esm/chunk-NP2IAUME.mjs.map +1 -0
  112. package/dist/esm/{chunk-TBOR2W2F.mjs → chunk-NTLOKAPD.mjs} +2 -2
  113. package/dist/esm/{chunk-KY4GDJA6.mjs → chunk-PXJEKGEG.mjs} +2 -2
  114. package/dist/esm/chunk-RQN6LA7E.mjs +2 -0
  115. package/dist/esm/{chunk-K3Q5EONX.mjs.map → chunk-RQN6LA7E.mjs.map} +1 -1
  116. package/dist/esm/{chunk-WBG25H7H.mjs → chunk-WZ6FL7CH.mjs} +2 -2
  117. package/dist/esm/{chunk-QITAALVJ.mjs → chunk-X674XJNJ.mjs} +2 -2
  118. package/dist/esm/cli/index.d.mts +1 -1
  119. package/dist/esm/cli/index.mjs +1 -1
  120. package/dist/esm/cli/localNode.mjs +1 -1
  121. package/dist/esm/cli/move.d.mts +1 -1
  122. package/dist/esm/client/core.d.mts +1 -1
  123. package/dist/esm/client/core.mjs +1 -1
  124. package/dist/esm/client/get.d.mts +1 -1
  125. package/dist/esm/client/get.mjs +1 -1
  126. package/dist/esm/client/index.d.mts +1 -1
  127. package/dist/esm/client/index.mjs +1 -1
  128. package/dist/esm/client/post.d.mts +1 -1
  129. package/dist/esm/client/post.mjs +1 -1
  130. package/dist/esm/core/account/index.d.mts +1 -1
  131. package/dist/esm/core/account/index.mjs +1 -1
  132. package/dist/esm/core/account/utils/address.d.mts +1 -1
  133. package/dist/esm/core/account/utils/address.mjs +1 -1
  134. package/dist/esm/core/account/utils/index.d.mts +1 -1
  135. package/dist/esm/core/account/utils/index.mjs +1 -1
  136. package/dist/esm/core/accountAddress.d.mts +1 -1
  137. package/dist/esm/core/accountAddress.mjs +1 -1
  138. package/dist/esm/core/authenticationKey.d.mts +1 -1
  139. package/dist/esm/core/authenticationKey.mjs +1 -1
  140. package/dist/esm/core/crypto/abstraction.d.mts +1 -1
  141. package/dist/esm/core/crypto/abstraction.mjs +1 -1
  142. package/dist/esm/core/crypto/deserializationUtils.d.mts +1 -1
  143. package/dist/esm/core/crypto/deserializationUtils.mjs +1 -1
  144. package/dist/esm/core/crypto/ed25519.d.mts +1 -1
  145. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  146. package/dist/esm/core/crypto/ephemeral.d.mts +1 -1
  147. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  148. package/dist/esm/core/crypto/federatedKeyless.d.mts +2 -2
  149. package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
  150. package/dist/esm/core/crypto/index.d.mts +2 -2
  151. package/dist/esm/core/crypto/index.mjs +1 -1
  152. package/dist/esm/core/crypto/keyless.d.mts +2 -2
  153. package/dist/esm/core/crypto/keyless.mjs +1 -1
  154. package/dist/esm/core/crypto/multiEd25519.d.mts +1 -1
  155. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  156. package/dist/esm/core/crypto/multiKey.d.mts +1 -1
  157. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  158. package/dist/esm/core/crypto/privateKey.d.mts +1 -1
  159. package/dist/esm/core/crypto/privateKey.mjs +1 -1
  160. package/dist/esm/core/crypto/proof.d.mts +1 -1
  161. package/dist/esm/core/crypto/proof.mjs +1 -1
  162. package/dist/esm/core/crypto/publicKey.d.mts +1 -1
  163. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  164. package/dist/esm/core/crypto/secp256k1.d.mts +1 -1
  165. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  166. package/dist/esm/core/crypto/secp256r1.d.mts +1 -1
  167. package/dist/esm/core/crypto/secp256r1.mjs +1 -1
  168. package/dist/esm/core/crypto/signature.d.mts +1 -1
  169. package/dist/esm/core/crypto/signature.mjs +1 -1
  170. package/dist/esm/core/crypto/singleKey.d.mts +1 -1
  171. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  172. package/dist/esm/core/crypto/types.d.mts +1 -1
  173. package/dist/esm/core/crypto/utils.d.mts +1 -1
  174. package/dist/esm/core/crypto/utils.mjs +1 -1
  175. package/dist/esm/core/hex.d.mts +1 -1
  176. package/dist/esm/core/index.d.mts +2 -2
  177. package/dist/esm/core/index.mjs +1 -1
  178. package/dist/esm/errors/index.d.mts +1 -1
  179. package/dist/esm/errors/index.mjs +1 -1
  180. package/dist/esm/{federatedKeyless-DE7i_6s_.d.mts → federatedKeyless-BzaYmP03.d.mts} +1 -1
  181. package/dist/esm/index.d.mts +4 -3
  182. package/dist/esm/index.mjs +1 -1
  183. package/dist/esm/internal/abstraction.d.mts +1 -1
  184. package/dist/esm/internal/abstraction.mjs +1 -1
  185. package/dist/esm/internal/account.d.mts +2 -2
  186. package/dist/esm/internal/account.mjs +1 -1
  187. package/dist/esm/internal/ans.d.mts +85 -33
  188. package/dist/esm/internal/ans.mjs +1 -1
  189. package/dist/esm/internal/coin.d.mts +1 -1
  190. package/dist/esm/internal/coin.mjs +1 -1
  191. package/dist/esm/internal/digitalAsset.d.mts +2 -2
  192. package/dist/esm/internal/digitalAsset.mjs +1 -1
  193. package/dist/esm/internal/faucet.d.mts +1 -1
  194. package/dist/esm/internal/faucet.mjs +1 -1
  195. package/dist/esm/internal/fungibleAsset.d.mts +2 -2
  196. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  197. package/dist/esm/internal/general.d.mts +1 -1
  198. package/dist/esm/internal/general.mjs +1 -1
  199. package/dist/esm/internal/keyless.d.mts +3 -3
  200. package/dist/esm/internal/keyless.mjs +1 -1
  201. package/dist/esm/internal/object.d.mts +1 -1
  202. package/dist/esm/internal/object.mjs +1 -1
  203. package/dist/esm/internal/staking.d.mts +1 -1
  204. package/dist/esm/internal/staking.mjs +1 -1
  205. package/dist/esm/internal/table.d.mts +1 -1
  206. package/dist/esm/internal/table.mjs +1 -1
  207. package/dist/esm/internal/transaction.d.mts +1 -1
  208. package/dist/esm/internal/transaction.mjs +1 -1
  209. package/dist/esm/internal/transactionSubmission.d.mts +2 -2
  210. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  211. package/dist/esm/internal/utils/index.d.mts +1 -1
  212. package/dist/esm/internal/utils/index.mjs +1 -1
  213. package/dist/esm/internal/utils/utils.d.mts +1 -1
  214. package/dist/esm/internal/utils/utils.mjs +1 -1
  215. package/dist/esm/internal/view.d.mts +1 -1
  216. package/dist/esm/internal/view.mjs +1 -1
  217. package/dist/esm/transactions/authenticator/account.d.mts +1 -1
  218. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  219. package/dist/esm/transactions/authenticator/index.d.mts +1 -1
  220. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  221. package/dist/esm/transactions/authenticator/transaction.d.mts +1 -1
  222. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  223. package/dist/esm/transactions/index.d.mts +1 -1
  224. package/dist/esm/transactions/index.mjs +1 -1
  225. package/dist/esm/transactions/instances/chainId.d.mts +1 -1
  226. package/dist/esm/transactions/instances/identifier.d.mts +1 -1
  227. package/dist/esm/transactions/instances/index.d.mts +1 -1
  228. package/dist/esm/transactions/instances/index.mjs +1 -1
  229. package/dist/esm/transactions/instances/moduleId.d.mts +1 -1
  230. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  231. package/dist/esm/transactions/instances/multiAgentTransaction.d.mts +1 -1
  232. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  233. package/dist/esm/transactions/instances/rawTransaction.d.mts +1 -1
  234. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  235. package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +1 -1
  236. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  237. package/dist/esm/transactions/instances/signedTransaction.d.mts +1 -1
  238. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  239. package/dist/esm/transactions/instances/simpleTransaction.d.mts +1 -1
  240. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  241. package/dist/esm/transactions/instances/transactionArgument.d.mts +1 -1
  242. package/dist/esm/transactions/instances/transactionPayload.d.mts +1 -1
  243. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  244. package/dist/esm/transactions/management/accountSequenceNumber.d.mts +2 -2
  245. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  246. package/dist/esm/transactions/management/index.d.mts +2 -2
  247. package/dist/esm/transactions/management/index.mjs +1 -1
  248. package/dist/esm/transactions/management/transactionWorker.d.mts +2 -2
  249. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  250. package/dist/esm/transactions/transactionBuilder/helpers.d.mts +1 -1
  251. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  252. package/dist/esm/transactions/transactionBuilder/index.d.mts +1 -1
  253. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  254. package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +1 -1
  255. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  256. package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +1 -1
  257. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  258. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +1 -1
  259. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  260. package/dist/esm/transactions/typeTag/index.d.mts +1 -1
  261. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  262. package/dist/esm/transactions/typeTag/parser.d.mts +1 -1
  263. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  264. package/dist/esm/transactions/types.d.mts +1 -1
  265. package/dist/esm/types/ans.d.mts +109 -0
  266. package/dist/esm/types/ans.mjs +2 -0
  267. package/dist/esm/types/ans.mjs.map +1 -0
  268. package/dist/esm/types/generated/operations.d.mts +5 -0
  269. package/dist/esm/types/generated/queries.d.mts +27 -27
  270. package/dist/esm/types/generated/queries.mjs +1 -1
  271. package/dist/esm/types/generated/types.d.mts +191 -7
  272. package/dist/esm/types/generated/types.mjs +1 -1
  273. package/dist/esm/types/generated/types.mjs.map +1 -1
  274. package/dist/esm/types/index.d.mts +2 -1
  275. package/dist/esm/types/index.mjs +1 -1
  276. package/dist/esm/types/types.d.mts +1 -1
  277. package/dist/esm/utils/helpers.d.mts +1 -1
  278. package/dist/esm/utils/helpers.mjs +1 -1
  279. package/dist/esm/utils/index.d.mts +1 -1
  280. package/dist/esm/utils/index.mjs +1 -1
  281. package/dist/esm/utils/normalizeBundle.d.mts +1 -1
  282. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  283. package/dist/esm/version.d.mts +1 -1
  284. package/dist/esm/version.mjs +1 -1
  285. package/package.json +2 -2
  286. package/src/api/ans.ts +70 -25
  287. package/src/internal/ans.ts +279 -109
  288. package/src/internal/queries/getNames.graphql +5 -0
  289. package/src/transactions/transactionBuilder/transactionBuilder.ts +4 -4
  290. package/src/transactions/types.ts +1 -1
  291. package/src/types/ans.ts +110 -0
  292. package/src/types/generated/operations.ts +1 -0
  293. package/src/types/generated/queries.ts +163 -76
  294. package/src/types/generated/types.ts +216 -6
  295. package/src/types/index.ts +1 -0
  296. package/src/version.ts +1 -1
  297. package/dist/esm/chunk-FD6FGKYY.mjs +0 -1
  298. package/dist/esm/chunk-K3Q5EONX.mjs +0 -2
  299. package/dist/esm/chunk-UL777LTI.mjs.map +0 -1
  300. package/dist/esm/chunk-VS5NYRHW.mjs +0 -2
  301. package/dist/esm/chunk-ZSO5R7FV.mjs +0 -4
  302. package/dist/esm/chunk-ZSO5R7FV.mjs.map +0 -1
  303. /package/dist/esm/{chunk-VO3JD6U6.mjs.map → chunk-2LCPW76G.mjs.map} +0 -0
  304. /package/dist/esm/{chunk-GRF3NBRO.mjs.map → chunk-52PWWLJJ.mjs.map} +0 -0
  305. /package/dist/esm/{chunk-3GNYDMRA.mjs.map → chunk-76SVQZDX.mjs.map} +0 -0
  306. /package/dist/esm/{chunk-Z6PXP6MJ.mjs.map → chunk-BGZDJ5SM.mjs.map} +0 -0
  307. /package/dist/esm/{chunk-DLD62OFZ.mjs.map → chunk-CUXCVNES.mjs.map} +0 -0
  308. /package/dist/esm/{chunk-FD6FGKYY.mjs.map → chunk-DE5K76I2.mjs.map} +0 -0
  309. /package/dist/esm/{chunk-EIQBQ62N.mjs.map → chunk-F3NI6N7R.mjs.map} +0 -0
  310. /package/dist/esm/{chunk-C622NWP7.mjs.map → chunk-JN65XG2P.mjs.map} +0 -0
  311. /package/dist/esm/{chunk-TBOR2W2F.mjs.map → chunk-NTLOKAPD.mjs.map} +0 -0
  312. /package/dist/esm/{chunk-KY4GDJA6.mjs.map → chunk-PXJEKGEG.mjs.map} +0 -0
  313. /package/dist/esm/{chunk-WBG25H7H.mjs.map → chunk-WZ6FL7CH.mjs.map} +0 -0
  314. /package/dist/esm/{chunk-QITAALVJ.mjs.map → chunk-X674XJNJ.mjs.map} +0 -0
@@ -10,10 +10,19 @@
10
10
  */
11
11
 
12
12
  import { AptosConfig } from "../api/aptosConfig";
13
- import { Account } from "../account";
14
13
  import { AccountAddress, AccountAddressInput } from "../core";
15
- import { InputGenerateTransactionOptions } from "../transactions/types";
16
- import { GetANSNameResponse, MoveAddressType, OrderByArg, PaginationArgs, WhereArg } from "../types";
14
+ import { InputGenerateTransactionOptions, InputEntryFunctionData } from "../transactions/types";
15
+ import {
16
+ AnsName,
17
+ AnsTokenStandard,
18
+ ExpirationStatus,
19
+ MoveAddressType,
20
+ OrderByArg,
21
+ PaginationArgs,
22
+ RawANSName,
23
+ SubdomainExpirationPolicy,
24
+ WhereArg,
25
+ } from "../types";
17
26
  import { GetNamesQuery } from "../types/generated/operations";
18
27
  import { GetNames } from "../types/generated/queries";
19
28
  import { CurrentAptosNamesBoolExp } from "../types/generated/types";
@@ -23,6 +32,10 @@ import { view } from "./view";
23
32
  import { generateTransaction } from "./transactionSubmission";
24
33
  import { SimpleTransaction } from "../transactions/instances/simpleTransaction";
25
34
 
35
+ let GRACE_PERIOD_IN_SECONDS: number | undefined;
36
+
37
+ const RENEWAL_MONTHS_WINDOW = 6;
38
+
26
39
  export const VALIDATION_RULES_DESCRIPTION = [
27
40
  "A name must be between 3 and 63 characters long,",
28
41
  "and can only contain lowercase a-z, 0-9, and hyphens.",
@@ -74,40 +87,52 @@ export function isValidANSName(name: string): { domainName: string; subdomainNam
74
87
  }
75
88
 
76
89
  /**
77
- * Policy for determining how subdomains expire in relation to their parent domain.
78
- * @group Implementation
79
- */
80
- export enum SubdomainExpirationPolicy {
81
- Independent = 0,
82
- FollowsDomain = 1,
83
- }
84
-
85
- /**
86
- * Determine if a given ANS name is considered active based on its expiration dates.
87
- * Domains are active if their expiration date is in the future, while subdomains may
88
- * follow their parent's expiration policy (1) or expire independently (0).
89
- * If the subdomain is expiring independently, it can expire before their parent, but not after.
90
+ * Determines the status of an ANS name's expiration.
90
91
  *
91
92
  * @param name - An ANS name returned from one of the functions of the SDK.
92
- * @returns A boolean indicating whether the contract considers the name active or not.
93
+ * @returns An ExpirationStatus indicating whether the name is Active, InGracePeriod, or Expired.
93
94
  * @group Implementation
94
95
  */
95
- export function isActiveANSName(name: GetANSNameResponse[0]): boolean {
96
- if (!name) return false;
96
+ export function getANSExpirationStatus({
97
+ aptosConfig,
98
+ name,
99
+ gracePeriod,
100
+ }: {
101
+ name: RawANSName;
102
+ aptosConfig: AptosConfig;
103
+ gracePeriod: number;
104
+ }): ExpirationStatus {
105
+ if (!name) return ExpirationStatus.Expired;
106
+
107
+ const gracePeriodMs = gracePeriod * 1000; // Convert to milliseconds
108
+
109
+ const now = Date.now();
110
+
111
+ const tldExpirationTime = new Date(name.domain_expiration_timestamp).getTime();
112
+ const nameExpirationTime = new Date(name.expiration_timestamp).getTime();
97
113
 
98
- const isTLDExpired = new Date(name.domain_expiration_timestamp).getTime() < Date.now();
99
- const isExpired = new Date(name.expiration_timestamp).getTime() < Date.now();
114
+ const isTLDExpired = tldExpirationTime < now;
115
+ const isNameExpired = nameExpirationTime < now;
116
+ const isInGracePeriod = isNameExpired && now - nameExpirationTime < gracePeriodMs;
117
+ const isTLDInGracePeriod = isTLDExpired && now - tldExpirationTime < gracePeriodMs;
100
118
 
101
119
  // If we are a subdomain, if our parent is expired we are always expired
102
- if (name.subdomain && isTLDExpired) return false;
120
+ if (name.subdomain && isTLDExpired && !isTLDInGracePeriod) {
121
+ return ExpirationStatus.Expired;
122
+ }
103
123
 
104
124
  // If we are a subdomain and our expiration policy is to follow the domain, we
105
- // are active (since we know our parent is not expired by this point)
106
- if (name.subdomain && name.subdomain_expiration_policy === SubdomainExpirationPolicy.FollowsDomain) return true;
125
+ // follow the parent's status (since we know our parent is not fully expired by this point)
126
+ if (name.subdomain && name.subdomain_expiration_policy === SubdomainExpirationPolicy.FollowsDomain) {
127
+ if (isTLDInGracePeriod) return ExpirationStatus.InGracePeriod;
128
+ return ExpirationStatus.Active;
129
+ }
107
130
 
108
131
  // At this point, we are either a TLD or a subdomain with an independent
109
- // expiration policy, we are active as long as we the expiration timestamp
110
- return !isExpired;
132
+ // expiration policy, check the name's expiration status
133
+ if (isInGracePeriod) return ExpirationStatus.InGracePeriod;
134
+ if (isNameExpired) return ExpirationStatus.Expired;
135
+ return ExpirationStatus.Active;
111
136
  }
112
137
 
113
138
  export const LOCAL_ANS_ACCOUNT_PK =
@@ -193,7 +218,7 @@ export async function getOwnerAddress(args: {
193
218
  */
194
219
  export interface RegisterNameParameters {
195
220
  aptosConfig: AptosConfig;
196
- sender: Account;
221
+ sender: AccountAddressInput;
197
222
  name: string;
198
223
  expiration:
199
224
  | { policy: "domain"; years?: 1 }
@@ -226,7 +251,9 @@ export interface RegisterNameParameters {
226
251
  * @returns A transaction object representing the registration process.
227
252
  * @group Implementation
228
253
  */
229
- export async function registerName(args: RegisterNameParameters): Promise<SimpleTransaction> {
254
+ export async function registerName(
255
+ args: RegisterNameParameters,
256
+ ): Promise<{ transaction: SimpleTransaction; data: InputEntryFunctionData }> {
230
257
  const { aptosConfig, expiration, name, sender, targetAddress, toAddress, options, transferable } = args;
231
258
  const routerAddress = getRouterAddress(aptosConfig);
232
259
  const { domainName, subdomainName } = isValidANSName(name);
@@ -253,17 +280,22 @@ export async function registerName(args: RegisterNameParameters): Promise<Simple
253
280
  const secondsInYear = 31536000;
254
281
  const registrationDuration = years * secondsInYear;
255
282
 
283
+ const data: InputEntryFunctionData = {
284
+ function: `${routerAddress}::router::register_domain`,
285
+ functionArguments: [domainName, registrationDuration, targetAddress, toAddress],
286
+ };
287
+
256
288
  const transaction = await generateTransaction({
257
289
  aptosConfig,
258
- sender: sender.accountAddress.toString(),
259
- data: {
260
- function: `${routerAddress}::router::register_domain`,
261
- functionArguments: [domainName, registrationDuration, targetAddress, toAddress],
262
- },
290
+ sender: AccountAddress.from(sender).toString(),
291
+ data,
263
292
  options,
264
293
  });
265
294
 
266
- return transaction;
295
+ return {
296
+ transaction,
297
+ data,
298
+ };
267
299
  }
268
300
 
269
301
  // We are a subdomain
@@ -283,25 +315,30 @@ export async function registerName(args: RegisterNameParameters): Promise<Simple
283
315
  throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");
284
316
  }
285
317
 
318
+ const data: InputEntryFunctionData = {
319
+ function: `${routerAddress}::router::register_subdomain`,
320
+ functionArguments: [
321
+ domainName,
322
+ subdomainName,
323
+ Math.round(expirationDateInMillisecondsSinceEpoch / 1000),
324
+ expiration.policy === "subdomain:follow-domain" ? 1 : 0,
325
+ !!transferable,
326
+ targetAddress,
327
+ toAddress,
328
+ ],
329
+ };
330
+
286
331
  const transaction = await generateTransaction({
287
332
  aptosConfig,
288
- sender: sender.accountAddress.toString(),
289
- data: {
290
- function: `${routerAddress}::router::register_subdomain`,
291
- functionArguments: [
292
- domainName,
293
- subdomainName,
294
- Math.round(expirationDateInMillisecondsSinceEpoch / 1000),
295
- expiration.policy === "subdomain:follow-domain" ? 1 : 0,
296
- !!transferable,
297
- targetAddress,
298
- toAddress,
299
- ],
300
- },
333
+ sender: AccountAddress.from(sender).toString(),
334
+ data,
301
335
  options,
302
336
  });
303
337
 
304
- return transaction;
338
+ return {
339
+ transaction,
340
+ data,
341
+ };
305
342
  }
306
343
 
307
344
  /**
@@ -381,40 +418,50 @@ export async function getPrimaryName(args: {
381
418
  */
382
419
  export async function setPrimaryName(args: {
383
420
  aptosConfig: AptosConfig;
384
- sender: Account;
421
+ sender: AccountAddressInput;
385
422
  name?: string;
386
423
  options?: InputGenerateTransactionOptions;
387
- }): Promise<SimpleTransaction> {
424
+ }): Promise<{ transaction: SimpleTransaction; data: InputEntryFunctionData }> {
388
425
  const { aptosConfig, sender, name, options } = args;
389
426
  const routerAddress = getRouterAddress(aptosConfig);
390
427
 
391
428
  if (!name) {
429
+ const data: InputEntryFunctionData = {
430
+ function: `${routerAddress}::router::clear_primary_name`,
431
+ functionArguments: [],
432
+ };
433
+
392
434
  const transaction = await generateTransaction({
393
435
  aptosConfig,
394
- sender: sender.accountAddress.toString(),
395
- data: {
396
- function: `${routerAddress}::router::clear_primary_name`,
397
- functionArguments: [],
398
- },
436
+ sender: AccountAddress.from(sender).toString(),
437
+ data,
399
438
  options,
400
439
  });
401
440
 
402
- return transaction;
441
+ return {
442
+ transaction,
443
+ data,
444
+ };
403
445
  }
404
446
 
405
447
  const { domainName, subdomainName } = isValidANSName(name);
406
448
 
449
+ const data: InputEntryFunctionData = {
450
+ function: `${routerAddress}::router::set_primary_name`,
451
+ functionArguments: [domainName, subdomainName],
452
+ };
453
+
407
454
  const transaction = await generateTransaction({
408
455
  aptosConfig,
409
- sender: sender.accountAddress.toString(),
410
- data: {
411
- function: `${routerAddress}::router::set_primary_name`,
412
- functionArguments: [domainName, subdomainName],
413
- },
456
+ sender: AccountAddress.from(sender).toString(),
457
+ data,
414
458
  options,
415
459
  });
416
460
 
417
- return transaction;
461
+ return {
462
+ transaction,
463
+ data,
464
+ };
418
465
  }
419
466
 
420
467
  /**
@@ -464,26 +511,72 @@ export async function getTargetAddress(args: {
464
511
  */
465
512
  export async function setTargetAddress(args: {
466
513
  aptosConfig: AptosConfig;
467
- sender: Account;
514
+ sender: AccountAddressInput;
468
515
  name: string;
469
516
  address: AccountAddressInput;
470
517
  options?: InputGenerateTransactionOptions;
471
- }): Promise<SimpleTransaction> {
518
+ }): Promise<{ transaction: SimpleTransaction; data: InputEntryFunctionData }> {
472
519
  const { aptosConfig, sender, name, address, options } = args;
473
520
  const routerAddress = getRouterAddress(aptosConfig);
474
521
  const { domainName, subdomainName } = isValidANSName(name);
475
522
 
523
+ const data: InputEntryFunctionData = {
524
+ function: `${routerAddress}::router::set_target_addr`,
525
+ functionArguments: [domainName, subdomainName, address],
526
+ };
527
+
476
528
  const transaction = await generateTransaction({
477
529
  aptosConfig,
478
- sender: sender.accountAddress.toString(),
479
- data: {
480
- function: `${routerAddress}::router::set_target_addr`,
481
- functionArguments: [domainName, subdomainName, address],
482
- },
530
+ sender: AccountAddress.from(sender).toString(),
531
+ data,
532
+ options,
533
+ });
534
+
535
+ return {
536
+ transaction,
537
+ data,
538
+ };
539
+ }
540
+
541
+ /**
542
+ * Clears the target address for a specified domain and subdomain in the Aptos network.
543
+ * This function removes the target address association, effectively clearing where the name resolves to.
544
+ *
545
+ * @param args - The arguments for clearing the target address.
546
+ * @param args.aptosConfig - The configuration settings for the Aptos network.
547
+ * @param args.sender - The account that is sending the transaction.
548
+ * @param args.name - The name of the domain or subdomain to clear the target address for.
549
+ * @param args.options - Optional parameters for generating the transaction.
550
+ *
551
+ * @returns A transaction object representing the clear target address operation.
552
+ * @group Implementation
553
+ */
554
+ export async function clearTargetAddress(args: {
555
+ aptosConfig: AptosConfig;
556
+ sender: AccountAddressInput;
557
+ name: string;
558
+ options?: InputGenerateTransactionOptions;
559
+ }): Promise<{ transaction: SimpleTransaction; data: InputEntryFunctionData }> {
560
+ const { aptosConfig, sender, name, options } = args;
561
+ const routerAddress = getRouterAddress(aptosConfig);
562
+ const { domainName, subdomainName } = isValidANSName(name);
563
+
564
+ const data: InputEntryFunctionData = {
565
+ function: `${routerAddress}::router::clear_target_addr`,
566
+ functionArguments: [domainName, subdomainName ?? null],
567
+ };
568
+
569
+ const transaction = await generateTransaction({
570
+ aptosConfig,
571
+ sender: AccountAddress.from(sender).toString(),
572
+ data,
483
573
  options,
484
574
  });
485
575
 
486
- return transaction;
576
+ return {
577
+ transaction,
578
+ data,
579
+ };
487
580
  }
488
581
 
489
582
  /**
@@ -495,11 +588,11 @@ export async function setTargetAddress(args: {
495
588
  * @returns The active Aptos name if it exists; otherwise, returns undefined.
496
589
  * @group Implementation
497
590
  */
498
- export async function getName(args: {
499
- aptosConfig: AptosConfig;
500
- name: string;
501
- }): Promise<GetANSNameResponse[0] | undefined> {
591
+ export async function getName(args: { aptosConfig: AptosConfig; name: string }): Promise<AnsName | undefined> {
502
592
  const { aptosConfig, name } = args;
593
+
594
+ const gracePeriod = await getANSGracePeriod({ aptosConfig });
595
+
503
596
  const { domainName, subdomainName = "" } = isValidANSName(name);
504
597
 
505
598
  const where: CurrentAptosNamesBoolExp = {
@@ -521,11 +614,7 @@ export async function getName(args: {
521
614
 
522
615
  // Convert the expiration_timestamp from an ISO string to milliseconds since epoch
523
616
  let res = data.current_aptos_names[0];
524
- if (res) {
525
- res = sanitizeANSName(res);
526
- }
527
-
528
- return isActiveANSName(res) ? res : undefined;
617
+ return res ? sanitizeANSName({ aptosConfig, name: res, gracePeriod }) : undefined;
529
618
  }
530
619
 
531
620
  /**
@@ -535,7 +624,7 @@ export async function getName(args: {
535
624
  * @group Implementation
536
625
  */
537
626
  interface QueryNamesOptions {
538
- options?: PaginationArgs & OrderByArg<GetANSNameResponse[0]> & WhereArg<CurrentAptosNamesBoolExp>;
627
+ options?: PaginationArgs & OrderByArg<AnsName> & WhereArg<CurrentAptosNamesBoolExp>;
539
628
  }
540
629
 
541
630
  /**
@@ -566,9 +655,11 @@ export interface GetAccountNamesArgs extends QueryNamesOptions {
566
655
  */
567
656
  export async function getAccountNames(
568
657
  args: { aptosConfig: AptosConfig } & GetAccountNamesArgs,
569
- ): Promise<GetANSNameResponse> {
658
+ ): Promise<{ names: AnsName[]; total: number }> {
570
659
  const { aptosConfig, options, accountAddress } = args;
571
660
 
661
+ const gracePeriod = await getANSGracePeriod({ aptosConfig });
662
+
572
663
  const expirationDate = await getANSExpirationDate({ aptosConfig });
573
664
 
574
665
  const data = await queryIndexer<GetNamesQuery>({
@@ -581,15 +672,16 @@ export async function getAccountNames(
581
672
  offset: options?.offset,
582
673
  order_by: options?.orderBy,
583
674
  where_condition: {
584
- ...(args.options?.where ?? {}),
585
675
  owner_address: { _eq: accountAddress.toString() },
586
676
  expiration_timestamp: { _gte: expirationDate },
677
+ ...(args.options?.where ?? {}),
587
678
  },
588
679
  },
589
680
  },
590
681
  });
591
-
592
- return data.current_aptos_names.map(sanitizeANSName);
682
+ const names = data.current_aptos_names.map((name) => sanitizeANSName({ aptosConfig, name, gracePeriod }));
683
+ const total = data.current_aptos_names_aggregate.aggregate?.count ?? 0;
684
+ return { names, total };
593
685
  }
594
686
 
595
687
  /**
@@ -622,9 +714,11 @@ export interface GetAccountDomainsArgs extends QueryNamesOptions {
622
714
  */
623
715
  export async function getAccountDomains(
624
716
  args: { aptosConfig: AptosConfig } & GetAccountDomainsArgs,
625
- ): Promise<GetANSNameResponse> {
717
+ ): Promise<{ names: AnsName[]; total: number }> {
626
718
  const { aptosConfig, options, accountAddress } = args;
627
719
 
720
+ const gracePeriod = await getANSGracePeriod({ aptosConfig });
721
+
628
722
  const expirationDate = await getANSExpirationDate({ aptosConfig });
629
723
 
630
724
  const data = await queryIndexer<GetNamesQuery>({
@@ -637,16 +731,19 @@ export async function getAccountDomains(
637
731
  offset: options?.offset,
638
732
  order_by: options?.orderBy,
639
733
  where_condition: {
640
- ...(args.options?.where ?? {}),
641
734
  owner_address: { _eq: accountAddress.toString() },
642
735
  expiration_timestamp: { _gte: expirationDate },
643
736
  subdomain: { _eq: "" },
737
+ ...(args.options?.where ?? {}),
644
738
  },
645
739
  },
646
740
  },
647
741
  });
648
742
 
649
- return data.current_aptos_names.map(sanitizeANSName);
743
+ const names = data.current_aptos_names.map((name) => sanitizeANSName({ aptosConfig, name, gracePeriod }));
744
+ const total = data.current_aptos_names_aggregate.aggregate?.count ?? 0;
745
+
746
+ return { names, total };
650
747
  }
651
748
 
652
749
  /**
@@ -678,10 +775,10 @@ export interface GetAccountSubdomainsArgs extends QueryNamesOptions {
678
775
  */
679
776
  export async function getAccountSubdomains(
680
777
  args: { aptosConfig: AptosConfig } & GetAccountSubdomainsArgs,
681
- ): Promise<GetANSNameResponse> {
778
+ ): Promise<{ names: AnsName[]; total: number }> {
682
779
  const { aptosConfig, options, accountAddress } = args;
683
780
 
684
- const expirationDate = await getANSExpirationDate({ aptosConfig });
781
+ const gracePeriod = await getANSGracePeriod({ aptosConfig });
685
782
 
686
783
  const data = await queryIndexer<GetNamesQuery>({
687
784
  aptosConfig,
@@ -693,16 +790,17 @@ export async function getAccountSubdomains(
693
790
  offset: options?.offset,
694
791
  order_by: options?.orderBy,
695
792
  where_condition: {
696
- ...(args.options?.where ?? {}),
697
793
  owner_address: { _eq: accountAddress.toString() },
698
- expiration_timestamp: { _gte: expirationDate },
699
794
  subdomain: { _neq: "" },
795
+ ...(args.options?.where ?? {}),
700
796
  },
701
797
  },
702
798
  },
703
799
  });
704
800
 
705
- return data.current_aptos_names.map(sanitizeANSName);
801
+ const names = data.current_aptos_names.map((name) => sanitizeANSName({ aptosConfig, name, gracePeriod }));
802
+ const total = data.current_aptos_names_aggregate.aggregate?.count ?? 0;
803
+ return { names, total };
706
804
  }
707
805
 
708
806
  /**
@@ -736,9 +834,11 @@ export interface GetDomainSubdomainsArgs extends QueryNamesOptions {
736
834
  */
737
835
  export async function getDomainSubdomains(
738
836
  args: { aptosConfig: AptosConfig } & GetDomainSubdomainsArgs,
739
- ): Promise<GetANSNameResponse> {
837
+ ): Promise<{ names: AnsName[]; total: number }> {
740
838
  const { aptosConfig, options, domain } = args;
741
839
 
840
+ const gracePeriod = await getANSGracePeriod({ aptosConfig });
841
+
742
842
  const data = await queryIndexer<GetNamesQuery>({
743
843
  aptosConfig,
744
844
  originMethod: "getDomainSubdomains",
@@ -749,15 +849,17 @@ export async function getDomainSubdomains(
749
849
  offset: options?.offset,
750
850
  order_by: options?.orderBy,
751
851
  where_condition: {
752
- ...(args.options?.where ?? {}),
753
852
  domain: { _eq: domain },
754
853
  subdomain: { _neq: "" },
854
+ ...(args.options?.where ?? {}),
755
855
  },
756
856
  },
757
857
  },
758
858
  });
759
859
 
760
- return data.current_aptos_names.map(sanitizeANSName).filter(isActiveANSName);
860
+ const names = data.current_aptos_names.map((name) => sanitizeANSName({ aptosConfig, name, gracePeriod }));
861
+ const total = data.current_aptos_names_aggregate.aggregate?.count ?? 0;
862
+ return { names, total };
761
863
  }
762
864
 
763
865
  /**
@@ -774,6 +876,28 @@ export async function getDomainSubdomains(
774
876
  * @group Implementation
775
877
  */
776
878
  async function getANSExpirationDate(args: { aptosConfig: AptosConfig }): Promise<string> {
879
+ const { aptosConfig } = args;
880
+ const gracePeriodInSeconds = await getANSGracePeriod({ aptosConfig });
881
+ const gracePeriodInDays = gracePeriodInSeconds / 60 / 60 / 24;
882
+ const now = () => new Date();
883
+ return new Date(now().setDate(now().getDate() - gracePeriodInDays)).toISOString();
884
+ }
885
+
886
+ /**
887
+ * This function returns the grace period in seconds as defined by the contract.
888
+ * A name that is past expiration but within the grace period is considered in
889
+ * grace period and can't be claimed by others.
890
+ *
891
+ * @param args - The arguments for the function.
892
+ * @param args.aptosConfig - An AptosConfig object containing the configuration settings.
893
+ * @returns The grace period in seconds.
894
+ * @group Implementation
895
+ */
896
+ export async function getANSGracePeriod(args: { aptosConfig: AptosConfig }): Promise<number> {
897
+ if (GRACE_PERIOD_IN_SECONDS) {
898
+ return GRACE_PERIOD_IN_SECONDS;
899
+ }
900
+
777
901
  const { aptosConfig } = args;
778
902
  const routerAddress = getRouterAddress(aptosConfig);
779
903
 
@@ -785,9 +909,8 @@ async function getANSExpirationDate(args: { aptosConfig: AptosConfig }): Promise
785
909
  },
786
910
  });
787
911
 
788
- const gracePeriodInDays = gracePeriodInSeconds / 60 / 60 / 24;
789
- const now = () => new Date();
790
- return new Date(now().setDate(now().getDate() - gracePeriodInDays)).toISOString();
912
+ GRACE_PERIOD_IN_SECONDS = gracePeriodInSeconds;
913
+ return gracePeriodInSeconds;
791
914
  }
792
915
 
793
916
  /**
@@ -804,11 +927,11 @@ async function getANSExpirationDate(args: { aptosConfig: AptosConfig }): Promise
804
927
  */
805
928
  export async function renewDomain(args: {
806
929
  aptosConfig: AptosConfig;
807
- sender: Account;
930
+ sender: AccountAddressInput;
808
931
  name: string;
809
932
  years?: 1;
810
933
  options?: InputGenerateTransactionOptions;
811
- }): Promise<SimpleTransaction> {
934
+ }): Promise<{ transaction: SimpleTransaction; data: InputEntryFunctionData }> {
812
935
  const { aptosConfig, sender, name, years = 1, options } = args;
813
936
  const routerAddress = getRouterAddress(aptosConfig);
814
937
  const renewalDuration = years * 31536000;
@@ -822,17 +945,22 @@ export async function renewDomain(args: {
822
945
  throw new Error("Currently, only 1 year renewals are supported");
823
946
  }
824
947
 
948
+ const data: InputEntryFunctionData = {
949
+ function: `${routerAddress}::router::renew_domain`,
950
+ functionArguments: [domainName, renewalDuration],
951
+ };
952
+
825
953
  const transaction = await generateTransaction({
826
954
  aptosConfig,
827
- sender: sender.accountAddress.toString(),
828
- data: {
829
- function: `${routerAddress}::router::renew_domain`,
830
- functionArguments: [domainName, renewalDuration],
831
- },
955
+ sender: AccountAddress.from(sender).toString(),
956
+ data,
832
957
  options,
833
958
  });
834
959
 
835
- return transaction;
960
+ return {
961
+ transaction,
962
+ data,
963
+ };
836
964
  }
837
965
 
838
966
  /**
@@ -845,9 +973,51 @@ export async function renewDomain(args: {
845
973
  * @param name.expiration_timestamp - The expiration timestamp in ISO string format.
846
974
  * @group Implementation
847
975
  */
848
- function sanitizeANSName(name: GetANSNameResponse[0]): GetANSNameResponse[0] {
976
+ function sanitizeANSName({
977
+ name,
978
+ aptosConfig,
979
+ gracePeriod,
980
+ }: {
981
+ aptosConfig: AptosConfig;
982
+ name: RawANSName;
983
+ gracePeriod: number;
984
+ }): AnsName {
985
+ const expiration_timestamp = name.expiration_timestamp + "Z";
986
+ const domain_expiration_timestamp = name.domain_expiration_timestamp + "Z";
987
+
988
+ const isSubdomain = !!name.subdomain;
989
+ const expirationPolicy = name.subdomain_expiration_policy as SubdomainExpirationPolicy;
990
+ const expiration =
991
+ isSubdomain && expirationPolicy === SubdomainExpirationPolicy.FollowsDomain
992
+ ? domain_expiration_timestamp
993
+ : expiration_timestamp;
994
+
995
+ const expiration_status = getANSExpirationStatus({ aptosConfig, name, gracePeriod });
996
+
997
+ let isInRenewablePeriod = false;
998
+ if (expiration_status === ExpirationStatus.InGracePeriod) {
999
+ isInRenewablePeriod = true;
1000
+ } else if (expiration_status === ExpirationStatus.Active) {
1001
+ // Check if the name is within the renewal window (6 months before expiration)
1002
+ const renewalWindowDate = new Date();
1003
+ renewalWindowDate.setMonth(renewalWindowDate.getMonth() + RENEWAL_MONTHS_WINDOW);
1004
+
1005
+ const expirationDate = new Date(expiration);
1006
+ isInRenewablePeriod = expirationDate < renewalWindowDate;
1007
+ }
1008
+
849
1009
  return {
850
- ...name,
851
- expiration_timestamp: new Date(name.expiration_timestamp).getTime(),
1010
+ domain: name.domain!,
1011
+ subdomain: name.subdomain || undefined,
1012
+ expiration_timestamp: expiration_timestamp,
1013
+ expiration_status,
1014
+ domain_expiration_timestamp: domain_expiration_timestamp!,
1015
+ expiration: new Date(expiration),
1016
+ token_standard: name.token_standard! as AnsTokenStandard,
1017
+ is_primary: name.is_primary!,
1018
+ subdomain_expiration_policy: name.subdomain_expiration_policy ?? SubdomainExpirationPolicy.FollowsDomain,
1019
+ owner_address: name.owner_address ?? "",
1020
+ registered_address: name.registered_address!,
1021
+ isInRenewablePeriod,
852
1022
  };
853
1023
  }
@@ -8,4 +8,9 @@ query getNames(
8
8
  current_aptos_names(limit: $limit, where: $where_condition, order_by: $order_by, offset: $offset) {
9
9
  ...AnsTokenFragment
10
10
  }
11
+ current_aptos_names_aggregate(where: $where_condition) {
12
+ aggregate {
13
+ count
14
+ }
15
+ }
11
16
  }
@@ -201,7 +201,7 @@ export function generateTransactionPayloadWithABI(
201
201
  }
202
202
 
203
203
  // Check all BCS types, and convert any non-BCS types
204
- const functionArguments: Array<EntryFunctionArgumentTypes> = args.functionArguments.map((arg, i) =>
204
+ const functionArguments: Array<EntryFunctionArgumentTypes> | undefined = args.functionArguments?.map((arg, i) =>
205
205
  /**
206
206
  * Converts the argument for a specified function using its ABI and type arguments.
207
207
  * This function helps ensure that the correct number of arguments is provided for the function call.
@@ -220,10 +220,10 @@ export function generateTransactionPayloadWithABI(
220
220
  );
221
221
 
222
222
  // Check that all arguments are accounted for
223
- if (functionArguments.length !== functionAbi.parameters.length) {
223
+ if ((functionArguments?.length ?? 0) !== functionAbi.parameters.length) {
224
224
  throw new Error(
225
225
  // eslint-disable-next-line max-len
226
- `Too few arguments for '${moduleAddress}::${moduleName}::${functionName}', expected ${functionAbi.parameters.length} but got ${functionArguments.length}`,
226
+ `Too few arguments for '${moduleAddress}::${moduleName}::${functionName}', expected ${functionAbi.parameters.length} but got ${functionArguments?.length ?? 0}`,
227
227
  );
228
228
  }
229
229
 
@@ -232,7 +232,7 @@ export function generateTransactionPayloadWithABI(
232
232
  `${moduleAddress}::${moduleName}`,
233
233
  functionName,
234
234
  typeArguments,
235
- functionArguments,
235
+ functionArguments ?? [],
236
236
  );
237
237
 
238
238
  // Send it as multi sig if it's a multisig payload