@aptos-labs/ts-sdk 5.1.1 → 5.1.2

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 (185) hide show
  1. package/README.md +4 -4
  2. package/dist/common/{account-Dr4y1uZG.d.ts → account-147vfOGb.d.ts} +1 -0
  3. package/dist/common/{chunk-A2XB7TVI.js → chunk-347THBDE.js} +3 -3
  4. package/dist/common/chunk-347THBDE.js.map +1 -0
  5. package/dist/common/cli/index.d.ts +3 -1
  6. package/dist/common/cli/index.js +1 -1
  7. package/dist/common/cli/index.js.map +1 -1
  8. package/dist/common/index.d.ts +14 -3
  9. package/dist/common/index.js +6 -6
  10. package/dist/common/index.js.map +1 -1
  11. package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
  12. package/dist/esm/account/AbstractedAccount.mjs +1 -1
  13. package/dist/esm/account/Account.mjs +1 -1
  14. package/dist/esm/account/AccountUtils.mjs +1 -1
  15. package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
  16. package/dist/esm/account/Ed25519Account.mjs +1 -1
  17. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  18. package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
  19. package/dist/esm/account/KeylessAccount.mjs +1 -1
  20. package/dist/esm/account/MultiEd25519Account.mjs +1 -1
  21. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  22. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  23. package/dist/esm/account/index.mjs +1 -1
  24. package/dist/esm/account/utils.mjs +1 -1
  25. package/dist/esm/api/account/abstraction.mjs +1 -1
  26. package/dist/esm/api/account.mjs +1 -1
  27. package/dist/esm/api/ans.mjs +1 -1
  28. package/dist/esm/api/aptos.mjs +1 -1
  29. package/dist/esm/api/aptosConfig.mjs +1 -1
  30. package/dist/esm/api/coin.mjs +1 -1
  31. package/dist/esm/api/digitalAsset.mjs +1 -1
  32. package/dist/esm/api/faucet.mjs +1 -1
  33. package/dist/esm/api/fungibleAsset.mjs +1 -1
  34. package/dist/esm/api/general.mjs +1 -1
  35. package/dist/esm/api/index.mjs +1 -1
  36. package/dist/esm/api/keyless.mjs +1 -1
  37. package/dist/esm/api/object.mjs +1 -1
  38. package/dist/esm/api/staking.mjs +1 -1
  39. package/dist/esm/api/table.mjs +1 -1
  40. package/dist/esm/api/transaction.mjs +1 -1
  41. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  42. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  43. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  44. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  45. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  46. package/dist/esm/api/utils.mjs +1 -1
  47. package/dist/esm/bcs/index.mjs +1 -1
  48. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  49. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  50. package/dist/esm/{chunk-ADJMFL73.mjs → chunk-2OPKZKOB.mjs} +2 -2
  51. package/dist/esm/{chunk-O26BHE5H.mjs → chunk-626KB2UQ.mjs} +2 -2
  52. package/dist/esm/{chunk-KB4XOTCR.mjs → chunk-AQW4BUKF.mjs} +2 -2
  53. package/dist/esm/{chunk-3LJVXUPB.mjs → chunk-E2U27PNC.mjs} +2 -2
  54. package/dist/esm/{chunk-TT3MPSBB.mjs → chunk-FC72YL4B.mjs} +2 -2
  55. package/dist/esm/chunk-GQ3UIDPQ.mjs +2 -0
  56. package/dist/esm/chunk-GQ3UIDPQ.mjs.map +1 -0
  57. package/dist/esm/chunk-H3EP5CGP.mjs +2 -0
  58. package/dist/esm/{chunk-GUPVZIYS.mjs.map → chunk-H3EP5CGP.mjs.map} +1 -1
  59. package/dist/esm/{chunk-7DQDJ2SA.mjs → chunk-LA56UDUK.mjs} +2 -2
  60. package/dist/esm/{chunk-CZDNBI5K.mjs → chunk-LAPXUUHK.mjs} +2 -2
  61. package/dist/esm/{chunk-7ZESTCBD.mjs → chunk-NCKJ7X57.mjs} +2 -2
  62. package/dist/esm/chunk-P5HCJN3A.mjs +2 -0
  63. package/dist/esm/chunk-P5HCJN3A.mjs.map +1 -0
  64. package/dist/esm/{chunk-PGUSBALH.mjs → chunk-PJTG745G.mjs} +3 -3
  65. package/dist/esm/{chunk-PGUSBALH.mjs.map → chunk-PJTG745G.mjs.map} +1 -1
  66. package/dist/esm/{chunk-57YZ7I7V.mjs → chunk-PSSIJHHC.mjs} +2 -2
  67. package/dist/esm/{chunk-I7XT6L7S.mjs → chunk-QNARIAVM.mjs} +2 -2
  68. package/dist/esm/{chunk-DHCGYW3W.mjs → chunk-R7FWJP3N.mjs} +2 -2
  69. package/dist/esm/{chunk-EF4FA5I6.mjs → chunk-RQX6JOEN.mjs} +2 -2
  70. package/dist/esm/{chunk-TSEAIF34.mjs → chunk-YS5IUILF.mjs} +2 -2
  71. package/dist/esm/{chunk-6WDVDEQZ.mjs → chunk-YZHAI55C.mjs} +2 -2
  72. package/dist/esm/chunk-ZYE7UTJZ.mjs +2 -0
  73. package/dist/esm/chunk-ZYE7UTJZ.mjs.map +1 -0
  74. package/dist/esm/cli/index.mjs +1 -1
  75. package/dist/esm/cli/localNode.d.mts +2 -0
  76. package/dist/esm/cli/localNode.mjs +1 -1
  77. package/dist/esm/client/core.mjs +1 -1
  78. package/dist/esm/client/get.mjs +1 -1
  79. package/dist/esm/client/index.mjs +1 -1
  80. package/dist/esm/client/post.mjs +1 -1
  81. package/dist/esm/core/account/index.d.mts +1 -1
  82. package/dist/esm/core/account/index.mjs +1 -1
  83. package/dist/esm/core/account/utils/address.d.mts +12 -1
  84. package/dist/esm/core/account/utils/address.mjs +1 -1
  85. package/dist/esm/core/account/utils/index.d.mts +1 -1
  86. package/dist/esm/core/account/utils/index.mjs +1 -1
  87. package/dist/esm/core/accountAddress.mjs +1 -1
  88. package/dist/esm/core/authenticationKey.mjs +1 -1
  89. package/dist/esm/core/crypto/abstraction.mjs +1 -1
  90. package/dist/esm/core/crypto/deserializationUtils.mjs +1 -1
  91. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  92. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  93. package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
  94. package/dist/esm/core/crypto/index.mjs +1 -1
  95. package/dist/esm/core/crypto/keyless.mjs +1 -1
  96. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  97. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  98. package/dist/esm/core/crypto/privateKey.mjs +1 -1
  99. package/dist/esm/core/crypto/proof.mjs +1 -1
  100. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  101. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  102. package/dist/esm/core/crypto/secp256r1.mjs +1 -1
  103. package/dist/esm/core/crypto/signature.mjs +1 -1
  104. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  105. package/dist/esm/core/crypto/utils.mjs +1 -1
  106. package/dist/esm/core/index.d.mts +1 -1
  107. package/dist/esm/core/index.mjs +1 -1
  108. package/dist/esm/errors/index.mjs +1 -1
  109. package/dist/esm/index.d.mts +1 -1
  110. package/dist/esm/index.mjs +1 -1
  111. package/dist/esm/internal/abstraction.mjs +1 -1
  112. package/dist/esm/internal/account.mjs +1 -1
  113. package/dist/esm/internal/ans.mjs +1 -1
  114. package/dist/esm/internal/coin.mjs +1 -1
  115. package/dist/esm/internal/digitalAsset.mjs +1 -1
  116. package/dist/esm/internal/faucet.mjs +1 -1
  117. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  118. package/dist/esm/internal/general.mjs +1 -1
  119. package/dist/esm/internal/keyless.mjs +1 -1
  120. package/dist/esm/internal/object.mjs +1 -1
  121. package/dist/esm/internal/staking.mjs +1 -1
  122. package/dist/esm/internal/table.mjs +1 -1
  123. package/dist/esm/internal/transaction.mjs +1 -1
  124. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  125. package/dist/esm/internal/utils/index.mjs +1 -1
  126. package/dist/esm/internal/utils/utils.mjs +1 -1
  127. package/dist/esm/internal/view.mjs +1 -1
  128. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  129. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  130. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  131. package/dist/esm/transactions/index.mjs +1 -1
  132. package/dist/esm/transactions/instances/index.mjs +1 -1
  133. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  134. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  135. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  136. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  137. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  138. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  139. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  140. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  141. package/dist/esm/transactions/management/index.mjs +1 -1
  142. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  143. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  144. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  145. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  146. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  147. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  148. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  149. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  150. package/dist/esm/types/index.mjs +1 -1
  151. package/dist/esm/utils/apiEndpoints.d.mts +1 -0
  152. package/dist/esm/utils/apiEndpoints.mjs +1 -1
  153. package/dist/esm/utils/helpers.mjs +1 -1
  154. package/dist/esm/utils/index.mjs +1 -1
  155. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  156. package/dist/esm/version.d.mts +1 -1
  157. package/dist/esm/version.mjs +1 -1
  158. package/package.json +18 -20
  159. package/src/cli/localNode.ts +13 -2
  160. package/src/core/account/utils/address.ts +22 -0
  161. package/src/internal/ans.ts +1 -0
  162. package/src/utils/apiEndpoints.ts +9 -2
  163. package/src/version.ts +1 -1
  164. package/dist/common/chunk-A2XB7TVI.js.map +0 -1
  165. package/dist/esm/chunk-B563XRSZ.mjs +0 -2
  166. package/dist/esm/chunk-B563XRSZ.mjs.map +0 -1
  167. package/dist/esm/chunk-EMR3S3VO.mjs +0 -2
  168. package/dist/esm/chunk-EMR3S3VO.mjs.map +0 -1
  169. package/dist/esm/chunk-GUPVZIYS.mjs +0 -2
  170. package/dist/esm/chunk-HNBVYE3N.mjs +0 -2
  171. package/dist/esm/chunk-HNBVYE3N.mjs.map +0 -1
  172. /package/dist/esm/{chunk-ADJMFL73.mjs.map → chunk-2OPKZKOB.mjs.map} +0 -0
  173. /package/dist/esm/{chunk-O26BHE5H.mjs.map → chunk-626KB2UQ.mjs.map} +0 -0
  174. /package/dist/esm/{chunk-KB4XOTCR.mjs.map → chunk-AQW4BUKF.mjs.map} +0 -0
  175. /package/dist/esm/{chunk-3LJVXUPB.mjs.map → chunk-E2U27PNC.mjs.map} +0 -0
  176. /package/dist/esm/{chunk-TT3MPSBB.mjs.map → chunk-FC72YL4B.mjs.map} +0 -0
  177. /package/dist/esm/{chunk-7DQDJ2SA.mjs.map → chunk-LA56UDUK.mjs.map} +0 -0
  178. /package/dist/esm/{chunk-CZDNBI5K.mjs.map → chunk-LAPXUUHK.mjs.map} +0 -0
  179. /package/dist/esm/{chunk-7ZESTCBD.mjs.map → chunk-NCKJ7X57.mjs.map} +0 -0
  180. /package/dist/esm/{chunk-57YZ7I7V.mjs.map → chunk-PSSIJHHC.mjs.map} +0 -0
  181. /package/dist/esm/{chunk-I7XT6L7S.mjs.map → chunk-QNARIAVM.mjs.map} +0 -0
  182. /package/dist/esm/{chunk-DHCGYW3W.mjs.map → chunk-R7FWJP3N.mjs.map} +0 -0
  183. /package/dist/esm/{chunk-EF4FA5I6.mjs.map → chunk-RQX6JOEN.mjs.map} +0 -0
  184. /package/dist/esm/{chunk-TSEAIF34.mjs.map → chunk-YS5IUILF.mjs.map} +0 -0
  185. /package/dist/esm/{chunk-6WDVDEQZ.mjs.map → chunk-YZHAI55C.mjs.map} +0 -0
