@aptos-labs/ts-sdk 0.0.6 → 0.0.7

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 (205) hide show
  1. package/README.md +9 -4
  2. package/dist/browser/index.d.ts +564 -338
  3. package/dist/browser/index.global.js +46 -25
  4. package/dist/browser/index.global.js.map +1 -1
  5. package/dist/common/index.d.ts +564 -338
  6. package/dist/common/index.js +45 -24
  7. package/dist/common/index.js.map +1 -1
  8. package/dist/esm/api/account.mjs +1 -1
  9. package/dist/esm/api/ans.d.mts +212 -18
  10. package/dist/esm/api/ans.mjs +1 -1
  11. package/dist/esm/api/aptos.d.mts +8 -0
  12. package/dist/esm/api/aptos.mjs +1 -1
  13. package/dist/esm/api/coin.d.mts +2 -2
  14. package/dist/esm/api/coin.mjs +1 -1
  15. package/dist/esm/api/digitalAsset.d.mts +3 -3
  16. package/dist/esm/api/digitalAsset.mjs +1 -1
  17. package/dist/esm/api/event.mjs +1 -1
  18. package/dist/esm/api/faucet.mjs +1 -1
  19. package/dist/esm/api/fungibleAsset.mjs +1 -1
  20. package/dist/esm/api/general.mjs +1 -1
  21. package/dist/esm/api/index.d.mts +4 -0
  22. package/dist/esm/api/index.mjs +1 -1
  23. package/dist/esm/api/staking.mjs +1 -1
  24. package/dist/esm/api/transaction.mjs +1 -1
  25. package/dist/esm/api/transactionSubmission/build.d.mts +53 -0
  26. package/dist/esm/api/transactionSubmission/build.mjs +2 -0
  27. package/dist/esm/api/transactionSubmission/build.mjs.map +1 -0
  28. package/dist/esm/api/transactionSubmission/sign.d.mts +50 -0
  29. package/dist/esm/api/transactionSubmission/sign.mjs +2 -0
  30. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -0
  31. package/dist/esm/api/transactionSubmission/simulate.d.mts +53 -0
  32. package/dist/esm/api/transactionSubmission/simulate.mjs +2 -0
  33. package/dist/esm/api/transactionSubmission/simulate.mjs.map +1 -0
  34. package/dist/esm/api/transactionSubmission/submit.d.mts +51 -0
  35. package/dist/esm/api/transactionSubmission/submit.mjs +2 -0
  36. package/dist/esm/api/transactionSubmission/submit.mjs.map +1 -0
  37. package/dist/esm/api/transactionSubmission.d.mts +9 -60
  38. package/dist/esm/api/transactionSubmission.mjs +1 -1
  39. package/dist/esm/{chunk-NGCFPQ22.mjs → chunk-2OZRBXLM.mjs} +2 -2
  40. package/dist/esm/{chunk-TQD4IGUM.mjs → chunk-33T7WTB6.mjs} +2 -2
  41. package/dist/esm/chunk-3732I6BR.mjs +2 -0
  42. package/dist/esm/chunk-3732I6BR.mjs.map +1 -0
  43. package/dist/esm/chunk-3VZ3OZKC.mjs +2 -0
  44. package/dist/esm/chunk-3VZ3OZKC.mjs.map +1 -0
  45. package/dist/esm/chunk-4KTQIWUP.mjs +2 -0
  46. package/dist/esm/chunk-4KTQIWUP.mjs.map +1 -0
  47. package/dist/esm/chunk-5LO7FR2P.mjs +2 -0
  48. package/dist/esm/chunk-5LO7FR2P.mjs.map +1 -0
  49. package/dist/esm/{chunk-Q6N6QACD.mjs → chunk-67OGU66P.mjs} +2 -2
  50. package/dist/esm/{chunk-V45RFKH7.mjs → chunk-72F5YXGC.mjs} +2 -2
  51. package/dist/esm/chunk-72F5YXGC.mjs.map +1 -0
  52. package/dist/esm/{chunk-2W744GUN.mjs → chunk-BFQRMCY2.mjs} +2 -2
  53. package/dist/esm/{chunk-WKY5ENCK.mjs → chunk-BM4HBROC.mjs} +2 -2
  54. package/dist/esm/chunk-DRPMIJH7.mjs +2 -0
  55. package/dist/esm/chunk-DRPMIJH7.mjs.map +1 -0
  56. package/dist/esm/{chunk-UPLWWSB4.mjs → chunk-GAI75GOG.mjs} +2 -2
  57. package/dist/esm/{chunk-7MNEEVXY.mjs → chunk-GU4OUKAF.mjs} +2 -2
  58. package/dist/esm/{chunk-EQ5BEDJ7.mjs → chunk-HO7K2UAK.mjs} +2 -2
  59. package/dist/esm/{chunk-U3LO2FSJ.mjs → chunk-IBH7IOIM.mjs} +2 -2
  60. package/dist/esm/{chunk-R26XML3D.mjs → chunk-J5BH7V37.mjs} +2 -2
  61. package/dist/esm/chunk-L7AA75WZ.mjs +2 -0
  62. package/dist/esm/chunk-L7AA75WZ.mjs.map +1 -0
  63. package/dist/esm/chunk-LACQ537H.mjs +2 -0
  64. package/dist/esm/{chunk-NYFVEKF6.mjs.map → chunk-LACQ537H.mjs.map} +1 -1
  65. package/dist/esm/{chunk-EGOYLZBU.mjs → chunk-LDAD54H5.mjs} +2 -2
  66. package/dist/esm/chunk-LXW3A3MJ.mjs +2 -0
  67. package/dist/esm/chunk-LXW3A3MJ.mjs.map +1 -0
  68. package/dist/esm/{chunk-4RVIA63I.mjs → chunk-M2V2POWK.mjs} +2 -2
  69. package/dist/esm/{chunk-3JVGSFHP.mjs → chunk-ND3ZQKTT.mjs} +2 -2
  70. package/dist/esm/chunk-O2B54NZT.mjs +2 -0
  71. package/dist/esm/chunk-O2B54NZT.mjs.map +1 -0
  72. package/dist/esm/chunk-OCW2L33Q.mjs +2 -0
  73. package/dist/esm/chunk-OCW2L33Q.mjs.map +1 -0
  74. package/dist/esm/{chunk-VMQWW5UT.mjs → chunk-OCYS4V2V.mjs} +2 -2
  75. package/dist/esm/{chunk-BWMNPUTK.mjs → chunk-OSTH5JRX.mjs} +2 -2
  76. package/dist/esm/chunk-OSTH5JRX.mjs.map +1 -0
  77. package/dist/esm/{chunk-Z2UDRTHA.mjs → chunk-OVHY6ZUJ.mjs} +2 -2
  78. package/dist/esm/chunk-PZCMSHY6.mjs +2 -0
  79. package/dist/esm/{chunk-P32MY5YF.mjs → chunk-RHS5ROLP.mjs} +2 -2
  80. package/dist/esm/chunk-RHS5ROLP.mjs.map +1 -0
  81. package/dist/esm/{chunk-BFSEVKNA.mjs → chunk-RKKU2SY5.mjs} +2 -2
  82. package/dist/esm/chunk-TGKB6ALT.mjs +2 -0
  83. package/dist/esm/chunk-TGKB6ALT.mjs.map +1 -0
  84. package/dist/esm/{chunk-GEFQFRL3.mjs → chunk-TPWSHFFI.mjs} +2 -2
  85. package/dist/esm/{chunk-WX43AJTD.mjs → chunk-UDBH4CER.mjs} +42 -21
  86. package/dist/esm/chunk-UDBH4CER.mjs.map +1 -0
  87. package/dist/esm/{chunk-VYAVLUPJ.mjs → chunk-WEJAI26R.mjs} +2 -2
  88. package/dist/esm/{chunk-JDS7K2WI.mjs → chunk-WL4OXZLN.mjs} +2 -2
  89. package/dist/esm/{chunk-AAIBCWZY.mjs → chunk-Y2HRRUZ6.mjs} +2 -2
  90. package/dist/esm/{chunk-J5ZFOJN2.mjs → chunk-ZLW65YCO.mjs} +2 -2
  91. package/dist/esm/chunk-ZUHN56GM.mjs +2 -0
  92. package/dist/esm/chunk-ZUHN56GM.mjs.map +1 -0
  93. package/dist/esm/client/core.mjs +1 -1
  94. package/dist/esm/client/get.mjs +1 -1
  95. package/dist/esm/client/index.mjs +1 -1
  96. package/dist/esm/client/post.mjs +1 -1
  97. package/dist/esm/core/account.mjs +1 -1
  98. package/dist/esm/core/authenticationKey.mjs +1 -1
  99. package/dist/esm/core/crypto/index.mjs +1 -1
  100. package/dist/esm/core/index.mjs +1 -1
  101. package/dist/esm/index.d.mts +6 -2
  102. package/dist/esm/index.mjs +1 -1
  103. package/dist/esm/internal/account.mjs +1 -1
  104. package/dist/esm/internal/ans.d.mts +80 -13
  105. package/dist/esm/internal/ans.mjs +1 -1
  106. package/dist/esm/internal/coin.d.mts +2 -2
  107. package/dist/esm/internal/coin.mjs +1 -1
  108. package/dist/esm/internal/digitalAsset.d.mts +3 -3
  109. package/dist/esm/internal/digitalAsset.mjs +1 -1
  110. package/dist/esm/internal/event.mjs +1 -1
  111. package/dist/esm/internal/faucet.d.mts +3 -3
  112. package/dist/esm/internal/faucet.mjs +1 -1
  113. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  114. package/dist/esm/internal/general.mjs +1 -1
  115. package/dist/esm/internal/staking.d.mts +2 -2
  116. package/dist/esm/internal/staking.mjs +1 -1
  117. package/dist/esm/internal/transaction.mjs +1 -1
  118. package/dist/esm/internal/transactionSubmission.d.mts +13 -44
  119. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  120. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  121. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  122. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  123. package/dist/esm/transactions/index.d.mts +1 -1
  124. package/dist/esm/transactions/index.mjs +1 -1
  125. package/dist/esm/transactions/instances/index.mjs +1 -1
  126. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  127. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  128. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  129. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  130. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  131. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  132. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  133. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +3 -6
  134. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  135. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  136. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  137. package/dist/esm/transactions/types.d.mts +15 -41
  138. package/dist/esm/types/generated/operations.d.mts +28 -2
  139. package/dist/esm/types/generated/queries.d.mts +5 -2
  140. package/dist/esm/types/generated/queries.mjs +1 -1
  141. package/dist/esm/types/index.d.mts +1 -1
  142. package/dist/esm/types/indexer.d.mts +3 -2
  143. package/package.json +1 -1
  144. package/src/api/ans.ts +250 -11
  145. package/src/api/aptos.ts +20 -0
  146. package/src/api/coin.ts +2 -2
  147. package/src/api/digitalAsset.ts +3 -3
  148. package/src/api/transactionSubmission/build.ts +42 -0
  149. package/src/api/transactionSubmission/sign.ts +44 -0
  150. package/src/api/transactionSubmission/simulate.ts +56 -0
  151. package/src/api/transactionSubmission/submit.ts +53 -0
  152. package/src/api/transactionSubmission.ts +4 -143
  153. package/src/internal/ans.ts +406 -20
  154. package/src/internal/coin.ts +3 -3
  155. package/src/internal/digitalAsset.ts +5 -5
  156. package/src/internal/queries/ansTokenFragment.graphql +9 -0
  157. package/src/internal/queries/getNames.graphql +11 -0
  158. package/src/internal/transactionSubmission.ts +29 -21
  159. package/src/transactions/transactionBuilder/transactionBuilder.ts +20 -43
  160. package/src/transactions/types.ts +14 -45
  161. package/src/types/generated/operations.ts +29 -0
  162. package/src/types/generated/queries.ts +34 -0
  163. package/src/types/indexer.ts +3 -0
  164. package/dist/esm/chunk-BP5ZO7NK.mjs +0 -2
  165. package/dist/esm/chunk-BP5ZO7NK.mjs.map +0 -1
  166. package/dist/esm/chunk-BWMNPUTK.mjs.map +0 -1
  167. package/dist/esm/chunk-EYXHVA6W.mjs +0 -2
  168. package/dist/esm/chunk-EYXHVA6W.mjs.map +0 -1
  169. package/dist/esm/chunk-IG5CHHSI.mjs +0 -2
  170. package/dist/esm/chunk-IG5CHHSI.mjs.map +0 -1
  171. package/dist/esm/chunk-IXMB2GOK.mjs +0 -2
  172. package/dist/esm/chunk-IXMB2GOK.mjs.map +0 -1
  173. package/dist/esm/chunk-NTD3H2S4.mjs +0 -2
  174. package/dist/esm/chunk-NTD3H2S4.mjs.map +0 -1
  175. package/dist/esm/chunk-NYFVEKF6.mjs +0 -2
  176. package/dist/esm/chunk-P32MY5YF.mjs.map +0 -1
  177. package/dist/esm/chunk-UNQNACJT.mjs +0 -2
  178. package/dist/esm/chunk-V45RFKH7.mjs.map +0 -1
  179. package/dist/esm/chunk-VOYW2TZW.mjs +0 -2
  180. package/dist/esm/chunk-VOYW2TZW.mjs.map +0 -1
  181. package/dist/esm/chunk-WX43AJTD.mjs.map +0 -1
  182. package/dist/esm/chunk-Y5DJPHJT.mjs +0 -2
  183. package/dist/esm/chunk-Y5DJPHJT.mjs.map +0 -1
  184. /package/dist/esm/{chunk-NGCFPQ22.mjs.map → chunk-2OZRBXLM.mjs.map} +0 -0
  185. /package/dist/esm/{chunk-TQD4IGUM.mjs.map → chunk-33T7WTB6.mjs.map} +0 -0
  186. /package/dist/esm/{chunk-Q6N6QACD.mjs.map → chunk-67OGU66P.mjs.map} +0 -0
  187. /package/dist/esm/{chunk-2W744GUN.mjs.map → chunk-BFQRMCY2.mjs.map} +0 -0
  188. /package/dist/esm/{chunk-WKY5ENCK.mjs.map → chunk-BM4HBROC.mjs.map} +0 -0
  189. /package/dist/esm/{chunk-UPLWWSB4.mjs.map → chunk-GAI75GOG.mjs.map} +0 -0
  190. /package/dist/esm/{chunk-7MNEEVXY.mjs.map → chunk-GU4OUKAF.mjs.map} +0 -0
  191. /package/dist/esm/{chunk-EQ5BEDJ7.mjs.map → chunk-HO7K2UAK.mjs.map} +0 -0
  192. /package/dist/esm/{chunk-U3LO2FSJ.mjs.map → chunk-IBH7IOIM.mjs.map} +0 -0
  193. /package/dist/esm/{chunk-R26XML3D.mjs.map → chunk-J5BH7V37.mjs.map} +0 -0
  194. /package/dist/esm/{chunk-EGOYLZBU.mjs.map → chunk-LDAD54H5.mjs.map} +0 -0
  195. /package/dist/esm/{chunk-4RVIA63I.mjs.map → chunk-M2V2POWK.mjs.map} +0 -0
  196. /package/dist/esm/{chunk-3JVGSFHP.mjs.map → chunk-ND3ZQKTT.mjs.map} +0 -0
  197. /package/dist/esm/{chunk-VMQWW5UT.mjs.map → chunk-OCYS4V2V.mjs.map} +0 -0
  198. /package/dist/esm/{chunk-Z2UDRTHA.mjs.map → chunk-OVHY6ZUJ.mjs.map} +0 -0
  199. /package/dist/esm/{chunk-UNQNACJT.mjs.map → chunk-PZCMSHY6.mjs.map} +0 -0
  200. /package/dist/esm/{chunk-BFSEVKNA.mjs.map → chunk-RKKU2SY5.mjs.map} +0 -0
  201. /package/dist/esm/{chunk-GEFQFRL3.mjs.map → chunk-TPWSHFFI.mjs.map} +0 -0
  202. /package/dist/esm/{chunk-VYAVLUPJ.mjs.map → chunk-WEJAI26R.mjs.map} +0 -0
  203. /package/dist/esm/{chunk-JDS7K2WI.mjs.map → chunk-WL4OXZLN.mjs.map} +0 -0
  204. /package/dist/esm/{chunk-AAIBCWZY.mjs.map → chunk-Y2HRRUZ6.mjs.map} +0 -0
  205. /package/dist/esm/{chunk-J5ZFOJN2.mjs.map → chunk-ZLW65YCO.mjs.map} +0 -0
