@aptos-labs/ts-sdk 5.1.3 → 5.1.5
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 +68 -201
- package/dist/common/{account-nCfrFDHy.d.ts → account-DefhsHe3.d.ts} +232 -1
- package/dist/common/chunk-HO5ESTN4.js +4 -0
- package/dist/common/chunk-HO5ESTN4.js.map +1 -0
- package/dist/common/cli/index.d.ts +1 -1
- package/dist/common/cli/index.js +1 -1
- package/dist/common/cli/index.js.map +1 -1
- package/dist/common/index.d.ts +2 -2
- package/dist/common/index.js +31 -31
- package/dist/common/index.js.map +1 -1
- package/dist/esm/{Ed25519Account-BgSyStyl.d.mts → Ed25519Account-CVg5T_jc.d.mts} +1 -1
- package/dist/esm/account/AbstractKeylessAccount.d.mts +3 -3
- package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
- package/dist/esm/account/AbstractedAccount.d.mts +2 -2
- package/dist/esm/account/AbstractedAccount.mjs +1 -1
- package/dist/esm/account/Account.d.mts +2 -2
- package/dist/esm/account/Account.mjs +1 -1
- package/dist/esm/account/AccountUtils.d.mts +3 -3
- package/dist/esm/account/AccountUtils.mjs +1 -1
- package/dist/esm/account/DerivableAbstractedAccount.d.mts +2 -2
- package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
- package/dist/esm/account/Ed25519Account.d.mts +2 -2
- package/dist/esm/account/Ed25519Account.mjs +1 -1
- package/dist/esm/account/EphemeralKeyPair.d.mts +1 -1
- package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
- package/dist/esm/account/FederatedKeylessAccount.d.mts +3 -3
- package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
- package/dist/esm/account/KeylessAccount.d.mts +3 -3
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/MultiEd25519Account.d.mts +2 -2
- package/dist/esm/account/MultiEd25519Account.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.d.mts +3 -3
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.d.mts +2 -2
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/index.d.mts +3 -3
- package/dist/esm/account/index.mjs +1 -1
- package/dist/esm/account/utils.d.mts +1 -1
- package/dist/esm/account/utils.mjs +1 -1
- package/dist/esm/{account-CAv0-Zs9.d.mts → account-DOs8SpoQ.d.mts} +232 -1
- package/dist/esm/api/account/abstraction.d.mts +1 -1
- package/dist/esm/api/account/abstraction.mjs +1 -1
- package/dist/esm/api/account.d.mts +2 -2
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +2 -2
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +3 -3
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.d.mts +1 -1
- package/dist/esm/api/coin.d.mts +1 -1
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +2 -2
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/faucet.d.mts +1 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +2 -2
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.d.mts +1 -1
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +3 -3
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.d.mts +3 -3
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/object.d.mts +1 -1
- package/dist/esm/api/object.mjs +1 -1
- package/dist/esm/api/staking.d.mts +1 -1
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/table.d.mts +1 -1
- package/dist/esm/api/table.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +2 -2
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.d.mts +1 -1
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/helpers.d.mts +1 -1
- package/dist/esm/api/transactionSubmission/management.d.mts +2 -2
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.d.mts +2 -2
- package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
- package/dist/esm/api/transactionSubmission/simulate.d.mts +1 -1
- package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
- package/dist/esm/api/transactionSubmission/submit.d.mts +1 -1
- package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
- package/dist/esm/api/utils.d.mts +1 -1
- package/dist/esm/api/utils.mjs +1 -1
- package/dist/esm/bcs/consts.d.mts +14 -2
- package/dist/esm/bcs/consts.mjs +1 -1
- package/dist/esm/bcs/deserializer.d.mts +1 -1
- package/dist/esm/bcs/deserializer.mjs +1 -1
- package/dist/esm/bcs/index.d.mts +1 -1
- package/dist/esm/bcs/index.mjs +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.d.mts +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/fixedBytes.d.mts +1 -1
- package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.d.mts +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.d.mts +1 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/bcs/serializer.d.mts +1 -1
- package/dist/esm/bcs/serializer.mjs +1 -1
- package/dist/esm/{chunk-DURSBMWP.mjs → chunk-3JDGB4IL.mjs} +2 -2
- package/dist/esm/chunk-3JDGB4IL.mjs.map +1 -0
- package/dist/esm/{chunk-N6YTF76Q.mjs → chunk-3P474TWM.mjs} +2 -2
- package/dist/esm/{chunk-Q4W3WJ2U.mjs → chunk-3Q4MUGFR.mjs} +2 -2
- package/dist/esm/{chunk-TOBQ5UE6.mjs → chunk-43LWUUXS.mjs} +2 -2
- package/dist/esm/chunk-5ABS6RDR.mjs +2 -0
- package/dist/esm/chunk-5ABS6RDR.mjs.map +1 -0
- package/dist/esm/{chunk-WSR5EBJM.mjs → chunk-5FNZUL2Y.mjs} +2 -2
- package/dist/esm/{chunk-XKUIMGKU.mjs → chunk-6IWGTO2J.mjs} +2 -2
- package/dist/esm/{chunk-ZYE7UTJZ.mjs → chunk-C5UZZHA4.mjs} +2 -2
- package/dist/esm/{chunk-MT2RJ7H3.mjs → chunk-DIFSO4N6.mjs} +2 -2
- package/dist/esm/{chunk-HX6SDBEX.mjs → chunk-EM7NAPDX.mjs} +2 -2
- package/dist/esm/{chunk-YZHAI55C.mjs → chunk-G3HAIETV.mjs} +2 -2
- package/dist/esm/{chunk-EF4FA5I6.mjs → chunk-GRF3NBRO.mjs} +2 -2
- package/dist/esm/chunk-I42Z32Q2.mjs +2 -0
- package/dist/esm/chunk-I42Z32Q2.mjs.map +1 -0
- package/dist/esm/{chunk-54WUP65H.mjs → chunk-I7UCQWRH.mjs} +2 -2
- package/dist/esm/chunk-JYXE7MWR.mjs +2 -0
- package/dist/esm/{chunk-EW45LLAP.mjs.map → chunk-JYXE7MWR.mjs.map} +1 -1
- package/dist/esm/{chunk-C2ZO2L5W.mjs → chunk-KNVQ5OJ7.mjs} +2 -2
- package/dist/esm/chunk-KUF4DKN5.mjs +2 -0
- package/dist/esm/{chunk-YSP6JG5G.mjs → chunk-L5EMB6TN.mjs} +2 -2
- package/dist/esm/chunk-LD3I4CYO.mjs +2 -0
- package/dist/esm/{chunk-DRBFLEZL.mjs → chunk-M2R4ECLZ.mjs} +2 -2
- package/dist/esm/{chunk-RGKRCZ36.mjs → chunk-MEG27LEV.mjs} +2 -2
- package/dist/esm/{chunk-M3FCWYLI.mjs → chunk-NV35GUIY.mjs} +3 -3
- package/dist/esm/{chunk-M3FCWYLI.mjs.map → chunk-NV35GUIY.mjs.map} +1 -1
- package/dist/esm/{chunk-LA56UDUK.mjs → chunk-PYVKCTUN.mjs} +2 -2
- package/dist/esm/{chunk-WCMW2L3P.mjs → chunk-QDJDZ3ON.mjs} +2 -2
- package/dist/esm/{chunk-FGFLPH5K.mjs → chunk-RYOICF37.mjs} +2 -2
- package/dist/esm/{chunk-AGAAGA2X.mjs → chunk-SQW3MYZL.mjs} +2 -2
- package/dist/esm/{chunk-BCTM24ZZ.mjs → chunk-UQT4B7EQ.mjs} +2 -2
- package/dist/esm/{chunk-I7XT6L7S.mjs → chunk-VO3JD6U6.mjs} +2 -2
- package/dist/esm/{chunk-GQ3UIDPQ.mjs → chunk-VS5NYRHW.mjs} +2 -2
- package/dist/esm/chunk-X2TPNKLV.mjs +2 -0
- package/dist/esm/chunk-X2TPNKLV.mjs.map +1 -0
- package/dist/esm/{chunk-EFQZGHAO.mjs → chunk-XP66F4IY.mjs} +2 -2
- package/dist/esm/{chunk-FLZPUYXQ.mjs → chunk-Y426VCPM.mjs} +2 -2
- package/dist/esm/{chunk-FLZPUYXQ.mjs.map → chunk-Y426VCPM.mjs.map} +1 -1
- package/dist/esm/{chunk-ZABLJ2JJ.mjs → chunk-YDWD2GVM.mjs} +2 -2
- package/dist/esm/{chunk-2XQKGWHQ.mjs → chunk-Z7NBE6RR.mjs} +2 -2
- package/dist/esm/cli/index.d.mts +1 -1
- package/dist/esm/cli/index.mjs +1 -1
- package/dist/esm/cli/localNode.mjs +1 -1
- package/dist/esm/cli/move.d.mts +1 -1
- package/dist/esm/client/core.d.mts +1 -1
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.d.mts +1 -1
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.d.mts +1 -1
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.d.mts +1 -1
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/core/account/index.d.mts +1 -1
- package/dist/esm/core/account/index.mjs +1 -1
- package/dist/esm/core/account/utils/address.d.mts +1 -1
- package/dist/esm/core/account/utils/address.mjs +1 -1
- package/dist/esm/core/account/utils/index.d.mts +1 -1
- package/dist/esm/core/account/utils/index.mjs +1 -1
- package/dist/esm/core/accountAddress.d.mts +1 -1
- package/dist/esm/core/accountAddress.mjs +1 -1
- package/dist/esm/core/authenticationKey.d.mts +1 -1
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/crypto/abstraction.d.mts +1 -1
- package/dist/esm/core/crypto/abstraction.mjs +1 -1
- package/dist/esm/core/crypto/deserializationUtils.d.mts +1 -1
- package/dist/esm/core/crypto/deserializationUtils.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.d.mts +1 -1
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.d.mts +1 -1
- package/dist/esm/core/crypto/ephemeral.mjs +1 -1
- package/dist/esm/core/crypto/federatedKeyless.d.mts +2 -2
- package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
- package/dist/esm/core/crypto/index.d.mts +2 -2
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/keyless.d.mts +2 -2
- package/dist/esm/core/crypto/keyless.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.d.mts +1 -1
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.d.mts +1 -1
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/privateKey.d.mts +1 -1
- package/dist/esm/core/crypto/privateKey.mjs +1 -1
- package/dist/esm/core/crypto/proof.d.mts +1 -1
- package/dist/esm/core/crypto/proof.mjs +1 -1
- package/dist/esm/core/crypto/publicKey.d.mts +1 -1
- package/dist/esm/core/crypto/publicKey.mjs +1 -1
- package/dist/esm/core/crypto/secp256k1.d.mts +1 -1
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/crypto/secp256r1.d.mts +1 -1
- package/dist/esm/core/crypto/secp256r1.mjs +1 -1
- package/dist/esm/core/crypto/signature.d.mts +1 -1
- package/dist/esm/core/crypto/signature.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.d.mts +1 -1
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/crypto/types.d.mts +1 -1
- package/dist/esm/core/crypto/utils.d.mts +1 -1
- package/dist/esm/core/crypto/utils.mjs +1 -1
- package/dist/esm/core/hex.d.mts +1 -1
- package/dist/esm/core/index.d.mts +2 -2
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/errors/index.d.mts +1 -1
- package/dist/esm/errors/index.mjs +1 -1
- package/dist/esm/{federatedKeyless-C8KXaSM1.d.mts → federatedKeyless-CxdU4W95.d.mts} +1 -1
- package/dist/esm/index.d.mts +3 -3
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/abstraction.d.mts +1 -1
- package/dist/esm/internal/abstraction.mjs +1 -1
- package/dist/esm/internal/account.d.mts +2 -2
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +2 -2
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.d.mts +1 -1
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +2 -2
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/faucet.d.mts +1 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +2 -2
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.d.mts +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.d.mts +3 -3
- package/dist/esm/internal/keyless.mjs +1 -1
- package/dist/esm/internal/object.d.mts +1 -1
- package/dist/esm/internal/object.mjs +1 -1
- package/dist/esm/internal/staking.d.mts +1 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/table.d.mts +1 -1
- package/dist/esm/internal/table.mjs +1 -1
- package/dist/esm/internal/transaction.d.mts +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +2 -2
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/utils/index.d.mts +1 -1
- package/dist/esm/internal/utils/index.mjs +1 -1
- package/dist/esm/internal/utils/utils.d.mts +1 -1
- package/dist/esm/internal/utils/utils.mjs +1 -1
- package/dist/esm/internal/view.d.mts +1 -1
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.d.mts +1 -1
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.d.mts +1 -1
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.d.mts +1 -1
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.d.mts +1 -1
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/chainId.d.mts +1 -1
- package/dist/esm/transactions/instances/chainId.mjs +1 -1
- package/dist/esm/transactions/instances/identifier.d.mts +1 -1
- package/dist/esm/transactions/instances/identifier.mjs +1 -1
- package/dist/esm/transactions/instances/index.d.mts +1 -1
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.d.mts +1 -1
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.d.mts +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.d.mts +1 -1
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.d.mts +1 -1
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.d.mts +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionArgument.d.mts +1 -1
- package/dist/esm/transactions/instances/transactionPayload.d.mts +1 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.d.mts +2 -2
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.d.mts +2 -2
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.d.mts +2 -2
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.d.mts +1 -1
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.d.mts +1 -1
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/transactions/types.d.mts +1 -1
- package/dist/esm/types/index.d.mts +1 -1
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/types/types.d.mts +1 -1
- package/dist/esm/types/types.mjs +1 -1
- package/dist/esm/utils/helpers.d.mts +1 -1
- package/dist/esm/utils/helpers.mjs +1 -1
- package/dist/esm/utils/index.d.mts +1 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/normalizeBundle.d.mts +1 -1
- package/dist/esm/utils/normalizeBundle.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/src/bcs/consts.ts +15 -1
- package/src/bcs/deserializer.ts +105 -0
- package/src/bcs/serializable/movePrimitives.ts +237 -1
- package/src/bcs/serializer.ts +111 -0
- package/src/internal/account.ts +13 -10
- package/src/types/types.ts +30 -0
- package/src/version.ts +1 -1
- package/dist/common/chunk-PW6UQAB2.js +0 -4
- package/dist/common/chunk-PW6UQAB2.js.map +0 -1
- package/dist/esm/chunk-56CNRT2K.mjs +0 -2
- package/dist/esm/chunk-56CNRT2K.mjs.map +0 -1
- package/dist/esm/chunk-CW35YAMN.mjs +0 -2
- package/dist/esm/chunk-DURSBMWP.mjs.map +0 -1
- package/dist/esm/chunk-EBMEXURY.mjs +0 -2
- package/dist/esm/chunk-EBMEXURY.mjs.map +0 -1
- package/dist/esm/chunk-EW45LLAP.mjs +0 -2
- package/dist/esm/chunk-ORMOQWWH.mjs +0 -2
- package/dist/esm/chunk-ORMOQWWH.mjs.map +0 -1
- package/dist/esm/chunk-XJJVJOX5.mjs +0 -2
- /package/dist/esm/{chunk-N6YTF76Q.mjs.map → chunk-3P474TWM.mjs.map} +0 -0
- /package/dist/esm/{chunk-Q4W3WJ2U.mjs.map → chunk-3Q4MUGFR.mjs.map} +0 -0
- /package/dist/esm/{chunk-TOBQ5UE6.mjs.map → chunk-43LWUUXS.mjs.map} +0 -0
- /package/dist/esm/{chunk-WSR5EBJM.mjs.map → chunk-5FNZUL2Y.mjs.map} +0 -0
- /package/dist/esm/{chunk-XKUIMGKU.mjs.map → chunk-6IWGTO2J.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZYE7UTJZ.mjs.map → chunk-C5UZZHA4.mjs.map} +0 -0
- /package/dist/esm/{chunk-MT2RJ7H3.mjs.map → chunk-DIFSO4N6.mjs.map} +0 -0
- /package/dist/esm/{chunk-HX6SDBEX.mjs.map → chunk-EM7NAPDX.mjs.map} +0 -0
- /package/dist/esm/{chunk-YZHAI55C.mjs.map → chunk-G3HAIETV.mjs.map} +0 -0
- /package/dist/esm/{chunk-EF4FA5I6.mjs.map → chunk-GRF3NBRO.mjs.map} +0 -0
- /package/dist/esm/{chunk-54WUP65H.mjs.map → chunk-I7UCQWRH.mjs.map} +0 -0
- /package/dist/esm/{chunk-C2ZO2L5W.mjs.map → chunk-KNVQ5OJ7.mjs.map} +0 -0
- /package/dist/esm/{chunk-XJJVJOX5.mjs.map → chunk-KUF4DKN5.mjs.map} +0 -0
- /package/dist/esm/{chunk-YSP6JG5G.mjs.map → chunk-L5EMB6TN.mjs.map} +0 -0
- /package/dist/esm/{chunk-CW35YAMN.mjs.map → chunk-LD3I4CYO.mjs.map} +0 -0
- /package/dist/esm/{chunk-DRBFLEZL.mjs.map → chunk-M2R4ECLZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-RGKRCZ36.mjs.map → chunk-MEG27LEV.mjs.map} +0 -0
- /package/dist/esm/{chunk-LA56UDUK.mjs.map → chunk-PYVKCTUN.mjs.map} +0 -0
- /package/dist/esm/{chunk-WCMW2L3P.mjs.map → chunk-QDJDZ3ON.mjs.map} +0 -0
- /package/dist/esm/{chunk-FGFLPH5K.mjs.map → chunk-RYOICF37.mjs.map} +0 -0
- /package/dist/esm/{chunk-AGAAGA2X.mjs.map → chunk-SQW3MYZL.mjs.map} +0 -0
- /package/dist/esm/{chunk-BCTM24ZZ.mjs.map → chunk-UQT4B7EQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-I7XT6L7S.mjs.map → chunk-VO3JD6U6.mjs.map} +0 -0
- /package/dist/esm/{chunk-GQ3UIDPQ.mjs.map → chunk-VS5NYRHW.mjs.map} +0 -0
- /package/dist/esm/{chunk-EFQZGHAO.mjs.map → chunk-XP66F4IY.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZABLJ2JJ.mjs.map → chunk-YDWD2GVM.mjs.map} +0 -0
- /package/dist/esm/{chunk-2XQKGWHQ.mjs.map → chunk-Z7NBE6RR.mjs.map} +0 -0
|
@@ -8,11 +8,23 @@ import {
|
|
|
8
8
|
MAX_U64_BIG_INT,
|
|
9
9
|
MAX_U8_NUMBER,
|
|
10
10
|
MAX_U256_BIG_INT,
|
|
11
|
+
MIN_I8_NUMBER,
|
|
12
|
+
MAX_I8_NUMBER,
|
|
13
|
+
MIN_I16_NUMBER,
|
|
14
|
+
MAX_I16_NUMBER,
|
|
15
|
+
MIN_I32_NUMBER,
|
|
16
|
+
MAX_I32_NUMBER,
|
|
17
|
+
MIN_I64_BIG_INT,
|
|
18
|
+
MAX_I64_BIG_INT,
|
|
19
|
+
MIN_I128_BIG_INT,
|
|
20
|
+
MAX_I128_BIG_INT,
|
|
21
|
+
MIN_I256_BIG_INT,
|
|
22
|
+
MAX_I256_BIG_INT,
|
|
11
23
|
} from "../consts";
|
|
12
24
|
import { Deserializer } from "../deserializer";
|
|
13
25
|
import { Serializable, Serializer, ensureBoolean, validateNumberInRange } from "../serializer";
|
|
14
26
|
import { TransactionArgument } from "../../transactions/instances/transactionArgument";
|
|
15
|
-
import { AnyNumber, Uint16, Uint32, Uint8, ScriptTransactionArgumentVariants } from "../../types";
|
|
27
|
+
import { AnyNumber, Uint16, Uint32, Uint8, Int8, Int16, Int32, ScriptTransactionArgumentVariants } from "../../types";
|
|
16
28
|
|
|
17
29
|
/**
|
|
18
30
|
* Represents a boolean value that can be serialized and deserialized.
|
|
@@ -326,3 +338,227 @@ export class U256 extends Serializable implements TransactionArgument {
|
|
|
326
338
|
return new U256(deserializer.deserializeU256());
|
|
327
339
|
}
|
|
328
340
|
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Represents an 8-bit signed integer (I8) value.
|
|
344
|
+
* This class extends the Serializable class and provides methods for serialization and deserialization of I8 values.
|
|
345
|
+
*
|
|
346
|
+
* @extends Serializable
|
|
347
|
+
* @group Implementation
|
|
348
|
+
* @category BCS
|
|
349
|
+
*/
|
|
350
|
+
export class I8 extends Serializable implements TransactionArgument {
|
|
351
|
+
public readonly value: Int8;
|
|
352
|
+
|
|
353
|
+
constructor(value: Int8) {
|
|
354
|
+
super();
|
|
355
|
+
validateNumberInRange(value, MIN_I8_NUMBER, MAX_I8_NUMBER);
|
|
356
|
+
this.value = value;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
serialize(serializer: Serializer): void {
|
|
360
|
+
serializer.serializeI8(this.value);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
serializeForEntryFunction(serializer: Serializer): void {
|
|
364
|
+
const bcsBytes = this.bcsToBytes();
|
|
365
|
+
serializer.serializeBytes(bcsBytes);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
serializeForScriptFunction(serializer: Serializer): void {
|
|
369
|
+
// Note: Script functions don't have variants for signed integers yet
|
|
370
|
+
// This will serialize as bytes
|
|
371
|
+
const bcsBytes = this.bcsToBytes();
|
|
372
|
+
serializer.serializeBytes(bcsBytes);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
static deserialize(deserializer: Deserializer): I8 {
|
|
376
|
+
return new I8(deserializer.deserializeI8());
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Represents a 16-bit signed integer (I16) value.
|
|
382
|
+
* This class extends the Serializable class and provides methods for serialization
|
|
383
|
+
* and deserialization of the I16 value.
|
|
384
|
+
*
|
|
385
|
+
* @extends Serializable
|
|
386
|
+
* @group Implementation
|
|
387
|
+
* @category BCS
|
|
388
|
+
*/
|
|
389
|
+
export class I16 extends Serializable implements TransactionArgument {
|
|
390
|
+
public readonly value: Int16;
|
|
391
|
+
|
|
392
|
+
constructor(value: Int16) {
|
|
393
|
+
super();
|
|
394
|
+
validateNumberInRange(value, MIN_I16_NUMBER, MAX_I16_NUMBER);
|
|
395
|
+
this.value = value;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
serialize(serializer: Serializer): void {
|
|
399
|
+
serializer.serializeI16(this.value);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
serializeForEntryFunction(serializer: Serializer): void {
|
|
403
|
+
const bcsBytes = this.bcsToBytes();
|
|
404
|
+
serializer.serializeBytes(bcsBytes);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
serializeForScriptFunction(serializer: Serializer): void {
|
|
408
|
+
const bcsBytes = this.bcsToBytes();
|
|
409
|
+
serializer.serializeBytes(bcsBytes);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
static deserialize(deserializer: Deserializer): I16 {
|
|
413
|
+
return new I16(deserializer.deserializeI16());
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Represents a 32-bit signed integer (I32) that can be serialized and deserialized.
|
|
419
|
+
* This class ensures that the value is within the valid range for an I32.
|
|
420
|
+
*
|
|
421
|
+
* @extends Serializable
|
|
422
|
+
* @group Implementation
|
|
423
|
+
* @category BCS
|
|
424
|
+
*/
|
|
425
|
+
export class I32 extends Serializable implements TransactionArgument {
|
|
426
|
+
public readonly value: Int32;
|
|
427
|
+
|
|
428
|
+
constructor(value: Int32) {
|
|
429
|
+
super();
|
|
430
|
+
validateNumberInRange(value, MIN_I32_NUMBER, MAX_I32_NUMBER);
|
|
431
|
+
this.value = value;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
serialize(serializer: Serializer): void {
|
|
435
|
+
serializer.serializeI32(this.value);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
serializeForEntryFunction(serializer: Serializer): void {
|
|
439
|
+
const bcsBytes = this.bcsToBytes();
|
|
440
|
+
serializer.serializeBytes(bcsBytes);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
serializeForScriptFunction(serializer: Serializer): void {
|
|
444
|
+
const bcsBytes = this.bcsToBytes();
|
|
445
|
+
serializer.serializeBytes(bcsBytes);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
static deserialize(deserializer: Deserializer): I32 {
|
|
449
|
+
return new I32(deserializer.deserializeI32());
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Represents a 64-bit signed integer (I64) and provides methods for serialization.
|
|
455
|
+
*
|
|
456
|
+
* This class ensures that the value is within the valid range for an I64 and provides
|
|
457
|
+
* functionality to serialize the value for various use cases, including entry functions
|
|
458
|
+
* and script functions.
|
|
459
|
+
*
|
|
460
|
+
* @extends Serializable
|
|
461
|
+
* @group Implementation
|
|
462
|
+
* @category BCS
|
|
463
|
+
*/
|
|
464
|
+
export class I64 extends Serializable implements TransactionArgument {
|
|
465
|
+
public readonly value: bigint;
|
|
466
|
+
|
|
467
|
+
constructor(value: AnyNumber) {
|
|
468
|
+
super();
|
|
469
|
+
validateNumberInRange(value, MIN_I64_BIG_INT, MAX_I64_BIG_INT);
|
|
470
|
+
this.value = BigInt(value);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
serialize(serializer: Serializer): void {
|
|
474
|
+
serializer.serializeI64(this.value);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
serializeForEntryFunction(serializer: Serializer): void {
|
|
478
|
+
const bcsBytes = this.bcsToBytes();
|
|
479
|
+
serializer.serializeBytes(bcsBytes);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
serializeForScriptFunction(serializer: Serializer): void {
|
|
483
|
+
const bcsBytes = this.bcsToBytes();
|
|
484
|
+
serializer.serializeBytes(bcsBytes);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
static deserialize(deserializer: Deserializer): I64 {
|
|
488
|
+
return new I64(deserializer.deserializeI64());
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Represents a 128-bit signed integer value.
|
|
494
|
+
* This class provides methods for serialization and deserialization
|
|
495
|
+
* of I128 values, ensuring that the values are within the valid range.
|
|
496
|
+
*
|
|
497
|
+
* @extends Serializable
|
|
498
|
+
* @group Implementation
|
|
499
|
+
* @category BCS
|
|
500
|
+
*/
|
|
501
|
+
export class I128 extends Serializable implements TransactionArgument {
|
|
502
|
+
public readonly value: bigint;
|
|
503
|
+
|
|
504
|
+
constructor(value: AnyNumber) {
|
|
505
|
+
super();
|
|
506
|
+
validateNumberInRange(value, MIN_I128_BIG_INT, MAX_I128_BIG_INT);
|
|
507
|
+
this.value = BigInt(value);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
serialize(serializer: Serializer): void {
|
|
511
|
+
serializer.serializeI128(this.value);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
serializeForEntryFunction(serializer: Serializer): void {
|
|
515
|
+
const bcsBytes = this.bcsToBytes();
|
|
516
|
+
serializer.serializeBytes(bcsBytes);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
serializeForScriptFunction(serializer: Serializer): void {
|
|
520
|
+
const bcsBytes = this.bcsToBytes();
|
|
521
|
+
serializer.serializeBytes(bcsBytes);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
static deserialize(deserializer: Deserializer): I128 {
|
|
525
|
+
return new I128(deserializer.deserializeI128());
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Represents a 256-bit signed integer (I256) that extends the Serializable class.
|
|
531
|
+
* This class provides methods for serialization and deserialization of I256 values,
|
|
532
|
+
* ensuring that the values are within the valid range.
|
|
533
|
+
*
|
|
534
|
+
* @extends Serializable
|
|
535
|
+
* @group Implementation
|
|
536
|
+
* @category BCS
|
|
537
|
+
*/
|
|
538
|
+
export class I256 extends Serializable implements TransactionArgument {
|
|
539
|
+
public readonly value: bigint;
|
|
540
|
+
|
|
541
|
+
constructor(value: AnyNumber) {
|
|
542
|
+
super();
|
|
543
|
+
validateNumberInRange(value, MIN_I256_BIG_INT, MAX_I256_BIG_INT);
|
|
544
|
+
this.value = BigInt(value);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
serialize(serializer: Serializer): void {
|
|
548
|
+
serializer.serializeI256(this.value);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
serializeForEntryFunction(serializer: Serializer): void {
|
|
552
|
+
const bcsBytes = this.bcsToBytes();
|
|
553
|
+
serializer.serializeBytes(bcsBytes);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
serializeForScriptFunction(serializer: Serializer): void {
|
|
557
|
+
const bcsBytes = this.bcsToBytes();
|
|
558
|
+
serializer.serializeBytes(bcsBytes);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
static deserialize(deserializer: Deserializer): I256 {
|
|
562
|
+
return new I256(deserializer.deserializeI256());
|
|
563
|
+
}
|
|
564
|
+
}
|
package/src/bcs/serializer.ts
CHANGED
|
@@ -9,6 +9,18 @@ import {
|
|
|
9
9
|
MAX_U64_BIG_INT,
|
|
10
10
|
MAX_U8_NUMBER,
|
|
11
11
|
MAX_U256_BIG_INT,
|
|
12
|
+
MIN_I8_NUMBER,
|
|
13
|
+
MAX_I8_NUMBER,
|
|
14
|
+
MIN_I16_NUMBER,
|
|
15
|
+
MAX_I16_NUMBER,
|
|
16
|
+
MIN_I32_NUMBER,
|
|
17
|
+
MAX_I32_NUMBER,
|
|
18
|
+
MIN_I64_BIG_INT,
|
|
19
|
+
MAX_I64_BIG_INT,
|
|
20
|
+
MIN_I128_BIG_INT,
|
|
21
|
+
MAX_I128_BIG_INT,
|
|
22
|
+
MIN_I256_BIG_INT,
|
|
23
|
+
MAX_I256_BIG_INT,
|
|
12
24
|
} from "./consts";
|
|
13
25
|
import { Hex } from "../core/hex";
|
|
14
26
|
import { AnyNumber, Uint16, Uint32, Uint8 } from "../types";
|
|
@@ -338,6 +350,105 @@ export class Serializer {
|
|
|
338
350
|
this.serializeU128(high);
|
|
339
351
|
}
|
|
340
352
|
|
|
353
|
+
/**
|
|
354
|
+
* Serializes an 8-bit signed integer value.
|
|
355
|
+
* BCS layout for "int8": One byte. Binary format in little-endian representation.
|
|
356
|
+
*
|
|
357
|
+
* @param value - The 8-bit signed integer value to serialize.
|
|
358
|
+
* @group Implementation
|
|
359
|
+
* @category BCS
|
|
360
|
+
*/
|
|
361
|
+
@checkNumberRange(MIN_I8_NUMBER, MAX_I8_NUMBER)
|
|
362
|
+
serializeI8(value: number) {
|
|
363
|
+
this.serializeWithFunction(DataView.prototype.setInt8, 1, value);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Serializes a 16-bit signed integer value into a binary format.
|
|
368
|
+
* BCS layout for "int16": Two bytes. Binary format in little-endian representation.
|
|
369
|
+
*
|
|
370
|
+
* @param value - The 16-bit signed integer value to serialize.
|
|
371
|
+
* @group Implementation
|
|
372
|
+
* @category BCS
|
|
373
|
+
*/
|
|
374
|
+
@checkNumberRange(MIN_I16_NUMBER, MAX_I16_NUMBER)
|
|
375
|
+
serializeI16(value: number) {
|
|
376
|
+
this.serializeWithFunction(DataView.prototype.setInt16, 2, value);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Serializes a 32-bit signed integer value into a binary format.
|
|
381
|
+
*
|
|
382
|
+
* @param value - The 32-bit signed integer value to serialize.
|
|
383
|
+
* @group Implementation
|
|
384
|
+
* @category BCS
|
|
385
|
+
*/
|
|
386
|
+
@checkNumberRange(MIN_I32_NUMBER, MAX_I32_NUMBER)
|
|
387
|
+
serializeI32(value: number) {
|
|
388
|
+
this.serializeWithFunction(DataView.prototype.setInt32, 4, value);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Serializes a 64-bit signed integer into a format suitable for storage or transmission.
|
|
393
|
+
* This function uses two's complement representation for negative values.
|
|
394
|
+
*
|
|
395
|
+
* @param value - The 64-bit signed integer to serialize.
|
|
396
|
+
* @group Implementation
|
|
397
|
+
* @category BCS
|
|
398
|
+
*/
|
|
399
|
+
@checkNumberRange(MIN_I64_BIG_INT, MAX_I64_BIG_INT)
|
|
400
|
+
serializeI64(value: AnyNumber) {
|
|
401
|
+
const val = BigInt(value);
|
|
402
|
+
// Convert to unsigned representation using two's complement
|
|
403
|
+
const unsigned = val < 0 ? (BigInt(1) << BigInt(64)) + val : val;
|
|
404
|
+
const low = unsigned & BigInt(MAX_U32_NUMBER);
|
|
405
|
+
const high = unsigned >> BigInt(32);
|
|
406
|
+
|
|
407
|
+
// write little endian number
|
|
408
|
+
this.serializeU32(Number(low));
|
|
409
|
+
this.serializeU32(Number(high));
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Serializes a 128-bit signed integer value.
|
|
414
|
+
*
|
|
415
|
+
* @param value - The 128-bit signed integer value to serialize.
|
|
416
|
+
* @group Implementation
|
|
417
|
+
* @category BCS
|
|
418
|
+
*/
|
|
419
|
+
@checkNumberRange(MIN_I128_BIG_INT, MAX_I128_BIG_INT)
|
|
420
|
+
serializeI128(value: AnyNumber) {
|
|
421
|
+
const val = BigInt(value);
|
|
422
|
+
// Convert to unsigned representation using two's complement
|
|
423
|
+
const unsigned = val < 0 ? (BigInt(1) << BigInt(128)) + val : val;
|
|
424
|
+
const low = unsigned & MAX_U64_BIG_INT;
|
|
425
|
+
const high = unsigned >> BigInt(64);
|
|
426
|
+
|
|
427
|
+
// write little endian number
|
|
428
|
+
this.serializeU64(low);
|
|
429
|
+
this.serializeU64(high);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Serializes a 256-bit signed integer value.
|
|
434
|
+
*
|
|
435
|
+
* @param value - The 256-bit signed integer value to serialize.
|
|
436
|
+
* @group Implementation
|
|
437
|
+
* @category BCS
|
|
438
|
+
*/
|
|
439
|
+
@checkNumberRange(MIN_I256_BIG_INT, MAX_I256_BIG_INT)
|
|
440
|
+
serializeI256(value: AnyNumber) {
|
|
441
|
+
const val = BigInt(value);
|
|
442
|
+
// Convert to unsigned representation using two's complement
|
|
443
|
+
const unsigned = val < 0 ? (BigInt(1) << BigInt(256)) + val : val;
|
|
444
|
+
const low = unsigned & MAX_U128_BIG_INT;
|
|
445
|
+
const high = unsigned >> BigInt(128);
|
|
446
|
+
|
|
447
|
+
// write little endian number
|
|
448
|
+
this.serializeU128(low);
|
|
449
|
+
this.serializeU128(high);
|
|
450
|
+
}
|
|
451
|
+
|
|
341
452
|
/**
|
|
342
453
|
* Serializes a 32-bit unsigned integer as a variable-length ULEB128 encoded byte array.
|
|
343
454
|
* BCS uses uleb128 encoding in two cases: (1) lengths of variable-length sequences and (2) tags of enum values
|
package/src/internal/account.ts
CHANGED
|
@@ -1355,6 +1355,7 @@ async function getMultiKeysForPublicKey(args: {
|
|
|
1355
1355
|
const whereCondition: any = {
|
|
1356
1356
|
public_key: { _eq: baseKey.toString() },
|
|
1357
1357
|
public_key_type: { _eq: variant },
|
|
1358
|
+
account_public_key: { _is_null: false },
|
|
1358
1359
|
...(includeUnverified ? {} : { is_public_key_used: { _eq: true } }),
|
|
1359
1360
|
};
|
|
1360
1361
|
|
|
@@ -1371,16 +1372,18 @@ async function getMultiKeysForPublicKey(args: {
|
|
|
1371
1372
|
originMethod: "getMultiKeysForPublicKey",
|
|
1372
1373
|
});
|
|
1373
1374
|
|
|
1374
|
-
const authKeys = data
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1375
|
+
const authKeys = data
|
|
1376
|
+
.filter((entry) => entry.account_public_key !== null)
|
|
1377
|
+
.map((entry) => {
|
|
1378
|
+
switch (entry.signature_type) {
|
|
1379
|
+
case "multi_ed25519_signature":
|
|
1380
|
+
return MultiEd25519PublicKey.deserializeWithoutLength(Deserializer.fromHex(entry.account_public_key!));
|
|
1381
|
+
case "multi_key_signature":
|
|
1382
|
+
return MultiKey.deserialize(Deserializer.fromHex(entry.account_public_key!));
|
|
1383
|
+
default:
|
|
1384
|
+
throw new Error(`Unknown multi-signature type: ${entry.signature_type}`);
|
|
1385
|
+
}
|
|
1386
|
+
});
|
|
1384
1387
|
return authKeys;
|
|
1385
1388
|
}
|
|
1386
1389
|
|
package/src/types/types.ts
CHANGED
|
@@ -252,6 +252,36 @@ export type Uint128 = bigint;
|
|
|
252
252
|
*/
|
|
253
253
|
export type Uint256 = bigint;
|
|
254
254
|
|
|
255
|
+
/**
|
|
256
|
+
* A signed 8-bit integer.
|
|
257
|
+
*/
|
|
258
|
+
export type Int8 = number;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* A signed 16-bit integer.
|
|
262
|
+
*/
|
|
263
|
+
export type Int16 = number;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* A signed 32-bit integer.
|
|
267
|
+
*/
|
|
268
|
+
export type Int32 = number;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* A signed 64-bit integer.
|
|
272
|
+
*/
|
|
273
|
+
export type Int64 = bigint;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* A signed 128-bit integer.
|
|
277
|
+
*/
|
|
278
|
+
export type Int128 = bigint;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* A signed 256-bit integer.
|
|
282
|
+
*/
|
|
283
|
+
export type Int256 = bigint;
|
|
284
|
+
|
|
255
285
|
/**
|
|
256
286
|
* A number or a bigint value.
|
|
257
287
|
*/
|
package/src/version.ts
CHANGED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var N=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var h=(t,e,r,n)=>{for(var s=n>1?void 0:n?C(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=(n?c(e,r,s):c(s))||s);return n&&s&&N(e,r,s),s};var u=class extends Error{constructor(e,r){super(e),this.invalidReason=r}};var _utils = require('@noble/hashes/utils');var O=(n=>(n.TOO_SHORT="too_short",n.INVALID_LENGTH="invalid_length",n.INVALID_HEX_CHARS="invalid_hex_chars",n))(O||{}),_= exports.j =class t{constructor(e){this.data=e}toUint8Array(){return this.data}toStringWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromHexString(e){let r=e;if(r.startsWith("0x")&&(r=r.slice(2)),r.length===0)throw new u("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(r.length%2!==0)throw new u("Hex string must be an even number of hex characters.","invalid_length");try{return new t(_utils.hexToBytes.call(void 0, r))}catch(n){throw new u(`Hex string contains invalid hex characters: ${_optionalChain([n, 'optionalAccess', _2 => _2.message])}`,"invalid_hex_chars")}}static fromHexInput(e){return e instanceof Uint8Array?new t(e):t.fromHexString(e)}static hexInputToUint8Array(e){return e instanceof Uint8Array?e:t.fromHexString(e).toUint8Array()}static hexInputToString(e){return t.fromHexInput(e).toString()}static hexInputToStringWithoutPrefix(e){return t.fromHexInput(e).toStringWithoutPrefix()}static isValid(e){try{return t.fromHexString(e),{valid:!0}}catch(r){return{valid:!1,invalidReason:_optionalChain([r, 'optionalAccess', _3 => _3.invalidReason]),invalidReasonMessage:_optionalChain([r, 'optionalAccess', _4 => _4.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((r,n)=>r===e.data[n])}},_e= exports.k =t=>new TextDecoder().decode(_.fromHexInput(t).toUint8Array());var v=255,T= exports.c =65535,x= exports.d =4294967295,b= exports.e =18446744073709551615n,A= exports.f =340282366920938463463374607431768211455n,I= exports.g =115792089237316195423570985008687907853269984665640564039457584007913129639935n;var m=class{bcsToBytes(){let e=new l;return this.serialize(e),e.toUint8Array()}bcsToHex(){let e=this.bcsToBytes();return _.fromHexInput(e)}toStringWithoutPrefix(){return this.bcsToHex().toStringWithoutPrefix()}toString(){return`0x${this.toStringWithoutPrefix()}`}},l= exports.m =class{constructor(e=64){if(e<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(e),this.offset=0}ensureBufferWillHandleSize(e){for(;this.buffer.byteLength<this.offset+e;){let r=new ArrayBuffer(this.buffer.byteLength*2);new Uint8Array(r).set(new Uint8Array(this.buffer)),this.buffer=r}}appendToBuffer(e){this.ensureBufferWillHandleSize(e.length),new Uint8Array(this.buffer,this.offset).set(e),this.offset+=e.length}serializeWithFunction(e,r,n){this.ensureBufferWillHandleSize(r);let s=new DataView(this.buffer,this.offset);e.apply(s,[0,n,!0]),this.offset+=r}serializeStr(e){let r=new TextEncoder;this.serializeBytes(r.encode(e))}serializeBytes(e){this.serializeU32AsUleb128(e.length),this.appendToBuffer(e)}serializeFixedBytes(e){this.appendToBuffer(e)}serializeBool(e){D(e);let r=e?1:0;this.appendToBuffer(new Uint8Array([r]))}serializeU8(e){this.appendToBuffer(new Uint8Array([e]))}serializeU16(e){this.serializeWithFunction(DataView.prototype.setUint16,2,e)}serializeU32(e){this.serializeWithFunction(DataView.prototype.setUint32,4,e)}serializeU64(e){let r=BigInt(e)&BigInt(x),n=BigInt(e)>>BigInt(32);this.serializeU32(Number(r)),this.serializeU32(Number(n))}serializeU128(e){let r=BigInt(e)&b,n=BigInt(e)>>BigInt(64);this.serializeU64(r),this.serializeU64(n)}serializeU256(e){let r=BigInt(e)&A,n=BigInt(e)>>BigInt(128);this.serializeU128(r),this.serializeU128(n)}serializeU32AsUleb128(e){let r=e,n=[];for(;r>>>7;)n.push(r&127|128),r>>>=7;n.push(r),this.appendToBuffer(new Uint8Array(n))}toUint8Array(){return new Uint8Array(this.buffer).slice(0,this.offset)}serialize(e){e.serialize(this)}serializeVector(e){this.serializeU32AsUleb128(e.length),e.forEach(r=>{r.serialize(this)})}serializeOption(e,r){let n=e!==void 0;this.serializeBool(n),n&&(typeof e=="string"?this.serializeStr(e):e instanceof Uint8Array?r!==void 0?this.serializeFixedBytes(e):this.serializeBytes(e):e.serialize(this))}serializeOptionStr(e){e===void 0?this.serializeU32AsUleb128(0):(this.serializeU32AsUleb128(1),this.serializeStr(e))}};h([f(0,v)],l.prototype,"serializeU8",1),h([f(0,T)],l.prototype,"serializeU16",1),h([f(0,x)],l.prototype,"serializeU32",1),h([f(BigInt(0),b)],l.prototype,"serializeU64",1),h([f(BigInt(0),A)],l.prototype,"serializeU128",1),h([f(BigInt(0),I)],l.prototype,"serializeU256",1),h([f(0,x)],l.prototype,"serializeU32AsUleb128",1);function D(t){if(typeof t!="boolean")throw new Error(`${t} is not a boolean value`)}var H=(t,e,r)=>`${t} is out of range: [${e}, ${r}]`;function F(t,e,r){let n=BigInt(t);if(n>BigInt(r)||n<BigInt(e))throw new Error(H(t,e,r))}function f(t,e){return(r,n,s)=>{let o=s.value;return s.value=function(g){return F(g,t,e),o.apply(this,[g])},s}}var P=(s=>(s.JSON="application/json",s.BCS="application/x-bcs",s.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",s.BCS_VIEW_FUNCTION="application/x.aptos.view_function+bcs",s))(P||{}),W= exports.r =(i=>(i[i.Bool=0]="Bool",i[i.U8=1]="U8",i[i.U64=2]="U64",i[i.U128=3]="U128",i[i.Address=4]="Address",i[i.Signer=5]="Signer",i[i.Vector=6]="Vector",i[i.Struct=7]="Struct",i[i.U16=8]="U16",i[i.U32=9]="U32",i[i.U256=10]="U256",i[i.I8=11]="I8",i[i.I16=12]="I16",i[i.I32=13]="I32",i[i.I64=14]="I64",i[i.I128=15]="I128",i[i.I256=16]="I256",i[i.Reference=254]="Reference",i[i.Generic=255]="Generic",i))(W||{}),M= exports.s =(p=>(p[p.U8=0]="U8",p[p.U64=1]="U64",p[p.U128=2]="U128",p[p.Address=3]="Address",p[p.U8Vector=4]="U8Vector",p[p.Bool=5]="Bool",p[p.U16=6]="U16",p[p.U32=7]="U32",p[p.U256=8]="U256",p[p.Serialized=9]="Serialized",p))(M||{}),z= exports.t =(s=>(s[s.Script=0]="Script",s[s.EntryFunction=2]="EntryFunction",s[s.Multisig=3]="Multisig",s[s.Payload=4]="Payload",s))(z||{}),G= exports.u =(e=>(e[e.V1=0]="V1",e))(G||{}),L= exports.v =(n=>(n[n.Script=0]="Script",n[n.EntryFunction=1]="EntryFunction",n[n.Empty=2]="Empty",n))(L||{}),$= exports.w =(e=>(e[e.V1=0]="V1",e))($||{}),q= exports.x =(r=>(r[r.MultiAgentTransaction=0]="MultiAgentTransaction",r[r.FeePayerTransaction=1]="FeePayerTransaction",r))(q||{}),X= exports.y =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.MultiAgent=2]="MultiAgent",o[o.FeePayer=3]="FeePayer",o[o.SingleSender=4]="SingleSender",o))(X||{}),j= exports.z =(c=>(c[c.Ed25519=0]="Ed25519",c[c.MultiEd25519=1]="MultiEd25519",c[c.SingleKey=2]="SingleKey",c[c.MultiKey=3]="MultiKey",c[c.NoAccountAuthenticator=4]="NoAccountAuthenticator",c[c.Abstraction=5]="Abstraction",c))(j||{}),K= exports.A =(n=>(n.Ed25519="ed25519",n.Secp256k1="secp256k1",n.Secp256r1="secp256r1",n))(K||{}),Y= exports.B =(o=>(o[o.Ed25519=0]="Ed25519",o[o.Secp256k1=1]="Secp256k1",o[o.Secp256r1=2]="Secp256r1",o[o.Keyless=3]="Keyless",o[o.FederatedKeyless=4]="FederatedKeyless",o))(Y||{});function Ue(t){switch(t){case 0:return"ed25519";case 1:return"secp256k1";case 2:return"secp256r1";case 3:return"keyless";case 4:return"federated_keyless";default:throw new Error("Unknown public key variant")}}var Z=(s=>(s[s.Ed25519=0]="Ed25519",s[s.Secp256k1=1]="Secp256k1",s[s.WebAuthn=2]="WebAuthn",s[s.Keyless=3]="Keyless",s))(Z||{}),Q= exports.E =(e=>(e[e.Ed25519=0]="Ed25519",e))(Q||{}),J= exports.F =(e=>(e[e.Ed25519=0]="Ed25519",e))(J||{}),V= exports.G =(e=>(e[e.ZkProof=0]="ZkProof",e))(V||{}),ee= exports.H =(e=>(e[e.Groth16=0]="Groth16",e))(ee||{}),te= exports.I =(g=>(g.Pending="pending_transaction",g.User="user_transaction",g.Genesis="genesis_transaction",g.BlockMetadata="block_metadata_transaction",g.StateCheckpoint="state_checkpoint_transaction",g.Validator="validator_transaction",g.BlockEpilogue="block_epilogue_transaction",g))(te||{});function ve(t){return t.type==="pending_transaction"}function Te(t){return t.type==="user_transaction"}function Ie(t){return t.type==="genesis_transaction"}function Me(t){return t.type==="block_metadata_transaction"}function Ee(t){return t.type==="state_checkpoint_transaction"}function Be(t){return t.type==="validator_transaction"}function Ne(t){return t.type==="block_epilogue_transaction"}function Ce(t){return"signature"in t&&t.type==="ed25519_signature"}function ke(t){return"signature"in t&&t.signature==="secp256k1_ecdsa_signature"}function we(t){return t.type==="multi_agent_signature"}function Oe(t){return t.type==="fee_payer_signature"}function De(t){return t.type==="multi_ed25519_signature"}function He(t){return t.type==="single_sender"}var re=(n=>(n.PRIVATE="private",n.PUBLIC="public",n.FRIEND="friend",n))(re||{}),ne= exports.X =(s=>(s.STORE="store",s.DROP="drop",s.KEY="key",s.COPY="copy",s))(ne||{}),se= exports.Y =(r=>(r.VALIDATOR="validator",r.FULL_NODE="full_node",r))(se||{}),oe= exports.Z =(s=>(s[s.Ed25519=0]="Ed25519",s[s.MultiEd25519=1]="MultiEd25519",s[s.SingleKey=2]="SingleKey",s[s.MultiKey=3]="MultiKey",s))(oe||{}),ie= exports._ =(r=>(r[r.Ed25519=0]="Ed25519",r[r.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",r))(ie||{}),E= exports.$ =(o=>(o[o.DeriveAuid=251]="DeriveAuid",o[o.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",o[o.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",o[o.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",o[o.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",o))(E||{});var pe=(y=>(y.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",y.INVALID_HEX_CHARS="invalid_hex_chars",y.TOO_SHORT="too_short",y.TOO_LONG="too_long",y.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",y.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",y.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",y.INVALID_PADDING_STRICTNESS="INVALID_PADDING_STRICTNESS",y))(pe||{}),a=class a extends m{constructor(e){if(super(),e.length!==a.LENGTH)throw new u("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=e}isSpecial(){return this.data.slice(0,this.data.length-1).every(e=>e===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let e=_utils.bytesToHex.call(void 0, this.data);return this.isSpecial()&&(e=e[e.length-1]),e}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toStringShort(){return`0x${this.toStringShortWithoutPrefix()}`}toStringShortWithoutPrefix(){let e=_utils.bytesToHex.call(void 0, this.data).replace(/^0+/,"");return e===""?"0":e}toUint8Array(){return this.data}serialize(e){e.serializeFixedBytes(this.data)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(3),e.serialize(this)}static deserialize(e){let r=e.deserializeFixedBytes(a.LENGTH);return new a(r)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new u("Hex string must start with a leading 0x.","leading_zero_x_required");let r=a.fromString(e);if(e.length!==a.LONG_STRING_LENGTH+2)if(r.isSpecial()){if(e.length!==3)throw new u(`The given hex string ${e} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,"INVALID_PADDING_ZEROES")}else throw new u(`The given hex string ${e} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return r}static fromString(e,{maxMissingChars:r=4}={}){let n=e;if(e.startsWith("0x")&&(n=e.slice(2)),n.length===0)throw new u("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(n.length>64)throw new u("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");if(r>63||r<0)throw new u(`maxMissingChars must be between or equal to 0 and 63. Received ${r}`,"INVALID_PADDING_STRICTNESS");let s;try{s=_utils.hexToBytes.call(void 0, n.padStart(64,"0"))}catch(c){throw new u(`Hex characters are invalid: ${_optionalChain([c, 'optionalAccess', _5 => _5.message])}`,"invalid_hex_chars")}let o=new a(s);if(n.length<64-r&&!o.isSpecial())throw new u(`Hex string is too short, must be ${64-r} to 64 chars long, excluding the leading 0x. You may need to fix
|
|
2
|
-
the addresss by padding it with 0s before passing it to \`fromString\` (e.g. <addressString>.padStart(64, '0')).
|
|
3
|
-
Received ${e}`,"too_short");return o}static from(e,{maxMissingChars:r=4}={}){return typeof e=="string"?a.fromString(e,{maxMissingChars:r}):e instanceof Uint8Array?new a(e):e}static fromStrict(e){return typeof e=="string"?a.fromStringStrict(e):e instanceof Uint8Array?new a(e):e}static isValid(e){try{return e.strict?a.fromStrict(e.input):a.from(e.input),{valid:!0}}catch(r){return{valid:!1,invalidReason:_optionalChain([r, 'optionalAccess', _6 => _6.invalidReason]),invalidReasonMessage:_optionalChain([r, 'optionalAccess', _7 => _7.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((r,n)=>r===e.data[n])}};a.LENGTH=32,a.LONG_STRING_LENGTH=64,a.ZERO=a.from("0x0"),a.ONE=a.from("0x1"),a.TWO=a.from("0x2"),a.THREE=a.from("0x3"),a.FOUR=a.from("0x4"),a.A=a.from("0xA");var d=a;var _sha3 = require('@noble/hashes/sha3');var U=(t,e)=>{let r=t.bcsToBytes(),n=typeof e=="string"?Buffer.from(e,"utf8"):e,s=new Uint8Array([...r,...n,254]);return new d(_sha3.sha3_256.call(void 0, s))},Ve= exports.da =(t,e)=>{let r=t.bcsToBytes(),n=typeof e=="string"?Buffer.from(e,"utf8"):e,s=new Uint8Array([...r,...n,255]);return new d(_sha3.sha3_256.call(void 0, s))},et= exports.ea =(t,e)=>{let r=t.bcsToBytes(),n=e.bcsToBytes(),s=new Uint8Array([...r,...n,252]);return new d(_sha3.sha3_256.call(void 0, s))},tt= exports.fa =(t,e,r)=>{let n=`${e}::${r}`;return U(t,n)};var _jsbase64 = require('js-base64');async function it(t){return new Promise(e=>{setTimeout(e,t)})}function at(t){return t instanceof Error?t.message:String(t)}var pt=()=>Math.floor(Date.now()/1e3);function ct(t){let e=new Date(t*1e3);return e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),Math.floor(e.getTime()/1e3)}function ut(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),r=e+"==".substring(0,(3-e.length%3)%3);return _jsbase64.decode.call(void 0, r)}function dt(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4!==0;)e+="=";return new Uint8Array(Buffer.from(e,"base64"))}var gt=(t,e)=>t*10**e,lt= exports.na =(t,e)=>t/10**e,B=t=>{let e="";for(let r=2;r<t.length;r+=2)e+=String.fromCharCode(parseInt(t.substring(r,r+2),16));return e},yt= exports.oa =t=>{let{account_address:e,module_name:r,struct_name:n}=t,s=B(r),o=B(n);return`${e}::${s}::${o}`},ht= exports.pa =t=>typeof t=="object"&&!Array.isArray(t)&&t!==null&&"account_address"in t&&"module_name"in t&&"struct_name"in t&&typeof t.account_address=="string"&&typeof t.module_name=="string"&&typeof t.struct_name=="string";function ft(t){let e=t.split("::");if(e.length!==3)throw new Error(`Invalid function ${t}`);let r=e[0],n=e[1],s=e[2];return{moduleAddress:r,moduleName:n,functionName:s}}function _t(t){let e=t.split("::");return e.length===3&&d.isValid({input:e[0]}).valid}function xt(t,e=6,r=5){return`${t.slice(0,e)}...${t.slice(-r)}`}var ue="0x1::aptos_coin::AptosCoin",mt=d.A.toStringLong();function de(t){let e=/0x[0-9a-fA-F]+/g;return t.replace(e,r=>d.from(r,{maxMissingChars:63}).toStringShort())}function bt(t){let e=de(t);return e===ue?d.A:U(d.A,e)}exports.a = h; exports.b = v; exports.c = T; exports.d = x; exports.e = b; exports.f = A; exports.g = I; exports.h = u; exports.i = O; exports.j = _; exports.k = _e; exports.l = m; exports.m = l; exports.n = D; exports.o = H; exports.p = F; exports.q = P; exports.r = W; exports.s = M; exports.t = z; exports.u = G; exports.v = L; exports.w = $; exports.x = q; exports.y = X; exports.z = j; exports.A = K; exports.B = Y; exports.C = Ue; exports.D = Z; exports.E = Q; exports.F = J; exports.G = V; exports.H = ee; exports.I = te; exports.J = ve; exports.K = Te; exports.L = Ie; exports.M = Me; exports.N = Ee; exports.O = Be; exports.P = Ne; exports.Q = Ce; exports.R = ke; exports.S = we; exports.T = Oe; exports.U = De; exports.V = He; exports.W = re; exports.X = ne; exports.Y = se; exports.Z = oe; exports._ = ie; exports.$ = E; exports.aa = pe; exports.ba = d; exports.ca = U; exports.da = Ve; exports.ea = et; exports.fa = tt; exports.ga = it; exports.ha = at; exports.ia = pt; exports.ja = ct; exports.ka = ut; exports.la = dt; exports.ma = gt; exports.na = lt; exports.oa = yt; exports.pa = ht; exports.qa = ft; exports.ra = _t; exports.sa = xt; exports.ta = bt;
|
|
4
|
-
//# sourceMappingURL=chunk-PW6UQAB2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kent/aptos-ts-sdk/dist/common/chunk-PW6UQAB2.js","../../src/core/common.ts","../../src/core/hex.ts","../../src/core/accountAddress.ts"],"names":["ParsingError","message","invalidReason","HexInvalidReason","Hex","_Hex","data","bytesToHex"],"mappings":"AAAA,ilBAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CCQhM,IAAMA,CAAAA,CAAN,MAAA,QAA8B,KAAM,CAkBzC,WAAA,CAAYC,CAAAA,CAAiBC,CAAAA,CAAkB,CAC7C,KAAA,CAAMD,CAAO,CAAA,CACb,IAAA,CAAK,aAAA,CAAgBC,CACvB,CACF,CAAA,CC3BA,4CAAuC,IAS3BC,CAAAA,CAAAA,CAAAA,CAAAA,EAAAA,CACVA,CAAAA,CAAA,SAAA,CAAY,WAAA,CACZA,CAAAA,CAAA,cAAA,CAAiB,gBAAA,CACjBA,CAAAA,CAAA,iBAAA,CAAoB,mBAAA,CAHVA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAgCCC,CAAAA,aAAN,MAAMC,CAAI,CAUf,WAAA,CAAYC,CAAAA,CAAkB,CAC5B,IAAA,CAAK,IAAA,CAAOA,CACd,CAaA,YAAA,CAAA,CAA2B,CACzB,OAAO,IAAA,CAAK,IACd,CASA,qBAAA,CAAA,CAAgC,CAC9B,OAAOC,+BAAAA,IAAW,CAAK,IAAI,CAC7B,CASA,QAAA,CAAA,CAAmB,CACjB,MAAO,CAAA,EAAA,EAAK,IAAA,CAAK,qBAAA,CAAsB,CAAC,CAAA,CAAA;ACkVsB;AAnWV,SAAA","file":"/Users/kent/aptos-ts-sdk/dist/common/chunk-PW6UQAB2.js","sourcesContent":[null,"// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This error is used to explain why parsing failed.\n * @group Implementation\n * @category Serialization\n */\nexport class ParsingError<T> extends Error {\n /**\n * This provides a programmatic way to access why parsing failed. Downstream devs\n * might want to use this to build their own error messages if the default error\n * messages are not suitable for their use case. This should be an enum.\n * @group Implementation\n * @category Serialization\n */\n public invalidReason: T;\n\n /**\n * Creates an instance of the error with a specified message and invalid reason.\n *\n * @param message The error message that describes the issue.\n * @param invalidReason The reason why the input is considered invalid.\n * @group Implementation\n * @category Serialization\n */\n constructor(message: string, invalidReason: T) {\n super(message);\n this.invalidReason = invalidReason;\n }\n}\n\n/**\n * Whereas ParsingError is thrown when parsing fails, e.g. in a fromString function,\n * this type is returned from \"defensive\" functions like isValid.\n * @group Implementation\n * @category Serialization\n */\nexport type ParsingResult<T> = {\n /**\n * True if valid, false otherwise.\n * @group Implementation\n * @category Serialization\n */\n valid: boolean;\n\n /**\n * If valid is false, this will be a code explaining why parsing failed.\n * @group Implementation\n * @category Serialization\n */\n invalidReason?: T;\n\n /**\n * If valid is false, this will be a string explaining why parsing failed.\n * @group Implementation\n * @category Serialization\n */\n invalidReasonMessage?: string;\n};\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bytesToHex, hexToBytes } from \"@noble/hashes/utils\";\nimport { ParsingError, ParsingResult } from \"./common\";\nimport { HexInput } from \"../types\";\n\n/**\n * Provides reasons for parsing failures related to hexadecimal values.\n * @group Implementation\n * @category Serialization\n */\nexport enum HexInvalidReason {\n TOO_SHORT = \"too_short\",\n INVALID_LENGTH = \"invalid_length\",\n INVALID_HEX_CHARS = \"invalid_hex_chars\",\n}\n\n/**\n * NOTE: Do not use this class when working with account addresses; use AccountAddress instead.\n * When accepting hex data as input to a function, prefer to accept HexInput and\n *\n * A helper class for working with hex data. Hex data, when represented as a string,\n * generally looks like this, for example: 0xaabbcc, 45cd32, etc.\n *\n * then use the static helper methods of this class to convert it into the desired\n * format. This enables the greatest flexibility for the developer.\n *\n * Example usage:\n * ```typescript\n * getTransactionByHash(txnHash: HexInput): Promise<Transaction> {\n * const txnHashString = Hex.fromHexInput(txnHash).toString();\n * return await getTransactionByHashInner(txnHashString);\n * }\n * ```\n * This call to `Hex.fromHexInput().toString()` converts the HexInput to a hex string\n * with a leading 0x prefix, regardless of what the input format was.\n *\n * Other ways to chain the functions together:\n * - `Hex.fromHexString({ hexInput: \"0x1f\" }).toUint8Array()`\n * - `new Hex([1, 3]).toStringWithoutPrefix()`\n * @group Implementation\n * @category Serialization\n */\nexport class Hex {\n private readonly data: Uint8Array;\n\n /**\n * Create a new Hex instance from a Uint8Array.\n *\n * @param data - The Uint8Array containing the data to initialize the Hex instance.\n * @group Implementation\n * @category Serialization\n */\n constructor(data: Uint8Array) {\n this.data = data;\n }\n\n // ===\n // Methods for representing an instance of Hex as other types.\n // ===\n\n /**\n * Get the inner hex data as a Uint8Array. The inner data is already a Uint8Array, so no conversion takes place.\n *\n * @returns Hex data as Uint8Array\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data;\n }\n\n /**\n * Get the hex data as a string without the 0x prefix.\n *\n * @returns Hex string without 0x prefix\n * @group Implementation\n * @category Serialization\n */\n toStringWithoutPrefix(): string {\n return bytesToHex(this.data);\n }\n\n /**\n * Get the hex data as a string with the 0x prefix.\n *\n * @returns Hex string with 0x prefix\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n return `0x${this.toStringWithoutPrefix()}`;\n }\n\n // ===\n // Methods for creating an instance of Hex from other types.\n // ===\n\n /**\n * Converts a hex string into a Hex instance, allowing for both prefixed and non-prefixed formats.\n *\n * @param str - A hex string, with or without the 0x prefix.\n *\n * @throws ParsingError - If the hex string is too short, has an odd number of characters, or contains invalid hex characters.\n *\n * @returns Hex - The resulting Hex instance created from the provided string.\n * @group Implementation\n * @category Serialization\n */\n static fromHexString(str: string): Hex {\n let input = str;\n\n if (input.startsWith(\"0x\")) {\n input = input.slice(2);\n }\n\n if (input.length === 0) {\n throw new ParsingError(\n \"Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.\",\n HexInvalidReason.TOO_SHORT,\n );\n }\n\n if (input.length % 2 !== 0) {\n throw new ParsingError(\"Hex string must be an even number of hex characters.\", HexInvalidReason.INVALID_LENGTH);\n }\n\n try {\n return new Hex(hexToBytes(input));\n } catch (error: any) {\n throw new ParsingError(\n `Hex string contains invalid hex characters: ${error?.message}`,\n HexInvalidReason.INVALID_HEX_CHARS,\n );\n }\n }\n\n /**\n * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Hex instance.\n * This function is useful for transforming hexadecimal representations into a structured Hex object for further manipulation.\n *\n * @param hexInput - A HexInput which can be a string or Uint8Array.\n * @returns A Hex instance created from the provided hexInput.\n * @group Implementation\n * @category Serialization\n */\n static fromHexInput(hexInput: HexInput): Hex {\n if (hexInput instanceof Uint8Array) return new Hex(hexInput);\n return Hex.fromHexString(hexInput);\n }\n\n /**\n * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Uint8Array.\n *\n * @param hexInput - A HexInput which can be a string or Uint8Array.\n * @returns A Uint8Array created from the provided hexInput.\n */\n static hexInputToUint8Array(hexInput: HexInput): Uint8Array {\n if (hexInput instanceof Uint8Array) return hexInput;\n return Hex.fromHexString(hexInput).toUint8Array();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string with '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string with '0x' prefix (e.g., \"0x1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToString(\"1234\") // returns \"0x1234\"\n * Hex.hexInputToString(\"0x1234\") // returns \"0x1234\"\n * Hex.hexInputToString(new Uint8Array([0x12, 0x34])) // returns \"0x1234\"\n * ```\n */\n static hexInputToString(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toString();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string without '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string without '0x' prefix (e.g., \"1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToStringWithoutPrefix(\"1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(\"0x1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(new Uint8Array([0x12, 0x34])) // returns \"1234\"\n * ```\n */\n static hexInputToStringWithoutPrefix(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toStringWithoutPrefix();\n }\n\n // ===\n // Methods for checking validity.\n // ===\n\n /**\n * Check if the provided string is a valid hexadecimal representation.\n *\n * @param str - A hex string representing byte data.\n *\n * @returns An object containing:\n * - valid: A boolean indicating whether the string is valid.\n * - invalidReason: The reason for invalidity if the string is not valid.\n * - invalidReasonMessage: A message explaining why the string is invalid.\n * @group Implementation\n * @category Serialization\n */\n static isValid(str: string): ParsingResult<HexInvalidReason> {\n try {\n Hex.fromHexString(str);\n return { valid: true };\n } catch (error: any) {\n return {\n valid: false,\n invalidReason: error?.invalidReason,\n invalidReasonMessage: error?.message,\n };\n }\n }\n\n /**\n * Determine if two Hex instances are equal by comparing their underlying byte data.\n *\n * @param other The Hex instance to compare to.\n * @returns true if the Hex instances are equal, false if not.\n * @group Implementation\n * @category Serialization\n */\n equals(other: Hex): boolean {\n if (this.data.length !== other.data.length) return false;\n return this.data.every((value, index) => value === other.data[index]);\n }\n}\n\nexport const hexToAsciiString = (hex: string) => new TextDecoder().decode(Hex.fromHexInput(hex).toUint8Array());\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bytesToHex, hexToBytes } from \"@noble/hashes/utils\";\nimport { Serializable, Serializer } from \"../bcs/serializer\";\nimport { Deserializer } from \"../bcs/deserializer\";\nimport { ParsingError, ParsingResult } from \"./common\";\nimport { TransactionArgument } from \"../transactions/instances/transactionArgument\";\nimport { HexInput, ScriptTransactionArgumentVariants } from \"../types\";\n\n/**\n * Provides reasons for an address was invalid.\n * @group Implementation\n * @category Serialization\n */\nexport enum AddressInvalidReason {\n INCORRECT_NUMBER_OF_BYTES = \"incorrect_number_of_bytes\",\n INVALID_HEX_CHARS = \"invalid_hex_chars\",\n TOO_SHORT = \"too_short\",\n TOO_LONG = \"too_long\",\n LEADING_ZERO_X_REQUIRED = \"leading_zero_x_required\",\n LONG_FORM_REQUIRED_UNLESS_SPECIAL = \"long_form_required_unless_special\",\n INVALID_PADDING_ZEROES = \"INVALID_PADDING_ZEROES\",\n INVALID_PADDING_STRICTNESS = \"INVALID_PADDING_STRICTNESS\",\n}\n\n/**\n * The input for an account address, which can be either a hexadecimal string or a standard account address.\n * @group Implementation\n * @category Serialization\n */\nexport type AccountAddressInput = HexInput | AccountAddress;\n\n/**\n * NOTE: Only use this class for account addresses. For other hex data, e.g. transaction\n * hashes, use the Hex class.\n *\n * AccountAddress is used for working with account addresses. Account addresses, when\n * represented as a string, generally look like these examples:\n * - 0x1\n * - 0xaa86fe99004361f747f91342ca13c426ca0cccb0c1217677180c9493bad6ef0c\n *\n * Proper formatting and parsing of account addresses is defined by AIP-40.\n * To learn more about the standard, read the AIP here:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * The comments in this class make frequent reference to the LONG and SHORT formats,\n * as well as \"special\" addresses. To learn what these refer to see AIP-40.\n * @group Implementation\n * @category Serialization\n */\nexport class AccountAddress extends Serializable implements TransactionArgument {\n /**\n * This is the internal representation of an account address.\n * @group Implementation\n * @category Serialization\n */\n readonly data: Uint8Array;\n\n /**\n * The number of bytes that make up an account address.\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH: number = 32;\n\n /**\n * The length of an address string in LONG form without a leading 0x.\n * @group Implementation\n * @category Serialization\n */\n static readonly LONG_STRING_LENGTH: number = 64;\n\n static ZERO: AccountAddress = AccountAddress.from(\"0x0\");\n\n static ONE: AccountAddress = AccountAddress.from(\"0x1\");\n\n static TWO: AccountAddress = AccountAddress.from(\"0x2\");\n\n static THREE: AccountAddress = AccountAddress.from(\"0x3\");\n\n static FOUR: AccountAddress = AccountAddress.from(\"0x4\");\n\n static A: AccountAddress = AccountAddress.from(\"0xA\");\n\n /**\n * Creates an instance of AccountAddress from a Uint8Array.\n *\n * This function ensures that the input data is exactly 32 bytes long, which is required for a valid account address.\n *\n * @param input A Uint8Array representing an account address.\n * @throws ParsingError if the input length is not equal to 32 bytes.\n * @group Implementation\n * @category Serialization\n */\n constructor(input: Uint8Array) {\n super();\n if (input.length !== AccountAddress.LENGTH) {\n throw new ParsingError(\n \"AccountAddress data should be exactly 32 bytes long\",\n AddressInvalidReason.INCORRECT_NUMBER_OF_BYTES,\n );\n }\n this.data = input;\n }\n\n /**\n * Determines if the address is classified as special, which is defined as 0x0 to 0xf inclusive.\n * In other words, the last byte of the address must be < 0b10000 (16)\n * and every other byte must be zero.\n *\n * For more information on how special addresses are defined, see AIP-40:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @returns true if the address is special, false otherwise.\n * @group Implementation\n * @category Serialization\n */\n isSpecial(): boolean {\n return (\n this.data.slice(0, this.data.length - 1).every((byte) => byte === 0) && this.data[this.data.length - 1] < 0b10000\n );\n }\n // ===\n // Methods for representing an instance of AccountAddress as other types.\n // ===\n\n /**\n * Return the AccountAddress as a string as per AIP-40.\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n * This representation returns special addresses in SHORT form (0xf)\n * and other addresses in LONG form (0x + 64 characters).\n *\n * @returns AccountAddress as a string conforming to AIP-40.\n * @group Implementation\n * @category Serialization\n */\n toString(): `0x${string}` {\n return `0x${this.toStringWithoutPrefix()}`;\n }\n\n /**\n * Return the AccountAddress as a string conforming to AIP-40 but without the leading 0x.\n *\n * NOTE: Prefer to use `toString` where possible.\n *\n * @returns AccountAddress as a string without the leading 0x.\n * @group Implementation\n * @category Serialization\n */\n toStringWithoutPrefix(): string {\n let hex = bytesToHex(this.data);\n if (this.isSpecial()) {\n hex = hex[hex.length - 1];\n }\n return hex;\n }\n\n /**\n * Convert the account address to a string in LONG format, which is always 0x followed by 64 hex characters.\n *\n * NOTE: Prefer to use `toString` where possible, as it formats special addresses using the SHORT form (no leading 0s).\n *\n * @returns AccountAddress as a string in LONG form.\n * @group Implementation\n * @category Serialization\n */\n toStringLong(): `0x${string}` {\n return `0x${this.toStringLongWithoutPrefix()}`;\n }\n\n /**\n * Returns the account address as a string in LONG form without a leading 0x.\n * This function will include leading zeroes and will produce a string of 64 hex characters.\n *\n * NOTE: Prefer to use `toString` where possible, as it formats special addresses using the SHORT form (no leading 0s).\n *\n * @returns {string} The account address in LONG form.\n * @group Implementation\n * @category Serialization\n */\n toStringLongWithoutPrefix(): string {\n return bytesToHex(this.data);\n }\n\n /**\n * Convert the account address to a string in SHORT format, which is 0x followed by the shortest\n * possible representation (no leading zeros).\n *\n * @returns AccountAddress as a string in SHORT form.\n * @group Implementation\n * @category Serialization\n */\n toStringShort(): `0x${string}` {\n return `0x${this.toStringShortWithoutPrefix()}`;\n }\n\n /**\n * Returns a lossless short string representation of the address by trimming leading zeros.\n * If the address consists of all zeros, returns \"0\".\n *\n * @returns A string representation of the address without leading zeros\n * @group Implementation\n * @category Serialization\n */\n toStringShortWithoutPrefix(): string {\n const hex = bytesToHex(this.data).replace(/^0+/, \"\");\n return hex === \"\" ? \"0\" : hex;\n }\n\n /**\n * Get the inner data as a Uint8Array.\n * The inner data is already a Uint8Array, so no conversion takes place.\n *\n * @returns Hex data as Uint8Array\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data;\n }\n\n /**\n * Serialize the AccountAddress to a Serializer instance's data buffer.\n * @param serializer The serializer to serialize the AccountAddress to.\n * @returns void\n * @example\n * const serializer = new Serializer();\n * const address = AccountAddress.fromString(\"0x1\");\n * address.serialize(serializer);\n * const bytes = serializer.toUint8Array();\n * // `bytes` is now the BCS-serialized address.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.data);\n }\n\n /**\n * Serializes the current instance into a byte sequence suitable for entry functions.\n * This allows for the proper encoding of data when interacting with entry functions in the blockchain.\n *\n * @param serializer - The serializer instance used to convert the data into bytes.\n * @group Implementation\n * @category Serialization\n */\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n /**\n * Serializes the current instance for use in a script function by encoding it into a byte sequence.\n * This process involves serializing the variant index and the instance data, making it suitable for transmission.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category Serialization\n */\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.Address);\n serializer.serialize(this);\n }\n\n /**\n * Deserialize an AccountAddress from the byte buffer in a Deserializer instance.\n * This function allows you to convert a byte representation of an AccountAddress into an instance of AccountAddress.\n * @param deserializer The deserializer to deserialize the AccountAddress from.\n * @returns An instance of AccountAddress.\n * @example\n * const bytes = hexToBytes(\"0x0102030405060708091011121314151617181920212223242526272829303132\");\n * const deserializer = new Deserializer(bytes);\n * const address = AccountAddress.deserialize(deserializer);\n * // `address` is now an instance of AccountAddress.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): AccountAddress {\n const bytes = deserializer.deserializeFixedBytes(AccountAddress.LENGTH);\n return new AccountAddress(bytes);\n }\n\n // ===\n // Methods for creating an instance of AccountAddress from other types.\n // ===\n\n /**\n * NOTE: This function has strict parsing behavior. For relaxed behavior, please use\n * the `fromString` function.\n *\n * Creates an instance of AccountAddress from a hex string.\n *\n * This function allows only the strictest formats defined by AIP-40. In short this\n * means only the following formats are accepted:\n *\n * - LONG\n * - SHORT for special addresses\n *\n * Where:\n * - LONG is defined as 0x + 64 hex characters.\n * - SHORT for special addresses is 0x0 to 0xf inclusive without padding zeroes.\n *\n * This means the following are not accepted:\n * - SHORT for non-special addresses.\n * - Any address without a leading 0x.\n *\n * @param input - A hex string representing an account address.\n *\n * @throws {ParsingError} If the hex string does not start with 0x or is not in a valid format.\n *\n * @remarks\n *\n * This function has strict parsing behavior. For relaxed behavior, please use the `fromString` function.\n *\n * @see AIP-40 documentation for more details on address formats:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @returns An instance of AccountAddress.\n * @group Implementation\n * @category Serialization\n */\n static fromStringStrict(input: string): AccountAddress {\n // Assert the string starts with 0x.\n if (!input.startsWith(\"0x\")) {\n throw new ParsingError(\"Hex string must start with a leading 0x.\", AddressInvalidReason.LEADING_ZERO_X_REQUIRED);\n }\n\n const address = AccountAddress.fromString(input);\n\n // Check if the address is in LONG form. If it is not, this is only allowed for\n // special addresses, in which case we check it is in proper SHORT form.\n if (input.length !== AccountAddress.LONG_STRING_LENGTH + 2) {\n if (!address.isSpecial()) {\n throw new ParsingError(\n `The given hex string ${input} is not a special address, it must be represented as 0x + 64 chars.`,\n AddressInvalidReason.LONG_FORM_REQUIRED_UNLESS_SPECIAL,\n );\n } else if (input.length !== 3) {\n // 0x + one hex char is the only valid SHORT form for special addresses.\n throw new ParsingError(\n // eslint-disable-next-line max-len\n `The given hex string ${input} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,\n AddressInvalidReason.INVALID_PADDING_ZEROES,\n );\n }\n }\n\n return address;\n }\n\n /**\n * NOTE: This function has relaxed parsing behavior. For strict behavior, please use\n * the `fromStringStrict` function. Where possible use `fromStringStrict` rather than this\n * function, `fromString`.\n *\n * Creates an instance of AccountAddress from a hex string.\n *\n * This function allows all formats defined by AIP-40. In short this means the\n * following formats are accepted:\n *\n * - LONG, with or without leading 0x\n * - SHORT*, with or without leading 0x\n *\n * Where:\n * - LONG is 64 hex characters.\n * - SHORT* is 1 to 63 hex characters inclusive. The address can have missing values up to `maxMissingChars` before it is padded.\n * - Padding zeroes are allowed, e.g. 0x0123 is valid.\n *\n * Learn more about the different address formats by reading AIP-40:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @param input A hex string representing an account address.\n * @param args.maxMissingChars The number of characters that can be missing in a padded address before it is invalid.\n *\n * @returns An instance of AccountAddress.\n *\n * @throws ParsingError if the hex string is too short, too long, or contains invalid characters.\n * @group Implementation\n * @category Serialization\n */\n static fromString(input: string, { maxMissingChars = 4 }: { maxMissingChars?: number } = {}): AccountAddress {\n let parsedInput = input;\n // Remove leading 0x for parsing.\n if (input.startsWith(\"0x\")) {\n parsedInput = input.slice(2);\n }\n\n // Ensure the address string is at least 1 character long.\n if (parsedInput.length === 0) {\n throw new ParsingError(\n \"Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.\",\n AddressInvalidReason.TOO_SHORT,\n );\n }\n\n // Ensure the address string is not longer than 64 characters.\n if (parsedInput.length > 64) {\n throw new ParsingError(\n \"Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.\",\n AddressInvalidReason.TOO_LONG,\n );\n }\n\n // Ensure that the maxMissingChars is between or equal to 0 and 63.\n if (maxMissingChars > 63 || maxMissingChars < 0) {\n throw new ParsingError(\n `maxMissingChars must be between or equal to 0 and 63. Received ${maxMissingChars}`,\n AddressInvalidReason.INVALID_PADDING_STRICTNESS,\n );\n }\n\n let addressBytes: Uint8Array;\n try {\n // Pad the address with leading zeroes, so it is 64 chars long and then convert\n // the hex string to bytes. Every two characters in a hex string constitutes a\n // single byte. So a 64 length hex string becomes a 32 byte array.\n addressBytes = hexToBytes(parsedInput.padStart(64, \"0\"));\n } catch (error: any) {\n // At this point the only way this can fail is if the hex string contains\n // invalid characters.\n throw new ParsingError(`Hex characters are invalid: ${error?.message}`, AddressInvalidReason.INVALID_HEX_CHARS);\n }\n\n const address = new AccountAddress(addressBytes);\n\n // Cannot pad the address if it has more than maxMissingChars missing.\n if (parsedInput.length < 64 - maxMissingChars) {\n if (!address.isSpecial()) {\n throw new ParsingError(\n `Hex string is too short, must be ${64 - maxMissingChars} to 64 chars long, excluding the leading 0x. You may need to fix \nthe addresss by padding it with 0s before passing it to \\`fromString\\` (e.g. <addressString>.padStart(64, '0')). \nReceived ${input}`,\n AddressInvalidReason.TOO_SHORT,\n );\n }\n }\n\n return address;\n }\n\n /**\n * Convenience method for creating an AccountAddress from various input types.\n * This function accepts a string, Uint8Array, or an existing AccountAddress instance and returns the corresponding\n * AccountAddress.\n *\n * @param input - The input to convert into an AccountAddress. This can be a string representation of an address, a Uint8Array,\n * or an existing AccountAddress.\n * @param args.maxMissingChars The number of characters that can be missing in a padded address before it is invalid.\n * @group Implementation\n * @category Serialization\n */\n static from(input: AccountAddressInput, { maxMissingChars = 4 }: { maxMissingChars?: number } = {}): AccountAddress {\n if (typeof input === \"string\") {\n return AccountAddress.fromString(input, { maxMissingChars });\n }\n if (input instanceof Uint8Array) {\n return new AccountAddress(input);\n }\n return input;\n }\n\n /**\n * Create an AccountAddress from various input types, including strings, Uint8Array, and AccountAddress instances.\n *\n * @param input - The input to convert into an AccountAddress, which can be a string, a Uint8Array, or an AccountAddress.\n * @group Implementation\n * @category Serialization\n */\n static fromStrict(input: AccountAddressInput): AccountAddress {\n if (typeof input === \"string\") {\n return AccountAddress.fromStringStrict(input);\n }\n if (input instanceof Uint8Array) {\n return new AccountAddress(input);\n }\n return input;\n }\n // ===\n // Methods for checking validity.\n // ===\n\n /**\n * Check if the provided input is a valid AccountAddress.\n *\n * @param args - The arguments for validation.\n * @param args.input - A hex string representing an account address.\n * @param args.strict - If true, use strict parsing behavior; if false, use relaxed parsing behavior.\n *\n * @returns An object indicating whether the address is valid. If valid, valid = true; if not, valid = false with additional details.\n * If the address is invalid, invalidReason will explain why it is invalid, and invalidReasonMessage will provide the error message.\n * @group Implementation\n * @category Serialization\n */\n static isValid(args: { input: AccountAddressInput; strict?: boolean }): ParsingResult<AddressInvalidReason> {\n try {\n if (args.strict) {\n AccountAddress.fromStrict(args.input);\n } else {\n AccountAddress.from(args.input);\n }\n return { valid: true };\n } catch (error: any) {\n return {\n valid: false,\n invalidReason: error?.invalidReason,\n invalidReasonMessage: error?.message,\n };\n }\n }\n\n /**\n * Determine if two AccountAddresses are equal based on their underlying byte data.\n *\n * @param other - The AccountAddress to compare to.\n * @returns true if the AccountAddresses are equal, false if not.\n * @group Implementation\n * @category Serialization\n */\n equals(other: AccountAddress): boolean {\n if (this.data.length !== other.data.length) return false;\n return this.data.every((value, index) => value === other.data[index]);\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bcs/consts.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Uint8, Uint16, Uint32, Uint64, Uint128, Uint256 } from \"../types\";\n\n// Upper bound values for uint8, uint16, uint64 etc. These are all derived as\n// 2^N - 1, where N is the number of bits in the type.\nexport const MAX_U8_NUMBER: Uint8 = 255;\nexport const MAX_U16_NUMBER: Uint16 = 65535;\nexport const MAX_U32_NUMBER: Uint32 = 4294967295;\nexport const MAX_U64_BIG_INT: Uint64 = 18446744073709551615n;\nexport const MAX_U128_BIG_INT: Uint128 = 340282366920938463463374607431768211455n;\nexport const MAX_U256_BIG_INT: Uint256 =\n 115792089237316195423570985008687907853269984665640564039457584007913129639935n;\n"],"mappings":"AAOO,IAAMA,EAAuB,IACvBC,EAAyB,MACzBC,EAAyB,WACzBC,EAA0B,sBAC1BC,EAA4B,yCAC5BC,EACX","names":["MAX_U8_NUMBER","MAX_U16_NUMBER","MAX_U32_NUMBER","MAX_U64_BIG_INT","MAX_U128_BIG_INT","MAX_U256_BIG_INT"]}
|