@aptos-labs/ts-sdk 1.12.2 → 1.13.0-zeta.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/chunk-KSEUZTKY.js +2 -0
- package/dist/common/chunk-KSEUZTKY.js.map +1 -0
- package/dist/common/cli/index.d.ts +37 -0
- package/dist/common/cli/index.js +2 -0
- package/dist/common/cli/index.js.map +1 -0
- package/dist/common/index.d.ts +2133 -1399
- package/dist/common/index.js +26 -26
- package/dist/common/index.js.map +1 -1
- package/dist/esm/{Ed25519Account-DHqzsb8B.d.mts → Ed25519Account-hkKk3b4Z.d.mts} +12 -14
- package/dist/esm/account/Account.d.mts +34 -0
- package/dist/esm/account/Account.mjs +2 -0
- package/dist/esm/account/Ed25519Account.d.mts +34 -0
- package/dist/esm/account/Ed25519Account.mjs +2 -0
- package/dist/esm/account/EphemeralKeyPair.d.mts +42 -0
- package/dist/esm/account/EphemeralKeyPair.mjs +2 -0
- package/dist/esm/account/KeylessAccount.d.mts +85 -0
- package/dist/esm/account/KeylessAccount.mjs +2 -0
- package/dist/esm/account/MultiKeyAccount.d.mts +99 -0
- package/dist/esm/account/MultiKeyAccount.mjs +2 -0
- package/dist/esm/account/SingleKeyAccount.d.mts +34 -0
- package/dist/esm/account/SingleKeyAccount.mjs +2 -0
- package/dist/esm/account/index.d.mts +39 -0
- package/dist/esm/account/index.mjs +2 -0
- package/dist/esm/api/account.d.mts +62 -9
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +20 -28
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +20 -9
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.d.mts +24 -0
- package/dist/esm/api/aptosConfig.mjs +1 -1
- package/dist/esm/api/coin.d.mts +14 -7
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +149 -10
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.d.mts +13 -8
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/faucet.d.mts +3 -0
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +36 -13
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.d.mts +55 -32
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +15 -9
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.d.mts +75 -0
- package/dist/esm/api/keyless.mjs +2 -0
- package/dist/esm/api/staking.d.mts +9 -0
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +59 -16
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.d.mts +2 -2
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.d.mts +9 -9
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.d.mts +2 -2
- 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.d.mts +7 -7
- package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
- package/dist/esm/api/transactionSubmission/submit.d.mts +1 -1
- package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
- package/dist/esm/api/utils.mjs +1 -1
- package/dist/esm/bcs/index.mjs +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/bcs/serializer.d.mts +2 -0
- package/dist/esm/bcs/serializer.mjs +1 -1
- package/dist/esm/chunk-2HXKDHMA.mjs +2 -0
- package/dist/esm/chunk-2HXKDHMA.mjs.map +1 -0
- package/dist/esm/{chunk-IYSHHN5A.mjs → chunk-2I2XAOH7.mjs} +2 -2
- package/dist/esm/{chunk-5RUPEEIG.mjs → chunk-2PW2EHCH.mjs} +2 -2
- package/dist/esm/chunk-2PW2EHCH.mjs.map +1 -0
- package/dist/esm/{chunk-6ILDDGAX.mjs → chunk-2XIT7I5L.mjs} +2 -2
- package/dist/esm/chunk-3FVRXELT.mjs +2 -0
- package/dist/esm/{chunk-U3YYSIIT.mjs → chunk-3VGX3TXH.mjs} +2 -2
- package/dist/esm/{chunk-Y2MYVQVT.mjs → chunk-45D3YXLT.mjs} +2 -2
- package/dist/esm/chunk-4FQ63Z6Y.mjs +2 -0
- package/dist/esm/chunk-4FQ63Z6Y.mjs.map +1 -0
- package/dist/esm/{chunk-OWXKKVWD.mjs → chunk-4QWFCYP2.mjs} +2 -2
- package/dist/esm/chunk-4QWFCYP2.mjs.map +1 -0
- package/dist/esm/{chunk-Q73VKL3A.mjs → chunk-5IM5TQN4.mjs} +2 -2
- package/dist/esm/{chunk-KS7UY4W5.mjs → chunk-67QYMEZE.mjs} +2 -2
- package/dist/esm/{chunk-GHYE26Q5.mjs → chunk-6FBKUTGF.mjs} +2 -2
- package/dist/esm/chunk-6Q2GNDKL.mjs +2 -0
- package/dist/esm/chunk-6RBUXB5I.mjs +2 -0
- package/dist/esm/{chunk-SRDIYE3M.mjs.map → chunk-6RBUXB5I.mjs.map} +1 -1
- package/dist/esm/{chunk-GQR35QW3.mjs → chunk-77MI5DFB.mjs} +2 -2
- package/dist/esm/chunk-77MI5DFB.mjs.map +1 -0
- package/dist/esm/{chunk-5EN52MUT.mjs → chunk-7STYQ5ZE.mjs} +2 -2
- package/dist/esm/chunk-7Z6DYLCA.mjs +1 -0
- package/dist/esm/{chunk-2EZJOBD2.mjs → chunk-ABBKCXG4.mjs} +2 -2
- package/dist/esm/chunk-ABBKCXG4.mjs.map +1 -0
- package/dist/esm/chunk-ACOL3VVP.mjs +2 -0
- package/dist/esm/chunk-ACOL3VVP.mjs.map +1 -0
- package/dist/esm/chunk-AFPBV2BQ.mjs +2 -0
- package/dist/esm/{chunk-BCUSI3N6.mjs → chunk-AOCNYMMX.mjs} +2 -2
- package/dist/esm/chunk-AQ4I7VVB.mjs +1 -0
- package/dist/esm/chunk-AQ4I7VVB.mjs.map +1 -0
- package/dist/esm/{chunk-IHPWATYH.mjs → chunk-AWMOLZCX.mjs} +2 -2
- package/dist/esm/chunk-AWMOLZCX.mjs.map +1 -0
- package/dist/esm/chunk-C3L4ETUF.mjs +2 -0
- package/dist/esm/chunk-CITY3EV2.mjs +2 -0
- package/dist/esm/chunk-CITY3EV2.mjs.map +1 -0
- package/dist/esm/chunk-COW5IGYC.mjs +2 -0
- package/dist/esm/chunk-CYA2GSRV.mjs +2 -0
- package/dist/esm/chunk-CYA2GSRV.mjs.map +1 -0
- package/dist/esm/{chunk-TTUXAKCV.mjs → chunk-CYWA4AJF.mjs} +2 -2
- package/dist/esm/{chunk-TVHLZDCO.mjs → chunk-DANNIPX2.mjs} +2 -2
- package/dist/esm/chunk-DANNIPX2.mjs.map +1 -0
- package/dist/esm/{chunk-V6FZ7WZH.mjs → chunk-E3YEX3FR.mjs} +2 -2
- package/dist/esm/{chunk-G56GPLTB.mjs → chunk-EB7AI4B4.mjs} +2 -2
- package/dist/esm/chunk-EMFDNUP2.mjs +2 -0
- package/dist/esm/chunk-EMFDNUP2.mjs.map +1 -0
- package/dist/esm/chunk-FBPNHF54.mjs +2 -0
- package/dist/esm/chunk-FCVWPGXD.mjs +2 -0
- package/dist/esm/chunk-FCVWPGXD.mjs.map +1 -0
- package/dist/esm/chunk-FLYEALDB.mjs +2 -0
- package/dist/esm/chunk-FLYEALDB.mjs.map +1 -0
- package/dist/esm/chunk-G7S2ZX5A.mjs +2 -0
- package/dist/esm/chunk-G7S2ZX5A.mjs.map +1 -0
- package/dist/esm/{chunk-KAGLWBIJ.mjs → chunk-HGZGTBA4.mjs} +2 -2
- package/dist/esm/{chunk-3AYBWD76.mjs → chunk-HJVGZBKN.mjs} +2 -2
- package/dist/esm/chunk-HJVGZBKN.mjs.map +1 -0
- package/dist/esm/{chunk-KXR3IUJ7.mjs → chunk-INYYKAXD.mjs} +2 -2
- package/dist/esm/chunk-J7YWDDUB.mjs +2 -0
- package/dist/esm/chunk-J7YWDDUB.mjs.map +1 -0
- package/dist/esm/chunk-JDD6TMHU.mjs +2 -0
- package/dist/esm/chunk-JDD6TMHU.mjs.map +1 -0
- package/dist/esm/chunk-JM3W7AQP.mjs +2 -0
- package/dist/esm/chunk-JM3W7AQP.mjs.map +1 -0
- package/dist/esm/{chunk-GKGTODGE.mjs → chunk-JNAI5UFZ.mjs} +2 -2
- package/dist/esm/chunk-JXCZTOYC.mjs +1 -0
- package/dist/esm/chunk-JXCZTOYC.mjs.map +1 -0
- package/dist/esm/chunk-KDTQD56P.mjs +2 -0
- package/dist/esm/{chunk-MXO53VAI.mjs.map → chunk-KDTQD56P.mjs.map} +1 -1
- package/dist/esm/{chunk-C7YANDB2.mjs → chunk-KOWGEMJZ.mjs} +2 -2
- package/dist/esm/chunk-KOWGEMJZ.mjs.map +1 -0
- package/dist/esm/chunk-KPAKF3K7.mjs +2 -0
- package/dist/esm/chunk-KPAKF3K7.mjs.map +1 -0
- package/dist/esm/{chunk-UEKKYJGA.mjs → chunk-KR3NQRBA.mjs} +2 -2
- package/dist/esm/chunk-KR3NQRBA.mjs.map +1 -0
- package/dist/esm/chunk-L4CV3DRL.mjs +2 -0
- package/dist/esm/chunk-L4CV3DRL.mjs.map +1 -0
- package/dist/esm/{chunk-LPB7SZHL.mjs → chunk-LFTWUMLK.mjs} +2 -2
- package/dist/esm/chunk-LPFIDI6C.mjs +2 -0
- package/dist/esm/chunk-LPFIDI6C.mjs.map +1 -0
- package/dist/esm/chunk-LVYKZS54.mjs +2 -0
- package/dist/esm/{chunk-CXR7MOBW.mjs.map → chunk-LVYKZS54.mjs.map} +1 -1
- package/dist/esm/chunk-MGOHPDX4.mjs +2 -0
- package/dist/esm/chunk-MLPJOS5C.mjs +2 -0
- package/dist/esm/chunk-MWUJCP27.mjs +2 -0
- package/dist/esm/{chunk-KLAYDUFD.mjs → chunk-MZGNUGEY.mjs} +2 -2
- package/dist/esm/chunk-MZGNUGEY.mjs.map +1 -0
- package/dist/esm/chunk-NNT3XRRO.mjs +2 -0
- package/dist/esm/chunk-NNT3XRRO.mjs.map +1 -0
- package/dist/esm/chunk-NUDRQTYI.mjs +2 -0
- package/dist/esm/chunk-NUR3TCTI.mjs +2 -0
- package/dist/esm/chunk-OOSPASLD.mjs +2 -0
- package/dist/esm/chunk-OOSPASLD.mjs.map +1 -0
- package/dist/esm/chunk-OVXWFD2N.mjs +2 -0
- package/dist/esm/{chunk-CAGDOGXS.mjs.map → chunk-OVXWFD2N.mjs.map} +1 -1
- package/dist/esm/{chunk-MJPUASSD.mjs → chunk-PFFAQZHT.mjs} +2 -2
- package/dist/esm/chunk-PTIZKRON.mjs +2 -0
- package/dist/esm/chunk-PTIZKRON.mjs.map +1 -0
- package/dist/esm/chunk-QREYDZ5R.mjs +2 -0
- package/dist/esm/chunk-RFSO3JRG.mjs +1 -0
- package/dist/esm/chunk-RFSO3JRG.mjs.map +1 -0
- package/dist/esm/chunk-S5HG2QUD.mjs +2 -0
- package/dist/esm/chunk-S5HG2QUD.mjs.map +1 -0
- package/dist/esm/chunk-SHL6OAGA.mjs +2 -0
- package/dist/esm/chunk-SHL6OAGA.mjs.map +1 -0
- package/dist/esm/chunk-SKXGYGDX.mjs +2 -0
- package/dist/esm/chunk-SKXGYGDX.mjs.map +1 -0
- package/dist/esm/chunk-STYDBDYL.mjs +2 -0
- package/dist/esm/{chunk-QRS4DGP3.mjs → chunk-T23OVRNF.mjs} +2 -2
- package/dist/esm/{chunk-QRS4DGP3.mjs.map → chunk-T23OVRNF.mjs.map} +1 -1
- package/dist/esm/chunk-T47T7HX4.mjs +2 -0
- package/dist/esm/chunk-T47T7HX4.mjs.map +1 -0
- package/dist/esm/chunk-TB2KXA2B.mjs +2 -0
- package/dist/esm/chunk-TB2KXA2B.mjs.map +1 -0
- package/dist/esm/{chunk-EKR6HLSN.mjs → chunk-THVGZXKD.mjs} +2 -2
- package/dist/esm/chunk-THVGZXKD.mjs.map +1 -0
- package/dist/esm/chunk-TJDC5PWD.mjs +2 -0
- package/dist/esm/chunk-TJTZVCPS.mjs +2 -0
- package/dist/esm/chunk-TJTZVCPS.mjs.map +1 -0
- package/dist/esm/chunk-TR6Q7RSZ.mjs +2 -0
- package/dist/esm/chunk-TR6Q7RSZ.mjs.map +1 -0
- package/dist/esm/{chunk-36QXVFR5.mjs → chunk-TVRJ3M7B.mjs} +2 -2
- package/dist/esm/{chunk-36QXVFR5.mjs.map → chunk-TVRJ3M7B.mjs.map} +1 -1
- package/dist/esm/chunk-U7AY6CMF.mjs +2 -0
- package/dist/esm/chunk-U7AY6CMF.mjs.map +1 -0
- package/dist/esm/{chunk-WHA7RISE.mjs → chunk-UYMZF37A.mjs} +2 -2
- package/dist/esm/chunk-VHC2KC7B.mjs +2 -0
- package/dist/esm/chunk-VHC2KC7B.mjs.map +1 -0
- package/dist/esm/chunk-VHCJCXVZ.mjs +2 -0
- package/dist/esm/chunk-VHCJCXVZ.mjs.map +1 -0
- package/dist/esm/chunk-VVGV4S24.mjs +2 -0
- package/dist/esm/chunk-VVGV4S24.mjs.map +1 -0
- package/dist/esm/{chunk-6APZ5TPE.mjs → chunk-W2R2FURG.mjs} +2 -2
- package/dist/esm/chunk-W2R2FURG.mjs.map +1 -0
- package/dist/esm/chunk-W57M6DIK.mjs +2 -0
- package/dist/esm/chunk-WRY7462X.mjs +2 -0
- package/dist/esm/chunk-WRY7462X.mjs.map +1 -0
- package/dist/esm/chunk-X5XBBEVT.mjs +2 -0
- package/dist/esm/chunk-X5XBBEVT.mjs.map +1 -0
- package/dist/esm/{chunk-XDXI3TRT.mjs → chunk-XBQEFZD7.mjs} +2 -2
- package/dist/esm/{chunk-U43KR4TW.mjs → chunk-Y5ZK4UII.mjs} +2 -2
- package/dist/esm/chunk-Y5ZK4UII.mjs.map +1 -0
- package/dist/esm/chunk-YP3RMVL3.mjs +2 -0
- package/dist/esm/chunk-YP3RMVL3.mjs.map +1 -0
- package/dist/esm/{chunk-35EWRSDK.mjs → chunk-ZNEBMSNC.mjs} +2 -2
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.d.mts +2 -1
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.d.mts +2 -2
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.d.mts +3 -1
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/client/types.mjs +1 -1
- package/dist/esm/core/account/utils/address.mjs +1 -1
- package/dist/esm/core/account/utils/index.mjs +1 -1
- package/dist/esm/core/accountAddress.mjs +1 -1
- package/dist/esm/core/authenticationKey.d.mts +1 -1
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/common.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.d.mts +9 -12
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.d.mts +76 -0
- package/dist/esm/core/crypto/ephemeral.mjs +2 -0
- package/dist/esm/core/crypto/ephemeral.mjs.map +1 -0
- package/dist/esm/core/crypto/hdKey.d.mts +15 -1
- package/dist/esm/core/crypto/hdKey.mjs +1 -1
- package/dist/esm/core/crypto/index.d.mts +8 -6
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/keyless.d.mts +217 -0
- package/dist/esm/core/crypto/keyless.mjs +2 -0
- package/dist/esm/core/crypto/keyless.mjs.map +1 -0
- package/dist/esm/core/crypto/multiEd25519.d.mts +1 -1
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.d.mts +5 -4
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/poseidon.d.mts +7 -0
- package/dist/esm/core/crypto/poseidon.mjs +2 -0
- package/dist/esm/core/crypto/poseidon.mjs.map +1 -0
- package/dist/esm/core/crypto/privateKey.d.mts +1 -1
- package/dist/esm/core/crypto/publicKey.d.mts +1 -1
- package/dist/esm/core/crypto/publicKey.mjs +1 -1
- package/dist/esm/core/crypto/secp256k1.d.mts +8 -1
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/crypto/signature.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.d.mts +1 -1
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/crypto/utils.mjs +1 -1
- package/dist/esm/core/hex.mjs +1 -1
- package/dist/esm/core/index.d.mts +7 -8
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/index.d.mts +16 -10
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/account.d.mts +14 -2
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +4 -4
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.d.mts +8 -8
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +11 -11
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.d.mts +1 -1
- package/dist/esm/internal/event.mjs +1 -1
- package/dist/esm/internal/faucet.d.mts +1 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +12 -12
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.d.mts +68 -0
- package/dist/esm/internal/keyless.mjs +2 -0
- package/dist/esm/internal/keyless.mjs.map +1 -0
- package/dist/esm/internal/staking.d.mts +1 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/transaction.d.mts +5 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +2 -2
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/view.d.mts +7 -7
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.d.mts +4 -5
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.d.mts +1 -1
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.d.mts +1 -1
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.d.mts +3 -3
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/chainId.mjs +1 -1
- package/dist/esm/transactions/instances/identifier.mjs +1 -1
- package/dist/esm/transactions/instances/index.d.mts +1 -1
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.d.mts +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/rotationProofChallenge.d.mts +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.d.mts +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.d.mts +1 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.d.mts +14 -2
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.d.mts +3 -3
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.d.mts +2 -2
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.d.mts +9 -9
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.d.mts +9 -9
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +6 -6
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +47 -0
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +2 -0
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs.map +1 -0
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +7 -29
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/transactions/types.d.mts +7 -7
- package/dist/esm/types/index.d.mts +18 -3
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/types/keyless.d.mts +14 -0
- package/dist/esm/types/keyless.mjs +1 -0
- package/dist/esm/types/keyless.mjs.map +1 -0
- package/dist/esm/utils/apiEndpoints.d.mts +3 -1
- package/dist/esm/utils/apiEndpoints.mjs +1 -1
- package/dist/esm/utils/const.d.mts +5 -3
- package/dist/esm/utils/const.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 +13 -7
- package/src/{core/account → account}/Account.ts +12 -16
- package/src/{core/account → account}/Ed25519Account.ts +13 -7
- package/src/account/EphemeralKeyPair.ts +78 -0
- package/src/account/KeylessAccount.ts +230 -0
- package/src/account/MultiKeyAccount.ts +121 -0
- package/src/{core/account → account}/SingleKeyAccount.ts +13 -7
- package/src/account/index.ts +6 -0
- package/src/api/account.ts +50 -8
- package/src/api/ans.ts +10 -17
- package/src/api/aptos.ts +10 -0
- package/src/api/aptosConfig.ts +50 -1
- package/src/api/coin.ts +7 -0
- package/src/api/digitalAsset.ts +142 -2
- package/src/api/event.ts +13 -8
- package/src/api/faucet.ts +3 -0
- package/src/api/fungibleAsset.ts +28 -4
- package/src/api/general.ts +48 -25
- package/src/api/keyless.ts +55 -0
- package/src/api/staking.ts +9 -0
- package/src/api/transaction.ts +59 -15
- package/src/api/transactionSubmission/management.ts +1 -1
- package/src/api/transactionSubmission/sign.ts +1 -1
- package/src/bcs/serializer.ts +18 -0
- package/src/client/core.ts +10 -1
- package/src/client/get.ts +6 -0
- package/src/client/post.ts +13 -0
- package/src/core/crypto/ed25519.ts +50 -34
- package/src/core/crypto/ephemeral.ts +147 -0
- package/src/core/crypto/hdKey.ts +31 -0
- package/src/core/crypto/index.ts +2 -0
- package/src/core/crypto/keyless.ts +502 -0
- package/src/core/crypto/multiKey.ts +23 -11
- package/src/core/crypto/poseidon.ts +134 -0
- package/src/core/crypto/secp256k1.ts +9 -3
- package/src/core/crypto/singleKey.ts +11 -0
- package/src/core/index.ts +0 -1
- package/src/index.ts +1 -0
- package/src/internal/account.ts +7 -10
- package/src/internal/ans.ts +2 -1
- package/src/internal/digitalAsset.ts +3 -2
- package/src/internal/fungibleAsset.ts +4 -3
- package/src/internal/keyless.ts +205 -0
- package/src/internal/transaction.ts +48 -10
- package/src/internal/transactionSubmission.ts +8 -7
- package/src/transactions/authenticator/account.ts +6 -11
- package/src/transactions/management/accountSequenceNumber.ts +1 -1
- package/src/transactions/management/transactionWorker.ts +8 -2
- package/src/transactions/transactionBuilder/index.ts +2 -0
- package/src/transactions/transactionBuilder/signingMessage.ts +75 -0
- package/src/transactions/transactionBuilder/transactionBuilder.ts +3 -80
- package/src/types/index.ts +21 -0
- package/src/types/keyless.ts +6 -0
- package/src/utils/apiEndpoints.ts +14 -0
- package/src/utils/const.ts +4 -2
- package/src/version.ts +1 -1
- package/dist/esm/chunk-2EZJOBD2.mjs.map +0 -1
- package/dist/esm/chunk-3AYBWD76.mjs.map +0 -1
- package/dist/esm/chunk-45ZZWQ7X.mjs +0 -2
- package/dist/esm/chunk-45ZZWQ7X.mjs.map +0 -1
- package/dist/esm/chunk-4ILXLBGX.mjs +0 -2
- package/dist/esm/chunk-4NHWV5AI.mjs +0 -2
- package/dist/esm/chunk-4QMXOWHP.mjs +0 -1
- package/dist/esm/chunk-5GKROFZ4.mjs +0 -2
- package/dist/esm/chunk-5GKROFZ4.mjs.map +0 -1
- package/dist/esm/chunk-5RUPEEIG.mjs.map +0 -1
- package/dist/esm/chunk-6APZ5TPE.mjs.map +0 -1
- package/dist/esm/chunk-6BR5UJDT.mjs +0 -2
- package/dist/esm/chunk-AEVRPB4E.mjs +0 -2
- package/dist/esm/chunk-AEVRPB4E.mjs.map +0 -1
- package/dist/esm/chunk-ARGODLTZ.mjs +0 -2
- package/dist/esm/chunk-ARGODLTZ.mjs.map +0 -1
- package/dist/esm/chunk-ASXXZH2D.mjs +0 -2
- package/dist/esm/chunk-ASXXZH2D.mjs.map +0 -1
- package/dist/esm/chunk-B7X6PSE7.mjs +0 -2
- package/dist/esm/chunk-C67BKZND.mjs +0 -2
- package/dist/esm/chunk-C67BKZND.mjs.map +0 -1
- package/dist/esm/chunk-C7YANDB2.mjs.map +0 -1
- package/dist/esm/chunk-CAGDOGXS.mjs +0 -2
- package/dist/esm/chunk-CEHCDA3G.mjs +0 -2
- package/dist/esm/chunk-CQS6ZCJ7.mjs +0 -2
- package/dist/esm/chunk-CQS6ZCJ7.mjs.map +0 -1
- package/dist/esm/chunk-CXR7MOBW.mjs +0 -2
- package/dist/esm/chunk-CYNQRMO5.mjs +0 -2
- package/dist/esm/chunk-CYNQRMO5.mjs.map +0 -1
- package/dist/esm/chunk-DUP7XY5P.mjs +0 -2
- package/dist/esm/chunk-DUP7XY5P.mjs.map +0 -1
- package/dist/esm/chunk-E7FWVXGX.mjs +0 -1
- package/dist/esm/chunk-EKR6HLSN.mjs.map +0 -1
- package/dist/esm/chunk-EV75CYGN.mjs +0 -2
- package/dist/esm/chunk-EV75CYGN.mjs.map +0 -1
- package/dist/esm/chunk-F7EMGK4M.mjs +0 -2
- package/dist/esm/chunk-FKTXWOKR.mjs +0 -2
- package/dist/esm/chunk-FKTXWOKR.mjs.map +0 -1
- package/dist/esm/chunk-GQR35QW3.mjs.map +0 -1
- package/dist/esm/chunk-IHPWATYH.mjs.map +0 -1
- package/dist/esm/chunk-IZF6DFAL.mjs +0 -2
- package/dist/esm/chunk-JOLLCFQL.mjs +0 -2
- package/dist/esm/chunk-JOLLCFQL.mjs.map +0 -1
- package/dist/esm/chunk-KLAYDUFD.mjs.map +0 -1
- package/dist/esm/chunk-LG7RJQ57.mjs +0 -2
- package/dist/esm/chunk-LR65XHSF.mjs +0 -2
- package/dist/esm/chunk-LR65XHSF.mjs.map +0 -1
- package/dist/esm/chunk-MLWIHWNH.mjs +0 -1
- package/dist/esm/chunk-MXO53VAI.mjs +0 -2
- package/dist/esm/chunk-N3U47Y6Y.mjs +0 -2
- package/dist/esm/chunk-NJRNZEHX.mjs +0 -2
- package/dist/esm/chunk-NJRNZEHX.mjs.map +0 -1
- package/dist/esm/chunk-OWXKKVWD.mjs.map +0 -1
- package/dist/esm/chunk-PF57EOJY.mjs +0 -2
- package/dist/esm/chunk-QJAI7DNA.mjs +0 -2
- package/dist/esm/chunk-QJAI7DNA.mjs.map +0 -1
- package/dist/esm/chunk-R7G3CLRI.mjs +0 -1
- package/dist/esm/chunk-RIUFW2OG.mjs +0 -2
- package/dist/esm/chunk-RIUFW2OG.mjs.map +0 -1
- package/dist/esm/chunk-SK5TPUAN.mjs +0 -2
- package/dist/esm/chunk-SOBCWGBM.mjs +0 -2
- package/dist/esm/chunk-SOBCWGBM.mjs.map +0 -1
- package/dist/esm/chunk-SRDIYE3M.mjs +0 -2
- package/dist/esm/chunk-SWZOGZJ6.mjs +0 -2
- package/dist/esm/chunk-SWZOGZJ6.mjs.map +0 -1
- package/dist/esm/chunk-T6J2LHHS.mjs +0 -2
- package/dist/esm/chunk-T6J2LHHS.mjs.map +0 -1
- package/dist/esm/chunk-TVHLZDCO.mjs.map +0 -1
- package/dist/esm/chunk-U43KR4TW.mjs.map +0 -1
- package/dist/esm/chunk-UEKKYJGA.mjs.map +0 -1
- package/dist/esm/chunk-UGPALAPN.mjs +0 -2
- package/dist/esm/chunk-URTTOOEM.mjs +0 -2
- package/dist/esm/chunk-URTTOOEM.mjs.map +0 -1
- package/dist/esm/chunk-UVSRX4SV.mjs +0 -1
- package/dist/esm/chunk-W3V4IGGB.mjs +0 -2
- package/dist/esm/chunk-WMJXRWVE.mjs +0 -2
- package/dist/esm/chunk-XX5J7KKC.mjs +0 -2
- package/dist/esm/chunk-XX5J7KKC.mjs.map +0 -1
- package/dist/esm/chunk-YZGEWPDE.mjs +0 -2
- package/dist/esm/chunk-YZGEWPDE.mjs.map +0 -1
- package/dist/esm/chunk-ZBT4HP6E.mjs +0 -2
- package/dist/esm/chunk-ZBT4HP6E.mjs.map +0 -1
- package/dist/esm/chunk-ZTIRBBNS.mjs +0 -2
- package/dist/esm/core/account/Account.d.mts +0 -20
- package/dist/esm/core/account/Account.mjs +0 -2
- package/dist/esm/core/account/Ed25519Account.d.mts +0 -20
- package/dist/esm/core/account/Ed25519Account.mjs +0 -2
- package/dist/esm/core/account/SingleKeyAccount.d.mts +0 -20
- package/dist/esm/core/account/SingleKeyAccount.mjs +0 -2
- package/dist/esm/core/account/index.d.mts +0 -21
- package/dist/esm/core/account/index.mjs +0 -2
- package/src/core/account/index.ts +0 -4
- /package/dist/esm/{core/account → account}/Account.mjs.map +0 -0
- /package/dist/esm/{core/account → account}/Ed25519Account.mjs.map +0 -0
- /package/dist/esm/{chunk-4QMXOWHP.mjs.map → account/EphemeralKeyPair.mjs.map} +0 -0
- /package/dist/esm/{chunk-E7FWVXGX.mjs.map → account/KeylessAccount.mjs.map} +0 -0
- /package/dist/esm/{chunk-MLWIHWNH.mjs.map → account/MultiKeyAccount.mjs.map} +0 -0
- /package/dist/esm/{core/account → account}/SingleKeyAccount.mjs.map +0 -0
- /package/dist/esm/{core/account → account}/index.mjs.map +0 -0
- /package/dist/esm/{chunk-R7G3CLRI.mjs.map → api/keyless.mjs.map} +0 -0
- /package/dist/esm/{chunk-IYSHHN5A.mjs.map → chunk-2I2XAOH7.mjs.map} +0 -0
- /package/dist/esm/{chunk-6ILDDGAX.mjs.map → chunk-2XIT7I5L.mjs.map} +0 -0
- /package/dist/esm/{chunk-CEHCDA3G.mjs.map → chunk-3FVRXELT.mjs.map} +0 -0
- /package/dist/esm/{chunk-U3YYSIIT.mjs.map → chunk-3VGX3TXH.mjs.map} +0 -0
- /package/dist/esm/{chunk-Y2MYVQVT.mjs.map → chunk-45D3YXLT.mjs.map} +0 -0
- /package/dist/esm/{chunk-Q73VKL3A.mjs.map → chunk-5IM5TQN4.mjs.map} +0 -0
- /package/dist/esm/{chunk-KS7UY4W5.mjs.map → chunk-67QYMEZE.mjs.map} +0 -0
- /package/dist/esm/{chunk-GHYE26Q5.mjs.map → chunk-6FBKUTGF.mjs.map} +0 -0
- /package/dist/esm/{chunk-W3V4IGGB.mjs.map → chunk-6Q2GNDKL.mjs.map} +0 -0
- /package/dist/esm/{chunk-5EN52MUT.mjs.map → chunk-7STYQ5ZE.mjs.map} +0 -0
- /package/dist/esm/{chunk-UVSRX4SV.mjs.map → chunk-7Z6DYLCA.mjs.map} +0 -0
- /package/dist/esm/{chunk-SK5TPUAN.mjs.map → chunk-AFPBV2BQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-BCUSI3N6.mjs.map → chunk-AOCNYMMX.mjs.map} +0 -0
- /package/dist/esm/{chunk-N3U47Y6Y.mjs.map → chunk-C3L4ETUF.mjs.map} +0 -0
- /package/dist/esm/{chunk-4NHWV5AI.mjs.map → chunk-COW5IGYC.mjs.map} +0 -0
- /package/dist/esm/{chunk-TTUXAKCV.mjs.map → chunk-CYWA4AJF.mjs.map} +0 -0
- /package/dist/esm/{chunk-V6FZ7WZH.mjs.map → chunk-E3YEX3FR.mjs.map} +0 -0
- /package/dist/esm/{chunk-G56GPLTB.mjs.map → chunk-EB7AI4B4.mjs.map} +0 -0
- /package/dist/esm/{chunk-LG7RJQ57.mjs.map → chunk-FBPNHF54.mjs.map} +0 -0
- /package/dist/esm/{chunk-KAGLWBIJ.mjs.map → chunk-HGZGTBA4.mjs.map} +0 -0
- /package/dist/esm/{chunk-KXR3IUJ7.mjs.map → chunk-INYYKAXD.mjs.map} +0 -0
- /package/dist/esm/{chunk-GKGTODGE.mjs.map → chunk-JNAI5UFZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-LPB7SZHL.mjs.map → chunk-LFTWUMLK.mjs.map} +0 -0
- /package/dist/esm/{chunk-B7X6PSE7.mjs.map → chunk-MGOHPDX4.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZTIRBBNS.mjs.map → chunk-MLPJOS5C.mjs.map} +0 -0
- /package/dist/esm/{chunk-PF57EOJY.mjs.map → chunk-MWUJCP27.mjs.map} +0 -0
- /package/dist/esm/{chunk-4ILXLBGX.mjs.map → chunk-NUDRQTYI.mjs.map} +0 -0
- /package/dist/esm/{chunk-WMJXRWVE.mjs.map → chunk-NUR3TCTI.mjs.map} +0 -0
- /package/dist/esm/{chunk-MJPUASSD.mjs.map → chunk-PFFAQZHT.mjs.map} +0 -0
- /package/dist/esm/{chunk-IZF6DFAL.mjs.map → chunk-QREYDZ5R.mjs.map} +0 -0
- /package/dist/esm/{chunk-UGPALAPN.mjs.map → chunk-STYDBDYL.mjs.map} +0 -0
- /package/dist/esm/{chunk-F7EMGK4M.mjs.map → chunk-TJDC5PWD.mjs.map} +0 -0
- /package/dist/esm/{chunk-WHA7RISE.mjs.map → chunk-UYMZF37A.mjs.map} +0 -0
- /package/dist/esm/{chunk-6BR5UJDT.mjs.map → chunk-W57M6DIK.mjs.map} +0 -0
- /package/dist/esm/{chunk-XDXI3TRT.mjs.map → chunk-XBQEFZD7.mjs.map} +0 -0
- /package/dist/esm/{chunk-35EWRSDK.mjs.map → chunk-ZNEBMSNC.mjs.map} +0 -0
- /package/dist/esm/{publicKey-B3XRNhHO.d.mts → publicKey-lq5djCIY.d.mts} +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/* eslint-disable no-bitwise */
|
|
2
|
+
import {
|
|
3
|
+
poseidon1,
|
|
4
|
+
poseidon2,
|
|
5
|
+
poseidon3,
|
|
6
|
+
poseidon4,
|
|
7
|
+
poseidon5,
|
|
8
|
+
poseidon6,
|
|
9
|
+
poseidon7,
|
|
10
|
+
poseidon8,
|
|
11
|
+
poseidon9,
|
|
12
|
+
poseidon10,
|
|
13
|
+
poseidon11,
|
|
14
|
+
poseidon12,
|
|
15
|
+
poseidon13,
|
|
16
|
+
poseidon14,
|
|
17
|
+
poseidon15,
|
|
18
|
+
poseidon16,
|
|
19
|
+
} from "poseidon-lite";
|
|
20
|
+
|
|
21
|
+
const numInputsToPoseidonFunc = [
|
|
22
|
+
poseidon1,
|
|
23
|
+
poseidon2,
|
|
24
|
+
poseidon3,
|
|
25
|
+
poseidon4,
|
|
26
|
+
poseidon5,
|
|
27
|
+
poseidon6,
|
|
28
|
+
poseidon7,
|
|
29
|
+
poseidon8,
|
|
30
|
+
poseidon9,
|
|
31
|
+
poseidon10,
|
|
32
|
+
poseidon11,
|
|
33
|
+
poseidon12,
|
|
34
|
+
poseidon13,
|
|
35
|
+
poseidon14,
|
|
36
|
+
poseidon15,
|
|
37
|
+
poseidon16,
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const BYTES_PACKED_PER_SCALAR = 31;
|
|
41
|
+
const MAX_NUM_INPUT_SCALARS = 16;
|
|
42
|
+
const MAX_NUM_INPUT_BYTES = (MAX_NUM_INPUT_SCALARS - 1) * BYTES_PACKED_PER_SCALAR;
|
|
43
|
+
|
|
44
|
+
// hashes an ASCII string to a field element
|
|
45
|
+
export function hashASCIIStrToField(str: string, maxSizeBytes: number) {
|
|
46
|
+
const textEncoder = new TextEncoder();
|
|
47
|
+
const strBytes = textEncoder.encode(str);
|
|
48
|
+
return hashBytesWithLen(strBytes, maxSizeBytes);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function hashBytesWithLen(bytes: Uint8Array, maxSizeBytes: number) {
|
|
52
|
+
if (bytes.length > maxSizeBytes) {
|
|
53
|
+
throw new Error(`Inputted bytes of length ${bytes} is longer than ${maxSizeBytes}`);
|
|
54
|
+
}
|
|
55
|
+
const packed = padAndPackBytesWithLen(bytes, maxSizeBytes);
|
|
56
|
+
return poseidonHash(packed);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function padAndPackBytesNoLen(bytes: Uint8Array, maxSizeBytes: number): bigint[] {
|
|
60
|
+
if (bytes.length > maxSizeBytes) {
|
|
61
|
+
throw new Error(`Input bytes of length ${bytes} is longer than ${maxSizeBytes}`);
|
|
62
|
+
}
|
|
63
|
+
const paddedStrBytes = padUint8ArrayWithZeros(bytes, maxSizeBytes);
|
|
64
|
+
return packBytes(paddedStrBytes);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function padAndPackBytesWithLen(bytes: Uint8Array, maxSizeBytes: number): bigint[] {
|
|
68
|
+
if (bytes.length > maxSizeBytes) {
|
|
69
|
+
throw new Error(`Input bytes of length ${bytes} is longer than ${maxSizeBytes}`);
|
|
70
|
+
}
|
|
71
|
+
return padAndPackBytesNoLen(bytes, maxSizeBytes).concat([BigInt(bytes.length)]);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function packBytes(bytes: Uint8Array): bigint[] {
|
|
75
|
+
if (bytes.length > MAX_NUM_INPUT_BYTES) {
|
|
76
|
+
throw new Error(`Can't pack more than ${MAX_NUM_INPUT_BYTES}. Was given ${bytes.length} bytes`);
|
|
77
|
+
}
|
|
78
|
+
return chunkUint8Array(bytes, BYTES_PACKED_PER_SCALAR).map((chunk) => bytesToBigIntLE(chunk));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function chunkUint8Array(array: Uint8Array, chunkSize: number): Uint8Array[] {
|
|
82
|
+
const result: Uint8Array[] = [];
|
|
83
|
+
for (let i = 0; i < array.length; i += chunkSize) {
|
|
84
|
+
result.push(array.subarray(i, i + chunkSize));
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function bytesToBigIntLE(bytes: Uint8Array): bigint {
|
|
90
|
+
let result = BigInt(0);
|
|
91
|
+
for (let i = bytes.length - 1; i >= 0; i -= 1) {
|
|
92
|
+
result = (result << BigInt(8)) | BigInt(bytes[i]);
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function bigIntToBytesLE(value: bigint, length: number): Uint8Array {
|
|
98
|
+
const bytes = new Uint8Array(length);
|
|
99
|
+
for (let i = 0; i < length; i += 1) {
|
|
100
|
+
bytes[i] = Number(value & BigInt(0xff));
|
|
101
|
+
// eslint-disable-next-line no-param-reassign
|
|
102
|
+
value >>= BigInt(8);
|
|
103
|
+
}
|
|
104
|
+
return bytes;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// From chatGPT
|
|
108
|
+
function padUint8ArrayWithZeros(inputArray: Uint8Array, paddedSize: number): Uint8Array {
|
|
109
|
+
if (paddedSize < inputArray.length) {
|
|
110
|
+
throw new Error("Padded size must be greater than or equal to the input array size.");
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Create a new Uint8Array with the padded size
|
|
114
|
+
const paddedArray = new Uint8Array(paddedSize);
|
|
115
|
+
|
|
116
|
+
// Copy the content of the input array to the new array
|
|
117
|
+
paddedArray.set(inputArray);
|
|
118
|
+
|
|
119
|
+
// Fill the remaining space with zeros
|
|
120
|
+
for (let i = inputArray.length; i < paddedSize; i += 1) {
|
|
121
|
+
paddedArray[i] = 0;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return paddedArray;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function poseidonHash(inputs: (number | bigint | string)[]): bigint {
|
|
128
|
+
const poseidonFixedHash = numInputsToPoseidonFunc[inputs.length - 1];
|
|
129
|
+
|
|
130
|
+
if (poseidonFixedHash) {
|
|
131
|
+
return poseidonFixedHash(inputs);
|
|
132
|
+
}
|
|
133
|
+
throw new Error(`Unable to hash input of length ${inputs.length}`);
|
|
134
|
+
}
|
|
@@ -41,7 +41,11 @@ export class Secp256k1PublicKey extends PublicKey {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// region PublicKey
|
|
44
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Verifies a Secp256k1 signature against the public key
|
|
46
|
+
*
|
|
47
|
+
* Note signatures are validated to be canonical as a malleability check
|
|
48
|
+
*/
|
|
45
49
|
verifySignature(args: VerifySignatureArgs): boolean {
|
|
46
50
|
const { message, signature } = args;
|
|
47
51
|
if (!(signature instanceof Secp256k1Signature)) {
|
|
@@ -51,7 +55,7 @@ export class Secp256k1PublicKey extends PublicKey {
|
|
|
51
55
|
const messageBytes = Hex.fromHexInput(messageToVerify).toUint8Array();
|
|
52
56
|
const messageSha3Bytes = sha3_256(messageBytes);
|
|
53
57
|
const signatureBytes = signature.toUint8Array();
|
|
54
|
-
return secp256k1.verify(signatureBytes, messageSha3Bytes, this.key.toUint8Array());
|
|
58
|
+
return secp256k1.verify(signatureBytes, messageSha3Bytes, this.key.toUint8Array(), { lowS: true });
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
toUint8Array(): Uint8Array {
|
|
@@ -166,6 +170,8 @@ export class Secp256k1PrivateKey extends Serializable implements PrivateKey {
|
|
|
166
170
|
/**
|
|
167
171
|
* Sign the given message with the private key.
|
|
168
172
|
*
|
|
173
|
+
* Note: signatures are canonical, and non-malleable
|
|
174
|
+
*
|
|
169
175
|
* @param message a message as a string or Uint8Array
|
|
170
176
|
* @returns Signature
|
|
171
177
|
*/
|
|
@@ -173,7 +179,7 @@ export class Secp256k1PrivateKey extends Serializable implements PrivateKey {
|
|
|
173
179
|
const messageToSign = convertSigningMessage(message);
|
|
174
180
|
const messageBytes = Hex.fromHexInput(messageToSign);
|
|
175
181
|
const messageHashBytes = sha3_256(messageBytes.toUint8Array());
|
|
176
|
-
const signature = secp256k1.sign(messageHashBytes, this.key.toUint8Array());
|
|
182
|
+
const signature = secp256k1.sign(messageHashBytes, this.key.toUint8Array(), { lowS: true });
|
|
177
183
|
return new Secp256k1Signature(signature.toCompactRawBytes());
|
|
178
184
|
}
|
|
179
185
|
|
|
@@ -4,6 +4,7 @@ import { AuthenticationKey } from "../authenticationKey";
|
|
|
4
4
|
import { Ed25519PublicKey, Ed25519Signature } from "./ed25519";
|
|
5
5
|
import { AccountPublicKey, PublicKey, VerifySignatureArgs } from "./publicKey";
|
|
6
6
|
import { Secp256k1PublicKey, Secp256k1Signature } from "./secp256k1";
|
|
7
|
+
import { KeylessPublicKey, KeylessSignature } from "./keyless";
|
|
7
8
|
import { Signature } from "./signature";
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -34,6 +35,8 @@ export class AnyPublicKey extends AccountPublicKey {
|
|
|
34
35
|
this.variant = AnyPublicKeyVariant.Ed25519;
|
|
35
36
|
} else if (publicKey instanceof Secp256k1PublicKey) {
|
|
36
37
|
this.variant = AnyPublicKeyVariant.Secp256k1;
|
|
38
|
+
} else if (publicKey instanceof KeylessPublicKey) {
|
|
39
|
+
this.variant = AnyPublicKeyVariant.Keyless;
|
|
37
40
|
} else {
|
|
38
41
|
throw new Error("Unsupported public key type");
|
|
39
42
|
}
|
|
@@ -85,6 +88,9 @@ export class AnyPublicKey extends AccountPublicKey {
|
|
|
85
88
|
case AnyPublicKeyVariant.Secp256k1:
|
|
86
89
|
publicKey = Secp256k1PublicKey.deserialize(deserializer);
|
|
87
90
|
break;
|
|
91
|
+
case AnyPublicKeyVariant.Keyless:
|
|
92
|
+
publicKey = KeylessPublicKey.deserialize(deserializer);
|
|
93
|
+
break;
|
|
88
94
|
default:
|
|
89
95
|
throw new Error(`Unknown variant index for AnyPublicKey: ${variantIndex}`);
|
|
90
96
|
}
|
|
@@ -138,6 +144,8 @@ export class AnySignature extends Signature {
|
|
|
138
144
|
this.variant = AnySignatureVariant.Ed25519;
|
|
139
145
|
} else if (signature instanceof Secp256k1Signature) {
|
|
140
146
|
this.variant = AnySignatureVariant.Secp256k1;
|
|
147
|
+
} else if (signature instanceof KeylessSignature) {
|
|
148
|
+
this.variant = AnySignatureVariant.Keyless;
|
|
141
149
|
} else {
|
|
142
150
|
throw new Error("Unsupported signature type");
|
|
143
151
|
}
|
|
@@ -170,6 +178,9 @@ export class AnySignature extends Signature {
|
|
|
170
178
|
case AnySignatureVariant.Secp256k1:
|
|
171
179
|
signature = Secp256k1Signature.deserialize(deserializer);
|
|
172
180
|
break;
|
|
181
|
+
case AnySignatureVariant.Keyless:
|
|
182
|
+
signature = KeylessSignature.deserialize(deserializer);
|
|
183
|
+
break;
|
|
173
184
|
default:
|
|
174
185
|
throw new Error(`Unknown variant index for AnySignature: ${variantIndex}`);
|
|
175
186
|
}
|
package/src/core/index.ts
CHANGED
package/src/index.ts
CHANGED
package/src/internal/account.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { AptosConfig } from "../api/aptosConfig";
|
|
12
12
|
import { AptosApiError, getAptosFullNode, paginateWithCursor } from "../client";
|
|
13
13
|
import { AccountAddress, AccountAddressInput } from "../core/accountAddress";
|
|
14
|
-
import { Account } from "../
|
|
14
|
+
import { Account } from "../account";
|
|
15
15
|
import { AnyPublicKey, Ed25519PublicKey, PrivateKey } from "../core/crypto";
|
|
16
16
|
import { getTableItem, queryIndexer } from "./general";
|
|
17
17
|
import {
|
|
@@ -27,7 +27,6 @@ import {
|
|
|
27
27
|
MoveStructId,
|
|
28
28
|
OrderByArg,
|
|
29
29
|
PaginationArgs,
|
|
30
|
-
SigningScheme,
|
|
31
30
|
TokenStandardArg,
|
|
32
31
|
TransactionResponse,
|
|
33
32
|
WhereArg,
|
|
@@ -528,16 +527,15 @@ export async function deriveAccountFromPrivateKey(args: {
|
|
|
528
527
|
|
|
529
528
|
if (privateKey instanceof Secp256k1PrivateKey) {
|
|
530
529
|
// private key is secp256k1, therefore we know it for sure uses a single signer key
|
|
531
|
-
const authKey = AuthenticationKey.
|
|
530
|
+
const authKey = AuthenticationKey.fromPublicKey({ publicKey });
|
|
532
531
|
const address = authKey.derivedAddress();
|
|
533
|
-
return Account.
|
|
532
|
+
return Account.fromPrivateKey({ privateKey, address });
|
|
534
533
|
}
|
|
535
534
|
|
|
536
535
|
if (privateKey instanceof Ed25519PrivateKey) {
|
|
537
536
|
// lookup single sender ed25519
|
|
538
|
-
const singleSenderTransactionAuthenticatorAuthKey = AuthenticationKey.
|
|
537
|
+
const singleSenderTransactionAuthenticatorAuthKey = AuthenticationKey.fromPublicKey({
|
|
539
538
|
publicKey,
|
|
540
|
-
scheme: SigningScheme.SingleKey,
|
|
541
539
|
});
|
|
542
540
|
const isSingleSenderTransactionAuthenticator = await isAccountExist({
|
|
543
541
|
authKey: singleSenderTransactionAuthenticatorAuthKey,
|
|
@@ -545,17 +543,16 @@ export async function deriveAccountFromPrivateKey(args: {
|
|
|
545
543
|
});
|
|
546
544
|
if (isSingleSenderTransactionAuthenticator) {
|
|
547
545
|
const address = singleSenderTransactionAuthenticatorAuthKey.derivedAddress();
|
|
548
|
-
return Account.
|
|
546
|
+
return Account.fromPrivateKey({ privateKey, address, legacy: false });
|
|
549
547
|
}
|
|
550
548
|
// lookup legacy ed25519
|
|
551
|
-
const legacyAuthKey = AuthenticationKey.
|
|
549
|
+
const legacyAuthKey = AuthenticationKey.fromPublicKey({
|
|
552
550
|
publicKey: publicKey.publicKey as Ed25519PublicKey,
|
|
553
|
-
scheme: SigningScheme.Ed25519,
|
|
554
551
|
});
|
|
555
552
|
const isLegacyEd25519 = await isAccountExist({ authKey: legacyAuthKey, aptosConfig });
|
|
556
553
|
if (isLegacyEd25519) {
|
|
557
554
|
const address = legacyAuthKey.derivedAddress();
|
|
558
|
-
return Account.
|
|
555
|
+
return Account.fromPrivateKey({ privateKey, address, legacy: true });
|
|
559
556
|
}
|
|
560
557
|
}
|
|
561
558
|
// if we are here, it means we couldn't find an address with an
|
package/src/internal/ans.ts
CHANGED
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
* name namespace and without having a dependency cycle error.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import { Account } from "../account";
|
|
11
12
|
import { AptosConfig } from "../api/aptosConfig";
|
|
12
|
-
import {
|
|
13
|
+
import { AccountAddress, AccountAddressInput } from "../core";
|
|
13
14
|
import { InputGenerateTransactionOptions } from "../transactions/types";
|
|
14
15
|
import { GetANSNameResponse, MoveAddressType, OrderByArg, PaginationArgs, WhereArg } from "../types";
|
|
15
16
|
import { GetNamesQuery } from "../types/generated/operations";
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import { AptosConfig } from "../api/aptosConfig";
|
|
12
12
|
import { Bool, MoveString, MoveVector, U64 } from "../bcs";
|
|
13
|
-
import {
|
|
13
|
+
import { AccountAddress, AccountAddressInput } from "../core";
|
|
14
14
|
import { EntryFunctionABI, InputGenerateTransactionOptions } from "../transactions/types";
|
|
15
15
|
import {
|
|
16
16
|
AnyNumber,
|
|
@@ -53,6 +53,7 @@ import {
|
|
|
53
53
|
TypeTagU64,
|
|
54
54
|
TypeTagVector,
|
|
55
55
|
} from "../transactions";
|
|
56
|
+
import { Account } from "../account";
|
|
56
57
|
import { SimpleTransaction } from "../transactions/instances/simpleTransaction";
|
|
57
58
|
|
|
58
59
|
// A property type map for the user input and what Move expects
|
|
@@ -447,7 +448,7 @@ export async function mintSoulBoundTransaction(args: {
|
|
|
447
448
|
description: string;
|
|
448
449
|
name: string;
|
|
449
450
|
uri: string;
|
|
450
|
-
recipient:
|
|
451
|
+
recipient: AccountAddressInput;
|
|
451
452
|
propertyKeys?: Array<string>;
|
|
452
453
|
propertyTypes?: Array<PropertyType>;
|
|
453
454
|
propertyValues?: Array<PropertyValue>;
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
FungibleAssetActivitiesBoolExp,
|
|
34
34
|
FungibleAssetMetadataBoolExp,
|
|
35
35
|
} from "../types/generated/types";
|
|
36
|
-
import {
|
|
36
|
+
import { AccountAddressInput } from "../core";
|
|
37
37
|
import {
|
|
38
38
|
EntryFunctionABI,
|
|
39
39
|
InputGenerateTransactionOptions,
|
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
TypeTagU64,
|
|
43
43
|
} from "../transactions";
|
|
44
44
|
import { generateTransaction } from "./transactionSubmission";
|
|
45
|
+
import { Account } from "../account";
|
|
45
46
|
import { SimpleTransaction } from "../transactions/instances/simpleTransaction";
|
|
46
47
|
|
|
47
48
|
export async function getFungibleAssetMetadata(args: {
|
|
@@ -124,8 +125,8 @@ const faTransferAbi: EntryFunctionABI = {
|
|
|
124
125
|
export async function transferFungibleAsset(args: {
|
|
125
126
|
aptosConfig: AptosConfig;
|
|
126
127
|
sender: Account;
|
|
127
|
-
fungibleAssetMetadataAddress:
|
|
128
|
-
recipient:
|
|
128
|
+
fungibleAssetMetadataAddress: AccountAddressInput;
|
|
129
|
+
recipient: AccountAddressInput;
|
|
129
130
|
amount: AnyNumber;
|
|
130
131
|
options?: InputGenerateTransactionOptions;
|
|
131
132
|
}): Promise<SimpleTransaction> {
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
// Copyright © Aptos Foundation
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This file contains the underlying implementations for exposed API surface in
|
|
6
|
+
* the {@link api/oidb}. By moving the methods out into a separate file,
|
|
7
|
+
* other namespaces and processes can access these methods without depending on the entire
|
|
8
|
+
* faucet namespace and without having a dependency cycle error.
|
|
9
|
+
*/
|
|
10
|
+
import { jwtDecode } from "jwt-decode";
|
|
11
|
+
import { bls12_381 as bls } from "@noble/curves/bls12-381";
|
|
12
|
+
import { ProjPointType } from "@noble/curves/abstract/weierstrass";
|
|
13
|
+
import { AptosConfig } from "../api/aptosConfig";
|
|
14
|
+
import { getAptosPepperService, postAptosPepperService, postAptosProvingService } from "../client";
|
|
15
|
+
import {
|
|
16
|
+
APTOS_BIP44_DEFAULT_DERIVATION_PATH,
|
|
17
|
+
EPK_HORIZON_SECS,
|
|
18
|
+
EphemeralSignature,
|
|
19
|
+
Groth16Zkp,
|
|
20
|
+
Hex,
|
|
21
|
+
MultiKey,
|
|
22
|
+
SignedGroth16Signature,
|
|
23
|
+
} from "../core";
|
|
24
|
+
import { HexInput } from "../types";
|
|
25
|
+
import { Serializer } from "../bcs";
|
|
26
|
+
import { EphemeralKeyPair, KeylessAccount, MultiKeyAccount } from "../account";
|
|
27
|
+
import { PepperFetchResponse, ProverResponse } from "../types/keyless";
|
|
28
|
+
|
|
29
|
+
const APTOS_KEYLESS_PEPPER_PINKAS_VUF_DST = "APTOS_KEYLESS_PEPPER_PINKAS_VUF_DST";
|
|
30
|
+
|
|
31
|
+
function stringToUint8Array(str: string): Uint8Array {
|
|
32
|
+
const encoder = new TextEncoder();
|
|
33
|
+
return encoder.encode(str);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const PINKAS_VUF_SECRET_KEY_BASE_AFFINE = bls.G2.hashToCurve(
|
|
37
|
+
stringToUint8Array("APTOS_KEYLESS_PEPPER_PINKAS_VUF_SECRET_KEY_BASE"),
|
|
38
|
+
{ DST: APTOS_KEYLESS_PEPPER_PINKAS_VUF_DST },
|
|
39
|
+
).toAffine();
|
|
40
|
+
|
|
41
|
+
function getPepperInput(args: { jwt: string; uidKey?: string }): ProjPointType<bigint> {
|
|
42
|
+
const { jwt, uidKey } = args;
|
|
43
|
+
const jwtPayload = jwtDecode<{ [key: string]: string }>(jwt);
|
|
44
|
+
const serializer = new Serializer();
|
|
45
|
+
serializer.serializeStr(jwtPayload.iss);
|
|
46
|
+
serializer.serializeStr(jwtPayload.aud);
|
|
47
|
+
serializer.serializeStr(jwtPayload[uidKey || "sub"]);
|
|
48
|
+
serializer.serializeStr(uidKey || "sub");
|
|
49
|
+
const serial = serializer.toUint8Array();
|
|
50
|
+
const msg = bls.G1.hashToCurve(serial, { DST: "APTOS_PEPPER_SERVICE_BLS12381_VUF_DST" }).toAffine();
|
|
51
|
+
const pp = bls.G1.ProjectivePoint.fromAffine(msg);
|
|
52
|
+
return pp;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function verifyPepperBase(args: {
|
|
56
|
+
aptosConfig: AptosConfig;
|
|
57
|
+
pepperInput: ProjPointType<bigint>;
|
|
58
|
+
pepperBase: Uint8Array;
|
|
59
|
+
}): Promise<boolean> {
|
|
60
|
+
const { aptosConfig, pepperInput, pepperBase } = args;
|
|
61
|
+
const { data: pubKeyResponse } = await getAptosPepperService<any, { vrf_public_key_hex_string: string }>({
|
|
62
|
+
aptosConfig,
|
|
63
|
+
path: "vrf-pub-key",
|
|
64
|
+
originMethod: "getPepper",
|
|
65
|
+
});
|
|
66
|
+
const publicKeyFromService = bls.G2.ProjectivePoint.fromHex(pubKeyResponse.vrf_public_key_hex_string);
|
|
67
|
+
return bls.verifyShortSignature(pepperBase, pepperInput, publicKeyFromService);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export async function getPepper(args: {
|
|
71
|
+
aptosConfig: AptosConfig;
|
|
72
|
+
jwt: string;
|
|
73
|
+
ephemeralKeyPair: EphemeralKeyPair;
|
|
74
|
+
uidKey?: string;
|
|
75
|
+
derivationPath?: string;
|
|
76
|
+
verify?: boolean;
|
|
77
|
+
}): Promise<Uint8Array> {
|
|
78
|
+
const { aptosConfig, jwt, ephemeralKeyPair, uidKey, verify } = args;
|
|
79
|
+
let { derivationPath } = args;
|
|
80
|
+
|
|
81
|
+
const body = {
|
|
82
|
+
jwt_b64: jwt,
|
|
83
|
+
epk: ephemeralKeyPair.publicKey.bcsToHex().toStringWithoutPrefix(),
|
|
84
|
+
exp_date_secs: Number(ephemeralKeyPair.expiryDateSecs),
|
|
85
|
+
epk_blinder: Hex.fromHexInput(ephemeralKeyPair.blinder).toStringWithoutPrefix(),
|
|
86
|
+
uid_key: uidKey,
|
|
87
|
+
};
|
|
88
|
+
// console.log(JSON.stringify(body));
|
|
89
|
+
const { data } = await postAptosPepperService<any, PepperFetchResponse>({
|
|
90
|
+
aptosConfig,
|
|
91
|
+
path: "fetch",
|
|
92
|
+
body,
|
|
93
|
+
originMethod: "getPepper",
|
|
94
|
+
overrides: { WITH_CREDENTIALS: false },
|
|
95
|
+
});
|
|
96
|
+
const pepperBase = Hex.fromHexInput(data.signature).toUint8Array();
|
|
97
|
+
|
|
98
|
+
if (verify) {
|
|
99
|
+
const pepperVerified = verifyPepperBase({ aptosConfig, pepperBase, pepperInput: getPepperInput(args) });
|
|
100
|
+
if (!pepperVerified) {
|
|
101
|
+
throw new Error("Unable to verify");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// This takes the BLS VUF H(m)^sk and transforms it into a Pinkas VUF e(H(m), g_3^sk), where g_3 is the base of the secret key (computed pseudo-randomly via hash-to-curve).
|
|
105
|
+
// This gives us the freedom of either decentralizing the pepper service as a BLS-based MPC or on top of the validators, by reusing the Pinkas WVUF-based randomness infrastructure.
|
|
106
|
+
const newPepperBase = bls.pairing(
|
|
107
|
+
bls.G1.ProjectivePoint.fromHex(pepperBase),
|
|
108
|
+
bls.G2.ProjectivePoint.fromAffine(PINKAS_VUF_SECRET_KEY_BASE_AFFINE),
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
if (derivationPath === undefined) {
|
|
112
|
+
derivationPath = APTOS_BIP44_DEFAULT_DERIVATION_PATH;
|
|
113
|
+
}
|
|
114
|
+
const pepper = KeylessAccount.fromDerivationPath(derivationPath, bls.fields.Fp12.toBytes(newPepperBase));
|
|
115
|
+
return pepper.slice(0, 31);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export async function getProof(args: {
|
|
119
|
+
aptosConfig: AptosConfig;
|
|
120
|
+
jwt: string;
|
|
121
|
+
ephemeralKeyPair: EphemeralKeyPair;
|
|
122
|
+
pepper: HexInput;
|
|
123
|
+
uidKey?: string;
|
|
124
|
+
extraFieldKey?: string;
|
|
125
|
+
}): Promise<SignedGroth16Signature> {
|
|
126
|
+
const { aptosConfig, jwt, ephemeralKeyPair, pepper, uidKey, extraFieldKey } = args;
|
|
127
|
+
const jwtPayload = jwtDecode<{ [key: string]: string }>(jwt);
|
|
128
|
+
let extraField;
|
|
129
|
+
if (extraFieldKey) {
|
|
130
|
+
const extraFieldVal = jwtPayload[extraFieldKey];
|
|
131
|
+
extraField = `"${extraFieldKey}":"${extraFieldVal}",`;
|
|
132
|
+
}
|
|
133
|
+
const json = {
|
|
134
|
+
jwt_b64: jwt,
|
|
135
|
+
epk: ephemeralKeyPair.publicKey.bcsToHex().toStringWithoutPrefix(),
|
|
136
|
+
epk_blinder: Hex.fromHexInput(ephemeralKeyPair.blinder).toStringWithoutPrefix(),
|
|
137
|
+
exp_date_secs: Number(ephemeralKeyPair.expiryDateSecs),
|
|
138
|
+
exp_horizon_secs: EPK_HORIZON_SECS,
|
|
139
|
+
pepper: Hex.fromHexInput(pepper).toStringWithoutPrefix(),
|
|
140
|
+
extra_field: extraFieldKey,
|
|
141
|
+
uid_key: uidKey || "sub",
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const { data } = await postAptosProvingService<any, ProverResponse>({
|
|
145
|
+
aptosConfig,
|
|
146
|
+
path: "prove",
|
|
147
|
+
body: json,
|
|
148
|
+
originMethod: "getProof",
|
|
149
|
+
overrides: { WITH_CREDENTIALS: false },
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const proofPoints = data.proof;
|
|
153
|
+
const proof = new Groth16Zkp({
|
|
154
|
+
a: proofPoints.a,
|
|
155
|
+
b: proofPoints.b,
|
|
156
|
+
c: proofPoints.c,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const signedProof = new SignedGroth16Signature({
|
|
160
|
+
proof,
|
|
161
|
+
extraField,
|
|
162
|
+
trainingWheelsSignature: EphemeralSignature.fromHex(data.training_wheels_signature),
|
|
163
|
+
});
|
|
164
|
+
return signedProof;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export async function deriveKeylessAccount(args: {
|
|
168
|
+
aptosConfig: AptosConfig;
|
|
169
|
+
jwt: string;
|
|
170
|
+
ephemeralKeyPair: EphemeralKeyPair;
|
|
171
|
+
uidKey?: string;
|
|
172
|
+
pepper?: HexInput;
|
|
173
|
+
extraFieldKey?: string;
|
|
174
|
+
disableConnect?: boolean;
|
|
175
|
+
fetchProofAsync?: boolean;
|
|
176
|
+
}): Promise<KeylessAccount | MultiKeyAccount> {
|
|
177
|
+
const { fetchProofAsync } = args;
|
|
178
|
+
let { pepper, disableConnect } = args;
|
|
179
|
+
|
|
180
|
+
if (pepper || disableConnect) {
|
|
181
|
+
disableConnect = true;
|
|
182
|
+
}
|
|
183
|
+
if (pepper === undefined) {
|
|
184
|
+
pepper = await getPepper(args);
|
|
185
|
+
} else if (Hex.fromHexInput(pepper).toUint8Array().length !== 31) {
|
|
186
|
+
throw new Error("Pepper needs to be 31 bytes");
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const proofPromise = getProof({ ...args, pepper });
|
|
190
|
+
const proof = fetchProofAsync ? proofPromise : await proofPromise;
|
|
191
|
+
|
|
192
|
+
const keylessAccount = KeylessAccount.fromJWTAndProof({ ...args, proofFetcherOrData: proof, pepper });
|
|
193
|
+
|
|
194
|
+
if (disableConnect === true) {
|
|
195
|
+
return keylessAccount;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const aptosConnectPublicKey = keylessAccount.deriveAptosConnectPublicKey();
|
|
199
|
+
|
|
200
|
+
const multiKey = new MultiKey({
|
|
201
|
+
publicKeys: [keylessAccount.publicKey, aptosConnectPublicKey],
|
|
202
|
+
signaturesRequired: 1,
|
|
203
|
+
});
|
|
204
|
+
return new MultiKeyAccount({ multiKey, signers: [keylessAccount] });
|
|
205
|
+
}
|
|
@@ -97,6 +97,19 @@ export async function isTransactionPending(args: {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
export async function longWaitForTransaction(args: {
|
|
101
|
+
aptosConfig: AptosConfig;
|
|
102
|
+
transactionHash: HexInput;
|
|
103
|
+
}): Promise<TransactionResponse> {
|
|
104
|
+
const { aptosConfig, transactionHash } = args;
|
|
105
|
+
const { data } = await getAptosFullNode<{}, TransactionResponse>({
|
|
106
|
+
aptosConfig,
|
|
107
|
+
path: `transactions/wait_by_hash/${transactionHash}`,
|
|
108
|
+
originMethod: "longWaitForTransaction",
|
|
109
|
+
});
|
|
110
|
+
return data;
|
|
111
|
+
}
|
|
112
|
+
|
|
100
113
|
export async function waitForTransaction(args: {
|
|
101
114
|
aptosConfig: AptosConfig;
|
|
102
115
|
transactionHash: HexInput;
|
|
@@ -113,6 +126,40 @@ export async function waitForTransaction(args: {
|
|
|
113
126
|
let backoffIntervalMs = 200;
|
|
114
127
|
const backoffMultiplier = 1.5;
|
|
115
128
|
|
|
129
|
+
function handleAPIError(e: any) {
|
|
130
|
+
// In short, this means we will retry if it was an AptosApiError and the code was 404 or 5xx.
|
|
131
|
+
const isAptosApiError = e instanceof AptosApiError;
|
|
132
|
+
if (!isAptosApiError) {
|
|
133
|
+
throw e; // This would be unexpected
|
|
134
|
+
}
|
|
135
|
+
lastError = e;
|
|
136
|
+
const isRequestError = e.status !== 404 && e.status >= 400 && e.status < 500;
|
|
137
|
+
if (isRequestError) {
|
|
138
|
+
throw e;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// check to see if the txn is already on the blockchain
|
|
143
|
+
try {
|
|
144
|
+
lastTxn = await getTransactionByHash({ aptosConfig, transactionHash });
|
|
145
|
+
isPending = lastTxn.type === TransactionResponseType.Pending;
|
|
146
|
+
} catch (e) {
|
|
147
|
+
handleAPIError(e);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// If the transaction is pending, we do a long wait once to avoid polling
|
|
151
|
+
if (isPending) {
|
|
152
|
+
const startTime = Date.now();
|
|
153
|
+
try {
|
|
154
|
+
lastTxn = await longWaitForTransaction({ aptosConfig, transactionHash });
|
|
155
|
+
isPending = lastTxn.type === TransactionResponseType.Pending;
|
|
156
|
+
} catch (e) {
|
|
157
|
+
handleAPIError(e);
|
|
158
|
+
}
|
|
159
|
+
timeElapsed = (Date.now() - startTime) / 1000;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Now we do polling to see if the transaction is still pending
|
|
116
163
|
while (isPending) {
|
|
117
164
|
if (timeElapsed >= timeoutSecs) {
|
|
118
165
|
break;
|
|
@@ -127,16 +174,7 @@ export async function waitForTransaction(args: {
|
|
|
127
174
|
break;
|
|
128
175
|
}
|
|
129
176
|
} catch (e) {
|
|
130
|
-
|
|
131
|
-
const isAptosApiError = e instanceof AptosApiError;
|
|
132
|
-
if (!isAptosApiError) {
|
|
133
|
-
throw e; // This would be unexpected
|
|
134
|
-
}
|
|
135
|
-
lastError = e;
|
|
136
|
-
const isRequestError = e.status !== 404 && e.status >= 400 && e.status < 500;
|
|
137
|
-
if (isRequestError) {
|
|
138
|
-
throw e;
|
|
139
|
-
}
|
|
177
|
+
handleAPIError(e);
|
|
140
178
|
}
|
|
141
179
|
// eslint-disable-next-line no-await-in-loop
|
|
142
180
|
await sleep(backoffIntervalMs);
|