@@ -10,6 +10,7 @@ export const NetworkToIndexerAPI: Record<string, string> = {
10
10
  testnet: "https://api.testnet.aptoslabs.com/v1/graphql",
11
11
  devnet: "https://api.devnet.aptoslabs.com/v1/graphql",
12
12
  shelbynet: "https://api.shelbynet.shelby.xyz/v1/graphql",
13
+ netna: "https://api.netna.staging.aptoslabs.com/v1/graphql",
13
14
  local: "http://127.0.0.1:8090/v1/graphql",
14
15
  };
15
16
 
@@ -22,6 +23,7 @@ export const NetworkToNodeAPI: Record<string, string> = {
22
23
  testnet: "https://api.testnet.aptoslabs.com/v1",
23
24
  devnet: "https://api.devnet.aptoslabs.com/v1",
24
25
  shelbynet: "https://api.shelbynet.shelby.xyz/v1",
26
+ netna: "https://api.netna.staging.aptoslabs.com/v1",
25
27
  local: "http://127.0.0.1:8080/v1",
26
28
  };
27
29
 
@@ -32,6 +34,7 @@ export const NetworkToNodeAPI: Record<string, string> = {
32
34
  export const NetworkToFaucetAPI: Record<string, string> = {
33
35
  devnet: "https://faucet.devnet.aptoslabs.com",
34
36
  shelbynet: "https://faucet.shelbynet.shelby.xyz",
37
+ netna: "https://faucet-dev-netna-us-central1-410192433417.us-central1.run.app",
35
38
  local: "http://127.0.0.1:8081",
36
39
  };
37
40
 
@@ -43,7 +46,8 @@ export const NetworkToPepperAPI: Record<string, string> = {
43
46
  mainnet: "https://api.mainnet.aptoslabs.com/keyless/pepper/v0",
44
47
  testnet: "https://api.testnet.aptoslabs.com/keyless/pepper/v0",
45
48
  devnet: "https://api.devnet.aptoslabs.com/keyless/pepper/v0",
46
- shelbynet: "https://api.devnet.aptoslabs.com/keyless/pepper/v0",
49
+ shelbynet: "https://api.shelbynet.aptoslabs.com/keyless/pepper/v0",
50
+ netna: "https://api.devnet.aptoslabs.com/keyless/pepper/v0",
47
51
  // Use the devnet service for local environment
48
52
  local: "https://api.devnet.aptoslabs.com/keyless/pepper/v0",
49
53
  };
@@ -56,7 +60,8 @@ export const NetworkToProverAPI: Record<string, string> = {
56
60
  mainnet: "https://api.mainnet.aptoslabs.com/keyless/prover/v0",
57
61
  testnet: "https://api.testnet.aptoslabs.com/keyless/prover/v0",
58
62
  devnet: "https://api.devnet.aptoslabs.com/keyless/prover/v0",
59
- shelbynet: "https://api.devnet.aptoslabs.com/keyless/prover/v0",
63
+ shelbynet: "https://api.shelbynet.aptoslabs.com/keyless/prover/v0",
64
+ netna: "https://api.devnet.aptoslabs.com/keyless/prover/v0",
60
65
  // Use the devnet service for local environment
61
66
  local: "https://api.devnet.aptoslabs.com/keyless/prover/v0",
62
67
  };
@@ -71,6 +76,7 @@ export enum Network {
71
76
  TESTNET = "testnet",
72
77
  DEVNET = "devnet",
73
78
  SHELBYNET = "shelbynet",
79
+ NETNA = "netna",
74
80
  LOCAL = "local",
75
81
  CUSTOM = "custom",
76
82
  }
@@ -94,6 +100,7 @@ export const NetworkToNetworkName: Record<string, Network> = {
94
100
  testnet: Network.TESTNET,
95
101
  devnet: Network.DEVNET,
96
102
  shelbynet: Network.SHELBYNET,
103
+ netna: Network.NETNA,
97
104
  local: Network.LOCAL,
98
105
  custom: Network.CUSTOM,
99
106
  };
package/src/version.ts CHANGED
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * hardcoded for now, we would want to have it injected dynamically
8
8
  */
9
- export const VERSION = "5.1.1";
9
+ export const VERSION = "5.1.2";
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/andrewhariri/Desktop/aptos-ts-sdk/dist/common/chunk-A2XB7TVI.js","../../src/core/common.ts","../../src/core/hex.ts","../../src/core/accountAddress.ts"],"names":["ParsingError","message","invalidReason","HexInvalidReason","Hex","_Hex","data","bytesToHex"],"mappings":"AAAA,ilBAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CCQhM,IAAMA,CAAAA,CAAN,MAAA,QAA8B,KAAM,CAkBzC,WAAA,CAAYC,CAAAA,CAAiBC,CAAAA,CAAkB,CAC7C,KAAA,CAAMD,CAAO,CAAA,CACb,IAAA,CAAK,aAAA,CAAgBC,CACvB,CACF,CAAA,CC3BA,4CAAuC,IAS3BC,CAAAA,CAAAA,CAAAA,CAAAA,EAAAA,CACVA,CAAAA,CAAA,SAAA,CAAY,WAAA,CACZA,CAAAA,CAAA,cAAA,CAAiB,gBAAA,CACjBA,CAAAA,CAAA,iBAAA,CAAoB,mBAAA,CAHVA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAgCCC,CAAAA,aAAN,MAAMC,CAAI,CAUf,WAAA,CAAYC,CAAAA,CAAkB,CAC5B,IAAA,CAAK,IAAA,CAAOA,CACd,CAaA,YAAA,CAAA,CAA2B,CACzB,OAAO,IAAA,CAAK,IACd,CASA,qBAAA,CAAA,CAAgC,CAC9B,OAAOC,+BAAAA,IAAW,CAAK,IAAI,CAC7B,CASA,QAAA,CAAA,CAAmB,CACjB,MAAO,CAAA,EAAA,EAAK,IAAA,CAAK,qBAAA,CAAsB,CAAC,CAAA,CAAA;ACkVsB;AAnWV,SAAA","file":"/Users/andrewhariri/Desktop/aptos-ts-sdk/dist/common/chunk-A2XB7TVI.js","sourcesContent":[null,"// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This error is used to explain why parsing failed.\n * @group Implementation\n * @category Serialization\n */\nexport class ParsingError<T> extends Error {\n /**\n * This provides a programmatic way to access why parsing failed. Downstream devs\n * might want to use this to build their own error messages if the default error\n * messages are not suitable for their use case. This should be an enum.\n * @group Implementation\n * @category Serialization\n */\n public invalidReason: T;\n\n /**\n * Creates an instance of the error with a specified message and invalid reason.\n *\n * @param message The error message that describes the issue.\n * @param invalidReason The reason why the input is considered invalid.\n * @group Implementation\n * @category Serialization\n */\n constructor(message: string, invalidReason: T) {\n super(message);\n this.invalidReason = invalidReason;\n }\n}\n\n/**\n * Whereas ParsingError is thrown when parsing fails, e.g. in a fromString function,\n * this type is returned from \"defensive\" functions like isValid.\n * @group Implementation\n * @category Serialization\n */\nexport type ParsingResult<T> = {\n /**\n * True if valid, false otherwise.\n * @group Implementation\n * @category Serialization\n */\n valid: boolean;\n\n /**\n * If valid is false, this will be a code explaining why parsing failed.\n * @group Implementation\n * @category Serialization\n */\n invalidReason?: T;\n\n /**\n * If valid is false, this will be a string explaining why parsing failed.\n * @group Implementation\n * @category Serialization\n */\n invalidReasonMessage?: string;\n};\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bytesToHex, hexToBytes } from \"@noble/hashes/utils\";\nimport { ParsingError, ParsingResult } from \"./common\";\nimport { HexInput } from \"../types\";\n\n/**\n * Provides reasons for parsing failures related to hexadecimal values.\n * @group Implementation\n * @category Serialization\n */\nexport enum HexInvalidReason {\n TOO_SHORT = \"too_short\",\n INVALID_LENGTH = \"invalid_length\",\n INVALID_HEX_CHARS = \"invalid_hex_chars\",\n}\n\n/**\n * NOTE: Do not use this class when working with account addresses; use AccountAddress instead.\n * When accepting hex data as input to a function, prefer to accept HexInput and\n *\n * A helper class for working with hex data. Hex data, when represented as a string,\n * generally looks like this, for example: 0xaabbcc, 45cd32, etc.\n *\n * then use the static helper methods of this class to convert it into the desired\n * format. This enables the greatest flexibility for the developer.\n *\n * Example usage:\n * ```typescript\n * getTransactionByHash(txnHash: HexInput): Promise<Transaction> {\n * const txnHashString = Hex.fromHexInput(txnHash).toString();\n * return await getTransactionByHashInner(txnHashString);\n * }\n * ```\n * This call to `Hex.fromHexInput().toString()` converts the HexInput to a hex string\n * with a leading 0x prefix, regardless of what the input format was.\n *\n * Other ways to chain the functions together:\n * - `Hex.fromHexString({ hexInput: \"0x1f\" }).toUint8Array()`\n * - `new Hex([1, 3]).toStringWithoutPrefix()`\n * @group Implementation\n * @category Serialization\n */\nexport class Hex {\n private readonly data: Uint8Array;\n\n /**\n * Create a new Hex instance from a Uint8Array.\n *\n * @param data - The Uint8Array containing the data to initialize the Hex instance.\n * @group Implementation\n * @category Serialization\n */\n constructor(data: Uint8Array) {\n this.data = data;\n }\n\n // ===\n // Methods for representing an instance of Hex as other types.\n // ===\n\n /**\n * Get the inner hex data as a Uint8Array. The inner data is already a Uint8Array, so no conversion takes place.\n *\n * @returns Hex data as Uint8Array\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data;\n }\n\n /**\n * Get the hex data as a string without the 0x prefix.\n *\n * @returns Hex string without 0x prefix\n * @group Implementation\n * @category Serialization\n */\n toStringWithoutPrefix(): string {\n return bytesToHex(this.data);\n }\n\n /**\n * Get the hex data as a string with the 0x prefix.\n *\n * @returns Hex string with 0x prefix\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n return `0x${this.toStringWithoutPrefix()}`;\n }\n\n // ===\n // Methods for creating an instance of Hex from other types.\n // ===\n\n /**\n * Converts a hex string into a Hex instance, allowing for both prefixed and non-prefixed formats.\n *\n * @param str - A hex string, with or without the 0x prefix.\n *\n * @throws ParsingError - If the hex string is too short, has an odd number of characters, or contains invalid hex characters.\n *\n * @returns Hex - The resulting Hex instance created from the provided string.\n * @group Implementation\n * @category Serialization\n */\n static fromHexString(str: string): Hex {\n let input = str;\n\n if (input.startsWith(\"0x\")) {\n input = input.slice(2);\n }\n\n if (input.length === 0) {\n throw new ParsingError(\n \"Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.\",\n HexInvalidReason.TOO_SHORT,\n );\n }\n\n if (input.length % 2 !== 0) {\n throw new ParsingError(\"Hex string must be an even number of hex characters.\", HexInvalidReason.INVALID_LENGTH);\n }\n\n try {\n return new Hex(hexToBytes(input));\n } catch (error: any) {\n throw new ParsingError(\n `Hex string contains invalid hex characters: ${error?.message}`,\n HexInvalidReason.INVALID_HEX_CHARS,\n );\n }\n }\n\n /**\n * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Hex instance.\n * This function is useful for transforming hexadecimal representations into a structured Hex object for further manipulation.\n *\n * @param hexInput - A HexInput which can be a string or Uint8Array.\n * @returns A Hex instance created from the provided hexInput.\n * @group Implementation\n * @category Serialization\n */\n static fromHexInput(hexInput: HexInput): Hex {\n if (hexInput instanceof Uint8Array) return new Hex(hexInput);\n return Hex.fromHexString(hexInput);\n }\n\n /**\n * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Uint8Array.\n *\n * @param hexInput - A HexInput which can be a string or Uint8Array.\n * @returns A Uint8Array created from the provided hexInput.\n */\n static hexInputToUint8Array(hexInput: HexInput): Uint8Array {\n if (hexInput instanceof Uint8Array) return hexInput;\n return Hex.fromHexString(hexInput).toUint8Array();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string with '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string with '0x' prefix (e.g., \"0x1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToString(\"1234\") // returns \"0x1234\"\n * Hex.hexInputToString(\"0x1234\") // returns \"0x1234\"\n * Hex.hexInputToString(new Uint8Array([0x12, 0x34])) // returns \"0x1234\"\n * ```\n */\n static hexInputToString(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toString();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string without '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string without '0x' prefix (e.g., \"1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToStringWithoutPrefix(\"1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(\"0x1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(new Uint8Array([0x12, 0x34])) // returns \"1234\"\n * ```\n */\n static hexInputToStringWithoutPrefix(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toStringWithoutPrefix();\n }\n\n // ===\n // Methods for checking validity.\n // ===\n\n /**\n * Check if the provided string is a valid hexadecimal representation.\n *\n * @param str - A hex string representing byte data.\n *\n * @returns An object containing:\n * - valid: A boolean indicating whether the string is valid.\n * - invalidReason: The reason for invalidity if the string is not valid.\n * - invalidReasonMessage: A message explaining why the string is invalid.\n * @group Implementation\n * @category Serialization\n */\n static isValid(str: string): ParsingResult<HexInvalidReason> {\n try {\n Hex.fromHexString(str);\n return { valid: true };\n } catch (error: any) {\n return {\n valid: false,\n invalidReason: error?.invalidReason,\n invalidReasonMessage: error?.message,\n };\n }\n }\n\n /**\n * Determine if two Hex instances are equal by comparing their underlying byte data.\n *\n * @param other The Hex instance to compare to.\n * @returns true if the Hex instances are equal, false if not.\n * @group Implementation\n * @category Serialization\n */\n equals(other: Hex): boolean {\n if (this.data.length !== other.data.length) return false;\n return this.data.every((value, index) => value === other.data[index]);\n }\n}\n\nexport const hexToAsciiString = (hex: string) => new TextDecoder().decode(Hex.fromHexInput(hex).toUint8Array());\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bytesToHex, hexToBytes } from \"@noble/hashes/utils\";\nimport { Serializable, Serializer } from \"../bcs/serializer\";\nimport { Deserializer } from \"../bcs/deserializer\";\nimport { ParsingError, ParsingResult } from \"./common\";\nimport { TransactionArgument } from \"../transactions/instances/transactionArgument\";\nimport { HexInput, ScriptTransactionArgumentVariants } from \"../types\";\n\n/**\n * Provides reasons for an address was invalid.\n * @group Implementation\n * @category Serialization\n */\nexport enum AddressInvalidReason {\n INCORRECT_NUMBER_OF_BYTES = \"incorrect_number_of_bytes\",\n INVALID_HEX_CHARS = \"invalid_hex_chars\",\n TOO_SHORT = \"too_short\",\n TOO_LONG = \"too_long\",\n LEADING_ZERO_X_REQUIRED = \"leading_zero_x_required\",\n LONG_FORM_REQUIRED_UNLESS_SPECIAL = \"long_form_required_unless_special\",\n INVALID_PADDING_ZEROES = \"INVALID_PADDING_ZEROES\",\n INVALID_PADDING_STRICTNESS = \"INVALID_PADDING_STRICTNESS\",\n}\n\n/**\n * The input for an account address, which can be either a hexadecimal string or a standard account address.\n * @group Implementation\n * @category Serialization\n */\nexport type AccountAddressInput = HexInput | AccountAddress;\n\n/**\n * NOTE: Only use this class for account addresses. For other hex data, e.g. transaction\n * hashes, use the Hex class.\n *\n * AccountAddress is used for working with account addresses. Account addresses, when\n * represented as a string, generally look like these examples:\n * - 0x1\n * - 0xaa86fe99004361f747f91342ca13c426ca0cccb0c1217677180c9493bad6ef0c\n *\n * Proper formatting and parsing of account addresses is defined by AIP-40.\n * To learn more about the standard, read the AIP here:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * The comments in this class make frequent reference to the LONG and SHORT formats,\n * as well as \"special\" addresses. To learn what these refer to see AIP-40.\n * @group Implementation\n * @category Serialization\n */\nexport class AccountAddress extends Serializable implements TransactionArgument {\n /**\n * This is the internal representation of an account address.\n * @group Implementation\n * @category Serialization\n */\n readonly data: Uint8Array;\n\n /**\n * The number of bytes that make up an account address.\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH: number = 32;\n\n /**\n * The length of an address string in LONG form without a leading 0x.\n * @group Implementation\n * @category Serialization\n */\n static readonly LONG_STRING_LENGTH: number = 64;\n\n static ZERO: AccountAddress = AccountAddress.from(\"0x0\");\n\n static ONE: AccountAddress = AccountAddress.from(\"0x1\");\n\n static TWO: AccountAddress = AccountAddress.from(\"0x2\");\n\n static THREE: AccountAddress = AccountAddress.from(\"0x3\");\n\n static FOUR: AccountAddress = AccountAddress.from(\"0x4\");\n\n static A: AccountAddress = AccountAddress.from(\"0xA\");\n\n /**\n * Creates an instance of AccountAddress from a Uint8Array.\n *\n * This function ensures that the input data is exactly 32 bytes long, which is required for a valid account address.\n *\n * @param input A Uint8Array representing an account address.\n * @throws ParsingError if the input length is not equal to 32 bytes.\n * @group Implementation\n * @category Serialization\n */\n constructor(input: Uint8Array) {\n super();\n if (input.length !== AccountAddress.LENGTH) {\n throw new ParsingError(\n \"AccountAddress data should be exactly 32 bytes long\",\n AddressInvalidReason.INCORRECT_NUMBER_OF_BYTES,\n );\n }\n this.data = input;\n }\n\n /**\n * Determines if the address is classified as special, which is defined as 0x0 to 0xf inclusive.\n * In other words, the last byte of the address must be < 0b10000 (16)\n * and every other byte must be zero.\n *\n * For more information on how special addresses are defined, see AIP-40:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @returns true if the address is special, false otherwise.\n * @group Implementation\n * @category Serialization\n */\n isSpecial(): boolean {\n return (\n this.data.slice(0, this.data.length - 1).every((byte) => byte === 0) && this.data[this.data.length - 1] < 0b10000\n );\n }\n // ===\n // Methods for representing an instance of AccountAddress as other types.\n // ===\n\n /**\n * Return the AccountAddress as a string as per AIP-40.\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n * This representation returns special addresses in SHORT form (0xf)\n * and other addresses in LONG form (0x + 64 characters).\n *\n * @returns AccountAddress as a string conforming to AIP-40.\n * @group Implementation\n * @category Serialization\n */\n toString(): `0x${string}` {\n return `0x${this.toStringWithoutPrefix()}`;\n }\n\n /**\n * Return the AccountAddress as a string conforming to AIP-40 but without the leading 0x.\n *\n * NOTE: Prefer to use `toString` where possible.\n *\n * @returns AccountAddress as a string without the leading 0x.\n * @group Implementation\n * @category Serialization\n */\n toStringWithoutPrefix(): string {\n let hex = bytesToHex(this.data);\n if (this.isSpecial()) {\n hex = hex[hex.length - 1];\n }\n return hex;\n }\n\n /**\n * Convert the account address to a string in LONG format, which is always 0x followed by 64 hex characters.\n *\n * NOTE: Prefer to use `toString` where possible, as it formats special addresses using the SHORT form (no leading 0s).\n *\n * @returns AccountAddress as a string in LONG form.\n * @group Implementation\n * @category Serialization\n */\n toStringLong(): `0x${string}` {\n return `0x${this.toStringLongWithoutPrefix()}`;\n }\n\n /**\n * Returns the account address as a string in LONG form without a leading 0x.\n * This function will include leading zeroes and will produce a string of 64 hex characters.\n *\n * NOTE: Prefer to use `toString` where possible, as it formats special addresses using the SHORT form (no leading 0s).\n *\n * @returns {string} The account address in LONG form.\n * @group Implementation\n * @category Serialization\n */\n toStringLongWithoutPrefix(): string {\n return bytesToHex(this.data);\n }\n\n /**\n * Convert the account address to a string in SHORT format, which is 0x followed by the shortest\n * possible representation (no leading zeros).\n *\n * @returns AccountAddress as a string in SHORT form.\n * @group Implementation\n * @category Serialization\n */\n toStringShort(): `0x${string}` {\n return `0x${this.toStringShortWithoutPrefix()}`;\n }\n\n /**\n * Returns a lossless short string representation of the address by trimming leading zeros.\n * If the address consists of all zeros, returns \"0\".\n *\n * @returns A string representation of the address without leading zeros\n * @group Implementation\n * @category Serialization\n */\n toStringShortWithoutPrefix(): string {\n const hex = bytesToHex(this.data).replace(/^0+/, \"\");\n return hex === \"\" ? \"0\" : hex;\n }\n\n /**\n * Get the inner data as a Uint8Array.\n * The inner data is already a Uint8Array, so no conversion takes place.\n *\n * @returns Hex data as Uint8Array\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data;\n }\n\n /**\n * Serialize the AccountAddress to a Serializer instance's data buffer.\n * @param serializer The serializer to serialize the AccountAddress to.\n * @returns void\n * @example\n * const serializer = new Serializer();\n * const address = AccountAddress.fromString(\"0x1\");\n * address.serialize(serializer);\n * const bytes = serializer.toUint8Array();\n * // `bytes` is now the BCS-serialized address.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.data);\n }\n\n /**\n * Serializes the current instance into a byte sequence suitable for entry functions.\n * This allows for the proper encoding of data when interacting with entry functions in the blockchain.\n *\n * @param serializer - The serializer instance used to convert the data into bytes.\n * @group Implementation\n * @category Serialization\n */\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n /**\n * Serializes the current instance for use in a script function by encoding it into a byte sequence.\n * This process involves serializing the variant index and the instance data, making it suitable for transmission.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category Serialization\n */\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.Address);\n serializer.serialize(this);\n }\n\n /**\n * Deserialize an AccountAddress from the byte buffer in a Deserializer instance.\n * This function allows you to convert a byte representation of an AccountAddress into an instance of AccountAddress.\n * @param deserializer The deserializer to deserialize the AccountAddress from.\n * @returns An instance of AccountAddress.\n * @example\n * const bytes = hexToBytes(\"0x0102030405060708091011121314151617181920212223242526272829303132\");\n * const deserializer = new Deserializer(bytes);\n * const address = AccountAddress.deserialize(deserializer);\n * // `address` is now an instance of AccountAddress.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): AccountAddress {\n const bytes = deserializer.deserializeFixedBytes(AccountAddress.LENGTH);\n return new AccountAddress(bytes);\n }\n\n // ===\n // Methods for creating an instance of AccountAddress from other types.\n // ===\n\n /**\n * NOTE: This function has strict parsing behavior. For relaxed behavior, please use\n * the `fromString` function.\n *\n * Creates an instance of AccountAddress from a hex string.\n *\n * This function allows only the strictest formats defined by AIP-40. In short this\n * means only the following formats are accepted:\n *\n * - LONG\n * - SHORT for special addresses\n *\n * Where:\n * - LONG is defined as 0x + 64 hex characters.\n * - SHORT for special addresses is 0x0 to 0xf inclusive without padding zeroes.\n *\n * This means the following are not accepted:\n * - SHORT for non-special addresses.\n * - Any address without a leading 0x.\n *\n * @param input - A hex string representing an account address.\n *\n * @throws {ParsingError} If the hex string does not start with 0x or is not in a valid format.\n *\n * @remarks\n *\n * This function has strict parsing behavior. For relaxed behavior, please use the `fromString` function.\n *\n * @see AIP-40 documentation for more details on address formats:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @returns An instance of AccountAddress.\n * @group Implementation\n * @category Serialization\n */\n static fromStringStrict(input: string): AccountAddress {\n // Assert the string starts with 0x.\n if (!input.startsWith(\"0x\")) {\n throw new ParsingError(\"Hex string must start with a leading 0x.\", AddressInvalidReason.LEADING_ZERO_X_REQUIRED);\n }\n\n const address = AccountAddress.fromString(input);\n\n // Check if the address is in LONG form. If it is not, this is only allowed for\n // special addresses, in which case we check it is in proper SHORT form.\n if (input.length !== AccountAddress.LONG_STRING_LENGTH + 2) {\n if (!address.isSpecial()) {\n throw new ParsingError(\n `The given hex string ${input} is not a special address, it must be represented as 0x + 64 chars.`,\n AddressInvalidReason.LONG_FORM_REQUIRED_UNLESS_SPECIAL,\n );\n } else if (input.length !== 3) {\n // 0x + one hex char is the only valid SHORT form for special addresses.\n throw new ParsingError(\n // eslint-disable-next-line max-len\n `The given hex string ${input} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,\n AddressInvalidReason.INVALID_PADDING_ZEROES,\n );\n }\n }\n\n return address;\n }\n\n /**\n * NOTE: This function has relaxed parsing behavior. For strict behavior, please use\n * the `fromStringStrict` function. Where possible use `fromStringStrict` rather than this\n * function, `fromString`.\n *\n * Creates an instance of AccountAddress from a hex string.\n *\n * This function allows all formats defined by AIP-40. In short this means the\n * following formats are accepted:\n *\n * - LONG, with or without leading 0x\n * - SHORT*, with or without leading 0x\n *\n * Where:\n * - LONG is 64 hex characters.\n * - SHORT* is 1 to 63 hex characters inclusive. The address can have missing values up to `maxMissingChars` before it is padded.\n * - Padding zeroes are allowed, e.g. 0x0123 is valid.\n *\n * Learn more about the different address formats by reading AIP-40:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @param input A hex string representing an account address.\n * @param args.maxMissingChars The number of characters that can be missing in a padded address before it is invalid.\n *\n * @returns An instance of AccountAddress.\n *\n * @throws ParsingError if the hex string is too short, too long, or contains invalid characters.\n * @group Implementation\n * @category Serialization\n */\n static fromString(input: string, { maxMissingChars = 4 }: { maxMissingChars?: number } = {}): AccountAddress {\n let parsedInput = input;\n // Remove leading 0x for parsing.\n if (input.startsWith(\"0x\")) {\n parsedInput = input.slice(2);\n }\n\n // Ensure the address string is at least 1 character long.\n if (parsedInput.length === 0) {\n throw new ParsingError(\n \"Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.\",\n AddressInvalidReason.TOO_SHORT,\n );\n }\n\n // Ensure the address string is not longer than 64 characters.\n if (parsedInput.length > 64) {\n throw new ParsingError(\n \"Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.\",\n AddressInvalidReason.TOO_LONG,\n );\n }\n\n // Ensure that the maxMissingChars is between or equal to 0 and 63.\n if (maxMissingChars > 63 || maxMissingChars < 0) {\n throw new ParsingError(\n `maxMissingChars must be between or equal to 0 and 63. Received ${maxMissingChars}`,\n AddressInvalidReason.INVALID_PADDING_STRICTNESS,\n );\n }\n\n let addressBytes: Uint8Array;\n try {\n // Pad the address with leading zeroes, so it is 64 chars long and then convert\n // the hex string to bytes. Every two characters in a hex string constitutes a\n // single byte. So a 64 length hex string becomes a 32 byte array.\n addressBytes = hexToBytes(parsedInput.padStart(64, \"0\"));\n } catch (error: any) {\n // At this point the only way this can fail is if the hex string contains\n // invalid characters.\n throw new ParsingError(`Hex characters are invalid: ${error?.message}`, AddressInvalidReason.INVALID_HEX_CHARS);\n }\n\n const address = new AccountAddress(addressBytes);\n\n // Cannot pad the address if it has more than maxMissingChars missing.\n if (parsedInput.length < 64 - maxMissingChars) {\n if (!address.isSpecial()) {\n throw new ParsingError(\n `Hex string is too short, must be ${64 - maxMissingChars} to 64 chars long, excluding the leading 0x. You may need to fix \nthe addresss by padding it with 0s before passing it to \\`fromString\\` (e.g. <addressString>.padStart(64, '0')). \nReceived ${input}`,\n AddressInvalidReason.TOO_SHORT,\n );\n }\n }\n\n return address;\n }\n\n /**\n * Convenience method for creating an AccountAddress from various input types.\n * This function accepts a string, Uint8Array, or an existing AccountAddress instance and returns the corresponding\n * AccountAddress.\n *\n * @param input - The input to convert into an AccountAddress. This can be a string representation of an address, a Uint8Array,\n * or an existing AccountAddress.\n * @param args.maxMissingChars The number of characters that can be missing in a padded address before it is invalid.\n * @group Implementation\n * @category Serialization\n */\n static from(input: AccountAddressInput, { maxMissingChars = 4 }: { maxMissingChars?: number } = {}): AccountAddress {\n if (typeof input === \"string\") {\n return AccountAddress.fromString(input, { maxMissingChars });\n }\n if (input instanceof Uint8Array) {\n return new AccountAddress(input);\n }\n return input;\n }\n\n /**\n * Create an AccountAddress from various input types, including strings, Uint8Array, and AccountAddress instances.\n *\n * @param input - The input to convert into an AccountAddress, which can be a string, a Uint8Array, or an AccountAddress.\n * @group Implementation\n * @category Serialization\n */\n static fromStrict(input: AccountAddressInput): AccountAddress {\n if (typeof input === \"string\") {\n return AccountAddress.fromStringStrict(input);\n }\n if (input instanceof Uint8Array) {\n return new AccountAddress(input);\n }\n return input;\n }\n // ===\n // Methods for checking validity.\n // ===\n\n /**\n * Check if the provided input is a valid AccountAddress.\n *\n * @param args - The arguments for validation.\n * @param args.input - A hex string representing an account address.\n * @param args.strict - If true, use strict parsing behavior; if false, use relaxed parsing behavior.\n *\n * @returns An object indicating whether the address is valid. If valid, valid = true; if not, valid = false with additional details.\n * If the address is invalid, invalidReason will explain why it is invalid, and invalidReasonMessage will provide the error message.\n * @group Implementation\n * @category Serialization\n */\n static isValid(args: { input: AccountAddressInput; strict?: boolean }): ParsingResult<AddressInvalidReason> {\n try {\n if (args.strict) {\n AccountAddress.fromStrict(args.input);\n } else {\n AccountAddress.from(args.input);\n }\n return { valid: true };\n } catch (error: any) {\n return {\n valid: false,\n invalidReason: error?.invalidReason,\n invalidReasonMessage: error?.message,\n };\n }\n }\n\n /**\n * Determine if two AccountAddresses are equal based on their underlying byte data.\n *\n * @param other - The AccountAddress to compare to.\n * @returns true if the AccountAddresses are equal, false if not.\n * @group Implementation\n * @category Serialization\n */\n equals(other: AccountAddress): boolean {\n if (this.data.length !== other.data.length) return false;\n return this.data.every((value, index) => value === other.data[index]);\n }\n}\n"]}
@@ -1,2 +0,0 @@
1
- import{a as r}from"./chunk-7DQDJ2SA.mjs";import{spawn as c}from"child_process";import l from"tree-kill";import{platform as h}from"os";var e=class{constructor(t){this.MAXIMUM_WAIT_TIME_SEC=75;this.READINESS_ENDPOINT="http://127.0.0.1:8070/";this.showStdout=!0;this.process=null;this.showStdout=t?.showStdout??!0}async stop(){await new Promise((t,o)=>{this.process?.pid&&l(this.process.pid,s=>{s?o(s):t(!0)})})}async run(){await this.checkIfProcessIsUp()||(this.start(),await this.waitUntilProcessIsUp())}start(){let t="npx",o=["aptos","node","run-localnet","--force-restart","--assume-yes","--with-indexer-api"],s=h(),a={env:{...process.env,ENABLE_KEYLESS_DEFAULT:"1"},...s==="win32"&&{shell:!0}};this.process=c(t,o,a),this.process.stdout?.on("data",i=>{let n=i.toString();this.showStdout&&console.log(n)})}async waitUntilProcessIsUp(){let t=await this.checkIfProcessIsUp(),o=Date.now()/1e3,s=o;for(;!t&&o+this.MAXIMUM_WAIT_TIME_SEC>s;)await r(1e3),t=await this.checkIfProcessIsUp(),s=Date.now()/1e3;if(!t)throw new Error("Process failed to start");return!0}async checkIfProcessIsUp(){try{return(await fetch(this.READINESS_ENDPOINT)).status===200}catch{return!1}}};export{e as a};
2
- //# sourceMappingURL=chunk-B563XRSZ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/cli/localNode.ts"],"sourcesContent":["/* eslint-disable no-console */\n\nimport { ChildProcessWithoutNullStreams, spawn } from \"child_process\";\nimport kill from \"tree-kill\";\nimport { platform } from \"os\";\n\nimport { sleep } from \"../utils/helpers\";\n\n/**\n * Represents a local node for running a localnet environment.\n * This class provides methods to start, stop, and check the status of the localnet process.\n * It manages the lifecycle of the node process and ensures that it is operational before executing tests.\n * @group Implementation\n * @category CLI\n */\nexport class LocalNode {\n readonly MAXIMUM_WAIT_TIME_SEC = 75;\n\n readonly READINESS_ENDPOINT = \"http://127.0.0.1:8070/\";\n\n showStdout: boolean = true;\n\n process: ChildProcessWithoutNullStreams | null = null;\n\n constructor(args?: { showStdout?: boolean }) {\n this.showStdout = args?.showStdout ?? true;\n }\n\n /**\n * Kills the current process and all its descendant processes.\n *\n * @returns {Promise<void>} A promise that resolves to true if the process was successfully killed.\n * @throws {Error} If there is an error while attempting to kill the process.\n * @group Implementation\n * @category CLI\n */\n async stop(): Promise<void> {\n await new Promise((resolve, reject) => {\n if (!this.process?.pid) return;\n\n /**\n * Terminates the process associated with the given process ID.\n *\n * @param pid - The process ID of the process to be terminated.\n * @param callback - A function that is called after the termination attempt is complete.\n * @param callback.err - An error object if the termination failed; otherwise, null.\n * @param callback.resolve - A boolean indicating whether the termination was successful.\n * @group Implementation\n * @category CLI\n */\n kill(this.process.pid, (err) => {\n if (err) {\n reject(err);\n } else {\n resolve(true);\n }\n });\n });\n }\n\n /**\n * Runs a localnet and waits for the process to be up.\n * If the local node process is already running, it returns without starting the process.\n *\n * @returns {Promise<void>} A promise that resolves when the process is up.\n * @group Implementation\n * @category CLI\n */\n async run(): Promise<void> {\n const nodeIsUp = await this.checkIfProcessIsUp();\n if (nodeIsUp) {\n return;\n }\n this.start();\n await this.waitUntilProcessIsUp();\n }\n\n /**\n * Starts the localnet by running the Aptos node with the specified command-line arguments.\n *\n * @returns {void}\n *\n * @throws {Error} If there is an issue starting the localnet.\n * @group Implementation\n * @category CLI\n */\n start(): void {\n const cliCommand = \"npx\";\n const cliArgs = [\"aptos\", \"node\", \"run-localnet\", \"--force-restart\", \"--assume-yes\", \"--with-indexer-api\"];\n\n const currentPlatform = platform();\n const spawnConfig = {\n env: { ...process.env, ENABLE_KEYLESS_DEFAULT: \"1\" },\n ...(currentPlatform === \"win32\" && { shell: true }),\n };\n\n this.process = spawn(cliCommand, cliArgs, spawnConfig);\n\n this.process.stdout?.on(\"data\", (data: any) => {\n const str = data.toString();\n // Print local node output log\n if (this.showStdout) {\n console.log(str);\n }\n });\n }\n\n /**\n * Waits for the localnet process to be operational within a specified maximum wait time.\n * This function continuously checks if the process is up and will throw an error if it fails to start.\n *\n * @returns Promise<boolean> - Resolves to true if the process is up, otherwise throws an error.\n * @group Implementation\n * @category CLI\n */\n async waitUntilProcessIsUp(): Promise<boolean> {\n let operational = await this.checkIfProcessIsUp();\n const start = Date.now() / 1000;\n let last = start;\n\n while (!operational && start + this.MAXIMUM_WAIT_TIME_SEC > last) {\n // eslint-disable-next-line no-await-in-loop\n await sleep(1000);\n // eslint-disable-next-line no-await-in-loop\n operational = await this.checkIfProcessIsUp();\n last = Date.now() / 1000;\n }\n\n // If we are here it means something blocks the process to start.\n // Might worth checking if another process is running on port 8080\n if (!operational) {\n throw new Error(\"Process failed to start\");\n }\n\n return true;\n }\n\n /**\n * Checks if the localnet is up by querying the readiness endpoint.\n *\n * @returns Promise<boolean> - A promise that resolves to true if the localnet is up, otherwise false.\n * @group Implementation\n * @category CLI\n */\n async checkIfProcessIsUp(): Promise<boolean> {\n try {\n // Query readiness endpoint\n const data = await fetch(this.READINESS_ENDPOINT);\n if (data.status === 200) {\n return true;\n }\n return false;\n } catch (err: any) {\n return false;\n }\n }\n}\n"],"mappings":"yCAEA,OAAyC,SAAAA,MAAa,gBACtD,OAAOC,MAAU,YACjB,OAAS,YAAAC,MAAgB,KAWlB,IAAMC,EAAN,KAAgB,CASrB,YAAYC,EAAiC,CAR7C,KAAS,sBAAwB,GAEjC,KAAS,mBAAqB,yBAE9B,gBAAsB,GAEtB,aAAiD,KAG/C,KAAK,WAAaA,GAAM,YAAc,EACxC,CAUA,MAAM,MAAsB,CAC1B,MAAM,IAAI,QAAQ,CAACC,EAASC,IAAW,CAChC,KAAK,SAAS,KAYnBC,EAAK,KAAK,QAAQ,IAAMC,GAAQ,CAC1BA,EACFF,EAAOE,CAAG,EAEVH,EAAQ,EAAI,CAEhB,CAAC,CACH,CAAC,CACH,CAUA,MAAM,KAAqB,CACR,MAAM,KAAK,mBAAmB,IAI/C,KAAK,MAAM,EACX,MAAM,KAAK,qBAAqB,EAClC,CAWA,OAAc,CACZ,IAAMI,EAAa,MACbC,EAAU,CAAC,QAAS,OAAQ,eAAgB,kBAAmB,eAAgB,oBAAoB,EAEnGC,EAAkBC,EAAS,EAC3BC,EAAc,CAClB,IAAK,CAAE,GAAG,QAAQ,IAAK,uBAAwB,GAAI,EACnD,GAAIF,IAAoB,SAAW,CAAE,MAAO,EAAK,CACnD,EAEA,KAAK,QAAUG,EAAML,EAAYC,EAASG,CAAW,EAErD,KAAK,QAAQ,QAAQ,GAAG,OAASE,GAAc,CAC7C,IAAMC,EAAMD,EAAK,SAAS,EAEtB,KAAK,YACP,QAAQ,IAAIC,CAAG,CAEnB,CAAC,CACH,CAUA,MAAM,sBAAyC,CAC7C,IAAIC,EAAc,MAAM,KAAK,mBAAmB,EAC1CC,EAAQ,KAAK,IAAI,EAAI,IACvBC,EAAOD,EAEX,KAAO,CAACD,GAAeC,EAAQ,KAAK,sBAAwBC,GAE1D,MAAMC,EAAM,GAAI,EAEhBH,EAAc,MAAM,KAAK,mBAAmB,EAC5CE,EAAO,KAAK,IAAI,EAAI,IAKtB,GAAI,CAACF,EACH,MAAM,IAAI,MAAM,yBAAyB,EAG3C,MAAO,EACT,CASA,MAAM,oBAAuC,CAC3C,GAAI,CAGF,OADa,MAAM,MAAM,KAAK,kBAAkB,GACvC,SAAW,GAItB,MAAmB,CACjB,MAAO,EACT,CACF,CACF","names":["spawn","kill","platform","LocalNode","args","resolve","reject","kill","err","cliCommand","cliArgs","currentPlatform","platform","spawnConfig","spawn","data","str","operational","start","last","sleep"]}
@@ -1,2 +0,0 @@
1
- var s={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",shelbynet:"https://api.shelbynet.shelby.xyz/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},p={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",shelbynet:"https://api.shelbynet.shelby.xyz/v1",local:"http://127.0.0.1:8080/v1"},o={devnet:"https://faucet.devnet.aptoslabs.com",shelbynet:"https://faucet.shelbynet.shelby.xyz",local:"http://127.0.0.1:8081"},n={mainnet:"https://api.mainnet.aptoslabs.com/keyless/pepper/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/pepper/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",shelbynet:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"https://api.devnet.aptoslabs.com/keyless/pepper/v0"},a={mainnet:"https://api.mainnet.aptoslabs.com/keyless/prover/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/prover/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/prover/v0",shelbynet:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"https://api.devnet.aptoslabs.com/keyless/prover/v0"},e=(t=>(t.MAINNET="mainnet",t.TESTNET="testnet",t.DEVNET="devnet",t.SHELBYNET="shelbynet",t.LOCAL="local",t.CUSTOM="custom",t))(e||{}),l={mainnet:1,testnet:2,local:4},r={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",shelbynet:"shelbynet",local:"local",custom:"custom"};export{s as a,p as b,o as c,n as d,a as e,e as f,l as g,r as h};
2
- //# sourceMappingURL=chunk-EMR3S3VO.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/apiEndpoints.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * @group Implementation\n * @category Network\n */\nexport const NetworkToIndexerAPI: Record<string, string> = {\n mainnet: \"https://api.mainnet.aptoslabs.com/v1/graphql\",\n testnet: \"https://api.testnet.aptoslabs.com/v1/graphql\",\n devnet: \"https://api.devnet.aptoslabs.com/v1/graphql\",\n shelbynet: \"https://api.shelbynet.shelby.xyz/v1/graphql\",\n local: \"http://127.0.0.1:8090/v1/graphql\",\n};\n\n/**\n * @group Implementation\n * @category Network\n */\nexport const NetworkToNodeAPI: Record<string, string> = {\n mainnet: \"https://api.mainnet.aptoslabs.com/v1\",\n testnet: \"https://api.testnet.aptoslabs.com/v1\",\n devnet: \"https://api.devnet.aptoslabs.com/v1\",\n shelbynet: \"https://api.shelbynet.shelby.xyz/v1\",\n local: \"http://127.0.0.1:8080/v1\",\n};\n\n/**\n * @group Implementation\n * @category Network\n */\nexport const NetworkToFaucetAPI: Record<string, string> = {\n devnet: \"https://faucet.devnet.aptoslabs.com\",\n shelbynet: \"https://faucet.shelbynet.shelby.xyz\",\n local: \"http://127.0.0.1:8081\",\n};\n\n/**\n * @group Implementation\n * @category Network\n */\nexport const NetworkToPepperAPI: Record<string, string> = {\n mainnet: \"https://api.mainnet.aptoslabs.com/keyless/pepper/v0\",\n testnet: \"https://api.testnet.aptoslabs.com/keyless/pepper/v0\",\n devnet: \"https://api.devnet.aptoslabs.com/keyless/pepper/v0\",\n shelbynet: \"https://api.devnet.aptoslabs.com/keyless/pepper/v0\",\n // Use the devnet service for local environment\n local: \"https://api.devnet.aptoslabs.com/keyless/pepper/v0\",\n};\n\n/**\n * @group Implementation\n * @category Network\n */\nexport const NetworkToProverAPI: Record<string, string> = {\n mainnet: \"https://api.mainnet.aptoslabs.com/keyless/prover/v0\",\n testnet: \"https://api.testnet.aptoslabs.com/keyless/prover/v0\",\n devnet: \"https://api.devnet.aptoslabs.com/keyless/prover/v0\",\n shelbynet: \"https://api.devnet.aptoslabs.com/keyless/prover/v0\",\n // Use the devnet service for local environment\n local: \"https://api.devnet.aptoslabs.com/keyless/prover/v0\",\n};\n\n/**\n * Different network environments for connecting to services, ranging from production to development setups.\n * @group Implementation\n * @category Network\n */\nexport enum Network {\n MAINNET = \"mainnet\",\n TESTNET = \"testnet\",\n DEVNET = \"devnet\",\n SHELBYNET = \"shelbynet\",\n LOCAL = \"local\",\n CUSTOM = \"custom\",\n}\n\n/**\n * @group Implementation\n * @category Network\n */\nexport const NetworkToChainId: Record<string, number> = {\n mainnet: 1,\n testnet: 2,\n local: 4,\n};\n\n/**\n * @group Implementation\n * @category Network\n */\nexport const NetworkToNetworkName: Record<string, Network> = {\n mainnet: Network.MAINNET,\n testnet: Network.TESTNET,\n devnet: Network.DEVNET,\n shelbynet: Network.SHELBYNET,\n local: Network.LOCAL,\n custom: Network.CUSTOM,\n};\n"],"mappings":"AAOO,IAAMA,EAA8C,CACzD,QAAS,+CACT,QAAS,+CACT,OAAQ,8CACR,UAAW,8CACX,MAAO,kCACT,EAMaC,EAA2C,CACtD,QAAS,uCACT,QAAS,uCACT,OAAQ,sCACR,UAAW,sCACX,MAAO,0BACT,EAMaC,EAA6C,CACxD,OAAQ,sCACR,UAAW,sCACX,MAAO,uBACT,EAMaC,EAA6C,CACxD,QAAS,sDACT,QAAS,sDACT,OAAQ,qDACR,UAAW,qDAEX,MAAO,oDACT,EAMaC,EAA6C,CACxD,QAAS,sDACT,QAAS,sDACT,OAAQ,qDACR,UAAW,qDAEX,MAAO,oDACT,EAOYC,OACVA,EAAA,QAAU,UACVA,EAAA,QAAU,UACVA,EAAA,OAAS,SACTA,EAAA,UAAY,YACZA,EAAA,MAAQ,QACRA,EAAA,OAAS,SANCA,OAAA,IAaCC,EAA2C,CACtD,QAAS,EACT,QAAS,EACT,MAAO,CACT,EAMaC,EAAgD,CAC3D,QAAS,UACT,QAAS,UACT,OAAQ,SACR,UAAW,YACX,MAAO,QACP,OAAQ,QACV","names":["NetworkToIndexerAPI","NetworkToNodeAPI","NetworkToFaucetAPI","NetworkToPepperAPI","NetworkToProverAPI","Network","NetworkToChainId","NetworkToNetworkName"]}
@@ -1,2 +0,0 @@
1
- var o="5.1.1";export{o as a};
2
- //# sourceMappingURL=chunk-GUPVZIYS.mjs.map
@@ -1,2 +0,0 @@
1
- import{b as c}from"./chunk-RGKRCZ36.mjs";import{sha3_256 as n}from"@noble/hashes/sha3";var d=(e,r)=>{let t=e.bcsToBytes(),s=typeof r=="string"?Buffer.from(r,"utf8"):r,o=new Uint8Array([...t,...s,254]);return new c(n(o))},f=(e,r)=>{let t=e.bcsToBytes(),s=typeof r=="string"?Buffer.from(r,"utf8"):r,o=new Uint8Array([...t,...s,255]);return new c(n(o))},a=(e,r,t)=>{let s=`${r}::${t}`;return d(e,s)};export{d as a,f as b,a as c};
2
- //# sourceMappingURL=chunk-HNBVYE3N.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/account/utils/address.ts"],"sourcesContent":["import { sha3_256 } from \"@noble/hashes/sha3\";\nimport { AccountAddress } from \"../../accountAddress\";\nimport { DeriveScheme } from \"../../../types\";\n\n/**\n * Creates an object address from creator address and seed\n *\n * @param creatorAddress The object creator account address\n * @param seed The seed in either Uint8Array | string type\n *\n * @returns The object account address\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport const createObjectAddress = (creatorAddress: AccountAddress, seed: Uint8Array | string): AccountAddress => {\n const creatorBytes = creatorAddress.bcsToBytes();\n\n const seedBytes = typeof seed === \"string\" ? Buffer.from(seed, \"utf8\") : seed;\n\n const bytes = new Uint8Array([...creatorBytes, ...seedBytes, DeriveScheme.DeriveObjectAddressFromSeed]);\n\n return new AccountAddress(sha3_256(bytes));\n};\n\n/**\n * Creates a resource address from creator address and seed\n *\n * @param creatorAddress The creator account address\n * @param seed The seed in either Uint8Array | string type\n *\n * @returns The resource account address\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport const createResourceAddress = (creatorAddress: AccountAddress, seed: Uint8Array | string): AccountAddress => {\n const creatorBytes = creatorAddress.bcsToBytes();\n\n const seedBytes = typeof seed === \"string\" ? Buffer.from(seed, \"utf8\") : seed;\n\n const bytes = new Uint8Array([...creatorBytes, ...seedBytes, DeriveScheme.DeriveResourceAccountAddress]);\n\n return new AccountAddress(sha3_256(bytes));\n};\n\n/**\n * Creates a token object address from creator address, collection name and token name\n *\n * @param creatorAddress The token creator account address\n * @param collectionName The collection name\n * @param tokenName The token name\n *\n * @returns The token account address\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport const createTokenAddress = (\n creatorAddress: AccountAddress,\n collectionName: string,\n tokenName: string,\n): AccountAddress => {\n const seed = `${collectionName}::${tokenName}`;\n return createObjectAddress(creatorAddress, seed);\n};\n"],"mappings":"yCAAA,OAAS,YAAAA,MAAgB,qBAclB,IAAMC,EAAsB,CAACC,EAAgCC,IAA8C,CAChH,IAAMC,EAAeF,EAAe,WAAW,EAEzCG,EAAY,OAAOF,GAAS,SAAW,OAAO,KAAKA,EAAM,MAAM,EAAIA,EAEnEG,EAAQ,IAAI,WAAW,CAAC,GAAGF,EAAc,GAAGC,KAAmD,CAAC,EAEtG,OAAO,IAAIE,EAAeC,EAASF,CAAK,CAAC,CAC3C,EAYaG,EAAwB,CAACP,EAAgCC,IAA8C,CAClH,IAAMC,EAAeF,EAAe,WAAW,EAEzCG,EAAY,OAAOF,GAAS,SAAW,OAAO,KAAKA,EAAM,MAAM,EAAIA,EAEnEG,EAAQ,IAAI,WAAW,CAAC,GAAGF,EAAc,GAAGC,KAAoD,CAAC,EAEvG,OAAO,IAAIE,EAAeC,EAASF,CAAK,CAAC,CAC3C,EAaaI,EAAqB,CAChCR,EACAS,EACAC,IACmB,CACnB,IAAMT,EAAO,GAAGQ,CAAc,KAAKC,CAAS,GAC5C,OAAOX,EAAoBC,EAAgBC,CAAI,CACjD","names":["sha3_256","createObjectAddress","creatorAddress","seed","creatorBytes","seedBytes","bytes","AccountAddress","sha3_256","createResourceAddress","createTokenAddress","collectionName","tokenName"]}