@aptos-labs/ts-sdk 1.35.0 → 1.36.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.
- package/dist/common/{accountAddress-CuHovHdK.d.ts → accountAddress-jrha_M3l.d.ts} +1 -1
- package/dist/common/{chunk-RX5UBAME.js → chunk-PA2XFIP3.js} +3 -3
- package/dist/common/chunk-PA2XFIP3.js.map +1 -0
- package/dist/common/cli/index.d.ts +1 -1
- package/dist/common/cli/index.js +1 -1
- package/dist/common/cli/index.js.map +1 -1
- package/dist/common/index.d.ts +99 -31
- package/dist/common/index.js +31 -31
- package/dist/common/index.js.map +1 -1
- package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
- package/dist/esm/account/AbstractedAccount.mjs +1 -1
- package/dist/esm/account/Account.mjs +1 -1
- package/dist/esm/account/AccountUtils.mjs +1 -1
- package/dist/esm/account/Ed25519Account.mjs +1 -1
- package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
- package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/MultiEd25519Account.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.d.mts +1 -0
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/index.mjs +1 -1
- package/dist/esm/account/utils.mjs +1 -1
- package/dist/esm/api/account/abstraction.mjs +1 -1
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/experimental.mjs +1 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.d.mts +2 -2
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/object.mjs +1 -1
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/table.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +34 -13
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
- package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
- package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
- package/dist/esm/api/utils.mjs +1 -1
- package/dist/esm/{chunk-EGCL6KA6.mjs → chunk-2N4EPY2J.mjs} +2 -2
- package/dist/esm/{chunk-YAGIE4GN.mjs → chunk-2OBSQ2FK.mjs} +2 -2
- package/dist/esm/{chunk-752TOOCA.mjs → chunk-2P27DDVV.mjs} +2 -2
- package/dist/esm/{chunk-RDPWCN4B.mjs → chunk-2SAOCLIU.mjs} +2 -2
- package/dist/esm/{chunk-44EHAKKW.mjs → chunk-36H47QOE.mjs} +2 -2
- package/dist/esm/{chunk-AQWKKSRN.mjs → chunk-3DHWWNJ3.mjs} +2 -2
- package/dist/esm/{chunk-DAJFOJ3L.mjs → chunk-4KKJ36IO.mjs} +2 -2
- package/dist/esm/{chunk-UJJGIPOA.mjs → chunk-4PW3JKQZ.mjs} +2 -2
- package/dist/esm/chunk-4QK4SKAT.mjs +2 -0
- package/dist/esm/{chunk-OLGEN23M.mjs.map → chunk-4QK4SKAT.mjs.map} +1 -1
- package/dist/esm/{chunk-B23VO5TB.mjs → chunk-4SWK3JHQ.mjs} +2 -2
- package/dist/esm/{chunk-XW3BXTCZ.mjs → chunk-553ZRNUL.mjs} +2 -2
- package/dist/esm/{chunk-ZS2IVRHT.mjs → chunk-5AD7ZF6G.mjs} +2 -2
- package/dist/esm/{chunk-GTVMJJQQ.mjs → chunk-5MVHOQKD.mjs} +2 -2
- package/dist/esm/{chunk-HKL4MFNL.mjs → chunk-5W5XV63W.mjs} +2 -2
- package/dist/esm/{chunk-P5CM4C2G.mjs → chunk-5WWU3WSU.mjs} +2 -2
- package/dist/esm/{chunk-FOEPRHAC.mjs → chunk-6FQDCTMA.mjs} +2 -2
- package/dist/esm/{chunk-5H5D6QVX.mjs → chunk-6IULVNLQ.mjs} +2 -2
- package/dist/esm/{chunk-2TRQERBL.mjs → chunk-6KI24ZRR.mjs} +2 -2
- package/dist/esm/{chunk-BPHCRTHD.mjs → chunk-6VGLRQBT.mjs} +2 -2
- package/dist/esm/{chunk-HBTJN4RJ.mjs → chunk-6YPM7TK2.mjs} +2 -2
- package/dist/esm/{chunk-XSBUL2WP.mjs → chunk-7HC33TEX.mjs} +2 -2
- package/dist/esm/{chunk-PC25RPDV.mjs → chunk-7KHKP7DY.mjs} +2 -2
- package/dist/esm/{chunk-MFLHAVIW.mjs → chunk-ACE3NEV6.mjs} +2 -2
- package/dist/esm/{chunk-CPFQUFVD.mjs → chunk-APGCD5FH.mjs} +2 -2
- package/dist/esm/{chunk-BHVSIRNF.mjs → chunk-CU6HQJSE.mjs} +2 -2
- package/dist/esm/{chunk-BHVSIRNF.mjs.map → chunk-CU6HQJSE.mjs.map} +1 -1
- package/dist/esm/{chunk-W4SMZ6IW.mjs → chunk-DAR3R4UP.mjs} +2 -2
- package/dist/esm/{chunk-3LDVJ2YK.mjs → chunk-DUJJUR7O.mjs} +2 -2
- package/dist/esm/{chunk-GU4MD5ST.mjs → chunk-EHTTY7EF.mjs} +2 -2
- package/dist/esm/{chunk-K233I26C.mjs → chunk-FCHN3LT7.mjs} +2 -2
- package/dist/esm/chunk-G3MHXDYA.mjs +1 -0
- package/dist/esm/{chunk-YXYYII5S.mjs → chunk-GJOUTA7U.mjs} +2 -2
- package/dist/esm/{chunk-6IJZRG3U.mjs → chunk-HTP5ZVX5.mjs} +2 -2
- package/dist/esm/{chunk-6IJZRG3U.mjs.map → chunk-HTP5ZVX5.mjs.map} +1 -1
- package/dist/esm/{chunk-IOHESHLR.mjs → chunk-HWMMVLTP.mjs} +2 -2
- package/dist/esm/chunk-HWNPKEOJ.mjs +2 -0
- package/dist/esm/chunk-HWNPKEOJ.mjs.map +1 -0
- package/dist/esm/chunk-IM4O756A.mjs +2 -0
- package/dist/esm/chunk-IM4O756A.mjs.map +1 -0
- package/dist/esm/{chunk-VDYUMBOT.mjs → chunk-JA7CXAVY.mjs} +2 -2
- package/dist/esm/{chunk-YLUULY6G.mjs → chunk-JBARRS6K.mjs} +2 -2
- package/dist/esm/{chunk-SJDHW55X.mjs → chunk-JLZGYZBX.mjs} +2 -2
- package/dist/esm/{chunk-QYJKCRVA.mjs → chunk-JXHGJ3AA.mjs} +2 -2
- package/dist/esm/chunk-K4JUKMMY.mjs +2 -0
- package/dist/esm/{chunk-G5F5ZOH5.mjs.map → chunk-K4JUKMMY.mjs.map} +1 -1
- package/dist/esm/{chunk-KK5HUWF6.mjs → chunk-KBC4ECVP.mjs} +2 -2
- package/dist/esm/chunk-LET633ZK.mjs +2 -0
- package/dist/esm/{chunk-5W2ERBGY.mjs.map → chunk-LET633ZK.mjs.map} +1 -1
- package/dist/esm/{chunk-27ESCVVC.mjs → chunk-M2GGYCLU.mjs} +2 -2
- package/dist/esm/{chunk-2YKERRHD.mjs → chunk-MY2BEHYF.mjs} +2 -2
- package/dist/esm/{chunk-MAWGZICD.mjs → chunk-MZVVBJVV.mjs} +2 -2
- package/dist/esm/chunk-N73S2K2V.mjs +2 -0
- package/dist/esm/chunk-NIDF2LHF.mjs +2 -0
- package/dist/esm/chunk-NIDF2LHF.mjs.map +1 -0
- package/dist/esm/{chunk-YWSDONJJ.mjs → chunk-OSZWSLJA.mjs} +2 -2
- package/dist/esm/chunk-P265EC4T.mjs +2 -0
- package/dist/esm/{chunk-E5PAUR4N.mjs.map → chunk-P265EC4T.mjs.map} +1 -1
- package/dist/esm/{chunk-U4DEYWFT.mjs → chunk-PE7KT5ZB.mjs} +2 -2
- package/dist/esm/{chunk-WLDYBSOG.mjs → chunk-PICZWW35.mjs} +2 -2
- package/dist/esm/{chunk-US2HZFOM.mjs → chunk-Q3AVJUBL.mjs} +2 -2
- package/dist/esm/{chunk-GI4AR6DQ.mjs → chunk-QLEZDMIK.mjs} +2 -2
- package/dist/esm/{chunk-7A2KHJ3D.mjs → chunk-QXTQNFEQ.mjs} +2 -2
- package/dist/esm/{chunk-OPD5EKOA.mjs → chunk-R6I6Z3AA.mjs} +2 -2
- package/dist/esm/{chunk-T7X4GZDU.mjs → chunk-SCLWOTHD.mjs} +2 -2
- package/dist/esm/{chunk-HVIF6DW6.mjs → chunk-SZU5Q6CF.mjs} +2 -2
- package/dist/esm/{chunk-ONGH5DXZ.mjs → chunk-T3VLXADE.mjs} +2 -2
- package/dist/esm/{chunk-WHVCUVZP.mjs → chunk-TJICLFR2.mjs} +2 -2
- package/dist/esm/{chunk-PYY2RXFP.mjs → chunk-U6ZD22B5.mjs} +2 -2
- package/dist/esm/{chunk-WFKPVKU3.mjs → chunk-UOBDL2BZ.mjs} +2 -2
- package/dist/esm/chunk-UP36QQGG.mjs +4 -0
- package/dist/esm/{chunk-VWZEJTGP.mjs.map → chunk-UP36QQGG.mjs.map} +1 -1
- package/dist/esm/{chunk-2ZLFQBT2.mjs → chunk-VIXTXBYA.mjs} +2 -2
- package/dist/esm/{chunk-Y65PKZLK.mjs → chunk-WYV4W2IM.mjs} +2 -2
- package/dist/esm/{chunk-TH5JCPN2.mjs → chunk-X5ORWYVO.mjs} +2 -2
- package/dist/esm/{chunk-2SAYQUUX.mjs → chunk-X5UJYMJU.mjs} +2 -2
- package/dist/esm/chunk-X5YB74NB.mjs +2 -0
- package/dist/esm/{chunk-BY3XFRUM.mjs.map → chunk-X5YB74NB.mjs.map} +1 -1
- package/dist/esm/{chunk-QUJM5W4L.mjs → chunk-X6H4G6NE.mjs} +2 -2
- package/dist/esm/{chunk-BQYKFATL.mjs → chunk-XFL3B4WZ.mjs} +2 -2
- package/dist/esm/{chunk-67A5U2X6.mjs → chunk-XX4SFNZY.mjs} +2 -2
- package/dist/esm/{chunk-CPAAEEF4.mjs → chunk-YMXJ6GYE.mjs} +2 -2
- package/dist/esm/chunk-ZJCTELB4.mjs +2 -0
- package/dist/esm/chunk-ZJCTELB4.mjs.map +1 -0
- package/dist/esm/{chunk-GRRBXHVG.mjs → chunk-ZOY6N6UM.mjs} +2 -2
- package/dist/esm/{chunk-TWETGZ3W.mjs → chunk-ZVYTHOS5.mjs} +2 -2
- package/dist/esm/cli/index.mjs +1 -1
- package/dist/esm/cli/localNode.mjs +1 -1
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/keyless.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.d.mts +2 -2
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/errors/index.mjs +1 -1
- package/dist/esm/index.d.mts +2 -2
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/abstraction.mjs +1 -1
- package/dist/esm/internal/account.d.mts +43 -3
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.mjs +1 -1
- package/dist/esm/internal/experimental.mjs +1 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.mjs +1 -1
- package/dist/esm/internal/object.mjs +1 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/table.mjs +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +3 -22
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/utils/index.d.mts +15 -0
- package/dist/esm/internal/utils/index.mjs +2 -0
- package/dist/esm/internal/utils/utils.d.mts +65 -0
- package/dist/esm/internal/utils/utils.mjs +2 -0
- package/dist/esm/internal/utils/utils.mjs.map +1 -0
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.d.mts +1 -1
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/scriptComposer/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +29 -18
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.d.mts +16 -0
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/utils/helpers.d.mts +20 -1
- package/dist/esm/utils/helpers.mjs +1 -1
- package/dist/esm/utils/index.d.mts +1 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +26 -25
- package/src/account/MultiKeyAccount.ts +3 -2
- package/src/api/general.ts +2 -2
- package/src/api/transaction.ts +30 -9
- package/src/internal/account.ts +201 -59
- package/src/internal/transactionSubmission.ts +4 -81
- package/src/internal/utils/index.ts +4 -0
- package/src/internal/utils/utils.ts +116 -0
- package/src/transactions/scriptComposer/index.ts +22 -7
- package/src/transactions/transactionBuilder/remoteAbi.ts +106 -34
- package/src/transactions/transactionBuilder/transactionBuilder.ts +7 -2
- package/src/transactions/typeTag/index.ts +22 -0
- package/src/utils/helpers.ts +22 -0
- package/src/version.ts +1 -1
- package/dist/common/chunk-RX5UBAME.js.map +0 -1
- package/dist/esm/chunk-53IBOHXB.mjs +0 -2
- package/dist/esm/chunk-53IBOHXB.mjs.map +0 -1
- package/dist/esm/chunk-5W2ERBGY.mjs +0 -2
- package/dist/esm/chunk-BY3XFRUM.mjs +0 -2
- package/dist/esm/chunk-CXLNTATW.mjs +0 -2
- package/dist/esm/chunk-E5PAUR4N.mjs +0 -2
- package/dist/esm/chunk-FJ5J7CVW.mjs +0 -2
- package/dist/esm/chunk-FJ5J7CVW.mjs.map +0 -1
- package/dist/esm/chunk-G5F5ZOH5.mjs +0 -2
- package/dist/esm/chunk-HYJQHVDZ.mjs +0 -2
- package/dist/esm/chunk-HYJQHVDZ.mjs.map +0 -1
- package/dist/esm/chunk-JXCZTOYC.mjs +0 -1
- package/dist/esm/chunk-L6KVC7CJ.mjs +0 -2
- package/dist/esm/chunk-L6KVC7CJ.mjs.map +0 -1
- package/dist/esm/chunk-OLGEN23M.mjs +0 -2
- package/dist/esm/chunk-PIPDQFL2.mjs +0 -2
- package/dist/esm/chunk-PIPDQFL2.mjs.map +0 -1
- package/dist/esm/chunk-UIRAXHDH.mjs +0 -1
- package/dist/esm/chunk-VWZEJTGP.mjs +0 -4
- package/dist/esm/chunk-W2C5KRUQ.mjs +0 -2
- package/dist/esm/chunk-W2C5KRUQ.mjs.map +0 -1
- package/dist/esm/chunk-XRVZAEQO.mjs +0 -2
- package/dist/esm/chunk-XRVZAEQO.mjs.map +0 -1
- /package/dist/esm/{chunk-EGCL6KA6.mjs.map → chunk-2N4EPY2J.mjs.map} +0 -0
- /package/dist/esm/{chunk-YAGIE4GN.mjs.map → chunk-2OBSQ2FK.mjs.map} +0 -0
- /package/dist/esm/{chunk-752TOOCA.mjs.map → chunk-2P27DDVV.mjs.map} +0 -0
- /package/dist/esm/{chunk-RDPWCN4B.mjs.map → chunk-2SAOCLIU.mjs.map} +0 -0
- /package/dist/esm/{chunk-44EHAKKW.mjs.map → chunk-36H47QOE.mjs.map} +0 -0
- /package/dist/esm/{chunk-AQWKKSRN.mjs.map → chunk-3DHWWNJ3.mjs.map} +0 -0
- /package/dist/esm/{chunk-DAJFOJ3L.mjs.map → chunk-4KKJ36IO.mjs.map} +0 -0
- /package/dist/esm/{chunk-UJJGIPOA.mjs.map → chunk-4PW3JKQZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-B23VO5TB.mjs.map → chunk-4SWK3JHQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-XW3BXTCZ.mjs.map → chunk-553ZRNUL.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZS2IVRHT.mjs.map → chunk-5AD7ZF6G.mjs.map} +0 -0
- /package/dist/esm/{chunk-GTVMJJQQ.mjs.map → chunk-5MVHOQKD.mjs.map} +0 -0
- /package/dist/esm/{chunk-HKL4MFNL.mjs.map → chunk-5W5XV63W.mjs.map} +0 -0
- /package/dist/esm/{chunk-P5CM4C2G.mjs.map → chunk-5WWU3WSU.mjs.map} +0 -0
- /package/dist/esm/{chunk-FOEPRHAC.mjs.map → chunk-6FQDCTMA.mjs.map} +0 -0
- /package/dist/esm/{chunk-5H5D6QVX.mjs.map → chunk-6IULVNLQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-2TRQERBL.mjs.map → chunk-6KI24ZRR.mjs.map} +0 -0
- /package/dist/esm/{chunk-BPHCRTHD.mjs.map → chunk-6VGLRQBT.mjs.map} +0 -0
- /package/dist/esm/{chunk-HBTJN4RJ.mjs.map → chunk-6YPM7TK2.mjs.map} +0 -0
- /package/dist/esm/{chunk-XSBUL2WP.mjs.map → chunk-7HC33TEX.mjs.map} +0 -0
- /package/dist/esm/{chunk-PC25RPDV.mjs.map → chunk-7KHKP7DY.mjs.map} +0 -0
- /package/dist/esm/{chunk-MFLHAVIW.mjs.map → chunk-ACE3NEV6.mjs.map} +0 -0
- /package/dist/esm/{chunk-CPFQUFVD.mjs.map → chunk-APGCD5FH.mjs.map} +0 -0
- /package/dist/esm/{chunk-W4SMZ6IW.mjs.map → chunk-DAR3R4UP.mjs.map} +0 -0
- /package/dist/esm/{chunk-3LDVJ2YK.mjs.map → chunk-DUJJUR7O.mjs.map} +0 -0
- /package/dist/esm/{chunk-GU4MD5ST.mjs.map → chunk-EHTTY7EF.mjs.map} +0 -0
- /package/dist/esm/{chunk-K233I26C.mjs.map → chunk-FCHN3LT7.mjs.map} +0 -0
- /package/dist/esm/{chunk-JXCZTOYC.mjs.map → chunk-G3MHXDYA.mjs.map} +0 -0
- /package/dist/esm/{chunk-YXYYII5S.mjs.map → chunk-GJOUTA7U.mjs.map} +0 -0
- /package/dist/esm/{chunk-IOHESHLR.mjs.map → chunk-HWMMVLTP.mjs.map} +0 -0
- /package/dist/esm/{chunk-VDYUMBOT.mjs.map → chunk-JA7CXAVY.mjs.map} +0 -0
- /package/dist/esm/{chunk-YLUULY6G.mjs.map → chunk-JBARRS6K.mjs.map} +0 -0
- /package/dist/esm/{chunk-SJDHW55X.mjs.map → chunk-JLZGYZBX.mjs.map} +0 -0
- /package/dist/esm/{chunk-QYJKCRVA.mjs.map → chunk-JXHGJ3AA.mjs.map} +0 -0
- /package/dist/esm/{chunk-KK5HUWF6.mjs.map → chunk-KBC4ECVP.mjs.map} +0 -0
- /package/dist/esm/{chunk-27ESCVVC.mjs.map → chunk-M2GGYCLU.mjs.map} +0 -0
- /package/dist/esm/{chunk-2YKERRHD.mjs.map → chunk-MY2BEHYF.mjs.map} +0 -0
- /package/dist/esm/{chunk-MAWGZICD.mjs.map → chunk-MZVVBJVV.mjs.map} +0 -0
- /package/dist/esm/{chunk-CXLNTATW.mjs.map → chunk-N73S2K2V.mjs.map} +0 -0
- /package/dist/esm/{chunk-YWSDONJJ.mjs.map → chunk-OSZWSLJA.mjs.map} +0 -0
- /package/dist/esm/{chunk-U4DEYWFT.mjs.map → chunk-PE7KT5ZB.mjs.map} +0 -0
- /package/dist/esm/{chunk-WLDYBSOG.mjs.map → chunk-PICZWW35.mjs.map} +0 -0
- /package/dist/esm/{chunk-US2HZFOM.mjs.map → chunk-Q3AVJUBL.mjs.map} +0 -0
- /package/dist/esm/{chunk-GI4AR6DQ.mjs.map → chunk-QLEZDMIK.mjs.map} +0 -0
- /package/dist/esm/{chunk-7A2KHJ3D.mjs.map → chunk-QXTQNFEQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-OPD5EKOA.mjs.map → chunk-R6I6Z3AA.mjs.map} +0 -0
- /package/dist/esm/{chunk-T7X4GZDU.mjs.map → chunk-SCLWOTHD.mjs.map} +0 -0
- /package/dist/esm/{chunk-HVIF6DW6.mjs.map → chunk-SZU5Q6CF.mjs.map} +0 -0
- /package/dist/esm/{chunk-ONGH5DXZ.mjs.map → chunk-T3VLXADE.mjs.map} +0 -0
- /package/dist/esm/{chunk-WHVCUVZP.mjs.map → chunk-TJICLFR2.mjs.map} +0 -0
- /package/dist/esm/{chunk-PYY2RXFP.mjs.map → chunk-U6ZD22B5.mjs.map} +0 -0
- /package/dist/esm/{chunk-WFKPVKU3.mjs.map → chunk-UOBDL2BZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-2ZLFQBT2.mjs.map → chunk-VIXTXBYA.mjs.map} +0 -0
- /package/dist/esm/{chunk-Y65PKZLK.mjs.map → chunk-WYV4W2IM.mjs.map} +0 -0
- /package/dist/esm/{chunk-TH5JCPN2.mjs.map → chunk-X5ORWYVO.mjs.map} +0 -0
- /package/dist/esm/{chunk-2SAYQUUX.mjs.map → chunk-X5UJYMJU.mjs.map} +0 -0
- /package/dist/esm/{chunk-QUJM5W4L.mjs.map → chunk-X6H4G6NE.mjs.map} +0 -0
- /package/dist/esm/{chunk-BQYKFATL.mjs.map → chunk-XFL3B4WZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-67A5U2X6.mjs.map → chunk-XX4SFNZY.mjs.map} +0 -0
- /package/dist/esm/{chunk-CPAAEEF4.mjs.map → chunk-YMXJ6GYE.mjs.map} +0 -0
- /package/dist/esm/{chunk-GRRBXHVG.mjs.map → chunk-ZOY6N6UM.mjs.map} +0 -0
- /package/dist/esm/{chunk-TWETGZ3W.mjs.map → chunk-ZVYTHOS5.mjs.map} +0 -0
- /package/dist/esm/{chunk-UIRAXHDH.mjs.map → internal/utils/index.mjs.map} +0 -0
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
FunctionABI,
|
|
24
24
|
TypeArgument,
|
|
25
25
|
} from "../types";
|
|
26
|
-
import { Bool, MoveOption, MoveString, MoveVector, U128, U16, U256, U32, U64, U8 } from "../../bcs";
|
|
26
|
+
import { Bool, FixedBytes, MoveOption, MoveString, MoveVector, U128, U16, U256, U32, U64, U8 } from "../../bcs";
|
|
27
27
|
import { AccountAddress } from "../../core";
|
|
28
28
|
import { getModule } from "../../internal/account";
|
|
29
29
|
import {
|
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
throwTypeMismatch,
|
|
46
46
|
convertNumber,
|
|
47
47
|
} from "./helpers";
|
|
48
|
-
import { CallArgument, MoveFunction } from "../../types";
|
|
48
|
+
import { CallArgument, MoveFunction, MoveModule } from "../../types";
|
|
49
49
|
|
|
50
50
|
const TEXT_ENCODER = new TextEncoder();
|
|
51
51
|
|
|
@@ -69,6 +69,24 @@ export function standardizeTypeTags(typeArguments?: Array<TypeArgument>): Array<
|
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Fetches the ABI of a specified module from the on-chain module ABI.
|
|
74
|
+
*
|
|
75
|
+
* @param moduleAddress - The address of the module from which to fetch the ABI.
|
|
76
|
+
* @param moduleName - The name of the module containing the ABI.
|
|
77
|
+
* @param aptosConfig - The configuration settings for Aptos.
|
|
78
|
+
* @group Implementation
|
|
79
|
+
* @category Transactions
|
|
80
|
+
*/
|
|
81
|
+
export async function fetchModuleAbi(
|
|
82
|
+
moduleAddress: string,
|
|
83
|
+
moduleName: string,
|
|
84
|
+
aptosConfig: AptosConfig,
|
|
85
|
+
): Promise<MoveModule | undefined> {
|
|
86
|
+
const moduleBytecode = await getModule({ aptosConfig, accountAddress: moduleAddress, moduleName });
|
|
87
|
+
return moduleBytecode.abi;
|
|
88
|
+
}
|
|
89
|
+
|
|
72
90
|
/**
|
|
73
91
|
* Fetches the ABI of a specified function from the on-chain module ABI. This function allows you to access the details of a
|
|
74
92
|
* specific function within a module.
|
|
@@ -86,22 +104,13 @@ export async function fetchFunctionAbi(
|
|
|
86
104
|
functionName: string,
|
|
87
105
|
aptosConfig: AptosConfig,
|
|
88
106
|
): Promise<MoveFunction | undefined> {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (module.abi) {
|
|
93
|
-
return module.abi.exposed_functions.find((func) => func.name === functionName);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return undefined;
|
|
107
|
+
const moduleAbi = await fetchModuleAbi(moduleAddress, moduleName, aptosConfig);
|
|
108
|
+
if (!moduleAbi) throw new Error(`Could not find module ABI for '${moduleAddress}::${moduleName}'`);
|
|
109
|
+
return moduleAbi.exposed_functions.find((func) => func.name === functionName);
|
|
97
110
|
}
|
|
98
111
|
|
|
99
112
|
/**
|
|
100
|
-
*
|
|
101
|
-
* @param moduleAddress
|
|
102
|
-
* @param moduleName
|
|
103
|
-
* @param functionName
|
|
104
|
-
* @param aptosConfig
|
|
113
|
+
* @deprecated Use `fetchFunctionAbi` instead and manually parse the type tags.
|
|
105
114
|
*/
|
|
106
115
|
export async function fetchMoveFunctionAbi(
|
|
107
116
|
moduleAddress: string,
|
|
@@ -220,15 +229,14 @@ export async function fetchViewFunctionAbi(
|
|
|
220
229
|
}
|
|
221
230
|
|
|
222
231
|
/**
|
|
223
|
-
*
|
|
224
|
-
* This function checks the provided argument against the expected parameter type and converts it accordingly.
|
|
232
|
+
* @deprecated Handle this inline
|
|
225
233
|
*
|
|
226
|
-
* @
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```typescript
|
|
236
|
+
* const callArgument = argument instanceof CallArgument ? argument : CallArgument.newBytes(
|
|
237
|
+
* convertArgument(functionName, functionAbi, argument, position, genericTypeParams).bcsToBytes()
|
|
238
|
+
* );
|
|
239
|
+
* ```
|
|
232
240
|
*/
|
|
233
241
|
export function convertCallArgument(
|
|
234
242
|
argument: CallArgument | EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes,
|
|
@@ -250,27 +258,54 @@ export function convertCallArgument(
|
|
|
250
258
|
* This function checks the provided argument against the expected parameter type and converts it accordingly.
|
|
251
259
|
*
|
|
252
260
|
* @param functionName - The name of the function for which the argument is being converted.
|
|
253
|
-
* @param
|
|
261
|
+
* @param functionAbiOrModuleAbi - The ABI (Application Binary Interface) of the function, which defines its parameters.
|
|
254
262
|
* @param arg - The argument to be converted, which can be of various types.
|
|
255
263
|
* @param position - The index of the argument in the function's parameter list.
|
|
256
264
|
* @param genericTypeParams - An array of type tags for any generic type parameters.
|
|
265
|
+
* @param options - Options for the conversion process.
|
|
266
|
+
* @param options.allowUnknownStructs - If true, unknown structs will be allowed and converted to a `FixedBytes`.
|
|
257
267
|
* @group Implementation
|
|
258
268
|
* @category Transactions
|
|
259
269
|
*/
|
|
260
270
|
export function convertArgument(
|
|
261
271
|
functionName: string,
|
|
262
|
-
|
|
272
|
+
functionAbiOrModuleAbi: MoveModule | FunctionABI,
|
|
263
273
|
arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes,
|
|
264
274
|
position: number,
|
|
265
275
|
genericTypeParams: Array<TypeTag>,
|
|
276
|
+
options?: { allowUnknownStructs?: boolean },
|
|
266
277
|
) {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
278
|
+
let param: TypeTag;
|
|
279
|
+
|
|
280
|
+
if ("exposed_functions" in functionAbiOrModuleAbi) {
|
|
281
|
+
const functionAbi = functionAbiOrModuleAbi.exposed_functions.find((func) => func.name === functionName);
|
|
282
|
+
if (!functionAbi) {
|
|
283
|
+
throw new Error(
|
|
284
|
+
`Could not find function ABI for '${functionAbiOrModuleAbi.address}::${functionAbiOrModuleAbi.name}::${functionName}'`,
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (position >= functionAbi.params.length) {
|
|
289
|
+
throw new Error(`Too many arguments for '${functionName}', expected ${functionAbi.params.length}`);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
param = parseTypeTag(functionAbi.params[position], { allowGenerics: true });
|
|
293
|
+
} else {
|
|
294
|
+
if (position >= functionAbiOrModuleAbi.parameters.length) {
|
|
295
|
+
throw new Error(`Too many arguments for '${functionName}', expected ${functionAbiOrModuleAbi.parameters.length}`);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
param = functionAbiOrModuleAbi.parameters[position];
|
|
270
299
|
}
|
|
271
300
|
|
|
272
|
-
|
|
273
|
-
|
|
301
|
+
return checkOrConvertArgument(
|
|
302
|
+
arg,
|
|
303
|
+
param,
|
|
304
|
+
position,
|
|
305
|
+
genericTypeParams,
|
|
306
|
+
"exposed_functions" in functionAbiOrModuleAbi ? functionAbiOrModuleAbi : undefined,
|
|
307
|
+
options,
|
|
308
|
+
);
|
|
274
309
|
}
|
|
275
310
|
|
|
276
311
|
/**
|
|
@@ -289,6 +324,8 @@ export function checkOrConvertArgument(
|
|
|
289
324
|
param: TypeTag,
|
|
290
325
|
position: number,
|
|
291
326
|
genericTypeParams: Array<TypeTag>,
|
|
327
|
+
moduleAbi?: MoveModule,
|
|
328
|
+
options?: { allowUnknownStructs?: boolean },
|
|
292
329
|
) {
|
|
293
330
|
// If the argument is bcs encoded, we can just use it directly
|
|
294
331
|
if (isEncodedEntryFunctionArgument(arg)) {
|
|
@@ -301,6 +338,8 @@ export function checkOrConvertArgument(
|
|
|
301
338
|
* @param typeArgs - The expected type arguments.
|
|
302
339
|
* @param arg - The argument to be checked.
|
|
303
340
|
* @param position - The position of the argument in the context of the check.
|
|
341
|
+
* @param moduleAbi - The ABI of the module containing the function, used for type checking.
|
|
342
|
+
* This will typically have information about structs, enums, and other types.
|
|
304
343
|
* @group Implementation
|
|
305
344
|
* @category Transactions
|
|
306
345
|
*/
|
|
@@ -309,7 +348,7 @@ export function checkOrConvertArgument(
|
|
|
309
348
|
}
|
|
310
349
|
|
|
311
350
|
// If it is not BCS encoded, we will need to convert it with the ABI
|
|
312
|
-
return parseArg(arg, param, position, genericTypeParams);
|
|
351
|
+
return parseArg(arg, param, position, genericTypeParams, moduleAbi, options);
|
|
313
352
|
}
|
|
314
353
|
|
|
315
354
|
/**
|
|
@@ -321,6 +360,10 @@ export function checkOrConvertArgument(
|
|
|
321
360
|
* @param param - The type tag that defines the expected type of the argument.
|
|
322
361
|
* @param position - The position of the argument in the function call, used for error reporting.
|
|
323
362
|
* @param genericTypeParams - An array of type tags for generic type parameters, used when the parameter type is generic.
|
|
363
|
+
* @param moduleAbi - The ABI of the module containing the function, used for type checking.
|
|
364
|
+
* This will typically have information about structs, enums, and other types.
|
|
365
|
+
* @param options - Options for the conversion process.
|
|
366
|
+
* @param options.allowUnknownStructs - If true, unknown structs will be allowed and converted to a `FixedBytes`.
|
|
324
367
|
* @group Implementation
|
|
325
368
|
* @category Transactions
|
|
326
369
|
*/
|
|
@@ -329,6 +372,8 @@ function parseArg(
|
|
|
329
372
|
param: TypeTag,
|
|
330
373
|
position: number,
|
|
331
374
|
genericTypeParams: Array<TypeTag>,
|
|
375
|
+
moduleAbi?: MoveModule,
|
|
376
|
+
options?: { allowUnknownStructs?: boolean },
|
|
332
377
|
): EntryFunctionArgumentTypes {
|
|
333
378
|
if (param.isBool()) {
|
|
334
379
|
if (isBool(arg)) {
|
|
@@ -403,7 +448,7 @@ function parseArg(
|
|
|
403
448
|
throw new Error(`Generic argument ${param.toString()} is invalid for argument ${position}`);
|
|
404
449
|
}
|
|
405
450
|
|
|
406
|
-
return checkOrConvertArgument(arg, genericTypeParams[genericIndex], position, genericTypeParams);
|
|
451
|
+
return checkOrConvertArgument(arg, genericTypeParams[genericIndex], position, genericTypeParams, moduleAbi);
|
|
407
452
|
}
|
|
408
453
|
|
|
409
454
|
// We have to special case some vectors for Vector<u8>
|
|
@@ -433,7 +478,9 @@ function parseArg(
|
|
|
433
478
|
// TODO: Support Uint16Array, Uint32Array, BigUint64Array?
|
|
434
479
|
|
|
435
480
|
if (Array.isArray(arg)) {
|
|
436
|
-
return new MoveVector(
|
|
481
|
+
return new MoveVector(
|
|
482
|
+
arg.map((item) => checkOrConvertArgument(item, param.value, position, genericTypeParams, moduleAbi)),
|
|
483
|
+
);
|
|
437
484
|
}
|
|
438
485
|
|
|
439
486
|
throw new Error(`Type mismatch for argument ${position}, type '${param.toString()}'`);
|
|
@@ -454,6 +501,13 @@ function parseArg(
|
|
|
454
501
|
}
|
|
455
502
|
throwTypeMismatch("string | AccountAddress", position);
|
|
456
503
|
}
|
|
504
|
+
// Handle known enum types from Aptos framework
|
|
505
|
+
if (param.isDelegationKey() || param.isRateLimiter()) {
|
|
506
|
+
if (arg instanceof Uint8Array) {
|
|
507
|
+
return new FixedBytes(arg);
|
|
508
|
+
}
|
|
509
|
+
throwTypeMismatch("Uint8Array", position);
|
|
510
|
+
}
|
|
457
511
|
|
|
458
512
|
if (param.isOption()) {
|
|
459
513
|
if (isEmptyOption(arg)) {
|
|
@@ -490,7 +544,25 @@ function parseArg(
|
|
|
490
544
|
return new MoveOption<MoveString>(null);
|
|
491
545
|
}
|
|
492
546
|
|
|
493
|
-
return new MoveOption(
|
|
547
|
+
return new MoveOption(
|
|
548
|
+
checkOrConvertArgument(arg, param.value.typeArgs[0], position, genericTypeParams, moduleAbi),
|
|
549
|
+
);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// We are assuming that fieldless structs are enums, and therefore we cannot typecheck any further due
|
|
553
|
+
// to limited information from the ABI. This does not work for structs on other modules.
|
|
554
|
+
const structDefinition = moduleAbi?.structs.find((s) => s.name === param.value.name.identifier);
|
|
555
|
+
if (structDefinition?.fields.length === 0 && arg instanceof Uint8Array) {
|
|
556
|
+
return new FixedBytes(arg);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
if (arg instanceof Uint8Array && options?.allowUnknownStructs) {
|
|
560
|
+
// eslint-disable-next-line no-console
|
|
561
|
+
console.warn(
|
|
562
|
+
// eslint-disable-next-line max-len
|
|
563
|
+
`Unsupported struct input type for argument ${position}. Continuing since 'allowUnknownStructs' is enabled.`,
|
|
564
|
+
);
|
|
565
|
+
return new FixedBytes(arg);
|
|
494
566
|
}
|
|
495
567
|
|
|
496
568
|
throw new Error(`Unsupported struct input type for argument ${position}, type '${param.toString()}'`);
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
MultiKeySignature,
|
|
21
21
|
} from "../../core/crypto";
|
|
22
22
|
import { Ed25519PublicKey, Ed25519Signature } from "../../core/crypto/ed25519";
|
|
23
|
-
import { getInfo } from "../../internal/
|
|
23
|
+
import { getInfo } from "../../internal/utils";
|
|
24
24
|
import { getLedgerInfo } from "../../internal/general";
|
|
25
25
|
import { getGasPriceEstimation } from "../../internal/transaction";
|
|
26
26
|
import { NetworkToChainId } from "../../utils/apiEndpoints";
|
|
@@ -638,7 +638,12 @@ export function getAuthenticatorForSimulation(publicKey?: PublicKey) {
|
|
|
638
638
|
return new AccountAuthenticatorMultiKey(
|
|
639
639
|
accountPublicKey,
|
|
640
640
|
new MultiKeySignature({
|
|
641
|
-
signatures: accountPublicKey.publicKeys.map(() =>
|
|
641
|
+
signatures: accountPublicKey.publicKeys.map((pubKey) => {
|
|
642
|
+
if (KeylessPublicKey.isInstance(pubKey.publicKey) || FederatedKeylessPublicKey.isInstance(pubKey.publicKey)) {
|
|
643
|
+
return new AnySignature(KeylessSignature.getSimulationSignature());
|
|
644
|
+
}
|
|
645
|
+
return new AnySignature(invalidSignature);
|
|
646
|
+
}),
|
|
642
647
|
bitmap: accountPublicKey.createBitmap({
|
|
643
648
|
bits: Array(accountPublicKey.publicKeys.length)
|
|
644
649
|
.fill(0)
|
|
@@ -639,6 +639,28 @@ export class TypeTagStruct extends TypeTag {
|
|
|
639
639
|
isObject(): boolean {
|
|
640
640
|
return this.isTypeTag(AccountAddress.ONE, "object", "Object");
|
|
641
641
|
}
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Checks if the provided value is a 'DelegationKey' for permissioned signers.
|
|
645
|
+
*
|
|
646
|
+
* @returns {boolean} Returns true if the value is a DelegationKey, otherwise false.
|
|
647
|
+
* @group Implementation
|
|
648
|
+
* @category Transactions
|
|
649
|
+
*/
|
|
650
|
+
isDelegationKey(): boolean {
|
|
651
|
+
return this.isTypeTag(AccountAddress.ONE, "permissioned_delegation", "DelegationKey");
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* Checks if the provided value is of type `RateLimiter`.
|
|
656
|
+
*
|
|
657
|
+
* @returns {boolean} Returns true if the value is a RateLimiter, otherwise false.
|
|
658
|
+
* @group Implementation
|
|
659
|
+
* @category Transactions
|
|
660
|
+
*/
|
|
661
|
+
isRateLimiter(): boolean {
|
|
662
|
+
return this.isTypeTag(AccountAddress.ONE, "rate_limiter", "RateLimiter");
|
|
663
|
+
}
|
|
642
664
|
}
|
|
643
665
|
|
|
644
666
|
/**
|
package/src/utils/helpers.ts
CHANGED
|
@@ -198,7 +198,29 @@ export function getFunctionParts(functionArg: MoveFunctionId) {
|
|
|
198
198
|
return { moduleAddress, moduleName, functionName };
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
/**
|
|
202
|
+
* Validates the provided function information.
|
|
203
|
+
*
|
|
204
|
+
* @param functionInfo - The function information to validate.
|
|
205
|
+
* @returns Whether the function information is valid.
|
|
206
|
+
* @group Implementation
|
|
207
|
+
* @category Utils
|
|
208
|
+
*/
|
|
201
209
|
export function isValidFunctionInfo(functionInfo: string): boolean {
|
|
202
210
|
const parts = functionInfo.split("::");
|
|
203
211
|
return parts.length === 3 && AccountAddress.isValid({ input: parts[0] }).valid;
|
|
204
212
|
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Truncates the provided wallet address at the middle with an ellipsis.
|
|
216
|
+
*
|
|
217
|
+
* @param address - The wallet address to truncate.
|
|
218
|
+
* @param start - The number of characters to show at the beginning of the address.
|
|
219
|
+
* @param end - The number of characters to show at the end of the address.
|
|
220
|
+
* @returns The truncated address.
|
|
221
|
+
* @group Implementation
|
|
222
|
+
* @category Utils
|
|
223
|
+
*/
|
|
224
|
+
export function truncateAddress(address: string, start: number = 6, end: number = 5) {
|
|
225
|
+
return `${address.slice(0, start)}...${address.slice(-end)}`;
|
|
226
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/greg/git/aptos-ts-sdk/dist/common/chunk-RX5UBAME.js","../../src/core/common.ts","../../src/core/hex.ts","../../src/core/accountAddress.ts"],"names":["ParsingError","message","invalidReason","HexInvalidReason","Hex","_Hex","data","bytesToHex"],"mappings":"AAAA,ilBAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CCQhM,IAAMA,CAAAA,CAAN,MAAA,QAA8B,KAAM,CAkBzC,WAAA,CAAYC,CAAAA,CAAiBC,CAAAA,CAAkB,CAC7C,KAAA,CAAMD,CAAO,CAAA,CACb,IAAA,CAAK,aAAA,CAAgBC,CACvB,CACF,CAAA,CC3BA,4CAAuC,IAS3BC,CAAAA,CAAAA,CAAAA,CAAAA,EAAAA,CACVA,CAAAA,CAAA,SAAA,CAAY,WAAA,CACZA,CAAAA,CAAA,cAAA,CAAiB,gBAAA,CACjBA,CAAAA,CAAA,iBAAA,CAAoB,mBAAA,CAHVA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAgCCC,CAAAA,aAAN,MAAMC,CAAI,CAUf,WAAA,CAAYC,CAAAA,CAAkB,CAC5B,IAAA,CAAK,IAAA,CAAOA,CACd,CAaA,YAAA,CAAA,CAA2B,CACzB,OAAO,IAAA,CAAK,IACd,CASA,qBAAA,CAAA,CAAgC,CAC9B,OAAOC,+BAAAA,IAAW,CAAK,IAAI,CAC7B,CASA,QAAA,CAAA,CAAmB,CACjB,MAAO,CAAA,EAAA,EAAK,IAAA,CAAK,qBAAA,CAAsB,CAAC,CAAA,CAAA;ACyTsB;AA1UV,SAAA","file":"/Users/greg/git/aptos-ts-sdk/dist/common/chunk-RX5UBAME.js","sourcesContent":[null,"// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This error is used to explain why parsing failed.\n * @group Implementation\n * @category Serialization\n */\nexport class ParsingError<T> extends Error {\n /**\n * This provides a programmatic way to access why parsing failed. Downstream devs\n * might want to use this to build their own error messages if the default error\n * messages are not suitable for their use case. This should be an enum.\n * @group Implementation\n * @category Serialization\n */\n public invalidReason: T;\n\n /**\n * Creates an instance of the error with a specified message and invalid reason.\n *\n * @param message The error message that describes the issue.\n * @param invalidReason The reason why the input is considered invalid.\n * @group Implementation\n * @category Serialization\n */\n constructor(message: string, invalidReason: T) {\n super(message);\n this.invalidReason = invalidReason;\n }\n}\n\n/**\n * Whereas ParsingError is thrown when parsing fails, e.g. in a fromString function,\n * this type is returned from \"defensive\" functions like isValid.\n * @group Implementation\n * @category Serialization\n */\nexport type ParsingResult<T> = {\n /**\n * True if valid, false otherwise.\n * @group Implementation\n * @category Serialization\n */\n valid: boolean;\n\n /**\n * If valid is false, this will be a code explaining why parsing failed.\n * @group Implementation\n * @category Serialization\n */\n invalidReason?: T;\n\n /**\n * If valid is false, this will be a string explaining why parsing failed.\n * @group Implementation\n * @category Serialization\n */\n invalidReasonMessage?: string;\n};\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bytesToHex, hexToBytes } from \"@noble/hashes/utils\";\nimport { ParsingError, ParsingResult } from \"./common\";\nimport { HexInput } from \"../types\";\n\n/**\n * Provides reasons for parsing failures related to hexadecimal values.\n * @group Implementation\n * @category Serialization\n */\nexport enum HexInvalidReason {\n TOO_SHORT = \"too_short\",\n INVALID_LENGTH = \"invalid_length\",\n INVALID_HEX_CHARS = \"invalid_hex_chars\",\n}\n\n/**\n * NOTE: Do not use this class when working with account addresses; use AccountAddress instead.\n * When accepting hex data as input to a function, prefer to accept HexInput and\n *\n * A helper class for working with hex data. Hex data, when represented as a string,\n * generally looks like this, for example: 0xaabbcc, 45cd32, etc.\n *\n * then use the static helper methods of this class to convert it into the desired\n * format. This enables the greatest flexibility for the developer.\n *\n * Example usage:\n * ```typescript\n * getTransactionByHash(txnHash: HexInput): Promise<Transaction> {\n * const txnHashString = Hex.fromHexInput(txnHash).toString();\n * return await getTransactionByHashInner(txnHashString);\n * }\n * ```\n * This call to `Hex.fromHexInput().toString()` converts the HexInput to a hex string\n * with a leading 0x prefix, regardless of what the input format was.\n *\n * Other ways to chain the functions together:\n * - `Hex.fromHexString({ hexInput: \"0x1f\" }).toUint8Array()`\n * - `new Hex([1, 3]).toStringWithoutPrefix()`\n * @group Implementation\n * @category Serialization\n */\nexport class Hex {\n private readonly data: Uint8Array;\n\n /**\n * Create a new Hex instance from a Uint8Array.\n *\n * @param data - The Uint8Array containing the data to initialize the Hex instance.\n * @group Implementation\n * @category Serialization\n */\n constructor(data: Uint8Array) {\n this.data = data;\n }\n\n // ===\n // Methods for representing an instance of Hex as other types.\n // ===\n\n /**\n * Get the inner hex data as a Uint8Array. The inner data is already a Uint8Array, so no conversion takes place.\n *\n * @returns Hex data as Uint8Array\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data;\n }\n\n /**\n * Get the hex data as a string without the 0x prefix.\n *\n * @returns Hex string without 0x prefix\n * @group Implementation\n * @category Serialization\n */\n toStringWithoutPrefix(): string {\n return bytesToHex(this.data);\n }\n\n /**\n * Get the hex data as a string with the 0x prefix.\n *\n * @returns Hex string with 0x prefix\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n return `0x${this.toStringWithoutPrefix()}`;\n }\n\n // ===\n // Methods for creating an instance of Hex from other types.\n // ===\n\n /**\n * Converts a hex string into a Hex instance, allowing for both prefixed and non-prefixed formats.\n *\n * @param str - A hex string, with or without the 0x prefix.\n *\n * @throws ParsingError - If the hex string is too short, has an odd number of characters, or contains invalid hex characters.\n *\n * @returns Hex - The resulting Hex instance created from the provided string.\n * @group Implementation\n * @category Serialization\n */\n static fromHexString(str: string): Hex {\n let input = str;\n\n if (input.startsWith(\"0x\")) {\n input = input.slice(2);\n }\n\n if (input.length === 0) {\n throw new ParsingError(\n \"Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.\",\n HexInvalidReason.TOO_SHORT,\n );\n }\n\n if (input.length % 2 !== 0) {\n throw new ParsingError(\"Hex string must be an even number of hex characters.\", HexInvalidReason.INVALID_LENGTH);\n }\n\n try {\n return new Hex(hexToBytes(input));\n } catch (error: any) {\n throw new ParsingError(\n `Hex string contains invalid hex characters: ${error?.message}`,\n HexInvalidReason.INVALID_HEX_CHARS,\n );\n }\n }\n\n /**\n * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Hex instance.\n * This function is useful for transforming hexadecimal representations into a structured Hex object for further manipulation.\n *\n * @param hexInput - A HexInput which can be a string or Uint8Array.\n * @returns A Hex instance created from the provided hexInput.\n * @group Implementation\n * @category Serialization\n */\n static fromHexInput(hexInput: HexInput): Hex {\n if (hexInput instanceof Buffer) return new Hex(new Uint8Array(hexInput));\n if (hexInput instanceof Uint8Array) return new Hex(hexInput);\n if (typeof hexInput === \"string\") return Hex.fromHexString(hexInput);\n throw new Error(`Invalid hex input type: ${typeof hexInput}`);\n }\n\n /**\n * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Uint8Array.\n *\n * @param hexInput - A HexInput which can be a string or Uint8Array.\n * @returns A Uint8Array created from the provided hexInput.\n */\n static hexInputToUint8Array(hexInput: HexInput): Uint8Array {\n if (hexInput instanceof Uint8Array) return hexInput;\n return Hex.fromHexString(hexInput).toUint8Array();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string with '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string with '0x' prefix (e.g., \"0x1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToString(\"1234\") // returns \"0x1234\"\n * Hex.hexInputToString(\"0x1234\") // returns \"0x1234\"\n * Hex.hexInputToString(new Uint8Array([0x12, 0x34])) // returns \"0x1234\"\n * ```\n */\n static hexInputToString(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toString();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string without '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string without '0x' prefix (e.g., \"1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToStringWithoutPrefix(\"1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(\"0x1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(new Uint8Array([0x12, 0x34])) // returns \"1234\"\n * ```\n */\n static hexInputToStringWithoutPrefix(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toStringWithoutPrefix();\n }\n\n // ===\n // Methods for checking validity.\n // ===\n\n /**\n * Check if the provided string is a valid hexadecimal representation.\n *\n * @param str - A hex string representing byte data.\n *\n * @returns An object containing:\n * - valid: A boolean indicating whether the string is valid.\n * - invalidReason: The reason for invalidity if the string is not valid.\n * - invalidReasonMessage: A message explaining why the string is invalid.\n * @group Implementation\n * @category Serialization\n */\n static isValid(str: string): ParsingResult<HexInvalidReason> {\n try {\n Hex.fromHexString(str);\n return { valid: true };\n } catch (error: any) {\n return {\n valid: false,\n invalidReason: error?.invalidReason,\n invalidReasonMessage: error?.message,\n };\n }\n }\n\n /**\n * Determine if two Hex instances are equal by comparing their underlying byte data.\n *\n * @param other The Hex instance to compare to.\n * @returns true if the Hex instances are equal, false if not.\n * @group Implementation\n * @category Serialization\n */\n equals(other: Hex): boolean {\n if (this.data.length !== other.data.length) return false;\n return this.data.every((value, index) => value === other.data[index]);\n }\n}\n\nexport const hexToAsciiString = (hex: string) => new TextDecoder().decode(Hex.fromHexInput(hex).toUint8Array());\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bytesToHex, hexToBytes } from \"@noble/hashes/utils\";\nimport { Serializable, Serializer } from \"../bcs/serializer\";\nimport { Deserializer } from \"../bcs/deserializer\";\nimport { ParsingError, ParsingResult } from \"./common\";\nimport { TransactionArgument } from \"../transactions/instances/transactionArgument\";\nimport { HexInput, ScriptTransactionArgumentVariants } from \"../types\";\n\n/**\n * Provides reasons for an address was invalid.\n * @group Implementation\n * @category Serialization\n */\nexport enum AddressInvalidReason {\n INCORRECT_NUMBER_OF_BYTES = \"incorrect_number_of_bytes\",\n INVALID_HEX_CHARS = \"invalid_hex_chars\",\n TOO_SHORT = \"too_short\",\n TOO_LONG = \"too_long\",\n LEADING_ZERO_X_REQUIRED = \"leading_zero_x_required\",\n LONG_FORM_REQUIRED_UNLESS_SPECIAL = \"long_form_required_unless_special\",\n INVALID_PADDING_ZEROES = \"INVALID_PADDING_ZEROES\",\n INVALID_PADDING_STRICTNESS = \"INVALID_PADDING_STRICTNESS\",\n}\n\n/**\n * The input for an account address, which can be either a hexadecimal string or a standard account address.\n * @group Implementation\n * @category Serialization\n */\nexport type AccountAddressInput = HexInput | AccountAddress;\n\n/**\n * NOTE: Only use this class for account addresses. For other hex data, e.g. transaction\n * hashes, use the Hex class.\n *\n * AccountAddress is used for working with account addresses. Account addresses, when\n * represented as a string, generally look like these examples:\n * - 0x1\n * - 0xaa86fe99004361f747f91342ca13c426ca0cccb0c1217677180c9493bad6ef0c\n *\n * Proper formatting and parsing of account addresses is defined by AIP-40.\n * To learn more about the standard, read the AIP here:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * The comments in this class make frequent reference to the LONG and SHORT formats,\n * as well as \"special\" addresses. To learn what these refer to see AIP-40.\n * @group Implementation\n * @category Serialization\n */\nexport class AccountAddress extends Serializable implements TransactionArgument {\n /**\n * This is the internal representation of an account address.\n * @group Implementation\n * @category Serialization\n */\n readonly data: Uint8Array;\n\n /**\n * The number of bytes that make up an account address.\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH: number = 32;\n\n /**\n * The length of an address string in LONG form without a leading 0x.\n * @group Implementation\n * @category Serialization\n */\n static readonly LONG_STRING_LENGTH: number = 64;\n\n static ZERO: AccountAddress = AccountAddress.from(\"0x0\");\n\n static ONE: AccountAddress = AccountAddress.from(\"0x1\");\n\n static TWO: AccountAddress = AccountAddress.from(\"0x2\");\n\n static THREE: AccountAddress = AccountAddress.from(\"0x3\");\n\n static FOUR: AccountAddress = AccountAddress.from(\"0x4\");\n\n static A: AccountAddress = AccountAddress.from(\"0xA\");\n\n /**\n * Creates an instance of AccountAddress from a Uint8Array.\n *\n * This function ensures that the input data is exactly 32 bytes long, which is required for a valid account address.\n *\n * @param input A Uint8Array representing an account address.\n * @throws ParsingError if the input length is not equal to 32 bytes.\n * @group Implementation\n * @category Serialization\n */\n constructor(input: Uint8Array) {\n super();\n if (input.length !== AccountAddress.LENGTH) {\n throw new ParsingError(\n \"AccountAddress data should be exactly 32 bytes long\",\n AddressInvalidReason.INCORRECT_NUMBER_OF_BYTES,\n );\n }\n this.data = input;\n }\n\n /**\n * Determines if the address is classified as special, which is defined as 0x0 to 0xf inclusive.\n * In other words, the last byte of the address must be < 0b10000 (16)\n * and every other byte must be zero.\n *\n * For more information on how special addresses are defined, see AIP-40:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @returns true if the address is special, false otherwise.\n * @group Implementation\n * @category Serialization\n */\n isSpecial(): boolean {\n return (\n this.data.slice(0, this.data.length - 1).every((byte) => byte === 0) && this.data[this.data.length - 1] < 0b10000\n );\n }\n // ===\n // Methods for representing an instance of AccountAddress as other types.\n // ===\n\n /**\n * Return the AccountAddress as a string as per AIP-40.\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n * This representation returns special addresses in SHORT form (0xf)\n * and other addresses in LONG form (0x + 64 characters).\n *\n * @returns AccountAddress as a string conforming to AIP-40.\n * @group Implementation\n * @category Serialization\n */\n toString(): `0x${string}` {\n return `0x${this.toStringWithoutPrefix()}`;\n }\n\n /**\n * Return the AccountAddress as a string conforming to AIP-40 but without the leading 0x.\n *\n * NOTE: Prefer to use `toString` where possible.\n *\n * @returns AccountAddress as a string without the leading 0x.\n * @group Implementation\n * @category Serialization\n */\n toStringWithoutPrefix(): string {\n let hex = bytesToHex(this.data);\n if (this.isSpecial()) {\n hex = hex[hex.length - 1];\n }\n return hex;\n }\n\n /**\n * Convert the account address to a string in LONG format, which is always 0x followed by 64 hex characters.\n *\n * NOTE: Prefer to use `toString` where possible, as it formats special addresses using the SHORT form (no leading 0s).\n *\n * @returns AccountAddress as a string in LONG form.\n * @group Implementation\n * @category Serialization\n */\n toStringLong(): `0x${string}` {\n return `0x${this.toStringLongWithoutPrefix()}`;\n }\n\n /**\n * Returns the account address as a string in LONG form without a leading 0x.\n * This function will include leading zeroes and will produce a string of 64 hex characters.\n *\n * NOTE: Prefer to use `toString` where possible, as it formats special addresses using the SHORT form (no leading 0s).\n *\n * @returns {string} The account address in LONG form.\n * @group Implementation\n * @category Serialization\n */\n toStringLongWithoutPrefix(): string {\n return bytesToHex(this.data);\n }\n\n /**\n * Get the inner data as a Uint8Array.\n * The inner data is already a Uint8Array, so no conversion takes place.\n *\n * @returns Hex data as Uint8Array\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data;\n }\n\n /**\n * Serialize the AccountAddress to a Serializer instance's data buffer.\n * @param serializer The serializer to serialize the AccountAddress to.\n * @returns void\n * @example\n * const serializer = new Serializer();\n * const address = AccountAddress.fromString(\"0x1\");\n * address.serialize(serializer);\n * const bytes = serializer.toUint8Array();\n * // `bytes` is now the BCS-serialized address.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.data);\n }\n\n /**\n * Serializes the current instance into a byte sequence suitable for entry functions.\n * This allows for the proper encoding of data when interacting with entry functions in the blockchain.\n *\n * @param serializer - The serializer instance used to convert the data into bytes.\n * @group Implementation\n * @category Serialization\n */\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n /**\n * Serializes the current instance for use in a script function by encoding it into a byte sequence.\n * This process involves serializing the variant index and the instance data, making it suitable for transmission.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category Serialization\n */\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.Address);\n serializer.serialize(this);\n }\n\n /**\n * Deserialize an AccountAddress from the byte buffer in a Deserializer instance.\n * This function allows you to convert a byte representation of an AccountAddress into an instance of AccountAddress.\n * @param deserializer The deserializer to deserialize the AccountAddress from.\n * @returns An instance of AccountAddress.\n * @example\n * const bytes = hexToBytes(\"0x0102030405060708091011121314151617181920212223242526272829303132\");\n * const deserializer = new Deserializer(bytes);\n * const address = AccountAddress.deserialize(deserializer);\n * // `address` is now an instance of AccountAddress.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): AccountAddress {\n const bytes = deserializer.deserializeFixedBytes(AccountAddress.LENGTH);\n return new AccountAddress(bytes);\n }\n\n // ===\n // Methods for creating an instance of AccountAddress from other types.\n // ===\n\n /**\n * NOTE: This function has strict parsing behavior. For relaxed behavior, please use\n * the `fromString` function.\n *\n * Creates an instance of AccountAddress from a hex string.\n *\n * This function allows only the strictest formats defined by AIP-40. In short this\n * means only the following formats are accepted:\n *\n * - LONG\n * - SHORT for special addresses\n *\n * Where:\n * - LONG is defined as 0x + 64 hex characters.\n * - SHORT for special addresses is 0x0 to 0xf inclusive without padding zeroes.\n *\n * This means the following are not accepted:\n * - SHORT for non-special addresses.\n * - Any address without a leading 0x.\n *\n * @param input - A hex string representing an account address.\n *\n * @throws {ParsingError} If the hex string does not start with 0x or is not in a valid format.\n *\n * @remarks\n *\n * This function has strict parsing behavior. For relaxed behavior, please use the `fromString` function.\n *\n * @see AIP-40 documentation for more details on address formats:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @returns An instance of AccountAddress.\n * @group Implementation\n * @category Serialization\n */\n static fromStringStrict(input: string): AccountAddress {\n // Assert the string starts with 0x.\n if (!input.startsWith(\"0x\")) {\n throw new ParsingError(\"Hex string must start with a leading 0x.\", AddressInvalidReason.LEADING_ZERO_X_REQUIRED);\n }\n\n const address = AccountAddress.fromString(input);\n\n // Check if the address is in LONG form. If it is not, this is only allowed for\n // special addresses, in which case we check it is in proper SHORT form.\n if (input.length !== AccountAddress.LONG_STRING_LENGTH + 2) {\n if (!address.isSpecial()) {\n throw new ParsingError(\n `The given hex string ${input} is not a special address, it must be represented as 0x + 64 chars.`,\n AddressInvalidReason.LONG_FORM_REQUIRED_UNLESS_SPECIAL,\n );\n } else if (input.length !== 3) {\n // 0x + one hex char is the only valid SHORT form for special addresses.\n throw new ParsingError(\n // eslint-disable-next-line max-len\n `The given hex string ${input} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,\n AddressInvalidReason.INVALID_PADDING_ZEROES,\n );\n }\n }\n\n return address;\n }\n\n /**\n * NOTE: This function has relaxed parsing behavior. For strict behavior, please use\n * the `fromStringStrict` function. Where possible use `fromStringStrict` rather than this\n * function, `fromString`.\n *\n * Creates an instance of AccountAddress from a hex string.\n *\n * This function allows all formats defined by AIP-40. In short this means the\n * following formats are accepted:\n *\n * - LONG, with or without leading 0x\n * - SHORT*, with or without leading 0x\n *\n * Where:\n * - LONG is 64 hex characters.\n * - SHORT* is 1 to 63 hex characters inclusive. The address can have missing values up to `maxMissingChars` before it is padded.\n * - Padding zeroes are allowed, e.g. 0x0123 is valid.\n *\n * Learn more about the different address formats by reading AIP-40:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @param input A hex string representing an account address.\n * @param args.maxMissingChars The number of characters that can be missing in a padded address before it is invalid.\n *\n * @returns An instance of AccountAddress.\n *\n * @throws ParsingError if the hex string is too short, too long, or contains invalid characters.\n * @group Implementation\n * @category Serialization\n */\n static fromString(input: string, { maxMissingChars = 4 }: { maxMissingChars?: number } = {}): AccountAddress {\n let parsedInput = input;\n // Remove leading 0x for parsing.\n if (input.startsWith(\"0x\")) {\n parsedInput = input.slice(2);\n }\n\n // Ensure the address string is at least 1 character long.\n if (parsedInput.length === 0) {\n throw new ParsingError(\n \"Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.\",\n AddressInvalidReason.TOO_SHORT,\n );\n }\n\n // Ensure the address string is not longer than 64 characters.\n if (parsedInput.length > 64) {\n throw new ParsingError(\n \"Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.\",\n AddressInvalidReason.TOO_LONG,\n );\n }\n\n // Ensure that the maxMissingChars is between or equal to 0 and 63.\n if (maxMissingChars > 63 || maxMissingChars < 0) {\n throw new ParsingError(\n `maxMissingChars must be between or equal to 0 and 63. Received ${maxMissingChars}`,\n AddressInvalidReason.INVALID_PADDING_STRICTNESS,\n );\n }\n\n let addressBytes: Uint8Array;\n try {\n // Pad the address with leading zeroes, so it is 64 chars long and then convert\n // the hex string to bytes. Every two characters in a hex string constitutes a\n // single byte. So a 64 length hex string becomes a 32 byte array.\n addressBytes = hexToBytes(parsedInput.padStart(64, \"0\"));\n } catch (error: any) {\n // At this point the only way this can fail is if the hex string contains\n // invalid characters.\n throw new ParsingError(`Hex characters are invalid: ${error?.message}`, AddressInvalidReason.INVALID_HEX_CHARS);\n }\n\n const address = new AccountAddress(addressBytes);\n\n // Cannot pad the address if it has more than maxMissingChars missing.\n if (parsedInput.length < 64 - maxMissingChars) {\n if (!address.isSpecial()) {\n throw new ParsingError(\n `Hex string is too short, must be ${64 - maxMissingChars} to 64 chars long, excluding the leading 0x. You may need to fix \nthe addresss by padding it with 0s before passing it to \\`fromString\\` (e.g. <addressString>.padStart(64, '0')). \nReceived ${input}`,\n AddressInvalidReason.TOO_SHORT,\n );\n }\n }\n\n return address;\n }\n\n /**\n * Convenience method for creating an AccountAddress from various input types.\n * This function accepts a string, Uint8Array, or an existing AccountAddress instance and returns the corresponding\n * AccountAddress.\n *\n * @param input - The input to convert into an AccountAddress. This can be a string representation of an address, a Uint8Array,\n * or an existing AccountAddress.\n * @param args.maxMissingChars The number of characters that can be missing in a padded address before it is invalid.\n * @group Implementation\n * @category Serialization\n */\n static from(input: AccountAddressInput, { maxMissingChars = 4 }: { maxMissingChars?: number } = {}): AccountAddress {\n if (typeof input === \"string\") {\n return AccountAddress.fromString(input, { maxMissingChars });\n }\n if (input instanceof Uint8Array) {\n return new AccountAddress(input);\n }\n return input;\n }\n\n /**\n * Create an AccountAddress from various input types, including strings, Uint8Array, and AccountAddress instances.\n *\n * @param input - The input to convert into an AccountAddress, which can be a string, a Uint8Array, or an AccountAddress.\n * @group Implementation\n * @category Serialization\n */\n static fromStrict(input: AccountAddressInput): AccountAddress {\n if (typeof input === \"string\") {\n return AccountAddress.fromStringStrict(input);\n }\n if (input instanceof Uint8Array) {\n return new AccountAddress(input);\n }\n return input;\n }\n // ===\n // Methods for checking validity.\n // ===\n\n /**\n * Check if the provided input is a valid AccountAddress.\n *\n * @param args - The arguments for validation.\n * @param args.input - A hex string representing an account address.\n * @param args.strict - If true, use strict parsing behavior; if false, use relaxed parsing behavior.\n *\n * @returns An object indicating whether the address is valid. If valid, valid = true; if not, valid = false with additional details.\n * If the address is invalid, invalidReason will explain why it is invalid, and invalidReasonMessage will provide the error message.\n * @group Implementation\n * @category Serialization\n */\n static isValid(args: { input: AccountAddressInput; strict?: boolean }): ParsingResult<AddressInvalidReason> {\n try {\n if (args.strict) {\n AccountAddress.fromStrict(args.input);\n } else {\n AccountAddress.from(args.input);\n }\n return { valid: true };\n } catch (error: any) {\n return {\n valid: false,\n invalidReason: error?.invalidReason,\n invalidReasonMessage: error?.message,\n };\n }\n }\n\n /**\n * Determine if two AccountAddresses are equal based on their underlying byte data.\n *\n * @param other - The AccountAddress to compare to.\n * @returns true if the AccountAddresses are equal, false if not.\n * @group Implementation\n * @category Serialization\n */\n equals(other: AccountAddress): boolean {\n if (this.data.length !== other.data.length) return false;\n return this.data.every((value, index) => value === other.data[index]);\n }\n}\n"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as g,f as l,g as R,i as x}from"./chunk-PIPDQFL2.mjs";import{a as K}from"./chunk-W2C5KRUQ.mjs";import{a as S}from"./chunk-2YKERRHD.mjs";import{a as y,b as C}from"./chunk-CPAAEEF4.mjs";import{d as I}from"./chunk-P5CM4C2G.mjs";import{a as w}from"./chunk-AEGA5N2W.mjs";import{a as b}from"./chunk-YWSDONJJ.mjs";import{c as m,m as c}from"./chunk-5W2ERBGY.mjs";import{a as h}from"./chunk-XW3BXTCZ.mjs";import{i as P}from"./chunk-HVIF6DW6.mjs";import{c as d}from"./chunk-752TOOCA.mjs";import{a as s}from"./chunk-HHWJHOFZ.mjs";import{b as f}from"./chunk-TKXEVD7A.mjs";import{a as T}from"./chunk-ZD2TY5N3.mjs";import{b as p}from"./chunk-LQOSHBB7.mjs";async function _(t){let e=await k(t);return v(t,e)}async function k(t){let{aptosConfig:e,data:n}=t,o,a;return"bytecode"in n?a=await g(n):"multisigAddress"in n?(o={aptosConfig:e,multisigAddress:n.multisigAddress,function:n.function,functionArguments:n.functionArguments,typeArguments:n.typeArguments,abi:n.abi},a=await g(o)):(o={aptosConfig:e,function:n.function,functionArguments:n.functionArguments,typeArguments:n.typeArguments,abi:n.abi},a=await g(o)),a}async function v(t,e){let{aptosConfig:n,sender:o,options:a}=t,i;if(M(t)&&(i=p.ZERO.toString()),N(t)){let{secondarySignerAddresses:r}=t;return l({aptosConfig:n,sender:o,payload:e,options:a,secondarySignerAddresses:r,feePayerAddress:i})}return l({aptosConfig:n,sender:o,payload:e,options:a,feePayerAddress:i})}function M(t){return t.withFeePayer===!0}function N(t){return"secondarySignerAddresses"in t}function sn(t){let{transaction:e}=t;return I(e)}function D(t){let{signer:e,transaction:n}=t;return e.signTransactionWithAuthenticator(n)}function G(t){let{signer:e,transaction:n}=t;if(!n.feePayerAddress)throw new Error(`Transaction ${n} is not a Fee Payer transaction`);return n.feePayerAddress=e.accountAddress,D({signer:e,transaction:n})}async function cn(t){let{aptosConfig:e,transaction:n,signerPublicKey:o,secondarySignersPublicKeys:a,feePayerPublicKey:i,options:r}=t,u=R({transaction:n,signerPublicKey:o,secondarySignersPublicKeys:a,feePayerPublicKey:i,options:r}),{data:A}=await d({aptosConfig:e,body:u,path:"transactions/simulate",params:{estimate_gas_unit_price:t.options?.estimateGasUnitPrice??!1,estimate_max_gas_amount:t.options?.estimateMaxGasAmount??!1,estimate_prioritized_gas_unit_price:t.options?.estimatePrioritizedGasUnitPrice??!1},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return A}async function U(t){let{aptosConfig:e}=t,n=x({...t});try{let{data:o}=await d({aptosConfig:e,body:n,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return o}catch(o){let a=b.deserialize(new T(n));throw a.authenticator.isSingleSender()&&a.authenticator.sender.isSingleKey()&&(a.authenticator.sender.public_key.publicKey instanceof P||a.authenticator.sender.public_key.publicKey instanceof h)&&await C.fetchJWK({aptosConfig:e,publicKey:a.authenticator.sender.public_key.publicKey,kid:a.authenticator.sender.signature.signature.getJwkKid()}),o}}async function O(t){let{aptosConfig:e,signer:n,feePayer:o,transaction:a}=t;y(n)&&await n.checkKeylessAccountValidity(e),y(o)&&await o.checkKeylessAccountValidity(e);let i=t.feePayerAuthenticator||o&&G({signer:o,transaction:a}),r=D({signer:n,transaction:a});return U({aptosConfig:e,transaction:a,senderAuthenticator:r,feePayerAuthenticator:i})}async function un(t){let{aptosConfig:e,senderAuthenticator:n,feePayer:o,transaction:a}=t;y(o)&&await o.checkKeylessAccountValidity(e);let i=G({signer:o,transaction:a});return U({aptosConfig:e,transaction:a,senderAuthenticator:n,feePayerAuthenticator:i})}var E={typeParameters:[],parameters:[c.u8(),new c(c.u8())]};async function pn(t){let{aptosConfig:e,account:n,metadataBytes:o,moduleBytecode:a,options:i}=t,r=a.map(u=>s.U8(u));return _({aptosConfig:e,sender:p.from(n),data:{function:"0x1::code::publish_package_txn",functionArguments:[s.U8(o),new s(r)],abi:E},options:i})}var V={typeParameters:[],parameters:[new m,c.u8(),new m,c.u8(),c.u8(),c.u8()]};async function yn(t){let{aptosConfig:e,fromAccount:n,toNewPrivateKey:o}=t,a=await K({aptosConfig:e,accountAddress:n.accountAddress}),i=S.fromPrivateKey({privateKey:o,legacy:!0}),u=new w({sequenceNumber:BigInt(a.sequence_number),originator:n.accountAddress,currentAuthKey:p.from(a.authentication_key),newPublicKey:i.publicKey}).bcsToBytes(),A=n.sign(u),B=i.sign(u),F=await _({aptosConfig:e,sender:n.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new f(n.signingScheme),s.U8(n.publicKey.toUint8Array()),new f(i.signingScheme),s.U8(i.publicKey.toUint8Array()),s.U8(A.toUint8Array()),s.U8(B.toUint8Array())],abi:V}});return O({aptosConfig:e,signer:n,transaction:F})}export{_ as a,k as b,v as c,sn as d,D as e,G as f,cn as g,U as h,O as i,un as j,pn as k,yn as l};
|
|
2
|
-
//# sourceMappingURL=chunk-53IBOHXB.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/internal/transactionSubmission.ts"],"sourcesContent":["/**\n * This file contains the underlying implementations for exposed submission API surface in\n * the {@link api/transaction}. By moving the methods out into a separate file,\n * other namespaces and processes can access these methods without depending on the entire\n * transaction namespace and without having a dependency cycle error.\n * @group Implementation\n */\n\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { Deserializer, MoveVector, U8 } from \"../bcs\";\nimport { postAptosFullNode } from \"../client\";\nimport { Account, AbstractKeylessAccount, isKeylessSigner } from \"../account\";\nimport { AccountAddress, AccountAddressInput } from \"../core/accountAddress\";\nimport { FederatedKeylessPublicKey, KeylessPublicKey, KeylessSignature, PrivateKeyInput } from \"../core/crypto\";\nimport { AccountAuthenticator } from \"../transactions/authenticator/account\";\nimport { RotationProofChallenge } from \"../transactions/instances/rotationProofChallenge\";\nimport {\n buildTransaction,\n generateTransactionPayload,\n generateSignedTransactionForSimulation,\n generateSignedTransaction,\n} from \"../transactions/transactionBuilder/transactionBuilder\";\nimport {\n InputGenerateTransactionData,\n AnyRawTransaction,\n InputSimulateTransactionData,\n InputGenerateTransactionOptions,\n InputGenerateTransactionPayloadDataWithRemoteABI,\n InputSubmitTransactionData,\n InputGenerateMultiAgentRawTransactionData,\n InputGenerateSingleSignerRawTransactionData,\n AnyTransactionPayloadInstance,\n EntryFunctionABI,\n} from \"../transactions/types\";\nimport { getInfo } from \"./account\";\nimport { UserTransactionResponse, PendingTransactionResponse, MimeType, HexInput, TransactionResponse } from \"../types\";\nimport { SignedTransaction, TypeTagU8, TypeTagVector, generateSigningMessageForTransaction } from \"../transactions\";\nimport { SimpleTransaction } from \"../transactions/instances/simpleTransaction\";\nimport { MultiAgentTransaction } from \"../transactions/instances/multiAgentTransaction\";\n\n/**\n * We are defining function signatures, each with its specific input and output.\n * These are the possible function signature for `generateTransaction` function.\n * When we call `generateTransaction` function with the relevant type properties,\n * Typescript can infer the return type based on the appropriate function overload.\n * @group Implementation\n */\nexport async function generateTransaction(\n args: { aptosConfig: AptosConfig } & InputGenerateSingleSignerRawTransactionData,\n): Promise<SimpleTransaction>;\nexport async function generateTransaction(\n args: { aptosConfig: AptosConfig } & InputGenerateMultiAgentRawTransactionData,\n): Promise<MultiAgentTransaction>;\n/**\n * Generates any transaction by passing in the required arguments\n *\n * @param args.sender The transaction sender's account address as a AccountAddressInput\n * @param args.data EntryFunctionData | ScriptData | MultiSigData\n * @param args.feePayerAddress optional. For a fee payer (aka sponsored) transaction\n * @param args.secondarySignerAddresses optional. For a multi-agent or fee payer (aka sponsored) transactions\n * @param args.options optional. GenerateTransactionOptions type\n *\n * @example\n * For a single signer entry function\n * move function name, move function type arguments, move function arguments\n * `\n * data: {\n * function:\"0x1::aptos_account::transfer\",\n * typeArguments:[]\n * functionArguments :[receiverAddress,10]\n * }\n * `\n *\n * @example\n * For a single signer script function\n * module bytecode, move function type arguments, move function arguments\n * ```\n * data: {\n * bytecode:\"0x001234567\",\n * typeArguments:[],\n * functionArguments :[receiverAddress,10]\n * }\n * ```\n *\n * @return An instance of a RawTransaction, plus optional secondary/fee payer addresses\n * ```\n * {\n * rawTransaction: RawTransaction,\n * secondarySignerAddresses?: Array<AccountAddress>,\n * feePayerAddress?: AccountAddress\n * }\n * ```\n * @group Implementation\n */\nexport async function generateTransaction(\n args: { aptosConfig: AptosConfig } & InputGenerateTransactionData,\n): Promise<AnyRawTransaction> {\n const payload = await buildTransactionPayload(args);\n return buildRawTransaction(args, payload);\n}\n\n/**\n * Builds a transaction payload based on the provided configuration and input data.\n * This function is essential for preparing transaction data for execution on the Aptos blockchain.\n *\n * @param args - The arguments for building the transaction payload.\n * @param args.aptosConfig - Configuration settings for the Aptos network.\n * @param args.data - Input data required to generate the transaction payload, which may include bytecode, multisig address,\n * function name, function arguments, type arguments, and ABI.\n * @returns A promise that resolves to the generated transaction payload instance.\n * @group Implementation\n */\nexport async function buildTransactionPayload(\n args: { aptosConfig: AptosConfig } & InputGenerateTransactionData,\n): Promise<AnyTransactionPayloadInstance> {\n const { aptosConfig, data } = args;\n // Merge in aptosConfig for remote ABI on non-script payloads\n let generateTransactionPayloadData: InputGenerateTransactionPayloadDataWithRemoteABI;\n let payload: AnyTransactionPayloadInstance;\n\n if (\"bytecode\" in data) {\n // TODO: Add ABI checking later\n payload = await generateTransactionPayload(data);\n } else if (\"multisigAddress\" in data) {\n generateTransactionPayloadData = {\n aptosConfig,\n multisigAddress: data.multisigAddress,\n function: data.function,\n functionArguments: data.functionArguments,\n typeArguments: data.typeArguments,\n abi: data.abi,\n };\n payload = await generateTransactionPayload(generateTransactionPayloadData);\n } else {\n generateTransactionPayloadData = {\n aptosConfig,\n function: data.function,\n functionArguments: data.functionArguments,\n typeArguments: data.typeArguments,\n abi: data.abi,\n };\n payload = await generateTransactionPayload(generateTransactionPayloadData);\n }\n return payload;\n}\n\n/**\n * Builds a raw transaction based on the provided configuration and payload.\n * This function helps in creating a transaction that can be sent to the Aptos blockchain.\n *\n * @param args - The arguments for generating the transaction.\n * @param args.aptosConfig - The configuration settings for Aptos.\n * @param args.sender - The address of the sender of the transaction.\n * @param args.options - Additional options for the transaction.\n * @param payload - The payload of the transaction, which defines the action to be performed.\n * @group Implementation\n */\nexport async function buildRawTransaction(\n args: { aptosConfig: AptosConfig } & InputGenerateTransactionData,\n payload: AnyTransactionPayloadInstance,\n): Promise<AnyRawTransaction> {\n const { aptosConfig, sender, options } = args;\n\n let feePayerAddress;\n if (isFeePayerTransactionInput(args)) {\n feePayerAddress = AccountAddress.ZERO.toString();\n }\n\n if (isMultiAgentTransactionInput(args)) {\n const { secondarySignerAddresses } = args;\n return buildTransaction({\n aptosConfig,\n sender,\n payload,\n options,\n secondarySignerAddresses,\n feePayerAddress,\n });\n }\n\n return buildTransaction({\n aptosConfig,\n sender,\n payload,\n options,\n feePayerAddress,\n });\n}\n\n/**\n * Determine if the transaction input includes a fee payer.\n *\n * @param data - The input data for generating a transaction.\n * @param data.withFeePayer - Indicates whether a fee payer is included in the transaction input.\n * @returns A boolean value indicating if the transaction input has a fee payer.\n * @group Implementation\n */\nfunction isFeePayerTransactionInput(data: InputGenerateTransactionData): boolean {\n return data.withFeePayer === true;\n}\n\n/**\n * Determines whether the provided transaction input data includes multiple agent signatures.\n *\n * @param data - The transaction input data to evaluate.\n * @param data.secondarySignerAddresses - An array of secondary signer addresses, indicating multiple agents.\n * @group Implementation\n */\nfunction isMultiAgentTransactionInput(\n data: InputGenerateTransactionData,\n): data is InputGenerateMultiAgentRawTransactionData {\n return \"secondarySignerAddresses\" in data;\n}\n\n/**\n * Builds a signing message that can be signed by external signers.\n *\n * Note: Please prefer using `signTransaction` unless signing outside the SDK.\n *\n * @param args - The arguments for generating the signing message.\n * @param args.transaction - AnyRawTransaction, as generated by `generateTransaction()`.\n *\n * @returns The message to be signed.\n * @group Implementation\n */\nexport function getSigningMessage(args: { transaction: AnyRawTransaction }): Uint8Array {\n const { transaction } = args;\n return generateSigningMessageForTransaction(transaction);\n}\n\n/**\n * Sign a transaction that can later be submitted to the chain.\n *\n * @param args The arguments for signing the transaction.\n * @param args.signer The signer account to sign the transaction.\n * @param args.transaction An instance of a RawTransaction, plus optional secondary/fee payer addresses.\n *\n * @return The signer AccountAuthenticator.\n * @group Implementation\n */\nexport function signTransaction(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {\n const { signer, transaction } = args;\n return signer.signTransactionWithAuthenticator(transaction);\n}\n\nexport function signAsFeePayer(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {\n const { signer, transaction } = args;\n\n // if transaction doesn't hold a \"feePayerAddress\" prop it means\n // this is not a fee payer transaction\n if (!transaction.feePayerAddress) {\n throw new Error(`Transaction ${transaction} is not a Fee Payer transaction`);\n }\n\n // Set the feePayerAddress to the signer account address\n transaction.feePayerAddress = signer.accountAddress;\n\n return signTransaction({\n signer,\n transaction,\n });\n}\n\n/**\n * Simulates a transaction before signing it to evaluate its potential outcome.\n *\n * @param args The arguments for simulating the transaction.\n * @param args.aptosConfig The configuration for the Aptos network.\n * @param args.transaction The raw transaction to simulate.\n * @param args.signerPublicKey Optional. The signer public key.\n * @param args.secondarySignersPublicKeys Optional. For when the transaction involves multiple signers.\n * @param args.feePayerPublicKey Optional. For when the transaction is sponsored by a fee payer.\n * @param args.options Optional. A configuration object to customize the simulation process.\n * @param args.options.estimateGasUnitPrice Optional. Indicates whether to estimate the gas unit price.\n * @param args.options.estimateMaxGasAmount Optional. Indicates whether to estimate the maximum gas amount.\n * @param args.options.estimatePrioritizedGasUnitPrice Optional. Indicates whether to estimate the prioritized gas unit price.\n * @group Implementation\n */\nexport async function simulateTransaction(\n args: { aptosConfig: AptosConfig } & InputSimulateTransactionData,\n): Promise<Array<UserTransactionResponse>> {\n const { aptosConfig, transaction, signerPublicKey, secondarySignersPublicKeys, feePayerPublicKey, options } = args;\n\n const signedTransaction = generateSignedTransactionForSimulation({\n transaction,\n signerPublicKey,\n secondarySignersPublicKeys,\n feePayerPublicKey,\n options,\n });\n\n const { data } = await postAptosFullNode<Uint8Array, Array<UserTransactionResponse>>({\n aptosConfig,\n body: signedTransaction,\n path: \"transactions/simulate\",\n params: {\n estimate_gas_unit_price: args.options?.estimateGasUnitPrice ?? false,\n estimate_max_gas_amount: args.options?.estimateMaxGasAmount ?? false,\n estimate_prioritized_gas_unit_price: args.options?.estimatePrioritizedGasUnitPrice ?? false,\n },\n originMethod: \"simulateTransaction\",\n contentType: MimeType.BCS_SIGNED_TRANSACTION,\n });\n return data;\n}\n\n/**\n * Submit a transaction to the Aptos blockchain.\n *\n * @param args - The arguments for submitting the transaction.\n * @param args.aptosConfig - The configuration for connecting to the Aptos network.\n * @param args.transaction - The Aptos transaction data to be submitted.\n * @param args.senderAuthenticator - The account authenticator of the transaction sender.\n * @param args.secondarySignerAuthenticators - Optional. Authenticators for additional signers in a multi-signer transaction.\n *\n * @returns PendingTransactionResponse - The response containing the status of the submitted transaction.\n * @group Implementation\n */\nexport async function submitTransaction(\n args: {\n aptosConfig: AptosConfig;\n } & InputSubmitTransactionData,\n): Promise<PendingTransactionResponse> {\n const { aptosConfig } = args;\n const signedTransaction = generateSignedTransaction({ ...args });\n try {\n const { data } = await postAptosFullNode<Uint8Array, PendingTransactionResponse>({\n aptosConfig,\n body: signedTransaction,\n path: \"transactions\",\n originMethod: \"submitTransaction\",\n contentType: MimeType.BCS_SIGNED_TRANSACTION,\n });\n return data;\n } catch (e) {\n const signedTxn = SignedTransaction.deserialize(new Deserializer(signedTransaction));\n if (\n signedTxn.authenticator.isSingleSender() &&\n signedTxn.authenticator.sender.isSingleKey() &&\n (signedTxn.authenticator.sender.public_key.publicKey instanceof KeylessPublicKey ||\n signedTxn.authenticator.sender.public_key.publicKey instanceof FederatedKeylessPublicKey)\n ) {\n await AbstractKeylessAccount.fetchJWK({\n aptosConfig,\n publicKey: signedTxn.authenticator.sender.public_key.publicKey,\n kid: (signedTxn.authenticator.sender.signature.signature as KeylessSignature).getJwkKid(),\n });\n }\n throw e;\n }\n}\n\nexport type FeePayerOrFeePayerAuthenticatorOrNeither =\n | { feePayer: Account; feePayerAuthenticator?: never }\n | { feePayer?: never; feePayerAuthenticator: AccountAuthenticator }\n | { feePayer?: never; feePayerAuthenticator?: never };\n\nexport async function signAndSubmitTransaction(\n args: FeePayerOrFeePayerAuthenticatorOrNeither & {\n aptosConfig: AptosConfig;\n signer: Account;\n transaction: AnyRawTransaction;\n },\n): Promise<PendingTransactionResponse> {\n const { aptosConfig, signer, feePayer, transaction } = args;\n // If the signer contains a KeylessAccount, await proof fetching in case the proof\n // was fetched asynchronously.\n if (isKeylessSigner(signer)) {\n await signer.checkKeylessAccountValidity(aptosConfig);\n }\n if (isKeylessSigner(feePayer)) {\n await feePayer.checkKeylessAccountValidity(aptosConfig);\n }\n const feePayerAuthenticator =\n args.feePayerAuthenticator || (feePayer && signAsFeePayer({ signer: feePayer, transaction }));\n\n const senderAuthenticator = signTransaction({ signer, transaction });\n return submitTransaction({\n aptosConfig,\n transaction,\n senderAuthenticator,\n feePayerAuthenticator,\n });\n}\n\nexport async function signAndSubmitAsFeePayer(args: {\n aptosConfig: AptosConfig;\n feePayer: Account;\n senderAuthenticator: AccountAuthenticator;\n transaction: AnyRawTransaction;\n}): Promise<PendingTransactionResponse> {\n const { aptosConfig, senderAuthenticator, feePayer, transaction } = args;\n\n if (isKeylessSigner(feePayer)) {\n await feePayer.checkKeylessAccountValidity(aptosConfig);\n }\n\n const feePayerAuthenticator = signAsFeePayer({ signer: feePayer, transaction });\n\n return submitTransaction({\n aptosConfig,\n transaction,\n senderAuthenticator,\n feePayerAuthenticator,\n });\n}\n\nconst packagePublishAbi: EntryFunctionABI = {\n typeParameters: [],\n parameters: [TypeTagVector.u8(), new TypeTagVector(TypeTagVector.u8())],\n};\n\n/**\n * Publishes a package transaction to the Aptos blockchain.\n * This function allows you to create and send a transaction that publishes a package with the specified metadata and bytecode.\n *\n * @param args - The arguments for the package transaction.\n * @param args.aptosConfig - The configuration settings for the Aptos client.\n * @param args.account - The address of the account sending the transaction.\n * @param args.metadataBytes - The metadata associated with the package, represented as hexadecimal input.\n * @param args.moduleBytecode - An array of module bytecode, each represented as hexadecimal input.\n * @param args.options - Optional parameters for generating the transaction.\n * @group Implementation\n */\nexport async function publicPackageTransaction(args: {\n aptosConfig: AptosConfig;\n account: AccountAddressInput;\n metadataBytes: HexInput;\n moduleBytecode: Array<HexInput>;\n options?: InputGenerateTransactionOptions;\n}): Promise<SimpleTransaction> {\n const { aptosConfig, account, metadataBytes, moduleBytecode, options } = args;\n\n const totalByteCode = moduleBytecode.map((bytecode) => MoveVector.U8(bytecode));\n\n return generateTransaction({\n aptosConfig,\n sender: AccountAddress.from(account),\n data: {\n function: \"0x1::code::publish_package_txn\",\n functionArguments: [MoveVector.U8(metadataBytes), new MoveVector(totalByteCode)],\n abi: packagePublishAbi,\n },\n options,\n });\n}\n\nconst rotateAuthKeyAbi: EntryFunctionABI = {\n typeParameters: [],\n parameters: [\n new TypeTagU8(),\n TypeTagVector.u8(),\n new TypeTagU8(),\n TypeTagVector.u8(),\n TypeTagVector.u8(),\n TypeTagVector.u8(),\n ],\n};\n\n/**\n * Rotates the authentication key for a given account, allowing for enhanced security and management of account access.\n *\n * @param args - The arguments for rotating the authentication key.\n * @param args.aptosConfig - The configuration settings for the Aptos network.\n * @param args.fromAccount - The account from which the authentication key will be rotated.\n * @param args.toNewPrivateKey - The new private key that will be associated with the account.\n *\n * @remarks\n * This function requires the current authentication key and the new private key to sign a challenge that validates the rotation.\n *\n * TODO: Need to refactor and move this function out of transactionSubmission.\n * @group Implementation\n */\nexport async function rotateAuthKey(args: {\n aptosConfig: AptosConfig;\n fromAccount: Account;\n toNewPrivateKey: PrivateKeyInput;\n}): Promise<TransactionResponse> {\n const { aptosConfig, fromAccount, toNewPrivateKey } = args;\n const accountInfo = await getInfo({\n aptosConfig,\n accountAddress: fromAccount.accountAddress,\n });\n\n const newAccount = Account.fromPrivateKey({ privateKey: toNewPrivateKey, legacy: true });\n\n const challenge = new RotationProofChallenge({\n sequenceNumber: BigInt(accountInfo.sequence_number),\n originator: fromAccount.accountAddress,\n currentAuthKey: AccountAddress.from(accountInfo.authentication_key),\n newPublicKey: newAccount.publicKey,\n });\n\n // Sign the challenge\n const challengeHex = challenge.bcsToBytes();\n const proofSignedByCurrentPrivateKey = fromAccount.sign(challengeHex);\n const proofSignedByNewPrivateKey = newAccount.sign(challengeHex);\n\n // Generate transaction\n const rawTxn = await generateTransaction({\n aptosConfig,\n sender: fromAccount.accountAddress,\n data: {\n function: \"0x1::account::rotate_authentication_key\",\n functionArguments: [\n new U8(fromAccount.signingScheme), // from scheme\n MoveVector.U8(fromAccount.publicKey.toUint8Array()),\n new U8(newAccount.signingScheme), // to scheme\n MoveVector.U8(newAccount.publicKey.toUint8Array()),\n MoveVector.U8(proofSignedByCurrentPrivateKey.toUint8Array()),\n MoveVector.U8(proofSignedByNewPrivateKey.toUint8Array()),\n ],\n abi: rotateAuthKeyAbi,\n },\n });\n return signAndSubmitTransaction({\n aptosConfig,\n signer: fromAccount,\n transaction: rawTxn,\n });\n}\n"],"mappings":"0oBA8FA,eAAsBA,EACpBC,EAC4B,CAC5B,IAAMC,EAAU,MAAMC,EAAwBF,CAAI,EAClD,OAAOG,EAAoBH,EAAMC,CAAO,CAC1C,CAaA,eAAsBC,EACpBF,EACwC,CACxC,GAAM,CAAE,YAAAI,EAAa,KAAAC,CAAK,EAAIL,EAE1BM,EACAL,EAEJ,MAAI,aAAcI,EAEhBJ,EAAU,MAAMM,EAA2BF,CAAI,EACtC,oBAAqBA,GAC9BC,EAAiC,CAC/B,YAAAF,EACA,gBAAiBC,EAAK,gBACtB,SAAUA,EAAK,SACf,kBAAmBA,EAAK,kBACxB,cAAeA,EAAK,cACpB,IAAKA,EAAK,GACZ,EACAJ,EAAU,MAAMM,EAA2BD,CAA8B,IAEzEA,EAAiC,CAC/B,YAAAF,EACA,SAAUC,EAAK,SACf,kBAAmBA,EAAK,kBACxB,cAAeA,EAAK,cACpB,IAAKA,EAAK,GACZ,EACAJ,EAAU,MAAMM,EAA2BD,CAA8B,GAEpEL,CACT,CAaA,eAAsBE,EACpBH,EACAC,EAC4B,CAC5B,GAAM,CAAE,YAAAG,EAAa,OAAAI,EAAQ,QAAAC,CAAQ,EAAIT,EAErCU,EAKJ,GAJIC,EAA2BX,CAAI,IACjCU,EAAkBE,EAAe,KAAK,SAAS,GAG7CC,EAA6Bb,CAAI,EAAG,CACtC,GAAM,CAAE,yBAAAc,CAAyB,EAAId,EACrC,OAAOe,EAAiB,CACtB,YAAAX,EACA,OAAAI,EACA,QAAAP,EACA,QAAAQ,EACA,yBAAAK,EACA,gBAAAJ,CACF,CAAC,CACH,CAEA,OAAOK,EAAiB,CACtB,YAAAX,EACA,OAAAI,EACA,QAAAP,EACA,QAAAQ,EACA,gBAAAC,CACF,CAAC,CACH,CAUA,SAASC,EAA2BN,EAA6C,CAC/E,OAAOA,EAAK,eAAiB,EAC/B,CASA,SAASQ,EACPR,EACmD,CACnD,MAAO,6BAA8BA,CACvC,CAaO,SAASW,GAAkBhB,EAAsD,CACtF,GAAM,CAAE,YAAAiB,CAAY,EAAIjB,EACxB,OAAOkB,EAAqCD,CAAW,CACzD,CAYO,SAASE,EAAgBnB,EAAiF,CAC/G,GAAM,CAAE,OAAAoB,EAAQ,YAAAH,CAAY,EAAIjB,EAChC,OAAOoB,EAAO,iCAAiCH,CAAW,CAC5D,CAEO,SAASI,EAAerB,EAAiF,CAC9G,GAAM,CAAE,OAAAoB,EAAQ,YAAAH,CAAY,EAAIjB,EAIhC,GAAI,CAACiB,EAAY,gBACf,MAAM,IAAI,MAAM,eAAeA,CAAW,iCAAiC,EAI7E,OAAAA,EAAY,gBAAkBG,EAAO,eAE9BD,EAAgB,CACrB,OAAAC,EACA,YAAAH,CACF,CAAC,CACH,CAiBA,eAAsBK,GACpBtB,EACyC,CACzC,GAAM,CAAE,YAAAI,EAAa,YAAAa,EAAa,gBAAAM,EAAiB,2BAAAC,EAA4B,kBAAAC,EAAmB,QAAAhB,CAAQ,EAAIT,EAExG0B,EAAoBC,EAAuC,CAC/D,YAAAV,EACA,gBAAAM,EACA,2BAAAC,EACA,kBAAAC,EACA,QAAAhB,CACF,CAAC,EAEK,CAAE,KAAAJ,CAAK,EAAI,MAAMuB,EAA8D,CACnF,YAAAxB,EACA,KAAMsB,EACN,KAAM,wBACN,OAAQ,CACN,wBAAyB1B,EAAK,SAAS,sBAAwB,GAC/D,wBAAyBA,EAAK,SAAS,sBAAwB,GAC/D,oCAAqCA,EAAK,SAAS,iCAAmC,EACxF,EACA,aAAc,sBACd,wDACF,CAAC,EACD,OAAOK,CACT,CAcA,eAAsBwB,EACpB7B,EAGqC,CACrC,GAAM,CAAE,YAAAI,CAAY,EAAIJ,EAClB0B,EAAoBI,EAA0B,CAAE,GAAG9B,CAAK,CAAC,EAC/D,GAAI,CACF,GAAM,CAAE,KAAAK,CAAK,EAAI,MAAMuB,EAA0D,CAC/E,YAAAxB,EACA,KAAMsB,EACN,KAAM,eACN,aAAc,oBACd,wDACF,CAAC,EACD,OAAOrB,CACT,OAAS0B,EAAG,CACV,IAAMC,EAAYC,EAAkB,YAAY,IAAIC,EAAaR,CAAiB,CAAC,EACnF,MACEM,EAAU,cAAc,eAAe,GACvCA,EAAU,cAAc,OAAO,YAAY,IAC1CA,EAAU,cAAc,OAAO,WAAW,qBAAqBG,GAC9DH,EAAU,cAAc,OAAO,WAAW,qBAAqBI,IAEjE,MAAMC,EAAuB,SAAS,CACpC,YAAAjC,EACA,UAAW4B,EAAU,cAAc,OAAO,WAAW,UACrD,IAAMA,EAAU,cAAc,OAAO,UAAU,UAA+B,UAAU,CAC1F,CAAC,EAEGD,CACR,CACF,CAOA,eAAsBO,EACpBtC,EAKqC,CACrC,GAAM,CAAE,YAAAI,EAAa,OAAAgB,EAAQ,SAAAmB,EAAU,YAAAtB,CAAY,EAAIjB,EAGnDwC,EAAgBpB,CAAM,GACxB,MAAMA,EAAO,4BAA4BhB,CAAW,EAElDoC,EAAgBD,CAAQ,GAC1B,MAAMA,EAAS,4BAA4BnC,CAAW,EAExD,IAAMqC,EACJzC,EAAK,uBAA0BuC,GAAYlB,EAAe,CAAE,OAAQkB,EAAU,YAAAtB,CAAY,CAAC,EAEvFyB,EAAsBvB,EAAgB,CAAE,OAAAC,EAAQ,YAAAH,CAAY,CAAC,EACnE,OAAOY,EAAkB,CACvB,YAAAzB,EACA,YAAAa,EACA,oBAAAyB,EACA,sBAAAD,CACF,CAAC,CACH,CAEA,eAAsBE,GAAwB3C,EAKN,CACtC,GAAM,CAAE,YAAAI,EAAa,oBAAAsC,EAAqB,SAAAH,EAAU,YAAAtB,CAAY,EAAIjB,EAEhEwC,EAAgBD,CAAQ,GAC1B,MAAMA,EAAS,4BAA4BnC,CAAW,EAGxD,IAAMqC,EAAwBpB,EAAe,CAAE,OAAQkB,EAAU,YAAAtB,CAAY,CAAC,EAE9E,OAAOY,EAAkB,CACvB,YAAAzB,EACA,YAAAa,EACA,oBAAAyB,EACA,sBAAAD,CACF,CAAC,CACH,CAEA,IAAMG,EAAsC,CAC1C,eAAgB,CAAC,EACjB,WAAY,CAACC,EAAc,GAAG,EAAG,IAAIA,EAAcA,EAAc,GAAG,CAAC,CAAC,CACxE,EAcA,eAAsBC,GAAyB9C,EAMhB,CAC7B,GAAM,CAAE,YAAAI,EAAa,QAAA2C,EAAS,cAAAC,EAAe,eAAAC,EAAgB,QAAAxC,CAAQ,EAAIT,EAEnEkD,EAAgBD,EAAe,IAAKE,GAAaC,EAAW,GAAGD,CAAQ,CAAC,EAE9E,OAAOpD,EAAoB,CACzB,YAAAK,EACA,OAAQQ,EAAe,KAAKmC,CAAO,EACnC,KAAM,CACJ,SAAU,iCACV,kBAAmB,CAACK,EAAW,GAAGJ,CAAa,EAAG,IAAII,EAAWF,CAAa,CAAC,EAC/E,IAAKN,CACP,EACA,QAAAnC,CACF,CAAC,CACH,CAEA,IAAM4C,EAAqC,CACzC,eAAgB,CAAC,EACjB,WAAY,CACV,IAAIC,EACJT,EAAc,GAAG,EACjB,IAAIS,EACJT,EAAc,GAAG,EACjBA,EAAc,GAAG,EACjBA,EAAc,GAAG,CACnB,CACF,EAgBA,eAAsBU,GAAcvD,EAIH,CAC/B,GAAM,CAAE,YAAAI,EAAa,YAAAoD,EAAa,gBAAAC,CAAgB,EAAIzD,EAChD0D,EAAc,MAAMC,EAAQ,CAChC,YAAAvD,EACA,eAAgBoD,EAAY,cAC9B,CAAC,EAEKI,EAAaC,EAAQ,eAAe,CAAE,WAAYJ,EAAiB,OAAQ,EAAK,CAAC,EAUjFK,EARY,IAAIC,EAAuB,CAC3C,eAAgB,OAAOL,EAAY,eAAe,EAClD,WAAYF,EAAY,eACxB,eAAgB5C,EAAe,KAAK8C,EAAY,kBAAkB,EAClE,aAAcE,EAAW,SAC3B,CAAC,EAG8B,WAAW,EACpCI,EAAiCR,EAAY,KAAKM,CAAY,EAC9DG,EAA6BL,EAAW,KAAKE,CAAY,EAGzDI,EAAS,MAAMnE,EAAoB,CACvC,YAAAK,EACA,OAAQoD,EAAY,eACpB,KAAM,CACJ,SAAU,0CACV,kBAAmB,CACjB,IAAIW,EAAGX,EAAY,aAAa,EAChCJ,EAAW,GAAGI,EAAY,UAAU,aAAa,CAAC,EAClD,IAAIW,EAAGP,EAAW,aAAa,EAC/BR,EAAW,GAAGQ,EAAW,UAAU,aAAa,CAAC,EACjDR,EAAW,GAAGY,EAA+B,aAAa,CAAC,EAC3DZ,EAAW,GAAGa,EAA2B,aAAa,CAAC,CACzD,EACA,IAAKZ,CACP,CACF,CAAC,EACD,OAAOf,EAAyB,CAC9B,YAAAlC,EACA,OAAQoD,EACR,YAAaU,CACf,CAAC,CACH","names":["generateTransaction","args","payload","buildTransactionPayload","buildRawTransaction","aptosConfig","data","generateTransactionPayloadData","generateTransactionPayload","sender","options","feePayerAddress","isFeePayerTransactionInput","AccountAddress","isMultiAgentTransactionInput","secondarySignerAddresses","buildTransaction","getSigningMessage","transaction","generateSigningMessageForTransaction","signTransaction","signer","signAsFeePayer","simulateTransaction","signerPublicKey","secondarySignersPublicKeys","feePayerPublicKey","signedTransaction","generateSignedTransactionForSimulation","postAptosFullNode","submitTransaction","generateSignedTransaction","e","signedTxn","SignedTransaction","Deserializer","KeylessPublicKey","FederatedKeylessPublicKey","AbstractKeylessAccount","signAndSubmitTransaction","feePayer","isKeylessSigner","feePayerAuthenticator","senderAuthenticator","signAndSubmitAsFeePayer","packagePublishAbi","TypeTagVector","publicPackageTransaction","account","metadataBytes","moduleBytecode","totalByteCode","bytecode","MoveVector","rotateAuthKeyAbi","TypeTagU8","rotateAuthKey","fromAccount","toNewPrivateKey","accountInfo","getInfo","newAccount","Account","challengeHex","RotationProofChallenge","proofSignedByCurrentPrivateKey","proofSignedByNewPrivateKey","rawTxn","U8"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as n}from"./chunk-PDAWVDI7.mjs";import{b as a}from"./chunk-LQOSHBB7.mjs";import{a as v}from"./chunk-RXHER6EA.mjs";var t=class i extends v{deserialize(e){let r=a.deserialize(e),s=n.deserialize(e),l=n.deserialize(e),b=e.deserializeVector(i);return new o(r,s,l,b)}static deserialize(e){let r=e.deserializeUleb128AsU32();switch(r){case 0:return u.load(e);case 1:return c.load(e);case 2:return p.load(e);case 3:return z.load(e);case 4:return T.load(e);case 5:return S.load(e);case 6:return f.load(e);case 7:return y.load(e);case 8:return d.load(e);case 9:return g.load(e);case 10:return h.load(e);case 255:return U.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${r}`)}}isBool(){return this instanceof u}isAddress(){return this instanceof T}isGeneric(){return this instanceof U}isSigner(){return this instanceof S}isVector(){return this instanceof f}isStruct(){return this instanceof y}isU8(){return this instanceof c}isU16(){return this instanceof d}isU32(){return this instanceof g}isU64(){return this instanceof p}isU128(){return this instanceof z}isU256(){return this instanceof h}isPrimitive(){return this instanceof S||this instanceof T||this instanceof u||this instanceof c||this instanceof d||this instanceof g||this instanceof p||this instanceof z||this instanceof h}},u=class i extends t{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new i}},c=class i extends t{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new i}},d=class i extends t{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new i}},g=class i extends t{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new i}},p=class i extends t{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new i}},z=class i extends t{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new i}},h=class i extends t{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new i}},T=class i extends t{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new i}},S=class i extends t{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new i}},x=class i extends t{constructor(r){super();this.value=r}toString(){return`&${this.value.toString()}`}serialize(r){r.serializeU32AsUleb128(254)}static load(r){let s=t.deserialize(r);return new i(s)}},U=class i extends t{constructor(r){super();this.value=r;if(r<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(r){r.serializeU32AsUleb128(255),r.serializeU32(this.value)}static load(r){let s=r.deserializeU32();return new i(s)}},f=class i extends t{constructor(r){super();this.value=r}toString(){return`vector<${this.value.toString()}>`}static u8(){return new i(new c)}serialize(r){r.serializeU32AsUleb128(6),this.value.serialize(r)}static load(r){let s=t.deserialize(r);return new i(s)}},y=class i extends t{constructor(r){super();this.value=r}toString(){let r="";return this.value.typeArgs.length>0&&(r=`<${this.value.typeArgs.map(s=>s.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${r}`}serialize(r){r.serializeU32AsUleb128(7),this.value.serialize(r)}static load(r){let s=o.deserialize(r);return new i(s)}isTypeTag(r,s,l){return this.value.moduleName.identifier===s&&this.value.name.identifier===l&&this.value.address.equals(r)}isString(){return this.isTypeTag(a.ONE,"string","String")}isOption(){return this.isTypeTag(a.ONE,"option","Option")}isObject(){return this.isTypeTag(a.ONE,"object","Object")}},o=class i extends v{constructor(e,r,s,l){super(),this.address=e,this.moduleName=r,this.name=s,this.typeArgs=l}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let r=a.deserialize(e),s=n.deserialize(e),l=n.deserialize(e),b=e.deserializeVector(t);return new i(r,s,l,b)}};function O(){return new o(a.ONE,new n("aptos_coin"),new n("AptosCoin"),[])}function E(){return new o(a.ONE,new n("string"),new n("String"),[])}function V(i){return new o(a.ONE,new n("option"),new n("Option"),[i])}function j(i){return new o(a.ONE,new n("object"),new n("Object"),[i])}export{t as a,u as b,c,d,g as e,p as f,z as g,h,T as i,S as j,x as k,U as l,f as m,y as n,o,O as p,E as q,V as r,j as s};
|
|
2
|
-
//# sourceMappingURL=chunk-5W2ERBGY.mjs.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as u}from"./chunk-53IBOHXB.mjs";import{h as M}from"./chunk-XRVZAEQO.mjs";import{c as R}from"./chunk-GI4AR6DQ.mjs";import{c as k}from"./chunk-KK5HUWF6.mjs";import{A as V,m as O,y as q,z as G}from"./chunk-VHNX2NUR.mjs";import{b as w,f as h,i as x,l as A,m as f,n as i,q as p,s as y}from"./chunk-5W2ERBGY.mjs";import{a as _,c as d}from"./chunk-HHWJHOFZ.mjs";import{a as T,e as D}from"./chunk-TKXEVD7A.mjs";import{b as c}from"./chunk-LQOSHBB7.mjs";import{d as E}from"./chunk-56CNRT2K.mjs";var C={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},l="0x4::token::Token";async function It(t){let{aptosConfig:o,digitalAssetAddress:n}=t,e={token_data_id:{_eq:c.from(n).toStringLong()}};return(await k({aptosConfig:o,query:{query:V,variables:{where_condition:e}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function Pt(t){let{aptosConfig:o,digitalAssetAddress:n}=t,e={token_data_id:{_eq:c.from(n).toStringLong()},amount:{_gt:0}};return(await k({aptosConfig:o,query:{query:G,variables:{where_condition:e}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function bt(t){let{aptosConfig:o,ownerAddress:n,options:e}=t,r={owner_address:{_eq:c.from(n).toStringLong()},amount:{_gt:0}},s={query:G,variables:{where_condition:r,offset:e?.offset,limit:e?.limit,order_by:e?.orderBy}};return(await k({aptosConfig:o,query:s,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function St(t){let{aptosConfig:o,digitalAssetAddress:n,options:e}=t,r={token_data_id:{_eq:c.from(n).toStringLong()}},s={query:q,variables:{where_condition:r,offset:e?.offset,limit:e?.limit,order_by:e?.orderBy}};return(await k({aptosConfig:o,query:s,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var F={typeParameters:[],parameters:[new i(p()),new h,new i(p()),new i(p()),new w,new w,new w,new w,new w,new w,new w,new w,new w,new h,new h]};async function Dt(t){let{aptosConfig:o,options:n,creator:e}=t;return u({aptosConfig:o,sender:e.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new d(t.description),new D(t.maxSupply??E),new d(t.name),new d(t.uri),new T(t.mutableDescription??!0),new T(t.mutableRoyalty??!0),new T(t.mutableURI??!0),new T(t.mutableTokenDescription??!0),new T(t.mutableTokenName??!0),new T(t.mutableTokenProperties??!0),new T(t.mutableTokenURI??!0),new T(t.tokensBurnableByCreator??!0),new T(t.tokensFreezableByCreator??!0),new D(t.royaltyNumerator??0),new D(t.royaltyDenominator??1)],abi:F},options:n})}async function v(t){let{aptosConfig:o,options:n}=t,e=n?.where;n?.tokenStandard&&(e.token_standard={_eq:n?.tokenStandard??"v2"});let r={query:O,variables:{where_condition:e,offset:n?.offset,limit:n?.limit}};return(await k({aptosConfig:o,query:r,originMethod:"getCollectionData"})).current_collections_v2[0]}async function ht(t){let{aptosConfig:o,creatorAddress:n,collectionName:e,options:r}=t,s=c.from(n),a={collection_name:{_eq:e},creator_address:{_eq:s.toStringLong()}};return r?.tokenStandard&&(a.token_standard={_eq:r?.tokenStandard??"v2"}),v({aptosConfig:o,options:{...r,where:a}})}async function vt(t){let{aptosConfig:o,creatorAddress:n,options:e}=t,s={creator_address:{_eq:c.from(n).toStringLong()}};return e?.tokenStandard&&(s.token_standard={_eq:e?.tokenStandard??"v2"}),v({aptosConfig:o,options:{...e,where:s}})}async function xt(t){let{aptosConfig:o,collectionId:n,options:e}=t,s={collection_id:{_eq:c.from(n).toStringLong()}};return e?.tokenStandard&&(s.token_standard={_eq:e?.tokenStandard??"v2"}),v({aptosConfig:o,options:{...e,where:s}})}async function Gt(t){let{creatorAddress:o,collectionName:n,options:e,aptosConfig:r}=t,s=c.from(o),a={collection_name:{_eq:n},creator_address:{_eq:s.toStringLong()}};return e?.tokenStandard&&(a.token_standard={_eq:e?.tokenStandard??"v2"}),(await v({aptosConfig:r,options:{where:a}})).collection_id}var N={typeParameters:[],parameters:[new i(p()),new i(p()),new i(p()),new i(p()),new f(new i(p())),new f(new i(p())),new f(f.u8())]};async function Bt(t){let{aptosConfig:o,options:n,creator:e,collection:r,description:s,name:a,uri:m,propertyKeys:g,propertyTypes:P,propertyValues:I}=t,b=P?.map(S=>C[S]);return u({aptosConfig:o,sender:e.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new d(r),new d(s),new d(a),new d(m),_.MoveString(g??[]),_.MoveString(b??[]),K(I??[],b??[])],abi:N},options:n})}var Q={typeParameters:[{constraints:["key"]}],parameters:[new i(y(new A(0))),new x]};async function Et(t){let{aptosConfig:o,sender:n,digitalAssetAddress:e,recipient:r,digitalAssetType:s,options:a}=t;return u({aptosConfig:o,sender:n.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[s??l],functionArguments:[c.from(e),c.from(r)],abi:Q},options:a})}var Y={typeParameters:[],parameters:[new i(p()),new i(p()),new i(p()),new i(p()),new f(new i(p())),new f(new i(p())),new f(f.u8()),new x]};async function Ot(t){let{aptosConfig:o,account:n,collection:e,description:r,name:s,uri:a,recipient:m,propertyKeys:g,propertyTypes:P,propertyValues:I,options:b}=t;if(g?.length!==I?.length)throw new Error("Property keys and property values counts do not match");if(P?.length!==I?.length)throw new Error("Property types and property values counts do not match");let S=P?.map(U=>C[U]);return u({aptosConfig:o,sender:n.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[e,r,s,a,_.MoveString(g??[]),_.MoveString(S??[]),K(I??[],S??[]),m],abi:Y},options:b})}var L={typeParameters:[{constraints:["key"]}],parameters:[new i(y(new A(0)))]};async function qt(t){let{aptosConfig:o,creator:n,digitalAssetAddress:e,digitalAssetType:r,options:s}=t;return u({aptosConfig:o,sender:n.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[r??l],functionArguments:[c.from(e)],abi:L},options:s})}var z={typeParameters:[{constraints:["key"]}],parameters:[new i(y(new A(0)))]};async function Vt(t){let{aptosConfig:o,creator:n,digitalAssetAddress:e,digitalAssetType:r,options:s}=t;return u({aptosConfig:o,sender:n.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[r??l],functionArguments:[e],abi:z},options:s})}var j={typeParameters:[{constraints:["key"]}],parameters:[new i(y(new A(0)))]};async function Rt(t){let{aptosConfig:o,creator:n,digitalAssetAddress:e,digitalAssetType:r,options:s}=t;return u({aptosConfig:o,sender:n.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[r??l],functionArguments:[e],abi:j},options:s})}var W={typeParameters:[{constraints:["key"]}],parameters:[new i(y(new A(0))),new i(p())]};async function Mt(t){let{aptosConfig:o,creator:n,description:e,digitalAssetAddress:r,digitalAssetType:s,options:a}=t;return u({aptosConfig:o,sender:n.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[s??l],functionArguments:[c.from(r),new d(e)],abi:W},options:a})}var X={typeParameters:[{constraints:["key"]}],parameters:[new i(y(new A(0))),new i(p())]};async function Kt(t){let{aptosConfig:o,creator:n,name:e,digitalAssetAddress:r,digitalAssetType:s,options:a}=t;return u({aptosConfig:o,sender:n.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[s??l],functionArguments:[c.from(r),new d(e)],abi:X},options:a})}var H={typeParameters:[{constraints:["key"]}],parameters:[new i(y(new A(0))),new i(p())]};async function Ut(t){let{aptosConfig:o,creator:n,uri:e,digitalAssetAddress:r,digitalAssetType:s,options:a}=t;return u({aptosConfig:o,sender:n.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[s??l],functionArguments:[c.from(r),new d(e)],abi:H},options:a})}var J={typeParameters:[{constraints:["key"]}],parameters:[new i(y(new A(0))),new i(p()),new i(p()),f.u8()]};async function Ft(t){let{aptosConfig:o,creator:n,propertyKey:e,propertyType:r,propertyValue:s,digitalAssetAddress:a,digitalAssetType:m,options:g}=t;return u({aptosConfig:o,sender:n.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[m??l],functionArguments:[c.from(a),new d(e),new d(C[r]),_.U8(B(s,C[r]))],abi:J},options:g})}var Z={typeParameters:[{constraints:["key"]}],parameters:[new i(y(new A(0))),new i(p())]};async function Nt(t){let{aptosConfig:o,creator:n,propertyKey:e,digitalAssetAddress:r,digitalAssetType:s,options:a}=t;return u({aptosConfig:o,sender:n.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[s??l],functionArguments:[c.from(r),new d(e)],abi:Z},options:a})}var $={typeParameters:[{constraints:["key"]}],parameters:[new i(y(new A(0))),new i(p()),new i(p()),f.u8()]};async function Qt(t){let{aptosConfig:o,creator:n,propertyKey:e,propertyType:r,propertyValue:s,digitalAssetAddress:a,digitalAssetType:m,options:g}=t;return u({aptosConfig:o,sender:n.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[m??l],functionArguments:[c.from(a),new d(e),new d(C[r]),B(s,C[r])],abi:$},options:g})}var tt={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new i(y(new A(0))),new i(p()),new A(1)]};async function Yt(t){let{aptosConfig:o,creator:n,propertyKey:e,propertyType:r,propertyValue:s,digitalAssetAddress:a,digitalAssetType:m,options:g}=t;return u({aptosConfig:o,sender:n.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[m??l,C[r]],functionArguments:[c.from(a),new d(e),s],abi:tt},options:g})}var et={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new i(y(new A(0))),new i(p()),new A(1)]};async function Lt(t){let{aptosConfig:o,creator:n,propertyKey:e,propertyType:r,propertyValue:s,digitalAssetAddress:a,digitalAssetType:m,options:g}=t;return u({aptosConfig:o,sender:n.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[m??l,C[r]],functionArguments:[c.from(a),new d(e),s],abi:et},options:g})}function K(t,o){let n=new Array;return o.forEach((e,r)=>{n.push(B(t[r],e))}),n}function B(t,o){let n=R(o);return M(t,n,0,[]).bcsToBytes()}export{It as a,Pt as b,bt as c,St as d,Dt as e,v as f,ht as g,vt as h,xt as i,Gt as j,Bt as k,Et as l,Ot as m,qt as n,Vt as o,Rt as p,Mt as q,Kt as r,Ut as s,Ft as t,Nt as u,Qt as v,Yt as w,Lt as x};
|
|
2
|
-
//# sourceMappingURL=chunk-E5PAUR4N.mjs.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as u,c as d,f as p}from"./chunk-XRVZAEQO.mjs";import{j as l}from"./chunk-BHVSIRNF.mjs";import{ScriptComposerWasm as m}from"@aptos-labs/script-composer-pack";var g=class o{constructor(t){this.config=t,this.builder=void 0}async init(){if(!o.transactionComposer){let t=await import("@aptos-labs/script-composer-pack"),{TransactionComposer:e,initSync:n}=t;m.isInitialized||m.init(),n({module:m.wasm}),o.transactionComposer=e}this.builder=o.transactionComposer.single_signer()}async addBatchedCalls(t){let{moduleAddress:e,moduleName:n,functionName:a}=l(t.function),c=this.config.getRequestUrl("Fullnode");await this.builder.load_module(c,`${e}::${n}`),t.typeArguments!==void 0&&await Promise.all(t.typeArguments.map(i=>this.builder.load_type_tag(c,i.toString())));let r=u(t.typeArguments),s=await d(e,n,a,this.config);if(r.length!==s.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${s.typeParameters.length}, received ${r.length}`);let f=t.functionArguments.map((i,h)=>p(i,a,s,h,r));return this.builder.add_batched_call(`${e}::${n}`,a,r.map(i=>i.toString()),f)}build(){return this.builder.generate_batched_calls(!0)}};export{g as a};
|
|
2
|
-
//# sourceMappingURL=chunk-FJ5J7CVW.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transactions/scriptComposer/index.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ScriptComposerWasm } from \"@aptos-labs/script-composer-pack\";\nimport { AptosApiType, getFunctionParts } from \"../../utils\";\nimport { AptosConfig } from \"../../api/aptosConfig\";\nimport { InputBatchedFunctionData } from \"../types\";\nimport { fetchMoveFunctionAbi, standardizeTypeTags } from \"../transactionBuilder\";\nimport { CallArgument } from \"../../types\";\nimport { convertCallArgument } from \"../transactionBuilder/remoteAbi\";\n\n/**\n * A wrapper class around TransactionComposer, which is a WASM library compiled\n * from aptos-core/aptos-move/script-composer.\n * This class allows the SDK caller to build a transaction that invokes multiple Move functions\n * and allow for arguments to be passed around.\n * */\nexport class AptosScriptComposer {\n private config: AptosConfig;\n\n private builder?: any;\n\n private static transactionComposer?: any;\n\n constructor(aptosConfig: AptosConfig) {\n this.config = aptosConfig;\n this.builder = undefined;\n }\n\n // Initializing the wasm needed for the script composer, must be called\n // before using the composer.\n async init() {\n if (!AptosScriptComposer.transactionComposer) {\n const module = await import(\"@aptos-labs/script-composer-pack\");\n const { TransactionComposer, initSync } = module;\n if (!ScriptComposerWasm.isInitialized) {\n ScriptComposerWasm.init();\n }\n initSync({ module: ScriptComposerWasm.wasm });\n AptosScriptComposer.transactionComposer = TransactionComposer;\n }\n this.builder = AptosScriptComposer.transactionComposer.single_signer();\n }\n\n // Add a move function invocation to the TransactionComposer.\n //\n // Similar to how to create an entry function, the difference is that input arguments could\n // either be a `CallArgument` which represents an abstract value returned from a previous Move call\n // or the regular entry function arguments.\n //\n // The function would also return a list of `CallArgument` that can be passed on to future calls.\n async addBatchedCalls(input: InputBatchedFunctionData): Promise<CallArgument[]> {\n const { moduleAddress, moduleName, functionName } = getFunctionParts(input.function);\n const nodeUrl = this.config.getRequestUrl(AptosApiType.FULLNODE);\n\n // Load the calling module into the builder.\n await this.builder.load_module(nodeUrl, `${moduleAddress}::${moduleName}`);\n\n // Load the calling type arguments into the loader.\n if (input.typeArguments !== undefined) {\n await Promise.all(input.typeArguments.map((typeTag) => this.builder.load_type_tag(nodeUrl, typeTag.toString())));\n }\n const typeArguments = standardizeTypeTags(input.typeArguments);\n const functionAbi = await fetchMoveFunctionAbi(moduleAddress, moduleName, functionName, this.config);\n // Check the type argument count against the ABI\n if (typeArguments.length !== functionAbi.typeParameters.length) {\n throw new Error(\n `Type argument count mismatch, expected ${functionAbi.typeParameters.length}, received ${typeArguments.length}`,\n );\n }\n\n const functionArguments: CallArgument[] = input.functionArguments.map((arg, i) =>\n convertCallArgument(arg, functionName, functionAbi, i, typeArguments),\n );\n\n return this.builder.add_batched_call(\n `${moduleAddress}::${moduleName}`,\n functionName,\n typeArguments.map((arg) => arg.toString()),\n functionArguments,\n );\n }\n\n build(): Uint8Array {\n return this.builder.generate_batched_calls(true);\n }\n}\n"],"mappings":"gGAGA,OAAS,sBAAAA,MAA0B,mCAc5B,IAAMC,EAAN,MAAMC,CAAoB,CAO/B,YAAYC,EAA0B,CACpC,KAAK,OAASA,EACd,KAAK,QAAU,MACjB,CAIA,MAAM,MAAO,CACX,GAAI,CAACD,EAAoB,oBAAqB,CAC5C,IAAME,EAAS,KAAM,QAAO,kCAAkC,EACxD,CAAE,oBAAAC,EAAqB,SAAAC,CAAS,EAAIF,EACrCG,EAAmB,eACtBA,EAAmB,KAAK,EAE1BD,EAAS,CAAE,OAAQC,EAAmB,IAAK,CAAC,EAC5CL,EAAoB,oBAAsBG,CAC5C,CACA,KAAK,QAAUH,EAAoB,oBAAoB,cAAc,CACvE,CASA,MAAM,gBAAgBM,EAA0D,CAC9E,GAAM,CAAE,cAAAC,EAAe,WAAAC,EAAY,aAAAC,CAAa,EAAIC,EAAiBJ,EAAM,QAAQ,EAC7EK,EAAU,KAAK,OAAO,wBAAmC,EAG/D,MAAM,KAAK,QAAQ,YAAYA,EAAS,GAAGJ,CAAa,KAAKC,CAAU,EAAE,EAGrEF,EAAM,gBAAkB,QAC1B,MAAM,QAAQ,IAAIA,EAAM,cAAc,IAAKM,GAAY,KAAK,QAAQ,cAAcD,EAASC,EAAQ,SAAS,CAAC,CAAC,CAAC,EAEjH,IAAMC,EAAgBC,EAAoBR,EAAM,aAAa,EACvDS,EAAc,MAAMC,EAAqBT,EAAeC,EAAYC,EAAc,KAAK,MAAM,EAEnG,GAAII,EAAc,SAAWE,EAAY,eAAe,OACtD,MAAM,IAAI,MACR,0CAA0CA,EAAY,eAAe,MAAM,cAAcF,EAAc,MAAM,EAC/G,EAGF,IAAMI,EAAoCX,EAAM,kBAAkB,IAAI,CAACY,EAAKC,IAC1EC,EAAoBF,EAAKT,EAAcM,EAAaI,EAAGN,CAAa,CACtE,EAEA,OAAO,KAAK,QAAQ,iBAClB,GAAGN,CAAa,KAAKC,CAAU,GAC/BC,EACAI,EAAc,IAAKK,GAAQA,EAAI,SAAS,CAAC,EACzCD,CACF,CACF,CAEA,OAAoB,CAClB,OAAO,KAAK,QAAQ,uBAAuB,EAAI,CACjD,CACF","names":["ScriptComposerWasm","AptosScriptComposer","_AptosScriptComposer","aptosConfig","module","TransactionComposer","initSync","ScriptComposerWasm","input","moduleAddress","moduleName","functionName","getFunctionParts","nodeUrl","typeTag","typeArguments","standardizeTypeTags","functionAbi","fetchMoveFunctionAbi","functionArguments","arg","i","convertCallArgument"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as _}from"./chunk-53IBOHXB.mjs";import{g}from"./chunk-W2C5KRUQ.mjs";import{a as C}from"./chunk-CPFQUFVD.mjs";import{a as l}from"./chunk-YLUULY6G.mjs";import{a as v}from"./chunk-XW3BXTCZ.mjs";import{i as k,l as E,m as S,n as b,q as y}from"./chunk-HVIF6DW6.mjs";import{b as h}from"./chunk-PWGTRRSJ.mjs";import{g as A,h as x}from"./chunk-752TOOCA.mjs";import{d as K}from"./chunk-TH5JCPN2.mjs";import{j as w}from"./chunk-RJ7F4JDV.mjs";import{a as u}from"./chunk-HHWJHOFZ.mjs";import{b as f}from"./chunk-VHY6ZATX.mjs";import{jwtDecode as T}from"jwt-decode";async function j(r){let{aptosConfig:i,jwt:a,ephemeralKeyPair:e,uidKey:p="sub",derivationPath:s}=r,t={jwt_b64:a,epk:e.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:e.expiryDateSecs,epk_blinder:f.fromHexInput(e.blinder).toStringWithoutPrefix(),uid_key:p,derivation_path:s},{data:n}=await A({aptosConfig:i,path:"fetch",body:t,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return f.fromHexInput(n.pepper).toUint8Array()}async function F(r){let{aptosConfig:i,jwt:a,ephemeralKeyPair:e,pepper:p=await j(r),uidKey:s="sub",maxExpHorizonSecs:t=(await y({aptosConfig:i})).maxExpHorizonSecs}=r;if(f.fromHexInput(p).toUint8Array().length!==l.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${l.PEPPER_LENGTH} bytes`);let n=T(a);if(typeof n.iat!="number")throw new Error("iat was not found");if(t<e.expiryDateSecs-n.iat)throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${t}`);let o={jwt_b64:a,epk:e.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:f.fromHexInput(e.blinder).toStringWithoutPrefix(),exp_date_secs:e.expiryDateSecs,exp_horizon_secs:t,pepper:f.fromHexInput(p).toStringWithoutPrefix(),uid_key:s},{data:c}=await x({aptosConfig:i,path:"prove",body:o,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),d=c.proof,m=new E({a:d.a,b:d.b,c:d.c});return new b({proof:new S(m,0),trainingWheelsSignature:h.fromHex(c.training_wheels_signature),expHorizonSecs:t})}async function oe(r){let{aptosConfig:i,jwt:a,jwkAddress:e,uidKey:p,proofFetchCallback:s,pepper:t=await j(r)}=r,{verificationKey:n,maxExpHorizonSecs:o}=await y({aptosConfig:i}),c=F({...r,pepper:t,maxExpHorizonSecs:o}),d=s?c:await c;if(e!==void 0){let H=v.fromJwtAndPepper({jwt:a,pepper:t,jwkAddress:e,uidKey:p}),I=await g({aptosConfig:i,authenticationKey:H.authKey().derivedAddress()});return C.create({...r,address:I,proof:d,pepper:t,proofFetchCallback:s,jwkAddress:e,verificationKey:n})}let m=k.fromJwtAndPepper({jwt:a,pepper:t,uidKey:p}),P=await g({aptosConfig:i,authenticationKey:m.authKey().derivedAddress()});return l.create({...r,address:P,proof:d,pepper:t,proofFetchCallback:s,verificationKey:n})}async function re(r){let{aptosConfig:i,sender:a,iss:e,options:p}=r,{jwksUrl:s}=r;s===void 0&&(w.test(e)?s="https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com":s=e.endsWith("/")?`${e}.well-known/jwks.json`:`${e}/.well-known/jwks.json`);let t;try{if(t=await fetch(s),!t.ok)throw new Error(`${t.status} ${t.statusText}`)}catch(o){let c;throw o instanceof Error?c=`${o.message}`:c=`error unknown - ${o}`,K.fromErrorType({type:14,details:`Failed to fetch JWKS at ${s}: ${c}`})}let n=await t.json();return _({aptosConfig:i,sender:a.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[e,u.MoveString(n.keys.map(o=>o.kid)),u.MoveString(n.keys.map(o=>o.alg)),u.MoveString(n.keys.map(o=>o.e)),u.MoveString(n.keys.map(o=>o.n))]},options:p})}export{j as a,F as b,oe as c,re as d};
|
|
2
|
-
//# sourceMappingURL=chunk-G5F5ZOH5.mjs.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as g}from"./chunk-CPAAEEF4.mjs";import{b as m}from"./chunk-WHVCUVZP.mjs";import{a as p}from"./chunk-MAWGZICD.mjs";import{e as a}from"./chunk-BPHCRTHD.mjs";import{b as d,c as u}from"./chunk-QUJM5W4L.mjs";import{b as y}from"./chunk-LQOSHBB7.mjs";var A=class l{constructor(e){this.signingScheme=3;let{multiKey:i,address:s}=e,n=e.signers.map(t=>t instanceof p?m.fromEd25519Account(t):t);if(i.signaturesRequired>n.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${i.signaturesRequired} signers, but only ${n.length} provided`);if(i.signaturesRequired<n.length)throw new Error(`More signers provided than required. Need ${i.signaturesRequired} signers, but ${n.length} provided`);this.publicKey=i,this.accountAddress=s?y.from(s):this.publicKey.authKey().derivedAddress();let r=[];for(let t of n)r.push(this.publicKey.getIndex(t.getAnyPublicKey()));let o=n.map((t,c)=>[t,r[c]]);o.sort((t,c)=>t[1]-c[1]),this.signers=o.map(t=>t[0]),this.signerIndicies=o.map(t=>t[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:r})}static fromPublicKeysAndSigners(e){let{publicKeys:i,signaturesRequired:s,signers:n}=e,r=new d({publicKeys:i,signaturesRequired:s});return new l({multiKey:r,signers:n})}static isMultiKeySigner(e){return e instanceof l}signWithAuthenticator(e){return new a(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new a(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let i=this.signers.filter(s=>s instanceof g).map(async s=>s.waitForProofFetch());await Promise.all(i)}async checkKeylessAccountValidity(e){let s=this.signers.filter(n=>n instanceof g).map(n=>n.checkKeylessAccountValidity(e));await Promise.all(s)}sign(e){let i=[];for(let s of this.signers)i.push(s.sign(e));return new u({signatures:i,bitmap:this.signaturesBitmap})}signTransaction(e){let i=[];for(let s of this.signers)i.push(s.signTransaction(e));return new u({signatures:i,bitmap:this.signaturesBitmap})}verifySignature(e){let{message:i,signature:s}=e;if(!this.signerIndicies.every((r,o)=>o===0||r>=this.signerIndicies[o-1]))return!1;for(let r=0;r<s.signatures.length;r+=1){let o=s.signatures[r];if(!this.publicKey.publicKeys[this.signerIndicies[r]].verifySignature({message:i,signature:o}))return!1}return!0}};export{A as a};
|
|
2
|
-
//# sourceMappingURL=chunk-HYJQHVDZ.mjs.map
|