package/src/api/ans.ts CHANGED
@@ -1,9 +1,29 @@
1
1
  // Copyright © Aptos Foundation
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { RegisterNameParameters, getOwnerAddress, registerName } from "../internal/ans";
5
- import { InputSingleSignerTransaction } from "../transactions/types";
6
- import { MoveAddressType } from "../types";
4
+ import { Account, AccountAddressInput } from "../core";
5
+ import {
6
+ RegisterNameParameters,
7
+ getExpiration,
8
+ getOwnerAddress,
9
+ registerName,
10
+ getPrimaryName,
11
+ setPrimaryName,
12
+ getTargetAddress,
13
+ setTargetAddress,
14
+ renewDomain,
15
+ getName,
16
+ getAccountDomains,
17
+ GetAccountDomainsArgs,
18
+ GetAccountSubdomainsArgs,
19
+ getAccountSubdomains,
20
+ getAccountNames,
21
+ GetAccountNamesArgs,
22
+ getDomainSubdomains,
23
+ GetDomainSubdomainsArgs,
24
+ } from "../internal/ans";
25
+ import { GetANSNameResponse, MoveAddressType } from "../types";
26
+ import { InputGenerateTransactionOptions, SingleSignerTransaction } from "../transactions/types";
7
27
  import { AptosConfig } from "./aptosConfig";
