@moveindustries/ts-sdk 5.1.4
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/LICENSE +201 -0
- package/README.md +66 -0
- package/dist/common/accountAddress-DoqkxUqw.d.ts +7769 -0
- package/dist/common/chunk-56DGDNEY.js +4 -0
- package/dist/common/chunk-56DGDNEY.js.map +1 -0
- package/dist/common/cli/index.d.ts +316 -0
- package/dist/common/cli/index.js +2 -0
- package/dist/common/cli/index.js.map +1 -0
- package/dist/common/index.d.ts +10643 -0
- package/dist/common/index.js +482 -0
- package/dist/common/index.js.map +1 -0
- package/dist/esm/Ed25519Account-DsqenvLJ.d.mts +628 -0
- package/dist/esm/account/AbstractKeylessAccount.d.mts +336 -0
- package/dist/esm/account/AbstractKeylessAccount.mjs +2 -0
- package/dist/esm/account/AbstractKeylessAccount.mjs.map +1 -0
- package/dist/esm/account/AbstractedAccount.d.mts +64 -0
- package/dist/esm/account/AbstractedAccount.mjs +2 -0
- package/dist/esm/account/AbstractedAccount.mjs.map +1 -0
- package/dist/esm/account/Account.d.mts +8 -0
- package/dist/esm/account/Account.mjs +2 -0
- package/dist/esm/account/Account.mjs.map +1 -0
- package/dist/esm/account/AccountUtils.d.mts +38 -0
- package/dist/esm/account/AccountUtils.mjs +2 -0
- package/dist/esm/account/AccountUtils.mjs.map +1 -0
- package/dist/esm/account/DerivableAbstractedAccount.d.mts +59 -0
- package/dist/esm/account/DerivableAbstractedAccount.mjs +2 -0
- package/dist/esm/account/DerivableAbstractedAccount.mjs.map +1 -0
- package/dist/esm/account/Ed25519Account.d.mts +8 -0
- package/dist/esm/account/Ed25519Account.mjs +2 -0
- package/dist/esm/account/Ed25519Account.mjs.map +1 -0
- package/dist/esm/account/EphemeralKeyPair.d.mts +141 -0
- package/dist/esm/account/EphemeralKeyPair.mjs +2 -0
- package/dist/esm/account/EphemeralKeyPair.mjs.map +1 -0
- package/dist/esm/account/FederatedKeylessAccount.d.mts +118 -0
- package/dist/esm/account/FederatedKeylessAccount.mjs +2 -0
- package/dist/esm/account/FederatedKeylessAccount.mjs.map +1 -0
- package/dist/esm/account/KeylessAccount.d.mts +124 -0
- package/dist/esm/account/KeylessAccount.mjs +2 -0
- package/dist/esm/account/KeylessAccount.mjs.map +1 -0
- package/dist/esm/account/MultiEd25519Account.d.mts +102 -0
- package/dist/esm/account/MultiEd25519Account.mjs +2 -0
- package/dist/esm/account/MultiEd25519Account.mjs.map +1 -0
- package/dist/esm/account/MultiKeyAccount.d.mts +206 -0
- package/dist/esm/account/MultiKeyAccount.mjs +2 -0
- package/dist/esm/account/MultiKeyAccount.mjs.map +1 -0
- package/dist/esm/account/SingleKeyAccount.d.mts +8 -0
- package/dist/esm/account/SingleKeyAccount.mjs +2 -0
- package/dist/esm/account/SingleKeyAccount.mjs.map +1 -0
- package/dist/esm/account/index.d.mts +24 -0
- package/dist/esm/account/index.mjs +2 -0
- package/dist/esm/account/index.mjs.map +1 -0
- package/dist/esm/account/utils.d.mts +14 -0
- package/dist/esm/account/utils.mjs +2 -0
- package/dist/esm/account/utils.mjs.map +1 -0
- package/dist/esm/accountAddress-CNXtapt1.d.mts +6979 -0
- package/dist/esm/api/account/abstraction.d.mts +181 -0
- package/dist/esm/api/account/abstraction.mjs +2 -0
- package/dist/esm/api/account/abstraction.mjs.map +1 -0
- package/dist/esm/api/account.d.mts +852 -0
- package/dist/esm/api/account.mjs +2 -0
- package/dist/esm/api/account.mjs.map +1 -0
- package/dist/esm/api/ans.d.mts +504 -0
- package/dist/esm/api/ans.mjs +2 -0
- package/dist/esm/api/ans.mjs.map +1 -0
- package/dist/esm/api/coin.d.mts +81 -0
- package/dist/esm/api/coin.mjs +2 -0
- package/dist/esm/api/coin.mjs.map +1 -0
- package/dist/esm/api/digitalAsset.d.mts +1030 -0
- package/dist/esm/api/digitalAsset.mjs +2 -0
- package/dist/esm/api/digitalAsset.mjs.map +1 -0
- package/dist/esm/api/faucet.d.mts +80 -0
- package/dist/esm/api/faucet.mjs +2 -0
- package/dist/esm/api/faucet.mjs.map +1 -0
- package/dist/esm/api/fungibleAsset.d.mts +288 -0
- package/dist/esm/api/fungibleAsset.mjs +2 -0
- package/dist/esm/api/fungibleAsset.mjs.map +1 -0
- package/dist/esm/api/general.d.mts +303 -0
- package/dist/esm/api/general.mjs +2 -0
- package/dist/esm/api/general.mjs.map +1 -0
- package/dist/esm/api/index.d.mts +46 -0
- package/dist/esm/api/index.mjs +2 -0
- package/dist/esm/api/index.mjs.map +1 -0
- package/dist/esm/api/keyless.d.mts +170 -0
- package/dist/esm/api/keyless.mjs +2 -0
- package/dist/esm/api/keyless.mjs.map +1 -0
- package/dist/esm/api/movement.d.mts +113 -0
- package/dist/esm/api/movement.mjs +2 -0
- package/dist/esm/api/movement.mjs.map +1 -0
- package/dist/esm/api/movementConfig.d.mts +7 -0
- package/dist/esm/api/movementConfig.mjs +2 -0
- package/dist/esm/api/movementConfig.mjs.map +1 -0
- package/dist/esm/api/object.d.mts +80 -0
- package/dist/esm/api/object.mjs +2 -0
- package/dist/esm/api/object.mjs.map +1 -0
- package/dist/esm/api/staking.d.mts +134 -0
- package/dist/esm/api/staking.mjs +2 -0
- package/dist/esm/api/staking.mjs.map +1 -0
- package/dist/esm/api/table.d.mts +169 -0
- package/dist/esm/api/table.mjs +2 -0
- package/dist/esm/api/table.mjs.map +1 -0
- package/dist/esm/api/transaction.d.mts +679 -0
- package/dist/esm/api/transaction.mjs +2 -0
- package/dist/esm/api/transaction.mjs.map +1 -0
- package/dist/esm/api/transactionSubmission/build.d.mts +141 -0
- package/dist/esm/api/transactionSubmission/build.mjs +2 -0
- package/dist/esm/api/transactionSubmission/build.mjs.map +1 -0
- package/dist/esm/api/transactionSubmission/helpers.d.mts +98 -0
- package/dist/esm/api/transactionSubmission/helpers.mjs +2 -0
- package/dist/esm/api/transactionSubmission/helpers.mjs.map +1 -0
- package/dist/esm/api/transactionSubmission/management.d.mts +168 -0
- package/dist/esm/api/transactionSubmission/management.mjs +2 -0
- package/dist/esm/api/transactionSubmission/management.mjs.map +1 -0
- package/dist/esm/api/transactionSubmission/sign.d.mts +124 -0
- package/dist/esm/api/transactionSubmission/sign.mjs +2 -0
- package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -0
- package/dist/esm/api/transactionSubmission/simulate.d.mts +181 -0
- package/dist/esm/api/transactionSubmission/simulate.mjs +2 -0
- package/dist/esm/api/transactionSubmission/simulate.mjs.map +1 -0
- package/dist/esm/api/transactionSubmission/submit.d.mts +142 -0
- package/dist/esm/api/transactionSubmission/submit.mjs +2 -0
- package/dist/esm/api/transactionSubmission/submit.mjs.map +1 -0
- package/dist/esm/api/utils.d.mts +45 -0
- package/dist/esm/api/utils.mjs +2 -0
- package/dist/esm/api/utils.mjs.map +1 -0
- package/dist/esm/bcs/consts.d.mts +28 -0
- package/dist/esm/bcs/consts.mjs +2 -0
- package/dist/esm/bcs/consts.mjs.map +1 -0
- package/dist/esm/bcs/deserializer.d.mts +7 -0
- package/dist/esm/bcs/deserializer.mjs +2 -0
- package/dist/esm/bcs/deserializer.mjs.map +1 -0
- package/dist/esm/bcs/index.d.mts +8 -0
- package/dist/esm/bcs/index.mjs +2 -0
- package/dist/esm/bcs/index.mjs.map +1 -0
- package/dist/esm/bcs/serializable/entryFunctionBytes.d.mts +65 -0
- package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +2 -0
- package/dist/esm/bcs/serializable/entryFunctionBytes.mjs.map +1 -0
- package/dist/esm/bcs/serializable/fixedBytes.d.mts +7 -0
- package/dist/esm/bcs/serializable/fixedBytes.mjs +2 -0
- package/dist/esm/bcs/serializable/fixedBytes.mjs.map +1 -0
- package/dist/esm/bcs/serializable/movePrimitives.d.mts +7 -0
- package/dist/esm/bcs/serializable/movePrimitives.mjs +2 -0
- package/dist/esm/bcs/serializable/movePrimitives.mjs.map +1 -0
- package/dist/esm/bcs/serializable/moveStructs.d.mts +7 -0
- package/dist/esm/bcs/serializable/moveStructs.mjs +2 -0
- package/dist/esm/bcs/serializable/moveStructs.mjs.map +1 -0
- package/dist/esm/bcs/serializer.d.mts +7 -0
- package/dist/esm/bcs/serializer.mjs +2 -0
- package/dist/esm/bcs/serializer.mjs.map +1 -0
- package/dist/esm/chunk-2KDUIZKB.mjs +2 -0
- package/dist/esm/chunk-2KDUIZKB.mjs.map +1 -0
- package/dist/esm/chunk-2QTV4AOE.mjs +2 -0
- package/dist/esm/chunk-2QTV4AOE.mjs.map +1 -0
- package/dist/esm/chunk-47V7UGV5.mjs +4 -0
- package/dist/esm/chunk-47V7UGV5.mjs.map +1 -0
- package/dist/esm/chunk-4QMXOWHP.mjs +1 -0
- package/dist/esm/chunk-4QMXOWHP.mjs.map +1 -0
- package/dist/esm/chunk-4WPQQPUF.mjs +1 -0
- package/dist/esm/chunk-4WPQQPUF.mjs.map +1 -0
- package/dist/esm/chunk-5HXLZHDW.mjs +1 -0
- package/dist/esm/chunk-5HXLZHDW.mjs.map +1 -0
- package/dist/esm/chunk-5IMQPJ6J.mjs +2 -0
- package/dist/esm/chunk-5IMQPJ6J.mjs.map +1 -0
- package/dist/esm/chunk-5ZKA765G.mjs +2 -0
- package/dist/esm/chunk-5ZKA765G.mjs.map +1 -0
- package/dist/esm/chunk-6NO4QKAO.mjs +2 -0
- package/dist/esm/chunk-6NO4QKAO.mjs.map +1 -0
- package/dist/esm/chunk-7ECCT6PK.mjs +1 -0
- package/dist/esm/chunk-7ECCT6PK.mjs.map +1 -0
- package/dist/esm/chunk-7TTTMBAK.mjs +2 -0
- package/dist/esm/chunk-7TTTMBAK.mjs.map +1 -0
- package/dist/esm/chunk-A5L76YP7.mjs +2 -0
- package/dist/esm/chunk-A5L76YP7.mjs.map +1 -0
- package/dist/esm/chunk-ANTEUWH6.mjs +2 -0
- package/dist/esm/chunk-ANTEUWH6.mjs.map +1 -0
- package/dist/esm/chunk-CHWDP6AR.mjs +2 -0
- package/dist/esm/chunk-CHWDP6AR.mjs.map +1 -0
- package/dist/esm/chunk-CRCE7R4D.mjs +2 -0
- package/dist/esm/chunk-CRCE7R4D.mjs.map +1 -0
- package/dist/esm/chunk-D6HPXGEP.mjs +2 -0
- package/dist/esm/chunk-D6HPXGEP.mjs.map +1 -0
- package/dist/esm/chunk-DS6QB6HG.mjs +4 -0
- package/dist/esm/chunk-DS6QB6HG.mjs.map +1 -0
- package/dist/esm/chunk-FD6FGKYY.mjs +1 -0
- package/dist/esm/chunk-FD6FGKYY.mjs.map +1 -0
- package/dist/esm/chunk-FJRPU2NH.mjs +2 -0
- package/dist/esm/chunk-FJRPU2NH.mjs.map +1 -0
- package/dist/esm/chunk-FS5ZJKO7.mjs +2 -0
- package/dist/esm/chunk-FS5ZJKO7.mjs.map +1 -0
- package/dist/esm/chunk-FZY4PMEE.mjs +1 -0
- package/dist/esm/chunk-FZY4PMEE.mjs.map +1 -0
- package/dist/esm/chunk-G3MHXDYA.mjs +1 -0
- package/dist/esm/chunk-G3MHXDYA.mjs.map +1 -0
- package/dist/esm/chunk-GOXRBEIJ.mjs +2 -0
- package/dist/esm/chunk-GOXRBEIJ.mjs.map +1 -0
- package/dist/esm/chunk-HGLO5LDS.mjs +1 -0
- package/dist/esm/chunk-HGLO5LDS.mjs.map +1 -0
- package/dist/esm/chunk-HL2JMZ7N.mjs +2 -0
- package/dist/esm/chunk-HL2JMZ7N.mjs.map +1 -0
- package/dist/esm/chunk-I6YGBK5S.mjs +2 -0
- package/dist/esm/chunk-I6YGBK5S.mjs.map +1 -0
- package/dist/esm/chunk-K4NT6TTN.mjs +2 -0
- package/dist/esm/chunk-K4NT6TTN.mjs.map +1 -0
- package/dist/esm/chunk-KDMSOCZY.mjs +2 -0
- package/dist/esm/chunk-KDMSOCZY.mjs.map +1 -0
- package/dist/esm/chunk-KPJGWDSQ.mjs +7 -0
- package/dist/esm/chunk-KPJGWDSQ.mjs.map +1 -0
- package/dist/esm/chunk-MEWW7VTQ.mjs +2 -0
- package/dist/esm/chunk-MEWW7VTQ.mjs.map +1 -0
- package/dist/esm/chunk-NECL5FCQ.mjs +1 -0
- package/dist/esm/chunk-NECL5FCQ.mjs.map +1 -0
- package/dist/esm/chunk-NMFJJOGW.mjs +2 -0
- package/dist/esm/chunk-NMFJJOGW.mjs.map +1 -0
- package/dist/esm/chunk-NQUZ4UHR.mjs +2 -0
- package/dist/esm/chunk-NQUZ4UHR.mjs.map +1 -0
- package/dist/esm/chunk-NUB6KE73.mjs +2 -0
- package/dist/esm/chunk-NUB6KE73.mjs.map +1 -0
- package/dist/esm/chunk-OOOAVIMQ.mjs +2 -0
- package/dist/esm/chunk-OOOAVIMQ.mjs.map +1 -0
- package/dist/esm/chunk-PCESRJYO.mjs +2 -0
- package/dist/esm/chunk-PCESRJYO.mjs.map +1 -0
- package/dist/esm/chunk-PHRRBT44.mjs +2 -0
- package/dist/esm/chunk-PHRRBT44.mjs.map +1 -0
- package/dist/esm/chunk-PZ233FIY.mjs +2 -0
- package/dist/esm/chunk-PZ233FIY.mjs.map +1 -0
- package/dist/esm/chunk-R2G23RIY.mjs +2 -0
- package/dist/esm/chunk-R2G23RIY.mjs.map +1 -0
- package/dist/esm/chunk-RL4YPMN4.mjs +2 -0
- package/dist/esm/chunk-RL4YPMN4.mjs.map +1 -0
- package/dist/esm/chunk-RUIFVDWM.mjs +2 -0
- package/dist/esm/chunk-RUIFVDWM.mjs.map +1 -0
- package/dist/esm/chunk-RXHPS4IU.mjs +2 -0
- package/dist/esm/chunk-RXHPS4IU.mjs.map +1 -0
- package/dist/esm/chunk-S4D2KBYN.mjs +2 -0
- package/dist/esm/chunk-S4D2KBYN.mjs.map +1 -0
- package/dist/esm/chunk-SRXFRTHK.mjs +2 -0
- package/dist/esm/chunk-SRXFRTHK.mjs.map +1 -0
- package/dist/esm/chunk-SYXDZA4K.mjs +2 -0
- package/dist/esm/chunk-SYXDZA4K.mjs.map +1 -0
- package/dist/esm/chunk-UI4OF6CP.mjs +2 -0
- package/dist/esm/chunk-UI4OF6CP.mjs.map +1 -0
- package/dist/esm/chunk-UL777LTI.mjs +494 -0
- package/dist/esm/chunk-UL777LTI.mjs.map +1 -0
- package/dist/esm/chunk-UVP74ONT.mjs +2 -0
- package/dist/esm/chunk-UVP74ONT.mjs.map +1 -0
- package/dist/esm/chunk-UYVPNUH3.mjs +1 -0
- package/dist/esm/chunk-UYVPNUH3.mjs.map +1 -0
- package/dist/esm/chunk-V3MBJJTL.mjs +1 -0
- package/dist/esm/chunk-V3MBJJTL.mjs.map +1 -0
- package/dist/esm/chunk-V3O2SBO4.mjs +2 -0
- package/dist/esm/chunk-V3O2SBO4.mjs.map +1 -0
- package/dist/esm/chunk-VEZCMPUG.mjs +2 -0
- package/dist/esm/chunk-VEZCMPUG.mjs.map +1 -0
- package/dist/esm/chunk-VW3WBAAD.mjs +2 -0
- package/dist/esm/chunk-VW3WBAAD.mjs.map +1 -0
- package/dist/esm/chunk-WFAH73WN.mjs +2 -0
- package/dist/esm/chunk-WFAH73WN.mjs.map +1 -0
- package/dist/esm/chunk-WVDICMU4.mjs +2 -0
- package/dist/esm/chunk-WVDICMU4.mjs.map +1 -0
- package/dist/esm/chunk-XCURF77K.mjs +2 -0
- package/dist/esm/chunk-XCURF77K.mjs.map +1 -0
- package/dist/esm/chunk-Y6YW4BAZ.mjs +2 -0
- package/dist/esm/chunk-Y6YW4BAZ.mjs.map +1 -0
- package/dist/esm/chunk-YFFYA5U3.mjs +2 -0
- package/dist/esm/chunk-YFFYA5U3.mjs.map +1 -0
- package/dist/esm/chunk-YOHEYPDP.mjs +2 -0
- package/dist/esm/chunk-YOHEYPDP.mjs.map +1 -0
- package/dist/esm/chunk-ZP4DWSQA.mjs +2 -0
- package/dist/esm/chunk-ZP4DWSQA.mjs.map +1 -0
- package/dist/esm/cli/index.d.mts +10 -0
- package/dist/esm/cli/index.mjs +2 -0
- package/dist/esm/cli/index.mjs.map +1 -0
- package/dist/esm/cli/localNode.d.mts +67 -0
- package/dist/esm/cli/localNode.mjs +2 -0
- package/dist/esm/cli/localNode.mjs.map +1 -0
- package/dist/esm/cli/move.d.mts +257 -0
- package/dist/esm/cli/move.mjs +2 -0
- package/dist/esm/cli/move.mjs.map +1 -0
- package/dist/esm/client/core.d.mts +42 -0
- package/dist/esm/client/core.mjs +2 -0
- package/dist/esm/client/core.mjs.map +1 -0
- package/dist/esm/client/get.d.mts +125 -0
- package/dist/esm/client/get.mjs +2 -0
- package/dist/esm/client/get.mjs.map +1 -0
- package/dist/esm/client/index.d.mts +10 -0
- package/dist/esm/client/index.mjs +2 -0
- package/dist/esm/client/index.mjs.map +1 -0
- package/dist/esm/client/post.d.mts +158 -0
- package/dist/esm/client/post.mjs +2 -0
- package/dist/esm/client/post.mjs.map +1 -0
- package/dist/esm/core/account/index.d.mts +8 -0
- package/dist/esm/core/account/index.mjs +2 -0
- package/dist/esm/core/account/index.mjs.map +1 -0
- package/dist/esm/core/account/utils/address.d.mts +55 -0
- package/dist/esm/core/account/utils/address.mjs +2 -0
- package/dist/esm/core/account/utils/address.mjs.map +1 -0
- package/dist/esm/core/account/utils/index.d.mts +8 -0
- package/dist/esm/core/account/utils/index.mjs +2 -0
- package/dist/esm/core/account/utils/index.mjs.map +1 -0
- package/dist/esm/core/accountAddress.d.mts +7 -0
- package/dist/esm/core/accountAddress.mjs +2 -0
- package/dist/esm/core/accountAddress.mjs.map +1 -0
- package/dist/esm/core/authenticationKey.d.mts +7 -0
- package/dist/esm/core/authenticationKey.mjs +2 -0
- package/dist/esm/core/authenticationKey.mjs.map +1 -0
- package/dist/esm/core/common.d.mts +52 -0
- package/dist/esm/core/common.mjs +2 -0
- package/dist/esm/core/common.mjs.map +1 -0
- package/dist/esm/core/crypto/abstraction.d.mts +24 -0
- package/dist/esm/core/crypto/abstraction.mjs +2 -0
- package/dist/esm/core/crypto/abstraction.mjs.map +1 -0
- package/dist/esm/core/crypto/deserializationUtils.d.mts +28 -0
- package/dist/esm/core/crypto/deserializationUtils.mjs +2 -0
- package/dist/esm/core/crypto/deserializationUtils.mjs.map +1 -0
- package/dist/esm/core/crypto/ed25519.d.mts +7 -0
- package/dist/esm/core/crypto/ed25519.mjs +2 -0
- package/dist/esm/core/crypto/ed25519.mjs.map +1 -0
- package/dist/esm/core/crypto/ephemeral.d.mts +116 -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/federatedKeyless.d.mts +13 -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/hdKey.d.mts +95 -0
- package/dist/esm/core/crypto/hdKey.mjs +2 -0
- package/dist/esm/core/crypto/hdKey.mjs.map +1 -0
- package/dist/esm/core/crypto/index.d.mts +19 -0
- package/dist/esm/core/crypto/index.mjs +2 -0
- package/dist/esm/core/crypto/index.mjs.map +1 -0
- package/dist/esm/core/crypto/keyless.d.mts +13 -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 +7 -0
- package/dist/esm/core/crypto/multiEd25519.mjs +2 -0
- package/dist/esm/core/crypto/multiEd25519.mjs.map +1 -0
- package/dist/esm/core/crypto/multiKey.d.mts +7 -0
- package/dist/esm/core/crypto/multiKey.mjs +2 -0
- package/dist/esm/core/crypto/multiKey.mjs.map +1 -0
- package/dist/esm/core/crypto/poseidon.d.mts +59 -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 +7 -0
- package/dist/esm/core/crypto/privateKey.mjs +2 -0
- package/dist/esm/core/crypto/privateKey.mjs.map +1 -0
- package/dist/esm/core/crypto/proof.d.mts +18 -0
- package/dist/esm/core/crypto/proof.mjs +2 -0
- package/dist/esm/core/crypto/proof.mjs.map +1 -0
- package/dist/esm/core/crypto/publicKey.d.mts +7 -0
- package/dist/esm/core/crypto/publicKey.mjs +2 -0
- package/dist/esm/core/crypto/publicKey.mjs.map +1 -0
- package/dist/esm/core/crypto/secp256k1.d.mts +7 -0
- package/dist/esm/core/crypto/secp256k1.mjs +2 -0
- package/dist/esm/core/crypto/secp256k1.mjs.map +1 -0
- package/dist/esm/core/crypto/secp256r1.d.mts +306 -0
- package/dist/esm/core/crypto/secp256r1.mjs +2 -0
- package/dist/esm/core/crypto/secp256r1.mjs.map +1 -0
- package/dist/esm/core/crypto/signature.d.mts +7 -0
- package/dist/esm/core/crypto/signature.mjs +2 -0
- package/dist/esm/core/crypto/signature.mjs.map +1 -0
- package/dist/esm/core/crypto/singleKey.d.mts +7 -0
- package/dist/esm/core/crypto/singleKey.mjs +2 -0
- package/dist/esm/core/crypto/singleKey.mjs.map +1 -0
- package/dist/esm/core/crypto/types.d.mts +11 -0
- package/dist/esm/core/crypto/types.mjs +2 -0
- package/dist/esm/core/crypto/types.mjs.map +1 -0
- package/dist/esm/core/crypto/utils.d.mts +23 -0
- package/dist/esm/core/crypto/utils.mjs +2 -0
- package/dist/esm/core/crypto/utils.mjs.map +1 -0
- package/dist/esm/core/hex.d.mts +7 -0
- package/dist/esm/core/hex.mjs +2 -0
- package/dist/esm/core/hex.mjs.map +1 -0
- package/dist/esm/core/index.d.mts +20 -0
- package/dist/esm/core/index.mjs +2 -0
- package/dist/esm/core/index.mjs.map +1 -0
- package/dist/esm/errors/index.d.mts +131 -0
- package/dist/esm/errors/index.mjs +2 -0
- package/dist/esm/errors/index.mjs.map +1 -0
- package/dist/esm/federatedKeyless-D-d9d5aC.d.mts +869 -0
- package/dist/esm/index.d.mts +71 -0
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/internal/abstraction.d.mts +27 -0
- package/dist/esm/internal/abstraction.mjs +2 -0
- package/dist/esm/internal/abstraction.mjs.map +1 -0
- package/dist/esm/internal/account.d.mts +453 -0
- package/dist/esm/internal/account.mjs +2 -0
- package/dist/esm/internal/account.mjs.map +1 -0
- package/dist/esm/internal/ans.d.mts +365 -0
- package/dist/esm/internal/ans.mjs +2 -0
- package/dist/esm/internal/ans.mjs.map +1 -0
- package/dist/esm/internal/coin.d.mts +31 -0
- package/dist/esm/internal/coin.mjs +2 -0
- package/dist/esm/internal/coin.mjs.map +1 -0
- package/dist/esm/internal/digitalAsset.d.mts +580 -0
- package/dist/esm/internal/digitalAsset.mjs +2 -0
- package/dist/esm/internal/digitalAsset.mjs.map +1 -0
- package/dist/esm/internal/faucet.d.mts +39 -0
- package/dist/esm/internal/faucet.mjs +2 -0
- package/dist/esm/internal/faucet.mjs.map +1 -0
- package/dist/esm/internal/fungibleAsset.d.mts +112 -0
- package/dist/esm/internal/fungibleAsset.mjs +2 -0
- package/dist/esm/internal/fungibleAsset.mjs.map +1 -0
- package/dist/esm/internal/general.d.mts +92 -0
- package/dist/esm/internal/general.mjs +2 -0
- package/dist/esm/internal/general.mjs.map +1 -0
- package/dist/esm/internal/keyless.d.mts +111 -0
- package/dist/esm/internal/keyless.mjs +2 -0
- package/dist/esm/internal/keyless.mjs.map +1 -0
- package/dist/esm/internal/object.d.mts +42 -0
- package/dist/esm/internal/object.mjs +2 -0
- package/dist/esm/internal/object.mjs.map +1 -0
- package/dist/esm/internal/staking.d.mts +60 -0
- package/dist/esm/internal/staking.mjs +2 -0
- package/dist/esm/internal/staking.mjs.map +1 -0
- package/dist/esm/internal/table.d.mts +66 -0
- package/dist/esm/internal/table.mjs +2 -0
- package/dist/esm/internal/table.mjs.map +1 -0
- package/dist/esm/internal/transaction.d.mts +199 -0
- package/dist/esm/internal/transaction.mjs +2 -0
- package/dist/esm/internal/transaction.mjs.map +1 -0
- package/dist/esm/internal/transactionSubmission.d.mts +165 -0
- package/dist/esm/internal/transactionSubmission.mjs +2 -0
- package/dist/esm/internal/transactionSubmission.mjs.map +1 -0
- package/dist/esm/internal/utils/index.d.mts +8 -0
- package/dist/esm/internal/utils/index.mjs +2 -0
- package/dist/esm/internal/utils/index.mjs.map +1 -0
- package/dist/esm/internal/utils/utils.d.mts +41 -0
- package/dist/esm/internal/utils/utils.mjs +2 -0
- package/dist/esm/internal/utils/utils.mjs.map +1 -0
- package/dist/esm/internal/view.d.mts +20 -0
- package/dist/esm/internal/view.mjs +2 -0
- package/dist/esm/internal/view.mjs.map +1 -0
- package/dist/esm/transactions/authenticator/account.d.mts +7 -0
- package/dist/esm/transactions/authenticator/account.mjs +2 -0
- package/dist/esm/transactions/authenticator/account.mjs.map +1 -0
- package/dist/esm/transactions/authenticator/index.d.mts +8 -0
- package/dist/esm/transactions/authenticator/index.mjs +2 -0
- package/dist/esm/transactions/authenticator/index.mjs.map +1 -0
- package/dist/esm/transactions/authenticator/transaction.d.mts +152 -0
- package/dist/esm/transactions/authenticator/transaction.mjs +2 -0
- package/dist/esm/transactions/authenticator/transaction.mjs.map +1 -0
- package/dist/esm/transactions/index.d.mts +15 -0
- package/dist/esm/transactions/index.mjs +2 -0
- package/dist/esm/transactions/index.mjs.map +1 -0
- package/dist/esm/transactions/instances/chainId.d.mts +7 -0
- package/dist/esm/transactions/instances/chainId.mjs +2 -0
- package/dist/esm/transactions/instances/chainId.mjs.map +1 -0
- package/dist/esm/transactions/instances/identifier.d.mts +7 -0
- package/dist/esm/transactions/instances/identifier.mjs +2 -0
- package/dist/esm/transactions/instances/identifier.mjs.map +1 -0
- package/dist/esm/transactions/instances/index.d.mts +10 -0
- package/dist/esm/transactions/instances/index.mjs +2 -0
- package/dist/esm/transactions/instances/index.mjs.map +1 -0
- package/dist/esm/transactions/instances/moduleId.d.mts +7 -0
- package/dist/esm/transactions/instances/moduleId.mjs +2 -0
- package/dist/esm/transactions/instances/moduleId.mjs.map +1 -0
- package/dist/esm/transactions/instances/multiAgentTransaction.d.mts +7 -0
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs +2 -0
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs.map +1 -0
- package/dist/esm/transactions/instances/rawTransaction.d.mts +7 -0
- package/dist/esm/transactions/instances/rawTransaction.mjs +2 -0
- package/dist/esm/transactions/instances/rawTransaction.mjs.map +1 -0
- package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +58 -0
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +2 -0
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs.map +1 -0
- package/dist/esm/transactions/instances/signedTransaction.d.mts +59 -0
- package/dist/esm/transactions/instances/signedTransaction.mjs +2 -0
- package/dist/esm/transactions/instances/signedTransaction.mjs.map +1 -0
- package/dist/esm/transactions/instances/simpleTransaction.d.mts +7 -0
- package/dist/esm/transactions/instances/simpleTransaction.mjs +2 -0
- package/dist/esm/transactions/instances/simpleTransaction.mjs.map +1 -0
- package/dist/esm/transactions/instances/transactionArgument.d.mts +7 -0
- package/dist/esm/transactions/instances/transactionArgument.mjs +2 -0
- package/dist/esm/transactions/instances/transactionArgument.mjs.map +1 -0
- package/dist/esm/transactions/instances/transactionPayload.d.mts +7 -0
- package/dist/esm/transactions/instances/transactionPayload.mjs +2 -0
- package/dist/esm/transactions/instances/transactionPayload.mjs.map +1 -0
- package/dist/esm/transactions/management/accountSequenceNumber.d.mts +123 -0
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +2 -0
- package/dist/esm/transactions/management/accountSequenceNumber.mjs.map +1 -0
- package/dist/esm/transactions/management/asyncQueue.d.mts +77 -0
- package/dist/esm/transactions/management/asyncQueue.mjs +2 -0
- package/dist/esm/transactions/management/asyncQueue.mjs.map +1 -0
- package/dist/esm/transactions/management/index.d.mts +12 -0
- package/dist/esm/transactions/management/index.mjs +2 -0
- package/dist/esm/transactions/management/index.mjs.map +1 -0
- package/dist/esm/transactions/management/transactionWorker.d.mts +210 -0
- package/dist/esm/transactions/management/transactionWorker.mjs +2 -0
- package/dist/esm/transactions/management/transactionWorker.mjs.map +1 -0
- package/dist/esm/transactions/transactionBuilder/helpers.d.mts +159 -0
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +2 -0
- package/dist/esm/transactions/transactionBuilder/helpers.mjs.map +1 -0
- package/dist/esm/transactions/transactionBuilder/index.d.mts +11 -0
- package/dist/esm/transactions/transactionBuilder/index.mjs +2 -0
- package/dist/esm/transactions/transactionBuilder/index.mjs.map +1 -0
- package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +104 -0
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +2 -0
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs.map +1 -0
- package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +62 -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 +192 -0
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +2 -0
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs.map +1 -0
- package/dist/esm/transactions/typeTag/index.d.mts +7 -0
- package/dist/esm/transactions/typeTag/index.mjs +2 -0
- package/dist/esm/transactions/typeTag/index.mjs.map +1 -0
- package/dist/esm/transactions/typeTag/parser.d.mts +81 -0
- package/dist/esm/transactions/typeTag/parser.mjs +2 -0
- package/dist/esm/transactions/typeTag/parser.mjs.map +1 -0
- package/dist/esm/transactions/types.d.mts +7 -0
- package/dist/esm/transactions/types.mjs +2 -0
- package/dist/esm/transactions/types.mjs.map +1 -0
- package/dist/esm/types/abstraction.d.mts +15 -0
- package/dist/esm/types/abstraction.mjs +2 -0
- package/dist/esm/types/abstraction.mjs.map +1 -0
- package/dist/esm/types/generated/operations.d.mts +709 -0
- package/dist/esm/types/generated/operations.mjs +1 -0
- package/dist/esm/types/generated/operations.mjs.map +1 -0
- package/dist/esm/types/generated/queries.d.mts +66 -0
- package/dist/esm/types/generated/queries.mjs +2 -0
- package/dist/esm/types/generated/queries.mjs.map +1 -0
- package/dist/esm/types/generated/types.d.mts +9495 -0
- package/dist/esm/types/generated/types.mjs +2 -0
- package/dist/esm/types/generated/types.mjs.map +1 -0
- package/dist/esm/types/index.d.mts +7 -0
- package/dist/esm/types/index.mjs +2 -0
- package/dist/esm/types/index.mjs.map +1 -0
- package/dist/esm/types/indexer.d.mts +186 -0
- package/dist/esm/types/indexer.mjs +2 -0
- package/dist/esm/types/indexer.mjs.map +1 -0
- package/dist/esm/types/keyless.d.mts +102 -0
- package/dist/esm/types/keyless.mjs +1 -0
- package/dist/esm/types/keyless.mjs.map +1 -0
- package/dist/esm/types/types.d.mts +7 -0
- package/dist/esm/types/types.mjs +2 -0
- package/dist/esm/types/types.mjs.map +1 -0
- package/dist/esm/utils/apiEndpoints.d.mts +51 -0
- package/dist/esm/utils/apiEndpoints.mjs +2 -0
- package/dist/esm/utils/apiEndpoints.mjs.map +1 -0
- package/dist/esm/utils/const.d.mts +90 -0
- package/dist/esm/utils/const.mjs +2 -0
- package/dist/esm/utils/const.mjs.map +1 -0
- package/dist/esm/utils/helpers.d.mts +174 -0
- package/dist/esm/utils/helpers.mjs +2 -0
- package/dist/esm/utils/helpers.mjs.map +1 -0
- package/dist/esm/utils/index.d.mts +9 -0
- package/dist/esm/utils/index.mjs +2 -0
- package/dist/esm/utils/index.mjs.map +1 -0
- package/dist/esm/utils/memoize.d.mts +26 -0
- package/dist/esm/utils/memoize.mjs +2 -0
- package/dist/esm/utils/memoize.mjs.map +1 -0
- package/dist/esm/utils/normalizeBundle.d.mts +35 -0
- package/dist/esm/utils/normalizeBundle.mjs +2 -0
- package/dist/esm/utils/normalizeBundle.mjs.map +1 -0
- package/dist/esm/version.d.mts +8 -0
- package/dist/esm/version.mjs +2 -0
- package/dist/esm/version.mjs.map +1 -0
- package/package.json +98 -0
- package/src/account/AbstractKeylessAccount.ts +579 -0
- package/src/account/AbstractedAccount.ts +124 -0
- package/src/account/Account.ts +354 -0
- package/src/account/AccountUtils.ts +216 -0
- package/src/account/DerivableAbstractedAccount.ts +103 -0
- package/src/account/Ed25519Account.ts +210 -0
- package/src/account/EphemeralKeyPair.ts +222 -0
- package/src/account/FederatedKeylessAccount.ts +178 -0
- package/src/account/KeylessAccount.ts +179 -0
- package/src/account/MultiEd25519Account.ts +181 -0
- package/src/account/MultiKeyAccount.ts +296 -0
- package/src/account/SingleKeyAccount.ts +277 -0
- package/src/account/index.ts +12 -0
- package/src/account/utils.ts +16 -0
- package/src/api/account/abstraction.ts +239 -0
- package/src/api/account.ts +1128 -0
- package/src/api/ans.ts +550 -0
- package/src/api/coin.ts +83 -0
- package/src/api/digitalAsset.ts +1203 -0
- package/src/api/faucet.ts +94 -0
- package/src/api/fungibleAsset.ts +371 -0
- package/src/api/general.ts +351 -0
- package/src/api/index.ts +6 -0
- package/src/api/keyless.ts +227 -0
- package/src/api/movement.ts +171 -0
- package/src/api/movementConfig.ts +334 -0
- package/src/api/object.ts +90 -0
- package/src/api/staking.ts +161 -0
- package/src/api/table.ts +193 -0
- package/src/api/transaction.ts +784 -0
- package/src/api/transactionSubmission/build.ts +153 -0
- package/src/api/transactionSubmission/helpers.ts +112 -0
- package/src/api/transactionSubmission/management.ts +211 -0
- package/src/api/transactionSubmission/sign.ts +142 -0
- package/src/api/transactionSubmission/simulate.ts +192 -0
- package/src/api/transactionSubmission/submit.ts +156 -0
- package/src/api/utils.ts +48 -0
- package/src/bcs/consts.ts +28 -0
- package/src/bcs/deserializer.ts +550 -0
- package/src/bcs/index.ts +10 -0
- package/src/bcs/serializable/entryFunctionBytes.ts +92 -0
- package/src/bcs/serializable/fixedBytes.ts +107 -0
- package/src/bcs/serializable/movePrimitives.ts +564 -0
- package/src/bcs/serializable/moveStructs.ts +619 -0
- package/src/bcs/serializer.ts +641 -0
- package/src/cli/index.ts +2 -0
- package/src/cli/localNode.ts +169 -0
- package/src/cli/move.ts +474 -0
- package/src/client/core.ts +120 -0
- package/src/client/get.ts +262 -0
- package/src/client/index.ts +7 -0
- package/src/client/post.ts +245 -0
- package/src/core/account/index.ts +1 -0
- package/src/core/account/utils/address.ts +85 -0
- package/src/core/account/utils/index.ts +1 -0
- package/src/core/accountAddress.ts +524 -0
- package/src/core/authenticationKey.ts +157 -0
- package/src/core/common.ts +60 -0
- package/src/core/crypto/abstraction.ts +52 -0
- package/src/core/crypto/deserializationUtils.ts +106 -0
- package/src/core/crypto/ed25519.ts +493 -0
- package/src/core/crypto/ephemeral.ts +185 -0
- package/src/core/crypto/federatedKeyless.ts +169 -0
- package/src/core/crypto/hdKey.ts +136 -0
- package/src/core/crypto/index.ts +21 -0
- package/src/core/crypto/keyless.ts +1700 -0
- package/src/core/crypto/multiEd25519.ts +434 -0
- package/src/core/crypto/multiKey.ts +498 -0
- package/src/core/crypto/poseidon.ts +231 -0
- package/src/core/crypto/privateKey.ts +115 -0
- package/src/core/crypto/proof.ts +9 -0
- package/src/core/crypto/publicKey.ts +106 -0
- package/src/core/crypto/secp256k1.ts +451 -0
- package/src/core/crypto/secp256r1.ts +495 -0
- package/src/core/crypto/signature.ts +57 -0
- package/src/core/crypto/singleKey.ts +351 -0
- package/src/core/crypto/types.ts +9 -0
- package/src/core/crypto/utils.ts +63 -0
- package/src/core/hex.ts +241 -0
- package/src/core/index.ts +10 -0
- package/src/errors/index.ts +457 -0
- package/src/index.ts +14 -0
- package/src/internal/abstraction.ts +79 -0
- package/src/internal/account.ts +1484 -0
- package/src/internal/ans.ts +853 -0
- package/src/internal/coin.ts +49 -0
- package/src/internal/digitalAsset.ts +1291 -0
- package/src/internal/faucet.ts +71 -0
- package/src/internal/fungibleAsset.ts +233 -0
- package/src/internal/general.ts +161 -0
- package/src/internal/keyless.ts +297 -0
- package/src/internal/object.ts +68 -0
- package/src/internal/queries/TokenActivitiesFieldsFragment.graphql +17 -0
- package/src/internal/queries/ansTokenFragment.graphql +11 -0
- package/src/internal/queries/currentTokenOwnershipFieldsFragment.graphql +46 -0
- package/src/internal/queries/getAccountAddressesForAuthKey.graphql +8 -0
- package/src/internal/queries/getAccountCoinCount.graphql +7 -0
- package/src/internal/queries/getAccountCoinsData.graphql +32 -0
- package/src/internal/queries/getAccountCollectionsWithOwnedTokens.graphql +33 -0
- package/src/internal/queries/getAccountOwnedTokens.graphql +11 -0
- package/src/internal/queries/getAccountOwnedTokensByTokenData.graphql +11 -0
- package/src/internal/queries/getAccountOwnedTokensFromCollectionAddress.graphql +11 -0
- package/src/internal/queries/getAccountTokensCount.graphql +7 -0
- package/src/internal/queries/getAccountTransactionsCount.graphql +7 -0
- package/src/internal/queries/getAuthKeysForPublicKey.graphql +11 -0
- package/src/internal/queries/getChainTopUserTransactions.graphql +5 -0
- package/src/internal/queries/getCollectionData.graphql +29 -0
- package/src/internal/queries/getCurrentFungibleAssetBalances.graphql +17 -0
- package/src/internal/queries/getDelegatedStakingActivities.graphql +12 -0
- package/src/internal/queries/getEvents.graphql +13 -0
- package/src/internal/queries/getFungibleAssetActivities.graphql +20 -0
- package/src/internal/queries/getFungibleAssetMetadata.graphql +18 -0
- package/src/internal/queries/getNames.graphql +11 -0
- package/src/internal/queries/getNumberOfDelegatorsQuery.graphql +9 -0
- package/src/internal/queries/getObjectData.graphql +16 -0
- package/src/internal/queries/getProcessorStatus.graphql +7 -0
- package/src/internal/queries/getTableItemsData.graphql +15 -0
- package/src/internal/queries/getTableItemsMetadata.graphql +12 -0
- package/src/internal/queries/getTokenActivity.graphql +11 -0
- package/src/internal/queries/getTokenCurrentOwner.graphql +11 -0
- package/src/internal/queries/getTokenData.graphql +39 -0
- package/src/internal/staking.ts +96 -0
- package/src/internal/table.ts +117 -0
- package/src/internal/transaction.ts +503 -0
- package/src/internal/transactionSubmission.ts +454 -0
- package/src/internal/utils/index.ts +4 -0
- package/src/internal/utils/utils.ts +86 -0
- package/src/internal/view.ts +61 -0
- package/src/transactions/authenticator/account.ts +405 -0
- package/src/transactions/authenticator/index.ts +6 -0
- package/src/transactions/authenticator/transaction.ts +288 -0
- package/src/transactions/index.ts +10 -0
- package/src/transactions/instances/chainId.ts +53 -0
- package/src/transactions/instances/identifier.ts +54 -0
- package/src/transactions/instances/index.ts +14 -0
- package/src/transactions/instances/moduleId.ts +77 -0
- package/src/transactions/instances/multiAgentTransaction.ts +92 -0
- package/src/transactions/instances/rawTransaction.ts +256 -0
- package/src/transactions/instances/rotationProofChallenge.ts +86 -0
- package/src/transactions/instances/signedTransaction.ts +73 -0
- package/src/transactions/instances/simpleTransaction.ts +83 -0
- package/src/transactions/instances/transactionArgument.ts +79 -0
- package/src/transactions/instances/transactionPayload.ts +676 -0
- package/src/transactions/management/accountSequenceNumber.ts +226 -0
- package/src/transactions/management/asyncQueue.ts +126 -0
- package/src/transactions/management/index.ts +2 -0
- package/src/transactions/management/transactionWorker.ts +396 -0
- package/src/transactions/transactionBuilder/helpers.ts +319 -0
- package/src/transactions/transactionBuilder/index.ts +8 -0
- package/src/transactions/transactionBuilder/remoteAbi.ts +655 -0
- package/src/transactions/transactionBuilder/signingMessage.ts +111 -0
- package/src/transactions/transactionBuilder/transactionBuilder.ts +863 -0
- package/src/transactions/typeTag/index.ts +926 -0
- package/src/transactions/typeTag/parser.ts +434 -0
- package/src/transactions/types.ts +518 -0
- package/src/types/abstraction.ts +14 -0
- package/src/types/codegen.yaml +33 -0
- package/src/types/generated/operations.ts +738 -0
- package/src/types/generated/queries.ts +926 -0
- package/src/types/generated/types.ts +10421 -0
- package/src/types/index.ts +2 -0
- package/src/types/indexer.ts +240 -0
- package/src/types/keyless.ts +94 -0
- package/src/types/types.ts +1713 -0
- package/src/utils/apiEndpoints.ts +107 -0
- package/src/utils/const.ts +100 -0
- package/src/utils/helpers.ts +287 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/memoize.ts +76 -0
- package/src/utils/normalizeBundle.ts +34 -0
- package/src/version.ts +9 -0
|
@@ -0,0 +1,1484 @@
|
|
|
1
|
+
// Copyright © Move Industries
|
|
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/account}. By moving the methods out into a separate file,
|
|
7
|
+
* other namespaces and processes can access these methods without depending on the entire
|
|
8
|
+
* account namespace and without having a dependency cycle error.
|
|
9
|
+
* @group Implementation
|
|
10
|
+
*/
|
|
11
|
+
import {
|
|
12
|
+
Account,
|
|
13
|
+
Ed25519Account,
|
|
14
|
+
FederatedKeylessAccount,
|
|
15
|
+
KeylessAccount,
|
|
16
|
+
MultiEd25519Account,
|
|
17
|
+
MultiKeyAccount,
|
|
18
|
+
SingleKeyAccount,
|
|
19
|
+
} from "../account";
|
|
20
|
+
import { MovementConfig } from "../api/movementConfig";
|
|
21
|
+
import { Deserializer, MoveVector, U8 } from "../bcs";
|
|
22
|
+
import {
|
|
23
|
+
getAptosFullNode,
|
|
24
|
+
getPageWithObfuscatedCursor,
|
|
25
|
+
paginateWithCursor,
|
|
26
|
+
paginateWithObfuscatedCursor,
|
|
27
|
+
} from "../client";
|
|
28
|
+
import { AuthenticationKey, createObjectAddress, Ed25519PrivateKey, Hex, Secp256k1PrivateKey } from "../core";
|
|
29
|
+
import { AccountAddress, AccountAddressInput } from "../core/accountAddress";
|
|
30
|
+
import {
|
|
31
|
+
AbstractMultiKey,
|
|
32
|
+
AccountPublicKey,
|
|
33
|
+
AnyPublicKey,
|
|
34
|
+
BaseAccountPublicKey,
|
|
35
|
+
Ed25519PublicKey,
|
|
36
|
+
MultiEd25519PublicKey,
|
|
37
|
+
MultiKey,
|
|
38
|
+
PrivateKeyInput,
|
|
39
|
+
} from "../core/crypto";
|
|
40
|
+
import { accountPublicKeyToBaseAccountPublicKey, accountPublicKeyToSigningScheme } from "../core/crypto/utils";
|
|
41
|
+
import { MovementApiError } from "../errors";
|
|
42
|
+
import {
|
|
43
|
+
EntryFunctionABI,
|
|
44
|
+
InputGenerateTransactionOptions,
|
|
45
|
+
RotationProofChallenge,
|
|
46
|
+
SimpleTransaction,
|
|
47
|
+
TypeTagU8,
|
|
48
|
+
TypeTagVector,
|
|
49
|
+
} from "../transactions";
|
|
50
|
+
import {
|
|
51
|
+
AccountData,
|
|
52
|
+
anyPublicKeyVariantToString,
|
|
53
|
+
CommittedTransactionResponse,
|
|
54
|
+
CursorPaginationArgs,
|
|
55
|
+
GetAccountCoinsDataResponse,
|
|
56
|
+
GetAccountCollectionsWithOwnedTokenResponse,
|
|
57
|
+
GetAccountOwnedTokensFromCollectionResponse,
|
|
58
|
+
GetAccountOwnedTokensQueryResponse,
|
|
59
|
+
GetObjectDataQueryResponse,
|
|
60
|
+
LedgerVersionArg,
|
|
61
|
+
MoveModuleBytecode,
|
|
62
|
+
MoveResource,
|
|
63
|
+
MoveStructId,
|
|
64
|
+
OrderByArg,
|
|
65
|
+
PaginationArgs,
|
|
66
|
+
TokenStandardArg,
|
|
67
|
+
WhereArg
|
|
68
|
+
} from "../types";
|
|
69
|
+
import {
|
|
70
|
+
GetAccountAddressesForAuthKeyQuery,
|
|
71
|
+
GetAccountCoinsCountQuery,
|
|
72
|
+
GetAccountCoinsDataQuery,
|
|
73
|
+
GetAccountCollectionsWithOwnedTokensQuery,
|
|
74
|
+
GetAccountOwnedTokensFromCollectionQuery,
|
|
75
|
+
GetAccountOwnedTokensQuery,
|
|
76
|
+
GetAccountTokensCountQuery,
|
|
77
|
+
GetAccountTransactionsCountQuery,
|
|
78
|
+
GetAuthKeysForPublicKeyQuery,
|
|
79
|
+
GetObjectDataQuery,
|
|
80
|
+
} from "../types/generated/operations";
|
|
81
|
+
import {
|
|
82
|
+
GetAccountAddressesForAuthKey,
|
|
83
|
+
GetAccountCoinsCount,
|
|
84
|
+
GetAccountCoinsData,
|
|
85
|
+
GetAccountCollectionsWithOwnedTokens,
|
|
86
|
+
GetAccountOwnedTokens,
|
|
87
|
+
GetAccountOwnedTokensFromCollection,
|
|
88
|
+
GetAccountTokensCount,
|
|
89
|
+
GetAccountTransactionsCount,
|
|
90
|
+
GetAuthKeysForPublicKey,
|
|
91
|
+
GetObjectData,
|
|
92
|
+
} from "../types/generated/queries";
|
|
93
|
+
import { CurrentFungibleAssetBalancesBoolExp } from "../types/generated/types";
|
|
94
|
+
import { MOVEMENT_COIN } from "../utils";
|
|
95
|
+
import { queryIndexer } from "./general";
|
|
96
|
+
import { getTableItem } from "./table";
|
|
97
|
+
import { generateTransaction } from "./transactionSubmission";
|
|
98
|
+
import { getInfo as getInfoUtil, getModule as getModuleUtil } from "./utils";
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Retrieves account information for a specified account address.
|
|
102
|
+
*
|
|
103
|
+
* @param args - The arguments for retrieving account information.
|
|
104
|
+
* @param args.movementConfig - The configuration object for Movement.
|
|
105
|
+
* @param args.accountAddress - The address of the account to retrieve information for.
|
|
106
|
+
* @group Implementation
|
|
107
|
+
*/
|
|
108
|
+
export async function getInfo(args: {
|
|
109
|
+
movementConfig: MovementConfig;
|
|
110
|
+
accountAddress: AccountAddressInput;
|
|
111
|
+
}): Promise<AccountData> {
|
|
112
|
+
return getInfoUtil(args);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Retrieves the modules associated with a specified account address.
|
|
117
|
+
*
|
|
118
|
+
* @param args - The arguments for retrieving modules.
|
|
119
|
+
* @param args.movementConfig - The configuration for connecting to the Movement blockchain.
|
|
120
|
+
* @param args.accountAddress - The address of the account whose modules are to be retrieved.
|
|
121
|
+
* @param args.options - Optional parameters for pagination and ledger version.
|
|
122
|
+
* @param args.options.limit - The maximum number of modules to retrieve (default is 1000).
|
|
123
|
+
* @param args.options.offset - The starting point for pagination. Note, this is obfuscated and is not an index.
|
|
124
|
+
* @param args.options.ledgerVersion - The specific ledger version to query.
|
|
125
|
+
* @group Implementation
|
|
126
|
+
*/
|
|
127
|
+
export async function getModules(args: {
|
|
128
|
+
movementConfig: MovementConfig;
|
|
129
|
+
accountAddress: AccountAddressInput;
|
|
130
|
+
options?: { limit?: number } & LedgerVersionArg;
|
|
131
|
+
}): Promise<MoveModuleBytecode[]> {
|
|
132
|
+
const { movementConfig, accountAddress, options } = args;
|
|
133
|
+
return paginateWithObfuscatedCursor<{}, MoveModuleBytecode[]>({
|
|
134
|
+
movementConfig,
|
|
135
|
+
originMethod: "getModules",
|
|
136
|
+
path: `accounts/${AccountAddress.from(accountAddress).toString()}/modules`,
|
|
137
|
+
params: {
|
|
138
|
+
ledger_version: options?.ledgerVersion,
|
|
139
|
+
limit: options?.limit ?? 1000,
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Retrieves the modules associated with a specified account address.
|
|
146
|
+
*
|
|
147
|
+
* @param args - The arguments for retrieving modules.
|
|
148
|
+
* @param args.movementConfig - The configuration for connecting to the Movement blockchain.
|
|
149
|
+
* @param args.accountAddress - The address of the account whose modules are to be retrieved.
|
|
150
|
+
* @param args.options - Optional parameters for pagination and ledger version.
|
|
151
|
+
* @param args.options.cursor - The starting point for pagination. Note, this is obfuscated and is not an index.
|
|
152
|
+
* @param args.options.limit - The maximum number of modules to retrieve (default is 100).
|
|
153
|
+
* @param args.options.ledgerVersion - The specific ledger version to query.
|
|
154
|
+
* @group Implementation
|
|
155
|
+
*/
|
|
156
|
+
export async function getModulesPage(args: {
|
|
157
|
+
movementConfig: MovementConfig;
|
|
158
|
+
accountAddress: AccountAddressInput;
|
|
159
|
+
options?: CursorPaginationArgs & LedgerVersionArg;
|
|
160
|
+
}): Promise<{ modules: MoveModuleBytecode[]; cursor: string | undefined }> {
|
|
161
|
+
const { movementConfig, accountAddress, options } = args;
|
|
162
|
+
const { response, cursor } = await getPageWithObfuscatedCursor<{}, MoveModuleBytecode[]>({
|
|
163
|
+
movementConfig,
|
|
164
|
+
originMethod: "getModulesPage",
|
|
165
|
+
path: `accounts/${AccountAddress.from(accountAddress).toString()}/modules`,
|
|
166
|
+
params: {
|
|
167
|
+
ledger_version: options?.ledgerVersion,
|
|
168
|
+
cursor: options?.cursor,
|
|
169
|
+
limit: options?.limit ?? 100,
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
return { modules: response.data, cursor };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Queries for a move module given an account address and module name.
|
|
178
|
+
* This function can help you retrieve the module's ABI and other relevant information.
|
|
179
|
+
*
|
|
180
|
+
* @param args - The arguments for retrieving the module.
|
|
181
|
+
* @param args.movementConfig - The configuration for the Movement client.
|
|
182
|
+
* @param args.accountAddress - The account address in hex-encoded 32 byte format.
|
|
183
|
+
* @param args.moduleName - The name of the module to retrieve.
|
|
184
|
+
* @param args.options - Optional parameters for the request.
|
|
185
|
+
* @param args.options.ledgerVersion - Specifies the ledger version of transactions. By default, the latest version will be used.
|
|
186
|
+
* @returns The move module.
|
|
187
|
+
* @group Implementation
|
|
188
|
+
*/
|
|
189
|
+
export async function getModule(args: {
|
|
190
|
+
movementConfig: MovementConfig;
|
|
191
|
+
accountAddress: AccountAddressInput;
|
|
192
|
+
moduleName: string;
|
|
193
|
+
options?: LedgerVersionArg;
|
|
194
|
+
}): Promise<MoveModuleBytecode> {
|
|
195
|
+
return getModuleUtil(args);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Retrieves a list of transactions associated with a specific account address.
|
|
200
|
+
* This function allows you to paginate through the transactions for better performance and usability.
|
|
201
|
+
*
|
|
202
|
+
* @param args - The arguments for retrieving transactions.
|
|
203
|
+
* @param args.movementConfig - The configuration settings for Movement.
|
|
204
|
+
* @param args.accountAddress - The account address for which to retrieve transactions.
|
|
205
|
+
* @param args.options - Optional pagination parameters.
|
|
206
|
+
* @param args.options.offset - The starting point for pagination.
|
|
207
|
+
* @param args.options.limit - The maximum number of transactions to retrieve.
|
|
208
|
+
* @group Implementation
|
|
209
|
+
*/
|
|
210
|
+
export async function getTransactions(args: {
|
|
211
|
+
movementConfig: MovementConfig;
|
|
212
|
+
accountAddress: AccountAddressInput;
|
|
213
|
+
options?: PaginationArgs;
|
|
214
|
+
}): Promise<CommittedTransactionResponse[]> {
|
|
215
|
+
const { movementConfig, accountAddress, options } = args;
|
|
216
|
+
return paginateWithCursor<{}, CommittedTransactionResponse[]>({
|
|
217
|
+
movementConfig,
|
|
218
|
+
originMethod: "getTransactions",
|
|
219
|
+
path: `accounts/${AccountAddress.from(accountAddress).toString()}/transactions`,
|
|
220
|
+
params: { start: options?.offset, limit: options?.limit },
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Retrieves a list of resources associated with a specific account address.
|
|
226
|
+
*
|
|
227
|
+
* @param args - The arguments for retrieving resources.
|
|
228
|
+
* @param args.movementConfig - The configuration settings for Movement.
|
|
229
|
+
* @param args.accountAddress - The address of the account to fetch resources for.
|
|
230
|
+
* @param args.options - Optional pagination and ledger version parameters.
|
|
231
|
+
* @param args.options.limit - The maximum number of resources to retrieve (default is 999).
|
|
232
|
+
* @param args.options.ledgerVersion - The specific ledger version to query.
|
|
233
|
+
* @group Implementation
|
|
234
|
+
*/
|
|
235
|
+
export async function getResources(args: {
|
|
236
|
+
movementConfig: MovementConfig;
|
|
237
|
+
accountAddress: AccountAddressInput;
|
|
238
|
+
options?: { limit?: number } & LedgerVersionArg;
|
|
239
|
+
}): Promise<MoveResource[]> {
|
|
240
|
+
const { movementConfig, accountAddress, options } = args;
|
|
241
|
+
return paginateWithObfuscatedCursor<{}, MoveResource[]>({
|
|
242
|
+
movementConfig,
|
|
243
|
+
originMethod: "getResources",
|
|
244
|
+
path: `accounts/${AccountAddress.from(accountAddress).toString()}/resources`,
|
|
245
|
+
params: {
|
|
246
|
+
ledger_version: options?.ledgerVersion,
|
|
247
|
+
limit: options?.limit ?? 999,
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Retrieves a page of resources associated with a specific account address.
|
|
254
|
+
*
|
|
255
|
+
* @param args - The arguments for retrieving resources.
|
|
256
|
+
* @param args.movementConfig - The configuration settings for Movement.
|
|
257
|
+
* @param args.accountAddress - The address of the account to fetch resources for.
|
|
258
|
+
* @param args.options - Optional pagination and ledger version parameters.
|
|
259
|
+
* @param args.options.cursor - The starting point for pagination. Note, this is obfuscated and is not an index.
|
|
260
|
+
* @param args.options.limit - The maximum number of resources to retrieve (default is 100).
|
|
261
|
+
* @param args.options.ledgerVersion - The specific ledger version to query.
|
|
262
|
+
* @group Implementation
|
|
263
|
+
*/
|
|
264
|
+
export async function getResourcesPage(args: {
|
|
265
|
+
movementConfig: MovementConfig;
|
|
266
|
+
accountAddress: AccountAddressInput;
|
|
267
|
+
options?: CursorPaginationArgs & LedgerVersionArg;
|
|
268
|
+
}): Promise<{ resources: MoveResource[]; cursor: string | undefined }> {
|
|
269
|
+
const { movementConfig, accountAddress, options } = args;
|
|
270
|
+
const { response, cursor } = await getPageWithObfuscatedCursor<{}, MoveResource[]>({
|
|
271
|
+
movementConfig,
|
|
272
|
+
originMethod: "getResourcesPage",
|
|
273
|
+
path: `accounts/${AccountAddress.from(accountAddress).toString()}/resources`,
|
|
274
|
+
params: {
|
|
275
|
+
ledger_version: options?.ledgerVersion,
|
|
276
|
+
cursor: options?.cursor,
|
|
277
|
+
limit: options?.limit ?? 100,
|
|
278
|
+
},
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
return { resources: response.data, cursor };
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Retrieves a specific resource of a given type for the specified account address.
|
|
286
|
+
*
|
|
287
|
+
* @param args - The arguments for retrieving the resource.
|
|
288
|
+
* @param args.movementConfig - The configuration settings for Movement.
|
|
289
|
+
* @param args.accountAddress - The address of the account from which to retrieve the resource.
|
|
290
|
+
* @param args.resourceType - The type of the resource to retrieve, specified as a MoveStructId.
|
|
291
|
+
* @param args.options - Optional parameters for specifying the ledger version.
|
|
292
|
+
* @group Implementation
|
|
293
|
+
*/
|
|
294
|
+
export async function getResource<T extends {}>(args: {
|
|
295
|
+
movementConfig: MovementConfig;
|
|
296
|
+
accountAddress: AccountAddressInput;
|
|
297
|
+
resourceType: MoveStructId;
|
|
298
|
+
options?: LedgerVersionArg;
|
|
299
|
+
}): Promise<T> {
|
|
300
|
+
const { movementConfig, accountAddress, resourceType, options } = args;
|
|
301
|
+
const { data } = await getAptosFullNode<{}, MoveResource>({
|
|
302
|
+
movementConfig,
|
|
303
|
+
originMethod: "getResource",
|
|
304
|
+
path: `accounts/${AccountAddress.from(accountAddress).toString()}/resource/${resourceType}`,
|
|
305
|
+
params: { ledger_version: options?.ledgerVersion },
|
|
306
|
+
});
|
|
307
|
+
return data.data as T;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Retrieves the original account address associated with a given authentication key, which is useful for handling key rotations.
|
|
312
|
+
*
|
|
313
|
+
* @param args - The arguments for the lookup.
|
|
314
|
+
* @param args.movementConfig - The configuration for the Movement client.
|
|
315
|
+
* @param args.authenticationKey - The authentication key for which to look up the original address.
|
|
316
|
+
* @param args.options - Optional parameters for specifying the ledger version.
|
|
317
|
+
* @returns The original account address or the provided authentication key address if not found.
|
|
318
|
+
* @throws Throws an error if the lookup fails for reasons other than the address not being found.
|
|
319
|
+
* @group Implementation
|
|
320
|
+
*/
|
|
321
|
+
export async function lookupOriginalAccountAddress(args: {
|
|
322
|
+
movementConfig: MovementConfig;
|
|
323
|
+
authenticationKey: AccountAddressInput;
|
|
324
|
+
options?: LedgerVersionArg;
|
|
325
|
+
}): Promise<AccountAddress> {
|
|
326
|
+
const { movementConfig, authenticationKey, options } = args;
|
|
327
|
+
type OriginatingAddress = {
|
|
328
|
+
address_map: { handle: string };
|
|
329
|
+
};
|
|
330
|
+
const resource = await getResource<OriginatingAddress>({
|
|
331
|
+
movementConfig,
|
|
332
|
+
accountAddress: "0x1",
|
|
333
|
+
resourceType: "0x1::account::OriginatingAddress",
|
|
334
|
+
options,
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
const {
|
|
338
|
+
address_map: { handle },
|
|
339
|
+
} = resource;
|
|
340
|
+
|
|
341
|
+
const authKeyAddress = AccountAddress.from(authenticationKey);
|
|
342
|
+
|
|
343
|
+
// If the address is not found in the address map, which means its not rotated
|
|
344
|
+
// then return the address as is
|
|
345
|
+
try {
|
|
346
|
+
const originalAddress = await getTableItem<string>({
|
|
347
|
+
movementConfig,
|
|
348
|
+
handle,
|
|
349
|
+
data: {
|
|
350
|
+
key: authKeyAddress.toString(),
|
|
351
|
+
key_type: "address",
|
|
352
|
+
value_type: "address",
|
|
353
|
+
},
|
|
354
|
+
options,
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
return AccountAddress.from(originalAddress);
|
|
358
|
+
} catch (err) {
|
|
359
|
+
if (err instanceof MovementApiError && err.data.error_code === "table_item_not_found") {
|
|
360
|
+
return authKeyAddress;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
throw err;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Retrieves the count of tokens owned by a specific account address.
|
|
369
|
+
*
|
|
370
|
+
* @param args - The arguments for retrieving the account tokens count.
|
|
371
|
+
* @param args.movementConfig - The configuration settings for the Movement network.
|
|
372
|
+
* @param args.accountAddress - The address of the account for which to count the tokens.
|
|
373
|
+
* @returns The count of tokens owned by the specified account.
|
|
374
|
+
* @group Implementation
|
|
375
|
+
*/
|
|
376
|
+
export async function getAccountTokensCount(args: {
|
|
377
|
+
movementConfig: MovementConfig;
|
|
378
|
+
accountAddress: AccountAddressInput;
|
|
379
|
+
}): Promise<number> {
|
|
380
|
+
const { movementConfig, accountAddress } = args;
|
|
381
|
+
|
|
382
|
+
const address = AccountAddress.from(accountAddress).toStringLong();
|
|
383
|
+
|
|
384
|
+
const whereCondition: { owner_address: { _eq: string }; amount: { _gt: number } } = {
|
|
385
|
+
owner_address: { _eq: address },
|
|
386
|
+
amount: { _gt: 0 },
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
const graphqlQuery = {
|
|
390
|
+
query: GetAccountTokensCount,
|
|
391
|
+
variables: { where_condition: whereCondition },
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
const data = await queryIndexer<GetAccountTokensCountQuery>({
|
|
395
|
+
movementConfig,
|
|
396
|
+
query: graphqlQuery,
|
|
397
|
+
originMethod: "getAccountTokensCount",
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
// commonjs (aka cjs) doesn't handle Nullish Coalescing for some reason
|
|
401
|
+
// might be because of how ts infer the graphql generated scheme type
|
|
402
|
+
return data.current_token_ownerships_v2_aggregate.aggregate
|
|
403
|
+
? data.current_token_ownerships_v2_aggregate.aggregate.count
|
|
404
|
+
: 0;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Retrieves the tokens owned by a specified account address.
|
|
409
|
+
*
|
|
410
|
+
* @param args - The arguments for retrieving the account's tokens.
|
|
411
|
+
* @param args.movementConfig - The configuration for the Movement client.
|
|
412
|
+
* @param args.accountAddress - The address of the account whose tokens are being queried.
|
|
413
|
+
* @param args.options - Optional parameters for filtering and pagination.
|
|
414
|
+
* @param args.options.tokenStandard - The specific token standard to filter the results.
|
|
415
|
+
* @param args.options.offset - The number of records to skip before starting to collect the result set.
|
|
416
|
+
* @param args.options.limit - The maximum number of records to return.
|
|
417
|
+
* @param args.options.orderBy - The criteria for ordering the results.
|
|
418
|
+
* @returns A promise that resolves to the current token ownerships of the specified account.
|
|
419
|
+
* @group Implementation
|
|
420
|
+
*/
|
|
421
|
+
export async function getAccountOwnedTokens(args: {
|
|
422
|
+
movementConfig: MovementConfig;
|
|
423
|
+
accountAddress: AccountAddressInput;
|
|
424
|
+
options?: TokenStandardArg & PaginationArgs & OrderByArg<GetAccountOwnedTokensQueryResponse[0]>;
|
|
425
|
+
}): Promise<GetAccountOwnedTokensQueryResponse> {
|
|
426
|
+
const { movementConfig, accountAddress, options } = args;
|
|
427
|
+
const address = AccountAddress.from(accountAddress).toStringLong();
|
|
428
|
+
|
|
429
|
+
const whereCondition: { owner_address: { _eq: string }; amount: { _gt: number }; token_standard?: { _eq: string } } =
|
|
430
|
+
{
|
|
431
|
+
owner_address: { _eq: address },
|
|
432
|
+
amount: { _gt: 0 },
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
if (options?.tokenStandard) {
|
|
436
|
+
whereCondition.token_standard = { _eq: options?.tokenStandard };
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
const graphqlQuery = {
|
|
440
|
+
query: GetAccountOwnedTokens,
|
|
441
|
+
variables: {
|
|
442
|
+
where_condition: whereCondition,
|
|
443
|
+
offset: options?.offset,
|
|
444
|
+
limit: options?.limit,
|
|
445
|
+
order_by: options?.orderBy,
|
|
446
|
+
},
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
const data = await queryIndexer<GetAccountOwnedTokensQuery>({
|
|
450
|
+
movementConfig,
|
|
451
|
+
query: graphqlQuery,
|
|
452
|
+
originMethod: "getAccountOwnedTokens",
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
return data.current_token_ownerships_v2;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Retrieves the tokens owned by a specific account from a particular collection address.
|
|
460
|
+
*
|
|
461
|
+
* @param args - The parameters required to fetch the owned tokens.
|
|
462
|
+
* @param args.movementConfig - The Movement configuration object.
|
|
463
|
+
* @param args.accountAddress - The address of the account whose tokens are being queried.
|
|
464
|
+
* @param args.collectionAddress - The address of the collection from which tokens are being retrieved.
|
|
465
|
+
* @param args.options - Optional parameters for filtering and pagination, including token standard, pagination arguments, and
|
|
466
|
+
* order by options.
|
|
467
|
+
* @group Implementation
|
|
468
|
+
*/
|
|
469
|
+
export async function getAccountOwnedTokensFromCollectionAddress(args: {
|
|
470
|
+
movementConfig: MovementConfig;
|
|
471
|
+
accountAddress: AccountAddressInput;
|
|
472
|
+
collectionAddress: AccountAddressInput;
|
|
473
|
+
options?: TokenStandardArg & PaginationArgs & OrderByArg<GetAccountOwnedTokensFromCollectionResponse[0]>;
|
|
474
|
+
}): Promise<GetAccountOwnedTokensFromCollectionResponse> {
|
|
475
|
+
const { movementConfig, accountAddress, collectionAddress, options } = args;
|
|
476
|
+
const ownerAddress = AccountAddress.from(accountAddress).toStringLong();
|
|
477
|
+
const collAddress = AccountAddress.from(collectionAddress).toStringLong();
|
|
478
|
+
|
|
479
|
+
const whereCondition: {
|
|
480
|
+
owner_address: { _eq: string };
|
|
481
|
+
current_token_data: { collection_id: { _eq: string } };
|
|
482
|
+
amount: { _gt: number };
|
|
483
|
+
token_standard?: { _eq: string };
|
|
484
|
+
} = {
|
|
485
|
+
owner_address: { _eq: ownerAddress },
|
|
486
|
+
current_token_data: { collection_id: { _eq: collAddress } },
|
|
487
|
+
amount: { _gt: 0 },
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
if (options?.tokenStandard) {
|
|
491
|
+
whereCondition.token_standard = { _eq: options?.tokenStandard };
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
const graphqlQuery = {
|
|
495
|
+
query: GetAccountOwnedTokensFromCollection,
|
|
496
|
+
variables: {
|
|
497
|
+
where_condition: whereCondition,
|
|
498
|
+
offset: options?.offset,
|
|
499
|
+
limit: options?.limit,
|
|
500
|
+
order_by: options?.orderBy,
|
|
501
|
+
},
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
const data = await queryIndexer<GetAccountOwnedTokensFromCollectionQuery>({
|
|
505
|
+
movementConfig,
|
|
506
|
+
query: graphqlQuery,
|
|
507
|
+
originMethod: "getAccountOwnedTokensFromCollectionAddress",
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
return data.current_token_ownerships_v2;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Retrieves the collections owned by a specified account along with the tokens in those collections.
|
|
515
|
+
*
|
|
516
|
+
* @param args - The arguments for the function.
|
|
517
|
+
* @param args.movementConfig - The configuration for the Movement client.
|
|
518
|
+
* @param args.accountAddress - The address of the account whose collections are being queried.
|
|
519
|
+
* @param args.options - Optional parameters for filtering and pagination.
|
|
520
|
+
* @param args.options.tokenStandard - An optional token standard to filter the collections.
|
|
521
|
+
* @param args.options.offset - An optional offset for pagination.
|
|
522
|
+
* @param args.options.limit - An optional limit for the number of results returned.
|
|
523
|
+
* @param args.options.orderBy - An optional parameter to specify the order of the results.
|
|
524
|
+
* @group Implementation
|
|
525
|
+
*/
|
|
526
|
+
export async function getAccountCollectionsWithOwnedTokens(args: {
|
|
527
|
+
movementConfig: MovementConfig;
|
|
528
|
+
accountAddress: AccountAddressInput;
|
|
529
|
+
options?: TokenStandardArg & PaginationArgs & OrderByArg<GetAccountCollectionsWithOwnedTokenResponse[0]>;
|
|
530
|
+
}): Promise<GetAccountCollectionsWithOwnedTokenResponse> {
|
|
531
|
+
const { movementConfig, accountAddress, options } = args;
|
|
532
|
+
const address = AccountAddress.from(accountAddress).toStringLong();
|
|
533
|
+
|
|
534
|
+
const whereCondition: {
|
|
535
|
+
owner_address: { _eq: string };
|
|
536
|
+
current_collection?: { token_standard: { _eq: string } };
|
|
537
|
+
} = {
|
|
538
|
+
owner_address: { _eq: address },
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
if (options?.tokenStandard) {
|
|
542
|
+
whereCondition.current_collection = {
|
|
543
|
+
token_standard: { _eq: options?.tokenStandard },
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
const graphqlQuery = {
|
|
548
|
+
query: GetAccountCollectionsWithOwnedTokens,
|
|
549
|
+
variables: {
|
|
550
|
+
where_condition: whereCondition,
|
|
551
|
+
offset: options?.offset,
|
|
552
|
+
limit: options?.limit,
|
|
553
|
+
order_by: options?.orderBy,
|
|
554
|
+
},
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
const data = await queryIndexer<GetAccountCollectionsWithOwnedTokensQuery>({
|
|
558
|
+
movementConfig,
|
|
559
|
+
query: graphqlQuery,
|
|
560
|
+
originMethod: "getAccountCollectionsWithOwnedTokens",
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
return data.current_collection_ownership_v2_view;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Retrieves the count of transactions associated with a specified account.
|
|
568
|
+
*
|
|
569
|
+
* @param args - The arguments for the function.
|
|
570
|
+
* @param args.movementConfig - The configuration settings for Movement.
|
|
571
|
+
* @param args.accountAddress - The address of the account for which to retrieve the transaction count.
|
|
572
|
+
* @returns The number of transactions associated with the specified account.
|
|
573
|
+
* @group Implementation
|
|
574
|
+
*/
|
|
575
|
+
export async function getAccountTransactionsCount(args: {
|
|
576
|
+
movementConfig: MovementConfig;
|
|
577
|
+
accountAddress: AccountAddressInput;
|
|
578
|
+
}): Promise<number> {
|
|
579
|
+
const { movementConfig, accountAddress } = args;
|
|
580
|
+
|
|
581
|
+
const address = AccountAddress.from(accountAddress).toStringLong();
|
|
582
|
+
|
|
583
|
+
const graphqlQuery = {
|
|
584
|
+
query: GetAccountTransactionsCount,
|
|
585
|
+
variables: { address },
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
const data = await queryIndexer<GetAccountTransactionsCountQuery>({
|
|
589
|
+
movementConfig,
|
|
590
|
+
query: graphqlQuery,
|
|
591
|
+
originMethod: "getAccountTransactionsCount",
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
// commonjs (aka cjs) doesn't handle Nullish Coalescing for some reason
|
|
595
|
+
// might be because of how ts infer the graphql generated scheme type
|
|
596
|
+
return data.account_transactions_aggregate.aggregate ? data.account_transactions_aggregate.aggregate.count : 0;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Retrieves the amount of a specific coin held by an account.
|
|
601
|
+
*
|
|
602
|
+
* @param args - The parameters for the request.
|
|
603
|
+
* @param args.movementConfig - The Movement configuration object.
|
|
604
|
+
* @param args.accountAddress - The address of the account to query.
|
|
605
|
+
* @param args.coinType - Optional; the type of coin to check the amount for.
|
|
606
|
+
* @param args.faMetadataAddress - Optional; the address of the fungible asset metadata.
|
|
607
|
+
* @returns The amount of the specified coin held by the account, or 0 if none is found.
|
|
608
|
+
* @throws Error if neither coinType nor faMetadataAddress is provided.
|
|
609
|
+
* @group Implementation
|
|
610
|
+
*/
|
|
611
|
+
export async function getAccountCoinAmount(args: {
|
|
612
|
+
movementConfig: MovementConfig;
|
|
613
|
+
accountAddress: AccountAddressInput;
|
|
614
|
+
coinType?: MoveStructId;
|
|
615
|
+
faMetadataAddress?: AccountAddressInput;
|
|
616
|
+
}): Promise<number> {
|
|
617
|
+
const { movementConfig, accountAddress, coinType, faMetadataAddress } = args;
|
|
618
|
+
|
|
619
|
+
let coinAssetType: string | undefined = coinType;
|
|
620
|
+
let faAddress: string;
|
|
621
|
+
|
|
622
|
+
if (coinType !== undefined && faMetadataAddress !== undefined) {
|
|
623
|
+
faAddress = AccountAddress.from(faMetadataAddress).toStringLong();
|
|
624
|
+
} else if (coinType !== undefined && faMetadataAddress === undefined) {
|
|
625
|
+
// TODO Move to a separate function as defined in the AIP for coin migration
|
|
626
|
+
if (coinType === MOVEMENT_COIN) {
|
|
627
|
+
faAddress = AccountAddress.A.toStringLong();
|
|
628
|
+
} else {
|
|
629
|
+
faAddress = createObjectAddress(AccountAddress.A, coinType).toStringLong();
|
|
630
|
+
}
|
|
631
|
+
} else if (coinType === undefined && faMetadataAddress !== undefined) {
|
|
632
|
+
const addr = AccountAddress.from(faMetadataAddress);
|
|
633
|
+
faAddress = addr.toStringLong();
|
|
634
|
+
if (addr === AccountAddress.A) {
|
|
635
|
+
coinAssetType = MOVEMENT_COIN;
|
|
636
|
+
}
|
|
637
|
+
// The paired CoinType should be populated outside of this function in another
|
|
638
|
+
// async call. We cannot do this internally due to dependency cycles issue.
|
|
639
|
+
} else {
|
|
640
|
+
throw new Error("Either coinType, fungibleAssetAddress, or both must be provided");
|
|
641
|
+
}
|
|
642
|
+
const address = AccountAddress.from(accountAddress).toStringLong();
|
|
643
|
+
|
|
644
|
+
// Search by fungible asset address, unless it has a coin it migrated from
|
|
645
|
+
let where: any = { asset_type: { _eq: faAddress } };
|
|
646
|
+
if (coinAssetType !== undefined) {
|
|
647
|
+
where = { asset_type: { _in: [coinAssetType, faAddress] } };
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
const data = await getAccountCoinsData({
|
|
651
|
+
movementConfig,
|
|
652
|
+
accountAddress: address,
|
|
653
|
+
options: {
|
|
654
|
+
where,
|
|
655
|
+
},
|
|
656
|
+
});
|
|
657
|
+
|
|
658
|
+
// commonjs (aka cjs) doesn't handle Nullish Coalescing for some reason
|
|
659
|
+
// might be because of how ts infer the graphql generated scheme type
|
|
660
|
+
return data[0] ? data[0].amount : 0;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Retrieves the current fungible asset balances for a specified account.
|
|
665
|
+
*
|
|
666
|
+
* @param args - The arguments for retrieving account coins data.
|
|
667
|
+
* @param args.movementConfig - The configuration for connecting to the Movement network.
|
|
668
|
+
* @param args.accountAddress - The address of the account for which to retrieve coin data.
|
|
669
|
+
* @param args.options - Optional parameters for pagination and filtering the results.
|
|
670
|
+
* @param args.options.offset - The number of items to skip before starting to collect the result set.
|
|
671
|
+
* @param args.options.limit - The maximum number of items to return.
|
|
672
|
+
* @param args.options.orderBy - The criteria for ordering the results.
|
|
673
|
+
* @param args.options.where - Conditions to filter the results based on the current fungible asset balances.
|
|
674
|
+
* @group Implementation
|
|
675
|
+
*/
|
|
676
|
+
export async function getAccountCoinsData(args: {
|
|
677
|
+
movementConfig: MovementConfig;
|
|
678
|
+
accountAddress: AccountAddressInput;
|
|
679
|
+
options?: PaginationArgs & OrderByArg<GetAccountCoinsDataResponse[0]> & WhereArg<CurrentFungibleAssetBalancesBoolExp>;
|
|
680
|
+
}): Promise<GetAccountCoinsDataResponse> {
|
|
681
|
+
const { movementConfig, accountAddress, options } = args;
|
|
682
|
+
const address = AccountAddress.from(accountAddress).toStringLong();
|
|
683
|
+
|
|
684
|
+
const whereCondition: { owner_address: { _eq: string } } = {
|
|
685
|
+
...options?.where,
|
|
686
|
+
owner_address: { _eq: address },
|
|
687
|
+
};
|
|
688
|
+
|
|
689
|
+
const graphqlQuery = {
|
|
690
|
+
query: GetAccountCoinsData,
|
|
691
|
+
variables: {
|
|
692
|
+
where_condition: whereCondition,
|
|
693
|
+
offset: options?.offset,
|
|
694
|
+
limit: options?.limit,
|
|
695
|
+
order_by: options?.orderBy,
|
|
696
|
+
},
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
const data = await queryIndexer<GetAccountCoinsDataQuery>({
|
|
700
|
+
movementConfig,
|
|
701
|
+
query: graphqlQuery,
|
|
702
|
+
originMethod: "getAccountCoinsData",
|
|
703
|
+
});
|
|
704
|
+
|
|
705
|
+
return data.current_fungible_asset_balances;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Retrieves the count of fungible asset coins held by a specified account.
|
|
710
|
+
*
|
|
711
|
+
* @param args - The arguments for the function.
|
|
712
|
+
* @param args.movementConfig - The configuration settings for the Movement network.
|
|
713
|
+
* @param args.accountAddress - The address of the account for which to retrieve the coin count.
|
|
714
|
+
* @throws Error if the count of account coins cannot be retrieved.
|
|
715
|
+
* @group Implementation
|
|
716
|
+
*/
|
|
717
|
+
export async function getAccountCoinsCount(args: {
|
|
718
|
+
movementConfig: MovementConfig;
|
|
719
|
+
accountAddress: AccountAddressInput;
|
|
720
|
+
}): Promise<number> {
|
|
721
|
+
const { movementConfig, accountAddress } = args;
|
|
722
|
+
const address = AccountAddress.from(accountAddress).toStringLong();
|
|
723
|
+
|
|
724
|
+
const graphqlQuery = {
|
|
725
|
+
query: GetAccountCoinsCount,
|
|
726
|
+
variables: { address },
|
|
727
|
+
};
|
|
728
|
+
|
|
729
|
+
const data = await queryIndexer<GetAccountCoinsCountQuery>({
|
|
730
|
+
movementConfig,
|
|
731
|
+
query: graphqlQuery,
|
|
732
|
+
originMethod: "getAccountCoinsCount",
|
|
733
|
+
});
|
|
734
|
+
|
|
735
|
+
if (!data.current_fungible_asset_balances_aggregate.aggregate) {
|
|
736
|
+
throw Error("Failed to get the count of account coins");
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
return data.current_fungible_asset_balances_aggregate.aggregate.count;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Retrieves an account's balance for the given asset via the fullnode REST API.
|
|
744
|
+
*
|
|
745
|
+
* - `asset` may be a coin type (Move struct ID, e.g. `0x1::aptos_coin::AptosCoin`) or an FA metadata address.
|
|
746
|
+
* - Calls: `GET /accounts/{accountAddress}/balance/{asset}` and returns the numeric balance.
|
|
747
|
+
*
|
|
748
|
+
* @param args - The parameters for the request.
|
|
749
|
+
* @param args.movementConfig - The Movement configuration object.
|
|
750
|
+
* @param args.accountAddress - The account address to query.
|
|
751
|
+
* @param args.asset - The asset identifier (coin type or FA metadata address).
|
|
752
|
+
* @returns The balance as a number.
|
|
753
|
+
* @group Implementation
|
|
754
|
+
*/
|
|
755
|
+
export async function getBalance(args: {
|
|
756
|
+
movementConfig: MovementConfig;
|
|
757
|
+
accountAddress: AccountAddressInput;
|
|
758
|
+
asset: MoveStructId | AccountAddressInput;
|
|
759
|
+
}): Promise<number> {
|
|
760
|
+
const { movementConfig, accountAddress, asset } = args;
|
|
761
|
+
|
|
762
|
+
const response = await getAptosFullNode<{}, number>({
|
|
763
|
+
movementConfig,
|
|
764
|
+
originMethod: "getBalance",
|
|
765
|
+
path: `accounts/${accountAddress}/balance/${asset}`,
|
|
766
|
+
params: {
|
|
767
|
+
accountAddress: accountAddress.toString(),
|
|
768
|
+
asset: asset instanceof Uint8Array ? AccountAddress.from(asset).toString() : asset.toString(),
|
|
769
|
+
},
|
|
770
|
+
});
|
|
771
|
+
|
|
772
|
+
return parseInt(response.data.toString(), 10);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Retrieves the objects owned by a specified account.
|
|
777
|
+
*
|
|
778
|
+
* @param args - The parameters for the request.
|
|
779
|
+
* @param args.movementConfig - The configuration for the Movement client.
|
|
780
|
+
* @param args.accountAddress - The address of the account whose owned objects are to be retrieved.
|
|
781
|
+
* @param args.options - Optional parameters for pagination and ordering of the results.
|
|
782
|
+
* @param args.options.offset - The number of items to skip before starting to collect the result set.
|
|
783
|
+
* @param args.options.limit - The maximum number of items to return.
|
|
784
|
+
* @param args.options.orderBy - The criteria to order the results by.
|
|
785
|
+
* @returns A promise that resolves to the current objects owned by the specified account.
|
|
786
|
+
* @group Implementation
|
|
787
|
+
*/
|
|
788
|
+
export async function getAccountOwnedObjects(args: {
|
|
789
|
+
movementConfig: MovementConfig;
|
|
790
|
+
accountAddress: AccountAddressInput;
|
|
791
|
+
options?: PaginationArgs & OrderByArg<GetObjectDataQueryResponse[0]>;
|
|
792
|
+
}): Promise<GetObjectDataQueryResponse> {
|
|
793
|
+
const { movementConfig, accountAddress, options } = args;
|
|
794
|
+
const address = AccountAddress.from(accountAddress).toStringLong();
|
|
795
|
+
|
|
796
|
+
const whereCondition: { owner_address: { _eq: string } } = {
|
|
797
|
+
owner_address: { _eq: address },
|
|
798
|
+
};
|
|
799
|
+
const graphqlQuery = {
|
|
800
|
+
query: GetObjectData,
|
|
801
|
+
variables: {
|
|
802
|
+
where_condition: whereCondition,
|
|
803
|
+
offset: options?.offset,
|
|
804
|
+
limit: options?.limit,
|
|
805
|
+
order_by: options?.orderBy,
|
|
806
|
+
},
|
|
807
|
+
};
|
|
808
|
+
const data = await queryIndexer<GetObjectDataQuery>({
|
|
809
|
+
movementConfig,
|
|
810
|
+
query: graphqlQuery,
|
|
811
|
+
originMethod: "getAccountOwnedObjects",
|
|
812
|
+
});
|
|
813
|
+
|
|
814
|
+
return data.current_objects;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* Derives an account from the provided private key and Movement configuration.
|
|
819
|
+
*
|
|
820
|
+
* This function queries all owned accounts for the provided private key and returns the most
|
|
821
|
+
* recently used account. If no account is found, it will throw an error unless `throwIfNoAccountFound` is set to false.
|
|
822
|
+
*
|
|
823
|
+
* If `throwIfNoAccountFound` is set to false, the function will return the default account for the private key via `Account.fromPrivateKey`.
|
|
824
|
+
*
|
|
825
|
+
* NOTE: There is a potential issue once the unified single signer scheme is adopted by the community.
|
|
826
|
+
* Because one could create two accounts with the same private key with this new authenticator type,
|
|
827
|
+
* we'll need to determine the order in which we look up the accounts: first unified scheme and then legacy scheme,
|
|
828
|
+
* or first legacy scheme and then unified scheme.
|
|
829
|
+
*
|
|
830
|
+
* @param args - The arguments for deriving the account.
|
|
831
|
+
* @param args.movementConfig - The Movement configuration used for account lookup.
|
|
832
|
+
* @param args.privateKey - The private key used to derive the account.
|
|
833
|
+
* @param args.options.throwIfNoAccountFound - If true, throw an error if no existing account is found on chain. Default is false.
|
|
834
|
+
* @throws Error if the account cannot be derived from the private key.
|
|
835
|
+
* @group Implementation
|
|
836
|
+
* @deprecated Note that more inspection is needed by the user to determine which account exists on-chain
|
|
837
|
+
*/
|
|
838
|
+
export async function deriveAccountFromPrivateKey(args: {
|
|
839
|
+
movementConfig: MovementConfig;
|
|
840
|
+
privateKey: PrivateKeyInput;
|
|
841
|
+
options?: {
|
|
842
|
+
throwIfNoAccountFound?: boolean;
|
|
843
|
+
};
|
|
844
|
+
}): Promise<Account> {
|
|
845
|
+
const { movementConfig, privateKey, options } = args;
|
|
846
|
+
const throwIfNoAccountFound = options?.throwIfNoAccountFound ?? false;
|
|
847
|
+
|
|
848
|
+
const accounts = await deriveOwnedAccountsFromPrivateKey({ movementConfig, privateKey });
|
|
849
|
+
if (accounts.length === 0) {
|
|
850
|
+
if (throwIfNoAccountFound) {
|
|
851
|
+
throw new Error(`No existing account found for private key.`);
|
|
852
|
+
}
|
|
853
|
+
// If no account is found, return the default account. This is a legacy account for Ed25519 private keys.
|
|
854
|
+
return Account.fromPrivateKey({ privateKey });
|
|
855
|
+
}
|
|
856
|
+
return accounts[0];
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* Checks if an account exists by verifying its information against the Movement blockchain.
|
|
861
|
+
*
|
|
862
|
+
* @param args - The arguments for the function.
|
|
863
|
+
* @param args.movementConfig - The configuration for connecting to the Movement blockchain.
|
|
864
|
+
* @param args.authKey - The authentication key used to derive the account address.
|
|
865
|
+
* @returns A promise that resolves to a boolean indicating whether the account exists.
|
|
866
|
+
*
|
|
867
|
+
* @throws Throws an Error if there is an issue while looking for account information.
|
|
868
|
+
* @group Implementation
|
|
869
|
+
*/
|
|
870
|
+
export async function isAccountExist(args: { movementConfig: MovementConfig; authKey: AuthenticationKey }): Promise<boolean> {
|
|
871
|
+
const { movementConfig, authKey } = args;
|
|
872
|
+
const accountAddress = await lookupOriginalAccountAddress({
|
|
873
|
+
movementConfig,
|
|
874
|
+
authenticationKey: authKey.derivedAddress(),
|
|
875
|
+
});
|
|
876
|
+
|
|
877
|
+
return doesAccountExistAtAddress({ movementConfig, accountAddress });
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
/**
|
|
881
|
+
* Checks if an account exists at a given address.
|
|
882
|
+
*
|
|
883
|
+
* @param args - The arguments for checking account existence.
|
|
884
|
+
* @param args.movementConfig - The configuration for the Movement client.
|
|
885
|
+
* @param args.accountAddress - The address of the account to check.
|
|
886
|
+
* @param args.options.withAuthKey - An optional authentication key which will also be checked against if provided.
|
|
887
|
+
* @returns A promise that resolves to a boolean indicating whether the account exists.
|
|
888
|
+
* @group Implementation
|
|
889
|
+
*/
|
|
890
|
+
async function doesAccountExistAtAddress(args: {
|
|
891
|
+
movementConfig: MovementConfig;
|
|
892
|
+
accountAddress: AccountAddress;
|
|
893
|
+
options?: { withAuthKey?: AuthenticationKey };
|
|
894
|
+
}): Promise<boolean> {
|
|
895
|
+
const { movementConfig, accountAddress, options } = args;
|
|
896
|
+
try {
|
|
897
|
+
// Get the account resources and the balance of the account. We need to check both because
|
|
898
|
+
// an account resource can exist with 0 balance and a balance can exist without an account resource (light accounts).
|
|
899
|
+
const [resources, ownedObjects] = await Promise.all([
|
|
900
|
+
getResources({
|
|
901
|
+
movementConfig,
|
|
902
|
+
accountAddress,
|
|
903
|
+
}),
|
|
904
|
+
getAccountOwnedObjects({
|
|
905
|
+
movementConfig,
|
|
906
|
+
accountAddress,
|
|
907
|
+
options: {
|
|
908
|
+
limit: 1,
|
|
909
|
+
},
|
|
910
|
+
}),
|
|
911
|
+
]);
|
|
912
|
+
|
|
913
|
+
const accountResource: MoveResource<{ authentication_key: string }> | undefined = resources.find(
|
|
914
|
+
(r) => r.type === "0x1::account::Account",
|
|
915
|
+
) as MoveResource<{ authentication_key: string }> | undefined;
|
|
916
|
+
|
|
917
|
+
// If the account resource is not found and the balance is 0, then the account does not exist.
|
|
918
|
+
if (!accountResource && ownedObjects.length === 0) {
|
|
919
|
+
return false;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
// If no auth key is provided as an argument, return true.
|
|
923
|
+
if (!options?.withAuthKey) {
|
|
924
|
+
return true;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
// Get the auth key from the account resource if it exists. If the account resource does not exist,
|
|
928
|
+
// then the auth key is the account address by default.
|
|
929
|
+
let authKey;
|
|
930
|
+
if (accountResource) {
|
|
931
|
+
authKey = accountResource.data.authentication_key;
|
|
932
|
+
} else {
|
|
933
|
+
authKey = accountAddress.toStringLong();
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
if (authKey !== options.withAuthKey.toString()) {
|
|
937
|
+
return false;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
// Else the account exists and the auth key matches.
|
|
941
|
+
return true;
|
|
942
|
+
} catch (error: any) {
|
|
943
|
+
throw new Error(`Error while checking if account exists at ${accountAddress.toString()}: ${error}`);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
const rotateAuthKeyAbi: EntryFunctionABI = {
|
|
948
|
+
typeParameters: [],
|
|
949
|
+
parameters: [
|
|
950
|
+
new TypeTagU8(),
|
|
951
|
+
TypeTagVector.u8(),
|
|
952
|
+
new TypeTagU8(),
|
|
953
|
+
TypeTagVector.u8(),
|
|
954
|
+
TypeTagVector.u8(),
|
|
955
|
+
TypeTagVector.u8(),
|
|
956
|
+
],
|
|
957
|
+
};
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* Rotates the authentication key for a given account.
|
|
961
|
+
*
|
|
962
|
+
* @param args - The arguments for rotating the authentication key.
|
|
963
|
+
* @param args.movementConfig - The configuration settings for the Movement network.
|
|
964
|
+
* @param args.fromAccount - The account from which the authentication key will be rotated.
|
|
965
|
+
* @param args.toAccount - (Optional) The target account to rotate to. Required if not using toNewPrivateKey.
|
|
966
|
+
* @param args.toNewPrivateKey - (Optional) The new private key to rotate to. Required if not using toAccount.
|
|
967
|
+
*
|
|
968
|
+
* @remarks
|
|
969
|
+
* This function supports three modes of rotation:
|
|
970
|
+
* 1. Using a target Account object (toAccount)
|
|
971
|
+
* 2. Using a new private key (toNewPrivateKey)
|
|
972
|
+
*
|
|
973
|
+
* @returns A simple transaction object that can be submitted to the network.
|
|
974
|
+
* @throws Error if the rotation fails or verification fails.
|
|
975
|
+
*
|
|
976
|
+
* @group Implementation
|
|
977
|
+
*/
|
|
978
|
+
export async function rotateAuthKey(
|
|
979
|
+
args: {
|
|
980
|
+
movementConfig: MovementConfig;
|
|
981
|
+
fromAccount: Account;
|
|
982
|
+
options?: InputGenerateTransactionOptions;
|
|
983
|
+
} & ({ toAccount: Ed25519Account | MultiEd25519Account } | { toNewPrivateKey: Ed25519PrivateKey }),
|
|
984
|
+
): Promise<SimpleTransaction> {
|
|
985
|
+
const { movementConfig, fromAccount, options } = args;
|
|
986
|
+
if ("toNewPrivateKey" in args) {
|
|
987
|
+
return rotateAuthKeyWithChallenge({
|
|
988
|
+
movementConfig,
|
|
989
|
+
fromAccount,
|
|
990
|
+
toNewPrivateKey: args.toNewPrivateKey,
|
|
991
|
+
options,
|
|
992
|
+
});
|
|
993
|
+
} else if ("toAccount" in args) {
|
|
994
|
+
if (args.toAccount instanceof Ed25519Account) {
|
|
995
|
+
return rotateAuthKeyWithChallenge({
|
|
996
|
+
movementConfig,
|
|
997
|
+
fromAccount,
|
|
998
|
+
toNewPrivateKey: args.toAccount.privateKey,
|
|
999
|
+
options,
|
|
1000
|
+
});
|
|
1001
|
+
} else {
|
|
1002
|
+
return rotateAuthKeyWithChallenge({ movementConfig, fromAccount, toAccount: args.toAccount, options });
|
|
1003
|
+
}
|
|
1004
|
+
} else {
|
|
1005
|
+
throw new Error("Invalid arguments");
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
async function rotateAuthKeyWithChallenge(
|
|
1010
|
+
args: {
|
|
1011
|
+
movementConfig: MovementConfig;
|
|
1012
|
+
fromAccount: Account;
|
|
1013
|
+
options?: InputGenerateTransactionOptions;
|
|
1014
|
+
} & ({ toNewPrivateKey: Ed25519PrivateKey } | { toAccount: MultiEd25519Account }),
|
|
1015
|
+
): Promise<SimpleTransaction> {
|
|
1016
|
+
const { movementConfig, fromAccount, options } = args;
|
|
1017
|
+
const accountInfo = await getInfo({
|
|
1018
|
+
movementConfig,
|
|
1019
|
+
accountAddress: fromAccount.accountAddress,
|
|
1020
|
+
});
|
|
1021
|
+
|
|
1022
|
+
let newAccount: Account;
|
|
1023
|
+
if ("toNewPrivateKey" in args) {
|
|
1024
|
+
newAccount = Account.fromPrivateKey({ privateKey: args.toNewPrivateKey, legacy: true });
|
|
1025
|
+
} else {
|
|
1026
|
+
newAccount = args.toAccount;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
const challenge = new RotationProofChallenge({
|
|
1030
|
+
sequenceNumber: BigInt(accountInfo.sequence_number),
|
|
1031
|
+
originator: fromAccount.accountAddress,
|
|
1032
|
+
currentAuthKey: AccountAddress.from(accountInfo.authentication_key),
|
|
1033
|
+
newPublicKey: newAccount.publicKey,
|
|
1034
|
+
});
|
|
1035
|
+
|
|
1036
|
+
// Sign the challenge
|
|
1037
|
+
const challengeHex = challenge.bcsToBytes();
|
|
1038
|
+
const proofSignedByCurrentKey = fromAccount.sign(challengeHex);
|
|
1039
|
+
const proofSignedByNewKey = newAccount.sign(challengeHex);
|
|
1040
|
+
|
|
1041
|
+
// Generate transaction
|
|
1042
|
+
return generateTransaction({
|
|
1043
|
+
movementConfig,
|
|
1044
|
+
sender: fromAccount.accountAddress,
|
|
1045
|
+
data: {
|
|
1046
|
+
function: "0x1::account::rotate_authentication_key",
|
|
1047
|
+
functionArguments: [
|
|
1048
|
+
new U8(fromAccount.signingScheme), // from scheme
|
|
1049
|
+
MoveVector.U8(fromAccount.publicKey.toUint8Array()),
|
|
1050
|
+
new U8(newAccount.signingScheme), // to scheme
|
|
1051
|
+
MoveVector.U8(newAccount.publicKey.toUint8Array()),
|
|
1052
|
+
MoveVector.U8(proofSignedByCurrentKey.toUint8Array()),
|
|
1053
|
+
MoveVector.U8(proofSignedByNewKey.toUint8Array()),
|
|
1054
|
+
],
|
|
1055
|
+
abi: rotateAuthKeyAbi,
|
|
1056
|
+
},
|
|
1057
|
+
options,
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
const rotateAuthKeyUnverifiedAbi: EntryFunctionABI = {
|
|
1062
|
+
typeParameters: [],
|
|
1063
|
+
parameters: [new TypeTagU8(), TypeTagVector.u8()],
|
|
1064
|
+
};
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* Rotates the authentication key for a given account without verifying the new key.
|
|
1068
|
+
*
|
|
1069
|
+
* @param args - The arguments for rotating the authentication key.
|
|
1070
|
+
* @param args.movementConfig - The configuration settings for the Movement network.
|
|
1071
|
+
* @param args.fromAccount - The account from which the authentication key will be rotated.
|
|
1072
|
+
* @param args.toNewPublicKey - The new public key to rotate to.
|
|
1073
|
+
* @returns A simple transaction object that can be submitted to the network.
|
|
1074
|
+
* @throws Error if the rotation fails or verification fails.
|
|
1075
|
+
*
|
|
1076
|
+
* @group Implementation
|
|
1077
|
+
*/
|
|
1078
|
+
export async function rotateAuthKeyUnverified(args: {
|
|
1079
|
+
movementConfig: MovementConfig;
|
|
1080
|
+
fromAccount: Account;
|
|
1081
|
+
toNewPublicKey: AccountPublicKey;
|
|
1082
|
+
options?: InputGenerateTransactionOptions;
|
|
1083
|
+
}): Promise<SimpleTransaction> {
|
|
1084
|
+
const { movementConfig, fromAccount, toNewPublicKey, options } = args;
|
|
1085
|
+
|
|
1086
|
+
return generateTransaction({
|
|
1087
|
+
movementConfig,
|
|
1088
|
+
sender: fromAccount.accountAddress,
|
|
1089
|
+
data: {
|
|
1090
|
+
function: "0x1::account::rotate_authentication_key_from_public_key",
|
|
1091
|
+
functionArguments: [
|
|
1092
|
+
new U8(accountPublicKeyToSigningScheme(toNewPublicKey)), // to scheme
|
|
1093
|
+
MoveVector.U8(accountPublicKeyToBaseAccountPublicKey(toNewPublicKey).toUint8Array()),
|
|
1094
|
+
],
|
|
1095
|
+
abi: rotateAuthKeyUnverifiedAbi,
|
|
1096
|
+
},
|
|
1097
|
+
options,
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
export type AccountInfo = {
|
|
1102
|
+
accountAddress: AccountAddress;
|
|
1103
|
+
publicKey: BaseAccountPublicKey;
|
|
1104
|
+
lastTransactionVersion: number;
|
|
1105
|
+
};
|
|
1106
|
+
|
|
1107
|
+
export async function getAccountsForPublicKey(args: {
|
|
1108
|
+
movementConfig: MovementConfig;
|
|
1109
|
+
publicKey: BaseAccountPublicKey;
|
|
1110
|
+
options?: { includeUnverified?: boolean; noMultiKey?: boolean };
|
|
1111
|
+
}): Promise<AccountInfo[]> {
|
|
1112
|
+
const { movementConfig, publicKey, options } = args;
|
|
1113
|
+
const noMultiKey = options?.noMultiKey ?? false;
|
|
1114
|
+
if (noMultiKey && publicKey instanceof AbstractMultiKey) {
|
|
1115
|
+
throw new Error("Multi-key accounts are not supported when noMultiKey is true.");
|
|
1116
|
+
}
|
|
1117
|
+
const allPublicKeys: BaseAccountPublicKey[] = [publicKey];
|
|
1118
|
+
|
|
1119
|
+
// For Ed25519, we add the both the legacy Ed25519PublicKey and the new AnyPublicKey form.
|
|
1120
|
+
if (publicKey instanceof AnyPublicKey && publicKey.publicKey instanceof Ed25519PublicKey) {
|
|
1121
|
+
allPublicKeys.push(publicKey.publicKey);
|
|
1122
|
+
} else if (publicKey instanceof Ed25519PublicKey) {
|
|
1123
|
+
allPublicKeys.push(new AnyPublicKey(publicKey));
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
// Run both operations in parallel
|
|
1127
|
+
const [defaultAccountData, multiPublicKeys] = await Promise.all([
|
|
1128
|
+
// Check the provided public key for the default account. In the case of Ed25519, this will check both the legacy Ed25519PublicKey
|
|
1129
|
+
// and the AnyPublicKey form and may an existing account for each.
|
|
1130
|
+
Promise.all(
|
|
1131
|
+
allPublicKeys.map(async (publicKey) => {
|
|
1132
|
+
const addressAndLastTxnVersion = await getDefaultAccountInfoForPublicKey({ movementConfig, publicKey });
|
|
1133
|
+
if (addressAndLastTxnVersion) {
|
|
1134
|
+
return { ...addressAndLastTxnVersion, publicKey };
|
|
1135
|
+
}
|
|
1136
|
+
return undefined;
|
|
1137
|
+
}),
|
|
1138
|
+
),
|
|
1139
|
+
// Get multi-keys for the provided public key if not already a multi-key.
|
|
1140
|
+
!(publicKey instanceof AbstractMultiKey) && !noMultiKey
|
|
1141
|
+
? getMultiKeysForPublicKey({ movementConfig, publicKey, options })
|
|
1142
|
+
: Promise.resolve([]),
|
|
1143
|
+
]);
|
|
1144
|
+
|
|
1145
|
+
const result: {
|
|
1146
|
+
accountAddress: AccountAddress;
|
|
1147
|
+
publicKey: BaseAccountPublicKey;
|
|
1148
|
+
lastTransactionVersion: number;
|
|
1149
|
+
}[] = [];
|
|
1150
|
+
|
|
1151
|
+
// Add any default accounts that exist to the result.
|
|
1152
|
+
for (const data of defaultAccountData) {
|
|
1153
|
+
if (data) {
|
|
1154
|
+
result.push(data);
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
// Add any multi-keys to allPublicKeys
|
|
1159
|
+
allPublicKeys.push(...multiPublicKeys);
|
|
1160
|
+
|
|
1161
|
+
// Get a map of the auth key to the public key for all public keys.
|
|
1162
|
+
const authKeyToPublicKey = new Map(allPublicKeys.map((key) => [key.authKey().toString(), key]));
|
|
1163
|
+
|
|
1164
|
+
// Get the account addresses for the auth keys.
|
|
1165
|
+
const authKeyAccountAddressPairs = await getAccountAddressesForAuthKeys({
|
|
1166
|
+
movementConfig,
|
|
1167
|
+
authKeys: allPublicKeys.map((key) => key.authKey()),
|
|
1168
|
+
options,
|
|
1169
|
+
});
|
|
1170
|
+
|
|
1171
|
+
for (const authKeyAccountAddressPair of authKeyAccountAddressPairs) {
|
|
1172
|
+
// Skip if the account address is already in the result.
|
|
1173
|
+
// This can happen in the rare edge case where the default account has been rotated but has been rotated back to the original auth key.
|
|
1174
|
+
if (result.find((r) => r.accountAddress === authKeyAccountAddressPair.accountAddress)) {
|
|
1175
|
+
continue;
|
|
1176
|
+
}
|
|
1177
|
+
// Get the public key for the auth key using the map we created earlier.
|
|
1178
|
+
const publicKey = authKeyToPublicKey.get(authKeyAccountAddressPair.authKey.toString());
|
|
1179
|
+
if (!publicKey) {
|
|
1180
|
+
throw new Error(
|
|
1181
|
+
`No publicKey found for authentication key ${authKeyAccountAddressPair.authKey}. This should never happen.`,
|
|
1182
|
+
);
|
|
1183
|
+
}
|
|
1184
|
+
result.push({
|
|
1185
|
+
accountAddress: authKeyAccountAddressPair.accountAddress,
|
|
1186
|
+
publicKey,
|
|
1187
|
+
lastTransactionVersion: authKeyAccountAddressPair.lastTransactionVersion,
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
// Sort the result by the last transaction version in descending order (most recent first).
|
|
1191
|
+
return result.sort((a, b) => b.lastTransactionVersion - a.lastTransactionVersion);
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
export async function deriveOwnedAccountsFromSigner(args: {
|
|
1195
|
+
movementConfig: MovementConfig;
|
|
1196
|
+
signer: Account | PrivateKeyInput;
|
|
1197
|
+
options?: { includeUnverified?: boolean; noMultiKey?: boolean };
|
|
1198
|
+
}): Promise<Account[]> {
|
|
1199
|
+
const { movementConfig, signer, options } = args;
|
|
1200
|
+
|
|
1201
|
+
if (signer instanceof Ed25519PrivateKey || signer instanceof Secp256k1PrivateKey) {
|
|
1202
|
+
return deriveOwnedAccountsFromPrivateKey({ movementConfig, privateKey: signer, options });
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
if (signer instanceof Ed25519Account || signer instanceof SingleKeyAccount) {
|
|
1206
|
+
return deriveOwnedAccountsFromPrivateKey({ movementConfig, privateKey: signer.privateKey, options });
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
if (signer instanceof KeylessAccount || signer instanceof FederatedKeylessAccount) {
|
|
1210
|
+
return deriveOwnedAccountsFromKeylessSigner({ movementConfig, keylessAccount: signer, options });
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
if (signer instanceof MultiKeyAccount) {
|
|
1214
|
+
if (signer.signers.length === 1) {
|
|
1215
|
+
return deriveOwnedAccountsFromSigner({ movementConfig, signer: signer.signers[0], options });
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
if (signer instanceof MultiEd25519Account) {
|
|
1220
|
+
if (signer.signers.length === 1) {
|
|
1221
|
+
return deriveOwnedAccountsFromPrivateKey({ movementConfig, privateKey: signer.signers[0], options });
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
throw new Error("Unknown signer type");
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
async function deriveOwnedAccountsFromKeylessSigner(args: {
|
|
1229
|
+
movementConfig: MovementConfig;
|
|
1230
|
+
keylessAccount: KeylessAccount | FederatedKeylessAccount;
|
|
1231
|
+
options?: { includeUnverified?: boolean; noMultiKey?: boolean };
|
|
1232
|
+
}): Promise<Account[]> {
|
|
1233
|
+
const { movementConfig, keylessAccount, options } = args;
|
|
1234
|
+
const addressesAndPublicKeys = await getAccountsForPublicKey({
|
|
1235
|
+
movementConfig,
|
|
1236
|
+
publicKey: keylessAccount.getAnyPublicKey(),
|
|
1237
|
+
options,
|
|
1238
|
+
});
|
|
1239
|
+
|
|
1240
|
+
const keylessAccountParams = {
|
|
1241
|
+
proof: keylessAccount.proofOrPromise,
|
|
1242
|
+
jwt: keylessAccount.jwt,
|
|
1243
|
+
ephemeralKeyPair: keylessAccount.ephemeralKeyPair,
|
|
1244
|
+
pepper: keylessAccount.pepper,
|
|
1245
|
+
verificationKeyHash: keylessAccount.verificationKeyHash,
|
|
1246
|
+
};
|
|
1247
|
+
|
|
1248
|
+
const accounts: Account[] = [];
|
|
1249
|
+
for (const { accountAddress, publicKey } of addressesAndPublicKeys) {
|
|
1250
|
+
if (publicKey instanceof AbstractMultiKey) {
|
|
1251
|
+
if (publicKey.getSignaturesRequired() > 1) {
|
|
1252
|
+
continue;
|
|
1253
|
+
}
|
|
1254
|
+
if (publicKey instanceof MultiEd25519PublicKey) {
|
|
1255
|
+
throw new Error("Keyless authentication cannot be used for multi-ed25519 accounts. This should never happen.");
|
|
1256
|
+
} else if (publicKey instanceof MultiKey) {
|
|
1257
|
+
accounts.push(new MultiKeyAccount({ multiKey: publicKey, signers: [keylessAccount], address: accountAddress }));
|
|
1258
|
+
}
|
|
1259
|
+
} else {
|
|
1260
|
+
if (keylessAccount instanceof FederatedKeylessAccount) {
|
|
1261
|
+
accounts.push(
|
|
1262
|
+
FederatedKeylessAccount.create({
|
|
1263
|
+
...keylessAccountParams,
|
|
1264
|
+
address: accountAddress,
|
|
1265
|
+
jwkAddress: keylessAccount.publicKey.jwkAddress,
|
|
1266
|
+
}),
|
|
1267
|
+
);
|
|
1268
|
+
} else {
|
|
1269
|
+
accounts.push(
|
|
1270
|
+
KeylessAccount.create({
|
|
1271
|
+
...keylessAccountParams,
|
|
1272
|
+
address: accountAddress,
|
|
1273
|
+
}),
|
|
1274
|
+
);
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
return accounts;
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
async function deriveOwnedAccountsFromPrivateKey(args: {
|
|
1282
|
+
movementConfig: MovementConfig;
|
|
1283
|
+
privateKey: Ed25519PrivateKey | Secp256k1PrivateKey;
|
|
1284
|
+
options?: { includeUnverified?: boolean; noMultiKey?: boolean };
|
|
1285
|
+
}): Promise<Account[]> {
|
|
1286
|
+
const { movementConfig, privateKey, options } = args;
|
|
1287
|
+
const singleKeyAccount = Account.fromPrivateKey({ privateKey, legacy: false });
|
|
1288
|
+
const addressesAndPublicKeys = await getAccountsForPublicKey({
|
|
1289
|
+
movementConfig,
|
|
1290
|
+
publicKey: new AnyPublicKey(privateKey.publicKey()),
|
|
1291
|
+
options,
|
|
1292
|
+
});
|
|
1293
|
+
|
|
1294
|
+
const accounts: Account[] = [];
|
|
1295
|
+
|
|
1296
|
+
// Iterate through the addressesAndPublicKeys and construct the accounts.
|
|
1297
|
+
for (const { accountAddress, publicKey } of addressesAndPublicKeys) {
|
|
1298
|
+
if (publicKey instanceof AbstractMultiKey) {
|
|
1299
|
+
// Skip multi-key accounts with more than 1 signature required as the user does not have full ownership with just 1 private key.
|
|
1300
|
+
if (publicKey.getSignaturesRequired() > 1) {
|
|
1301
|
+
continue;
|
|
1302
|
+
}
|
|
1303
|
+
// Construct the appropriate multi-key type.
|
|
1304
|
+
if (publicKey instanceof MultiEd25519PublicKey) {
|
|
1305
|
+
accounts.push(
|
|
1306
|
+
new MultiEd25519Account({ publicKey, signers: [privateKey as Ed25519PrivateKey], address: accountAddress }),
|
|
1307
|
+
);
|
|
1308
|
+
} else if (publicKey instanceof MultiKey) {
|
|
1309
|
+
accounts.push(
|
|
1310
|
+
new MultiKeyAccount({ multiKey: publicKey, signers: [singleKeyAccount], address: accountAddress }),
|
|
1311
|
+
);
|
|
1312
|
+
}
|
|
1313
|
+
} else {
|
|
1314
|
+
// Check if the public key is a legacy Ed25519PublicKey, if so, we need to use the legacy account constructor.
|
|
1315
|
+
const isLegacy = publicKey instanceof Ed25519PublicKey;
|
|
1316
|
+
accounts.push(Account.fromPrivateKey({ privateKey, address: accountAddress, legacy: isLegacy }));
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
return accounts;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
/**
|
|
1323
|
+
* Gets the multi-keys for a given public key.
|
|
1324
|
+
*
|
|
1325
|
+
* This function retrieves the multi-keys that contain the provided public key.
|
|
1326
|
+
* It performs the following steps:
|
|
1327
|
+
* 1. Constructs a where condition for the public key where the public key matches the provided public key.
|
|
1328
|
+
* 2. Queries the indexer for the multi-keys.
|
|
1329
|
+
* 3. Returns the multi-keys.
|
|
1330
|
+
*
|
|
1331
|
+
* @param args.movementConfig - The configuration settings for the Movement network.
|
|
1332
|
+
* @param args.publicKey - The public key to get the multi-keys for. This public key cannot itself be a multi-key.
|
|
1333
|
+
* @returns The multi-keys (MultiKey or MultiEd25519PublicKey) that contain the given public key.
|
|
1334
|
+
*/
|
|
1335
|
+
async function getMultiKeysForPublicKey(args: {
|
|
1336
|
+
movementConfig: MovementConfig;
|
|
1337
|
+
publicKey: Ed25519PublicKey | AnyPublicKey;
|
|
1338
|
+
options?: { includeUnverified?: boolean };
|
|
1339
|
+
}): Promise<(MultiKey | MultiEd25519PublicKey)[]> {
|
|
1340
|
+
const { movementConfig, publicKey, options } = args;
|
|
1341
|
+
if (publicKey instanceof AbstractMultiKey) {
|
|
1342
|
+
throw new Error("Public key is a multi-key.");
|
|
1343
|
+
}
|
|
1344
|
+
const includeUnverified = options?.includeUnverified ?? false;
|
|
1345
|
+
const anyPublicKey = publicKey instanceof AnyPublicKey ? publicKey : new AnyPublicKey(publicKey);
|
|
1346
|
+
const baseKey = anyPublicKey.publicKey;
|
|
1347
|
+
const variant = anyPublicKeyVariantToString(anyPublicKey.variant);
|
|
1348
|
+
|
|
1349
|
+
const whereCondition: any = {
|
|
1350
|
+
public_key: { _eq: baseKey.toString() },
|
|
1351
|
+
public_key_type: { _eq: variant },
|
|
1352
|
+
...(includeUnverified ? {} : { is_public_key_used: { _eq: true } }),
|
|
1353
|
+
};
|
|
1354
|
+
|
|
1355
|
+
const graphqlQuery = {
|
|
1356
|
+
query: GetAuthKeysForPublicKey,
|
|
1357
|
+
variables: {
|
|
1358
|
+
where_condition: whereCondition,
|
|
1359
|
+
},
|
|
1360
|
+
};
|
|
1361
|
+
|
|
1362
|
+
const { public_key_auth_keys: data } = await queryIndexer<GetAuthKeysForPublicKeyQuery>({
|
|
1363
|
+
movementConfig,
|
|
1364
|
+
query: graphqlQuery,
|
|
1365
|
+
originMethod: "getMultiKeysForPublicKey",
|
|
1366
|
+
});
|
|
1367
|
+
|
|
1368
|
+
const authKeys = data.map((entry) => {
|
|
1369
|
+
switch (entry.signature_type) {
|
|
1370
|
+
case "multi_ed25519_signature":
|
|
1371
|
+
return MultiEd25519PublicKey.deserializeWithoutLength(Deserializer.fromHex(entry.account_public_key!));
|
|
1372
|
+
case "multi_key_signature":
|
|
1373
|
+
return MultiKey.deserialize(Deserializer.fromHex(entry.account_public_key!));
|
|
1374
|
+
default:
|
|
1375
|
+
throw new Error(`Unknown multi-signature type: ${entry.signature_type}`);
|
|
1376
|
+
}
|
|
1377
|
+
});
|
|
1378
|
+
return authKeys;
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
/**
|
|
1382
|
+
* Gets the account addresses for the given authentication keys.
|
|
1383
|
+
*
|
|
1384
|
+
* This function retrieves the account addresses that are associated with the provided authentication keys.
|
|
1385
|
+
* It performs the following steps:
|
|
1386
|
+
* 1. Constructs a where condition for the authentication keys where auth key matches any of the provided auth keys.
|
|
1387
|
+
* 2. Queries the indexer for the account addresses and gets the results ordered by the last transaction version (most recent first).
|
|
1388
|
+
* 3. Returns the account addresses.
|
|
1389
|
+
*
|
|
1390
|
+
* @param args.movementConfig - The configuration settings for the Movement network.
|
|
1391
|
+
* @param args.authKeys - The authentication keys to get the account addresses for.
|
|
1392
|
+
* @param args.options.includeUnverified - Whether to include unverified accounts in the results. Unverified accounts
|
|
1393
|
+
* are accounts that can be authenticated with the signer, but there is no history of the signer using the account.
|
|
1394
|
+
* Default is false.
|
|
1395
|
+
* @returns The account addresses associated with the given authentication keys.
|
|
1396
|
+
*/
|
|
1397
|
+
async function getAccountAddressesForAuthKeys(args: {
|
|
1398
|
+
movementConfig: MovementConfig;
|
|
1399
|
+
authKeys: AuthenticationKey[];
|
|
1400
|
+
options?: { includeUnverified?: boolean };
|
|
1401
|
+
}): Promise<{ authKey: AuthenticationKey; accountAddress: AccountAddress; lastTransactionVersion: number }[]> {
|
|
1402
|
+
const { movementConfig, authKeys, options } = args;
|
|
1403
|
+
const includeUnverified = options?.includeUnverified ?? false;
|
|
1404
|
+
if (authKeys.length === 0) {
|
|
1405
|
+
throw new Error("No authentication keys provided");
|
|
1406
|
+
}
|
|
1407
|
+
const whereCondition: any = {
|
|
1408
|
+
auth_key: { _in: authKeys.map((authKey) => authKey.toString()) },
|
|
1409
|
+
...(includeUnverified ? {} : { is_auth_key_used: { _eq: true } }),
|
|
1410
|
+
};
|
|
1411
|
+
|
|
1412
|
+
const graphqlQuery = {
|
|
1413
|
+
query: GetAccountAddressesForAuthKey,
|
|
1414
|
+
variables: {
|
|
1415
|
+
where_condition: whereCondition,
|
|
1416
|
+
order_by: [{ last_transaction_version: "desc" }],
|
|
1417
|
+
},
|
|
1418
|
+
};
|
|
1419
|
+
const { auth_key_account_addresses: data } = await queryIndexer<GetAccountAddressesForAuthKeyQuery>({
|
|
1420
|
+
movementConfig,
|
|
1421
|
+
query: graphqlQuery,
|
|
1422
|
+
originMethod: "getAccountAddressesForAuthKeys",
|
|
1423
|
+
});
|
|
1424
|
+
return data.map((entry) => ({
|
|
1425
|
+
authKey: new AuthenticationKey({ data: entry.auth_key }),
|
|
1426
|
+
accountAddress: new AccountAddress(Hex.hexInputToUint8Array(entry.account_address)),
|
|
1427
|
+
lastTransactionVersion: Number(entry.last_transaction_version),
|
|
1428
|
+
}));
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
/**
|
|
1432
|
+
* Returns the last transaction version that was signed by an account.
|
|
1433
|
+
*
|
|
1434
|
+
* If an account was created but has not signed any transactions, the last transaction version will be 0.
|
|
1435
|
+
*
|
|
1436
|
+
* @param args.movementConfig - The configuration settings for the Movement network.
|
|
1437
|
+
* @param args.accountAddress - The account address to get the latest transaction version for.
|
|
1438
|
+
* @returns The last transaction version that was signed by the account.
|
|
1439
|
+
*/
|
|
1440
|
+
async function getLatestTransactionVersionForAddress(args: {
|
|
1441
|
+
movementConfig: MovementConfig;
|
|
1442
|
+
accountAddress: AccountAddressInput;
|
|
1443
|
+
}): Promise<number> {
|
|
1444
|
+
const { movementConfig, accountAddress } = args;
|
|
1445
|
+
const transactions = await getTransactions({ movementConfig, accountAddress, options: { limit: 1 } });
|
|
1446
|
+
if (transactions.length === 0) {
|
|
1447
|
+
return 0;
|
|
1448
|
+
}
|
|
1449
|
+
return Number(transactions[0].version);
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
/**
|
|
1453
|
+
* Gets the default account info for a given public key. 'Default account' means the account
|
|
1454
|
+
* is address is the same as the auth key derived from the public key and the account auth key has
|
|
1455
|
+
* not been rotated.
|
|
1456
|
+
*
|
|
1457
|
+
* @param args - The arguments for getting the default account info for a given public key.
|
|
1458
|
+
* @param args.movementConfig - The configuration settings for the Movement network.
|
|
1459
|
+
* @param args.publicKey - The public key to use to derive the address.
|
|
1460
|
+
* @returns An object containing the account address and the last transaction version, or undefined if the account does not exist.
|
|
1461
|
+
*/
|
|
1462
|
+
async function getDefaultAccountInfoForPublicKey(args: {
|
|
1463
|
+
movementConfig: MovementConfig;
|
|
1464
|
+
publicKey: AccountPublicKey;
|
|
1465
|
+
}): Promise<{ accountAddress: AccountAddress; lastTransactionVersion: number } | undefined> {
|
|
1466
|
+
const { movementConfig, publicKey } = args;
|
|
1467
|
+
const derivedAddress = publicKey.authKey().derivedAddress();
|
|
1468
|
+
|
|
1469
|
+
const [lastTransactionVersion, exists] = await Promise.all([
|
|
1470
|
+
getLatestTransactionVersionForAddress({
|
|
1471
|
+
movementConfig,
|
|
1472
|
+
accountAddress: derivedAddress,
|
|
1473
|
+
}),
|
|
1474
|
+
doesAccountExistAtAddress({
|
|
1475
|
+
movementConfig,
|
|
1476
|
+
accountAddress: derivedAddress,
|
|
1477
|
+
options: { withAuthKey: publicKey.authKey() },
|
|
1478
|
+
}),
|
|
1479
|
+
]);
|
|
1480
|
+
if (exists) {
|
|
1481
|
+
return { accountAddress: derivedAddress, lastTransactionVersion };
|
|
1482
|
+
}
|
|
1483
|
+
return undefined;
|
|
1484
|
+
}
|