@aptos-labs/ts-sdk 1.36.0-zeta.0 → 1.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/dist/common/{accountAddress-C685VEzA.d.ts → accountAddress-DZH9Wn5l.d.ts} +28 -1
  2. package/dist/common/chunk-MVCKMP5U.js +4 -0
  3. package/dist/common/{chunk-5GUWOXQG.js.map → chunk-MVCKMP5U.js.map} +1 -1
  4. package/dist/common/cli/index.d.ts +1 -1
  5. package/dist/common/cli/index.js +1 -1
  6. package/dist/common/cli/index.js.map +1 -1
  7. package/dist/common/index.d.ts +221 -31
  8. package/dist/common/index.js +9 -9
  9. package/dist/common/index.js.map +1 -1
  10. package/dist/esm/{Ed25519Account-6KGApCPu.d.mts → Ed25519Account-CDURCT1q.d.mts} +56 -0
  11. package/dist/esm/account/AbstractKeylessAccount.d.mts +2 -2
  12. package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
  13. package/dist/esm/account/AbstractedAccount.d.mts +1 -1
  14. package/dist/esm/account/AbstractedAccount.mjs +1 -1
  15. package/dist/esm/account/Account.d.mts +3 -3
  16. package/dist/esm/account/Account.mjs +1 -1
  17. package/dist/esm/account/AccountUtils.d.mts +2 -2
  18. package/dist/esm/account/AccountUtils.mjs +1 -1
  19. package/dist/esm/account/Ed25519Account.d.mts +4 -4
  20. package/dist/esm/account/Ed25519Account.mjs +1 -1
  21. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  22. package/dist/esm/account/FederatedKeylessAccount.d.mts +2 -2
  23. package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
  24. package/dist/esm/account/KeylessAccount.d.mts +2 -2
  25. package/dist/esm/account/KeylessAccount.mjs +1 -1
  26. package/dist/esm/account/MultiEd25519Account.d.mts +35 -13
  27. package/dist/esm/account/MultiEd25519Account.mjs +1 -1
  28. package/dist/esm/account/MultiKeyAccount.d.mts +6 -2
  29. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  30. package/dist/esm/account/SingleKeyAccount.d.mts +4 -4
  31. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  32. package/dist/esm/account/index.d.mts +2 -2
  33. package/dist/esm/account/index.mjs +1 -1
  34. package/dist/esm/account/utils.mjs +1 -1
  35. package/dist/esm/api/account/abstraction.mjs +1 -1
  36. package/dist/esm/api/account.d.mts +85 -6
  37. package/dist/esm/api/account.mjs +1 -1
  38. package/dist/esm/api/ans.d.mts +1 -1
  39. package/dist/esm/api/ans.mjs +1 -1
  40. package/dist/esm/api/aptos.d.mts +2 -2
  41. package/dist/esm/api/aptos.mjs +1 -1
  42. package/dist/esm/api/coin.mjs +1 -1
  43. package/dist/esm/api/digitalAsset.d.mts +1 -1
  44. package/dist/esm/api/digitalAsset.mjs +1 -1
  45. package/dist/esm/api/event.mjs +1 -1
  46. package/dist/esm/api/experimental.mjs +1 -1
  47. package/dist/esm/api/faucet.mjs +1 -1
  48. package/dist/esm/api/fungibleAsset.d.mts +1 -1
  49. package/dist/esm/api/fungibleAsset.mjs +1 -1
  50. package/dist/esm/api/general.mjs +1 -1
  51. package/dist/esm/api/index.d.mts +2 -2
  52. package/dist/esm/api/index.mjs +1 -1
  53. package/dist/esm/api/keyless.d.mts +2 -2
  54. package/dist/esm/api/keyless.mjs +1 -1
  55. package/dist/esm/api/object.mjs +1 -1
  56. package/dist/esm/api/staking.mjs +1 -1
  57. package/dist/esm/api/table.mjs +1 -1
  58. package/dist/esm/api/transaction.d.mts +1 -1
  59. package/dist/esm/api/transaction.mjs +1 -1
  60. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  61. package/dist/esm/api/transactionSubmission/management.d.mts +1 -1
  62. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  63. package/dist/esm/api/transactionSubmission/sign.d.mts +1 -1
  64. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  65. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  66. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  67. package/dist/esm/api/utils.mjs +1 -1
  68. package/dist/esm/bcs/index.mjs +1 -1
  69. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  70. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  71. package/dist/esm/{chunk-AIPHJFJL.mjs → chunk-3IGJ2IMB.mjs} +2 -2
  72. package/dist/esm/{chunk-CWL7ZA3P.mjs → chunk-5MMTP427.mjs} +2 -2
  73. package/dist/esm/chunk-6374Q7AG.mjs +2 -0
  74. package/dist/esm/{chunk-3RVAGHAA.mjs.map → chunk-6374Q7AG.mjs.map} +1 -1
  75. package/dist/esm/{chunk-AEGA5N2W.mjs → chunk-6J64BOS7.mjs} +2 -2
  76. package/dist/esm/chunk-7H44HTYE.mjs +4 -0
  77. package/dist/esm/chunk-7H44HTYE.mjs.map +1 -0
  78. package/dist/esm/{chunk-6KE4JZD6.mjs → chunk-7VEWPUCH.mjs} +2 -2
  79. package/dist/esm/chunk-ANTUWHYB.mjs +2 -0
  80. package/dist/esm/chunk-ANTUWHYB.mjs.map +1 -0
  81. package/dist/esm/{chunk-R6QCPXQG.mjs → chunk-B373VRCY.mjs} +2 -2
  82. package/dist/esm/chunk-B373VRCY.mjs.map +1 -0
  83. package/dist/esm/{chunk-TTY5GFMN.mjs → chunk-BSH7B2QT.mjs} +2 -2
  84. package/dist/esm/chunk-EYLZD4JU.mjs +4 -0
  85. package/dist/esm/chunk-EYLZD4JU.mjs.map +1 -0
  86. package/dist/esm/chunk-GPG64UZT.mjs +2 -0
  87. package/dist/esm/{chunk-X5YB74NB.mjs.map → chunk-GPG64UZT.mjs.map} +1 -1
  88. package/dist/esm/{chunk-PSZYS4RG.mjs → chunk-HRHICHDX.mjs} +2 -2
  89. package/dist/esm/{chunk-XLDMPCLF.mjs → chunk-JG4T5BDZ.mjs} +2 -2
  90. package/dist/esm/{chunk-35CO4BP4.mjs → chunk-LBA4CTUV.mjs} +2 -2
  91. package/dist/esm/{chunk-RXMLONF7.mjs → chunk-NZXPT44W.mjs} +2 -2
  92. package/dist/esm/{chunk-KXVD52Y6.mjs → chunk-POELQOLD.mjs} +2 -2
  93. package/dist/esm/chunk-PR72YXRK.mjs +2 -0
  94. package/dist/esm/chunk-PR72YXRK.mjs.map +1 -0
  95. package/dist/esm/{chunk-3EUHEZND.mjs → chunk-PXG3WJIU.mjs} +2 -2
  96. package/dist/esm/{chunk-TBY3VMMV.mjs → chunk-TTFYJM6A.mjs} +2 -2
  97. package/dist/esm/{chunk-EODSU3YN.mjs → chunk-VNUNIQAY.mjs} +2 -2
  98. package/dist/esm/{chunk-WB26DWOY.mjs → chunk-YHJHXLYS.mjs} +2 -2
  99. package/dist/esm/{chunk-7YTGBTWH.mjs → chunk-YHKWV7NV.mjs} +2 -2
  100. package/dist/esm/cli/index.mjs +1 -1
  101. package/dist/esm/cli/localNode.mjs +1 -1
  102. package/dist/esm/client/core.mjs +1 -1
  103. package/dist/esm/client/get.d.mts +5 -1
  104. package/dist/esm/client/get.mjs +1 -1
  105. package/dist/esm/client/index.d.mts +1 -1
  106. package/dist/esm/client/index.mjs +1 -1
  107. package/dist/esm/client/post.mjs +1 -1
  108. package/dist/esm/core/account/index.mjs +1 -1
  109. package/dist/esm/core/account/utils/address.mjs +1 -1
  110. package/dist/esm/core/account/utils/index.mjs +1 -1
  111. package/dist/esm/core/accountAddress.d.mts +18 -0
  112. package/dist/esm/core/accountAddress.mjs +1 -1
  113. package/dist/esm/core/authenticationKey.mjs +1 -1
  114. package/dist/esm/core/crypto/abstraction.mjs +1 -1
  115. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  116. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  117. package/dist/esm/core/crypto/federatedKeyless.d.mts +2 -2
  118. package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
  119. package/dist/esm/core/crypto/index.d.mts +1 -1
  120. package/dist/esm/core/crypto/index.mjs +1 -1
  121. package/dist/esm/core/crypto/keyless.d.mts +1 -1
  122. package/dist/esm/core/crypto/keyless.mjs +1 -1
  123. package/dist/esm/core/crypto/multiEd25519.d.mts +2 -2
  124. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  125. package/dist/esm/core/crypto/multiKey.d.mts +4 -1
  126. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  127. package/dist/esm/core/crypto/privateKey.mjs +1 -1
  128. package/dist/esm/core/crypto/proof.mjs +1 -1
  129. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  130. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  131. package/dist/esm/core/crypto/signature.mjs +1 -1
  132. package/dist/esm/core/crypto/singleKey.d.mts +4 -1
  133. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  134. package/dist/esm/core/index.d.mts +1 -1
  135. package/dist/esm/core/index.mjs +1 -1
  136. package/dist/esm/errors/index.mjs +1 -1
  137. package/dist/esm/{federatedKeyless-Qe_j8OqV.d.mts → federatedKeyless-J5bdbbLQ.d.mts} +20 -20
  138. package/dist/esm/index.d.mts +5 -5
  139. package/dist/esm/index.mjs +1 -1
  140. package/dist/esm/internal/abstraction.mjs +1 -1
  141. package/dist/esm/internal/account.d.mts +49 -6
  142. package/dist/esm/internal/account.mjs +1 -1
  143. package/dist/esm/internal/ans.d.mts +1 -1
  144. package/dist/esm/internal/ans.mjs +1 -1
  145. package/dist/esm/internal/coin.mjs +1 -1
  146. package/dist/esm/internal/digitalAsset.d.mts +1 -1
  147. package/dist/esm/internal/digitalAsset.mjs +1 -1
  148. package/dist/esm/internal/event.mjs +1 -1
  149. package/dist/esm/internal/experimental.mjs +1 -1
  150. package/dist/esm/internal/faucet.mjs +1 -1
  151. package/dist/esm/internal/fungibleAsset.d.mts +1 -1
  152. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  153. package/dist/esm/internal/general.mjs +1 -1
  154. package/dist/esm/internal/keyless.d.mts +2 -2
  155. package/dist/esm/internal/keyless.mjs +1 -1
  156. package/dist/esm/internal/object.mjs +1 -1
  157. package/dist/esm/internal/staking.mjs +1 -1
  158. package/dist/esm/internal/table.mjs +1 -1
  159. package/dist/esm/internal/transaction.mjs +1 -1
  160. package/dist/esm/internal/transactionSubmission.d.mts +1 -1
  161. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  162. package/dist/esm/internal/utils/index.d.mts +1 -1
  163. package/dist/esm/internal/utils/index.mjs +1 -1
  164. package/dist/esm/internal/utils/utils.d.mts +2 -19
  165. package/dist/esm/internal/utils/utils.mjs +1 -1
  166. package/dist/esm/internal/view.mjs +1 -1
  167. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  168. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  169. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  170. package/dist/esm/transactions/index.mjs +1 -1
  171. package/dist/esm/transactions/instances/index.mjs +1 -1
  172. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  173. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  174. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  175. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  176. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  177. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  178. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  179. package/dist/esm/transactions/management/accountSequenceNumber.d.mts +1 -1
  180. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  181. package/dist/esm/transactions/management/index.d.mts +1 -1
  182. package/dist/esm/transactions/management/index.mjs +1 -1
  183. package/dist/esm/transactions/management/transactionWorker.d.mts +1 -1
  184. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  185. package/dist/esm/transactions/scriptComposer/index.mjs +1 -1
  186. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  187. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  188. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  189. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  190. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  191. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  192. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  193. package/dist/esm/types/index.d.mts +1 -1
  194. package/dist/esm/types/index.mjs +1 -1
  195. package/dist/esm/types/types.d.mts +10 -1
  196. package/dist/esm/types/types.mjs +1 -1
  197. package/dist/esm/utils/helpers.d.mts +27 -1
  198. package/dist/esm/utils/helpers.mjs +1 -1
  199. package/dist/esm/utils/index.d.mts +3 -1
  200. package/dist/esm/utils/index.mjs +1 -1
  201. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  202. package/dist/esm/version.d.mts +1 -1
  203. package/dist/esm/version.mjs +1 -1
  204. package/package.json +7 -1
  205. package/src/account/Account.ts +20 -0
  206. package/src/account/Ed25519Account.ts +26 -1
  207. package/src/account/MultiEd25519Account.ts +28 -1
  208. package/src/account/MultiKeyAccount.ts +2 -0
  209. package/src/account/SingleKeyAccount.ts +35 -1
  210. package/src/api/account.ts +84 -4
  211. package/src/client/get.ts +45 -18
  212. package/src/core/accountAddress.ts +25 -0
  213. package/src/core/crypto/federatedKeyless.ts +8 -2
  214. package/src/core/crypto/keyless.ts +93 -60
  215. package/src/core/crypto/multiEd25519.ts +2 -2
  216. package/src/core/crypto/multiKey.ts +24 -13
  217. package/src/core/crypto/singleKey.ts +12 -2
  218. package/src/internal/account.ts +84 -7
  219. package/src/internal/utils/utils.ts +2 -32
  220. package/src/types/types.ts +10 -0
  221. package/src/utils/helpers.ts +50 -0
  222. package/src/version.ts +1 -1
  223. package/dist/common/chunk-5GUWOXQG.js +0 -4
  224. package/dist/esm/chunk-3RVAGHAA.mjs +0 -2
  225. package/dist/esm/chunk-LQOSHBB7.mjs +0 -4
  226. package/dist/esm/chunk-LQOSHBB7.mjs.map +0 -1
  227. package/dist/esm/chunk-NFPNWY6Z.mjs +0 -4
  228. package/dist/esm/chunk-NFPNWY6Z.mjs.map +0 -1
  229. package/dist/esm/chunk-R6QCPXQG.mjs.map +0 -1
  230. package/dist/esm/chunk-TNWABITK.mjs +0 -2
  231. package/dist/esm/chunk-TNWABITK.mjs.map +0 -1
  232. package/dist/esm/chunk-X5YB74NB.mjs +0 -2
  233. package/dist/esm/chunk-ZELTLAUN.mjs +0 -2
  234. package/dist/esm/chunk-ZELTLAUN.mjs.map +0 -1
  235. /package/dist/esm/{chunk-AIPHJFJL.mjs.map → chunk-3IGJ2IMB.mjs.map} +0 -0
  236. /package/dist/esm/{chunk-CWL7ZA3P.mjs.map → chunk-5MMTP427.mjs.map} +0 -0
  237. /package/dist/esm/{chunk-AEGA5N2W.mjs.map → chunk-6J64BOS7.mjs.map} +0 -0
  238. /package/dist/esm/{chunk-6KE4JZD6.mjs.map → chunk-7VEWPUCH.mjs.map} +0 -0
  239. /package/dist/esm/{chunk-TTY5GFMN.mjs.map → chunk-BSH7B2QT.mjs.map} +0 -0
  240. /package/dist/esm/{chunk-PSZYS4RG.mjs.map → chunk-HRHICHDX.mjs.map} +0 -0
  241. /package/dist/esm/{chunk-XLDMPCLF.mjs.map → chunk-JG4T5BDZ.mjs.map} +0 -0
  242. /package/dist/esm/{chunk-35CO4BP4.mjs.map → chunk-LBA4CTUV.mjs.map} +0 -0
  243. /package/dist/esm/{chunk-RXMLONF7.mjs.map → chunk-NZXPT44W.mjs.map} +0 -0
  244. /package/dist/esm/{chunk-KXVD52Y6.mjs.map → chunk-POELQOLD.mjs.map} +0 -0
  245. /package/dist/esm/{chunk-3EUHEZND.mjs.map → chunk-PXG3WJIU.mjs.map} +0 -0
  246. /package/dist/esm/{chunk-TBY3VMMV.mjs.map → chunk-TTFYJM6A.mjs.map} +0 -0
  247. /package/dist/esm/{chunk-EODSU3YN.mjs.map → chunk-VNUNIQAY.mjs.map} +0 -0
  248. /package/dist/esm/{chunk-WB26DWOY.mjs.map → chunk-YHJHXLYS.mjs.map} +0 -0
  249. /package/dist/esm/{chunk-7YTGBTWH.mjs.map → chunk-YHKWV7NV.mjs.map} +0 -0