8
28
 
9
29
  /**
@@ -17,11 +37,12 @@ export class ANS {
17
37
  }
18
38
 
19
39
  /**
20
- * Retrieve the owner address of a domain name or subdomain name.
40
+ * Retrieve the owner address of a domain name or subdomain name from the contract.
21
41
  *
22
42
  * ```ts
23
- * getOwnerAddress({name: "test.aptos"})
24
43
  * // Will return the owner address of "test.aptos.apt" or undefined
44
+ * const owner = await aptos.getOwnerAddress({name: "test.aptos"})
45
+ * // owner = 0x123...
25
46
  * ```
26
47
  *
27
48
  * @param args.name - A string of the name to retrieve
@@ -33,26 +54,244 @@ export class ANS {
33
54
  }
34
55
 
35
56
  /**
36
- * Registers a new domain or subdomain name
57
+ * Retrieve the expiration time of a domain name or subdomain name from the contract.
58
+ *
59
+ * ```ts
60
+ * // Will return the expiration of "test.aptos.apt" or undefined
61
+ * const exp = await aptos.getExpiration({name: "test.aptos"})
62
+ * // new Date(exp) would give you the date in question: 2021-01-01T00:00:00.000Z
63
+ * ```
64
+ *
65
+ * @param args.name - A string of the name to retrieve
66
+ *
67
+ * @returns number as a unix timestamp in seconds.
68
+ */
69
+ async getExpiration(args: { name: string }): Promise<number | undefined> {
70
+ return getExpiration({ aptosConfig: this.config, ...args });
71
+ }
72
+
73
+ /**
74
+ * Retrieve the target address of a domain or subdomain name. This is the
75
+ * address the name points to for use on chain. Note, the target address can
76
+ * point to addresses that are not the owner of the name
77
+ *
78
+ * ```ts
79
+ * const targetAddr = await aptos.getTargetAddress({name: "test.aptos"})
80
+ * // targetAddr = 0x123...
81
+ * ```
82
+ *
83
+ * @param args.name - A string of the name: primary, primary.apt, secondary.primary, secondary.primary.apt, etc.
84
+ *
85
+ * @returns MoveAddressType if the name has a target, undefined otherwise
86
+ */
87
+ async getTargetAddress(args: { name: string }): Promise<MoveAddressType | undefined> {
88
+ return getTargetAddress({ aptosConfig: this.config, ...args });
89
+ }
90
+
91
+ /**
92
+ * Sets the target address of a domain or subdomain name. This is the
93
+ * address the name points to for use on chain. Note, the target address can
94
+ * point to addresses that are not the owner of the name
95
+ *
96
+ * ```ts
97
+ * await aptos.setTargetAddress({sender: alice, name: "test.aptos", address: bob.accountAddress.toString})
98
+ * const address = await aptos.getTargetAddress({name: "test.aptos"})
99
+ * // address = bob.accountAddress.toString()
100
+ * ```
101
+ *
102
+ * @param args.name - A string of the name: test.aptos.apt, test.apt, test, test.aptos, etc.
103
+ * @param args.address - A AccountAddressInput of the address to set the domain or subdomain to
104
+ *
105
+ * @returns SingleSignerTransaction
106
+ */
107
+ async setTargetAddress(args: {
108
+ sender: Account;
109
+ name: string;
110
+ address: AccountAddressInput;
111
+ options?: InputGenerateTransactionOptions;
112
+ }): Promise<SingleSignerTransaction> {
113
+ return setTargetAddress({ aptosConfig: this.config, ...args });
114
+ }
115
+
116
+ /**
117
+ * Retrieve the primary name for an account. An account can have
118
+ * multiple names that target it, but only a single name that is primary. An
119
+ * account also may not have a primary name.
120
+ *
121
+ * ```ts
122
+ * const name = await aptos.getPrimaryName({address: alice.accountAddress.toString()})
123
+ * // name = test.aptos
124
+ * ```
125
+ *
126
+ * @param args.address - A AccountAddressInput (address) of the account
127
+ *
128
+ * @returns a string if the account has a primary name, undefined otherwise
129
+ */
130
+ async getPrimaryName(args: { address: AccountAddressInput }): Promise<string | undefined> {
131
+ return getPrimaryName({ aptosConfig: this.config, ...args });
132
+ }
133
+
134
+ /**
135
+ * Sets the primary name for the sender. An account can have
136
+ * multiple names that target it, but only a single name that is primary. An
137
+ * account also may not have a primary name.
138
+ *
139
+ * ```ts
140
+ * await aptos.setPrimaryName({sender: alice, name: "test.aptos"})
141
+ * const primaryName = await aptos.getPrimaryName({address: alice.accountAddress.toString()})
142
+ * // primaryName = test.aptos
143
+ * ```
144
+ *
145
+ * @param args.sender - The sender account
146
+ * @param args.name - A string of the name: test, test.apt, test.aptos, test.aptos.apt, etc.
147
+ *
148
+ * @returns SingleSignerTransaction
149
+ */
150
+ async setPrimaryName(args: {
151
+ sender: Account;
152
+ name: string | null;
153
+ options?: InputGenerateTransactionOptions;
154
+ }): Promise<SingleSignerTransaction> {
155
+ return setPrimaryName({ aptosConfig: this.config, ...args });
156
+ }
157
+
158
+ /**
159
+ * Registers a new name
160
+ *
161
+ * ```ts
162
+ * // An example of registering a subdomain name assuming def.apt is already registered
163
+ * // and belongs to the sender alice.
164
+ * const txn = aptos.registerName({
165
+ * sender: alice,
166
+ * name: "test.aptos.apt",
167
+ * expiration: {
168
+ * policy: "subdomain:independent",
169
+ * expirationDate: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000),
170
+ * },
171
+ * });
172
+ * ```
37
173
  *
38
174
  * @param args.sender - The sender account
39
- * @param args.name - A string or {domainName: string, subdomainName?: string} of the name to register. This
40
- * can be inclusive or exclusive of the .apt suffix.
41
- * Examples include: "xyz", "xyz.apt", "xyz.kyc.apt", {domainName: "xyz"}, {domainName: "kyc", subdomainName: "xyz"}.
175
+ * @param args.name - A string of the name to register. This can be inclusive or exclusive of the .apt suffix.
176
+ * Examples include: "test", "test.apt", "test.aptos.apt", etc.
42
177
  * @param args.expiration - An object with the expiration policy of the name.
43
178
  * @param args.expiration.policy - 'domain' | 'subdomain:follow-domain' | 'subdomain:independent'
44
179
  * - domain: Years is required and the name will expire after the given number of years.
45
180
  * - subdomain:follow-domain: The name will expire at the same time as the domain name.
46
181
  * - subdomain:independent: The name will expire at the given date.
182
+ * @param args.expiration.expirationDate - A javascript date of when the subdomain will expire. Only applicable when
183
+ * the policy is set to 'subdomain:independent'.
47
184
  * @param args.transferable - Determines if the subdomain being minted is soul-bound. Applicable only to subdomains.
48
185
  * @param args.targetAddress optional - The address the domain name will resolve to. If not provided,
49
186
  * the sender's address will be used.
50
187
  * @param args.toAddress optional - The address to send the domain name to. If not provided,
51
188
  * the transaction will be sent to the router.
52
189
  *
53
- * @returns InputSingleSignerTransaction
190
+ * @returns SingleSignerTransaction
54
191
  */
