@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,351 @@
|
|
|
1
|
+
import type { MovementConfig } from "../../api";
|
|
2
|
+
import { Deserializer, Serializer } from "../../bcs";
|
|
3
|
+
import {
|
|
4
|
+
AnyPublicKeyVariant,
|
|
5
|
+
AnySignatureVariant,
|
|
6
|
+
SigningScheme as AuthenticationKeyScheme,
|
|
7
|
+
HexInput,
|
|
8
|
+
} from "../../types";
|
|
9
|
+
import { AuthenticationKey } from "../authenticationKey";
|
|
10
|
+
import { Ed25519PrivateKey, Ed25519PublicKey, Ed25519Signature } from "./ed25519";
|
|
11
|
+
import { FederatedKeylessPublicKey } from "./federatedKeyless";
|
|
12
|
+
import { KeylessPublicKey, KeylessSignature } from "./keyless";
|
|
13
|
+
import { AccountPublicKey, PublicKey } from "./publicKey";
|
|
14
|
+
import { Secp256k1PrivateKey, Secp256k1PublicKey, Secp256k1Signature } from "./secp256k1";
|
|
15
|
+
import { Secp256r1PublicKey, WebAuthnSignature } from "./secp256r1";
|
|
16
|
+
import { Signature } from "./signature";
|
|
17
|
+
|
|
18
|
+
export type PrivateKeyInput = Ed25519PrivateKey | Secp256k1PrivateKey;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Represents any public key supported by Movement.
|
|
22
|
+
*
|
|
23
|
+
* Since [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263) Movement supports
|
|
24
|
+
* `Legacy` and `Unified` authentication keys.
|
|
25
|
+
*
|
|
26
|
+
* Any unified authentication key is represented in the SDK as `AnyPublicKey`.
|
|
27
|
+
* @group Implementation
|
|
28
|
+
* @category Serialization
|
|
29
|
+
*/
|
|
30
|
+
export class AnyPublicKey extends AccountPublicKey {
|
|
31
|
+
/**
|
|
32
|
+
* Reference to the inner public key
|
|
33
|
+
* @group Implementation
|
|
34
|
+
* @category Serialization
|
|
35
|
+
*/
|
|
36
|
+
public readonly publicKey: PublicKey;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Index of the underlying enum variant
|
|
40
|
+
* @group Implementation
|
|
41
|
+
* @category Serialization
|
|
42
|
+
*/
|
|
43
|
+
public readonly variant: AnyPublicKeyVariant;
|
|
44
|
+
|
|
45
|
+
// region Constructors
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Creates an instance of the signature class based on the provided signature type.
|
|
49
|
+
* This allows for the handling of different signature variants such as Ed25519, Secp256k1, and Keyless.
|
|
50
|
+
*
|
|
51
|
+
* @param publicKey - The publicKey object which determines the variant to be used.
|
|
52
|
+
* @throws Error if the provided signature type is unsupported.
|
|
53
|
+
* @group Implementation
|
|
54
|
+
* @category Serialization
|
|
55
|
+
*/
|
|
56
|
+
constructor(publicKey: PublicKey) {
|
|
57
|
+
super();
|
|
58
|
+
this.publicKey = publicKey;
|
|
59
|
+
if (publicKey instanceof Ed25519PublicKey) {
|
|
60
|
+
this.variant = AnyPublicKeyVariant.Ed25519;
|
|
61
|
+
} else if (publicKey instanceof Secp256k1PublicKey) {
|
|
62
|
+
this.variant = AnyPublicKeyVariant.Secp256k1;
|
|
63
|
+
} else if (publicKey instanceof Secp256r1PublicKey) {
|
|
64
|
+
this.variant = AnyPublicKeyVariant.Secp256r1;
|
|
65
|
+
} else if (publicKey instanceof KeylessPublicKey) {
|
|
66
|
+
this.variant = AnyPublicKeyVariant.Keyless;
|
|
67
|
+
} else if (publicKey instanceof FederatedKeylessPublicKey) {
|
|
68
|
+
this.variant = AnyPublicKeyVariant.FederatedKeyless;
|
|
69
|
+
} else {
|
|
70
|
+
throw new Error("Unsupported public key type");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// endregion
|
|
75
|
+
|
|
76
|
+
// region AccountPublicKey
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Verifies the provided signature against the given message.
|
|
80
|
+
* This function helps ensure the integrity and authenticity of the message by confirming that the signature is valid.
|
|
81
|
+
*
|
|
82
|
+
* @param args - The arguments for signature verification.
|
|
83
|
+
* @param args.message - The message that was signed.
|
|
84
|
+
* @param args.signature - The signature to verify, which must be an instance of AnySignature.
|
|
85
|
+
* @returns A boolean indicating whether the signature is valid for the given message.
|
|
86
|
+
* @group Implementation
|
|
87
|
+
* @category Serialization
|
|
88
|
+
*/
|
|
89
|
+
verifySignature(args: { message: HexInput; signature: AnySignature }): boolean {
|
|
90
|
+
const { message, signature } = args;
|
|
91
|
+
if (this.publicKey instanceof KeylessPublicKey) {
|
|
92
|
+
throw new Error("Use verifySignatureAsync to verify Keyless signatures");
|
|
93
|
+
}
|
|
94
|
+
return this.publicKey.verifySignature({
|
|
95
|
+
message,
|
|
96
|
+
signature: signature.signature,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Verifies the provided signature against the given message.
|
|
102
|
+
* This function helps ensure the integrity and authenticity of the message by confirming that the signature is valid.
|
|
103
|
+
*
|
|
104
|
+
* @param args - The arguments for signature verification.
|
|
105
|
+
* @param args.movementConfig - The configuration object for connecting to the Movement network
|
|
106
|
+
* @param args.message - The message that was signed.
|
|
107
|
+
* @param args.signature - The signature to verify, which must be an instance of AnySignature.
|
|
108
|
+
* @returns A boolean indicating whether the signature is valid for the given message.
|
|
109
|
+
* @group Implementation
|
|
110
|
+
* @category Serialization
|
|
111
|
+
*/
|
|
112
|
+
async verifySignatureAsync(args: {
|
|
113
|
+
movementConfig: MovementConfig;
|
|
114
|
+
message: HexInput;
|
|
115
|
+
signature: Signature;
|
|
116
|
+
options?: { throwErrorWithReason?: boolean };
|
|
117
|
+
}): Promise<boolean> {
|
|
118
|
+
if (!(args.signature instanceof AnySignature)) {
|
|
119
|
+
if (args.options?.throwErrorWithReason) {
|
|
120
|
+
throw new Error("Signature must be an instance of AnySignature");
|
|
121
|
+
}
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
return await this.publicKey.verifySignatureAsync({
|
|
125
|
+
...args,
|
|
126
|
+
signature: args.signature.signature,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Generates an authentication key from the current instance's byte representation.
|
|
132
|
+
* This function is essential for creating a unique identifier for authentication purposes.
|
|
133
|
+
*
|
|
134
|
+
* @returns {AuthenticationKey} The generated authentication key.
|
|
135
|
+
* @group Implementation
|
|
136
|
+
* @category Serialization
|
|
137
|
+
*/
|
|
138
|
+
authKey(): AuthenticationKey {
|
|
139
|
+
return AuthenticationKey.fromSchemeAndBytes({
|
|
140
|
+
scheme: AuthenticationKeyScheme.SingleKey,
|
|
141
|
+
input: this.toUint8Array(),
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Get the signature in bytes (Uint8Array).
|
|
147
|
+
*
|
|
148
|
+
* This function is a warning that it will soon return the underlying signature bytes directly.
|
|
149
|
+
* Use AnySignature.bcsToBytes() instead.
|
|
150
|
+
*
|
|
151
|
+
* @returns Uint8Array representation of the signature.
|
|
152
|
+
* @group Implementation
|
|
153
|
+
* @category Serialization
|
|
154
|
+
*/
|
|
155
|
+
toUint8Array(): Uint8Array {
|
|
156
|
+
return this.bcsToBytes();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// endregion
|
|
160
|
+
|
|
161
|
+
// region Serializable
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Serializes the current object using the provided serializer.
|
|
165
|
+
* This function helps in converting the object into a format suitable for transmission or storage.
|
|
166
|
+
*
|
|
167
|
+
* @param serializer - The serializer instance used to perform the serialization.
|
|
168
|
+
* @group Implementation
|
|
169
|
+
* @category Serialization
|
|
170
|
+
*/
|
|
171
|
+
serialize(serializer: Serializer): void {
|
|
172
|
+
serializer.serializeU32AsUleb128(this.variant);
|
|
173
|
+
this.publicKey.serialize(serializer);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Deserializes an AnySignature from the provided deserializer.
|
|
178
|
+
* This function helps in reconstructing the AnySignature object from its serialized form, allowing for further processing or validation.
|
|
179
|
+
*
|
|
180
|
+
* @param deserializer - The deserializer instance used to read the serialized data.
|
|
181
|
+
* @group Implementation
|
|
182
|
+
* @category Serialization
|
|
183
|
+
*/
|
|
184
|
+
static deserialize(deserializer: Deserializer): AnyPublicKey {
|
|
185
|
+
const variantIndex = deserializer.deserializeUleb128AsU32();
|
|
186
|
+
let publicKey: PublicKey;
|
|
187
|
+
switch (variantIndex) {
|
|
188
|
+
case AnyPublicKeyVariant.Ed25519:
|
|
189
|
+
publicKey = Ed25519PublicKey.deserialize(deserializer);
|
|
190
|
+
break;
|
|
191
|
+
case AnyPublicKeyVariant.Secp256k1:
|
|
192
|
+
publicKey = Secp256k1PublicKey.deserialize(deserializer);
|
|
193
|
+
break;
|
|
194
|
+
case AnyPublicKeyVariant.Secp256r1:
|
|
195
|
+
publicKey = Secp256r1PublicKey.deserialize(deserializer);
|
|
196
|
+
break;
|
|
197
|
+
case AnyPublicKeyVariant.Keyless:
|
|
198
|
+
publicKey = KeylessPublicKey.deserialize(deserializer);
|
|
199
|
+
break;
|
|
200
|
+
case AnyPublicKeyVariant.FederatedKeyless:
|
|
201
|
+
publicKey = FederatedKeylessPublicKey.deserialize(deserializer);
|
|
202
|
+
break;
|
|
203
|
+
default:
|
|
204
|
+
throw new Error(`Unknown variant index for AnyPublicKey: ${variantIndex}`);
|
|
205
|
+
}
|
|
206
|
+
return new AnyPublicKey(publicKey);
|
|
207
|
+
}
|
|
208
|
+
// endregion
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Determines if the provided public key is an instance of AnyPublicKey.
|
|
212
|
+
*
|
|
213
|
+
* @param publicKey - The public key to check.
|
|
214
|
+
* @deprecated Use `instanceof AnyPublicKey` instead.
|
|
215
|
+
* @group Implementation
|
|
216
|
+
* @category Serialization
|
|
217
|
+
*/
|
|
218
|
+
static isPublicKey(publicKey: AccountPublicKey): publicKey is AnyPublicKey {
|
|
219
|
+
return publicKey instanceof AnyPublicKey;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Determines if the current public key is an instance of Ed25519PublicKey.
|
|
224
|
+
*
|
|
225
|
+
* @deprecated use `publicKey instanceof Ed25519PublicKey` instead.
|
|
226
|
+
* @group Implementation
|
|
227
|
+
* @category Serialization
|
|
228
|
+
*/
|
|
229
|
+
isEd25519(): boolean {
|
|
230
|
+
return this.publicKey instanceof Ed25519PublicKey;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Checks if the public key is an instance of Secp256k1PublicKey.
|
|
235
|
+
*
|
|
236
|
+
* @deprecated use `publicKey instanceof Secp256k1PublicKey` instead.
|
|
237
|
+
* @group Implementation
|
|
238
|
+
* @category Serialization
|
|
239
|
+
*/
|
|
240
|
+
isSecp256k1PublicKey(): boolean {
|
|
241
|
+
return this.publicKey instanceof Secp256k1PublicKey;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Determines if the provided publicKey is an instance of a valid PublicKey object.
|
|
246
|
+
*
|
|
247
|
+
* @param publicKey - The publicKey to be checked for validity.
|
|
248
|
+
* @param publicKey.publicKey - The actual publicKey object that needs to be validated.
|
|
249
|
+
* @returns True if the signature is a valid instance; otherwise, false.
|
|
250
|
+
* @group Implementation
|
|
251
|
+
* @category Serialization
|
|
252
|
+
*/
|
|
253
|
+
static isInstance(publicKey: PublicKey): publicKey is AnyPublicKey {
|
|
254
|
+
return "publicKey" in publicKey && "variant" in publicKey;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Represents a signature that utilizes the SingleKey authentication scheme.
|
|
260
|
+
* This class is designed to encapsulate various types of signatures, which can
|
|
261
|
+
* only be generated by a `SingleKeySigner` due to the shared authentication mechanism.
|
|
262
|
+
*
|
|
263
|
+
* @extends Signature
|
|
264
|
+
* @group Implementation
|
|
265
|
+
* @category Serialization
|
|
266
|
+
*/
|
|
267
|
+
export class AnySignature extends Signature {
|
|
268
|
+
public readonly signature: Signature;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Index of the underlying enum variant
|
|
272
|
+
* @group Implementation
|
|
273
|
+
* @category Serialization
|
|
274
|
+
*/
|
|
275
|
+
private readonly variant: AnySignatureVariant;
|
|
276
|
+
|
|
277
|
+
// region Constructors
|
|
278
|
+
|
|
279
|
+
constructor(signature: Signature) {
|
|
280
|
+
super();
|
|
281
|
+
this.signature = signature;
|
|
282
|
+
|
|
283
|
+
if (signature instanceof Ed25519Signature) {
|
|
284
|
+
this.variant = AnySignatureVariant.Ed25519;
|
|
285
|
+
} else if (signature instanceof Secp256k1Signature) {
|
|
286
|
+
this.variant = AnySignatureVariant.Secp256k1;
|
|
287
|
+
} else if (signature instanceof WebAuthnSignature) {
|
|
288
|
+
this.variant = AnySignatureVariant.WebAuthn;
|
|
289
|
+
} else if (signature instanceof KeylessSignature) {
|
|
290
|
+
this.variant = AnySignatureVariant.Keyless;
|
|
291
|
+
} else {
|
|
292
|
+
throw new Error("Unsupported signature type");
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// endregion
|
|
297
|
+
|
|
298
|
+
// region AccountSignature
|
|
299
|
+
|
|
300
|
+
toUint8Array(): Uint8Array {
|
|
301
|
+
// TODO: keep this warning around for a bit, and eventually change this to return `this.signature.toUint8Array()`.
|
|
302
|
+
// eslint-disable-next-line no-console
|
|
303
|
+
console.warn(
|
|
304
|
+
"[Aptos SDK] Calls to AnySignature.toUint8Array() will soon return the underlying signature bytes. " +
|
|
305
|
+
"Use AnySignature.bcsToBytes() instead.",
|
|
306
|
+
);
|
|
307
|
+
return this.bcsToBytes();
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// endregion
|
|
311
|
+
|
|
312
|
+
// region Serializable
|
|
313
|
+
|
|
314
|
+
serialize(serializer: Serializer): void {
|
|
315
|
+
serializer.serializeU32AsUleb128(this.variant);
|
|
316
|
+
this.signature.serialize(serializer);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
static deserialize(deserializer: Deserializer): AnySignature {
|
|
320
|
+
const variantIndex = deserializer.deserializeUleb128AsU32();
|
|
321
|
+
let signature: Signature;
|
|
322
|
+
switch (variantIndex) {
|
|
323
|
+
case AnySignatureVariant.Ed25519:
|
|
324
|
+
signature = Ed25519Signature.deserialize(deserializer);
|
|
325
|
+
break;
|
|
326
|
+
case AnySignatureVariant.Secp256k1:
|
|
327
|
+
signature = Secp256k1Signature.deserialize(deserializer);
|
|
328
|
+
break;
|
|
329
|
+
case AnySignatureVariant.WebAuthn:
|
|
330
|
+
signature = WebAuthnSignature.deserialize(deserializer);
|
|
331
|
+
break;
|
|
332
|
+
case AnySignatureVariant.Keyless:
|
|
333
|
+
signature = KeylessSignature.deserialize(deserializer);
|
|
334
|
+
break;
|
|
335
|
+
default:
|
|
336
|
+
throw new Error(`Unknown variant index for AnySignature: ${variantIndex}`);
|
|
337
|
+
}
|
|
338
|
+
return new AnySignature(signature);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// endregion
|
|
342
|
+
|
|
343
|
+
static isInstance(signature: Signature): signature is AnySignature {
|
|
344
|
+
return (
|
|
345
|
+
"signature" in signature &&
|
|
346
|
+
typeof signature.signature === "object" &&
|
|
347
|
+
signature.signature !== null &&
|
|
348
|
+
"toUint8Array" in signature.signature
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AnyPublicKey } from "./singleKey";
|
|
2
|
+
import { Ed25519PublicKey } from "./ed25519";
|
|
3
|
+
import { MultiKey } from "./multiKey";
|
|
4
|
+
import { MultiEd25519PublicKey } from "./multiEd25519";
|
|
5
|
+
|
|
6
|
+
// This type is used to represent the base from of an account's public key.
|
|
7
|
+
// These are the types of public keys that can be used to derive an account's address by appending
|
|
8
|
+
// the signing scheme to the public key as bytes and hashing it.
|
|
9
|
+
export type BaseAccountPublicKey = Ed25519PublicKey | AnyPublicKey | MultiKey | MultiEd25519PublicKey;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { HexInput, SigningScheme } from "../../types";
|
|
2
|
+
import { Hex } from "../hex";
|
|
3
|
+
import { Ed25519PublicKey } from "./ed25519";
|
|
4
|
+
import { FederatedKeylessPublicKey } from "./federatedKeyless";
|
|
5
|
+
import { KeylessPublicKey } from "./keyless";
|
|
6
|
+
import { MultiEd25519PublicKey } from "./multiEd25519";
|
|
7
|
+
import { MultiKey } from "./multiKey";
|
|
8
|
+
import { AccountPublicKey } from "./publicKey";
|
|
9
|
+
import { AnyPublicKey } from "./singleKey";
|
|
10
|
+
import { BaseAccountPublicKey } from "./types";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Helper function to convert a message to sign or to verify to a valid message input
|
|
14
|
+
*
|
|
15
|
+
* @param message a message as a string or Uint8Array
|
|
16
|
+
*
|
|
17
|
+
* @returns a valid HexInput - string or Uint8Array
|
|
18
|
+
* @group Implementation
|
|
19
|
+
* @category Serialization
|
|
20
|
+
*/
|
|
21
|
+
export const convertSigningMessage = (message: HexInput): HexInput => {
|
|
22
|
+
// if message is of type string, verify it is a valid Hex string
|
|
23
|
+
if (typeof message === "string") {
|
|
24
|
+
const isValid = Hex.isValid(message);
|
|
25
|
+
// If message is not a valid Hex string, convert it
|
|
26
|
+
if (!isValid.valid) {
|
|
27
|
+
return new TextEncoder().encode(message);
|
|
28
|
+
}
|
|
29
|
+
// If message is a valid Hex string, return it
|
|
30
|
+
return message;
|
|
31
|
+
}
|
|
32
|
+
// message is a Uint8Array
|
|
33
|
+
return message;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const accountPublicKeyToBaseAccountPublicKey = (publicKey: AccountPublicKey): BaseAccountPublicKey => {
|
|
37
|
+
if (
|
|
38
|
+
publicKey instanceof Ed25519PublicKey ||
|
|
39
|
+
publicKey instanceof AnyPublicKey ||
|
|
40
|
+
publicKey instanceof MultiEd25519PublicKey ||
|
|
41
|
+
publicKey instanceof MultiKey
|
|
42
|
+
) {
|
|
43
|
+
return publicKey;
|
|
44
|
+
}
|
|
45
|
+
if (publicKey instanceof KeylessPublicKey || publicKey instanceof FederatedKeylessPublicKey) {
|
|
46
|
+
return new AnyPublicKey(publicKey);
|
|
47
|
+
}
|
|
48
|
+
throw new Error(`Unknown account public key: ${publicKey}`);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const accountPublicKeyToSigningScheme = (publicKey: AccountPublicKey): SigningScheme => {
|
|
52
|
+
const baseAccountPublicKey = accountPublicKeyToBaseAccountPublicKey(publicKey);
|
|
53
|
+
if (baseAccountPublicKey instanceof Ed25519PublicKey) {
|
|
54
|
+
return SigningScheme.Ed25519;
|
|
55
|
+
} else if (baseAccountPublicKey instanceof AnyPublicKey) {
|
|
56
|
+
return SigningScheme.SingleKey;
|
|
57
|
+
} else if (baseAccountPublicKey instanceof MultiEd25519PublicKey) {
|
|
58
|
+
return SigningScheme.MultiEd25519;
|
|
59
|
+
} else if (baseAccountPublicKey instanceof MultiKey) {
|
|
60
|
+
return SigningScheme.MultiKey;
|
|
61
|
+
}
|
|
62
|
+
throw new Error(`Unknown signing scheme: ${baseAccountPublicKey}`);
|
|
63
|
+
};
|
package/src/core/hex.ts
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
// Copyright © Move Industries
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { bytesToHex, hexToBytes } from "@noble/hashes/utils";
|
|
5
|
+
import { HexInput } from "../types";
|
|
6
|
+
import { ParsingError, ParsingResult } from "./common";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Provides reasons for parsing failures related to hexadecimal values.
|
|
10
|
+
* @group Implementation
|
|
11
|
+
* @category Serialization
|
|
12
|
+
*/
|
|
13
|
+
export enum HexInvalidReason {
|
|
14
|
+
TOO_SHORT = "too_short",
|
|
15
|
+
INVALID_LENGTH = "invalid_length",
|
|
16
|
+
INVALID_HEX_CHARS = "invalid_hex_chars",
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* NOTE: Do not use this class when working with account addresses; use AccountAddress instead.
|
|
21
|
+
* When accepting hex data as input to a function, prefer to accept HexInput and
|
|
22
|
+
*
|
|
23
|
+
* A helper class for working with hex data. Hex data, when represented as a string,
|
|
24
|
+
* generally looks like this, for example: 0xaabbcc, 45cd32, etc.
|
|
25
|
+
*
|
|
26
|
+
* then use the static helper methods of this class to convert it into the desired
|
|
27
|
+
* format. This enables the greatest flexibility for the developer.
|
|
28
|
+
*
|
|
29
|
+
* Example usage:
|
|
30
|
+
* ```typescript
|
|
31
|
+
* getTransactionByHash(txnHash: HexInput): Promise<Transaction> {
|
|
32
|
+
* const txnHashString = Hex.fromHexInput(txnHash).toString();
|
|
33
|
+
* return await getTransactionByHashInner(txnHashString);
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
* This call to `Hex.fromHexInput().toString()` converts the HexInput to a hex string
|
|
37
|
+
* with a leading 0x prefix, regardless of what the input format was.
|
|
38
|
+
*
|
|
39
|
+
* Other ways to chain the functions together:
|
|
40
|
+
* - `Hex.fromHexString({ hexInput: "0x1f" }).toUint8Array()`
|
|
41
|
+
* - `new Hex([1, 3]).toStringWithoutPrefix()`
|
|
42
|
+
* @group Implementation
|
|
43
|
+
* @category Serialization
|
|
44
|
+
*/
|
|
45
|
+
export class Hex {
|
|
46
|
+
private readonly data: Uint8Array;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Create a new Hex instance from a Uint8Array.
|
|
50
|
+
*
|
|
51
|
+
* @param data - The Uint8Array containing the data to initialize the Hex instance.
|
|
52
|
+
* @group Implementation
|
|
53
|
+
* @category Serialization
|
|
54
|
+
*/
|
|
55
|
+
constructor(data: Uint8Array) {
|
|
56
|
+
this.data = data;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ===
|
|
60
|
+
// Methods for representing an instance of Hex as other types.
|
|
61
|
+
// ===
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Get the inner hex data as a Uint8Array. The inner data is already a Uint8Array, so no conversion takes place.
|
|
65
|
+
*
|
|
66
|
+
* @returns Hex data as Uint8Array
|
|
67
|
+
* @group Implementation
|
|
68
|
+
* @category Serialization
|
|
69
|
+
*/
|
|
70
|
+
toUint8Array(): Uint8Array {
|
|
71
|
+
return this.data;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get the hex data as a string without the 0x prefix.
|
|
76
|
+
*
|
|
77
|
+
* @returns Hex string without 0x prefix
|
|
78
|
+
* @group Implementation
|
|
79
|
+
* @category Serialization
|
|
80
|
+
*/
|
|
81
|
+
toStringWithoutPrefix(): string {
|
|
82
|
+
return bytesToHex(this.data);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Get the hex data as a string with the 0x prefix.
|
|
87
|
+
*
|
|
88
|
+
* @returns Hex string with 0x prefix
|
|
89
|
+
* @group Implementation
|
|
90
|
+
* @category Serialization
|
|
91
|
+
*/
|
|
92
|
+
toString(): string {
|
|
93
|
+
return `0x${this.toStringWithoutPrefix()}`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ===
|
|
97
|
+
// Methods for creating an instance of Hex from other types.
|
|
98
|
+
// ===
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Converts a hex string into a Hex instance, allowing for both prefixed and non-prefixed formats.
|
|
102
|
+
*
|
|
103
|
+
* @param str - A hex string, with or without the 0x prefix.
|
|
104
|
+
*
|
|
105
|
+
* @throws ParsingError - If the hex string is too short, has an odd number of characters, or contains invalid hex characters.
|
|
106
|
+
*
|
|
107
|
+
* @returns Hex - The resulting Hex instance created from the provided string.
|
|
108
|
+
* @group Implementation
|
|
109
|
+
* @category Serialization
|
|
110
|
+
*/
|
|
111
|
+
static fromHexString(str: string): Hex {
|
|
112
|
+
let input = str;
|
|
113
|
+
|
|
114
|
+
if (input.startsWith("0x")) {
|
|
115
|
+
input = input.slice(2);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (input.length === 0) {
|
|
119
|
+
throw new ParsingError(
|
|
120
|
+
"Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.",
|
|
121
|
+
HexInvalidReason.TOO_SHORT,
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (input.length % 2 !== 0) {
|
|
126
|
+
throw new ParsingError("Hex string must be an even number of hex characters.", HexInvalidReason.INVALID_LENGTH);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
try {
|
|
130
|
+
return new Hex(hexToBytes(input));
|
|
131
|
+
} catch (error: any) {
|
|
132
|
+
throw new ParsingError(
|
|
133
|
+
`Hex string contains invalid hex characters: ${error?.message}`,
|
|
134
|
+
HexInvalidReason.INVALID_HEX_CHARS,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Converts an instance of HexInput, which can be a string or a Uint8Array, into a Hex instance.
|
|
141
|
+
* This function is useful for transforming hexadecimal representations into a structured Hex object for further manipulation.
|
|
142
|
+
*
|
|
143
|
+
* @param hexInput - A HexInput which can be a string or Uint8Array.
|
|
144
|
+
* @returns A Hex instance created from the provided hexInput.
|
|
145
|
+
* @group Implementation
|
|
146
|
+
* @category Serialization
|
|
147
|
+
*/
|
|
148
|
+
static fromHexInput(hexInput: HexInput): Hex {
|
|
149
|
+
if (hexInput instanceof Uint8Array) return new Hex(hexInput);
|
|
150
|
+
return Hex.fromHexString(hexInput);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Converts an instance of HexInput, which can be a string or a Uint8Array, into a Uint8Array.
|
|
155
|
+
*
|
|
156
|
+
* @param hexInput - A HexInput which can be a string or Uint8Array.
|
|
157
|
+
* @returns A Uint8Array created from the provided hexInput.
|
|
158
|
+
*/
|
|
159
|
+
static hexInputToUint8Array(hexInput: HexInput): Uint8Array {
|
|
160
|
+
if (hexInput instanceof Uint8Array) return hexInput;
|
|
161
|
+
return Hex.fromHexString(hexInput).toUint8Array();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Converts a HexInput (string or Uint8Array) to a hex string with '0x' prefix.
|
|
166
|
+
*
|
|
167
|
+
* @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array
|
|
168
|
+
* @returns A hex string with '0x' prefix (e.g., "0x1234")
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```typescript
|
|
172
|
+
* Hex.hexInputToString("1234") // returns "0x1234"
|
|
173
|
+
* Hex.hexInputToString("0x1234") // returns "0x1234"
|
|
174
|
+
* Hex.hexInputToString(new Uint8Array([0x12, 0x34])) // returns "0x1234"
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
static hexInputToString(hexInput: HexInput): string {
|
|
178
|
+
return Hex.fromHexInput(hexInput).toString();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Converts a HexInput (string or Uint8Array) to a hex string without '0x' prefix.
|
|
183
|
+
*
|
|
184
|
+
* @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array
|
|
185
|
+
* @returns A hex string without '0x' prefix (e.g., "1234")
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* Hex.hexInputToStringWithoutPrefix("1234") // returns "1234"
|
|
190
|
+
* Hex.hexInputToStringWithoutPrefix("0x1234") // returns "1234"
|
|
191
|
+
* Hex.hexInputToStringWithoutPrefix(new Uint8Array([0x12, 0x34])) // returns "1234"
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
static hexInputToStringWithoutPrefix(hexInput: HexInput): string {
|
|
195
|
+
return Hex.fromHexInput(hexInput).toStringWithoutPrefix();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// ===
|
|
199
|
+
// Methods for checking validity.
|
|
200
|
+
// ===
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Check if the provided string is a valid hexadecimal representation.
|
|
204
|
+
*
|
|
205
|
+
* @param str - A hex string representing byte data.
|
|
206
|
+
*
|
|
207
|
+
* @returns An object containing:
|
|
208
|
+
* - valid: A boolean indicating whether the string is valid.
|
|
209
|
+
* - invalidReason: The reason for invalidity if the string is not valid.
|
|
210
|
+
* - invalidReasonMessage: A message explaining why the string is invalid.
|
|
211
|
+
* @group Implementation
|
|
212
|
+
* @category Serialization
|
|
213
|
+
*/
|
|
214
|
+
static isValid(str: string): ParsingResult<HexInvalidReason> {
|
|
215
|
+
try {
|
|
216
|
+
Hex.fromHexString(str);
|
|
217
|
+
return { valid: true };
|
|
218
|
+
} catch (error: any) {
|
|
219
|
+
return {
|
|
220
|
+
valid: false,
|
|
221
|
+
invalidReason: error?.invalidReason,
|
|
222
|
+
invalidReasonMessage: error?.message,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Determine if two Hex instances are equal by comparing their underlying byte data.
|
|
229
|
+
*
|
|
230
|
+
* @param other The Hex instance to compare to.
|
|
231
|
+
* @returns true if the Hex instances are equal, false if not.
|
|
232
|
+
* @group Implementation
|
|
233
|
+
* @category Serialization
|
|
234
|
+
*/
|
|
235
|
+
equals(other: Hex): boolean {
|
|
236
|
+
if (this.data.length !== other.data.length) return false;
|
|
237
|
+
return this.data.every((value, index) => value === other.data[index]);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export const hexToAsciiString = (hex: string) => new TextDecoder().decode(Hex.fromHexInput(hex).toUint8Array());
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright © Move Industries
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export * from "./account";
|
|
5
|
+
export * from "./accountAddress";
|
|
6
|
+
export * from "./authenticationKey";
|
|
7
|
+
export * from "./common";
|
|
8
|
+
export * from "./crypto";
|
|
9
|
+
export * from "./hex";
|
|
10
|
+
|