@aptos-labs/ts-sdk 1.28.0 → 1.29.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/README.md +103 -82
- package/dist/common/{accountAddress-OVl7-qVN.d.ts → accountAddress-DUCC2ffJ.d.ts} +9 -2
- package/dist/common/cli/index.d.ts +1 -1
- package/dist/common/index.d.ts +266 -42
- package/dist/common/index.js +28 -28
- package/dist/common/index.js.map +1 -1
- package/dist/esm/account/AbstractKeylessAccount.d.mts +207 -0
- package/dist/esm/account/AbstractKeylessAccount.mjs +2 -0
- package/dist/esm/account/Account.mjs +1 -1
- package/dist/esm/account/Ed25519Account.mjs +1 -1
- package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
- package/dist/esm/account/FederatedKeylessAccount.d.mts +75 -0
- package/dist/esm/account/FederatedKeylessAccount.mjs +2 -0
- package/dist/esm/account/KeylessAccount.d.mts +13 -130
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/index.d.mts +4 -1
- package/dist/esm/account/index.mjs +1 -1
- package/dist/esm/api/account.d.mts +1 -1
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +4 -0
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/coin.d.mts +2 -2
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +2 -2
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.d.mts +1 -1
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +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.d.mts +4 -0
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.d.mts +34 -20
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/object.d.mts +2 -2
- package/dist/esm/api/object.mjs +1 -1
- package/dist/esm/api/staking.d.mts +2 -2
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/table.d.mts +1 -1
- package/dist/esm/api/table.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +33 -9
- 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/bcs/index.mjs +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/{chunk-OTNGLTKS.mjs → chunk-2BTTX2KO.mjs} +2 -2
- package/dist/esm/{chunk-NPFW6ZFY.mjs → chunk-2F7Z7RMW.mjs} +2 -2
- package/dist/esm/{chunk-P2EKDA7R.mjs → chunk-367OG3DB.mjs} +2 -2
- package/dist/esm/{chunk-5L3UXSQI.mjs → chunk-3W2DHZXK.mjs} +2 -2
- package/dist/esm/chunk-44GYWUSH.mjs +2 -0
- package/dist/esm/chunk-44GYWUSH.mjs.map +1 -0
- package/dist/esm/{chunk-UWPO7WWS.mjs → chunk-45IUUCAV.mjs} +2 -2
- package/dist/esm/{chunk-YFMFXRJX.mjs → chunk-4HR32TSY.mjs} +2 -2
- package/dist/esm/chunk-4TB3AWQE.mjs +2 -0
- package/dist/esm/chunk-4TB3AWQE.mjs.map +1 -0
- package/dist/esm/{chunk-3HTSCV3R.mjs → chunk-53RB2PRH.mjs} +2 -2
- package/dist/esm/{chunk-GKERWKMB.mjs → chunk-5PCNWXRN.mjs} +2 -2
- package/dist/esm/{chunk-OPTI3MH2.mjs → chunk-5VD4MHB3.mjs} +2 -2
- package/dist/esm/{chunk-VTEZ6TBO.mjs → chunk-6UZ3VI5Y.mjs} +2 -2
- package/dist/esm/{chunk-Z2AJWV6D.mjs → chunk-7VKFXX5Q.mjs} +2 -2
- package/dist/esm/{chunk-GR4PHW7K.mjs → chunk-A42BPAD4.mjs} +2 -2
- package/dist/esm/{chunk-QQHA2Y46.mjs → chunk-ADE6MVXC.mjs} +2 -2
- package/dist/esm/chunk-ADE6MVXC.mjs.map +1 -0
- package/dist/esm/{chunk-2CAGPXCX.mjs → chunk-APN6AV5Q.mjs} +2 -2
- package/dist/esm/chunk-BA4RBST6.mjs +2 -0
- package/dist/esm/chunk-BA4RBST6.mjs.map +1 -0
- package/dist/esm/{chunk-4ENUSVZB.mjs → chunk-BSAHPS6E.mjs} +2 -2
- package/dist/esm/{chunk-NDJKEFNU.mjs → chunk-BWNTSJOC.mjs} +2 -2
- package/dist/esm/chunk-CB6H4VMZ.mjs +2 -0
- package/dist/esm/chunk-CB6H4VMZ.mjs.map +1 -0
- package/dist/esm/{chunk-LS6G4DZV.mjs → chunk-CRA2MFJC.mjs} +2 -2
- package/dist/esm/{chunk-VQVNUN5Y.mjs → chunk-D3Q4BC3I.mjs} +2 -2
- package/dist/esm/chunk-E4O26ZJB.mjs +2 -0
- package/dist/esm/chunk-E4O26ZJB.mjs.map +1 -0
- package/dist/esm/{chunk-5TBIWC7N.mjs → chunk-ELYS7CWV.mjs} +2 -2
- package/dist/esm/chunk-F3M2UQA4.mjs +2 -0
- package/dist/esm/chunk-F3M2UQA4.mjs.map +1 -0
- package/dist/esm/{chunk-ZXYTLPP6.mjs → chunk-F63E4CR7.mjs} +2 -2
- package/dist/esm/{chunk-JOROI7FE.mjs → chunk-F76N4MQO.mjs} +2 -2
- package/dist/esm/{chunk-F5PNGH44.mjs → chunk-FZ5EYP3D.mjs} +2 -2
- package/dist/esm/chunk-G5XLMQ5E.mjs +2 -0
- package/dist/esm/chunk-G5XLMQ5E.mjs.map +1 -0
- package/dist/esm/chunk-GAEAYY44.mjs +1 -0
- package/dist/esm/chunk-GAEAYY44.mjs.map +1 -0
- package/dist/esm/{chunk-O4BBULNE.mjs → chunk-GDO6Q2FI.mjs} +2 -2
- package/dist/esm/{chunk-WYQLUB4H.mjs → chunk-GDUAFXIQ.mjs} +2 -2
- package/dist/esm/chunk-GMBSQDPO.mjs +2 -0
- package/dist/esm/chunk-GMBSQDPO.mjs.map +1 -0
- package/dist/esm/{chunk-Q7MD4V7H.mjs → chunk-GWSDIX6C.mjs} +2 -2
- package/dist/esm/chunk-HEZ2ZYZA.mjs +1 -0
- package/dist/esm/chunk-HEZ2ZYZA.mjs.map +1 -0
- package/dist/esm/{chunk-WX6P3Q4I.mjs → chunk-HHGJXVAE.mjs} +2 -2
- package/dist/esm/{chunk-AVSM2BJR.mjs → chunk-HKBBA653.mjs} +2 -2
- package/dist/esm/{chunk-6CHBLB3V.mjs → chunk-HVMFZF6P.mjs} +2 -2
- package/dist/esm/{chunk-ZNC3FRSK.mjs → chunk-IR4SLC2M.mjs} +2 -2
- package/dist/esm/{chunk-GGPA6QTN.mjs → chunk-J64ARI4E.mjs} +2 -2
- package/dist/esm/{chunk-3F3FCWT5.mjs → chunk-JH6VLTMS.mjs} +2 -2
- package/dist/esm/{chunk-ORGMRM5K.mjs → chunk-KUOB4DDE.mjs} +2 -2
- package/dist/esm/{chunk-2XYA7NOU.mjs → chunk-KUZ2YTJH.mjs} +2 -2
- package/dist/esm/{chunk-HBQLX5QF.mjs → chunk-L2QXU6F4.mjs} +2 -2
- package/dist/esm/{chunk-QQU4IQ27.mjs → chunk-LNEZEYYE.mjs} +2 -2
- package/dist/esm/{chunk-53DBMWMU.mjs → chunk-MAMPMCO7.mjs} +2 -2
- package/dist/esm/chunk-MDJ66AA3.mjs +2 -0
- package/dist/esm/chunk-MDJ66AA3.mjs.map +1 -0
- package/dist/esm/{chunk-56F7EYFE.mjs → chunk-MNVUSJEK.mjs} +2 -2
- package/dist/esm/{chunk-SUAA25UP.mjs → chunk-O2BPA6TS.mjs} +2 -2
- package/dist/esm/{chunk-NKDHR2DA.mjs → chunk-OKAQO57B.mjs} +2 -2
- package/dist/esm/chunk-OMV7445F.mjs +2 -0
- package/dist/esm/chunk-OMV7445F.mjs.map +1 -0
- package/dist/esm/chunk-P2EIZ7WL.mjs +2 -0
- package/dist/esm/chunk-P2EIZ7WL.mjs.map +1 -0
- package/dist/esm/{chunk-PDNA4H34.mjs → chunk-P3TAY5PP.mjs} +2 -2
- package/dist/esm/{chunk-EJMPY5MF.mjs → chunk-Q3TAEOH5.mjs} +2 -2
- package/dist/esm/chunk-Q4XR6QOZ.mjs +2 -0
- package/dist/esm/{chunk-F7EMGK4M.mjs.map → chunk-Q4XR6QOZ.mjs.map} +1 -1
- package/dist/esm/{chunk-MNVDBUF3.mjs → chunk-QBSU3L5Q.mjs} +2 -2
- package/dist/esm/{chunk-3GOJQ5JD.mjs → chunk-QPB6EJVM.mjs} +2 -2
- package/dist/esm/{chunk-KRIIRH5L.mjs → chunk-R76DHMGR.mjs} +2 -2
- package/dist/esm/{chunk-52HZTDBB.mjs → chunk-RXE6NNOL.mjs} +2 -2
- package/dist/esm/chunk-RXE6NNOL.mjs.map +1 -0
- package/dist/esm/{chunk-JUNVPIW4.mjs → chunk-S2KDCIZN.mjs} +2 -2
- package/dist/esm/{chunk-YPQZJ72F.mjs → chunk-S2W4D6NZ.mjs} +2 -2
- package/dist/esm/{chunk-5P7MXLZA.mjs → chunk-SDWE6WMM.mjs} +2 -2
- package/dist/esm/chunk-SRPI2FFA.mjs +2 -0
- package/dist/esm/chunk-SRPI2FFA.mjs.map +1 -0
- package/dist/esm/chunk-STUXKQVZ.mjs +2 -0
- package/dist/esm/chunk-STUXKQVZ.mjs.map +1 -0
- package/dist/esm/{chunk-WLZYSLHP.mjs → chunk-SWNFKKRE.mjs} +2 -2
- package/dist/esm/{chunk-DVIRUFCY.mjs → chunk-TQWGQLM6.mjs} +2 -2
- package/dist/esm/chunk-UAEODDZS.mjs +2 -0
- package/dist/esm/{chunk-ZXVQ2OBJ.mjs.map → chunk-UAEODDZS.mjs.map} +1 -1
- package/dist/esm/{chunk-VYXJ7FUF.mjs → chunk-WJRZWAIS.mjs} +2 -2
- package/dist/esm/{chunk-LFUBUXHD.mjs → chunk-X34JJPW5.mjs} +2 -2
- package/dist/esm/{chunk-EXMQBH3I.mjs → chunk-XMW65WCQ.mjs} +2 -2
- package/dist/esm/chunk-Y2GWUE7C.mjs +2 -0
- package/dist/esm/chunk-Y2GWUE7C.mjs.map +1 -0
- package/dist/esm/chunk-Y3BATGHX.mjs +2 -0
- package/dist/esm/chunk-Y3BATGHX.mjs.map +1 -0
- package/dist/esm/{chunk-54QUDAAC.mjs → chunk-YU3IYJRL.mjs} +2 -2
- package/dist/esm/{chunk-NBO2BDDZ.mjs → chunk-ZROQH5YL.mjs} +2 -2
- package/dist/esm/cli/index.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/account/index.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.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.mjs +1 -1
- package/dist/esm/core/crypto/federatedKeyless.d.mts +97 -0
- package/dist/esm/core/crypto/federatedKeyless.mjs +2 -0
- package/dist/esm/core/crypto/federatedKeyless.mjs.map +1 -0
- package/dist/esm/core/crypto/index.d.mts +4 -2
- 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/poseidon.d.mts +1 -1
- package/dist/esm/core/crypto/poseidon.mjs +1 -1
- package/dist/esm/core/crypto/proof.mjs +1 -1
- package/dist/esm/core/crypto/publicKey.mjs +1 -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.mjs +1 -1
- package/dist/esm/core/crypto/utils.mjs +1 -1
- package/dist/esm/core/index.d.mts +2 -0
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/index.d.mts +6 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/account.d.mts +1 -7
- 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/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.d.mts +25 -14
- 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 +22 -2
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- 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.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/rotationProofChallenge.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/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- 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.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/types/index.d.mts +8 -1
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/normalizeBundle.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/src/account/AbstractKeylessAccount.ts +329 -0
- package/src/account/EphemeralKeyPair.ts +9 -2
- package/src/account/FederatedKeylessAccount.ts +116 -0
- package/src/account/KeylessAccount.ts +13 -297
- package/src/account/MultiKeyAccount.ts +4 -2
- package/src/account/index.ts +2 -0
- package/src/api/account.ts +68 -22
- package/src/api/keyless.ts +50 -4
- package/src/api/transaction.ts +40 -20
- package/src/core/crypto/federatedKeyless.ts +134 -0
- package/src/core/crypto/index.ts +2 -0
- package/src/core/crypto/keyless.ts +4 -3
- package/src/core/crypto/poseidon.ts +4 -4
- package/src/core/crypto/singleKey.ts +6 -0
- package/src/core/crypto/utils.ts +2 -2
- package/src/internal/account.ts +1 -54
- package/src/internal/keyless.ts +86 -8
- package/src/internal/transactionSubmission.ts +63 -10
- package/src/transactions/transactionBuilder/transactionBuilder.ts +25 -14
- package/src/types/index.ts +7 -0
- package/src/version.ts +1 -1
- package/dist/esm/chunk-52HZTDBB.mjs.map +0 -1
- package/dist/esm/chunk-7Z6DYLCA.mjs +0 -1
- package/dist/esm/chunk-AQ4I7VVB.mjs +0 -1
- package/dist/esm/chunk-BIGX2RJL.mjs +0 -2
- package/dist/esm/chunk-BIGX2RJL.mjs.map +0 -1
- package/dist/esm/chunk-DCNBMUKN.mjs +0 -2
- package/dist/esm/chunk-DCNBMUKN.mjs.map +0 -1
- package/dist/esm/chunk-EQSON7Y5.mjs +0 -2
- package/dist/esm/chunk-EQSON7Y5.mjs.map +0 -1
- package/dist/esm/chunk-F7EMGK4M.mjs +0 -2
- package/dist/esm/chunk-G773HST5.mjs +0 -2
- package/dist/esm/chunk-G773HST5.mjs.map +0 -1
- package/dist/esm/chunk-IVOEXGOG.mjs +0 -2
- package/dist/esm/chunk-IVOEXGOG.mjs.map +0 -1
- package/dist/esm/chunk-IVVWQKCF.mjs +0 -2
- package/dist/esm/chunk-IVVWQKCF.mjs.map +0 -1
- package/dist/esm/chunk-LJZPPBTH.mjs +0 -2
- package/dist/esm/chunk-LJZPPBTH.mjs.map +0 -1
- package/dist/esm/chunk-QQHA2Y46.mjs.map +0 -1
- package/dist/esm/chunk-SCYGW3VV.mjs +0 -2
- package/dist/esm/chunk-SCYGW3VV.mjs.map +0 -1
- package/dist/esm/chunk-T53MZO2U.mjs +0 -2
- package/dist/esm/chunk-T53MZO2U.mjs.map +0 -1
- package/dist/esm/chunk-VYXS7TLB.mjs +0 -2
- package/dist/esm/chunk-VYXS7TLB.mjs.map +0 -1
- package/dist/esm/chunk-XSTCHOUI.mjs +0 -2
- package/dist/esm/chunk-XSTCHOUI.mjs.map +0 -1
- package/dist/esm/chunk-ZWX3NHGU.mjs +0 -2
- package/dist/esm/chunk-ZWX3NHGU.mjs.map +0 -1
- package/dist/esm/chunk-ZXVQ2OBJ.mjs +0 -2
- /package/dist/esm/{chunk-7Z6DYLCA.mjs.map → account/AbstractKeylessAccount.mjs.map} +0 -0
- /package/dist/esm/{chunk-AQ4I7VVB.mjs.map → account/FederatedKeylessAccount.mjs.map} +0 -0
- /package/dist/esm/{chunk-OTNGLTKS.mjs.map → chunk-2BTTX2KO.mjs.map} +0 -0
- /package/dist/esm/{chunk-NPFW6ZFY.mjs.map → chunk-2F7Z7RMW.mjs.map} +0 -0
- /package/dist/esm/{chunk-P2EKDA7R.mjs.map → chunk-367OG3DB.mjs.map} +0 -0
- /package/dist/esm/{chunk-5L3UXSQI.mjs.map → chunk-3W2DHZXK.mjs.map} +0 -0
- /package/dist/esm/{chunk-UWPO7WWS.mjs.map → chunk-45IUUCAV.mjs.map} +0 -0
- /package/dist/esm/{chunk-YFMFXRJX.mjs.map → chunk-4HR32TSY.mjs.map} +0 -0
- /package/dist/esm/{chunk-3HTSCV3R.mjs.map → chunk-53RB2PRH.mjs.map} +0 -0
- /package/dist/esm/{chunk-GKERWKMB.mjs.map → chunk-5PCNWXRN.mjs.map} +0 -0
- /package/dist/esm/{chunk-OPTI3MH2.mjs.map → chunk-5VD4MHB3.mjs.map} +0 -0
- /package/dist/esm/{chunk-VTEZ6TBO.mjs.map → chunk-6UZ3VI5Y.mjs.map} +0 -0
- /package/dist/esm/{chunk-Z2AJWV6D.mjs.map → chunk-7VKFXX5Q.mjs.map} +0 -0
- /package/dist/esm/{chunk-GR4PHW7K.mjs.map → chunk-A42BPAD4.mjs.map} +0 -0
- /package/dist/esm/{chunk-2CAGPXCX.mjs.map → chunk-APN6AV5Q.mjs.map} +0 -0
- /package/dist/esm/{chunk-4ENUSVZB.mjs.map → chunk-BSAHPS6E.mjs.map} +0 -0
- /package/dist/esm/{chunk-NDJKEFNU.mjs.map → chunk-BWNTSJOC.mjs.map} +0 -0
- /package/dist/esm/{chunk-LS6G4DZV.mjs.map → chunk-CRA2MFJC.mjs.map} +0 -0
- /package/dist/esm/{chunk-VQVNUN5Y.mjs.map → chunk-D3Q4BC3I.mjs.map} +0 -0
- /package/dist/esm/{chunk-5TBIWC7N.mjs.map → chunk-ELYS7CWV.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZXYTLPP6.mjs.map → chunk-F63E4CR7.mjs.map} +0 -0
- /package/dist/esm/{chunk-JOROI7FE.mjs.map → chunk-F76N4MQO.mjs.map} +0 -0
- /package/dist/esm/{chunk-F5PNGH44.mjs.map → chunk-FZ5EYP3D.mjs.map} +0 -0
- /package/dist/esm/{chunk-O4BBULNE.mjs.map → chunk-GDO6Q2FI.mjs.map} +0 -0
- /package/dist/esm/{chunk-WYQLUB4H.mjs.map → chunk-GDUAFXIQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-Q7MD4V7H.mjs.map → chunk-GWSDIX6C.mjs.map} +0 -0
- /package/dist/esm/{chunk-WX6P3Q4I.mjs.map → chunk-HHGJXVAE.mjs.map} +0 -0
- /package/dist/esm/{chunk-AVSM2BJR.mjs.map → chunk-HKBBA653.mjs.map} +0 -0
- /package/dist/esm/{chunk-6CHBLB3V.mjs.map → chunk-HVMFZF6P.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZNC3FRSK.mjs.map → chunk-IR4SLC2M.mjs.map} +0 -0
- /package/dist/esm/{chunk-GGPA6QTN.mjs.map → chunk-J64ARI4E.mjs.map} +0 -0
- /package/dist/esm/{chunk-3F3FCWT5.mjs.map → chunk-JH6VLTMS.mjs.map} +0 -0
- /package/dist/esm/{chunk-ORGMRM5K.mjs.map → chunk-KUOB4DDE.mjs.map} +0 -0
- /package/dist/esm/{chunk-2XYA7NOU.mjs.map → chunk-KUZ2YTJH.mjs.map} +0 -0
- /package/dist/esm/{chunk-HBQLX5QF.mjs.map → chunk-L2QXU6F4.mjs.map} +0 -0
- /package/dist/esm/{chunk-QQU4IQ27.mjs.map → chunk-LNEZEYYE.mjs.map} +0 -0
- /package/dist/esm/{chunk-53DBMWMU.mjs.map → chunk-MAMPMCO7.mjs.map} +0 -0
- /package/dist/esm/{chunk-56F7EYFE.mjs.map → chunk-MNVUSJEK.mjs.map} +0 -0
- /package/dist/esm/{chunk-SUAA25UP.mjs.map → chunk-O2BPA6TS.mjs.map} +0 -0
- /package/dist/esm/{chunk-NKDHR2DA.mjs.map → chunk-OKAQO57B.mjs.map} +0 -0
- /package/dist/esm/{chunk-PDNA4H34.mjs.map → chunk-P3TAY5PP.mjs.map} +0 -0
- /package/dist/esm/{chunk-EJMPY5MF.mjs.map → chunk-Q3TAEOH5.mjs.map} +0 -0
- /package/dist/esm/{chunk-MNVDBUF3.mjs.map → chunk-QBSU3L5Q.mjs.map} +0 -0
- /package/dist/esm/{chunk-3GOJQ5JD.mjs.map → chunk-QPB6EJVM.mjs.map} +0 -0
- /package/dist/esm/{chunk-KRIIRH5L.mjs.map → chunk-R76DHMGR.mjs.map} +0 -0
- /package/dist/esm/{chunk-JUNVPIW4.mjs.map → chunk-S2KDCIZN.mjs.map} +0 -0
- /package/dist/esm/{chunk-YPQZJ72F.mjs.map → chunk-S2W4D6NZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-5P7MXLZA.mjs.map → chunk-SDWE6WMM.mjs.map} +0 -0
- /package/dist/esm/{chunk-WLZYSLHP.mjs.map → chunk-SWNFKKRE.mjs.map} +0 -0
- /package/dist/esm/{chunk-DVIRUFCY.mjs.map → chunk-TQWGQLM6.mjs.map} +0 -0
- /package/dist/esm/{chunk-VYXJ7FUF.mjs.map → chunk-WJRZWAIS.mjs.map} +0 -0
- /package/dist/esm/{chunk-LFUBUXHD.mjs.map → chunk-X34JJPW5.mjs.map} +0 -0
- /package/dist/esm/{chunk-EXMQBH3I.mjs.map → chunk-XMW65WCQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-54QUDAAC.mjs.map → chunk-YU3IYJRL.mjs.map} +0 -0
- /package/dist/esm/{chunk-NBO2BDDZ.mjs.map → chunk-ZROQH5YL.mjs.map} +0 -0
package/src/api/transaction.ts
CHANGED
|
@@ -21,10 +21,13 @@ import {
|
|
|
21
21
|
WaitForTransactionOptions,
|
|
22
22
|
} from "../types";
|
|
23
23
|
import {
|
|
24
|
+
FeePayerOrFeePayerAuthenticatorOrNeither,
|
|
24
25
|
getSigningMessage,
|
|
25
26
|
publicPackageTransaction,
|
|
26
27
|
rotateAuthKey,
|
|
28
|
+
signAndSubmitAsFeePayer,
|
|
27
29
|
signAndSubmitTransaction,
|
|
30
|
+
signAsFeePayer,
|
|
28
31
|
signTransaction,
|
|
29
32
|
} from "../internal/transactionSubmission";
|
|
30
33
|
import {
|
|
@@ -290,20 +293,8 @@ export class Transaction {
|
|
|
290
293
|
*/
|
|
291
294
|
// eslint-disable-next-line class-methods-use-this
|
|
292
295
|
signAsFeePayer(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
// if transaction doesnt hold a "feePayerAddress" prop it means
|
|
296
|
-
// this is not a fee payer transaction
|
|
297
|
-
if (!transaction.feePayerAddress) {
|
|
298
|
-
throw new Error(`Transaction ${transaction} is not a Fee Payer transaction`);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// Set the feePayerAddress to the signer account address
|
|
302
|
-
transaction.feePayerAddress = signer.accountAddress;
|
|
303
|
-
|
|
304
|
-
return signTransaction({
|
|
305
|
-
signer,
|
|
306
|
-
transaction,
|
|
296
|
+
return signAsFeePayer({
|
|
297
|
+
...args,
|
|
307
298
|
});
|
|
308
299
|
}
|
|
309
300
|
|
|
@@ -355,15 +346,44 @@ export class Transaction {
|
|
|
355
346
|
*
|
|
356
347
|
* @return PendingTransactionResponse
|
|
357
348
|
*/
|
|
358
|
-
async signAndSubmitTransaction(
|
|
359
|
-
|
|
349
|
+
async signAndSubmitTransaction(
|
|
350
|
+
args: FeePayerOrFeePayerAuthenticatorOrNeither & {
|
|
351
|
+
signer: Account;
|
|
352
|
+
transaction: AnyRawTransaction;
|
|
353
|
+
},
|
|
354
|
+
): Promise<PendingTransactionResponse> {
|
|
355
|
+
return signAndSubmitTransaction({
|
|
356
|
+
aptosConfig: this.config,
|
|
357
|
+
...args,
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Sign and submit a single signer transaction as the fee payer to chain given an authenticator by the sender of the transaction.
|
|
363
|
+
*
|
|
364
|
+
* @param args.feePayer The fee payer account to sign the transaction
|
|
365
|
+
* @param args.senderAuthenticator The AccountAuthenticator signed by the sender of the transaction
|
|
366
|
+
* @param args.transaction An instance of a RawTransaction, plus optional secondary/fee payer addresses
|
|
367
|
+
*
|
|
368
|
+
* @example
|
|
369
|
+
* const transaction = await aptos.transaction.build.simple({sender: alice.accountAddress, feePayer: true ...})
|
|
370
|
+
* const senderAuthenticator = alice.signTransactionWithAuthenticator(transaction)
|
|
371
|
+
* const pendingTransaction = await aptos.signAndSubmitAsFeePayer({
|
|
372
|
+
* senderAuthenticator,
|
|
373
|
+
* feePayer: bob,
|
|
374
|
+
* transaction,
|
|
375
|
+
* })
|
|
376
|
+
*
|
|
377
|
+
* @return PendingTransactionResponse
|
|
378
|
+
*/
|
|
379
|
+
async signAndSubmitAsFeePayer(args: {
|
|
380
|
+
feePayer: Account;
|
|
381
|
+
senderAuthenticator: AccountAuthenticator;
|
|
360
382
|
transaction: AnyRawTransaction;
|
|
361
383
|
}): Promise<PendingTransactionResponse> {
|
|
362
|
-
|
|
363
|
-
return signAndSubmitTransaction({
|
|
384
|
+
return signAndSubmitAsFeePayer({
|
|
364
385
|
aptosConfig: this.config,
|
|
365
|
-
|
|
366
|
-
transaction,
|
|
386
|
+
...args,
|
|
367
387
|
});
|
|
368
388
|
}
|
|
369
389
|
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Copyright © Aptos Foundation
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { AccountPublicKey, PublicKey } from "./publicKey";
|
|
5
|
+
import { Deserializer, Serializer } from "../../bcs";
|
|
6
|
+
import { Hex } from "../hex";
|
|
7
|
+
import { HexInput, AnyPublicKeyVariant, SigningScheme } from "../../types";
|
|
8
|
+
import { AuthenticationKey } from "../authenticationKey";
|
|
9
|
+
import { AccountAddress, AccountAddressInput } from "../accountAddress";
|
|
10
|
+
import { KeylessPublicKey, KeylessSignature } from "./keyless";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Represents the FederatedKeylessPublicKey public key
|
|
14
|
+
*
|
|
15
|
+
* These keys use an onchain address as a source of truth for the JWK used to verify signatures.
|
|
16
|
+
*
|
|
17
|
+
* FederatedKeylessPublicKey authentication key is represented in the SDK as `AnyPublicKey`.
|
|
18
|
+
*/
|
|
19
|
+
export class FederatedKeylessPublicKey extends AccountPublicKey {
|
|
20
|
+
/**
|
|
21
|
+
* The address that contains the JWK set to be used for verification.
|
|
22
|
+
*/
|
|
23
|
+
readonly jwkAddress: AccountAddress;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The inner public key which contains the standard Keyless public key.
|
|
27
|
+
*/
|
|
28
|
+
readonly keylessPublicKey: KeylessPublicKey;
|
|
29
|
+
|
|
30
|
+
constructor(jwkAddress: AccountAddressInput, keylessPublicKey: KeylessPublicKey) {
|
|
31
|
+
super();
|
|
32
|
+
this.jwkAddress = AccountAddress.from(jwkAddress);
|
|
33
|
+
this.keylessPublicKey = keylessPublicKey;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Get the authentication key for the federated keyless public key
|
|
38
|
+
*
|
|
39
|
+
* @returns AuthenticationKey
|
|
40
|
+
*/
|
|
41
|
+
authKey(): AuthenticationKey {
|
|
42
|
+
const serializer = new Serializer();
|
|
43
|
+
serializer.serializeU32AsUleb128(AnyPublicKeyVariant.FederatedKeyless);
|
|
44
|
+
serializer.serializeFixedBytes(this.bcsToBytes());
|
|
45
|
+
return AuthenticationKey.fromSchemeAndBytes({
|
|
46
|
+
scheme: SigningScheme.SingleKey,
|
|
47
|
+
input: serializer.toUint8Array(),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get the public key in bytes (Uint8Array).
|
|
53
|
+
*
|
|
54
|
+
* @returns Uint8Array representation of the public key
|
|
55
|
+
*/
|
|
56
|
+
toUint8Array(): Uint8Array {
|
|
57
|
+
return this.bcsToBytes();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Get the public key as a hex string with the 0x prefix.
|
|
62
|
+
*
|
|
63
|
+
* @returns string representation of the public key
|
|
64
|
+
*/
|
|
65
|
+
toString(): string {
|
|
66
|
+
return Hex.fromHexInput(this.toUint8Array()).toString();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Verifies a signed data with a public key
|
|
71
|
+
*
|
|
72
|
+
* @param args.message message
|
|
73
|
+
* @param args.signature The signature
|
|
74
|
+
* @returns true if the signature is valid
|
|
75
|
+
*/
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
|
|
77
|
+
verifySignature(args: { message: HexInput; signature: KeylessSignature }): boolean {
|
|
78
|
+
throw new Error("Not yet implemented");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
serialize(serializer: Serializer): void {
|
|
82
|
+
this.jwkAddress.serialize(serializer);
|
|
83
|
+
this.keylessPublicKey.serialize(serializer);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static deserialize(deserializer: Deserializer): FederatedKeylessPublicKey {
|
|
87
|
+
const jwkAddress = AccountAddress.deserialize(deserializer);
|
|
88
|
+
const keylessPublicKey = KeylessPublicKey.deserialize(deserializer);
|
|
89
|
+
return new FederatedKeylessPublicKey(jwkAddress, keylessPublicKey);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static isPublicKey(publicKey: PublicKey): publicKey is FederatedKeylessPublicKey {
|
|
93
|
+
return publicKey instanceof FederatedKeylessPublicKey;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Creates a FederatedKeylessPublicKey from the JWT components plus pepper
|
|
98
|
+
*
|
|
99
|
+
* @param args.iss the iss of the identity
|
|
100
|
+
* @param args.uidKey the key to use to get the uidVal in the JWT token
|
|
101
|
+
* @param args.uidVal the value of the uidKey in the JWT token
|
|
102
|
+
* @param args.aud the client ID of the application
|
|
103
|
+
* @param args.pepper The pepper used to maintain privacy of the account
|
|
104
|
+
* @returns FederatedKeylessPublicKey
|
|
105
|
+
*/
|
|
106
|
+
static create(args: {
|
|
107
|
+
iss: string;
|
|
108
|
+
uidKey: string;
|
|
109
|
+
uidVal: string;
|
|
110
|
+
aud: string;
|
|
111
|
+
pepper: HexInput;
|
|
112
|
+
jwkAddress: AccountAddressInput;
|
|
113
|
+
}): FederatedKeylessPublicKey {
|
|
114
|
+
return new FederatedKeylessPublicKey(args.jwkAddress, KeylessPublicKey.create(args));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
static fromJwtAndPepper(args: {
|
|
118
|
+
jwt: string;
|
|
119
|
+
pepper: HexInput;
|
|
120
|
+
jwkAddress: AccountAddressInput;
|
|
121
|
+
uidKey?: string;
|
|
122
|
+
}): FederatedKeylessPublicKey {
|
|
123
|
+
return new FederatedKeylessPublicKey(args.jwkAddress, KeylessPublicKey.fromJwtAndPepper(args));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
static isInstance(publicKey: PublicKey) {
|
|
127
|
+
return (
|
|
128
|
+
"jwkAddress" in publicKey &&
|
|
129
|
+
publicKey.jwkAddress instanceof AccountAddress &&
|
|
130
|
+
"keylessPublicKey" in publicKey &&
|
|
131
|
+
publicKey.keylessPublicKey instanceof KeylessPublicKey
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}
|
package/src/core/crypto/index.ts
CHANGED
|
@@ -6,7 +6,9 @@ export * from "./hdKey";
|
|
|
6
6
|
export * from "./multiEd25519";
|
|
7
7
|
export * from "./multiKey";
|
|
8
8
|
export * from "./ephemeral";
|
|
9
|
+
export * from "./federatedKeyless";
|
|
9
10
|
export * from "./keyless";
|
|
11
|
+
export * from "./poseidon";
|
|
10
12
|
export * from "./privateKey";
|
|
11
13
|
export * from "./publicKey";
|
|
12
14
|
export * from "./secp256k1";
|
|
@@ -158,13 +158,14 @@ export class KeylessPublicKey extends AccountPublicKey {
|
|
|
158
158
|
static fromJwtAndPepper(args: { jwt: string; pepper: HexInput; uidKey?: string }): KeylessPublicKey {
|
|
159
159
|
const { jwt, pepper, uidKey = "sub" } = args;
|
|
160
160
|
const jwtPayload = jwtDecode<JwtPayload & { [key: string]: string }>(jwt);
|
|
161
|
-
|
|
161
|
+
if (typeof jwtPayload.iss !== "string") {
|
|
162
|
+
throw new Error("iss was not found");
|
|
163
|
+
}
|
|
162
164
|
if (typeof jwtPayload.aud !== "string") {
|
|
163
165
|
throw new Error("aud was not found or an array of values");
|
|
164
166
|
}
|
|
165
|
-
const aud = jwtPayload.aud!;
|
|
166
167
|
const uidVal = jwtPayload[uidKey];
|
|
167
|
-
return KeylessPublicKey.create({ iss, uidKey, uidVal, aud, pepper });
|
|
168
|
+
return KeylessPublicKey.create({ iss: jwtPayload.iss, uidKey, uidVal, aud: jwtPayload.aud, pepper });
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
static isInstance(publicKey: PublicKey) {
|
|
@@ -98,12 +98,12 @@ export function bytesToBigIntLE(bytes: Uint8Array): bigint {
|
|
|
98
98
|
return result;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
export function bigIntToBytesLE(value: bigint, length: number): Uint8Array {
|
|
101
|
+
export function bigIntToBytesLE(value: bigint | number, length: number): Uint8Array {
|
|
102
|
+
let val = BigInt(value);
|
|
102
103
|
const bytes = new Uint8Array(length);
|
|
103
104
|
for (let i = 0; i < length; i += 1) {
|
|
104
|
-
bytes[i] = Number(
|
|
105
|
-
|
|
106
|
-
value >>= BigInt(8);
|
|
105
|
+
bytes[i] = Number(val & BigInt(0xff));
|
|
106
|
+
val >>= BigInt(8);
|
|
107
107
|
}
|
|
108
108
|
return bytes;
|
|
109
109
|
}
|
|
@@ -6,6 +6,7 @@ import { AccountPublicKey, PublicKey, VerifySignatureArgs } from "./publicKey";
|
|
|
6
6
|
import { Secp256k1PublicKey, Secp256k1Signature } from "./secp256k1";
|
|
7
7
|
import { KeylessPublicKey, KeylessSignature } from "./keyless";
|
|
8
8
|
import { Signature } from "./signature";
|
|
9
|
+
import { FederatedKeylessPublicKey } from "./federatedKeyless";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Represents any public key supported by Aptos.
|
|
@@ -37,6 +38,8 @@ export class AnyPublicKey extends AccountPublicKey {
|
|
|
37
38
|
this.variant = AnyPublicKeyVariant.Secp256k1;
|
|
38
39
|
} else if (publicKey instanceof KeylessPublicKey) {
|
|
39
40
|
this.variant = AnyPublicKeyVariant.Keyless;
|
|
41
|
+
} else if (publicKey instanceof FederatedKeylessPublicKey) {
|
|
42
|
+
this.variant = AnyPublicKeyVariant.FederatedKeyless;
|
|
40
43
|
} else {
|
|
41
44
|
throw new Error("Unsupported public key type");
|
|
42
45
|
}
|
|
@@ -91,6 +94,9 @@ export class AnyPublicKey extends AccountPublicKey {
|
|
|
91
94
|
case AnyPublicKeyVariant.Keyless:
|
|
92
95
|
publicKey = KeylessPublicKey.deserialize(deserializer);
|
|
93
96
|
break;
|
|
97
|
+
case AnyPublicKeyVariant.FederatedKeyless:
|
|
98
|
+
publicKey = FederatedKeylessPublicKey.deserialize(deserializer);
|
|
99
|
+
break;
|
|
94
100
|
default:
|
|
95
101
|
throw new Error(`Unknown variant index for AnyPublicKey: ${variantIndex}`);
|
|
96
102
|
}
|
package/src/core/crypto/utils.ts
CHANGED
|
@@ -12,9 +12,9 @@ export const convertSigningMessage = (message: HexInput): HexInput => {
|
|
|
12
12
|
// if message is of type string, verify it is a valid Hex string
|
|
13
13
|
if (typeof message === "string") {
|
|
14
14
|
const isValid = Hex.isValid(message);
|
|
15
|
-
// If message is not a valid Hex string, convert it
|
|
15
|
+
// If message is not a valid Hex string, convert it
|
|
16
16
|
if (!isValid.valid) {
|
|
17
|
-
return
|
|
17
|
+
return new TextEncoder().encode(message);
|
|
18
18
|
}
|
|
19
19
|
// If message is a valid Hex string, return it
|
|
20
20
|
return message;
|
package/src/internal/account.ts
CHANGED
|
@@ -52,10 +52,9 @@ import {
|
|
|
52
52
|
GetAccountTransactionsCount,
|
|
53
53
|
} from "../types/generated/queries";
|
|
54
54
|
import { memoizeAsync } from "../utils/memoize";
|
|
55
|
-
import { Secp256k1PrivateKey, AuthenticationKey, Ed25519PrivateKey
|
|
55
|
+
import { Secp256k1PrivateKey, AuthenticationKey, Ed25519PrivateKey } from "../core";
|
|
56
56
|
import { CurrentFungibleAssetBalancesBoolExp } from "../types/generated/types";
|
|
57
57
|
import { getTableItem } from "./table";
|
|
58
|
-
import { APTOS_COIN } from "../utils";
|
|
59
58
|
|
|
60
59
|
export async function getInfo(args: {
|
|
61
60
|
aptosConfig: AptosConfig;
|
|
@@ -402,58 +401,6 @@ export async function getAccountTransactionsCount(args: {
|
|
|
402
401
|
return data.account_transactions_aggregate.aggregate ? data.account_transactions_aggregate.aggregate.count : 0;
|
|
403
402
|
}
|
|
404
403
|
|
|
405
|
-
export async function getAccountCoinAmount(args: {
|
|
406
|
-
aptosConfig: AptosConfig;
|
|
407
|
-
accountAddress: AccountAddressInput;
|
|
408
|
-
coinType?: MoveStructId;
|
|
409
|
-
faMetadataAddress?: AccountAddressInput;
|
|
410
|
-
}): Promise<number> {
|
|
411
|
-
const { aptosConfig, accountAddress, coinType, faMetadataAddress } = args;
|
|
412
|
-
|
|
413
|
-
let coinAssetType: string | undefined = coinType;
|
|
414
|
-
let faAddress: string;
|
|
415
|
-
|
|
416
|
-
if (coinType !== undefined && faMetadataAddress !== undefined) {
|
|
417
|
-
faAddress = AccountAddress.from(faMetadataAddress).toStringLong();
|
|
418
|
-
} else if (coinType !== undefined && faMetadataAddress === undefined) {
|
|
419
|
-
// TODO Move to a separate function as defined in the AIP for coin migration
|
|
420
|
-
if (coinType === APTOS_COIN) {
|
|
421
|
-
faAddress = AccountAddress.A.toStringLong();
|
|
422
|
-
} else {
|
|
423
|
-
faAddress = createObjectAddress(AccountAddress.A, coinType).toStringLong();
|
|
424
|
-
}
|
|
425
|
-
} else if (coinType === undefined && faMetadataAddress !== undefined) {
|
|
426
|
-
const addr = AccountAddress.from(faMetadataAddress);
|
|
427
|
-
faAddress = addr.toStringLong();
|
|
428
|
-
if (addr === AccountAddress.A) {
|
|
429
|
-
coinAssetType = APTOS_COIN;
|
|
430
|
-
}
|
|
431
|
-
// The paired CoinType should be populated outside of this function in another
|
|
432
|
-
// async call. We cannot do this internally due to dependency cycles issue.
|
|
433
|
-
} else {
|
|
434
|
-
throw new Error("Either coinType, fungibleAssetAddress, or both must be provided");
|
|
435
|
-
}
|
|
436
|
-
const address = AccountAddress.from(accountAddress).toStringLong();
|
|
437
|
-
|
|
438
|
-
// Search by fungible asset address, unless it has a coin it migrated from
|
|
439
|
-
let where: any = { asset_type: { _eq: faAddress } };
|
|
440
|
-
if (coinAssetType !== undefined) {
|
|
441
|
-
where = { asset_type: { _in: [coinAssetType, faAddress] } };
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
const data = await getAccountCoinsData({
|
|
445
|
-
aptosConfig,
|
|
446
|
-
accountAddress: address,
|
|
447
|
-
options: {
|
|
448
|
-
where,
|
|
449
|
-
},
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
// commonjs (aka cjs) doesnt handle Nullish Coalescing for some reason
|
|
453
|
-
// might be because of how ts infer the graphql generated scheme type
|
|
454
|
-
return data[0] ? data[0].amount : 0;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
404
|
export async function getAccountCoinsData(args: {
|
|
458
405
|
aptosConfig: AptosConfig;
|
|
459
406
|
accountAddress: AccountAddressInput;
|
package/src/internal/keyless.ts
CHANGED
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* other namespaces and processes can access these methods without depending on the entire
|
|
8
8
|
* keyless namespace and without having a dependency cycle error.
|
|
9
9
|
*/
|
|
10
|
+
import { jwtDecode, JwtPayload } from "jwt-decode";
|
|
10
11
|
import { AptosConfig } from "../api/aptosConfig";
|
|
11
12
|
import { postAptosPepperService, postAptosProvingService } from "../client";
|
|
12
13
|
import {
|
|
14
|
+
AccountAddressInput,
|
|
13
15
|
EphemeralSignature,
|
|
14
16
|
Groth16Zkp,
|
|
15
17
|
Hex,
|
|
@@ -19,10 +21,14 @@ import {
|
|
|
19
21
|
getKeylessConfig,
|
|
20
22
|
} from "../core";
|
|
21
23
|
import { HexInput, ZkpVariant } from "../types";
|
|
22
|
-
import { EphemeralKeyPair, KeylessAccount, ProofFetchCallback } from "../account";
|
|
24
|
+
import { Account, EphemeralKeyPair, KeylessAccount, ProofFetchCallback } from "../account";
|
|
23
25
|
import { PepperFetchRequest, PepperFetchResponse, ProverRequest, ProverResponse } from "../types/keyless";
|
|
24
|
-
import { nowInSeconds } from "../utils/helpers";
|
|
25
26
|
import { lookupOriginalAccountAddress } from "./account";
|
|
27
|
+
import { FederatedKeylessPublicKey } from "../core/crypto/federatedKeyless";
|
|
28
|
+
import { FederatedKeylessAccount } from "../account/FederatedKeylessAccount";
|
|
29
|
+
import { MoveVector } from "../bcs";
|
|
30
|
+
import { generateTransaction } from "./transactionSubmission";
|
|
31
|
+
import { SimpleTransaction } from "../transactions";
|
|
26
32
|
|
|
27
33
|
export async function getPepper(args: {
|
|
28
34
|
aptosConfig: AptosConfig;
|
|
@@ -63,7 +69,11 @@ export async function getProof(args: {
|
|
|
63
69
|
throw new Error(`Pepper needs to be ${KeylessAccount.PEPPER_LENGTH} bytes`);
|
|
64
70
|
}
|
|
65
71
|
const { maxExpHorizonSecs } = await getKeylessConfig({ aptosConfig });
|
|
66
|
-
|
|
72
|
+
const decodedJwt = jwtDecode<JwtPayload>(jwt);
|
|
73
|
+
if (typeof decodedJwt.iat !== "number") {
|
|
74
|
+
throw new Error("iat was not found");
|
|
75
|
+
}
|
|
76
|
+
if (maxExpHorizonSecs < ephemeralKeyPair.expiryDateSecs - decodedJwt.iat) {
|
|
67
77
|
throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${maxExpHorizonSecs}`);
|
|
68
78
|
}
|
|
69
79
|
const json = {
|
|
@@ -106,8 +116,28 @@ export async function deriveKeylessAccount(args: {
|
|
|
106
116
|
uidKey?: string;
|
|
107
117
|
pepper?: HexInput;
|
|
108
118
|
proofFetchCallback?: ProofFetchCallback;
|
|
109
|
-
}): Promise<KeylessAccount
|
|
110
|
-
|
|
119
|
+
}): Promise<KeylessAccount>;
|
|
120
|
+
|
|
121
|
+
export async function deriveKeylessAccount(args: {
|
|
122
|
+
aptosConfig: AptosConfig;
|
|
123
|
+
jwt: string;
|
|
124
|
+
ephemeralKeyPair: EphemeralKeyPair;
|
|
125
|
+
jwkAddress: AccountAddressInput;
|
|
126
|
+
uidKey?: string;
|
|
127
|
+
pepper?: HexInput;
|
|
128
|
+
proofFetchCallback?: ProofFetchCallback;
|
|
129
|
+
}): Promise<FederatedKeylessAccount>;
|
|
130
|
+
|
|
131
|
+
export async function deriveKeylessAccount(args: {
|
|
132
|
+
aptosConfig: AptosConfig;
|
|
133
|
+
jwt: string;
|
|
134
|
+
ephemeralKeyPair: EphemeralKeyPair;
|
|
135
|
+
jwkAddress?: AccountAddressInput;
|
|
136
|
+
uidKey?: string;
|
|
137
|
+
pepper?: HexInput;
|
|
138
|
+
proofFetchCallback?: ProofFetchCallback;
|
|
139
|
+
}): Promise<KeylessAccount | FederatedKeylessAccount> {
|
|
140
|
+
const { aptosConfig, jwt, jwkAddress, uidKey, proofFetchCallback, pepper = await getPepper(args) } = args;
|
|
111
141
|
const proofPromise = getProof({ ...args, pepper });
|
|
112
142
|
// If a callback is provided, pass in the proof as a promise to KeylessAccount.create. This will make the proof be fetched in the
|
|
113
143
|
// background and the callback will handle the outcome of the fetch. This allows the developer to not have to block on the proof fetch
|
|
@@ -116,14 +146,62 @@ export async function deriveKeylessAccount(args: {
|
|
|
116
146
|
// If no callback is provided, the just await the proof fetch and continue syncronously.
|
|
117
147
|
const proof = proofFetchCallback ? proofPromise : await proofPromise;
|
|
118
148
|
|
|
119
|
-
// Look up the original address to handle key rotations
|
|
149
|
+
// Look up the original address to handle key rotations and then instantiate the account.
|
|
150
|
+
if (jwkAddress !== undefined) {
|
|
151
|
+
const publicKey = FederatedKeylessPublicKey.fromJwtAndPepper({ jwt, pepper, jwkAddress, uidKey });
|
|
152
|
+
const address = await lookupOriginalAccountAddress({
|
|
153
|
+
aptosConfig,
|
|
154
|
+
authenticationKey: publicKey.authKey().derivedAddress(),
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
return FederatedKeylessAccount.create({ ...args, address, proof, pepper, proofFetchCallback, jwkAddress });
|
|
158
|
+
}
|
|
159
|
+
|
|
120
160
|
const publicKey = KeylessPublicKey.fromJwtAndPepper({ jwt, pepper, uidKey });
|
|
121
161
|
const address = await lookupOriginalAccountAddress({
|
|
122
162
|
aptosConfig,
|
|
123
163
|
authenticationKey: publicKey.authKey().derivedAddress(),
|
|
124
164
|
});
|
|
165
|
+
return KeylessAccount.create({ ...args, address, proof, pepper, proofFetchCallback });
|
|
166
|
+
}
|
|
125
167
|
|
|
126
|
-
|
|
168
|
+
interface JWK {
|
|
169
|
+
kty: string; // Key type
|
|
170
|
+
kid: string; // Key ID
|
|
171
|
+
alg: string; // Algorithm used with the key
|
|
172
|
+
n: string; // Modulus (for RSA keys)
|
|
173
|
+
e: string; // Exponent (for RSA keys)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
interface JWKS {
|
|
177
|
+
keys: JWK[];
|
|
178
|
+
}
|
|
127
179
|
|
|
128
|
-
|
|
180
|
+
export async function updateFederatedKeylessJwkSetTransaction(args: {
|
|
181
|
+
aptosConfig: AptosConfig;
|
|
182
|
+
sender: Account;
|
|
183
|
+
iss: string;
|
|
184
|
+
jwksUrl?: string;
|
|
185
|
+
}): Promise<SimpleTransaction> {
|
|
186
|
+
const { aptosConfig, sender, iss } = args;
|
|
187
|
+
const jwksUrl = args.jwksUrl ?? (iss.endsWith("/") ? `${iss}.well-known/jwks.json` : `${iss}/.well-known/jwks.json`);
|
|
188
|
+
const response = await fetch(jwksUrl);
|
|
189
|
+
if (!response.ok) {
|
|
190
|
+
throw new Error(`Failed to fetch JWKS: ${response.status} ${response.statusText}`);
|
|
191
|
+
}
|
|
192
|
+
const jwks: JWKS = await response.json();
|
|
193
|
+
return generateTransaction({
|
|
194
|
+
aptosConfig,
|
|
195
|
+
sender: sender.accountAddress,
|
|
196
|
+
data: {
|
|
197
|
+
function: "0x1::jwks::update_federated_jwk_set",
|
|
198
|
+
functionArguments: [
|
|
199
|
+
iss,
|
|
200
|
+
MoveVector.MoveString(jwks.keys.map((key) => key.kid)),
|
|
201
|
+
MoveVector.MoveString(jwks.keys.map((key) => key.alg)),
|
|
202
|
+
MoveVector.MoveString(jwks.keys.map((key) => key.e)),
|
|
203
|
+
MoveVector.MoveString(jwks.keys.map((key) => key.n)),
|
|
204
|
+
],
|
|
205
|
+
},
|
|
206
|
+
});
|
|
129
207
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { AptosConfig } from "../api/aptosConfig";
|
|
9
9
|
import { MoveVector, U8 } from "../bcs";
|
|
10
10
|
import { postAptosFullNode } from "../client";
|
|
11
|
-
import { Account,
|
|
11
|
+
import { Account, AbstractKeylessAccount, MultiKeyAccount } from "../account";
|
|
12
12
|
import { AccountAddress, AccountAddressInput } from "../core/accountAddress";
|
|
13
13
|
import { PrivateKey } from "../core/crypto";
|
|
14
14
|
import { AccountAuthenticator } from "../transactions/authenticator/account";
|
|
@@ -206,6 +206,24 @@ export function signTransaction(args: { signer: Account; transaction: AnyRawTran
|
|
|
206
206
|
return signer.signTransactionWithAuthenticator(transaction);
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
export function signAsFeePayer(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {
|
|
210
|
+
const { signer, transaction } = args;
|
|
211
|
+
|
|
212
|
+
// if transaction doesnt hold a "feePayerAddress" prop it means
|
|
213
|
+
// this is not a fee payer transaction
|
|
214
|
+
if (!transaction.feePayerAddress) {
|
|
215
|
+
throw new Error(`Transaction ${transaction} is not a Fee Payer transaction`);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Set the feePayerAddress to the signer account address
|
|
219
|
+
transaction.feePayerAddress = signer.accountAddress;
|
|
220
|
+
|
|
221
|
+
return signTransaction({
|
|
222
|
+
signer,
|
|
223
|
+
transaction,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
|
|
209
227
|
/**
|
|
210
228
|
* Simulates a transaction before singing it.
|
|
211
229
|
*
|
|
@@ -268,23 +286,58 @@ export async function submitTransaction(
|
|
|
268
286
|
});
|
|
269
287
|
return data;
|
|
270
288
|
}
|
|
289
|
+
export type FeePayerOrFeePayerAuthenticatorOrNeither =
|
|
290
|
+
| { feePayer: Account; feePayerAuthenticator?: never }
|
|
291
|
+
| { feePayer?: never; feePayerAuthenticator: AccountAuthenticator }
|
|
292
|
+
| { feePayer?: never; feePayerAuthenticator?: never };
|
|
271
293
|
|
|
272
|
-
export async function signAndSubmitTransaction(
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
294
|
+
export async function signAndSubmitTransaction(
|
|
295
|
+
args: FeePayerOrFeePayerAuthenticatorOrNeither & {
|
|
296
|
+
aptosConfig: AptosConfig;
|
|
297
|
+
signer: Account;
|
|
298
|
+
transaction: AnyRawTransaction;
|
|
299
|
+
},
|
|
300
|
+
): Promise<PendingTransactionResponse> {
|
|
301
|
+
const { aptosConfig, signer, feePayer, transaction } = args;
|
|
278
302
|
// If the signer contains a KeylessAccount, await proof fetching in case the proof
|
|
279
303
|
// was fetched asyncronously.
|
|
280
|
-
if (signer instanceof
|
|
304
|
+
if (signer instanceof AbstractKeylessAccount || signer instanceof MultiKeyAccount) {
|
|
281
305
|
await signer.waitForProofFetch();
|
|
282
306
|
}
|
|
283
|
-
|
|
307
|
+
if (feePayer instanceof AbstractKeylessAccount || feePayer instanceof MultiKeyAccount) {
|
|
308
|
+
await feePayer.waitForProofFetch();
|
|
309
|
+
}
|
|
310
|
+
const feePayerAuthenticator =
|
|
311
|
+
args.feePayerAuthenticator || (feePayer && signAsFeePayer({ signer: feePayer, transaction }));
|
|
312
|
+
|
|
313
|
+
const senderAuthenticator = signTransaction({ signer, transaction });
|
|
314
|
+
return submitTransaction({
|
|
315
|
+
aptosConfig,
|
|
316
|
+
transaction,
|
|
317
|
+
senderAuthenticator,
|
|
318
|
+
feePayerAuthenticator,
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export async function signAndSubmitAsFeePayer(args: {
|
|
323
|
+
aptosConfig: AptosConfig;
|
|
324
|
+
feePayer: Account;
|
|
325
|
+
senderAuthenticator: AccountAuthenticator;
|
|
326
|
+
transaction: AnyRawTransaction;
|
|
327
|
+
}): Promise<PendingTransactionResponse> {
|
|
328
|
+
const { aptosConfig, senderAuthenticator, feePayer, transaction } = args;
|
|
329
|
+
|
|
330
|
+
if (feePayer instanceof AbstractKeylessAccount || feePayer instanceof MultiKeyAccount) {
|
|
331
|
+
await feePayer.waitForProofFetch();
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const feePayerAuthenticator = signAsFeePayer({ signer: feePayer, transaction });
|
|
335
|
+
|
|
284
336
|
return submitTransaction({
|
|
285
337
|
aptosConfig,
|
|
286
338
|
transaction,
|
|
287
|
-
senderAuthenticator
|
|
339
|
+
senderAuthenticator,
|
|
340
|
+
feePayerAuthenticator,
|
|
288
341
|
});
|
|
289
342
|
}
|
|
290
343
|
|
|
@@ -9,7 +9,14 @@
|
|
|
9
9
|
import { sha3_256 as sha3Hash } from "@noble/hashes/sha3";
|
|
10
10
|
import { AptosConfig } from "../../api/aptosConfig";
|
|
11
11
|
import { AccountAddress, AccountAddressInput, Hex, PublicKey } from "../../core";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
AnyPublicKey,
|
|
14
|
+
AnySignature,
|
|
15
|
+
KeylessPublicKey,
|
|
16
|
+
KeylessSignature,
|
|
17
|
+
Secp256k1PublicKey,
|
|
18
|
+
FederatedKeylessPublicKey,
|
|
19
|
+
} from "../../core/crypto";
|
|
13
20
|
import { Ed25519PublicKey, Ed25519Signature } from "../../core/crypto/ed25519";
|
|
14
21
|
import { getInfo } from "../../internal/account";
|
|
15
22
|
import { getLedgerInfo } from "../../internal/general";
|
|
@@ -445,25 +452,29 @@ export function generateSignedTransactionForSimulation(args: InputSimulateTransa
|
|
|
445
452
|
}
|
|
446
453
|
|
|
447
454
|
export function getAuthenticatorForSimulation(publicKey: PublicKey) {
|
|
455
|
+
// Wrap the public key types below with AnyPublicKey as they are only support through single sender.
|
|
456
|
+
// Learn more about AnyPublicKey here - https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-55.md
|
|
457
|
+
const convertToAnyPublicKey =
|
|
458
|
+
KeylessPublicKey.isInstance(publicKey) ||
|
|
459
|
+
FederatedKeylessPublicKey.isInstance(publicKey) ||
|
|
460
|
+
Secp256k1PublicKey.isInstance(publicKey);
|
|
461
|
+
const accountPublicKey = convertToAnyPublicKey ? new AnyPublicKey(publicKey) : publicKey;
|
|
462
|
+
|
|
448
463
|
// No need to for the signature to be matching in scheme. All that matters for simulations is that it's not valid
|
|
449
464
|
const invalidSignature = new Ed25519Signature(new Uint8Array(64));
|
|
450
465
|
|
|
451
|
-
if (Ed25519PublicKey.isInstance(
|
|
452
|
-
return new AccountAuthenticatorEd25519(
|
|
466
|
+
if (Ed25519PublicKey.isInstance(accountPublicKey)) {
|
|
467
|
+
return new AccountAuthenticatorEd25519(accountPublicKey, invalidSignature);
|
|
453
468
|
}
|
|
454
469
|
|
|
455
|
-
if (AnyPublicKey.isInstance(
|
|
456
|
-
if (KeylessPublicKey.isInstance(
|
|
457
|
-
return new AccountAuthenticatorSingleKey(
|
|
470
|
+
if (AnyPublicKey.isInstance(accountPublicKey)) {
|
|
471
|
+
if (KeylessPublicKey.isInstance(accountPublicKey.publicKey)) {
|
|
472
|
+
return new AccountAuthenticatorSingleKey(
|
|
473
|
+
accountPublicKey,
|
|
474
|
+
new AnySignature(KeylessSignature.getSimulationSignature()),
|
|
475
|
+
);
|
|
458
476
|
}
|
|
459
|
-
return new AccountAuthenticatorSingleKey(
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
// TODO: remove this, non-account public keys should never make it here
|
|
463
|
-
if (KeylessPublicKey.isInstance(publicKey) || Secp256k1PublicKey.isInstance(publicKey)) {
|
|
464
|
-
// eslint-disable-next-line no-console
|
|
465
|
-
console.warn("Expected AccountPublicKey, but got PublicKey. Please wrap your public key with AnyPublicKey.");
|
|
466
|
-
return new AccountAuthenticatorSingleKey(new AnyPublicKey(publicKey), new AnySignature(invalidSignature));
|
|
477
|
+
return new AccountAuthenticatorSingleKey(accountPublicKey, new AnySignature(invalidSignature));
|
|
467
478
|
}
|
|
468
479
|
|
|
469
480
|
// TODO add support for AnyMultiKey
|