55
- async registerName(args: Omit<RegisterNameParameters, "aptosConfig">): Promise<InputSingleSignerTransaction> {
192
+ async registerName(args: Omit<RegisterNameParameters, "aptosConfig">): Promise<SingleSignerTransaction> {
56
193
  return registerName({ aptosConfig: this.config, ...args });
57
194
  }
195
+
196
+ /**
197
+ * Renews a domain name
198
+ *
199
+ * Note: If a domain name was minted with V1 of the contract, it will automatically be upgraded to V2 via this transaction.
200
+ *
201
+ * ```ts
202
+ * await aptos.renewDomain({sender: alice, name: "test"})
203
+ * // test.apt will be renewed for one year
204
+ * ```
205
+ *
206
+ * @param args.sender - The sender account
207
+ * @param args.name - A string of the domain the subdomain will be under. The signer must be the domain owner.
208
+ * Subdomains cannot be renewed.
209
+ * @param args.years - The number of years to renew the name. Currently only one year is permitted.
210
+ *
211
+ * @returns SingleSignerTransaction
212
+ */
213
+ async renewDomain(args: {
214
+ sender: Account;
215
+ name: string;
216
+ years?: 1;
217
+ options?: InputGenerateTransactionOptions;
218
+ }): Promise<SingleSignerTransaction> {
219
+ return renewDomain({ aptosConfig: this.config, ...args });
220
+ }
221
+
222
+ /**
223
+ * Fetches a single name from the indexer
224
+ * @param args.name - A string of the name to retrieve, e.g. "test.aptos.apt"
225
+ * or "test.apt" or "test". Can be inclusive or exclusive of the .apt suffix.
226
+ * Can be a subdomain.
227
+ *
228
+ * @returns A promise of an ANSName or undefined
229
+ */
230
+ async getName(args: { name: string }): Promise<GetANSNameResponse[0] | undefined> {
231
+ return getName({ aptosConfig: this.config, ...args });
232
+ }
233
+
234
+ /**
235
+ * Fetches all names for an account (both top level domains and subdomains)
236
+ *
237
+ * @param args
238
+ * @param args.accountAddress - A AccountAddressInput of the address to retrieve names for.
239
+ * @param args.options.pagination.offset - Optional, the offset to start from when fetching names
240
+ * @param args.options.pagination.limit - Optional, A number of the names to fetch per request
241
+ * @param args.options.orderBy - The order to sort the names by
242
+ * @param args.options.where - Additional filters to apply to the query
243
+ *
244
+ * @returns a promise of an array of ANSName
245
+ */
246
+ async getAccountNames(args: GetAccountNamesArgs): Promise<GetANSNameResponse> {
247
+ return getAccountNames({ aptosConfig: this.config, ...args });
248
+ }
249
+
250
+ /**
251
+ * Fetches all top level domain names for an account
252
+ *
253
+ * @param args
254
+ * @param args.accountAddress - A AccountAddressInput of the address to retrieve domain names for.
255
+ * @param args.options.pagination.offset - Optional, the offset to start from when fetching names
256
+ * @param args.options.pagination.limit - Optional, A number of the names to fetch per request
257
+ * @param args.options.orderBy - The order to sort the names by
258
+ * @param args.options.where - Additional filters to apply to the query
259
+ *
260
+ * @returns a promise of an array of ANSName
261
+ */
262
+ async getAccountDomains(args: GetAccountDomainsArgs): Promise<GetANSNameResponse> {
263
+ return getAccountDomains({ aptosConfig: this.config, ...args });
264
+ }
265
+
266
+ /**
267
+ * Fetches all subdomains names for an account
268
+ *
269
+ * @param args
270
+ * @param args.accountAddress - A AccountAddressInput of the address to retrieve subdomains names for.
271
+ * @param args.options.pagination.offset - Optional, the offset to start from when fetching names
272
+ * @param args.options.pagination.limit - Optional, A number of the names to fetch per request
273
+ * @param args.options.orderBy - The order to sort the names by
274
+ * @param args.options.where - Additional filters to apply to the query
275
+ *
276
+ * @returns a promise of an array of ANSName
277
+ */
278
+ async getAccountSubdomains(args: GetAccountSubdomainsArgs): Promise<GetANSNameResponse> {
279
+ return getAccountSubdomains({ aptosConfig: this.config, ...args });
280
+ }
281
+
282
+ /**
283
+ * Fetches all subdomains names for a given domain. Note, this will not return the domain itself.
284
+ *
285
+ * @param args
286
+ * @param args.domain - A string of the domain name: eg. "test.apt" or "test" (without the suffix of .apt)
287
+ * @param args.options.pagination.offset - Optional, the offset to start from when fetching names
288
+ * @param args.options.pagination.limit - Optional, A number of the names to fetch per request
289
+ * @param args.options.orderBy - The order to sort the names by
290
+ * @param args.options.where - Additional filters to apply to the query
291
+ *
292
+ * @returns a promise of an array of ANSName
293
+ */
294
+ async getDomainSubdomains(args: GetDomainSubdomainsArgs): Promise<GetANSNameResponse> {
295
+ return getDomainSubdomains({ aptosConfig: this.config, ...args });
296
+ }
58
297
  }