@@ -1,4 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var M=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var y=(r,e,t,n)=>{for(var s=n>1?void 0:n?E(e,t):e,i=r.length-1,u;i>=0;i--)(u=r[i])&&(s=(n?u(e,t,s):u(s))||s);return n&&s&&M(e,t,s),s};var g=class extends Error{constructor(e,t){super(e),this.invalidReason=t}};var _utils = require('@noble/hashes/utils');var k=(n=>(n.TOO_SHORT="too_short",n.INVALID_LENGTH="invalid_length",n.INVALID_HEX_CHARS="invalid_hex_chars",n))(k||{}),_= exports.j =class r{constructor(e){this.data=e}toUint8Array(){return this.data}toStringWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromHexString(e){let t=e;if(t.startsWith("0x")&&(t=t.slice(2)),t.length===0)throw new g("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(t.length%2!==0)throw new g("Hex string must be an even number of hex characters.","invalid_length");try{return new r(_utils.hexToBytes.call(void 0, t))}catch(n){throw new g(`Hex string contains invalid hex characters: ${_optionalChain([n, 'optionalAccess', _2 => _2.message])}`,"invalid_hex_chars")}}static fromHexInput(e){if(e instanceof Buffer)return new r(new Uint8Array(e));if(e instanceof Uint8Array)return new r(e);if(typeof e=="string")return r.fromHexString(e);throw new Error(`Invalid hex input type: ${typeof e}`)}static hexInputToUint8Array(e){return e instanceof Uint8Array?e:r.fromHexString(e).toUint8Array()}static hexInputToString(e){return r.fromHexInput(e).toString()}static hexInputToStringWithoutPrefix(e){return r.fromHexInput(e).toStringWithoutPrefix()}static isValid(e){try{return r.fromHexString(e),{valid:!0}}catch(t){return{valid:!1,invalidReason:_optionalChain([t, 'optionalAccess', _3 => _3.invalidReason]),invalidReasonMessage:_optionalChain([t, 'optionalAccess', _4 => _4.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((t,n)=>t===e.data[n])}},ge= exports.k =r=>new TextDecoder().decode(_.fromHexInput(r).toUint8Array());var S=255,U= exports.c =65535,f= exports.d =4294967295,b= exports.e =18446744073709551615n,R= exports.f =340282366920938463463374607431768211455n,T= exports.g =115792089237316195423570985008687907853269984665640564039457584007913129639935n;var x=class{bcsToBytes(){let e=new c;return this.serialize(e),e.toUint8Array()}bcsToHex(){let e=this.bcsToBytes();return _.fromHexInput(e)}toStringWithoutPrefix(){return this.bcsToHex().toStringWithoutPrefix()}toString(){return`0x${this.toStringWithoutPrefix()}`}},c= exports.m =class{constructor(e=64){if(e<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(e),this.offset=0}ensureBufferWillHandleSize(e){for(;this.buffer.byteLength<this.offset+e;){let t=new ArrayBuffer(this.buffer.byteLength*2);new Uint8Array(t).set(new Uint8Array(this.buffer)),this.buffer=t}}appendToBuffer(e){this.ensureBufferWillHandleSize(e.length),new Uint8Array(this.buffer,this.offset).set(e),this.offset+=e.length}serializeWithFunction(e,t,n){this.ensureBufferWillHandleSize(t);let s=new DataView(this.buffer,this.offset);e.apply(s,[0,n,!0]),this.offset+=t}serializeStr(e){let t=new TextEncoder;this.serializeBytes(t.encode(e))}serializeBytes(e){this.serializeU32AsUleb128(e.length),this.appendToBuffer(e)}serializeFixedBytes(e){this.appendToBuffer(e)}serializeBool(e){C(e);let t=e?1:0;this.appendToBuffer(new Uint8Array([t]))}serializeU8(e){this.appendToBuffer(new Uint8Array([e]))}serializeU16(e){this.serializeWithFunction(DataView.prototype.setUint16,2,e)}serializeU32(e){this.serializeWithFunction(DataView.prototype.setUint32,4,e)}serializeU64(e){let t=BigInt(e)&BigInt(f),n=BigInt(e)>>BigInt(32);this.serializeU32(Number(t)),this.serializeU32(Number(n))}serializeU128(e){let t=BigInt(e)&b,n=BigInt(e)>>BigInt(64);this.serializeU64(t),this.serializeU64(n)}serializeU256(e){let t=BigInt(e)&R,n=BigInt(e)>>BigInt(128);this.serializeU128(t),this.serializeU128(n)}serializeU32AsUleb128(e){let t=e,n=[];for(;t>>>7;)n.push(t&127|128),t>>>=7;n.push(t),this.appendToBuffer(new Uint8Array(n))}toUint8Array(){return new Uint8Array(this.buffer).slice(0,this.offset)}serialize(e){e.serialize(this)}serializeVector(e){this.serializeU32AsUleb128(e.length),e.forEach(t=>{t.serialize(this)})}serializeOption(e,t){let n=e!==void 0;this.serializeBool(n),n&&(typeof e=="string"?this.serializeStr(e):e instanceof Uint8Array?t!==void 0?this.serializeFixedBytes(e):this.serializeBytes(e):e.serialize(this))}serializeOptionStr(e){e===void 0?this.serializeU32AsUleb128(0):(this.serializeU32AsUleb128(1),this.serializeStr(e))}};y([h(0,S)],c.prototype,"serializeU8",1),y([h(0,U)],c.prototype,"serializeU16",1),y([h(0,f)],c.prototype,"serializeU32",1),y([h(BigInt(0),b)],c.prototype,"serializeU64",1),y([h(BigInt(0),R)],c.prototype,"serializeU128",1),y([h(BigInt(0),T)],c.prototype,"serializeU256",1),y([h(0,f)],c.prototype,"serializeU32AsUleb128",1);function C(r){if(typeof r!="boolean")throw new Error(`${r} is not a boolean value`)}var w=(r,e,t)=>`${r} is out of range: [${e}, ${t}]`;function H(r,e,t){let n=BigInt(r);if(n>BigInt(t)||n<BigInt(e))throw new Error(w(r,e,t))}function h(r,e){return(t,n,s)=>{let i=s.value;return s.value=function(d){return H(d,r,e),i.apply(this,[d])},s}}var O=(s=>(s.JSON="application/json",s.BCS="application/x-bcs",s.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",s.BCS_VIEW_FUNCTION="application/x.aptos.view_function+bcs",s))(O||{}),W= exports.r =(a=>(a[a.Bool=0]="Bool",a[a.U8=1]="U8",a[a.U64=2]="U64",a[a.U128=3]="U128",a[a.Address=4]="Address",a[a.Signer=5]="Signer",a[a.Vector=6]="Vector",a[a.Struct=7]="Struct",a[a.U16=8]="U16",a[a.U32=9]="U32",a[a.U256=10]="U256",a[a.Reference=254]="Reference",a[a.Generic=255]="Generic",a))(W||{}),v= exports.s =(p=>(p[p.U8=0]="U8",p[p.U64=1]="U64",p[p.U128=2]="U128",p[p.Address=3]="Address",p[p.U8Vector=4]="U8Vector",p[p.Bool=5]="Bool",p[p.U16=6]="U16",p[p.U32=7]="U32",p[p.U256=8]="U256",p[p.Serialized=9]="Serialized",p))(v||{}),z= exports.t =(n=>(n[n.Script=0]="Script",n[n.EntryFunction=2]="EntryFunction",n[n.Multisig=3]="Multisig",n))(z||{}),D= exports.u =(t=>(t[t.MultiAgentTransaction=0]="MultiAgentTransaction",t[t.FeePayerTransaction=1]="FeePayerTransaction",t))(D||{}),F= exports.v =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.MultiAgent=2]="MultiAgent",i[i.FeePayer=3]="FeePayer",i[i.SingleSender=4]="SingleSender",i))(F||{}),G= exports.w =(u=>(u[u.Ed25519=0]="Ed25519",u[u.MultiEd25519=1]="MultiEd25519",u[u.SingleKey=2]="SingleKey",u[u.MultiKey=3]="MultiKey",u[u.NoAccountAuthenticator=4]="NoAccountAuthenticator",u[u.Abstraction=5]="Abstraction",u))(G||{}),P= exports.x =(t=>(t.Ed25519="ed25519",t.Secp256k1="secp256k1",t))(P||{}),L= exports.y =(s=>(s[s.Ed25519=0]="Ed25519",s[s.Secp256k1=1]="Secp256k1",s[s.Keyless=3]="Keyless",s[s.FederatedKeyless=4]="FederatedKeyless",s))(L||{}),$= exports.z =(n=>(n[n.Ed25519=0]="Ed25519",n[n.Secp256k1=1]="Secp256k1",n[n.Keyless=3]="Keyless",n))($||{}),q= exports.A =(e=>(e[e.Ed25519=0]="Ed25519",e))(q||{}),X= exports.B =(e=>(e[e.Ed25519=0]="Ed25519",e))(X||{}),Y= exports.C =(e=>(e[e.ZkProof=0]="ZkProof",e))(Y||{}),Z= exports.D =(e=>(e[e.Groth16=0]="Groth16",e))(Z||{}),Q= exports.E =(d=>(d.Pending="pending_transaction",d.User="user_transaction",d.Genesis="genesis_transaction",d.BlockMetadata="block_metadata_transaction",d.StateCheckpoint="state_checkpoint_transaction",d.Validator="validator_transaction",d.BlockEpilogue="block_epilogue_transaction",d))(Q||{});function fe(r){return r.type==="pending_transaction"}function xe(r){return r.type==="user_transaction"}function me(r){return r.type==="genesis_transaction"}function be(r){return r.type==="block_metadata_transaction"}function Re(r){return r.type==="state_checkpoint_transaction"}function Se(r){return r.type==="validator_transaction"}function Ue(r){return r.type==="block_epilogue_transaction"}function Te(r){return"signature"in r&&r.signature==="ed25519_signature"}function ve(r){return"signature"in r&&r.signature==="secp256k1_ecdsa_signature"}function Ae(r){return r.type==="multi_agent_signature"}function Ie(r){return r.type==="fee_payer_signature"}function Me(r){return r.type==="multi_ed25519_signature"}var j=(n=>(n.PRIVATE="private",n.PUBLIC="public",n.FRIEND="friend",n))(j||{}),K= exports.S =(s=>(s.STORE="store",s.DROP="drop",s.KEY="key",s.COPY="copy",s))(K||{}),J= exports.T =(t=>(t.VALIDATOR="validator",t.FULL_NODE="full_node",t))(J||{}),V= exports.U =(s=>(s[s.Ed25519=0]="Ed25519",s[s.MultiEd25519=1]="MultiEd25519",s[s.SingleKey=2]="SingleKey",s[s.MultiKey=3]="MultiKey",s))(V||{}),ee= exports.V =(t=>(t[t.Ed25519=0]="Ed25519",t[t.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",t))(ee||{}),te= exports.W =(i=>(i[i.DeriveAuid=251]="DeriveAuid",i[i.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",i[i.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",i[i.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",i[i.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",i))(te||{});var _scriptcomposerpack = require('@aptos-labs/script-composer-pack');var ne=(l=>(l.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",l.INVALID_HEX_CHARS="invalid_hex_chars",l.TOO_SHORT="too_short",l.TOO_LONG="too_long",l.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",l.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",l.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",l.INVALID_PADDING_STRICTNESS="INVALID_PADDING_STRICTNESS",l))(ne||{}),o=class o extends x{constructor(e){if(super(),e.length!==o.LENGTH)throw new g("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=e}isSpecial(){return this.data.slice(0,this.data.length-1).every(e=>e===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let e=_utils.bytesToHex.call(void 0, this.data);return this.isSpecial()&&(e=e[e.length-1]),e}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toUint8Array(){return this.data}serialize(e){e.serializeFixedBytes(this.data)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(3),e.serialize(this)}static deserialize(e){let t=e.deserializeFixedBytes(o.LENGTH);return new o(t)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new g("Hex string must start with a leading 0x.","leading_zero_x_required");let t=o.fromString(e);if(e.length!==o.LONG_STRING_LENGTH+2)if(t.isSpecial()){if(e.length!==3)throw new g(`The given hex string ${e} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,"INVALID_PADDING_ZEROES")}else throw new g(`The given hex string ${e} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return t}static fromString(e,{maxMissingChars:t=4}={}){let n=e;if(e.startsWith("0x")&&(n=e.slice(2)),n.length===0)throw new g("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(n.length>64)throw new g("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");if(t>63||t<0)throw new g(`maxMissingChars must be between or equal to 0 and 63. Received ${t}`,"INVALID_PADDING_STRICTNESS");let s;try{s=_utils.hexToBytes.call(void 0, n.padStart(64,"0"))}catch(u){throw new g(`Hex characters are invalid: ${_optionalChain([u, 'optionalAccess', _5 => _5.message])}`,"invalid_hex_chars")}let i=new o(s);if(n.length<64-t&&!i.isSpecial())throw new g(`Hex string is too short, must be ${64-t} to 64 chars long, excluding the leading 0x. You may need to fix
2
- the addresss by padding it with 0s before passing it to \`fromString\` (e.g. <addressString>.padStart(64, '0')).
3
- Received ${e}`,"too_short");return i}static from(e,{maxMissingChars:t=4}={}){return typeof e=="string"?o.fromString(e,{maxMissingChars:t}):e instanceof Uint8Array?new o(e):e}static fromStrict(e){return typeof e=="string"?o.fromStringStrict(e):e instanceof Uint8Array?new o(e):e}static isValid(e){try{return e.strict?o.fromStrict(e.input):o.from(e.input),{valid:!0}}catch(t){return{valid:!1,invalidReason:_optionalChain([t, 'optionalAccess', _6 => _6.invalidReason]),invalidReasonMessage:_optionalChain([t, 'optionalAccess', _7 => _7.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((t,n)=>t===e.data[n])}};o.LENGTH=32,o.LONG_STRING_LENGTH=64,o.ZERO=o.from("0x0"),o.ONE=o.from("0x1"),o.TWO=o.from("0x2"),o.THREE=o.from("0x3"),o.FOUR=o.from("0x4"),o.A=o.from("0xA");var m=o;var _jsbase64 = require('js-base64');async function qe(r){return new Promise(e=>{setTimeout(e,r)})}function Xe(r){return r instanceof Error?r.message:String(r)}var Ye=()=>Math.floor(Date.now()/1e3);function Ze(r){let e=new Date(r*1e3);return e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),Math.floor(e.getTime()/1e3)}function Qe(r){let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e+"==".substring(0,(3-e.length%3)%3);return _jsbase64.decode.call(void 0, t)}function je(r){let e=r.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4!==0;)e+="=";return new Uint8Array(Buffer.from(e,"base64"))}var Ke=(r,e)=>r*10**e,Je= exports.fa =(r,e)=>r/10**e,I=r=>{let e="";for(let t=2;t<r.length;t+=2)e+=String.fromCharCode(parseInt(r.substring(t,t+2),16));return e},Ve= exports.ga =r=>{let{account_address:e,module_name:t,struct_name:n}=r,s=I(t),i=I(n);return`${e}::${s}::${i}`},et= exports.ha =r=>typeof r=="object"&&!Array.isArray(r)&&r!==null&&"account_address"in r&&"module_name"in r&&"struct_name"in r&&typeof r.account_address=="string"&&typeof r.module_name=="string"&&typeof r.struct_name=="string";function tt(r){let e=r.split("::");if(e.length!==3)throw new Error(`Invalid function ${r}`);let t=e[0],n=e[1],s=e[2];return{moduleAddress:t,moduleName:n,functionName:s}}function rt(r){let e=r.split("::");return e.length===3&&m.isValid({input:e[0]}).valid}function nt(r,e=6,t=5){return`${r.slice(0,e)}...${r.slice(-t)}`}exports.a = y; exports.b = S; exports.c = U; exports.d = f; exports.e = b; exports.f = R; exports.g = T; exports.h = g; exports.i = k; exports.j = _; exports.k = ge; exports.l = x; exports.m = c; exports.n = C; exports.o = w; exports.p = H; exports.q = O; exports.r = W; exports.s = v; exports.t = z; exports.u = D; exports.v = F; exports.w = G; exports.x = P; exports.y = L; exports.z = $; exports.A = q; exports.B = X; exports.C = Y; exports.D = Z; exports.E = Q; exports.F = fe; exports.G = xe; exports.H = me; exports.I = be; exports.J = Re; exports.K = Se; exports.L = Ue; exports.M = Te; exports.N = ve; exports.O = Ae; exports.P = Ie; exports.Q = Me; exports.R = j; exports.S = K; exports.T = J; exports.U = V; exports.V = ee; exports.W = te; exports.X = _scriptcomposerpack.CallArgument; exports.Y = ne; exports.Z = m; exports._ = qe; exports.$ = Xe; exports.aa = Ye; exports.ba = Ze; exports.ca = Qe; exports.da = je; exports.ea = Ke; exports.fa = Je; exports.ga = Ve; exports.ha = et; exports.ia = tt; exports.ja = rt; exports.ka = nt;
4
- //# sourceMappingURL=chunk-5GUWOXQG.js.map
@@ -1,2 +0,0 @@
1
- import{c as u,d as f}from"./chunk-3EUHEZND.mjs";async function p(e){let{aptosConfig:t,overrides:s,params:n,contentType:o,acceptType:r,path:i,originMethod:a,type:d}=e,R=t.getRequestUrl(d);return u({url:R,method:"GET",originMethod:a,path:i,contentType:o,acceptType:r,params:n,overrides:{...t.clientConfig,...s}},t,e.type)}async function c(e){let{aptosConfig:t,overrides:s,params:n,contentType:o,acceptType:r,path:i,originMethod:a,type:d}=e,R=t.getRequestUrl(d);return f({url:R,method:"GET",originMethod:a,path:i,contentType:o,acceptType:r,params:n,overrides:{...t.clientConfig,...s}},t,e.type)}async function m(e){let{aptosConfig:t}=e;return p({...e,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...e.overrides,HEADERS:{...t.clientConfig?.HEADERS,...t.fullnodeConfig?.HEADERS}}})}async function q(e){let{aptosConfig:t}=e;return c({...e,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...e.overrides,HEADERS:{...t.clientConfig?.HEADERS,...t.fullnodeConfig?.HEADERS}}})}async function A(e){return p({...e,type:"Pepper"})}async function h(e){let t=[],s,n=e.params;do{let o=await p({type:"Fullnode",aptosConfig:e.aptosConfig,originMethod:e.originMethod,path:e.path,params:n,overrides:e.overrides});s=o.headers["x-aptos-cursor"],delete o.headers,t.push(...o.data),n.start=s}while(s!=null);return t}async function C(e){let t=[],s,n=e.params,o=n.limit;do{let r=await p({type:"Fullnode",aptosConfig:e.aptosConfig,originMethod:e.originMethod,path:e.path,params:n,overrides:e.overrides});if(s=r.headers["x-aptos-cursor"],delete r.headers,t.push(...r.data),n.offset=s,o!==void 0){let i=o-t.length;if(i<=0)break;n.limit=i}}while(s!=null);return t}export{p as a,c as b,m as c,q as d,A as e,h as f,C as g};
2
- //# sourceMappingURL=chunk-3RVAGHAA.mjs.map
@@ -1,4 +0,0 @@
1
- import{a as d}from"./chunk-RXHER6EA.mjs";import{a as i}from"./chunk-IF4UU2MT.mjs";import{bytesToHex as c,hexToBytes as h}from"@noble/hashes/utils";var u=(s=>(s.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",s.INVALID_HEX_CHARS="invalid_hex_chars",s.TOO_SHORT="too_short",s.TOO_LONG="too_long",s.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",s.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",s.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",s.INVALID_PADDING_STRICTNESS="INVALID_PADDING_STRICTNESS",s))(u||{}),e=class e extends d{constructor(t){if(super(),t.length!==e.LENGTH)throw new i("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=t}isSpecial(){return this.data.slice(0,this.data.length-1).every(t=>t===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let t=c(this.data);return this.isSpecial()&&(t=t[t.length-1]),t}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return c(this.data)}toUint8Array(){return this.data}serialize(t){t.serializeFixedBytes(this.data)}serializeForEntryFunction(t){let r=this.bcsToBytes();t.serializeBytes(r)}serializeForScriptFunction(t){t.serializeU32AsUleb128(3),t.serialize(this)}static deserialize(t){let r=t.deserializeFixedBytes(e.LENGTH);return new e(r)}static fromStringStrict(t){if(!t.startsWith("0x"))throw new i("Hex string must start with a leading 0x.","leading_zero_x_required");let r=e.fromString(t);if(t.length!==e.LONG_STRING_LENGTH+2)if(r.isSpecial()){if(t.length!==3)throw new i(`The given hex string ${t} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,"INVALID_PADDING_ZEROES")}else throw new i(`The given hex string ${t} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return r}static fromString(t,{maxMissingChars:r=4}={}){let n=t;if(t.startsWith("0x")&&(n=t.slice(2)),n.length===0)throw new i("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(n.length>64)throw new i("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");if(r>63||r<0)throw new i(`maxMissingChars must be between or equal to 0 and 63. Received ${r}`,"INVALID_PADDING_STRICTNESS");let a;try{a=h(n.padStart(64,"0"))}catch(g){throw new i(`Hex characters are invalid: ${g?.message}`,"invalid_hex_chars")}let o=new e(a);if(n.length<64-r&&!o.isSpecial())throw new i(`Hex string is too short, must be ${64-r} to 64 chars long, excluding the leading 0x. You may need to fix
2
- the addresss by padding it with 0s before passing it to \`fromString\` (e.g. <addressString>.padStart(64, '0')).
3
- Received ${t}`,"too_short");return o}static from(t,{maxMissingChars:r=4}={}){return typeof t=="string"?e.fromString(t,{maxMissingChars:r}):t instanceof Uint8Array?new e(t):t}static fromStrict(t){return typeof t=="string"?e.fromStringStrict(t):t instanceof Uint8Array?new e(t):t}static isValid(t){try{return t.strict?e.fromStrict(t.input):e.from(t.input),{valid:!0}}catch(r){return{valid:!1,invalidReason:r?.invalidReason,invalidReasonMessage:r?.message}}}equals(t){return this.data.length!==t.data.length?!1:this.data.every((r,n)=>r===t.data[n])}};e.LENGTH=32,e.LONG_STRING_LENGTH=64,e.ZERO=e.from("0x0"),e.ONE=e.from("0x1"),e.TWO=e.from("0x2"),e.THREE=e.from("0x3"),e.FOUR=e.from("0x4"),e.A=e.from("0xA");var l=e;export{u as a,l as b};
4
- //# sourceMappingURL=chunk-LQOSHBB7.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/accountAddress.ts"],"sourcesContent":["// 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 * 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"],"mappings":"kFAGA,OAAS,cAAAA,EAAY,cAAAC,MAAkB,sBAYhC,IAAKC,OACVA,EAAA,0BAA4B,4BAC5BA,EAAA,kBAAoB,oBACpBA,EAAA,UAAY,YACZA,EAAA,SAAW,WACXA,EAAA,wBAA0B,0BAC1BA,EAAA,kCAAoC,oCACpCA,EAAA,uBAAyB,yBACzBA,EAAA,2BAA6B,6BARnBA,OAAA,IAoCCC,EAAN,MAAMA,UAAuBC,CAA4C,CA4C9E,YAAYC,EAAmB,CAE7B,GADA,MAAM,EACFA,EAAM,SAAWF,EAAe,OAClC,MAAM,IAAIG,EACR,sDACA,2BACF,EAEF,KAAK,KAAOD,CACd,CAcA,WAAqB,CACnB,OACE,KAAK,KAAK,MAAM,EAAG,KAAK,KAAK,OAAS,CAAC,EAAE,MAAOE,GAASA,IAAS,CAAC,GAAK,KAAK,KAAK,KAAK,KAAK,OAAS,CAAC,EAAI,EAE9G,CAeA,UAA0B,CACxB,MAAO,KAAK,KAAK,sBAAsB,CAAC,EAC1C,CAWA,uBAAgC,CAC9B,IAAIC,EAAMC,EAAW,KAAK,IAAI,EAC9B,OAAI,KAAK,UAAU,IACjBD,EAAMA,EAAIA,EAAI,OAAS,CAAC,GAEnBA,CACT,CAWA,cAA8B,CAC5B,MAAO,KAAK,KAAK,0BAA0B,CAAC,EAC9C,CAYA,2BAAoC,CAClC,OAAOC,EAAW,KAAK,IAAI,CAC7B,CAUA,cAA2B,CACzB,OAAO,KAAK,IACd,CAeA,UAAUC,EAA8B,CACtCA,EAAW,oBAAoB,KAAK,IAAI,CAC1C,CAUA,0BAA0BA,EAA8B,CACtD,IAAMC,EAAW,KAAK,WAAW,EACjCD,EAAW,eAAeC,CAAQ,CACpC,CAUA,2BAA2BD,EAA8B,CACvDA,EAAW,uBAA+D,EAC1EA,EAAW,UAAU,IAAI,CAC3B,CAeA,OAAO,YAAYE,EAA4C,CAC7D,IAAMC,EAAQD,EAAa,sBAAsBT,EAAe,MAAM,EACtE,OAAO,IAAIA,EAAeU,CAAK,CACjC,CAyCA,OAAO,iBAAiBR,EAA+B,CAErD,GAAI,CAACA,EAAM,WAAW,IAAI,EACxB,MAAM,IAAIC,EAAa,2CAA4C,yBAA4C,EAGjH,IAAMQ,EAAUX,EAAe,WAAWE,CAAK,EAI/C,GAAIA,EAAM,SAAWF,EAAe,mBAAqB,EACvD,GAAKW,EAAQ,UAAU,GAKhB,GAAIT,EAAM,SAAW,EAE1B,MAAM,IAAIC,EAER,wBAAwBD,CAAK,wFAC7B,wBACF,MAVA,OAAM,IAAIC,EACR,wBAAwBD,CAAK,sEAC7B,mCACF,EAWJ,OAAOS,CACT,CAgCA,OAAO,WAAWT,EAAe,CAAE,gBAAAU,EAAkB,CAAE,EAAkC,CAAC,EAAmB,CAC3G,IAAIC,EAAcX,EAOlB,GALIA,EAAM,WAAW,IAAI,IACvBW,EAAcX,EAAM,MAAM,CAAC,GAIzBW,EAAY,SAAW,EACzB,MAAM,IAAIV,EACR,iFACA,WACF,EAIF,GAAIU,EAAY,OAAS,GACvB,MAAM,IAAIV,EACR,gFACA,UACF,EAIF,GAAIS,EAAkB,IAAMA,EAAkB,EAC5C,MAAM,IAAIT,EACR,kEAAkES,CAAe,GACjF,4BACF,EAGF,IAAIE,EACJ,GAAI,CAIFA,EAAeC,EAAWF,EAAY,SAAS,GAAI,GAAG,CAAC,CACzD,OAASG,EAAY,CAGnB,MAAM,IAAIb,EAAa,+BAA+Ba,GAAO,OAAO,GAAI,mBAAsC,CAChH,CAEA,IAAML,EAAU,IAAIX,EAAec,CAAY,EAG/C,GAAID,EAAY,OAAS,GAAKD,GACxB,CAACD,EAAQ,UAAU,EACrB,MAAM,IAAIR,EACR,oCAAoC,GAAKS,CAAe;AAAA;AAAA,WAEvDV,CAAK,GACN,WACF,EAIJ,OAAOS,CACT,CAaA,OAAO,KAAKT,EAA4B,CAAE,gBAAAU,EAAkB,CAAE,EAAkC,CAAC,EAAmB,CAClH,OAAI,OAAOV,GAAU,SACZF,EAAe,WAAWE,EAAO,CAAE,gBAAAU,CAAgB,CAAC,EAEzDV,aAAiB,WACZ,IAAIF,EAAeE,CAAK,EAE1BA,CACT,CASA,OAAO,WAAWA,EAA4C,CAC5D,OAAI,OAAOA,GAAU,SACZF,EAAe,iBAAiBE,CAAK,EAE1CA,aAAiB,WACZ,IAAIF,EAAeE,CAAK,EAE1BA,CACT,CAiBA,OAAO,QAAQe,EAA6F,CAC1G,GAAI,CACF,OAAIA,EAAK,OACPjB,EAAe,WAAWiB,EAAK,KAAK,EAEpCjB,EAAe,KAAKiB,EAAK,KAAK,EAEzB,CAAE,MAAO,EAAK,CACvB,OAASD,EAAY,CACnB,MAAO,CACL,MAAO,GACP,cAAeA,GAAO,cACtB,qBAAsBA,GAAO,OAC/B,CACF,CACF,CAUA,OAAOE,EAAgC,CACrC,OAAI,KAAK,KAAK,SAAWA,EAAM,KAAK,OAAe,GAC5C,KAAK,KAAK,MAAM,CAACC,EAAOC,IAAUD,IAAUD,EAAM,KAAKE,CAAK,CAAC,CACtE,CACF,EA/bapB,EAaK,OAAiB,GAbtBA,EAoBK,mBAA6B,GApBlCA,EAsBJ,KAAuBA,EAAe,KAAK,KAAK,EAtB5CA,EAwBJ,IAAsBA,EAAe,KAAK,KAAK,EAxB3CA,EA0BJ,IAAsBA,EAAe,KAAK,KAAK,EA1B3CA,EA4BJ,MAAwBA,EAAe,KAAK,KAAK,EA5B7CA,EA8BJ,KAAuBA,EAAe,KAAK,KAAK,EA9B5CA,EAgCJ,EAAoBA,EAAe,KAAK,KAAK,EAhC/C,IAAMqB,EAANrB","names":["bytesToHex","hexToBytes","AddressInvalidReason","_AccountAddress","Serializable","input","ParsingError","byte","hex","bytesToHex","serializer","bcsBytes","deserializer","bytes","address","maxMissingChars","parsedInput","addressBytes","hexToBytes","error","args","other","value","index","AccountAddress"]}
@@ -1,4 +0,0 @@
1
- import{a as zi,b as Fn,c as Ni}from"./chunk-TNWABITK.mjs";import{a as bi}from"./chunk-AEGA5N2W.mjs";import{a as Un,b as lr}from"./chunk-A5L76YP7.mjs";import{a as vn}from"./chunk-LS3IDL2N.mjs";import{a as _}from"./chunk-PDAWVDI7.mjs";import{a as _t,b as nt,c as ar}from"./chunk-MIW45ADL.mjs";import{a as be,b as Kn,c as Ct,d as ir,e as Et}from"./chunk-GOXRBEIJ.mjs";import{a as Xr}from"./chunk-2V636AYW.mjs";import{a as En}from"./chunk-AIPHJFJL.mjs";import{a as rr,b as Yr}from"./chunk-TBY3VMMV.mjs";import{a as Kt,b as We}from"./chunk-7YTGBTWH.mjs";import{b as R,c as $,d as B}from"./chunk-6KE4JZD6.mjs";import{b as $e}from"./chunk-LGC2JORV.mjs";import{a as we}from"./chunk-A3VO773Q.mjs";import{a as dr,b as pr}from"./chunk-W4BSN6SK.mjs";import{a as Z}from"./chunk-TTY5GFMN.mjs";import{a as gr}from"./chunk-XLDMPCLF.mjs";import{a as Mi}from"./chunk-KXVD52Y6.mjs";import{a as h}from"./chunk-EODSU3YN.mjs";import{a as Vi,b as kn,c as Hi,d as Li,e as qi,g as je,h as $i,k as Wi,l as ji}from"./chunk-RXMLONF7.mjs";import{a as It}from"./chunk-YOZBVVKL.mjs";import{a as _n,b as Oi,c as w,e as Gi,f as Bi}from"./chunk-PSZYS4RG.mjs";import{A as Ri,d as Ti,e as Si,f as Pi,g as xi,i as Ki,j as Ci,k as Ei,m as vi,n as Ii,o as _i,p as Fi,q as ki,r as Ui,s as Ft,t as cr,u as In,y as Di,z as ur}from"./chunk-VHNX2NUR.mjs";import{c as vt,d as Ai,f as fi,g as hi,h as wi}from"./chunk-CWL7ZA3P.mjs";import{c as tt,f as mi,g as yi}from"./chunk-3RVAGHAA.mjs";import{a as si}from"./chunk-BMPHQ3E7.mjs";import{d as P,e as gi}from"./chunk-WB26DWOY.mjs";import{a as S,b as Zr,c as I,d as J}from"./chunk-HHWJHOFZ.mjs";import{a as G,b as fe,c as Tt,d as St,e as he,f as Pt,g as xt}from"./chunk-TKXEVD7A.mjs";import{a as Jr}from"./chunk-ERLDXTIY.mjs";import{a as wt}from"./chunk-RIINVEZA.mjs";import{a as q}from"./chunk-ZD2TY5N3.mjs";import{a as Qt,b as ai,c as ve,d as ci,e as ui,f as di,i as pi,j as li,k as Y,l as Cn}from"./chunk-ZELTLAUN.mjs";import{b as u}from"./chunk-LQOSHBB7.mjs";import{a as bt}from"./chunk-3OLFJ65O.mjs";import{E as Q}from"./chunk-R6QCPXQG.mjs";import{a as T,b as ne}from"./chunk-RXHER6EA.mjs";import{b,c as Qr}from"./chunk-VHY6ZATX.mjs";import{d as jr}from"./chunk-56CNRT2K.mjs";import{a as Qi}from"./chunk-KSLLV3ZC.mjs";import{g as or}from"./chunk-4RXKALLC.mjs";import{b as ei,c as ti,d as ni,e as Ee,f as ri,g as ii,h as sr,j as oi}from"./chunk-RJ7F4JDV.mjs";import{a as ht}from"./chunk-KDMSOCZY.mjs";import{jwtDecode as Ms}from"jwt-decode";import{sha3_256 as $a}from"@noble/hashes/sha3";import{bn254 as Ae}from"@noble/curves/bn254";import{bytesToNumberBE as Wa}from"@noble/curves/abstract/utils";var W=class n extends $e{constructor(e,t){super(),this.jwkAddress=u.from(e),this.keylessPublicKey=t}authKey(){let e=new ne;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),Z.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){return Ar({...e,publicKey:this})}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(e){let t=u.deserialize(e),r=v.deserialize(e);return new n(t,r)}static isPublicKey(e){return e instanceof n}async verifySignatureAsync(e){return yr({...e,publicKey:this})}static create(e){return new n(e.jwkAddress,v.create(e))}static fromJwtAndPepper(e){return new n(e.jwkAddress,v.fromJwtAndPepper(e))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof u&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof v}};import{encode as ja}from"js-base64";var F=class n extends $e{constructor(e){if(super(),this.publicKey=e,e instanceof R)this.variant=0;else if(e instanceof _t)this.variant=1;else if(e instanceof v)this.variant=3;else if(e instanceof W)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:r}=e;return this.publicKey.verifySignature({message:t,signature:r.signature})}async verifySignatureAsync(e){return await this.publicKey.verifySignatureAsync({...e,signature:e.signature.signature})}authKey(){return Z.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=R.deserialize(e);break;case 1:r=_t.deserialize(e);break;case 3:r=v.deserialize(e);break;case 4:r=W.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${t}`)}return new n(r)}static isPublicKey(e){return e instanceof n}isEd25519(){return this.publicKey instanceof R}isSecp256k1PublicKey(){return this.publicKey instanceof _t}static isInstance(e){return"publicKey"in e&&"variant"in e}},z=class n extends we{constructor(e){if(super(),this.signature=e,e instanceof B)this.variant=0;else if(e instanceof ar)this.variant=1;else if(e instanceof Te)this.variant=3;else throw new Error("Unsupported signature type")}toUint8Array(){return console.warn("[Aptos SDK] Calls to AnySignature.toUint8Array() will soon return the underlying signature bytes. Use AnySignature.bcsToBytes() instead."),this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=B.deserialize(e);break;case 1:r=ar.deserialize(e);break;case 3:r=Te.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${t}`)}return new n(r)}static isInstance(e){return"signature"in e&&typeof e.signature=="object"&&e.signature!==null&&"toUint8Array"in e.signature}};function Vs(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var Jt=class extends $e{constructor(e){super(),this.publicKeys=e.publicKeys}createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(a+1>this.publicKeys.length)throw new Error(`Signature index ${a+1} is out of public keys range, ${this.publicKeys.length}.`);if(o.has(s))throw new Error(`Duplicate bit ${s} detected.`);o.add(s);let c=Math.floor(s/8),d=i[c];d|=r>>s%8,i[c]=d}),i}getIndex(e){let t=this.publicKeys.findIndex(r=>r.toString()===e.toString());if(t!==-1)return t;throw new Error(`Public key ${e} not found in multi key set ${this.publicKeys}`)}},Se=class n extends Jt{constructor(e){let{publicKeys:t,signaturesRequired:r}=e;if(super({publicKeys:t}),r<1)throw new Error("The number of required signatures needs to be greater than 0");if(t.length<r)throw new Error(`Provided ${t.length} public keys is smaller than the ${r} required signatures`);this.publicKeys=t.map(i=>i instanceof F?i:new F(i)),this.signaturesRequired=r}verifySignature(e){let{message:t,signature:r}=e;if(r.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");let i=r.bitMapToSignerIndices();for(let o=0;o<r.signatures.length;o+=1){let s=r.signatures[o];if(!this.publicKeys[i[o]].verifySignature({message:t,signature:s}))return!1}return!0}async verifySignatureAsync(e){let{message:t,signature:r,aptosConfig:i}=e;if(r.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");let o=r.bitMapToSignerIndices();for(let s=0;s<r.signatures.length;s+=1){let a=r.signatures[s];if(!await this.publicKeys[o[s]].verifySignatureAsync({aptosConfig:i,message:t,signature:a}))return!1}return!0}authKey(){return Z.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector(F),r=e.deserializeU8();return new n({publicKeys:t,signaturesRequired:r})}getIndex(e){let t=e instanceof F?e:new F(e);return super.getIndex(t)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},re=class re extends we{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>re.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${re.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(o=>o instanceof z?o:new z(o)),!(r instanceof Uint8Array))this.bitmap=re.createBitmap({bits:r});else{if(r.length!==re.BITMAP_LEN)throw new Error(`"bitmap" length should be ${re.BITMAP_LEN}`);this.bitmap=r}let i=this.bitmap.reduce((o,s)=>o+Vs(s),0);if(i!==this.signatures.length)throw new Error(`Expecting ${i} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach(s=>{if(s>=re.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${re.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");o.add(s);let a=Math.floor(s/8),c=i[a];c|=r>>s%8,i[a]=c}),i}bitMapToSignerIndices(){let e=[];for(let t=0;t<this.bitmap.length;t+=1){let r=this.bitmap[t];for(let i=0;i<8;i+=1)r&128>>i&&e.push(t*8+i)}return e}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let t=e.deserializeVector(z),r=e.deserializeBytes();return new re({signatures:t,bitmap:r})}};re.BITMAP_LEN=4,re.MAX_SIGNATURES_SUPPORTED=re.BITMAP_LEN*8;var Ie=re;var ue=class ue extends Jt{constructor(e){let{publicKeys:t,threshold:r}=e;if(super({publicKeys:t}),t.length>ue.MAX_KEYS||t.length<ue.MIN_KEYS)throw new Error(`Must have between ${ue.MIN_KEYS} and ${ue.MAX_KEYS} public keys, inclusive`);if(r<ue.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${ue.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=r}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof _e))return!1;let i=[];for(let o=0;o<4;o+=1)for(let s=0;s<8;s+=1)if((r.bitmap[o]&1<<7-s)!==0){let c=o*8+s;i.push(c)}if(i.length!==r.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(i.length<this.threshold)throw new Error("Not enough signatures");for(let o=0;o<i.length;o+=1)if(!this.publicKeys[i[o]].verifySignature({message:t,signature:r.signatures[o]}))return!1;return!0}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return Z.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*R.LENGTH+1);return this.publicKeys.forEach((t,r)=>{e.set(t.toUint8Array(),r*R.LENGTH)}),e[this.publicKeys.length*R.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t[t.length-1],i=[];for(let o=0;o<t.length-1;o+=R.LENGTH){let s=o;i.push(new R(t.subarray(s,s+R.LENGTH)))}return new ue({publicKeys:i,threshold:r})}getIndex(e){return super.getIndex(e)}};ue.MAX_KEYS=32,ue.MIN_KEYS=2,ue.MIN_THRESHOLD=1;var kt=ue,ie=class ie extends we{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>ie.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${ie.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=ie.createBitmap({bits:r});else{if(r.length!==ie.BITMAP_LEN)throw new Error(`"bitmap" length should be ${ie.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*B.LENGTH+ie.BITMAP_LEN);return this.signatures.forEach((t,r)=>{e.set(t.toUint8Array(),r*B.LENGTH)}),e.set(this.bitmap,this.signatures.length*B.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t.subarray(t.length-4),i=[];for(let o=0;o<t.length-r.length;o+=B.LENGTH){let s=o;i.push(new B(t.subarray(s,s+B.LENGTH)))}return new ie({signatures:i,bitmap:r})}static createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(s>=ie.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${ie.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");if(a>0&&s<=t[a-1])throw new Error("The bits need to be sorted in ascending order.");o.add(s);let c=Math.floor(s/8),d=i[c];d|=r>>s%8,i[c]=d}),i}};ie.MAX_SIGNATURES_SUPPORTED=32,ie.BITMAP_LEN=4;var _e=ie;var V=class extends T{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return ge.load(e);case 1:return Fe.load(e);case 2:return X.load(e);case 3:return Pe.load(e);case 4:return Ut.load(e);case 5:return Zt.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof ge}isMultiEd25519(){return this instanceof Fe}isSingleKey(){return this instanceof X}isMultiKey(){return this instanceof Pe}},ge=class n extends V{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=R.deserialize(e),r=B.deserialize(e);return new n(t,r)}},Fe=class n extends V{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=kt.deserialize(e),r=_e.deserialize(e);return new n(t,r)}},X=class n extends V{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=F.deserialize(e),r=z.deserialize(e);return new n(t,r)}},Pe=class n extends V{constructor(e,t){super(),this.public_keys=e,this.signatures=t}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),this.signatures.serialize(e)}static load(e){let t=Se.deserialize(e),r=Ie.deserialize(e);return new n(t,r)}},Ut=class n extends V{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},Zt=class n extends V{constructor(e,t,r){if(super(),!Cn(e))throw new Error(`Invalid function info ${e} passed into AccountAuthenticatorAbstraction`);this.functionInfo=e,this.authenticator=b.fromHexInput(r),this.signingMessageDigest=b.fromHexInput(b.fromHexInput(t).toUint8Array())}serialize(e){e.serializeU32AsUleb128(5);let{moduleAddress:t,moduleName:r,functionName:i}=Y(this.functionInfo);u.fromString(t).serialize(e),e.serializeStr(r),e.serializeStr(i),e.serializeU32AsUleb128(0),e.serializeBytes(this.signingMessageDigest.toUint8Array()),e.serializeFixedBytes(this.authenticator.toUint8Array())}static load(e){let t=u.deserialize(e),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeUleb128AsU32();if(o===0){let s=e.deserializeBytes(),a=e.deserializeFixedBytes(e.remaining());return new n(`${t}::${r}::${i}`,s,a)}throw new Error(`Unknown variant index for AccountAuthenticatorAbstraction: ${o}`)}};import{sha3_256 as Ls}from"@noble/hashes/sha3";var Yt=class n extends T{constructor(e,t){super(),this.address=e,this.name=t}static fromStr(e){let t=e.split("::");if(t.length!==2)throw new Error("Invalid module id.");return new n(u.fromString(t[0]),new _(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=u.deserialize(e),r=_.deserialize(e);return new n(t,r)}};var U=class n extends T{deserialize(e){let t=u.deserialize(e),r=_.deserialize(e),i=_.deserialize(e),o=e.deserializeVector(n);return new xe(t,r,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return O.load(e);case 1:return oe.load(e);case 2:return H.load(e);case 3:return De.load(e);case 4:return k.load(e);case 5:return rt.load(e);case 6:return K.load(e);case 7:return m.load(e);case 8:return ke.load(e);case 9:return Ue.load(e);case 10:return Re.load(e);case 255:return D.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof O}isAddress(){return this instanceof k}isGeneric(){return this instanceof D}isSigner(){return this instanceof rt}isVector(){return this instanceof K}isStruct(){return this instanceof m}isU8(){return this instanceof oe}isU16(){return this instanceof ke}isU32(){return this instanceof Ue}isU64(){return this instanceof H}isU128(){return this instanceof De}isU256(){return this instanceof Re}isPrimitive(){return this instanceof rt||this instanceof k||this instanceof O||this instanceof oe||this instanceof ke||this instanceof Ue||this instanceof H||this instanceof De||this instanceof Re}},O=class n extends U{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new n}},oe=class n extends U{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new n}},ke=class n extends U{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new n}},Ue=class n extends U{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new n}},H=class n extends U{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},De=class n extends U{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new n}},Re=class n extends U{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new n}},k=class n extends U{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},rt=class n extends U{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},Dn=class n extends U{constructor(t){super();this.value=t}toString(){return`&${this.value.toString()}`}serialize(t){t.serializeU32AsUleb128(254)}static load(t){let r=U.deserialize(t);return new n(r)}},D=class n extends U{constructor(t){super();this.value=t;if(t<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(t){t.serializeU32AsUleb128(255),t.serializeU32(this.value)}static load(t){let r=t.deserializeU32();return new n(r)}},K=class n extends U{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new oe)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let r=U.deserialize(t);return new n(r)}},m=class n extends U{constructor(t){super();this.value=t}toString(){let t="";return this.value.typeArgs.length>0&&(t=`<${this.value.typeArgs.map(r=>r.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${t}`}serialize(t){t.serializeU32AsUleb128(7),this.value.serialize(t)}static load(t){let r=xe.deserialize(t);return new n(r)}isTypeTag(t,r,i){return this.value.moduleName.identifier===r&&this.value.name.identifier===i&&this.value.address.equals(t)}isString(){return this.isTypeTag(u.ONE,"string","String")}isOption(){return this.isTypeTag(u.ONE,"option","Option")}isObject(){return this.isTypeTag(u.ONE,"object","Object")}isDelegationKey(){return this.isTypeTag(u.ONE,"permissioned_delegation","DelegationKey")}isRateLimiter(){return this.isTypeTag(u.ONE,"rate_limiter","RateLimiter")}},xe=class n extends T{constructor(e,t,r,i){super(),this.address=e,this.moduleName=t,this.name=r,this.typeArgs=i}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let t=u.deserialize(e),r=_.deserialize(e),i=_.deserialize(e),o=e.deserializeVector(U);return new n(t,r,i,o)}};function Qu(){return new xe(u.ONE,new _("aptos_coin"),new _("AptosCoin"),[])}function x(){return new xe(u.ONE,new _("string"),new _("String"),[])}function Ju(n){return new xe(u.ONE,new _("option"),new _("Option"),[n])}function se(n){return new xe(u.ONE,new _("object"),new _("Object"),[n])}function Hs(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return fe.deserialize(n);case 1:return he.deserialize(n);case 2:return Pt.deserialize(n);case 3:return u.deserialize(n);case 4:return S.deserialize(n,fe);case 5:return G.deserialize(n);case 6:return Tt.deserialize(n);case 7:return St.deserialize(n);case 8:return xt.deserialize(n);case 9:return Zr.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var it=class extends T{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return ot.load(e);case 2:return Xt.load(e);case 3:return en.load(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},ot=class n extends it{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=tn.deserialize(e);return new n(t)}},Xt=class n extends it{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=st.deserialize(e);return new n(t)}},en=class n extends it{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=nn.deserialize(e);return new n(t)}},st=class n{constructor(e,t,r,i){this.module_name=e,this.function_name=t,this.type_args=r,this.args=i}static build(e,t,r,i){return new n(Yt.fromStr(e),new _(t),r,i)}serialize(e){this.module_name.serialize(e),this.function_name.serialize(e),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForEntryFunction(e)})}static deserialize(e){let t=Yt.deserialize(e),r=_.deserialize(e),i=e.deserializeVector(U),o=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=e.deserializeUleb128AsU32(),d=Jr.deserialize(e,c);s.push(d)}return new n(t,r,i,s)}},tn=class n{constructor(e,t,r){this.bytecode=e,this.type_args=t,this.args=r}serialize(e){e.serializeBytes(this.bytecode),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForScriptFunction(e)})}static deserialize(e){let t=e.deserializeBytes(),r=e.deserializeVector(U),i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=Hs(e);o.push(a)}return new n(t,r,o)}},nn=class n{constructor(e,t){this.multisig_address=e,this.transaction_payload=t}serialize(e){this.multisig_address.serialize(e),this.transaction_payload===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.transaction_payload.serialize(e))}static deserialize(e){let t=u.deserialize(e),r=e.deserializeBool(),i;return r&&(i=rn.deserialize(e)),new n(t,i)}},rn=class n extends T{constructor(e){super(),this.transaction_payload=e}serialize(e){e.serializeU32AsUleb128(0),this.transaction_payload.serialize(e)}static deserialize(e){return e.deserializeUleb128AsU32(),new n(st.deserialize(e))}};var de=class n extends T{constructor(e,t,r,i,o,s,a){super(),this.sender=e,this.sequence_number=t,this.payload=r,this.max_gas_amount=i,this.gas_unit_price=o,this.expiration_timestamp_secs=s,this.chain_id=a}serialize(e){this.sender.serialize(e),e.serializeU64(this.sequence_number),this.payload.serialize(e),e.serializeU64(this.max_gas_amount),e.serializeU64(this.gas_unit_price),e.serializeU64(this.expiration_timestamp_secs),this.chain_id.serialize(e)}static deserialize(e){let t=u.deserialize(e),r=e.deserializeU64(),i=it.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=vn.deserialize(e);return new n(t,r,i,o,s,a,c)}},Rn=class extends T{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return at.load(e);case 1:return ct.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},at=class n extends Rn{constructor(e,t){super(),this.raw_txn=e,this.secondary_signer_addresses=t}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let t=de.deserialize(e),r=e.deserializeVector(u);return new n(t,r)}},ct=class n extends Rn{constructor(e,t,r){super(),this.raw_txn=e,this.secondary_signer_addresses=t,this.fee_payer_address=r}serialize(e){e.serializeU32AsUleb128(1),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses),this.fee_payer_address.serialize(e)}static load(e){let t=de.deserialize(e),r=e.deserializeVector(u),i=u.deserialize(e);return new n(t,r,i)}};var Oe=class extends T{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return ut.load(e);case 1:return Dt.load(e);case 2:return dt.load(e);case 3:return pt.load(e);case 4:return Qe.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof ut}isMultiEd25519(){return this instanceof Dt}isMultiAgent(){return this instanceof dt}isFeePayer(){return this instanceof pt}isSingleSender(){return this instanceof Qe}},ut=class n extends Oe{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=R.deserialize(e),r=B.deserialize(e);return new n(t,r)}},Dt=class n extends Oe{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=kt.deserialize(e),r=_e.deserialize(e);return new n(t,r)}},dt=class n extends Oe{constructor(e,t,r){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let t=V.deserialize(e),r=e.deserializeVector(u),i=e.deserializeVector(V);return new n(t,r,i)}},pt=class n extends Oe{constructor(e,t,r,i){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r,this.fee_payer=i}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let t=V.deserialize(e),r=e.deserializeVector(u),i=e.deserializeVector(V),o=u.deserialize(e),s=V.deserialize(e),a={address:o,authenticator:s};return new n(t,r,i,a)}},Qe=class n extends Oe{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=V.deserialize(e);return new n(t)}};var Ge=class n extends T{constructor(e,t){super(),this.raw_txn=e,this.authenticator=t}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let t=de.deserialize(e),r=Oe.deserialize(e);return new n(t,r)}};var Rt=class n extends T{constructor(e,t){super(),this.rawTransaction=e,this.feePayerAddress=t}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=de.deserialize(e),r=e.deserializeBool(),i;return r&&(i=u.deserialize(e)),new n(t,i)}};var On=class n extends T{constructor(e,t,r){super(),this.rawTransaction=e,this.feePayerAddress=r,this.secondarySignerAddresses=t}serialize(e){this.rawTransaction.serialize(e),e.serializeVector(this.secondarySignerAddresses),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=de.deserialize(e),r=e.deserializeVector(u),i=e.deserializeBool(),o;return i&&(o=u.deserialize(e)),new n(t,r,o)}};function Gn(n){return n.feePayerAddress?new ct(n.rawTransaction,n.secondarySignerAddresses??[],n.feePayerAddress):n.secondarySignerAddresses?new at(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function Je(n,e){let t=Ls.create();if(!e.startsWith("APTOS::"))throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${e}`);t.update(e);let r=t.digest(),i=n,o=new Uint8Array(r.length+i.length);return o.set(r),o.set(i,r.length),o}function op(n){return Je(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function me(n){let e=Gn(n);return n.feePayerAddress?Je(e.bcsToBytes(),sr):n.secondarySignerAddresses?Je(e.bcsToBytes(),sr):Je(e.bcsToBytes(),ii)}var ee=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let e=$.generate();return new n({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:r}=e,i=$.fromDerivationPath(t,r);return new n({privateKey:i})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){return new ge(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new ge(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(me(e))}};function fr(n){return typeof n=="object"&&n!==null&&"getAnyPublicKey"in n&&typeof n.getAnyPublicKey=="function"}var pe=class n{constructor(e){this.signingScheme=2;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=new F(t.publicKey()),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}getAnyPublicKey(){return this.publicKey}static generate(e={}){let{scheme:t=0}=e,r;switch(t){case 0:r=$.generate();break;case 2:r=nt.generate();break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:r})}static fromDerivationPath(e){let{scheme:t=0,path:r,mnemonic:i}=e,o;switch(t){case 0:o=$.fromDerivationPath(r,i);break;case 2:o=nt.fromDerivationPath(r,i);break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:o})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){return new X(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new X(this.publicKey,this.signTransaction(e))}sign(e){return new z(this.privateKey.sign(e))}signTransaction(e){return this.sign(me(e))}static fromEd25519Account(e){return new n({privateKey:e.privateKey,address:e.accountAddress})}};var Be=class{static generate(e={}){let{scheme:t=0,legacy:r=!0}=e;return t===0&&r?ee.generate():pe.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:i=!0}=e;return t instanceof $&&i?new ee({privateKey:t,address:r}):new pe({privateKey:t,address:r})}static fromPrivateKeyAndAddress(e){return this.fromPrivateKey(e)}static fromDerivationPath(e){let{scheme:t=0,mnemonic:r,path:i,legacy:o=!0}=e;return t===0&&o?ee.fromDerivationPath({mnemonic:r,path:i}):pe.fromDerivationPath({scheme:t,mnemonic:r,path:i})}static authKey(e){let{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}};import{randomBytes as $s}from"@noble/hashes/utils";var Ws=1209600,Ot=class Ot extends T{constructor(e){super();let{privateKey:t,expiryDateSecs:r,blinder:i}=e;this.privateKey=t,this.publicKey=new Kt(t.publicKey()),this.expiryDateSecs=r||ci(ve()+Ws),this.blinder=i!==void 0?b.fromHexInput(i).toUint8Array():js();let o=Kn(this.publicKey.bcsToBytes(),93);o.push(BigInt(this.expiryDateSecs)),o.push(Ct(this.blinder));let s=Et(o);this.nonce=s.toString()}getPublicKey(){return this.publicKey}isExpired(){return Math.floor(Date.now()/1e3)>this.expiryDateSecs}serialize(e){e.serializeU32AsUleb128(this.publicKey.variant),e.serializeBytes(this.privateKey.toUint8Array()),e.serializeU64(this.expiryDateSecs),e.serializeFixedBytes(this.blinder)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=$.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let i=e.deserializeU64(),o=e.deserializeFixedBytes(31);return new Ot({privateKey:r,expiryDateSecs:Number(i),blinder:o})}static fromBytes(e){return Ot.deserialize(new q(e))}static generate(e){let t;switch(e?.scheme){case 0:default:t=$.generate()}return new Ot({privateKey:t,expiryDateSecs:e?.expiryDateSecs})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new We(this.privateKey.sign(e))}};Ot.BLINDER_LENGTH=31;var lt=Ot;function js(){return $s(lt.BLINDER_LENGTH)}import Js from"eventemitter3";import{jwtDecode as Zs}from"jwt-decode";function zn(n){return n!=null&&typeof n.checkKeylessAccountValidity=="function"}var Gt=class Gt extends T{constructor(t){super();this.signingScheme=2;let{address:r,ephemeralKeyPair:i,publicKey:o,uidKey:s,uidVal:a,aud:c,pepper:d,proof:l,proofFetchCallback:y,jwt:p,verificationKeyHash:g}=t;if(this.ephemeralKeyPair=i,this.publicKey=o,this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress(),this.uidKey=s,this.uidVal=a,this.aud=c,this.jwt=p,this.emitter=new Js,this.proofOrPromise=l,l instanceof ae)this.proof=l;else{if(y===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async C=>{await y(C),this.emitter.removeAllListeners()}),this.init(l)}let f=b.fromHexInput(d).toUint8Array();if(f.length!==Gt.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${Gt.PEPPER_LENGTH}`);if(this.pepper=f,g!==void 0){if(b.hexInputToUint8Array(g).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=b.hexInputToUint8Array(g)}}getAnyPublicKey(){return new F(this.publicKey)}async init(t){try{this.proof=await t,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(r){r instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:r.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(t){if(this.accountAddress.serialize(t),t.serializeStr(this.jwt),t.serializeStr(this.uidKey),t.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(t),this.proof===void 0)throw new Error("Cannot serialize - proof undefined");this.proof.serialize(t),t.serializeOption(this.verificationKeyHash,32)}static partialDeserialize(t){let r=u.deserialize(t),i=t.deserializeStr(),o=t.deserializeStr(),s=t.deserializeFixedBytes(31),a=lt.deserialize(t),c=ae.deserialize(t),d=t.deserializeOption("fixedBytes",32);return{address:r,jwt:i,uidKey:o,pepper:s,ephemeralKeyPair:a,proof:c,verificationKeyHash:d}}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(t){let r=new z(this.sign(t)),i=new F(this.publicKey);return new X(i,r)}signTransactionWithAuthenticator(t){let r=new z(this.signTransaction(t)),i=new F(this.publicKey);return new X(i,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(t){if(this.isExpired())throw P.fromErrorType({type:0});if(await this.waitForProofFetch(),this.proof===void 0)throw P.fromErrorType({type:2});let r=Zs(this.jwt,{header:!0});if(r.kid===void 0)throw P.fromErrorType({type:12,details:"checkKeylessAccountValidity failed. JWT is missing 'kid' in header. This should never happen."});if(this.verificationKeyHash!==void 0){let{verificationKey:i}=await zt({aptosConfig:t});if(b.hexInputToString(i.hash())!==b.hexInputToString(this.verificationKeyHash))throw P.fromErrorType({type:4})}else console.warn("[Aptos SDK] The verification key hash was not set. Proof may be invalid if the verification key has rotated.");await Gt.fetchJWK({aptosConfig:t,publicKey:this.publicKey,kid:r.kid})}sign(t){let{expiryDateSecs:r}=this.ephemeralKeyPair;if(this.isExpired())throw P.fromErrorType({type:0});if(this.proof===void 0)throw P.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let i=this.ephemeralKeyPair.getPublicKey(),o=this.ephemeralKeyPair.sign(t);return new Te({jwtHeader:ui(this.jwt.split(".")[0]),ephemeralCertificate:new Bt(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:i,ephemeralSignature:o})}signTransaction(t){if(this.proof===void 0)throw P.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=Gn(t),o=new Bn(r,this.proof.proof).hash();return this.sign(o)}getSigningMessage(t){if(this.proof===void 0)throw P.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=Gn(t);return new Bn(r,this.proof.proof).hash()}verifySignature(t){return this.publicKey.verifySignature(t)}async verifySignatureAsync(t){return this.publicKey.verifySignatureAsync({...t})}static async fetchJWK(t){return hr(t)}};Gt.PEPPER_LENGTH=31;var ce=Gt,Bn=class extends T{constructor(t,r){super();this.domainSeparator="APTOS::TransactionAndProof";this.transaction=t,this.proof=r}serialize(t){t.serializeFixedBytes(this.transaction.bcsToBytes()),t.serializeOption(this.proof)}hash(){return Je(this.bcsToBytes(),this.domainSeparator)}};var Ne=class n extends ce{constructor(e){let t=v.create(e);super({publicKey:t,...e}),this.publicKey=t}serialize(e){super.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=ce.partialDeserialize(e),{iss:d,aud:l,uidVal:y}=ze({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:d,uidKey:s,uidVal:y,aud:l,pepper:a,jwt:o,verificationKeyHash:c})}static fromBytes(e){return n.deserialize(new q(b.hexInputToUint8Array(e)))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,uidKey:a="sub",proofFetchCallback:c,verificationKey:d}=e,{iss:l,aud:y,uidVal:p}=ze({jwt:i,uidKey:a});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:l,uidKey:a,uidVal:p,aud:y,pepper:s,jwt:i,proofFetchCallback:c,verificationKeyHash:d?d.hash():void 0})}};var gt=class n extends ce{constructor(e){let t=W.create(e);super({publicKey:t,...e}),this.publicKey=t,this.audless=e.audless??!1}serialize(e){super.serialize(e),this.publicKey.jwkAddress.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=ce.partialDeserialize(e),d=u.deserialize(e),{iss:l,aud:y,uidVal:p}=ze({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:l,uidKey:s,uidVal:p,aud:y,pepper:a,jwt:o,verificationKeyHash:c,jwkAddress:d})}static fromBytes(e){return n.deserialize(q.fromHex(e))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,jwkAddress:a,uidKey:c="sub",proofFetchCallback:d,verificationKey:l}=e,{iss:y,aud:p,uidVal:g}=ze({jwt:i,uidKey:c});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:y,uidKey:c,uidVal:g,aud:p,pepper:s,jwkAddress:u.from(a),jwt:i,proofFetchCallback:d,verificationKeyHash:l?l.hash():void 0})}};var on=class n{constructor(e){this.signingScheme=3;let{multiKey:t,address:r}=e,i=e.signers.map(a=>a instanceof ee?pe.fromEd25519Account(a):a);if(t.signaturesRequired>i.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${t.signaturesRequired} signers, but only ${i.length} provided`);if(t.signaturesRequired<i.length)throw new Error(`More signers provided than required. Need ${t.signaturesRequired} signers, but ${i.length} provided`);this.publicKey=t,this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress();let o=[];for(let a of i)o.push(this.publicKey.getIndex(a.getAnyPublicKey()));let s=i.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndicies=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}static fromPublicKeysAndSigners(e){let{address:t,publicKeys:r,signaturesRequired:i,signers:o}=e,s=new Se({publicKeys:r,signaturesRequired:i});return new n({multiKey:s,signers:o,address:t})}static isMultiKeySigner(e){return e instanceof n}signWithAuthenticator(e){return new Pe(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new Pe(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(r=>r instanceof ce).map(async r=>r.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let r=this.signers.filter(i=>i instanceof ce).map(i=>i.checkKeylessAccountValidity(e));await Promise.all(r)}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new Ie({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let r of this.signers)t.push(r.signTransaction(e));return new Ie({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return await this.publicKey.verifySignatureAsync(e)}};var Nn=class{constructor(e){this.signingScheme=1;let{signers:t,publicKey:r,address:i}=e;if(this.publicKey=r,this.accountAddress=i?u.from(i):this.publicKey.authKey().derivedAddress(),r.threshold>t.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${r.threshold} signers, but only ${t.length} provided`);if(r.threshold<t.length)throw new Error(`More signers provided than required. Need ${r.threshold} signers, but ${t.length} provided`);let o=[];for(let a of t)o.push(this.publicKey.getIndex(a.publicKey()));let s=t.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndices=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){return new Fe(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new Fe(this.publicKey,this.signTransaction(e))}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new _e({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){return this.sign(me(e))}};function Zi(n){let e=n.deserializeUleb128AsU32();if(!Object.values(Q).includes(e))throw new Error(`Deserialization of Account failed: SigningScheme variant ${e} is invalid`);return{address:u.deserialize(n),signingScheme:e}}function Yi(n,e){if(e.serializeStr(n.jwt),e.serializeStr(n.uidKey),e.serializeFixedBytes(n.pepper),n.ephemeralKeyPair.serialize(e),n.proof===void 0)throw new Error("Cannot serialize - proof undefined");n.proof.serialize(e),e.serializeOption(n.verificationKeyHash,32)}function Xi(n){let e=n.deserializeStr(),t=n.deserializeStr(),r=n.deserializeFixedBytes(31),i=lt.deserialize(n),o=ae.deserialize(n),s=n.deserializeOption("fixedBytes",32);return{jwt:e,uidKey:t,pepper:r,ephemeralKeyPair:i,proof:o,verificationKeyHash:s}}var eo;(y=>{function n(p){let g=new ne;switch(g.serializeU32AsUleb128(p.signingScheme),p.accountAddress.serialize(g),p.signingScheme){case 0:return p.privateKey.serialize(g),g.toUint8Array();case 2:{if(!fr(p))throw new Error("Account is not a SingleKeySigner");let f=p.getAnyPublicKey();switch(g.serializeU32AsUleb128(f.variant),f.variant){case 3:return Yi(p,g),g.toUint8Array();case 4:{let C=p;return Yi(C,g),C.publicKey.jwkAddress.serialize(g),g.serializeBool(C.audless),g.toUint8Array()}case 1:case 0:return p.privateKey.serialize(g),g.toUint8Array();default:throw new Error(`Invalid public key variant: ${f.variant}`)}}case 3:{let f=p;return f.publicKey.serialize(g),g.serializeU32AsUleb128(f.signers.length),f.signers.forEach(C=>{g.serializeFixedBytes(n(C))}),g.toUint8Array()}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${p.signingScheme}`)}}y.toBytes=n;function e(p){return b.hexInputToStringWithoutPrefix(n(p))}y.toHexStringWithoutPrefix=e;function t(p){return b.hexInputToString(n(p))}y.toHexString=t;function r(p){let{address:g,signingScheme:f}=Zi(p);switch(f){case 0:{let C=$.deserialize(p);return new ee({privateKey:C,address:g})}case 2:{let C=p.deserializeUleb128AsU32();switch(C){case 0:{let M=$.deserialize(p);return new pe({privateKey:M,address:g})}case 1:{let M=nt.deserialize(p);return new pe({privateKey:M,address:g})}case 3:{let M=Xi(p),Ce=ze(M);return new Ne({...M,...Ce})}case 4:{let M=Xi(p),Ce=u.deserialize(p),Le=p.deserializeBool(),qe=ze(M);return new gt({...M,...qe,jwkAddress:Ce,audless:Le})}default:throw new Error(`Unsupported public key variant ${C}`)}}case 3:{let C=Se.deserialize(p),M=p.deserializeUleb128AsU32(),Ce=new Array;for(let Le=0;Le<M;Le+=1){let qe=r(p);if(!fr(qe)&&!(qe instanceof ee))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");Ce.push(qe)}return new on({multiKey:C,signers:Ce,address:g})}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${f}`)}}y.deserialize=r;function i(p){let g=d(p);if(!(g instanceof Ne))throw new Error("Deserialization of KeylessAccount failed");return g}y.keylessAccountFromHex=i;function o(p){let g=d(p);if(!(g instanceof gt))throw new Error("Deserialization of FederatedKeylessAccount failed");return g}y.federatedKeylessAccountFromHex=o;function s(p){let g=d(p);if(!(g instanceof on))throw new Error("Deserialization of MultiKeyAccount failed");return g}y.multiKeyAccountFromHex=s;function a(p){let g=d(p);if(!(g instanceof pe))throw new Error("Deserialization of SingleKeyAccount failed");return g}y.singleKeyAccountFromHex=a;function c(p){let g=d(p);if(!(g instanceof ee))throw new Error("Deserialization of Ed25519Account failed");return g}y.ed25519AccountFromHex=c;function d(p){return r(q.fromHex(p))}y.fromHex=d;function l(p){return d(p)}y.fromBytes=l})(eo||(eo={}));import{sha3_256 as to}from"@noble/hashes/sha3";var no=class n extends Be{constructor({signer:t,accountAddress:r,authenticationFunction:i}){super();this.signingScheme=2;if(!Cn(i))throw new Error(`Invalid authentication function ${i} passed into AbstractedAccount`);this.authenticationFunction=i,this.accountAddress=r,this.publicKey=new Yr(this.accountAddress),this.sign=o=>new rr(t(o))}static fromPermissionedSigner({signer:t,accountAddress:r}){return new n({signer:i=>{let o=new ne;return t.publicKey.serialize(o),t.sign(i).serialize(o),o.toUint8Array()},accountAddress:r??t.accountAddress,authenticationFunction:"0x1::permissioned_delegation::authenticate"})}signWithAuthenticator(t){return new Zt(this.authenticationFunction,to(t),this.sign(to(t)).toUint8Array())}signTransactionWithAuthenticator(t){return this.signWithAuthenticator(me(t))}signTransaction(t){return this.sign(me(t))}setSigner(t){this.sign=r=>new rr(t(r))}};import{sha3_256 as aa}from"@noble/hashes/sha3";function ro(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function io(n){return!!n.match(/\s/)}function Ys(n){return!!n.match(/^T[0-9]+$/)}function Xs(n){return!!n.match(/^&.+$/)}function ea(n){switch(n){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":return!0;default:return!1}}function ta(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!io(r))break}return t}var na=(f=>(f.InvalidTypeTag="unknown type",f.UnexpectedGenericType="unexpected generic type",f.UnexpectedTypeArgumentClose="unexpected '>'",f.UnexpectedWhitespaceCharacter="unexpected whitespace character",f.UnexpectedComma="unexpected ','",f.TypeArgumentCountMismatch="type argument count doesn't match expected amount",f.MissingTypeArgumentClose="no matching '>' for '<'",f.MissingTypeArgument="no type argument before ','",f.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",f.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",f.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",f.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",f.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",f.InvalidAddress="struct address must be valid",f))(na||{}),N=class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function ye(n,e){let t=e?.allowGenerics??!1,r=[],i=[],o=[],s=0,a="",c=1;for(;s<n.length;){let d=n[s];if(d==="<")r.push({savedExpectedTypes:c,savedStr:a,savedTypes:o}),a="",o=[],c=1;else if(d===">"){if(a!==""){let f=sn(a,i,t);o.push(f)}let l=r.pop();if(l===void 0)throw new N(n,"unexpected '>'");if(c!==o.length)throw new N(n,"type argument count doesn't match expected amount");let{savedStr:y,savedTypes:p,savedExpectedTypes:g}=l;i=o,o=p,a=y,c=g}else if(d===","){if(r.length===0)throw new N(n,"unexpected ','");if(a.length===0)throw new N(n,"no type argument before ','");let l=sn(a,i,t);i=[],o.push(l),a="",c+=1}else if(io(d)){let l=!1;if(a.length!==0){let p=sn(a,i,t);i=[],o.push(p),a="",l=!0}s=ta(n,s);let y=n[s];if(s<n.length&&l&&y!==","&&y!==">")throw new N(n,"unexpected whitespace character");continue}else a+=d;s+=1}if(r.length>0)throw new N(n,"no matching '>' for '<'");switch(o.length){case 0:return sn(a,i,t);case 1:if(a==="")return o[0];throw new N(n,"unexpected ','");default:throw new N(n,"unexpected whitespace character")}}function sn(n,e,t){let r=n.trim(),i=r.toLowerCase();if(ea(i)&&e.length>0)throw new N(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new rt;case"bool":return new O;case"address":return new k;case"u8":return new oe;case"u16":return new ke;case"u32":return new Ue;case"u64":return new H;case"u128":return new De;case"u256":return new Re;case"vector":if(e.length!==1)throw new N(n,"vector type expected to have exactly one type argument");return new K(e[0]);default:if(Xs(r)){let a=r.substring(1);return new Dn(sn(a,e,t))}if(Ys(r)){if(t)return new D(Number(r.split("T")[1]));throw new N(n,"unexpected generic type")}if(!r.match(/:/))throw new N(n,"unknown type");let o=r.split("::");if(o.length!==3)throw new N(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=u.fromString(o[0])}catch{throw new N(n,"struct address must be valid")}if(!ro(o[1]))throw new N(n,"module name must only contain alphanumeric or '_' characters");if(!ro(o[2]))throw new N(n,"struct name must only contain alphanumeric or '_' characters");return new m(new xe(s,new _(o[1]),new _(o[2]),e))}}function oo(n){return typeof n=="boolean"}function Me(n){return typeof n=="string"}function ra(n){return typeof n=="number"}function Mn(n){if(ra(n))return n;if(Me(n)&&n!=="")return Number.parseInt(n,10)}function Vn(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function so(n){return n==null}function ao(n){return wr(n)||Tr(n)||Sr(n)||Pr(n)||xr(n)||Kr(n)||Cr(n)||Hn(n)||br(n)||ia(n)||n instanceof S||n instanceof J}function wr(n){return n instanceof G}function Hn(n){return n instanceof u}function br(n){return n instanceof I}function ia(n){return n instanceof wt}function Tr(n){return n instanceof fe}function Sr(n){return n instanceof Tt}function Pr(n){return n instanceof St}function xr(n){return n instanceof he}function Kr(n){return n instanceof Pt}function Cr(n){return n instanceof xt}function co(n){return"bytecode"in n}function E(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function uo(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}var oa=new TextEncoder;function Nt(n){return n?.map(e=>Me(e)?ye(e):e)??[]}async function vr(n,e,t){return(await Ln({aptosConfig:t,accountAddress:n,moduleName:e})).abi}async function Ir(n,e,t,r){let i=await vr(n,e,r);if(!i)throw new Error(`Could not find module ABI for '${n}::${e}'`);return i.exposed_functions.find(o=>o.name===t)}async function im(n,e,t,r){let i=await Ir(n,e,t,r);if(!i)throw new Error(`Could not find function ABI for '${n}::${e}::${t}'`);let o=[];for(let s=0;s<i.params.length;s+=1)o.push(ye(i.params[s],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o}}async function po(n,e,t,r){let i=await Ir(n,e,t,r);if(!i)throw new Error(`Could not find entry function ABI for '${n}::${e}::${t}'`);if(!i.is_entry)throw new Error(`'${n}::${e}::${t}' is not an entry function`);let o=uo(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(ye(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function lo(n,e,t,r){let i=await Ir(n,e,t,r);if(!i)throw new Error(`Could not find view function ABI for '${n}::${e}::${t}'`);if(!i.is_view)throw new Error(`'${n}::${e}::${t}' is not an view function`);let o=[];for(let a=0;a<i.params.length;a+=1)o.push(ye(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(ye(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function om(n,e,t,r,i){return n instanceof bt?n:bt.newBytes(Mt(e,t,n,r,i).bcsToBytes())}function Mt(n,e,t,r,i,o){let s;if("exposed_functions"in e){let a=e.exposed_functions.find(c=>c.name===n);if(!a)throw new Error(`Could not find function ABI for '${e.address}::${e.name}::${n}'`);if(r>=a.params.length)throw new Error(`Too many arguments for '${n}', expected ${a.params.length}`);s=ye(a.params[r],{allowGenerics:!0})}else{if(r>=e.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${e.parameters.length}`);s=e.parameters[r]}return mt(t,s,r,i,"exposed_functions"in e?e:void 0,o)}function mt(n,e,t,r,i,o){return ao(n)?(Er(e,n,t),n):sa(n,e,t,r,i,o)}function sa(n,e,t,r,i,o){if(e.isBool()){if(oo(n))return new G(n);if(Me(n)){if(n==="true")return new G(!0);if(n==="false")return new G(!1)}E("boolean",t)}if(e.isAddress()){if(Me(n))return u.fromString(n);E("string | AccountAddress",t)}if(e.isU8()){let s=Mn(n);if(s!==void 0)return new fe(s);E("number | string",t)}if(e.isU16()){let s=Mn(n);if(s!==void 0)return new Tt(s);E("number | string",t)}if(e.isU32()){let s=Mn(n);if(s!==void 0)return new St(s);E("number | string",t)}if(e.isU64()){if(Vn(n))return new he(BigInt(n));E("bigint | number | string",t)}if(e.isU128()){if(Vn(n))return new Pt(BigInt(n));E("bigint | number | string",t)}if(e.isU256()){if(Vn(n))return new xt(BigInt(n));E("bigint | number | string",t)}if(e.isGeneric()){let s=e.value;if(s<0||s>=r.length)throw new Error(`Generic argument ${e.toString()} is invalid for argument ${t}`);return mt(n,r[s],t,r,i)}if(e.isVector()){if(e.value.isU8()){if(Me(n))return S.U8(oa.encode(n));if(n instanceof Uint8Array)return S.U8(n);if(n instanceof ArrayBuffer)return S.U8(new Uint8Array(n))}if(Me(n)&&n.startsWith("["))return mt(JSON.parse(n),e,t,r);if(Array.isArray(n))return new S(n.map(s=>mt(s,e.value,t,r,i)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(Me(n))return new I(n);E("string",t)}if(e.isObject()){if(Me(n))return u.fromString(n);E("string | AccountAddress",t)}if(e.isDelegationKey()||e.isRateLimiter()){if(n instanceof Uint8Array)return new wt(n);E("Uint8Array",t)}if(e.isOption()){if(so(n)){let a=e.value.typeArgs[0];return a instanceof O?new J(null):a instanceof k?new J(null):a instanceof oe?new J(null):a instanceof ke?new J(null):a instanceof Ue?new J(null):a instanceof H?new J(null):a instanceof De?new J(null):a instanceof Re?new J(null):new J(null)}return new J(mt(n,e.value.typeArgs[0],t,r,i))}if(i?.structs.find(a=>a.name===e.value.name.identifier)?.fields.length===0&&n instanceof Uint8Array)return new wt(n);if(n instanceof Uint8Array&&o?.allowUnknownStructs)return console.warn(`Unsupported struct input type for argument ${t}. Continuing since 'allowUnknownStructs' is enabled.`),new wt(n);throw new Error(`Unsupported struct input type for argument ${t}, type '${e.toString()}'`)}throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}function Er(n,e,t){if(n.isBool()){if(wr(e))return;E("Bool",t)}if(n.isAddress()){if(Hn(e))return;E("AccountAddress",t)}if(n.isU8()){if(Tr(e))return;E("U8",t)}if(n.isU16()){if(Sr(e))return;E("U16",t)}if(n.isU32()){if(Pr(e))return;E("U32",t)}if(n.isU64()){if(xr(e))return;E("U64",t)}if(n.isU128()){if(Kr(e))return;E("U128",t)}if(n.isU256()){if(Cr(e))return;E("U256",t)}if(n.isVector()){if(e instanceof S){e.values.length>0&&Er(n.value,e.values[0],t);return}E("MoveVector",t)}if(n instanceof m){if(n.isString()){if(br(e))return;E("MoveString",t)}if(n.isObject()){if(Hn(e))return;E("AccountAddress",t)}if(n.isOption()){if(e instanceof J){e.value!==void 0&&Er(n.value.typeArgs[0],e.value,t);return}E("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}async function qn(n){if(co(n))return da(n);let{moduleAddress:e,moduleName:t,functionName:r}=Y(n.function),i=await yo({key:"entry-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:po});return ca({...n,abi:i})}function ca(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=Y(n.function),o=Nt(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=n.functionArguments.map((c,d)=>Mt(n.function,e,c,d,o));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);let a=st.build(`${t}::${r}`,i,o,s);if("multisigAddress"in n){let c=u.from(n.multisigAddress);return new en(new nn(c,new rn(a)))}return new Xt(a)}async function $n(n){let{moduleAddress:e,moduleName:t,functionName:r}=Y(n.function),i=await yo({key:"view-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:lo});return ua({abi:i,...n})}function ua(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=Y(n.function),o=Nt(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=n?.functionArguments?.map((a,c)=>Mt(n.function,e,a,c,o))??[];if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);return st.build(`${t}::${r}`,i,o,s)}function da(n){return new ot(new tn(b.fromHexInput(n.bytecode).toUint8Array(),Nt(n.typeArguments),n.functionArguments))}async function _r(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=async()=>or[e.network]?{chainId:or[e.network]}:{chainId:(await _n({aptosConfig:e})).chain_id},a=async()=>i?.gasUnitPrice?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await kn({aptosConfig:e})).gas_estimate},c=async()=>{let C=async()=>i?.accountSequenceNumber!==void 0?i.accountSequenceNumber:(await Fn({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&u.from(o).equals(u.ZERO))try{return await C()}catch{return 0}else return C()},[{chainId:d},{gasEstimate:l},y]=await Promise.all([s(),a(),c()]),{maxGasAmount:p,gasUnitPrice:g,expireTimestamp:f}={maxGasAmount:i?.maxGasAmount?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:i?.gasUnitPrice??BigInt(l),expireTimestamp:i?.expireTimestamp??BigInt(Math.floor(Date.now()/1e3)+20)};return new de(u.from(t),BigInt(y),r,BigInt(p),BigInt(g),BigInt(f),new vn(d))}async function Fr(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=await _r({aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=n.secondarySignerAddresses?.map(c=>u.from(c))??[];return new On(s,a,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}return new Rt(s,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}function go(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=Vt(e);if(t.feePayerAddress){let a=new ct(t.rawTransaction,t.secondarySignerAddresses??[],t.feePayerAddress),c=[];t.secondarySignerAddresses&&(r?c=r.map(y=>Vt(y)):c=Array.from({length:t.secondarySignerAddresses.length},()=>Vt(void 0)));let d=Vt(i),l=new pt(o,t.secondarySignerAddresses??[],c,{address:t.feePayerAddress,authenticator:d});return new Ge(a.raw_txn,l).bcsToBytes()}if(t.secondarySignerAddresses){let a=new at(t.rawTransaction,t.secondarySignerAddresses),c=[];r?c=r.map(l=>Vt(l)):c=Array.from({length:t.secondarySignerAddresses.length},()=>Vt(void 0));let d=new dt(o,t.secondarySignerAddresses,c);return new Ge(a.raw_txn,d).bcsToBytes()}let s;if(o instanceof ge)s=new ut(o.public_key,o.signature);else if(o instanceof X||o instanceof Pe)s=new Qe(o);else if(o instanceof Ut)s=new Qe(o);else throw new Error("Invalid public key");return new Ge(t.rawTransaction,s).bcsToBytes()}function Vt(n){if(!n)return new Ut;let t=v.isInstance(n)||W.isInstance(n)||_t.isInstance(n)?new F(n):n,r=new B(new Uint8Array(64));if(R.isInstance(t))return new ge(t,r);if(F.isInstance(t))return v.isInstance(t.publicKey)?new X(t,new z(Te.getSimulationSignature())):new X(t,new z(r));if(Se.isInstance(t))return new Pe(t,new Ie({signatures:t.publicKeys.map(i=>v.isInstance(i.publicKey)||W.isInstance(i.publicKey)?new z(Te.getSimulationSignature()):new z(r)),bitmap:t.createBitmap({bits:Array(t.publicKeys.length).fill(0).map((i,o)=>o)})}));throw new Error("Unsupported PublicKey used for simulations")}function kr(n){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:r}=n,i=si(V,n.senderAuthenticator),o;if(e.feePayerAddress){if(!t)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");o=new pt(i,e.secondarySignerAddresses??[],r??[],{address:e.feePayerAddress,authenticator:t})}else if(e.secondarySignerAddresses){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");o=new dt(i,e.secondarySignerAddresses,r)}else i instanceof ge?o=new ut(i.public_key,i.signature):i instanceof Fe?o=new Dt(i.public_key,i.signature):o=new Qe(i);return new Ge(e.rawTransaction,o).bcsToBytes()}function mo(n){let e=aa.create();for(let t of n)e.update(t);return e.digest()}var pa=mo(["APTOS::Transaction"]);function _m(n){let e=kr(n);return new b(mo([pa,new Uint8Array([0]),e])).toString()}async function yo({key:n,moduleAddress:e,moduleName:t,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:It(async()=>s(e,t,r,i),`${n}-${i.network}-${e}-${t}-${r}`,1e3*60*5)()}import{ScriptComposerWasm as Ur}from"@aptos-labs/script-composer-pack";var Wn=class n{constructor(e){this.config=e,this.builder=void 0}async init(){if(!n.transactionComposer){let e=await import("@aptos-labs/script-composer-pack"),{TransactionComposer:t,initSync:r}=e;Ur.isInitialized||Ur.init(),r({module:Ur.wasm}),n.transactionComposer=t}this.builder=n.transactionComposer.single_signer()}async addBatchedCalls(e){let{moduleAddress:t,moduleName:r,functionName:i}=Y(e.function),o=this.config.getRequestUrl("Fullnode");if(await this.builder.load_module(o,`${t}::${r}`),e.typeArguments!==void 0)for(let l of e.typeArguments)await this.builder.load_type_tag(o,l.toString());let s=Nt(e.typeArguments),a=await vr(t,r,this.config);if(!a)throw new Error(`Could not find module ABI for '${t}::${r}'`);let c=a?.exposed_functions.find(l=>l.name===i);if(!c)throw new Error(`Could not find function ABI for '${t}::${r}::${i}'`);if(s.length!==c.generic_type_params.length)throw new Error(`Type argument count mismatch, expected ${c?.generic_type_params.length}, received ${s.length}`);let d=e.functionArguments.map((l,y)=>l instanceof bt?l:bt.newBytes(Mt(i,a,l,y,s,{allowUnknownStructs:!0}).bcsToBytes()));return this.builder.add_batched_call(`${t}::${r}`,i,s.map(l=>l.toString()),d)}build(){return this.builder.generate_batched_calls(!0)}};async function A(n){let e=await la(n);return ga(n,e)}async function la(n){let{aptosConfig:e,data:t}=n,r,i;return"bytecode"in t?i=await qn(t):"multisigAddress"in t?(r={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await qn(r)):(r={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await qn(r)),i}async function ga(n,e){let{aptosConfig:t,sender:r,options:i}=n,o;if(ma(n)&&(o=u.ZERO.toString()),ya(n)){let{secondarySignerAddresses:s}=n;return Fr({aptosConfig:t,sender:r,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return Fr({aptosConfig:t,sender:r,payload:e,options:i,feePayerAddress:o})}function ma(n){return n.withFeePayer===!0}function ya(n){return"secondarySignerAddresses"in n}function fo(n){let{transaction:e}=n;return me(e)}function jn(n){let{signer:e,transaction:t}=n;return e.signTransactionWithAuthenticator(t)}function Qn(n){let{signer:e,transaction:t}=n;if(!t.feePayerAddress)throw new Error(`Transaction ${t} is not a Fee Payer transaction`);return t.feePayerAddress=e.accountAddress,jn({signer:e,transaction:t})}async function Dr(n){let{aptosConfig:e,transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=go({transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await vt({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:n.options?.estimateGasUnitPrice??!1,estimate_max_gas_amount:n.options?.estimateMaxGasAmount??!1,estimate_prioritized_gas_unit_price:n.options?.estimatePrioritizedGasUnitPrice??!1},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function an(n){let{aptosConfig:e}=n,t=kr({...n});try{let{data:r}=await vt({aptosConfig:e,body:t,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}catch(r){let i=Ge.deserialize(new q(t));throw i.authenticator.isSingleSender()&&i.authenticator.sender.isSingleKey()&&(i.authenticator.sender.public_key.publicKey instanceof v||i.authenticator.sender.public_key.publicKey instanceof W)&&await ce.fetchJWK({aptosConfig:e,publicKey:i.authenticator.sender.public_key.publicKey,kid:i.authenticator.sender.signature.signature.getJwkKid()}),r}}async function Ze(n){let{aptosConfig:e,signer:t,feePayer:r,transaction:i}=n;zn(t)&&await t.checkKeylessAccountValidity(e),zn(r)&&await r.checkKeylessAccountValidity(e);let o=n.feePayerAuthenticator||r&&Qn({signer:r,transaction:i}),s=jn({signer:t,transaction:i});return an({aptosConfig:e,transaction:i,senderAuthenticator:s,feePayerAuthenticator:o})}async function ho(n){let{aptosConfig:e,senderAuthenticator:t,feePayer:r,transaction:i}=n;zn(r)&&await r.checkKeylessAccountValidity(e);let o=Qn({signer:r,transaction:i});return an({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:o})}var Aa={typeParameters:[],parameters:[K.u8(),new K(K.u8())]};async function wo(n){let{aptosConfig:e,account:t,metadataBytes:r,moduleBytecode:i,options:o}=n,s=i.map(a=>S.U8(a));return A({aptosConfig:e,sender:u.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[S.U8(r),new S(s)],abi:Aa},options:o})}async function yt(n){return Fn(n)}async function To(n){return zi(n)}async function Ln(n){return Ni(n)}async function So(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return mi({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${u.from(t).toString()}/transactions`,params:{start:r?.offset,limit:r?.limit}})}async function Po(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return yi({aptosConfig:e,originMethod:"getResources",path:`accounts/${u.from(t).toString()}/resources`,params:{ledger_version:r?.ledgerVersion,offset:r?.offset,limit:r?.limit??999}})}async function Or(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:i}=n,{data:o}=await tt({aptosConfig:e,originMethod:"getResource",path:`accounts/${u.from(t).toString()}/resource/${r}`,params:{ledger_version:i?.ledgerVersion}});return o.data}async function Ht(n){let{aptosConfig:e,authenticationKey:t,options:r}=n,i=await Or({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=u.from(t);try{let a=await Mi({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return u.from(a)}catch(a){if(a instanceof gi&&a.data.error_code==="table_item_not_found")return s;throw a}}async function xo(n){let{aptosConfig:e,accountAddress:t}=n,i={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},s=await w({aptosConfig:e,query:{query:Ci,variables:{where_condition:i}},originMethod:"getAccountTokensCount"});return s.current_token_ownerships_v2_aggregate.aggregate?s.current_token_ownerships_v2_aggregate.aggregate.count:0}async function Ko(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};r?.tokenStandard&&(o.token_standard={_eq:r?.tokenStandard});let s={query:xi,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function Co(n){let{aptosConfig:e,accountAddress:t,collectionAddress:r,options:i}=n,o=u.from(t).toStringLong(),s=u.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};i?.tokenStandard&&(a.token_standard={_eq:i?.tokenStandard});let c={query:Ki,variables:{where_condition:a,offset:i?.offset,limit:i?.limit,order_by:i?.orderBy}};return(await w({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function Eo(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:u.from(t).toStringLong()}};r?.tokenStandard&&(o.current_collection={token_standard:{_eq:r?.tokenStandard}});let s={query:Pi,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function vo(n){let{aptosConfig:e,accountAddress:t}=n,r=u.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Ei,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function Ry(n){let{aptosConfig:e,accountAddress:t,coinType:r,faMetadataAddress:i}=n,o=r,s;if(r!==void 0&&i!==void 0)s=u.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===Ee?s=u.A.toStringLong():s=En(u.A,r).toStringLong();else if(r===void 0&&i!==void 0){let l=u.from(i);s=l.toStringLong(),l===u.A&&(o=Ee)}else throw new Error("Either coinType, fungibleAssetAddress, or both must be provided");let a=u.from(t).toStringLong(),c={asset_type:{_eq:s}};o!==void 0&&(c={asset_type:{_in:[o,s]}});let d=await Gr({aptosConfig:e,accountAddress:a,options:{where:c}});return d[0]?d[0].amount:0}async function Gr(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i=u.from(t).toStringLong(),o={...r?.where,owner_address:{_eq:i}},s={query:Si,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function Io(n){let{aptosConfig:e,accountAddress:t}=n,r=u.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Ti,variables:{address:r}},originMethod:"getAccountCoinsCount"});if(!o.current_fungible_asset_balances_aggregate.aggregate)throw Error("Failed to get the count of account coins");return o.current_fungible_asset_balances_aggregate.aggregate.count}async function _o(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:u.from(t).toStringLong()}},s={query:In,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function Fo(n){let{aptosConfig:e,privateKey:t}=n,r=new F(t.publicKey());if(t instanceof nt){let o=Z.fromPublicKey({publicKey:r}).derivedAddress();return Be.fromPrivateKey({privateKey:t,address:o})}if(t instanceof $){let i=Z.fromPublicKey({publicKey:r});if(await bo({authKey:i,aptosConfig:e})){let c=i.derivedAddress();return Be.fromPrivateKey({privateKey:t,address:c,legacy:!1})}let s=Z.fromPublicKey({publicKey:r.publicKey});if(await bo({authKey:s,aptosConfig:e})){let c=s.derivedAddress();return Be.fromPrivateKey({privateKey:t,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${t}`)}async function bo(n){let{aptosConfig:e,authKey:t}=n,r=await Ht({aptosConfig:e,authenticationKey:t.derivedAddress()});try{return await yt({aptosConfig:e,accountAddress:r}),!0}catch(i){if(i.status===404)return!1;throw new Error(`Error while looking for an account info ${r.toString()}`)}}var fa={typeParameters:[],parameters:[new oe,K.u8(),new oe,K.u8(),K.u8(),K.u8()]};async function ko(n){let{aptosConfig:e,fromAccount:t,dangerouslySkipVerification:r}=n;if("toNewPrivateKey"in n)return Rr({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toNewPrivateKey});let i;if("toAccount"in n){if(n.toAccount instanceof ee)return Rr({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toAccount.privateKey});if(n.toAccount instanceof Nn)return Rr({aptosConfig:e,fromAccount:t,toAccount:n.toAccount});i=n.toAccount.publicKey.authKey()}else if("toAuthKey"in n)i=n.toAuthKey;else throw new Error("Invalid arguments");let o=await wa({aptosConfig:e,fromAccount:t,toAuthKey:i});if(r===!0)return o;let s=await je({aptosConfig:e,transactionHash:o.hash});if(!s.success)throw new Error(`Failed to rotate authentication key - ${s}`);let a=await A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::set_originating_address",functionArguments:[]}});return Ze({aptosConfig:e,signer:n.toAccount,transaction:a})}async function Rr(n){let{aptosConfig:e,fromAccount:t}=n,r=await yt({aptosConfig:e,accountAddress:t.accountAddress}),i;"toNewPrivateKey"in n?i=Be.fromPrivateKey({privateKey:n.toNewPrivateKey,legacy:!0}):i=n.toAccount;let s=new bi({sequenceNumber:BigInt(r.sequence_number),originator:t.accountAddress,currentAuthKey:u.from(r.authentication_key),newPublicKey:i.publicKey}).bcsToBytes(),a=t.sign(s),c=i.sign(s),d=await A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new fe(t.signingScheme),S.U8(t.publicKey.toUint8Array()),new fe(i.signingScheme),S.U8(i.publicKey.toUint8Array()),S.U8(a.toUint8Array()),S.U8(c.toUint8Array())],abi:fa}});return Ze({aptosConfig:e,signer:t,transaction:d})}var ha={typeParameters:[],parameters:[K.u8()]};async function wa(n){let{aptosConfig:e,fromAccount:t,toAuthKey:r}=n,i=r,o=await A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key_call",functionArguments:[S.U8(i.toUint8Array())],abi:ha}});return Ze({aptosConfig:e,signer:t,transaction:o})}async function te(n){let{aptosConfig:e,payload:t,options:r}=n,i=await $n({...t,aptosConfig:e}),o=new ne;i.serialize(o);let s=o.toUint8Array(),{data:a}=await vt({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:r?.ledgerVersion},body:s});return a}async function Uo(n){let{aptosConfig:e,payload:t,options:r}=n,{data:i}=await vt({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:r?.ledgerVersion},body:{function:t.function,type_arguments:t.typeArguments??[],arguments:t.functionArguments??[]}});return i}async function Do(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=Y(r);return A({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::add_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new k,new m(x()),new m(x())]}},options:i})}async function Ro(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=Y(r);return A({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new k,new m(x()),new m(x())]}},options:i})}async function Oo(n){let{aptosConfig:e,sender:t,options:r}=n;return A({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authenticator",typeArguments:[],functionArguments:[],abi:{typeParameters:[],parameters:[]}},options:r})}var At=class{constructor(e){this.config=e;this.isAccountAbstractionEnabled=async e=>{let t=await this.getAuthenticationFunction(e),{moduleAddress:r,moduleName:i,functionName:o}=Y(e.authenticationFunction);return t?.some(s=>u.fromString(r).equals(s.moduleAddress)&&i===s.moduleName&&o===s.functionName)??!1};this.enableAccountAbstractionTransaction=this.addAuthenticationFunctionTransaction;this.disableAccountAbstractionTransaction=async e=>{let{accountAddress:t,authenticationFunction:r,options:i}=e;return r?this.removeAuthenticationFunctionTransaction({accountAddress:t,authenticationFunction:r,options:i}):this.removeDispatchableAuthenticatorTransaction({accountAddress:t,options:i})}}async addAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return Do({aptosConfig:this.config,authenticationFunction:r,sender:t,options:i})}async removeAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return Ro({aptosConfig:this.config,sender:t,authenticationFunction:r,options:i})}async removeDispatchableAuthenticatorTransaction(e){let{accountAddress:t,options:r}=e;return Oo({aptosConfig:this.config,sender:t,options:r})}async getAuthenticationFunction(e){let{accountAddress:t}=e,[{vec:r}]=await te({aptosConfig:this.config,payload:{function:"0x1::account_abstraction::dispatchable_authenticator",functionArguments:[u.from(t)],abi:{typeParameters:[],parameters:[new k],returnTypes:[]}}});if(r.length!==0)return r[0].map(i=>({moduleAddress:u.fromString(i.module_address),moduleName:i.module_name,functionName:i.function_name}))}};var cn=class{constructor(e){this.config=e;this.abstraction=new At(e)}async getAccountInfo(e){return yt({aptosConfig:this.config,...e})}async getAccountModules(e){return To({aptosConfig:this.config,...e})}async getAccountModule(e){return Ln({aptosConfig:this.config,...e})}async getAccountTransactions(e){return So({aptosConfig:this.config,...e})}async getAccountResources(e){return Po({aptosConfig:this.config,...e})}async getAccountResource(e){return Or({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return Ht({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),xo({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ko({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Co({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Eo({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),vo({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Gr({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Io({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:Ee,faMetadataAddress:ri,...e})}async getAccountCoinAmount(e){let{accountAddress:t,coinType:r,faMetadataAddress:i,minimumLedgerVersion:o}=e;o&&console.warn(`minimumLedgerVersion is not used anymore, here for backward
2
- compatibility see https://github.com/aptos-labs/aptos-ts-sdk/pull/519,
3
- will be removed in the near future`);let s=r;r===void 0&&i!==void 0&&(s=await It(async()=>{try{let d=(await te({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}})).at(0);if(d.vec.length>0&&li(d.vec[0]))return pi(d.vec[0])}catch{}},`coin-mapping-${i.toString()}`,1e3*60*5)());let a;if(r!==void 0&&i!==void 0)a=u.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===Ee?a=u.A.toStringLong():a=En(u.A,r).toStringLong();else if(r===void 0&&i!==void 0){let d=u.from(i);a=d.toStringLong(),d===u.A&&(s=Ee)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(s!==void 0){let[d]=await te({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[s],functionArguments:[t]}});return parseInt(d,10)}let[c]=await te({aptosConfig:this.config,payload:{function:"0x1::primary_fungible_store::balance",typeArguments:["0x1::object::ObjectCore"],functionArguments:[t,a]}});return parseInt(c,10)}async getAccountOwnedObjects(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),_o({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return Fo({aptosConfig:this.config,...e})}};var ba={typeParameters:[{constraints:[]}],parameters:[new k,new H]};async function Go(n){let{aptosConfig:e,sender:t,recipient:r,amount:i,coinType:o,options:s}=n;return A({aptosConfig:e,sender:t,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[o??Ee],functionArguments:[r,i],abi:ba},options:s})}var un=class{constructor(e){this.config=e}async transferCoinTransaction(e){return Go({aptosConfig:this.config,...e})}};var Ye={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},le="0x4::token::Token";async function Bo(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:u.from(t).toStringLong()}};return(await w({aptosConfig:e,query:{query:Ri,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function zo(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};return(await w({aptosConfig:e,query:{query:ur,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function No(n){let{aptosConfig:e,ownerAddress:t,options:r}=n,i={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},o={query:ur,variables:{where_condition:i,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await w({aptosConfig:e,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function Mo(n){let{aptosConfig:e,digitalAssetAddress:t,options:r}=n,i={token_data_id:{_eq:u.from(t).toStringLong()}},o={query:Di,variables:{where_condition:i,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await w({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var Ta={typeParameters:[],parameters:[new m(x()),new H,new m(x()),new m(x()),new O,new O,new O,new O,new O,new O,new O,new O,new O,new H,new H]};async function Vo(n){let{aptosConfig:e,options:t,creator:r}=n;return A({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new I(n.description),new he(n.maxSupply??jr),new I(n.name),new I(n.uri),new G(n.mutableDescription??!0),new G(n.mutableRoyalty??!0),new G(n.mutableURI??!0),new G(n.mutableTokenDescription??!0),new G(n.mutableTokenName??!0),new G(n.mutableTokenProperties??!0),new G(n.mutableTokenURI??!0),new G(n.tokensBurnableByCreator??!0),new G(n.tokensFreezableByCreator??!0),new he(n.royaltyNumerator??0),new he(n.royaltyDenominator??1)],abi:Ta},options:t})}async function qt(n){let{aptosConfig:e,options:t}=n,r=t?.where;t?.tokenStandard&&(r.token_standard={_eq:t?.tokenStandard??"v2"});let i={query:vi,variables:{where_condition:r,offset:t?.offset,limit:t?.limit}};return(await w({aptosConfig:e,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function Ho(n){let{aptosConfig:e,creatorAddress:t,collectionName:r,options:i}=n,o=u.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return i?.tokenStandard&&(s.token_standard={_eq:i?.tokenStandard??"v2"}),qt({aptosConfig:e,options:{...i,where:s}})}async function Lo(n){let{aptosConfig:e,creatorAddress:t,options:r}=n,o={creator_address:{_eq:u.from(t).toStringLong()}};return r?.tokenStandard&&(o.token_standard={_eq:r?.tokenStandard??"v2"}),qt({aptosConfig:e,options:{...r,where:o}})}async function qo(n){let{aptosConfig:e,collectionId:t,options:r}=n,o={collection_id:{_eq:u.from(t).toStringLong()}};return r?.tokenStandard&&(o.token_standard={_eq:r?.tokenStandard??"v2"}),qt({aptosConfig:e,options:{...r,where:o}})}async function $o(n){let{creatorAddress:e,collectionName:t,options:r,aptosConfig:i}=n,o=u.from(e),s={collection_name:{_eq:t},creator_address:{_eq:o.toStringLong()}};return r?.tokenStandard&&(s.token_standard={_eq:r?.tokenStandard??"v2"}),(await qt({aptosConfig:i,options:{where:s}})).collection_id}var Sa={typeParameters:[],parameters:[new m(x()),new m(x()),new m(x()),new m(x()),new K(new m(x())),new K(new m(x())),new K(K.u8())]};async function Wo(n){let{aptosConfig:e,options:t,creator:r,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:d,propertyValues:l}=n,y=d?.map(p=>Ye[p]);return A({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new I(i),new I(o),new I(s),new I(a),S.MoveString(c??[]),S.MoveString(y??[]),as(l??[],y??[])],abi:Sa},options:t})}var Pa={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0))),new k]};async function jo(n){let{aptosConfig:e,sender:t,digitalAssetAddress:r,recipient:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[o??le],functionArguments:[u.from(r),u.from(i)],abi:Pa},options:s})}var xa={typeParameters:[],parameters:[new m(x()),new m(x()),new m(x()),new m(x()),new K(new m(x())),new K(new m(x())),new K(K.u8()),new k]};async function Qo(n){let{aptosConfig:e,account:t,collection:r,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:d,propertyValues:l,options:y}=n;if(c?.length!==l?.length)throw new Error("Property keys and property values counts do not match");if(d?.length!==l?.length)throw new Error("Property types and property values counts do not match");let p=d?.map(g=>Ye[g]);return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,i,o,s,S.MoveString(c??[]),S.MoveString(p??[]),as(l??[],p??[]),a],abi:xa},options:y})}var Ka={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0)))]};async function Jo(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[i??le],functionArguments:[u.from(r)],abi:Ka},options:o})}var Ca={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0)))]};async function Zo(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[i??le],functionArguments:[r],abi:Ca},options:o})}var Ea={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0)))]};async function Yo(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[i??le],functionArguments:[r],abi:Ea},options:o})}var va={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0))),new m(x())]};async function Xo(n){let{aptosConfig:e,creator:t,description:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[o??le],functionArguments:[u.from(i),new I(r)],abi:va},options:s})}var Ia={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0))),new m(x())]};async function es(n){let{aptosConfig:e,creator:t,name:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[o??le],functionArguments:[u.from(i),new I(r)],abi:Ia},options:s})}var _a={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0))),new m(x())]};async function ts(n){let{aptosConfig:e,creator:t,uri:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[o??le],functionArguments:[u.from(i),new I(r)],abi:_a},options:s})}var Fa={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0))),new m(x()),new m(x()),K.u8()]};async function ns(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[a??le],functionArguments:[u.from(s),new I(r),new I(Ye[i]),S.U8(Br(o,Ye[i]))],abi:Fa},options:c})}var ka={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0))),new m(x())]};async function rs(n){let{aptosConfig:e,creator:t,propertyKey:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[o??le],functionArguments:[u.from(i),new I(r)],abi:ka},options:s})}var Ua={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0))),new m(x()),new m(x()),K.u8()]};async function is(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[a??le],functionArguments:[u.from(s),new I(r),new I(Ye[i]),Br(o,Ye[i])],abi:Ua},options:c})}var Da={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new m(se(new D(0))),new m(x()),new D(1)]};async function os(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[a??le,Ye[i]],functionArguments:[u.from(s),new I(r),o],abi:Da},options:c})}var Ra={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new m(se(new D(0))),new m(x()),new D(1)]};async function ss(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[a??le,Ye[i]],functionArguments:[u.from(s),new I(r),o],abi:Ra},options:c})}function as(n,e){let t=new Array;return e.forEach((r,i)=>{t.push(Br(n[i],r))}),t}function Br(n,e){let t=ye(e);return mt(n,t,0,[]).bcsToBytes()}var dn=class{constructor(e){this.config=e}async getCollectionData(e){await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:r,options:i}=e,o=u.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return i?.tokenStandard&&(s.token_standard={_eq:i?.tokenStandard??"v2"}),qt({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ho({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Lo({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),qo({aptosConfig:this.config,...e})}async getCollectionId(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),$o({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Bo({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),zo({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),No({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Mo({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return Vo({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return Wo({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return jo({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return Qo({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return Jo({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return Zo({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return Yo({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return Xo({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return es({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return ts({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return ns({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return rs({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return is({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return os({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return ss({aptosConfig:this.config,...e})}};var cs=300,Oa=n=>{if(n&&n.length>cs)throw new Error(`Event type length exceeds the maximum length of ${cs}`)};async function us(n){let{aptosConfig:e,eventType:t,options:r}=n,i={_or:[{account_address:{_eq:t.split("::")[0]}},{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},sequence_number:{_eq:0},creation_number:{_eq:0}}],indexed_type:{_eq:t}};return pn({aptosConfig:e,options:{...r,where:i}})}async function ds(n){let{accountAddress:e,aptosConfig:t,creationNumber:r,options:i}=n,s={account_address:{_eq:u.from(e).toStringLong()},creation_number:{_eq:r}};return pn({aptosConfig:t,options:{...i,where:s}})}async function ps(n){let{accountAddress:e,aptosConfig:t,eventType:r,options:i}=n,s={account_address:{_eq:u.from(e).toStringLong()},indexed_type:{_eq:r}};return pn({aptosConfig:t,options:{...i,where:s}})}async function pn(n){let{aptosConfig:e,options:t}=n;Oa(t?.where?.indexed_type?._eq);let r={query:Fi,variables:{where_condition:t?.where,offset:t?.offset,limit:t?.limit,order_by:t?.orderBy}};return(await w({aptosConfig:e,query:r,originMethod:"getEvents"})).events}var ln=class{constructor(e){this.config=e}async getModuleEventsByEventType(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),us({aptosConfig:this.config,...e})}async getAccountEventsByCreationNumber(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),ds({aptosConfig:this.config,...e})}async getAccountEventsByEventType(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),ps({aptosConfig:this.config,...e})}async getEvents(e){return await h({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"events_processor"}),pn({aptosConfig:this.config,...e})}};async function ls(n){let{aptosConfig:e,accountAddress:t,amount:r,options:i}=n,o=i?.timeoutSecs||20,{data:s}=await fi({aptosConfig:e,path:"fund",body:{address:u.from(t).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await je({aptosConfig:e,transactionHash:a,options:{timeoutSecs:o,checkSuccess:i?.checkSuccess}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var gn=class{constructor(e){this.config=e}async fundAccount(e){let t=await ls({aptosConfig:this.config,...e});return(e.options?.waitForIndexer===void 0||e.options?.waitForIndexer)&&await $i({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function Jn(n){let{aptosConfig:e,options:t}=n,r={query:Ui,variables:{where_condition:t?.where,limit:t?.limit,offset:t?.offset}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function gs(n){let{aptosConfig:e,options:t}=n,r={query:ki,variables:{where_condition:t?.where,limit:t?.limit,offset:t?.offset}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function ms(n){let{aptosConfig:e,options:t}=n,r={query:Ii,variables:{where_condition:t?.where,limit:t?.limit,offset:t?.offset}};return(await w({aptosConfig:e,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var Ga={typeParameters:[{constraints:[]}],parameters:[ye("0x1::object::Object"),new k,new H]};async function ys(n){let{aptosConfig:e,sender:t,fungibleAssetMetadataAddress:r,recipient:i,amount:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,i,o],abi:Ga},options:s})}var mn=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await h({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Jn({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await h({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),(await Jn({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await h({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),await Jn({aptosConfig:this.config,options:{where:{creator_address:{_eq:u.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await h({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),gs({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await h({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),ms({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return ys({aptosConfig:this.config,...e})}};var yn=class{constructor(e){this.config=e}async getLedgerInfo(){return _n({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return Wi({aptosConfig:this.config,...e})}async getBlockByHeight(e){return ji({aptosConfig:this.config,...e})}async view(e){return te({aptosConfig:this.config,...e})}async viewJson(e){return Uo({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return Oi({aptosConfig:this.config,...e})}async queryIndexer(e){return w({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return Gi({aptosConfig:this.config})}async getProcessorStatus(e){return Bi({aptosConfig:this.config,processorType:e})}};var As=["A name must be between 3 and 63 characters long,","and can only contain lowercase a-z, 0-9, and hyphens.","A name may not start or end with a hyphen."].join(" ");function fs(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function Xe(n){let[e,t,...r]=n.replace(/\.apt$/,"").split(".");if(r.length>0)throw new Error(`${n} is invalid. A name can only have two parts, a domain and a subdomain separated by a "."`);if(!fs(e))throw new Error(`${e} is not valid. ${As}`);if(t&&!fs(t))throw new Error(`${t} is not valid. ${As}`);return{domainName:t||e,subdomainName:t?e:void 0}}var Ba=(t=>(t[t.Independent=0]="Independent",t[t.FollowsDomain=1]="FollowsDomain",t))(Ba||{});function hs(n){if(!n)return!1;let e=new Date(n.domain_expiration_timestamp).getTime()<Date.now(),t=new Date(n.expiration_timestamp).getTime()<Date.now();return n.subdomain&&e?!1:n.subdomain&&n.subdomain_expiration_policy===1?!0:!t}var Jf="0x37368b46ce665362562c6d1d4ec01a08c8644c488690df5a17e13ba163e20221",za="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",Na={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:za,custom:null,devnet:null};function Ve(n){let e=Na[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var Zn=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function ws(n){let{aptosConfig:e,name:t}=n,r=Ve(e),{domainName:i,subdomainName:o}=Xe(t),s=await te({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=Zn(s[0]);return a?u.from(a):void 0}async function bs(n){let{aptosConfig:e,expiration:t,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,d=Ve(e),{domainName:l,subdomainName:y}=Xe(r),p=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(y&&!p)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(p&&!y)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let M=t.years??1;if(M!==1)throw new Error("For now, names can only be registered for 1 year at a time");let Le=M*31536e3;return await A({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${d}::router::register_domain`,functionArguments:[l,Le,o,s]},options:a})}if(!y)throw new Error(`${t.policy} requires a subdomain to be provided.`);let g=await zr({aptosConfig:e,name:l});if(!g)throw new Error("The domain does not exist");let f=t.policy==="subdomain:independent"?t.expirationDate:g;if(f>g)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await A({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${d}::router::register_subdomain`,functionArguments:[l,y,Math.round(f/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function zr(n){let{aptosConfig:e,name:t}=n,r=Ve(e),{domainName:i,subdomainName:o}=Xe(t);try{let s=await te({aptosConfig:e,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch{return}}async function Ts(n){let{aptosConfig:e,address:t}=n,r=Ve(e),i=await te({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[u.from(t).toString()]}}),o=Zn(i[1]),s=Zn(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function Ss(n){let{aptosConfig:e,sender:t,name:r,options:i}=n,o=Ve(e);if(!r)return await A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=Xe(r);return await A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function Ps(n){let{aptosConfig:e,name:t}=n,r=Ve(e),{domainName:i,subdomainName:o}=Xe(t),s=await te({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=Zn(s[0]);return a?u.from(a):void 0}async function xs(n){let{aptosConfig:e,sender:t,name:r,address:i,options:o}=n,s=Ve(e),{domainName:a,subdomainName:c}=Xe(r);return await A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function Ks(n){let{aptosConfig:e,name:t}=n,{domainName:r,subdomainName:i=""}=Xe(t),a=(await w({aptosConfig:e,query:{query:Ft,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=An(a)),hs(a)?a:void 0}async function Cs(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Nr({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountNames",query:{query:Ft,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{...n.options?.where??{},owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map(An)}async function Es(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Nr({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountDomains",query:{query:Ft,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{...n.options?.where??{},owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map(An)}async function vs(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Nr({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:Ft,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{...n.options?.where??{},owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map(An)}async function Is(n){let{aptosConfig:e,options:t,domain:r}=n;return(await w({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:Ft,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{...n.options?.where??{},domain:{_eq:r},subdomain:{_neq:""}}}}})).current_aptos_names.map(An).filter(hs)}async function Nr(n){let{aptosConfig:e}=n,t=Ve(e),[r]=await te({aptosConfig:e,payload:{function:`${t}::config::reregistration_grace_sec`,functionArguments:[]}}),i=r/60/60/24,o=()=>new Date;return new Date(o().setDate(o().getDate()-i)).toISOString()}async function _s(n){let{aptosConfig:e,sender:t,name:r,years:i=1,options:o}=n,s=Ve(e),a=i*31536e3,{domainName:c,subdomainName:d}=Xe(r);if(d)throw new Error("Subdomains cannot be renewed");if(i!==1)throw new Error("Currently, only 1 year renewals are supported");return await A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function An(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var fn=class{constructor(e){this.config=e}async getOwnerAddress(e){return ws({aptosConfig:this.config,...e})}async getExpiration(e){return zr({aptosConfig:this.config,...e})}async getTargetAddress(e){return Ps({aptosConfig:this.config,...e})}async setTargetAddress(e){return xs({aptosConfig:this.config,...e})}async getPrimaryName(e){return Ts({aptosConfig:this.config,...e})}async setPrimaryName(e){return Ss({aptosConfig:this.config,...e})}async registerName(e){return bs({aptosConfig:this.config,...e})}async renewDomain(e){return _s({aptosConfig:this.config,...e})}async getName(e){return Ks({aptosConfig:this.config,...e})}async getAccountNames(e){return Cs({aptosConfig:this.config,...e})}async getAccountDomains(e){return Es({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return vs({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return Is({aptosConfig:this.config,...e})}};async function Fs(n){let{aptosConfig:e,poolAddress:t}=n,r=u.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:cr,variables:{where_condition:{pool_address:{_eq:r}}}}});return o.num_active_delegator_per_pool[0]?o.num_active_delegator_per_pool[0].num_active_delegator:0}async function ks(n){let{aptosConfig:e,options:t}=n,r={query:cr,variables:{order_by:t?.orderBy}};return(await w({aptosConfig:e,query:r})).num_active_delegator_per_pool}async function Us(n){let{aptosConfig:e,delegatorAddress:t,poolAddress:r}=n,i={query:_i,variables:{delegatorAddress:u.from(t).toStringLong(),poolAddress:u.from(r).toStringLong()}};return(await w({aptosConfig:e,query:i})).delegated_staking_activities}var hn=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await h({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),Fs({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await h({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),ks({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await h({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),Us({aptosConfig:this.config,...e})}};var Yn=class{constructor(e){this.config=e}async simple(e){return A({aptosConfig:this.config,...e})}async scriptComposer(e){let t=new Wn(this.config);await t.init();let i=(await e.builder(t)).build(),o=await _r({aptosConfig:this.config,payload:ot.load(new q(i)),...e});return new Rt(o,e.withFeePayer===!0?u.ZERO:void 0)}async multiAgent(e){return A({aptosConfig:this.config,...e})}};var $t=class{constructor(e){this.config=e}async simple(e){return Dr({aptosConfig:this.config,...e})}async multiAgent(e){return Dr({aptosConfig:this.config,...e})}};ht([pr],$t.prototype,"simple",1),ht([pr],$t.prototype,"multiAgent",1);var Wt=class{constructor(e){this.config=e}async simple(e){return an({aptosConfig:this.config,...e})}async multiAgent(e){return an({aptosConfig:this.config,...e})}};ht([dr],Wt.prototype,"simple",1),ht([dr],Wt.prototype,"multiAgent",1);import Va from"eventemitter3";var Xn=class{constructor(e,t,r,i,o){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=e,this.account=t,this.maxWaitTime=r,this.maximumInFlight=i,this.sleepTime=o}async nextSequenceNumber(){for(;this.lock;)await Qt(this.sleepTime);this.lock=!0;let e=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let t=ve();for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await Qt(this.sleepTime),ve()-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}e=this.currentNumber,this.currentNumber+=BigInt(1)}catch(t){console.error("error in getting next sequence number for this account",t)}finally{this.lock=!1}return e}async initialize(){let{sequence_number:e}=await yt({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await yt({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(e),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await Qt(this.sleepTime);this.lock=!0;try{await this.update();let e=ve();for(;this.lastUncommintedNumber!==this.currentNumber;)ve()-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await Qt(this.sleepTime),await this.update())}catch(e){console.error("error in synchronizing this account sequence number with the one on chain",e)}finally{this.lock=!1}}}};import Ma from"eventemitter3";var Ds="fulfilled",Rs=(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(Rs||{}),er=class extends Ma{constructor(t,r,i=30,o=100,s=10){super();this.taskQueue=new Un;this.transactionsQueue=new Un;this.outstandingTransactions=new Un;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new Xn(t,r,i,o,s)}async submitNextTransaction(){try{for(;;){let t=await this.accountSequnceNumber.nextSequenceNumber();if(t===null)return;let r=await this.generateNextTransaction(this.account,t);if(!r)return;let i=Ze({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,t])}}catch(t){if(t instanceof lr)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],r=[],[i,o]=await this.outstandingTransactions.dequeue();for(t.push(i),r.push(o);!this.outstandingTransactions.isEmpty();)[i,o]=await this.outstandingTransactions.dequeue(),t.push(i),r.push(o);let s=await Promise.allSettled(t);for(let a=0;a<s.length&&a<r.length;a+=1){let c=s[a];o=r[a],c.status===Ds?(this.sentTransactions.push([c.value.hash,o,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,o)):(this.sentTransactions.push([c.status,o,c.reason]),this.emit("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${c.reason}`,error:c.reason}))}this.emit("executionFinish",{message:`execute ${s.length} transactions finished`})}}catch(t){if(t instanceof lr)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,r){try{let i=[];i.push(je({aptosConfig:this.aptosConfig,transactionHash:t.value.hash}));let o=await Promise.allSettled(i);for(let s=0;s<o.length;s+=1){let a=o[s];a.status===Ds?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:t.value.hash})):(this.executedTransactions.push([a.status,r,a.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${a.reason}`,error:a.reason}))}}catch(i){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${i}`)}}async push(t,r){this.transactionsQueue.enqueue([t,r])}async generateNextTransaction(t,r){if(this.transactionsQueue.isEmpty())return;let[i,o]=await this.transactionsQueue.dequeue();return A({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:i,options:{...o,accountSequenceNumber:r}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(t){throw new Error(`Unable to start transaction batching: ${t}`)}}start(){if(this.started)throw new Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw new Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}};var tr=class extends Va{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new er(this.config,t),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:t,options:r}=e;for(let i of t)this.transactionWorker.push(i,r)}registerToEvents(){this.transactionWorker.on("transactionSent",async e=>{this.emit("transactionSent",e)}),this.transactionWorker.on("transactionSendFailed",async e=>{this.emit("transactionSendFailed",e)}),this.transactionWorker.on("transactionExecuted",async e=>{this.emit("transactionExecuted",e)}),this.transactionWorker.on("transactionExecutionFailed",async e=>{this.emit("transactionExecutionFailed",e)}),this.transactionWorker.on("executionFinish",async e=>{this.emit("executionFinish",e)})}forSingleAccount(e){try{let{sender:t,data:r,options:i}=e;this.start({sender:t}),this.push({data:r,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}};var wn=class{constructor(e){this.config=e,this.build=new Yn(this.config),this.simulate=new $t(this.config),this.submit=new Wt(this.config),this.batch=new tr(this.config)}async getTransactions(e){return Vi({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return Hi({aptosConfig:this.config,...e})}async getTransactionByHash(e){return Li({aptosConfig:this.config,...e})}async isPendingTransaction(e){return qi({aptosConfig:this.config,...e})}async waitForTransaction(e){return je({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return kn({aptosConfig:this.config})}getSigningMessage(e){return fo(e)}async publishPackageTransaction(e){return wo({aptosConfig:this.config,...e})}async rotateAuthKey(e){return ko({aptosConfig:this.config,...e})}sign(e){return jn({...e})}signAsFeePayer(e){return Qn({...e})}async batchTransactionsForSingleAccount(e){try{let{sender:t,data:r,options:i}=e;this.batch.forSingleAccount({sender:t,data:r,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}async signAndSubmitTransaction(e){return Ze({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return ho({aptosConfig:this.config,...e})}};import{jwtDecode as La}from"jwt-decode";async function nr(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,uidKey:i="sub",derivationPath:o}=n,s={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,epk_blinder:b.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await hi({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return b.fromHexInput(a.pepper).toUint8Array()}async function Mr(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,pepper:i=await nr(n),uidKey:o="sub",maxExpHorizonSecs:s=(await zt({aptosConfig:e})).maxExpHorizonSecs}=n;if(b.fromHexInput(i).toUint8Array().length!==Ne.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${Ne.PEPPER_LENGTH} bytes`);let a=La(t);if(typeof a.iat!="number")throw new Error("iat was not found");if(s<r.expiryDateSecs-a.iat)throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${s}`);let c={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:b.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:b.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:d}=await wi({aptosConfig:e,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),l=d.proof,y=new et({a:l.a,b:l.b,c:l.c});return new ae({proof:new jt(y,0),trainingWheelsSignature:We.fromHex(d.training_wheels_signature),expHorizonSecs:s})}async function Os(n){let{aptosConfig:e,jwt:t,jwkAddress:r,uidKey:i,proofFetchCallback:o,pepper:s=await nr(n)}=n,{verificationKey:a,maxExpHorizonSecs:c}=await zt({aptosConfig:e}),d=Mr({...n,pepper:s,maxExpHorizonSecs:c}),l=o?d:await d;if(r!==void 0){let g=W.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:r,uidKey:i}),f=await Ht({aptosConfig:e,authenticationKey:g.authKey().derivedAddress()});return gt.create({...n,address:f,proof:l,pepper:s,proofFetchCallback:o,jwkAddress:r,verificationKey:a})}let y=v.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),p=await Ht({aptosConfig:e,authenticationKey:y.authKey().derivedAddress()});return Ne.create({...n,address:p,proof:l,pepper:s,proofFetchCallback:o,verificationKey:a})}async function Gs(n){let{aptosConfig:e,sender:t,iss:r,options:i}=n,{jwksUrl:o}=n;o===void 0&&(oi.test(r)?o="https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com":o=r.endsWith("/")?`${r}.well-known/jwks.json`:`${r}/.well-known/jwks.json`);let s;try{if(s=await fetch(o),!s.ok)throw new Error(`${s.status} ${s.statusText}`)}catch(c){let d;throw c instanceof Error?d=`${c.message}`:d=`error unknown - ${c}`,P.fromErrorType({type:14,details:`Failed to fetch JWKS at ${o}: ${d}`})}let a=await s.json();return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[r,S.MoveString(a.keys.map(c=>c.kid)),S.MoveString(a.keys.map(c=>c.alg)),S.MoveString(a.keys.map(c=>c.e)),S.MoveString(a.keys.map(c=>c.n))]},options:i})}var bn=class{constructor(e){this.config=e}async getPepper(e){return nr({aptosConfig:this.config,...e})}async getProof(e){return Mr({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return Os({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return Gs({aptosConfig:this.config,...e})}};async function qa(n){let{aptosConfig:e,options:t}=n,r={query:In,variables:{where_condition:t?.where,offset:t?.offset,limit:t?.limit,order_by:t?.orderBy}};return(await w({aptosConfig:e,query:r,originMethod:"getObjectData"})).current_objects}async function Bs(n){let{aptosConfig:e,objectAddress:t,options:r}=n,o={object_address:{_eq:u.from(t).toStringLong()}};return(await qa({aptosConfig:e,options:{...r,where:o}}))[0]}var Tn=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),Bs({aptosConfig:this.config,...e})}};async function zs(n){let{aptosConfig:e,payload:t,options:r}=n,i=await $n({...t,aptosConfig:e}),o=new ne;i.serialize(o);let s=o.toUint8Array(),{data:a}=await Ai({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",acceptType:"application/x-bcs",params:{ledger_version:r?.ledgerVersion},body:s}),c=new Uint8Array(a);return r?.convert?r.convert(c):c}var Sn=class{constructor(e){this.config=e}async viewBinary(e){return zs({...e,aptosConfig:this.config})}};var L=class{constructor(e){this.config=new Qi(e),this.account=new cn(this.config),this.abstraction=new At(this.config),this.ans=new fn(this.config),this.coin=new un(this.config),this.digitalAsset=new dn(this.config),this.event=new ln(this.config),this.experimental=new Sn(this.config),this.faucet=new gn(this.config),this.fungibleAsset=new mn(this.config),this.general=new yn(this.config),this.staking=new hn(this.config),this.transaction=new wn(this.config),this.table=new gr(this.config),this.keyless=new bn(this.config),this.object=new Tn(this.config)}};function j(n,e,t){Object.getOwnPropertyNames(e.prototype).forEach(r=>{let i=Object.getOwnPropertyDescriptor(e.prototype,r);i&&(i.value=function(...o){return this[t][r](...o)},Object.defineProperty(n.prototype,r,i))})}j(L,cn,"account");j(L,At,"abstraction");j(L,fn,"ans");j(L,un,"coin");j(L,dn,"digitalAsset");j(L,ln,"event");j(L,Sn,"experimental");j(L,gn,"faucet");j(L,mn,"fungibleAsset");j(L,yn,"general");j(L,hn,"staking");j(L,wn,"transaction");j(L,gr,"table");j(L,bn,"keyless");j(L,Tn,"object");var Qa=1e7,Vr=120,Ja=30,Za=330,Ya=120,Xa=350,ec=300,tc=93,Ke=class Ke extends $e{constructor(e,t){super();let r=b.fromHexInput(t).toUint8Array();if(r.length!==Ke.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${Ke.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=r}authKey(){let e=new ne;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),Z.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){return Ar({...e,publicKey:this})}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}async verifySignatureAsync(e){return yr({...e,publicKey:this})}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new Ke(t,r)}static load(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new Ke(t,r)}static isPublicKey(e){return e instanceof Ke}static create(e){return Ns(e),new Ke(e.iss,Ns(e))}static fromJwtAndPepper(e){let{jwt:t,pepper:r,uidKey:i="sub"}=e,o=Ms(t);if(typeof o.iss!="string")throw new Error("iss was not found");if(typeof o.aud!="string")throw new Error("aud was not found or an array of values");let s=o[i];return Ke.create({iss:o.iss,uidKey:i,uidVal:s,aud:o.aud,pepper:r})}static isInstance(e){return"iss"in e&&typeof e.iss=="string"&&"idCommitment"in e&&e.idCommitment instanceof Uint8Array}};Ke.ID_COMMITMENT_LENGTH=32;var v=Ke;async function yr(n){let{aptosConfig:e,publicKey:t,message:r,signature:i,jwk:o=await hr({aptosConfig:n.aptosConfig,publicKey:n.publicKey,kid:i.getJwkKid()}),keylessConfig:s=await zt({aptosConfig:e}),options:a}=n;try{return t.verifySignature({message:r,signature:i,jwk:o,keylessConfig:s}),!0}catch(c){if(a?.throwErrorWithReason)throw c;return!1}}function Ar(n){let{publicKey:e,message:t,signature:r,keylessConfig:i,jwk:o}=n,{verificationKey:s,maxExpHorizonSecs:a,trainingWheelsPubkey:c}=i;if(!(r.ephemeralCertificate.signature instanceof ae))throw P.fromErrorType({type:26,details:"Unsupported ephemeral certificate variant"});let d=r.ephemeralCertificate.signature;if(!(d.proof.proof instanceof et))throw P.fromErrorType({type:26,details:"Unsupported proof variant for ZeroKnowledgeSig"});let l=d.proof.proof;if(r.expiryDateSecs<ve())throw P.fromErrorType({type:27,details:"The expiryDateSecs is in the past"});if(d.expHorizonSecs>a)throw P.fromErrorType({type:28});if(!r.ephemeralPublicKey.verifySignature({message:t,signature:r.ephemeralSignature}))throw P.fromErrorType({type:29});let y=nc({publicKey:e,signature:r,jwk:o,keylessConfig:i});if(!s.verifyProof({publicInputsHash:y,groth16Proof:l}))throw P.fromErrorType({type:32});if(c){if(!d.trainingWheelsSignature)throw P.fromErrorType({type:30});let p=new Lr(l,y);if(!c.verifySignature({message:p.hash(),signature:d.trainingWheelsSignature}))throw P.fromErrorType({type:31})}return!0}function nc(n){let{publicKey:e,signature:t,jwk:r,keylessConfig:i}=n,o=e instanceof v?e:e.keylessPublicKey;if(!(t.ephemeralCertificate.signature instanceof ae))throw new Error("Signature is not a ZeroKnowledgeSig");let s=t.ephemeralCertificate.signature,a=[];return a.push(...Kn(t.ephemeralPublicKey.toUint8Array(),i.maxCommitedEpkBytes)),a.push(Ct(o.idCommitment)),a.push(t.expiryDateSecs),a.push(s.expHorizonSecs),a.push(be(o.iss,i.maxIssValBytes)),s.extraField?(a.push(1n),a.push(be(s.extraField,i.maxExtraFieldBytes))):(a.push(0n),a.push(be(" ",i.maxExtraFieldBytes))),a.push(be(ja(t.jwtHeader,!0)+".",i.maxJwtHeaderB64Bytes)),a.push(r.toScalar()),s.overrideAudVal?(a.push(be(s.overrideAudVal,Vr)),a.push(1n)):(a.push(be("",Vr)),a.push(0n)),Et(a)}async function hr(n){let{aptosConfig:e,publicKey:t,kid:r}=n,i=t instanceof v?t:t.keylessPublicKey,{iss:o}=i,s,a=t instanceof W?t.jwkAddress:void 0;try{s=await oc({aptosConfig:e,jwkAddr:a})}catch(l){throw P.fromErrorType({type:24,error:l,details:`Failed to fetch ${a?"Federated":"Patched"}JWKs ${a?`for address ${a}`:"0x1"}`})}let c=s.get(o);if(c===void 0)throw P.fromErrorType({type:7,details:`JWKs for issuer ${o} not found.`});let d=c.find(l=>l.kid===r);if(d===void 0)throw P.fromErrorType({type:6,details:`JWK with kid '${r}' for issuer '${o}' not found.`});return d}function Ns(n){let{uidKey:e,uidVal:t,aud:r,pepper:i}=n,o=[Ct(b.fromHexInput(i).toUint8Array()),be(r,Vr),be(t,Za),be(e,Ja)];return ir(Et(o),v.ID_COMMITMENT_LENGTH)}var Te=class n extends we{constructor(e){super();let{jwtHeader:t,ephemeralCertificate:r,expiryDateSecs:i,ephemeralPublicKey:o,ephemeralSignature:s}=e;this.jwtHeader=t,this.ephemeralCertificate=r,this.expiryDateSecs=i,this.ephemeralPublicKey=o,this.ephemeralSignature=s}getJwkKid(){return ac(this.jwtHeader).kid}serialize(e){this.ephemeralCertificate.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let t=Bt.deserialize(e),r=e.deserializeStr(),i=e.deserializeU64(),o=Kt.deserialize(e),s=We.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new n({jwtHeader:"{}",ephemeralCertificate:new Bt(new ae({proof:new jt(new et({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new Kt(new R(new Uint8Array(32))),ephemeralSignature:new We(new B(new Uint8Array(64)))})}static isSignature(e){return e instanceof n}},Bt=class n extends we{constructor(e,t){super(),this.signature=e,this.variant=t}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(ae.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},Pn=class Pn extends T{constructor(e){if(super(),this.data=b.fromHexInput(e).toUint8Array(),this.data.length!==32)throw new Error("Input needs to be 32 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(32);return new Pn(t)}toArray(){let e=this.toProjectivePoint();return[e.x.toString(),e.y.toString(),e.pz.toString()]}toProjectivePoint(){let e=new Uint8Array(this.data);e.reverse();let t=(e[0]&128)>>7,{Fp:r}=Ae.fields,i=r.create(Hr(e)),o=r.sqrt(r.add(r.pow(i,3n),Pn.B)),s=r.neg(o),a=o>s==(t===1)?o:s;return Ae.G1.ProjectivePoint.fromAffine({x:i,y:a})}};Pn.B=Ae.fields.Fp.create(3n);var He=Pn;function Hr(n){if(n.length!==32)throw new Error("Input should be 32 bytes");let e=new Uint8Array(n);return e[0]=e[0]&63,Wa(e)}var xn=class xn extends T{constructor(e){if(super(),this.data=b.fromHexInput(e).toUint8Array(),this.data.length!==64)throw new Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(64);return new xn(t)}toArray(){let e=this.toProjectivePoint();return[[e.x.c0.toString(),e.x.c1.toString()],[e.y.c0.toString(),e.y.c1.toString()],[e.pz.c0.toString(),e.pz.c1.toString()]]}toProjectivePoint(){let e=new Uint8Array(this.data),t=e.slice(0,32).reverse(),r=e.slice(32,64).reverse(),i=(r[0]&128)>>7,{Fp2:o}=Ae.fields,s=o.fromBigTuple([Hr(t),Hr(r)]),a=o.sqrt(o.add(o.pow(s,3n),xn.B)),c=o.neg(a),l=(a.c1>c.c1||a.c1===c.c1&&a.c0>c.c0)===(i===1)?a:c;return Ae.G2.ProjectivePoint.fromAffine({x:s,y:l})}};xn.B=Ae.fields.Fp2.fromBigTuple([19485874751759354771024239261021720505790618469301721065564631296452457478373n,266929791119991161246907387137283842545076965332900288569378510910307636690n]);var ft=xn,et=class n extends Xr{constructor(e){super();let{a:t,b:r,c:i}=e;this.a=new He(t),this.b=new ft(r),this.c=new He(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=He.deserialize(e).bcsToBytes(),r=ft.deserialize(e).bcsToBytes(),i=He.deserialize(e).bcsToBytes();return new n({a:t,b:r,c:i})}toSnarkJsJson(){return{protocol:"groth16",curve:"bn128",pi_a:this.a.toArray(),pi_b:this.b.toArray(),pi_c:this.c.toArray()}}},Lr=class n extends T{constructor(t,r){super();this.domainSeparator="APTOS::Groth16ProofAndStatement";if(this.proof=t,this.publicInputsHash=typeof r=="bigint"?ir(r,32):b.fromHexInput(r).toUint8Array(),this.publicInputsHash.length!==32)throw new Error("Invalid public inputs hash")}serialize(t){this.proof.serialize(t),t.serializeFixedBytes(this.publicInputsHash)}static deserialize(t){return new n(et.deserialize(t),t.deserializeFixedBytes(32))}hash(){return Je(this.bcsToBytes(),this.domainSeparator)}},jt=class n extends T{constructor(e,t){super(),this.proof=e,this.variant=t}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(et.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},ae=class n extends we{constructor(e){super();let{proof:t,expHorizonSecs:r,trainingWheelsSignature:i,extraField:o,overrideAudVal:s}=e;this.proof=t,this.expHorizonSecs=r,this.trainingWheelsSignature=i,this.extraField=o,this.overrideAudVal=s}static fromBytes(e){return n.deserialize(new q(e))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOption(this.extraField),e.serializeOption(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let t=jt.deserialize(e),r=Number(e.deserializeU64()),i=e.deserializeOption("string"),o=e.deserializeOption("string"),s=e.deserializeOption(We);return new n({proof:t,expHorizonSecs:r,trainingWheelsSignature:s,extraField:i,overrideAudVal:o})}},qr=class n{constructor(e){let{verificationKey:t,trainingWheelsPubkey:r,maxExpHorizonSecs:i=Qa,maxExtraFieldBytes:o=Xa,maxJwtHeaderB64Bytes:s=ec,maxIssValBytes:a=Ya,maxCommitedEpkBytes:c=tc}=e;this.verificationKey=t,this.maxExpHorizonSecs=i,r&&(this.trainingWheelsPubkey=new Kt(new R(r))),this.maxExtraFieldBytes=o,this.maxJwtHeaderB64Bytes=s,this.maxIssValBytes=a,this.maxCommitedEpkBytes=c}static create(e,t){return new n({verificationKey:new $r({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2}),maxExpHorizonSecs:Number(t.max_exp_horizon_secs),trainingWheelsPubkey:t.training_wheels_pubkey.vec[0],maxExtraFieldBytes:t.max_extra_field_bytes,maxJwtHeaderB64Bytes:t.max_jwt_header_b64_bytes,maxIssValBytes:t.max_iss_val_bytes,maxCommitedEpkBytes:t.max_commited_epk_bytes})}},$r=class n{constructor(e){let{alphaG1:t,betaG2:r,deltaG2:i,gammaAbcG1:o,gammaG2:s}=e;this.alphaG1=new He(t),this.betaG2=new ft(r),this.deltaG2=new ft(i),this.gammaAbcG1=[new He(o[0]),new He(o[1])],this.gammaG2=new ft(s)}hash(){let e=new ne;return this.serialize(e),$a.create().update(e.toUint8Array()).digest()}serialize(e){this.alphaG1.serialize(e),this.betaG2.serialize(e),this.deltaG2.serialize(e),this.gammaAbcG1[0].serialize(e),this.gammaAbcG1[1].serialize(e),this.gammaG2.serialize(e)}static fromGroth16VerificationKeyResponse(e){return new n({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2})}verifyProof(e){let{publicInputsHash:t,groth16Proof:r}=e,i=r.a.toProjectivePoint(),o=r.b.toProjectivePoint(),s=r.c.toProjectivePoint(),a=this.alphaG1.toProjectivePoint(),c=this.betaG2.toProjectivePoint(),d=this.gammaG2.toProjectivePoint(),l=this.deltaG2.toProjectivePoint(),y=this.gammaAbcG1.map(qe=>qe.toProjectivePoint()),{Fp12:p}=Ae.fields,g=y[0].add(y[1].multiply(t)),f=Ae.pairing(g,d),C=Ae.pairing(i,o),M=Ae.pairing(a,c),Ce=Ae.pairing(s,l),Le=p.mul(M,p.mul(f,Ce));return p.eql(C,Le)}toSnarkJsJson(){return{protocol:"groth16",curve:"bn128",nPublic:1,vk_alpha_1:this.alphaG1.toArray(),vk_beta_2:this.betaG2.toArray(),vk_gamma_2:this.gammaG2.toArray(),vk_delta_2:this.deltaG2.toArray(),IC:this.gammaAbcG1.map(e=>e.toArray())}}};async function zt(n){let{aptosConfig:e}=n;try{return await It(async()=>{let[t,r]=await Promise.all([rc(n),ic(n)]);return qr.create(r,t)},`keyless-configuration-${e.network}`,1e3*60*5)()}catch(t){throw t instanceof P?t:P.fromErrorType({type:25,error:t})}}function ze(n){let{jwt:e,uidKey:t="sub"}=n,r;try{r=Ms(e)}catch(o){throw P.fromErrorType({type:12,details:`Failed to parse JWT - ${ai(o)}`})}if(typeof r.iss!="string")throw P.fromErrorType({type:12,details:"JWT is missing 'iss' in the payload. This should never happen."});if(typeof r.aud!="string")throw P.fromErrorType({type:12,details:"JWT is missing 'aud' in the payload or 'aud' is an array of values."});let i=r[t];return{iss:r.iss,aud:r.aud,uidVal:i}}async function rc(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Configuration";try{let{data:i}=await tt({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${u.from("0x1").toString()}/resource/${r}`,params:{ledger_version:t?.ledgerVersion}});return i.data}catch(i){throw P.fromErrorType({type:22,error:i})}}async function ic(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await tt({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${u.from("0x1").toString()}/resource/${r}`,params:{ledger_version:t?.ledgerVersion}});return i.data}catch(i){throw P.fromErrorType({type:23,error:i})}}async function oc(n){let{aptosConfig:e,jwkAddr:t,options:r}=n,i;if(t){let s="0x1::jwks::FederatedJWKs",{data:a}=await tt({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/${u.from(t).toString()}/resource/${s}`,params:{ledger_version:r?.ledgerVersion}});i=a}else{let s="0x1::jwks::PatchedJWKs",{data:a}=await tt({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/0x1/resource/${s}`,params:{ledger_version:r?.ledgerVersion}});i=a}let o=new Map;for(let s of i.data.jwks.entries){let a=[];for(let c of s.jwks){let{data:d}=c.variant,l=new q(b.fromHexInput(d).toUint8Array()),y=Wr.deserialize(l);a.push(y)}o.set(Qr(s.issuer),a)}return o}var Wr=class n extends T{constructor(e){super();let{kid:t,kty:r,alg:i,e:o,n:s}=e;this.kid=t,this.kty=r,this.alg=i,this.e=o,this.n=s}serialize(e){e.serializeStr(this.kid),e.serializeStr(this.kty),e.serializeStr(this.alg),e.serializeStr(this.e),e.serializeStr(this.n)}static fromMoveStruct(e){let{data:t}=e.variant,r=new q(b.fromHexInput(t).toUint8Array());return n.deserialize(r)}toScalar(){if(this.alg!=="RS256")throw P.fromErrorType({type:32,details:"Failed to convert JWK to scalar when calculating the public inputs hash. Only RSA 256 is supported currently"});let e=di(this.n),r=sc(e.reverse()).map(i=>Ct(i));return r.push(256n),Et(r)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeStr(),s=e.deserializeStr();return new n({kid:t,kty:r,alg:i,n:s,e:o})}};function sc(n){let e=[];for(let t=0;t<n.length;t+=24){let r=n.slice(t,Math.min(t+24,n.length));if(r.length<24){let i=new Uint8Array(24);i.set(r),e.push(i)}else e.push(r)}return e}function ac(n){try{let e=JSON.parse(n);if(e.kid===void 0)throw new Error("JWT header missing kid");return e}catch{throw new Error("Failed to parse JWT header.")}}export{Qa as a,Vr as b,Ja as c,Za as d,Ya as e,Xa as f,ec as g,tc as h,v as i,yr as j,Ar as k,hr as l,Te as m,Bt as n,et as o,Lr as p,jt as q,ae as r,qr as s,$r as t,zt as u,ze as v,oc as w,Wr as x,ac as y,W as z,F as A,z as B,Jt as C,Se as D,Ie as E,kt as F,_e as G,V as H,ge as I,Fe as J,X as K,Pe as L,Ut as M,Zt as N,Yt as O,U as P,O as Q,oe as R,ke as S,Ue as T,H as U,De as V,Re as W,k as X,rt as Y,Dn as Z,D as _,K as $,m as aa,xe as ba,Qu as ca,x as da,Ju as ea,se as fa,Hs as ga,it as ha,ot as ia,Xt as ja,en as ka,st as la,tn as ma,nn as na,rn as oa,de as pa,Rn as qa,at as ra,ct as sa,Oe as ta,ut as ua,Dt as va,dt as wa,pt as xa,Qe as ya,Ge as za,Rt as Aa,On as Ba,Gn as Ca,Je as Da,op as Ea,me as Fa,ee as Ga,fr as Ha,pe as Ia,Be as Ja,lt as Ka,zn as La,ce as Ma,Bn as Na,Ne as Oa,gt as Pa,on as Qa,Nn as Ra,Zi as Sa,eo as Ta,no as Ua,na as Va,N as Wa,ye as Xa,oo as Ya,Me as Za,ra as _a,Mn as $a,Vn as ab,so as bb,ao as cb,wr as db,Hn as eb,br as fb,ia as gb,Tr as hb,Sr as ib,Pr as jb,xr as kb,Kr as lb,Cr as mb,co as nb,E as ob,uo as pb,Nt as qb,vr as rb,Ir as sb,im as tb,po as ub,lo as vb,om as wb,Mt as xb,mt as yb,qn as zb,ca as Ab,$n as Bb,ua as Cb,_r as Db,Fr as Eb,go as Fb,Vt as Gb,kr as Hb,mo as Ib,_m as Jb,Wn as Kb,A as Lb,la as Mb,ga as Nb,fo as Ob,jn as Pb,Qn as Qb,Dr as Rb,an as Sb,Ze as Tb,ho as Ub,wo as Vb,yt as Wb,To as Xb,Ln as Yb,So as Zb,Po as _b,Or as $b,Ht as ac,xo as bc,Ko as cc,Co as dc,Eo as ec,vo as fc,Ry as gc,Gr as hc,Io as ic,_o as jc,Fo as kc,bo as lc,ko as mc,te as nc,Uo as oc,Do as pc,Ro as qc,Oo as rc,At as sc,cn as tc,Go as uc,un as vc,Bo as wc,zo as xc,No as yc,Mo as zc,Vo as Ac,qt as Bc,Ho as Cc,Lo as Dc,qo as Ec,$o as Fc,Wo as Gc,jo as Hc,Qo as Ic,Jo as Jc,Zo as Kc,Yo as Lc,Xo as Mc,es as Nc,ts as Oc,ns as Pc,rs as Qc,is as Rc,os as Sc,ss as Tc,dn as Uc,us as Vc,ds as Wc,ps as Xc,pn as Yc,ln as Zc,ls as _c,gn as $c,Jn as ad,gs as bd,ms as cd,ys as dd,mn as ed,yn as fd,As as gd,fs as hd,Xe as id,Ba as jd,hs as kd,Jf as ld,za as md,ws as nd,bs as od,zr as pd,Ts as qd,Ss as rd,Ps as sd,xs as td,Ks as ud,Cs as vd,Es as wd,vs as xd,Is as yd,_s as zd,fn as Ad,Fs as Bd,ks as Cd,Us as Dd,hn as Ed,Yn as Fd,$t as Gd,Wt as Hd,Xn as Id,Ds as Jd,Rs as Kd,er as Ld,tr as Md,wn as Nd,nr as Od,Mr as Pd,Os as Qd,Gs as Rd,bn as Sd,qa as Td,Bs as Ud,Tn as Vd,zs as Wd,Sn as Xd,L as Yd};
4
- //# sourceMappingURL=chunk-NFPNWY6Z.mjs.map