package/src/api/aptos.ts CHANGED
@@ -13,6 +13,10 @@ import { ANS } from "./ans";
13
13
  import { Staking } from "./staking";
14
14
  import { Transaction } from "./transaction";
15
15
  import { TransactionSubmission } from "./transactionSubmission";
16
+ import { Build } from "./transactionSubmission/build";
17
+ import { Sign } from "./transactionSubmission/sign";
18
+ import { Simulate } from "./transactionSubmission/simulate";
19
+ import { Submit } from "./transactionSubmission/submit";
16
20
 
17
21
  /**
18
22
  * This class is the main entry point into Aptos's
@@ -46,6 +50,14 @@ export class Aptos {
46
50
 
47
51
  readonly transactionSubmission: TransactionSubmission;
48
52
 
53
+ readonly build: Build;
54
+
55
+ readonly sign: Sign;
56
+
57
+ readonly simulate: Simulate;
58
+
59
+ readonly submit: Submit;
60
+
49
61
  constructor(settings?: AptosConfig) {
50
62
  this.config = new AptosConfig(settings);
51
63
  this.account = new Account(this.config);
@@ -59,6 +71,10 @@ export class Aptos {
59
71
  this.staking = new Staking(this.config);
60
72
  this.transaction = new Transaction(this.config);
61
73
  this.transactionSubmission = new TransactionSubmission(this.config);
74
+ this.build = new Build(this.config);
75
+ this.sign = new Sign(this.config);
76
+ this.simulate = new Simulate(this.config);
77
+ this.submit = new Submit(this.config);
62
78
  }
63
79
  }
64
80
 
@@ -107,3 +123,7 @@ applyMixin(Aptos, General, "general");
107
123
  applyMixin(Aptos, Staking, "staking");
108
124
  applyMixin(Aptos, Transaction, "transaction");
109
125
  applyMixin(Aptos, TransactionSubmission, "transactionSubmission");
126
+ applyMixin(Aptos, Build, "build");
127
+ applyMixin(Aptos, Sign, "sign");
128
+ applyMixin(Aptos, Simulate, "simulate");
129
+ applyMixin(Aptos, Submit, "submit");
package/src/api/coin.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  import { AptosConfig } from "./aptosConfig";
5
5
  import { Account, AccountAddressInput } from "../core";
6
6
  import { transferCoinTransaction } from "../internal/coin";
7
- import { InputSingleSignerTransaction, InputGenerateTransactionOptions } from "../transactions/types";
7
+ import { SingleSignerTransaction, InputGenerateTransactionOptions } from "../transactions/types";
8
8
  import { AnyNumber, MoveStructId } from "../types";
9
9
 
10
10
  /**
@@ -33,7 +33,7 @@ export class Coin {
33
33
  amount: AnyNumber;
34
34
  coinType?: MoveStructId;
35
35
  options?: InputGenerateTransactionOptions;
36
- }): Promise<InputSingleSignerTransaction> {
36
+ }): Promise<SingleSignerTransaction> {
37
37
  return transferCoinTransaction({ aptosConfig: this.config, ...args });
38
38
  }
39
39
  }
@@ -13,7 +13,7 @@ import {
13
13
  } from "../types";
14
14
  import { AptosConfig } from "./aptosConfig";
15
15
  import { Account, AccountAddressInput } from "../core";
16
- import { InputGenerateTransactionOptions, InputSingleSignerTransaction } from "../transactions/types";
16
+ import { InputGenerateTransactionOptions, SingleSignerTransaction } from "../transactions/types";
17
17
  import {
18
18
  CreateCollectionOptions,
19
19
  createCollectionTransaction,
@@ -69,7 +69,7 @@ export class DigitalAsset {
69
69
  uri: string;
70
70
  options?: InputGenerateTransactionOptions;
71
71
  } & CreateCollectionOptions,
72
- ): Promise<InputSingleSignerTransaction> {
72
+ ): Promise<SingleSignerTransaction> {
73
73
  return createCollectionTransaction({ aptosConfig: this.config, ...args });
74
74
  }
75
75
 
@@ -133,7 +133,7 @@ export class DigitalAsset {
133
133
  name: string;
134
134
  uri: string;
135
135
  options?: InputGenerateTransactionOptions;
136
- }): Promise<InputSingleSignerTransaction> {
136
+ }): Promise<SingleSignerTransaction> {
137
137
  return mintTokenTransaction({ aptosConfig: this.config, ...args });
138
138
  }
139
139
 
@@ -0,0 +1,42 @@
1
+ // Copyright © Aptos Foundation
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { AccountAddressInput } from "../../core";
5
+ import { generateTransaction } from "../../internal/transactionSubmission";
6
+ import {
7
+ InputGenerateTransactionPayloadData,
8
+ InputGenerateTransactionOptions,
9
+ SingleSignerTransaction,
10
+ MultiAgentTransaction,
11
+ } from "../../transactions";
12
+ import { AptosConfig } from "../aptosConfig";
13
+
14
+ /**
15
+ * A class to handle all `Build` transaction operations
16
+ */
17
+ export class Build {
18
+ readonly config: AptosConfig;
19
+
20
+ constructor(config: AptosConfig) {
21
+ this.config = config;
22
+ }
23
+
24
+ async transaction(args: {
25
+ sender: AccountAddressInput;
26
+ data: InputGenerateTransactionPayloadData;
27
+ options?: InputGenerateTransactionOptions;
28
+ withFeePayer?: boolean;
29
+ }): Promise<SingleSignerTransaction> {
30
+ return generateTransaction({ aptosConfig: this.config, ...args });
31
+ }
32
+
33
+ async multiAgentTransaction(args: {
34
+ sender: AccountAddressInput;
35
+ data: InputGenerateTransactionPayloadData;
36
+ secondarySignerAddresses: AccountAddressInput[];
37
+ options?: InputGenerateTransactionOptions;
38
+ withFeePayer?: boolean;
39
+ }): Promise<MultiAgentTransaction> {
40
+ return generateTransaction({ aptosConfig: this.config, ...args });
41
+ }
42
+ }
@@ -0,0 +1,44 @@
1
+ // Copyright © Aptos Foundation
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { Account } from "../../core";
5
+ import { signTransaction } from "../../internal/transactionSubmission";
6
+ import { AccountAuthenticator, AnyRawTransaction } from "../../transactions";
7
+ import { AptosConfig } from "../aptosConfig";
8
+
9
+ /**
10
+ * A class to handle all `Sign` transaction operations
11
+ */
12
+ export class Sign {
13
+ readonly config: AptosConfig;
14
+
15
+ constructor(config: AptosConfig) {
16
+ this.config = config;
17
+ }
18
+
19
+ // eslint-disable-next-line class-methods-use-this
20
+ transaction(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {
21
+ return signTransaction({
22
+ ...args,
23
+ });
24
+ }
25
+
26
+ // eslint-disable-next-line class-methods-use-this
27
+ transactionAsFeePayer(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {
28
+ const { signer, transaction } = args;
29
+
30
+ // if transaction doesnt hold a "feePayerAddress" prop it means
31
+ // this is not a fee payer transaction
32
+ if (!transaction.feePayerAddress) {
33
+ throw new Error(`Transaction ${transaction} is not a Fee Payer transaction`);
34
+ }
35
+
36
+ // Set the feePayerAddress to the signer account address
37
+ transaction.feePayerAddress = signer.accountAddress;
38
+
39
+ return signTransaction({
40
+ signer,
41
+ transaction,
42
+ });
43
+ }
44
+ }
@@ -0,0 +1,56 @@
1
+ // Copyright © Aptos Foundation
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { PublicKey } from "../../core";
5
+ import { simulateTransaction } from "../../internal/transactionSubmission";
6
+ import { AnyRawTransaction, InputSimulateTransactionOptions } from "../../transactions";
7
+ import { UserTransactionResponse } from "../../types";
8
+ import { AptosConfig } from "../aptosConfig";
9
+
10
+ /**
11
+ * A class to handle all `Simulate` transaction operations
12
+ */
13
+ export class Simulate {
14
+ readonly config: AptosConfig;
15
+
16
+ constructor(config: AptosConfig) {
17
+ this.config = config;
18
+ }
19
+
20
+ @ValidateFeePayerData
21
+ async transaction(args: {
22
+ signerPublicKey: PublicKey;
23
+ transaction: AnyRawTransaction;
24
+ feePayerPublicKey?: PublicKey;
25
+ options?: InputSimulateTransactionOptions;
26
+ }): Promise<Array<UserTransactionResponse>> {
27
+ return simulateTransaction({ aptosConfig: this.config, ...args });
28
+ }
29
+
30
+ @ValidateFeePayerData
31
+ async multiAgentTransaction(args: {
32
+ signerPublicKey: PublicKey;
33
+ transaction: AnyRawTransaction;
34
+ secondarySignersPublicKeys: Array<PublicKey>;
35
+ feePayerPublicKey?: PublicKey;
36
+ options?: InputSimulateTransactionOptions;
37
+ }): Promise<Array<UserTransactionResponse>> {
38
+ return simulateTransaction({ aptosConfig: this.config, ...args });
39
+ }
40
+ }
41
+
42
+ function ValidateFeePayerData(target: unknown, propertyKey: string, descriptor: PropertyDescriptor) {
43
+ const originalMethod = descriptor.value;
44
+ /* eslint-disable-next-line func-names, no-param-reassign */
45
+ descriptor.value = async function (...args: any[]) {
46
+ const [methodArgs] = args;
47
+
48
+ if (methodArgs.transaction.feePayerAddress && !methodArgs.feePayerPublicKey) {
49
+ throw new Error("You are simulating a Fee Payer transaction but missing the feePayerPublicKey");
50
+ }
51
+
52
+ return originalMethod.apply(this, args);
53
+ };
54
+
55
+ return descriptor;
56
+ }
@@ -0,0 +1,53 @@
1
+ // Copyright © Aptos Foundation
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { submitTransaction } from "../../internal/transactionSubmission";
5
+ import { AccountAuthenticator, AnyRawTransaction } from "../../transactions";
6
+ import { PendingTransactionResponse } from "../../types";
7
+ import { AptosConfig } from "../aptosConfig";
8
+
9
+ /**
10
+ * A class to handle all `Submit` transaction operations
11
+ */
12
+ export class Submit {
13
+ readonly config: AptosConfig;
14
+
15
+ constructor(config: AptosConfig) {
16
+ this.config = config;
17
+ }
18
+
19
+ @ValidateFeePayerData
20
+ async transaction(args: {
21
+ transaction: AnyRawTransaction;
22
+ senderAuthenticator: AccountAuthenticator;
23
+ feePayerAuthenticator?: AccountAuthenticator;
24
+ }): Promise<PendingTransactionResponse> {
25
+ return submitTransaction({ aptosConfig: this.config, ...args });
26
+ }
27
+
28
+ @ValidateFeePayerData
29
+ async multiAgentTransaction(args: {
30
+ transaction: AnyRawTransaction;
31
+ senderAuthenticator: AccountAuthenticator;
32
+ additionalSignersAuthenticators: Array<AccountAuthenticator>;
33
+ feePayerAuthenticator?: AccountAuthenticator;
34
+ }): Promise<PendingTransactionResponse> {
35
+ return submitTransaction({ aptosConfig: this.config, ...args });
36
+ }
37
+ }
38
+
39
+ function ValidateFeePayerData(target: unknown, propertyKey: string, descriptor: PropertyDescriptor) {
40
+ const originalMethod = descriptor.value;
41
+ /* eslint-disable-next-line func-names, no-param-reassign */
42
+ descriptor.value = async function (...args: any[]) {
43
+ const [methodArgs] = args;
44
+
45
+ if (methodArgs.transaction.feePayerAddress && !methodArgs.feePayerAuthenticator) {
46
+ throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");
47
+ }
48
+
49
+ return originalMethod.apply(this, args);
50
+ };
51
+
52
+ return descriptor;
53
+ }