@aptos-labs/ts-sdk 6.3.0 → 6.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/{account-DGpxrkAn.d.ts → account-2FUAPVPW.d.ts} +15 -4
- package/dist/common/chunk-L5DUJTE3.js +4 -0
- package/dist/common/chunk-L5DUJTE3.js.map +1 -0
- package/dist/common/cli/index.d.ts +1 -1
- package/dist/common/cli/index.js +1 -1
- package/dist/common/index.d.ts +2 -2
- package/dist/common/index.js +34 -34
- package/dist/common/index.js.map +1 -1
- package/dist/esm/{Ed25519Account-BCt2cu_M.d.mts → Ed25519Account-DpZh3fRy.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-Dg0ejXHy.d.mts → account-sIOs_9XJ.d.mts} +15 -4
- 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 +1 -1
- 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/aptosConfig.mjs +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 +1 -1
- package/dist/esm/bcs/deserializer.d.mts +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-UBPX6GOS.mjs → chunk-226FBOWQ.mjs} +2 -2
- package/dist/esm/{chunk-LTZRUAGD.mjs → chunk-2DQRUJUC.mjs} +2 -2
- package/dist/esm/chunk-2EBXCCLB.mjs +2 -0
- package/dist/esm/chunk-2EBXCCLB.mjs.map +1 -0
- package/dist/esm/{chunk-R7PCBRRT.mjs → chunk-2YA4KQUV.mjs} +2 -2
- package/dist/esm/{chunk-POQ4FT4E.mjs → chunk-3ZC6F5SJ.mjs} +2 -2
- package/dist/esm/{chunk-NTREJSOS.mjs → chunk-4KEZEYCV.mjs} +2 -2
- package/dist/esm/chunk-6T2OBPIF.mjs +4 -0
- package/dist/esm/chunk-6T2OBPIF.mjs.map +1 -0
- package/dist/esm/{chunk-2VBY2V4Z.mjs → chunk-A5H5VKUI.mjs} +2 -2
- package/dist/esm/{chunk-QFUXOL34.mjs → chunk-DPHBSAZQ.mjs} +2 -2
- package/dist/esm/{chunk-CD3EZCI5.mjs → chunk-F4RJMSAW.mjs} +2 -2
- package/dist/esm/{chunk-UYG4XVVO.mjs → chunk-FAOLAKLJ.mjs} +2 -2
- package/dist/esm/{chunk-5LMLIRGK.mjs → chunk-GJYLYE6R.mjs} +2 -2
- package/dist/esm/{chunk-C2KVLMPH.mjs → chunk-GYYSHYO5.mjs} +2 -2
- package/dist/esm/{chunk-ASFFADWS.mjs → chunk-IEW452EO.mjs} +2 -2
- package/dist/esm/{chunk-2CH5QB7U.mjs → chunk-IZF6POVR.mjs} +2 -2
- package/dist/esm/chunk-KKPH2JUV.mjs +2 -0
- package/dist/esm/chunk-KKPH2JUV.mjs.map +1 -0
- package/dist/esm/{chunk-F4LHBGG2.mjs → chunk-LVZ7QMUH.mjs} +2 -2
- package/dist/esm/{chunk-J73MMLF7.mjs → chunk-MKTR4U2R.mjs} +2 -2
- package/dist/esm/{chunk-EIWPAECI.mjs → chunk-NHRPXEUE.mjs} +2 -2
- package/dist/esm/{chunk-OAK2V35A.mjs → chunk-NNXTS2GB.mjs} +2 -2
- package/dist/esm/{chunk-UPHD2B4I.mjs → chunk-NPWYZVHE.mjs} +2 -2
- package/dist/esm/{chunk-WD3SPNH7.mjs → chunk-NTMFADQ7.mjs} +2 -2
- package/dist/esm/{chunk-A7SQEK23.mjs → chunk-QE5MOGUI.mjs} +2 -2
- package/dist/esm/chunk-RB2GC7FW.mjs +2 -0
- package/dist/esm/chunk-RUKFK3OC.mjs +2 -0
- package/dist/esm/chunk-RUKFK3OC.mjs.map +1 -0
- package/dist/esm/chunk-RYCI4VKO.mjs +2 -0
- package/dist/esm/{chunk-WVKZFOPV.mjs.map → chunk-RYCI4VKO.mjs.map} +1 -1
- package/dist/esm/{chunk-TSPG5VED.mjs → chunk-RZNP3WG4.mjs} +2 -2
- package/dist/esm/{chunk-TEI33TO7.mjs → chunk-TBIK7DML.mjs} +2 -2
- package/dist/esm/chunk-UVNAHETD.mjs +2 -0
- package/dist/esm/{chunk-YJVBGKWM.mjs.map → chunk-UVNAHETD.mjs.map} +1 -1
- package/dist/esm/{chunk-E3DHFXN4.mjs → chunk-WOPHK7LB.mjs} +2 -2
- package/dist/esm/{chunk-F5KAWYF5.mjs → chunk-WZZ7PJ3X.mjs} +2 -2
- package/dist/esm/{chunk-QRW7MQDA.mjs → chunk-ZOSOF6ST.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-BYLu31Sa.d.mts → federatedKeyless-Cuo0IGJ6.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 +1 -1
- 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/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/serializable/movePrimitives.ts +21 -15
- package/src/bcs/serializable/moveStructs.ts +5 -5
- package/src/bcs/serializer.ts +19 -0
- package/src/core/accountAddress.ts +3 -3
- package/src/version.ts +1 -1
- package/dist/common/chunk-2VR6ONNW.js +0 -4
- package/dist/common/chunk-2VR6ONNW.js.map +0 -1
- package/dist/esm/chunk-5HHC2YG4.mjs +0 -2
- package/dist/esm/chunk-66F7RP7K.mjs +0 -2
- package/dist/esm/chunk-66F7RP7K.mjs.map +0 -1
- package/dist/esm/chunk-BT742BFQ.mjs +0 -2
- package/dist/esm/chunk-BT742BFQ.mjs.map +0 -1
- package/dist/esm/chunk-FDHHQUS3.mjs +0 -4
- package/dist/esm/chunk-FDHHQUS3.mjs.map +0 -1
- package/dist/esm/chunk-WFZFTRRS.mjs +0 -2
- package/dist/esm/chunk-WFZFTRRS.mjs.map +0 -1
- package/dist/esm/chunk-WVKZFOPV.mjs +0 -2
- package/dist/esm/chunk-YJVBGKWM.mjs +0 -2
- /package/dist/esm/{chunk-UBPX6GOS.mjs.map → chunk-226FBOWQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-LTZRUAGD.mjs.map → chunk-2DQRUJUC.mjs.map} +0 -0
- /package/dist/esm/{chunk-R7PCBRRT.mjs.map → chunk-2YA4KQUV.mjs.map} +0 -0
- /package/dist/esm/{chunk-POQ4FT4E.mjs.map → chunk-3ZC6F5SJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-NTREJSOS.mjs.map → chunk-4KEZEYCV.mjs.map} +0 -0
- /package/dist/esm/{chunk-2VBY2V4Z.mjs.map → chunk-A5H5VKUI.mjs.map} +0 -0
- /package/dist/esm/{chunk-QFUXOL34.mjs.map → chunk-DPHBSAZQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-CD3EZCI5.mjs.map → chunk-F4RJMSAW.mjs.map} +0 -0
- /package/dist/esm/{chunk-UYG4XVVO.mjs.map → chunk-FAOLAKLJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-5LMLIRGK.mjs.map → chunk-GJYLYE6R.mjs.map} +0 -0
- /package/dist/esm/{chunk-C2KVLMPH.mjs.map → chunk-GYYSHYO5.mjs.map} +0 -0
- /package/dist/esm/{chunk-ASFFADWS.mjs.map → chunk-IEW452EO.mjs.map} +0 -0
- /package/dist/esm/{chunk-2CH5QB7U.mjs.map → chunk-IZF6POVR.mjs.map} +0 -0
- /package/dist/esm/{chunk-F4LHBGG2.mjs.map → chunk-LVZ7QMUH.mjs.map} +0 -0
- /package/dist/esm/{chunk-J73MMLF7.mjs.map → chunk-MKTR4U2R.mjs.map} +0 -0
- /package/dist/esm/{chunk-EIWPAECI.mjs.map → chunk-NHRPXEUE.mjs.map} +0 -0
- /package/dist/esm/{chunk-OAK2V35A.mjs.map → chunk-NNXTS2GB.mjs.map} +0 -0
- /package/dist/esm/{chunk-UPHD2B4I.mjs.map → chunk-NPWYZVHE.mjs.map} +0 -0
- /package/dist/esm/{chunk-WD3SPNH7.mjs.map → chunk-NTMFADQ7.mjs.map} +0 -0
- /package/dist/esm/{chunk-A7SQEK23.mjs.map → chunk-QE5MOGUI.mjs.map} +0 -0
- /package/dist/esm/{chunk-5HHC2YG4.mjs.map → chunk-RB2GC7FW.mjs.map} +0 -0
- /package/dist/esm/{chunk-TSPG5VED.mjs.map → chunk-RZNP3WG4.mjs.map} +0 -0
- /package/dist/esm/{chunk-TEI33TO7.mjs.map → chunk-TBIK7DML.mjs.map} +0 -0
- /package/dist/esm/{chunk-E3DHFXN4.mjs.map → chunk-WOPHK7LB.mjs.map} +0 -0
- /package/dist/esm/{chunk-F5KAWYF5.mjs.map → chunk-WZZ7PJ3X.mjs.map} +0 -0
- /package/dist/esm/{chunk-QRW7MQDA.mjs.map → chunk-ZOSOF6ST.mjs.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bcs/serializer.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n MAX_U128_BIG_INT,\n MAX_U16_NUMBER,\n MAX_U32_NUMBER,\n MAX_U64_BIG_INT,\n MAX_U8_NUMBER,\n MAX_U256_BIG_INT,\n MIN_I8_NUMBER,\n MAX_I8_NUMBER,\n MIN_I16_NUMBER,\n MAX_I16_NUMBER,\n MIN_I32_NUMBER,\n MAX_I32_NUMBER,\n MIN_I64_BIG_INT,\n MAX_I64_BIG_INT,\n MIN_I128_BIG_INT,\n MAX_I128_BIG_INT,\n MIN_I256_BIG_INT,\n MAX_I256_BIG_INT,\n} from \"./consts\";\nimport { Hex } from \"../core/hex\";\nimport { AnyNumber, Uint16, Uint32, Uint8 } from \"../types\";\nimport { TEXT_ENCODER } from \"../utils/const\";\n\n/**\n * This class serves as a base class for all serializable types. It facilitates\n * composable serialization of complex types and enables the serialization of\n * instances to their BCS (Binary Canonical Serialization) representation.\n * @group Implementation\n * @category BCS\n */\nexport abstract class Serializable {\n abstract serialize(serializer: Serializer): void;\n\n /**\n * Serializes a `Serializable` value to its BCS representation.\n * This function is the TypeScript SDK equivalent of `bcs::to_bytes` in Move.\n * @returns the BCS representation of the Serializable instance as a byte buffer.\n * @group Implementation\n * @category BCS\n */\n bcsToBytes(): Uint8Array {\n const serializer = new Serializer();\n this.serialize(serializer);\n return serializer.toUint8Array();\n }\n\n /**\n * Converts the BCS-serialized bytes of a value into a Hex instance.\n * This function provides a Hex representation of the BCS-serialized data for easier handling and manipulation.\n * @returns A Hex instance with the BCS-serialized bytes loaded into its underlying Uint8Array.\n * @group Implementation\n * @category BCS\n */\n bcsToHex(): Hex {\n const bcsBytes = this.bcsToBytes();\n return Hex.fromHexInput(bcsBytes);\n }\n\n /**\n * Returns the hex string representation of the `Serializable` value without the 0x prefix.\n * @returns the hex format as a string without `0x` prefix.\n */\n toStringWithoutPrefix(): string {\n return this.bcsToHex().toStringWithoutPrefix();\n }\n\n /**\n * Returns the hex string representation of the `Serializable` value with the 0x prefix.\n * @returns the hex formatas a string prefixed by `0x`.\n */\n toString(): string {\n return `0x${this.toStringWithoutPrefix()}`;\n }\n}\n\n/**\n * Minimum buffer growth increment to avoid too many small reallocations.\n */\nconst MIN_BUFFER_GROWTH = 256;\n\n/**\n * Pool of reusable Serializer instances for temporary serialization operations.\n * This reduces allocations when using serializeAsBytes() repeatedly.\n */\nconst serializerPool: Serializer[] = [];\nconst MAX_POOL_SIZE = 8;\n\n/**\n * Acquires a Serializer from the pool or creates a new one.\n * @internal\n */\nfunction acquireSerializer(): Serializer {\n const serializer = serializerPool.pop();\n if (serializer) {\n serializer.reset();\n return serializer;\n }\n return new Serializer();\n}\n\n/**\n * Returns a Serializer to the pool for reuse.\n * @internal\n */\nfunction releaseSerializer(serializer: Serializer): void {\n if (serializerPool.length < MAX_POOL_SIZE) {\n serializerPool.push(serializer);\n }\n}\n\n/**\n * A class for serializing various data types into a binary format.\n * It provides methods to serialize strings, bytes, numbers, and other serializable objects\n * using the Binary Coded Serialization (BCS) layout. The serialized data can be retrieved as a\n * Uint8Array.\n * @group Implementation\n * @category BCS\n */\nexport class Serializer {\n private buffer: ArrayBuffer;\n\n private offset: number;\n\n /**\n * Reusable DataView instance to reduce allocations during serialization.\n * Recreated when buffer is resized.\n */\n private dataView: DataView;\n\n /**\n * Constructs a serializer with a buffer of size `length` bytes, 64 bytes by default.\n * The `length` must be greater than 0.\n *\n * @param length - The size of the buffer in bytes.\n * @group Implementation\n * @category BCS\n */\n constructor(length: number = 64) {\n if (length <= 0) {\n throw new Error(\"Length needs to be greater than 0\");\n }\n this.buffer = new ArrayBuffer(length);\n this.dataView = new DataView(this.buffer);\n this.offset = 0;\n }\n\n /**\n * Ensures that the internal buffer can accommodate the specified number of bytes.\n * This function dynamically resizes the buffer using a growth factor of 1.5x with\n * a minimum growth increment to balance memory usage and reallocation frequency.\n *\n * @param bytes - The number of bytes to ensure the buffer can handle.\n * @group Implementation\n * @category BCS\n */\n private ensureBufferWillHandleSize(bytes: number) {\n const requiredSize = this.offset + bytes;\n if (this.buffer.byteLength >= requiredSize) {\n return;\n }\n\n // Calculate new size: max of (1.5x current size) or (current + required + MIN_GROWTH)\n // Using 1.5x instead of 2x provides better memory efficiency\n const growthSize = Math.max(Math.floor(this.buffer.byteLength * 1.5), requiredSize + MIN_BUFFER_GROWTH);\n\n const newBuffer = new ArrayBuffer(growthSize);\n new Uint8Array(newBuffer).set(new Uint8Array(this.buffer, 0, this.offset));\n this.buffer = newBuffer;\n this.dataView = new DataView(this.buffer);\n }\n\n /**\n * Appends the specified values to the buffer, ensuring that the buffer can accommodate the new data.\n *\n * @param {Uint8Array} values - The values to be appended to the buffer.\n * @group Implementation\n * @category BCS\n */\n protected appendToBuffer(values: Uint8Array) {\n this.ensureBufferWillHandleSize(values.length);\n new Uint8Array(this.buffer, this.offset).set(values);\n this.offset += values.length;\n }\n\n /**\n * Serializes a value into the buffer using the provided function, ensuring the buffer can accommodate the size.\n * Uses the cached DataView instance for better performance.\n *\n * @param fn - The function to serialize the value, which takes a byte offset, the value to serialize, and an optional little-endian flag.\n * @param fn.byteOffset - The byte offset at which to write the value.\n * @param fn.value - The numeric value to serialize into the buffer.\n * @param fn.littleEndian - Optional flag indicating whether to use little-endian byte order (defaults to true).\n * @group Implementation\n * @category BCS\n */\n // TODO: JSDoc bytesLength and value\n private serializeWithFunction(\n fn: (byteOffset: number, value: number, littleEndian?: boolean) => void,\n bytesLength: number,\n value: number,\n ) {\n this.ensureBufferWillHandleSize(bytesLength);\n fn.apply(this.dataView, [this.offset, value, true]);\n this.offset += bytesLength;\n }\n\n /**\n * Serializes a string. UTF8 string is supported.\n * The number of bytes in the string content is serialized first, as a uleb128-encoded u32 integer.\n * Then the string content is serialized as UTF8 encoded bytes.\n *\n * BCS layout for \"string\": string_length | string_content\n * where string_length is a u32 integer encoded as a uleb128 integer, equal to the number of bytes in string_content.\n *\n * @param value - The string to serialize.\n *\n * @example\n * ```typescript\n * const serializer = new Serializer();\n * serializer.serializeStr(\"1234abcd\");\n * assert(serializer.toUint8Array() === new Uint8Array([8, 49, 50, 51, 52, 97, 98, 99, 100]));\n * ```\n * @group Implementation\n * @category BCS\n */\n serializeStr(value: string) {\n this.serializeBytes(TEXT_ENCODER.encode(value));\n }\n\n /**\n * Serializes an array of bytes.\n *\n * This function encodes the length of the byte array as a u32 integer in uleb128 format, followed by the byte array itself.\n * BCS layout for \"bytes\": bytes_length | bytes\n * where bytes_length is a u32 integer encoded as a uleb128 integer, equal to the length of the bytes array.\n * @param value - The byte array to serialize.\n * @group Implementation\n * @category BCS\n */\n serializeBytes(value: Uint8Array) {\n this.serializeU32AsUleb128(value.length);\n this.appendToBuffer(value);\n }\n\n /**\n * Serializes an array of bytes with a known length, allowing for efficient deserialization without needing to serialize the\n * length itself.\n * When deserializing, the number of bytes to deserialize needs to be passed in.\n\n * @param value - The Uint8Array to be serialized.\n * @group Implementation\n * @category BCS\n */\n serializeFixedBytes(value: Uint8Array) {\n this.appendToBuffer(value);\n }\n\n /**\n * Serializes a boolean value into a byte representation.\n *\n * The BCS layout for a boolean uses one byte, where \"0x01\" represents true and \"0x00\" represents false.\n *\n * @param value - The boolean value to serialize.\n * @group Implementation\n * @category BCS\n */\n serializeBool(value: boolean) {\n /**\n * Ensures that the provided value is a boolean.\n * This function throws an error if the value is not a boolean, helping to enforce type safety in your code.\n *\n * @param value - The value to be checked for boolean type.\n * @throws {Error} Throws an error if the value is not a boolean.\n * @group Implementation\n * @category BCS\n */\n ensureBoolean(value);\n const byteValue = value ? 1 : 0;\n this.appendToBuffer(new Uint8Array([byteValue]));\n }\n\n /**\n * Serializes a Uint8 value and appends it to the buffer.\n * BCS layout for \"uint8\": One byte. Binary format in little-endian representation.\n *\n * @param value - The Uint8 value to serialize.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(0, MAX_U8_NUMBER)\n serializeU8(value: Uint8) {\n this.appendToBuffer(new Uint8Array([value]));\n }\n\n /**\n * Serializes a uint16 number.\n *\n * @group Implementation\n * @category BCS\n\n */\n\n /**\n * Serializes a 16-bit unsigned integer value into a binary format.\n * BCS layout for \"uint16\": Two bytes. Binary format in little-endian representation.\n *\n * @param value - The 16-bit unsigned integer value to serialize.\n * @example\n * ```typescript\n * const serializer = new Serializer();\n * serializer.serializeU16(4660);\n * assert(serializer.toUint8Array() === new Uint8Array([0x34, 0x12]));\n * ```\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(0, MAX_U16_NUMBER)\n serializeU16(value: Uint16) {\n this.serializeWithFunction(DataView.prototype.setUint16, 2, value);\n }\n\n /**\n * Serializes a 32-bit unsigned integer value into a binary format.\n * This function is useful for encoding data that needs to be stored or transmitted in a compact form.\n * @example\n * ```typescript\n * const serializer = new Serializer();\n * serializer.serializeU32(305419896);\n * assert(serializer.toUint8Array() === new Uint8Array([0x78, 0x56, 0x34, 0x12]));\n * ```\n * @param value - The 32-bit unsigned integer value to serialize.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(0, MAX_U32_NUMBER)\n serializeU32(value: Uint32) {\n this.serializeWithFunction(DataView.prototype.setUint32, 4, value);\n }\n\n /**\n * Serializes a 64-bit unsigned integer into a format suitable for storage or transmission.\n * This function breaks down the value into two 32-bit components and writes them in little-endian order.\n *\n * @param value - The 64-bit unsigned integer to serialize, represented as a number.\n * @example\n * ```ts\n * const serializer = new Serializer();\n * serializer.serializeU64(1311768467750121216);\n * assert(serializer.toUint8Array() === new Uint8Array([0x00, 0xEF, 0xCD, 0xAB, 0x78, 0x56, 0x34, 0x12]));\n * ```\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(BigInt(0), MAX_U64_BIG_INT)\n serializeU64(value: AnyNumber) {\n const low = BigInt(value) & BigInt(MAX_U32_NUMBER);\n const high = BigInt(value) >> BigInt(32);\n\n // write little endian number\n this.serializeU32(Number(low));\n this.serializeU32(Number(high));\n }\n\n /**\n * Serializes a U128 value into a format suitable for storage or transmission.\n *\n * @param value - The U128 value to serialize, represented as a number.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(BigInt(0), MAX_U128_BIG_INT)\n serializeU128(value: AnyNumber) {\n const low = BigInt(value) & MAX_U64_BIG_INT;\n const high = BigInt(value) >> BigInt(64);\n\n // write little endian number\n this.serializeU64(low);\n this.serializeU64(high);\n }\n\n /**\n * Serializes a U256 value into a byte representation.\n * This function is essential for encoding large numbers in a compact format suitable for transmission or storage.\n *\n * @param value - The U256 value to serialize, represented as an AnyNumber.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(BigInt(0), MAX_U256_BIG_INT)\n serializeU256(value: AnyNumber) {\n const low = BigInt(value) & MAX_U128_BIG_INT;\n const high = BigInt(value) >> BigInt(128);\n\n // write little endian number\n this.serializeU128(low);\n this.serializeU128(high);\n }\n\n /**\n * Serializes an 8-bit signed integer value.\n * BCS layout for \"int8\": One byte. Binary format in little-endian representation.\n *\n * @param value - The 8-bit signed integer value to serialize.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(MIN_I8_NUMBER, MAX_I8_NUMBER)\n serializeI8(value: number) {\n this.serializeWithFunction(DataView.prototype.setInt8, 1, value);\n }\n\n /**\n * Serializes a 16-bit signed integer value into a binary format.\n * BCS layout for \"int16\": Two bytes. Binary format in little-endian representation.\n *\n * @param value - The 16-bit signed integer value to serialize.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(MIN_I16_NUMBER, MAX_I16_NUMBER)\n serializeI16(value: number) {\n this.serializeWithFunction(DataView.prototype.setInt16, 2, value);\n }\n\n /**\n * Serializes a 32-bit signed integer value into a binary format.\n *\n * @param value - The 32-bit signed integer value to serialize.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(MIN_I32_NUMBER, MAX_I32_NUMBER)\n serializeI32(value: number) {\n this.serializeWithFunction(DataView.prototype.setInt32, 4, value);\n }\n\n /**\n * Serializes a 64-bit signed integer into a format suitable for storage or transmission.\n * This function uses two's complement representation for negative values.\n *\n * @param value - The 64-bit signed integer to serialize.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(MIN_I64_BIG_INT, MAX_I64_BIG_INT)\n serializeI64(value: AnyNumber) {\n const val = BigInt(value);\n // Convert to unsigned representation using two's complement\n const unsigned = val < 0 ? (BigInt(1) << BigInt(64)) + val : val;\n const low = unsigned & BigInt(MAX_U32_NUMBER);\n const high = unsigned >> BigInt(32);\n\n // write little endian number\n this.serializeU32(Number(low));\n this.serializeU32(Number(high));\n }\n\n /**\n * Serializes a 128-bit signed integer value.\n *\n * @param value - The 128-bit signed integer value to serialize.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(MIN_I128_BIG_INT, MAX_I128_BIG_INT)\n serializeI128(value: AnyNumber) {\n const val = BigInt(value);\n // Convert to unsigned representation using two's complement\n const unsigned = val < 0 ? (BigInt(1) << BigInt(128)) + val : val;\n const low = unsigned & MAX_U64_BIG_INT;\n const high = unsigned >> BigInt(64);\n\n // write little endian number\n this.serializeU64(low);\n this.serializeU64(high);\n }\n\n /**\n * Serializes a 256-bit signed integer value.\n *\n * @param value - The 256-bit signed integer value to serialize.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(MIN_I256_BIG_INT, MAX_I256_BIG_INT)\n serializeI256(value: AnyNumber) {\n const val = BigInt(value);\n // Convert to unsigned representation using two's complement\n const unsigned = val < 0 ? (BigInt(1) << BigInt(256)) + val : val;\n const low = unsigned & MAX_U128_BIG_INT;\n const high = unsigned >> BigInt(128);\n\n // write little endian number\n this.serializeU128(low);\n this.serializeU128(high);\n }\n\n /**\n * Serializes a 32-bit unsigned integer as a variable-length ULEB128 encoded byte array.\n * BCS uses uleb128 encoding in two cases: (1) lengths of variable-length sequences and (2) tags of enum values\n *\n * @param val - The 32-bit unsigned integer value to be serialized.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(0, MAX_U32_NUMBER)\n serializeU32AsUleb128(val: Uint32) {\n let value = val;\n const valueArray = [];\n while (value >>> 7 !== 0) {\n valueArray.push((value & 0x7f) | 0x80);\n value >>>= 7;\n }\n valueArray.push(value);\n this.appendToBuffer(new Uint8Array(valueArray));\n }\n\n /**\n * Returns the buffered bytes as a Uint8Array.\n *\n * This function allows you to retrieve the byte representation of the buffer up to the current offset.\n * For better performance, returns a view when the buffer is exactly the right size, or copies\n * only the used portion otherwise.\n *\n * @returns Uint8Array - The byte array representation of the buffer.\n * @group Implementation\n * @category BCS\n */\n toUint8Array(): Uint8Array {\n // Return a copy of only the used portion of the buffer\n // Using subarray + slice pattern for efficiency\n return new Uint8Array(this.buffer, 0, this.offset).slice();\n }\n\n /**\n * Resets the serializer to its initial state, allowing the buffer to be reused.\n * This clears the buffer contents to prevent data leakage between uses.\n *\n * @group Implementation\n * @category BCS\n */\n reset(): void {\n // Clear buffer contents to prevent data leakage when reusing pooled serializers\n // Only clear the portion that was used (up to offset) for efficiency\n if (this.offset > 0) {\n new Uint8Array(this.buffer, 0, this.offset).fill(0);\n }\n this.offset = 0;\n }\n\n /**\n * Returns the current number of bytes written to the serializer.\n *\n * @returns The number of bytes written.\n * @group Implementation\n * @category BCS\n */\n getOffset(): number {\n return this.offset;\n }\n\n /**\n * Returns a view of the serialized bytes without copying.\n * WARNING: The returned view is only valid until the next write operation.\n * Use toUint8Array() if you need a persistent copy.\n *\n * @returns A Uint8Array view of the buffer (not a copy).\n * @group Implementation\n * @category BCS\n */\n toUint8ArrayView(): Uint8Array {\n return new Uint8Array(this.buffer, 0, this.offset);\n }\n\n /**\n * Serializes a `Serializable` value, facilitating composable serialization.\n *\n * @param value The Serializable value to serialize.\n *\n * @returns the serializer instance\n * @group Implementation\n * @category BCS\n */\n serialize<T extends Serializable>(value: T): void {\n // NOTE: The `serialize` method called by `value` is defined in `value`'s\n // Serializable interface, not the one defined in this class.\n value.serialize(this);\n }\n\n /**\n * Serializes a Serializable value as a byte array with a length prefix.\n * This is the optimized pattern for entry function argument serialization.\n *\n * Instead of:\n * ```typescript\n * const bcsBytes = value.bcsToBytes(); // Creates new Serializer, copies bytes\n * serializer.serializeBytes(bcsBytes);\n * ```\n *\n * Use:\n * ```typescript\n * serializer.serializeAsBytes(value); // Uses pooled Serializer, avoids extra copy\n * ```\n *\n * This method uses a pooled Serializer instance to reduce allocations and\n * directly appends the serialized bytes with a length prefix.\n *\n * @param value - The Serializable value to serialize as bytes.\n * @group Implementation\n * @category BCS\n */\n serializeAsBytes<T extends Serializable>(value: T): void {\n // Acquire a pooled serializer for temporary use\n const tempSerializer = acquireSerializer();\n\n try {\n // Serialize the value to the temporary serializer\n value.serialize(tempSerializer);\n\n // Get the serialized bytes (as a view to avoid copying)\n const bytes = tempSerializer.toUint8ArrayView();\n\n // Serialize with length prefix to this serializer\n this.serializeBytes(bytes);\n } finally {\n // Return the serializer to the pool for reuse\n releaseSerializer(tempSerializer);\n }\n }\n\n /**\n * Serializes an array of BCS Serializable values to a serializer instance.\n * The bytes are added to the serializer instance's byte buffer.\n *\n * @param values The array of BCS Serializable values\n * @example\n * const addresses = new Array<AccountAddress>(\n * AccountAddress.from(\"0x1\"),\n * AccountAddress.from(\"0x2\"),\n * AccountAddress.from(\"0xa\"),\n * AccountAddress.from(\"0xb\"),\n * );\n * const serializer = new Serializer();\n * serializer.serializeVector(addresses);\n * const serializedBytes = serializer.toUint8Array();\n * // serializedBytes is now the BCS-serialized bytes\n * // The equivalent value in Move would be:\n * // `bcs::to_bytes(&vector<address> [@0x1, @0x2, @0xa, @0xb])`;\n * @group Implementation\n * @category BCS\n */\n serializeVector<T extends Serializable>(values: Array<T>): void {\n this.serializeU32AsUleb128(values.length);\n values.forEach((item) => {\n item.serialize(this);\n });\n }\n\n /**\n * Serializes an optional value which can be a Serializable, string, or Uint8Array.\n * For strings and Uint8Arrays, it uses the appropriate serialization method.\n *\n * @param value The value to serialize (Serializable, string, Uint8Array, or undefined)\n * @param len Optional fixed length for Uint8Array serialization. If provided, uses serializeFixedBytes instead of serializeBytes\n *\n * @example\n * ```typescript\n * const serializer = new Serializer();\n * serializer.serializeOption(\"hello\"); // Serializes optional string\n * serializer.serializeOption(new Uint8Array([1, 2, 3])); // Serializes optional bytes\n * serializer.serializeOption(new Uint8Array([1, 2, 3]), 3); // Serializes optional fixed-length bytes\n * serializer.serializeOption(new AccountAddress(...)); // Serializes optional Serializable\n * serializer.serializeOption(undefined); // Serializes none case\n * ```\n * @group Implementation\n * @category BCS\n */\n serializeOption<T extends Serializable | string | Uint8Array>(value?: T, len?: number): void {\n const hasValue = value !== undefined;\n this.serializeBool(hasValue);\n if (hasValue) {\n if (typeof value === \"string\") {\n this.serializeStr(value);\n } else if (value instanceof Uint8Array) {\n if (len !== undefined) {\n this.serializeFixedBytes(value);\n } else {\n this.serializeBytes(value);\n }\n } else {\n value.serialize(this);\n }\n }\n }\n\n /**\n * @deprecated use `serializeOption` instead.\n * Serializes an optional string, supporting UTF8 encoding.\n * The function encodes the existence of the string first, followed by the length and content if it exists.\n *\n * BCS layout for optional \"string\": 1 | string_length | string_content\n * where string_length is a u32 integer encoded as a uleb128 integer, equal to the number of bytes in string_content.\n * BCS layout for undefined: 0\n *\n * @param value - The optional string to serialize. If undefined, it will serialize as 0.\n * @group Implementation\n * @category BCS\n */\n serializeOptionStr(value?: string): void {\n if (value === undefined) {\n this.serializeU32AsUleb128(0);\n } else {\n this.serializeU32AsUleb128(1);\n this.serializeStr(value);\n }\n }\n}\n\n/**\n * @group Implementation\n * @category BCS\n */\nexport function ensureBoolean(value: unknown): asserts value is boolean {\n if (typeof value !== \"boolean\") {\n throw new Error(`${value} is not a boolean value`);\n }\n}\n/**\n * @group Implementation\n * @category BCS\n */\nexport const outOfRangeErrorMessage = (value: AnyNumber, min: AnyNumber, max: AnyNumber) =>\n `${value} is out of range: [${min}, ${max}]`;\n\n/**\n * Validates that a given number is within a specified range.\n * This function throws an error if the value is outside the defined minimum and maximum bounds.\n *\n * @param value - The number to validate.\n * @param minValue - The minimum allowable value (inclusive).\n * @param maxValue - The maximum allowable value (inclusive).\n * @group Implementation\n * @category BCS\n */\nexport function validateNumberInRange<T extends AnyNumber>(value: T, minValue: T, maxValue: T) {\n const valueBigInt = BigInt(value);\n if (valueBigInt > BigInt(maxValue) || valueBigInt < BigInt(minValue)) {\n throw new Error(outOfRangeErrorMessage(value, minValue, maxValue));\n }\n}\n\n/**\n * A decorator that validates that the input argument for a function is within a specified range.\n * This ensures that the function is only called with valid input values, preventing potential errors.\n *\n * @param minValue - The input argument must be greater than or equal to this value.\n * @param maxValue - The input argument must be less than or equal to this value.\n * @group Implementation\n * @category BCS\n */\nfunction checkNumberRange<T extends AnyNumber>(minValue: T, maxValue: T) {\n return (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => {\n const childFunction = descriptor.value;\n\n descriptor.value = function deco(value: AnyNumber) {\n validateNumberInRange(value, minValue, maxValue);\n return childFunction.apply(this, [value]);\n };\n\n return descriptor;\n };\n}\n"],"mappings":"2RAkCO,IAAeA,EAAf,KAA4B,CAUjC,YAAyB,CACvB,IAAMC,EAAa,IAAIC,EACvB,YAAK,UAAUD,CAAU,EAClBA,EAAW,aAAa,CACjC,CASA,UAAgB,CACd,IAAME,EAAW,KAAK,WAAW,EACjC,OAAOC,EAAI,aAAaD,CAAQ,CAClC,CAMA,uBAAgC,CAC9B,OAAO,KAAK,SAAS,EAAE,sBAAsB,CAC/C,CAMA,UAAmB,CACjB,MAAO,KAAK,KAAK,sBAAsB,CAAC,EAC1C,CACF,EAKME,EAAoB,IAMpBC,EAA+B,CAAC,EAChCC,EAAgB,EAMtB,SAASC,GAAgC,CACvC,IAAMP,EAAaK,EAAe,IAAI,EACtC,OAAIL,GACFA,EAAW,MAAM,EACVA,GAEF,IAAIC,CACb,CAMA,SAASO,EAAkBR,EAA8B,CACnDK,EAAe,OAASC,GAC1BD,EAAe,KAAKL,CAAU,CAElC,CAUO,IAAMC,EAAN,KAAiB,CAmBtB,YAAYQ,EAAiB,GAAI,CAC/B,GAAIA,GAAU,EACZ,MAAM,IAAI,MAAM,mCAAmC,EAErD,KAAK,OAAS,IAAI,YAAYA,CAAM,EACpC,KAAK,SAAW,IAAI,SAAS,KAAK,MAAM,EACxC,KAAK,OAAS,CAChB,CAWQ,2BAA2BC,EAAe,CAChD,IAAMC,EAAe,KAAK,OAASD,EACnC,GAAI,KAAK,OAAO,YAAcC,EAC5B,OAKF,IAAMC,EAAa,KAAK,IAAI,KAAK,MAAM,KAAK,OAAO,WAAa,GAAG,EAAGD,EAAeP,CAAiB,EAEhGS,EAA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AAG,IAYpC,SAASC,EAA2CpC,EAAUqC,EAAaC,EAAa,CAC7F,IAAMC,EAAc,OAAOvC,CAAK,EAChC,GAAIuC,EAAc,OAAOD,CAAQ,GAAKC,EAAc,OAAOF,CAAQ,EACjE,MAAM,IAAI,MAAMJ,EAAuBjC,EAAOqC,EAAUC,CAAQ,CAAC,CAErE,CAWA,SAASrB,EAAsCoB,EAAaC,EAAa,CACvE,MAAO,CAACE,EAAiBC,EAAqBC,IAAmC,CAC/E,IAAMC,EAAgBD,EAAW,MAEjC,OAAAA,EAAW,MAAQ,SAAc1C,EAAkB,CACjD,OAAAoC,EAAsBpC,EAAOqC,EAAUC,CAAQ,EACxCK,EAAc,MAAM,KAAM,CAAC3C,CAAK,CAAC,CAC1C,EAEO0C,CACT,CACF","names":["Serializable","serializer","Serializer","bcsBytes","Hex","MIN_BUFFER_GROWTH","serializerPool","MAX_POOL_SIZE","acquireSerializer","releaseSerializer","length","bytes","requiredSize","growthSize","newBuffer","values","fn","bytesLength","value","TEXT_ENCODER","ensureBoolean","byteValue","low","MAX_U32_NUMBER","high","MAX_U64_BIG_INT","MAX_U128_BIG_INT","val","unsigned","valueArray","tempSerializer","item","len","hasValue","__decorateClass","checkNumberRange","MAX_U8_NUMBER","MAX_U16_NUMBER","MAX_U256_BIG_INT","MIN_I8_NUMBER","MAX_I8_NUMBER","MIN_I16_NUMBER","MAX_I16_NUMBER","MIN_I32_NUMBER","MAX_I32_NUMBER","MIN_I64_BIG_INT","MAX_I64_BIG_INT","MIN_I128_BIG_INT","MAX_I128_BIG_INT","MIN_I256_BIG_INT","MAX_I256_BIG_INT","outOfRangeErrorMessage","min","max","validateNumberInRange","minValue","maxValue","valueBigInt","target","propertyKey","descriptor","childFunction"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as r,c as B,e as s}from"./chunk-66F7RP7K.mjs";import{a,b as l,c as n,d as o,e as z,f as u,g as c,h as d,i as I,j as p,k as U,l as v,m as A,n as m,o as S,p as h,q as F,r as y}from"./chunk-X2TPNKLV.mjs";var b=class i extends r{constructor(e){super(),B(e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}deserialize(e){return new t(e.deserializeU256())}static deserialize(e){return new i(e.deserializeBool())}},N=class i extends r{constructor(e){super(),s(e,0,a),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new i(e.deserializeU8())}},_=class i extends r{constructor(e){super(),s(e,0,l),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new i(e.deserializeU16())}},g=class i extends r{constructor(e){super(),s(e,0,n),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new i(e.deserializeU32())}},M=class i extends r{constructor(e){super(),s(e,BigInt(0),o),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new i(e.deserializeU64())}},x=class i extends r{constructor(e){super(),s(e,BigInt(0),z),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new i(e.deserializeU128())}},t=class i extends r{constructor(e){super(),s(e,BigInt(0),u),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new i(e.deserializeU256())}},T=class i extends r{constructor(e){super(),s(e,c,d),this.value=e}serialize(e){e.serializeI8(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(10),e.serialize(this)}static deserialize(e){return new i(e.deserializeI8())}},E=class i extends r{constructor(e){super(),s(e,I,p),this.value=e}serialize(e){e.serializeI16(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(11),e.serialize(this)}static deserialize(e){return new i(e.deserializeI16())}},D=class i extends r{constructor(e){super(),s(e,U,v),this.value=e}serialize(e){e.serializeI32(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(12),e.serialize(this)}static deserialize(e){return new i(e.deserializeI32())}},w=class i extends r{constructor(e){super(),s(e,A,m),this.value=BigInt(e)}serialize(e){e.serializeI64(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(13),e.serialize(this)}static deserialize(e){return new i(e.deserializeI64())}},X=class i extends r{constructor(e){super(),s(e,S,h),this.value=BigInt(e)}serialize(e){e.serializeI128(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(14),e.serialize(this)}static deserialize(e){return new i(e.deserializeI128())}},R=class i extends r{constructor(e){super(),s(e,F,y),this.value=BigInt(e)}serialize(e){e.serializeI256(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(15),e.serialize(this)}static deserialize(e){return new i(e.deserializeI256())}};export{b as a,N as b,_ as c,g as d,M as e,x as f,t as g,T as h,E as i,D as j,w as k,X as l,R as m};
|
|
2
|
-
//# sourceMappingURL=chunk-BT742BFQ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bcs/serializable/movePrimitives.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\nimport {\n MAX_U128_BIG_INT,\n MAX_U16_NUMBER,\n MAX_U32_NUMBER,\n MAX_U64_BIG_INT,\n MAX_U8_NUMBER,\n MAX_U256_BIG_INT,\n MIN_I8_NUMBER,\n MAX_I8_NUMBER,\n MIN_I16_NUMBER,\n MAX_I16_NUMBER,\n MIN_I32_NUMBER,\n MAX_I32_NUMBER,\n MIN_I64_BIG_INT,\n MAX_I64_BIG_INT,\n MIN_I128_BIG_INT,\n MAX_I128_BIG_INT,\n MIN_I256_BIG_INT,\n MAX_I256_BIG_INT,\n} from \"../consts\";\nimport { Deserializer } from \"../deserializer\";\nimport { Serializable, Serializer, ensureBoolean, validateNumberInRange } from \"../serializer\";\nimport { TransactionArgument } from \"../../transactions/instances/transactionArgument\";\nimport { AnyNumber, Uint16, Uint32, Uint8, Int8, Int16, Int32, ScriptTransactionArgumentVariants } from \"../../types\";\n\n/**\n * Represents a boolean value that can be serialized and deserialized.\n * This class extends the Serializable class and provides methods to serialize\n * the boolean value for different contexts, such as entry functions and script functions.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class Bool extends Serializable implements TransactionArgument {\n public readonly value: boolean;\n\n /**\n * Constructs a new instance with a specified value.\n * This ensures that the value is validated to be within the acceptable range.\n *\n * @param value - The number to be validated and assigned, which must be between 0 and MAX_U256_BIG_INT.\n * @group Implementation\n * @category BCS\n */\n constructor(value: boolean) {\n super();\n\n /**\n * Ensures that the provided value is of type boolean.\n * This function throws an error if the value is not a boolean, helping to enforce type safety in your code.\n *\n * @param value - The value to be checked for boolean type.\n * @throws {Error} Throws an error if the value is not a boolean.\n * @group Implementation\n * @category BCS\n */\n ensureBoolean(value);\n this.value = value;\n }\n\n /**\n * Serializes the value using the provided serializer.\n * This function is essential for converting the value into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category BCS\n */\n serialize(serializer: Serializer): void {\n serializer.serializeBool(this.value);\n }\n\n /**\n * Serializes the current instance for use in an entry function by converting it to a byte sequence.\n * This allows the instance to be properly formatted for serialization in transactions.\n * Uses the optimized serializeAsBytes method to reduce allocations.\n *\n * @param serializer - The serializer instance used to serialize the byte sequence.\n * @group Implementation\n * @category BCS\n */\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n /**\n * Serializes the current instance for use in a script function.\n * This allows for the conversion of the instance into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer used to perform the serialization.\n * @group Implementation\n * @category BCS\n */\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.Bool);\n serializer.serialize(this);\n }\n\n /**\n * Deserializes a U256 value from the provided deserializer.\n *\n * @param deserializer - The deserializer instance used to read the U256 data.\n * @group Implementation\n * @category BCS\n */\n\n deserialize(deserializer: Deserializer) {\n return new U256(deserializer.deserializeU256());\n }\n\n static deserialize(deserializer: Deserializer): Bool {\n return new Bool(deserializer.deserializeBool());\n }\n}\n\n/**\n * Represents an unsigned 8-bit integer (U8) value.\n * This class extends the Serializable class and provides methods for serialization and deserialization of U8 values.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class U8 extends Serializable implements TransactionArgument {\n public readonly value: Uint8;\n\n constructor(value: Uint8) {\n super();\n validateNumberInRange(value, 0, MAX_U8_NUMBER);\n this.value = value;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU8(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U8);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): U8 {\n return new U8(deserializer.deserializeU8());\n }\n}\n\n/**\n * Represents a 16-bit unsigned integer (U16) value.\n * This class extends the Serializable class and provides methods for serialization\n * and deserialization of the U16 value.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class U16 extends Serializable implements TransactionArgument {\n public readonly value: Uint16;\n\n constructor(value: Uint16) {\n super();\n validateNumberInRange(value, 0, MAX_U16_NUMBER);\n this.value = value;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU16(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U16);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): U16 {\n return new U16(deserializer.deserializeU16());\n }\n}\n\n/**\n * Represents a 32-bit unsigned integer (U32) that can be serialized and deserialized.\n * This class ensures that the value is within the valid range for a U32.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class U32 extends Serializable implements TransactionArgument {\n public readonly value: Uint32;\n\n constructor(value: Uint32) {\n super();\n validateNumberInRange(value, 0, MAX_U32_NUMBER);\n this.value = value;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U32);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): U32 {\n return new U32(deserializer.deserializeU32());\n }\n}\n\n/**\n * Represents a 64-bit unsigned integer (U64) and provides methods for serialization.\n *\n * This class ensures that the value is within the valid range for a U64 and provides\n * functionality to serialize the value for various use cases, including entry functions\n * and script functions.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class U64 extends Serializable implements TransactionArgument {\n public readonly value: bigint;\n\n constructor(value: AnyNumber) {\n super();\n validateNumberInRange(value, BigInt(0), MAX_U64_BIG_INT);\n this.value = BigInt(value);\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU64(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U64);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): U64 {\n return new U64(deserializer.deserializeU64());\n }\n}\n\n/**\n * Represents a 128-bit unsigned integer value.\n * This class provides methods for serialization and deserialization\n * of U128 values, ensuring that the values are within the valid range.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class U128 extends Serializable implements TransactionArgument {\n public readonly value: bigint;\n\n constructor(value: AnyNumber) {\n super();\n validateNumberInRange(value, BigInt(0), MAX_U128_BIG_INT);\n this.value = BigInt(value);\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU128(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U128);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): U128 {\n return new U128(deserializer.deserializeU128());\n }\n}\n\n/**\n * Represents a 256-bit unsigned integer (U256) that extends the Serializable class.\n * This class provides methods for serialization and deserialization of U256 values,\n * ensuring that the values are within the valid range.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class U256 extends Serializable implements TransactionArgument {\n public readonly value: bigint;\n\n constructor(value: AnyNumber) {\n super();\n validateNumberInRange(value, BigInt(0), MAX_U256_BIG_INT);\n this.value = BigInt(value);\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU256(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U256);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): U256 {\n return new U256(deserializer.deserializeU256());\n }\n}\n\n/**\n * Represents an 8-bit signed integer (I8) value.\n * This class extends the Serializable class and provides methods for serialization and deserialization of I8 values.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class I8 extends Serializable implements TransactionArgument {\n public readonly value: Int8;\n\n constructor(value: Int8) {\n super();\n validateNumberInRange(value, MIN_I8_NUMBER, MAX_I8_NUMBER);\n this.value = value;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeI8(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.I8);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): I8 {\n return new I8(deserializer.deserializeI8());\n }\n}\n\n/**\n * Represents a 16-bit signed integer (I16) value.\n * This class extends the Serializable class and provides methods for serialization\n * and deserialization of the I16 value.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class I16 extends Serializable implements TransactionArgument {\n public readonly value: Int16;\n\n constructor(value: Int16) {\n super();\n validateNumberInRange(value, MIN_I16_NUMBER, MAX_I16_NUMBER);\n this.value = value;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeI16(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.I16);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): I16 {\n return new I16(deserializer.deserializeI16());\n }\n}\n\n/**\n * Represents a 32-bit signed integer (I32) that can be serialized and deserialized.\n * This class ensures that the value is within the valid range for an I32.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class I32 extends Serializable implements TransactionArgument {\n public readonly value: Int32;\n\n constructor(value: Int32) {\n super();\n validateNumberInRange(value, MIN_I32_NUMBER, MAX_I32_NUMBER);\n this.value = value;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeI32(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.I32);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): I32 {\n return new I32(deserializer.deserializeI32());\n }\n}\n\n/**\n * Represents a 64-bit signed integer (I64) and provides methods for serialization.\n *\n * This class ensures that the value is within the valid range for an I64 and provides\n * functionality to serialize the value for various use cases, including entry functions\n * and script functions.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class I64 extends Serializable implements TransactionArgument {\n public readonly value: bigint;\n\n constructor(value: AnyNumber) {\n super();\n validateNumberInRange(value, MIN_I64_BIG_INT, MAX_I64_BIG_INT);\n this.value = BigInt(value);\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeI64(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.I64);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): I64 {\n return new I64(deserializer.deserializeI64());\n }\n}\n\n/**\n * Represents a 128-bit signed integer value.\n * This class provides methods for serialization and deserialization\n * of I128 values, ensuring that the values are within the valid range.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class I128 extends Serializable implements TransactionArgument {\n public readonly value: bigint;\n\n constructor(value: AnyNumber) {\n super();\n validateNumberInRange(value, MIN_I128_BIG_INT, MAX_I128_BIG_INT);\n this.value = BigInt(value);\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeI128(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.I128);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): I128 {\n return new I128(deserializer.deserializeI128());\n }\n}\n\n/**\n * Represents a 256-bit signed integer (I256) that extends the Serializable class.\n * This class provides methods for serialization and deserialization of I256 values,\n * ensuring that the values are within the valid range.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class I256 extends Serializable implements TransactionArgument {\n public readonly value: bigint;\n\n constructor(value: AnyNumber) {\n super();\n validateNumberInRange(value, MIN_I256_BIG_INT, MAX_I256_BIG_INT);\n this.value = BigInt(value);\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeI256(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.I256);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): I256 {\n return new I256(deserializer.deserializeI256());\n }\n}\n"],"mappings":"kNAoCO,IAAMA,EAAN,MAAMC,UAAaC,CAA4C,CAWpE,YAAYC,EAAgB,CAC1B,MAAM,EAWNC,EAAcD,CAAK,EACnB,KAAK,MAAQA,CACf,CAUA,UAAUE,EAA8B,CACtCA,EAAW,cAAc,KAAK,KAAK,CACrC,CAWA,0BAA0BA,EAA8B,CACtDA,EAAW,iBAAiB,IAAI,CAClC,CAUA,2BAA2BA,EAA8B,CACvDA,EAAW,uBAA4D,EACvEA,EAAW,UAAU,IAAI,CAC3B,CAUA,YAAYC,EAA4B,CACtC,OAAO,IAAIC,EAAKD,EAAa,gBAAgB,CAAC,CAChD,CAEA,OAAO,YAAYA,EAAkC,CACnD,OAAO,IAAIL,EAAKK,EAAa,gBAAgB,CAAC,CAChD,CACF,EAUaE,EAAN,MAAMC,UAAWP,CAA4C,CAGlE,YAAYC,EAAc,CACxB,MAAM,EACNO,EAAsBP,EAAO,EAAGQ,CAAa,EAC7C,KAAK,MAAQR,CACf,CAEA,UA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serializer","U256","U8","_U8","validateNumberInRange","MAX_U8_NUMBER","U16","_U16","MAX_U16_NUMBER","U32","_U32","MAX_U32_NUMBER","U64","_U64","MAX_U64_BIG_INT","U128","_U128","MAX_U128_BIG_INT","_U256","MAX_U256_BIG_INT","I8","_I8","MIN_I8_NUMBER","MAX_I8_NUMBER","I16","_I16","MIN_I16_NUMBER","MAX_I16_NUMBER","I32","_I32","MIN_I32_NUMBER","MAX_I32_NUMBER","I64","_I64","MIN_I64_BIG_INT","MAX_I64_BIG_INT","I128","_I128","MIN_I128_BIG_INT","MAX_I128_BIG_INT","I256","_I256","MIN_I256_BIG_INT","MAX_I256_BIG_INT"]}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{a as l}from"./chunk-66F7RP7K.mjs";import{a as i}from"./chunk-IF4UU2MT.mjs";import{bytesToHex as a,hexToBytes as g}from"@noble/hashes/utils";var u=(s=>(s.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",s.INVALID_HEX_CHARS="invalid_hex_chars",s.TOO_SHORT="too_short",s.TOO_LONG="too_long",s.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",s.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",s.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",s.INVALID_PADDING_STRICTNESS="INVALID_PADDING_STRICTNESS",s))(u||{}),e=class e extends l{constructor(t){if(super(),t.length!==e.LENGTH)throw new i("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=t}isSpecial(){return this.data.slice(0,this.data.length-1).every(t=>t===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let t=a(this.data);return this.isSpecial()&&(t=t[t.length-1]),t}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return a(this.data)}toStringShort(){return`0x${this.toStringShortWithoutPrefix()}`}toStringShortWithoutPrefix(){let t=a(this.data).replace(/^0+/,"");return t===""?"0":t}toUint8Array(){return this.data}serialize(t){t.serializeFixedBytes(this.data)}serializeForEntryFunction(t){t.serializeAsBytes(this)}serializeForScriptFunction(t){t.serializeU32AsUleb128(3),t.serialize(this)}static deserialize(t){let r=t.deserializeFixedBytes(e.LENGTH);return new e(r)}static fromStringStrict(t){if(!t.startsWith("0x"))throw new i("Hex string must start with a leading 0x.","leading_zero_x_required");let r=e.fromString(t);if(t.length!==e.LONG_STRING_LENGTH+2)if(r.isSpecial()){if(t.length!==3)throw new i(`The given hex string ${t} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,"INVALID_PADDING_ZEROES")}else throw new i(`The given hex string ${t} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return r}static fromString(t,{maxMissingChars:r=4}={}){let n=t;if(t.startsWith("0x")&&(n=t.slice(2)),n.length===0)throw new i("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(n.length>64)throw new i("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 i(`maxMissingChars must be between or equal to 0 and 63. Received ${r}`,"INVALID_PADDING_STRICTNESS");let o;try{o=g(n.padStart(64,"0"))}catch(h){throw new i(`Hex characters are invalid: ${h?.message}`,"invalid_hex_chars")}let d=new e(o);if(n.length<64-r&&!d.isSpecial())throw new i(`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 ${t}`,"too_short");return d}static from(t,{maxMissingChars:r=4}={}){return typeof t=="string"?e.fromString(t,{maxMissingChars:r}):t instanceof Uint8Array?new e(t):t}static fromStrict(t){return typeof t=="string"?e.fromStringStrict(t):t instanceof Uint8Array?new e(t):t}static isValid(t){try{return t.strict?e.fromStrict(t.input):e.from(t.input),{valid:!0}}catch(r){return{valid:!1,invalidReason:r?.invalidReason,invalidReasonMessage:r?.message}}}equals(t){return this.data.length!==t.data.length?!1:this.data.every((r,n)=>r===t.data[n])}};e.LENGTH=32,e.LONG_STRING_LENGTH=64,e.ZERO=e.from("0x0"),e.ONE=e.from("0x1"),e.TWO=e.from("0x2"),e.THREE=e.from("0x3"),e.FOUR=e.from("0x4"),e.A=e.from("0xA");var c=e;export{u as a,c as b};
|
|
4
|
-
//# sourceMappingURL=chunk-FDHHQUS3.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/accountAddress.ts"],"sourcesContent":["// 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 * Uses the optimized serializeAsBytes method to reduce allocations.\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 serializer.serializeAsBytes(this);\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 `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"],"mappings":"kFAGA,OAAS,cAAAA,EAAY,cAAAC,MAAkB,sBAYhC,IAAKC,OACVA,EAAA,0BAA4B,4BAC5BA,EAAA,kBAAoB,oBACpBA,EAAA,UAAY,YACZA,EAAA,SAAW,WACXA,EAAA,wBAA0B,0BAC1BA,EAAA,kCAAoC,oCACpCA,EAAA,uBAAyB,yBACzBA,EAAA,2BAA6B,6BARnBA,OAAA,IAoCCC,EAAN,MAAMA,UAAuBC,CAA4C,CA4C9E,YAAYC,EAAmB,CAE7B,GADA,MAAM,EACFA,EAAM,SAAWF,EAAe,OAClC,MAAM,IAAIG,EACR,sDACA,2BACF,EAEF,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,QAAQc,EAA6F,CAC1G,GAAI,CACF,OAAIA,EAAK,OACPhB,EAAe,WAAWgB,EAAK,KAAK,EAEpChB,EAAe,KAAKgB,EAAK,KAAK,EAEzB,CAAE,MAAO,EAAK,CACvB,OAASD,EAAY,CACnB,MAAO,CACL,MAAO,GACP,cAAeA,GAAO,cACtB,qBAAsBA,GAAO,OAC/B,CACF,CACF,CAUA,OAAOE,EAAgC,CACrC,OAAI,KAAK,KAAK,SAAWA,EAAM,KAAK,OAAe,GAC5C,KAAK,KAAK,MAAM,CAACC,EAAOC,IAAUD,IAAUD,EAAM,KAAKE,CAAK,CAAC,CACtE,CACF,EAvdanB,EAaK,OAAiB,GAbtBA,EAoBK,mBAA6B,GApBlCA,EAsBJ,KAAuBA,EAAe,KAAK,KAAK,EAtB5CA,EAwBJ,IAAsBA,EAAe,KAAK,KAAK,EAxB3CA,EA0BJ,IAAsBA,EAAe,KAAK,KAAK,EA1B3CA,EA4BJ,MAAwBA,EAAe,KAAK,KAAK,EA5B7CA,EA8BJ,KAAuBA,EAAe,KAAK,KAAK,EA9B5CA,EAgCJ,EAAoBA,EAAe,KAAK,KAAK,EAhC/C,IAAMoB,EAANpB","names":["bytesToHex","hexToBytes","AddressInvalidReason","_AccountAddress","Serializable","input","ParsingError","byte","hex","bytesToHex","serializer","deserializer","bytes","address","maxMissingChars","parsedInput","addressBytes","hexToBytes","error","args","other","value","index","AccountAddress"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as c,b as s,c as d,d as m,e as w,f as p,g as y,h as z,i as U,j as A,k as f,l as b,m as I}from"./chunk-BT742BFQ.mjs";import{a as S}from"./chunk-M65PXVDO.mjs";import{a as o}from"./chunk-66F7RP7K.mjs";import{b as u}from"./chunk-STY74NUA.mjs";var t=class r extends o{constructor(e){super(),this.values=e}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){if(this.values[0]!==void 0&&!(this.values[0]instanceof s)){new v(this.bcsToBytes()).serializeForScriptFunction(e);return}e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let n;if(Array.isArray(e)&&e.length===0)n=[];else if(Array.isArray(e)&&typeof e[0]=="number")n=e;else if(typeof e=="string"){let i=u.fromHexInput(e);n=Array.from(i.toUint8Array())}else if(e instanceof Uint8Array)n=Array.from(e);else throw new Error("Invalid input type, must be an number[], Uint8Array, or hex string");return new r(n.map(i=>new s(i)))}static U16(e){return new r(e.map(n=>new d(n)))}static U32(e){return new r(e.map(n=>new m(n)))}static U64(e){return new r(e.map(n=>new w(n)))}static U128(e){return new r(e.map(n=>new p(n)))}static U256(e){return new r(e.map(n=>new y(n)))}static Bool(e){return new r(e.map(n=>new c(n)))}static I8(e){return new r(e.map(n=>new z(n)))}static I16(e){return new r(e.map(n=>new U(n)))}static I32(e){return new r(e.map(n=>new A(n)))}static I64(e){return new r(e.map(n=>new f(n)))}static I128(e){return new r(e.map(n=>new b(n)))}static I256(e){return new r(e.map(n=>new I(n)))}static MoveString(e){return new r(e.map(n=>new a(n)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,n){let i=e.deserializeUleb128AsU32(),l=new Array;for(let M=0;M<i;M+=1)l.push(n.deserialize(e));return new r(l)}},v=class r extends o{constructor(e){super(),this.value=u.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}serializeForEntryFunction(e){this.serialize(e)}serializeForScriptFunction(e){e.serializeU32AsUleb128(9),this.serialize(e)}static deserialize(e){return new r(e.deserializeBytes())}toMoveVector(e){let n=new S(this.bcsToBytes());n.deserializeUleb128AsU32();let i=n.deserializeVector(e);return new t(i)}},a=class r extends o{constructor(e){super(),this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){e.serializeAsBytes(this)}serializeForScriptFunction(e){let i=new TextEncoder().encode(this.value);t.U8(i).serializeForScriptFunction(e)}static deserialize(e){return new r(e.deserializeStr())}},h=class r extends o{constructor(e){super(),typeof e<"u"&&e!==null?this.vec=new t([e]):this.vec=new t([]),[this.value]=this.vec.values}serializeForEntryFunction(e){e.serializeAsBytes(this)}unwrap(){if(this.isSome())return this.vec.values[0];throw new Error("Called unwrap on a MoveOption with no value")}isSome(){return this.vec.values.length===1}serialize(e){this.vec.serialize(e)}static U8(e){return new r(e!=null?new s(e):void 0)}static U16(e){return new r(e!=null?new d(e):void 0)}static U32(e){return new r(e!=null?new m(e):void 0)}static U64(e){return new r(e!=null?new w(e):void 0)}static U128(e){return new r(e!=null?new p(e):void 0)}static U256(e){return new r(e!=null?new y(e):void 0)}static Bool(e){return new r(e!=null?new c(e):void 0)}static I8(e){return new r(e!=null?new z(e):void 0)}static I16(e){return new r(e!=null?new U(e):void 0)}static I32(e){return new r(e!=null?new A(e):void 0)}static I64(e){return new r(e!=null?new f(e):void 0)}static I128(e){return new r(e!=null?new b(e):void 0)}static I256(e){return new r(e!=null?new I(e):void 0)}static MoveString(e){return new r(e!=null?new a(e):void 0)}static deserialize(e,n){let i=t.deserialize(e,n);return new r(i.values[0])}};export{t as a,v as b,a as c,h as d};
|
|
2
|
-
//# sourceMappingURL=chunk-WFZFTRRS.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bcs/serializable/moveStructs.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Bool, U128, U16, U256, U32, U64, U8, I8, I16, I32, I64, I128, I256 } from \"./movePrimitives\";\nimport { Serializable, Serializer } from \"../serializer\";\nimport { Deserializable, Deserializer } from \"../deserializer\";\nimport { AnyNumber, HexInput, ScriptTransactionArgumentVariants } from \"../../types\";\nimport { Hex } from \"../../core/hex\";\nimport { EntryFunctionArgument, TransactionArgument } from \"../../transactions/instances/transactionArgument\";\n\n/**\n * This class is the Aptos Typescript SDK representation of a Move `vector<T>`,\n * where `T` represents either a primitive type (`bool`, `u8`, `u64`, ...)\n * or a BCS-serializable struct itself.\n *\n * It is a BCS-serializable, array-like type that contains an array of values of type `T`,\n * where `T` is a class that implements `Serializable`.\n *\n * The purpose of this class is to facilitate easy construction of BCS-serializable\n * Move `vector<T>` types.\n *\n * @example\n * // in Move: `vector<u8> [1, 2, 3, 4];`\n * const vecOfU8s = new MoveVector<U8>([new U8(1), new U8(2), new U8(3), new U8(4)]);\n * // in Move: `std::bcs::to_bytes(vector<u8> [1, 2, 3, 4]);`\n * const bcsBytes = vecOfU8s.toUint8Array();\n *\n * // vector<vector<u8>> [ vector<u8> [1], vector<u8> [1, 2, 3, 4], vector<u8> [5, 6, 7, 8] ];\n * const vecOfVecs = new MoveVector<MoveVector<U8>>([\n * new MoveVector<U8>([new U8(1)]),\n * MoveVector.U8([1, 2, 3, 4]),\n * MoveVector.U8([5, 6, 7, 8]),\n * ]);\n *\n * // vector<Option<u8>> [ std::option::some<u8>(1), std::option::some<u8>(2) ];\n * const vecOfOptionU8s = new MoveVector<MoveOption<U8>>([\n * MoveOption.U8(1),\n * MoveOption.U8(2),\n * ]);\n *\n * // vector<MoveString> [ std::string::utf8(b\"hello\"), std::string::utf8(b\"world\") ];\n * const vecOfStrings = new MoveVector([new MoveString(\"hello\"), new MoveString(\"world\")]);\n * const vecOfStrings2 = MoveVector.MoveString([\"hello\", \"world\"]);\n *\n * @param values an Array<T> of values where T is a class that implements Serializable\n * @returns a `MoveVector<T>` with the values `values`\n * @group Implementation\n * @category BCS\n */\nexport class MoveVector<T extends Serializable & EntryFunctionArgument>\n extends Serializable\n implements TransactionArgument\n{\n public values: Array<T>;\n\n /**\n * Initializes a new instance of the class with an optional value.\n * This constructor sets up the internal vector based on the provided value.\n *\n * @param values - The initial value to be stored in the vector, or null to initialize an empty vector.\n * @group Implementation\n * @category BCS\n */\n constructor(values: Array<T>) {\n super();\n this.values = values;\n }\n\n /**\n * Serializes the current instance into a byte sequence suitable for entry functions.\n * This allows the data to be properly formatted for transmission or storage.\n * Uses the optimized serializeAsBytes method to reduce allocations.\n *\n * @param serializer - The serializer instance used to serialize the byte sequence.\n * @group Implementation\n * @category BCS\n */\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n /**\n * NOTE: This function will only work when the inner values in the `MoveVector` are `U8`s.\n * @param serializer\n * @group Implementation\n * @category BCS\n */\n\n /**\n * Serialize the string as a fixed byte string without the length prefix for use in a script function.\n * @param serializer - The serializer used to convert the byte vector into a format suitable for a script function.\n * @group Implementation\n * @category BCS\n */\n serializeForScriptFunction(serializer: Serializer): void {\n // This checks if the type of a non-empty vector is of type other than U8. If so, we use the Serialized\n // transaction argument type to serialize the argument.\n if (this.values[0] !== undefined && !(this.values[0] instanceof U8)) {\n const serialized = new Serialized(this.bcsToBytes());\n serialized.serializeForScriptFunction(serializer);\n return;\n }\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U8Vector);\n serializer.serialize(this);\n }\n\n /**\n * Factory method to generate a MoveVector<U8> from a `number` or `undefined`.\n *\n * This method allows you to create a MoveVector that encapsulates a U8 value, enabling you to handle optional U8 values\n * effectively.\n *\n * @param values - The values used to fill the MoveVector. If `values` is undefined or null, the resulting MoveVector's\n * `.isSome()` method will return false.\n * @returns A MoveVector<U8> with an inner value `value`.\n *\n * @example\n * ```typescript\n * const v = MoveVector.U8([1, 2, 3, 4]);\n * ```\n * @group Implementation\n * @category BCS\n */\n static U8(values: Array<number> | HexInput): MoveVector<U8> {\n let numbers: Array<number>;\n\n if (Array.isArray(values) && values.length === 0) {\n // Handle empty array, since it won't have a \"first value\"\n numbers = [];\n } else if (Array.isArray(values) && typeof values[0] === \"number\") {\n numbers = values;\n } else if (typeof values === \"string\") {\n const hex = Hex.fromHexInput(values);\n numbers = Array.from(hex.toUint8Array());\n } else if (values instanceof Uint8Array) {\n numbers = Array.from(values);\n } else {\n throw new Error(\"Invalid input type, must be an number[], Uint8Array, or hex string\");\n }\n\n return new MoveVector<U8>(numbers.map((v) => new U8(v)));\n }\n\n /**\n * Factory method to generate a MoveOption<U16> from a `number` or `null`.\n *\n * This method allows you to create a MoveVector that can either hold a U16 value or be empty.\n *\n * @param values - The value used to fill the MoveVector. If `value` is null or undefined, the resulting MoveVector's\n * `.isSome()` method will return false.\n * @returns A MoveVector<U16> with an inner value `value`.\n * @example\n * ```typescript\n * const v = MoveVector.U16([1, 2, 3, 4]);\n * ```\n * @group Implementation\n * @category BCS\n\n */\n static U16(values: Array<number>): MoveVector<U16> {\n return new MoveVector<U16>(values.map((v) => new U16(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<U32> from a `number` or `null`.\n *\n * This method allows you to create a MoveVector that can either hold a U32 value or be empty.\n *\n * @param values - The value used to fill the MoveVector. If `value` is null or undefined,\n * the resulting MoveVector's .isSome() method will return false.\n * @returns A MoveVector<U32> with an inner value `value`.\n *\n * @example\n * ```\n * const v = MoveVector.U32([1, 2, 3, 4]);\n * ```\n * @group Implementation\n * @category BCS\n\n */\n static U32(values: Array<number>): MoveVector<U32> {\n return new MoveVector<U32>(values.map((v) => new U32(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<U64> from a number, bigint, or null/undefined.\n * This allows for the creation of an optional U64 value that can be checked for presence.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined or null, the resulting MoveVector's\n * `.isSome()` method will return false.\n * @returns A MoveVector<U64> with an inner value `value`.\n *\n * @example\n * ```typescript\n * const v = MoveVector.U64([1, 2, 3, 4]);\n * ```\n * @group Implementation\n * @category BCS\n */\n static U64(values: Array<AnyNumber>): MoveVector<U64> {\n return new MoveVector<U64>(values.map((v) => new U64(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<U128> from a number, bigint, or undefined.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined, the resulting MoveVector's `.isSome()`\n * method will return false.\n * @returns A MoveVector<U128> with an inner value `value`.\n *\n * @example\n * ```typescript\n * const v = MoveVector.U128([1, 2, 3, 4]);\n * ```\n * @group Implementation\n * @category BCS\n */\n static U128(values: Array<AnyNumber>): MoveVector<U128> {\n return new MoveVector<U128>(values.map((v) => new U128(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<U256> from a number, bigint, or null/undefined.\n * This allows for the creation of an optional U256 value, enabling checks for presence or absence of a value.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined or null,\n * the resulting MoveVector's .isSome() method will return false.\n * @returns A MoveVector<U256> with an inner value `value`.\n *\n * @example\n * ```typescript\n * const v = MoveVector.U256([1, 2, 3, 4]);\n * ```\n * @group Implementation\n * @category BCS\n */\n static U256(values: Array<AnyNumber>): MoveVector<U256> {\n return new MoveVector<U256>(values.map((v) => new U256(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<Bool> from a `boolean` or `undefined`.\n * This method allows you to create an optional boolean value that can be used in various contexts where a boolean may or may\n * not be present.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined, the resulting MoveVector's .isSome() method\n * will return false.\n * @returns A MoveVector<Bool> with an inner value `value`.\n *\n * @example\n * * const v = MoveVector.Bool([true, false, true, false]);\n * @group Implementation\n * @category BCS\n */\n static Bool(values: Array<boolean>): MoveVector<Bool> {\n return new MoveVector<Bool>(values.map((v) => new Bool(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<I8> from an array of numbers.\n *\n * @param values - The values used to fill the MoveVector.\n * @returns A MoveVector<I8> with the inner values.\n *\n * @example\n * ```typescript\n * const v = MoveVector.I8([-1, 0, 1, 127]);\n * ```\n * @group Implementation\n * @category BCS\n */\n static I8(values: Array<number>): MoveVector<I8> {\n return new MoveVector<I8>(values.map((v) => new I8(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<I16> from an array of numbers.\n *\n * @param values - The values used to fill the MoveVector.\n * @returns A MoveVector<I16> with the inner values.\n *\n * @example\n * ```typescript\n * const v = MoveVector.I16([-1, 0, 1, 32767]);\n * ```\n * @group Implementation\n * @category BCS\n */\n static I16(values: Array<number>): MoveVector<I16> {\n return new MoveVector<I16>(values.map((v) => new I16(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<I32> from an array of numbers.\n *\n * @param values - The values used to fill the MoveVector.\n * @returns A MoveVector<I32> with the inner values.\n *\n * @example\n * ```typescript\n * const v = MoveVector.I32([-1, 0, 1, 2147483647]);\n * ```\n * @group Implementation\n * @category BCS\n */\n static I32(values: Array<number>): MoveVector<I32> {\n return new MoveVector<I32>(values.map((v) => new I32(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<I64> from an array of numbers or bigints.\n *\n * @param values - The values used to fill the MoveVector.\n * @returns A MoveVector<I64> with the inner values.\n *\n * @example\n * ```typescript\n * const v = MoveVector.I64([-1n, 0n, 1n, 9223372036854775807n]);\n * ```\n * @group Implementation\n * @category BCS\n */\n static I64(values: Array<AnyNumber>): MoveVector<I64> {\n return new MoveVector<I64>(values.map((v) => new I64(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<I128> from an array of numbers or bigints.\n *\n * @param values - The values used to fill the MoveVector.\n * @returns A MoveVector<I128> with the inner values.\n *\n * @example\n * ```typescript\n * const v = MoveVector.I128([-1n, 0n, 1n]);\n * ```\n * @group Implementation\n * @category BCS\n */\n static I128(values: Array<AnyNumber>): MoveVector<I128> {\n return new MoveVector<I128>(values.map((v) => new I128(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<I256> from an array of numbers or bigints.\n *\n * @param values - The values used to fill the MoveVector.\n * @returns A MoveVector<I256> with the inner values.\n *\n * @example\n * ```typescript\n * const v = MoveVector.I256([-1n, 0n, 1n]);\n * ```\n * @group Implementation\n * @category BCS\n */\n static I256(values: Array<AnyNumber>): MoveVector<I256> {\n return new MoveVector<I256>(values.map((v) => new I256(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<MoveString> from a `string` or `undefined`.\n * This function creates a MoveVector that encapsulates a MoveString if the provided value is not null or undefined.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined, the resulting MoveVector's .isSome() method\n * will return false.\n * @returns A MoveVector<MoveString> with an inner value `value`.\n *\n * @example\n * const v = MoveVector.MoveString([\"hello\", \"world\"]);\n * @group Implementation\n * @category BCS\n */\n static MoveString(values: Array<string>): MoveVector<MoveString> {\n return new MoveVector<MoveString>(values.map((v) => new MoveString(v)));\n }\n\n /**\n * Serializes the current object using the provided serializer.\n * This function will serialize the value if it is present.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category BCS\n */\n serialize(serializer: Serializer): void;\n serialize(serializer: Serializer): void {\n serializer.serializeVector(this.values);\n }\n\n /**\n * Deserialize a MoveVector of type T, specifically where T is a Serializable and Deserializable type.\n *\n * NOTE: This only works with a depth of one. Generics will not work.\n *\n * NOTE: This will not work with types that aren't of the Serializable class.\n *\n * If you're looking for a more flexible deserialization function, you can use the deserializeVector function\n * in the Deserializer class.\n *\n * @example\n * const vec = MoveVector.deserialize(deserializer, U64);\n * @param deserializer the Deserializer instance to use, with bytes loaded into it already.\n * @param cls the class to typecast the input values to, must be a Serializable and Deserializable type.\n * @returns a MoveVector of the corresponding class T\n *\n * @group Implementation\n * @category BCS\n */\n static deserialize<T extends Serializable & EntryFunctionArgument>(\n deserializer: Deserializer,\n cls: Deserializable<T>,\n ): MoveVector<T> {\n const length = deserializer.deserializeUleb128AsU32();\n const values = new Array<T>();\n for (let i = 0; i < length; i += 1) {\n values.push(cls.deserialize(deserializer));\n }\n return new MoveVector(values);\n }\n}\n\n/**\n * Represents a serialized data structure that encapsulates a byte array.\n * This class extends the Serializable class and provides methods for serialization\n * and deserialization of byte data, as well as converting to a MoveVector.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class Serialized extends Serializable implements TransactionArgument {\n public readonly value: Uint8Array;\n\n constructor(value: HexInput) {\n super();\n this.value = Hex.fromHexInput(value).toUint8Array();\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n this.serialize(serializer);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.Serialized);\n this.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): Serialized {\n return new Serialized(deserializer.deserializeBytes());\n }\n\n /**\n * Deserialize the bytecode into a MoveVector of the specified type.\n * This function allows you to convert serialized data into a usable MoveVector format.\n *\n * @param cls - The class type of the elements in the MoveVector.\n * @group Implementation\n * @category BCS\n */\n toMoveVector<T extends Serializable & EntryFunctionArgument>(cls: Deserializable<T>): MoveVector<T> {\n const deserializer = new Deserializer(this.bcsToBytes());\n deserializer.deserializeUleb128AsU32();\n const vec = deserializer.deserializeVector(cls);\n return new MoveVector(vec);\n }\n}\n\n/**\n * Represents a string value that can be serialized and deserialized.\n * This class extends the Serializable base class and provides methods\n * for serializing the string in different contexts, such as for entry\n * functions and script functions.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class MoveString extends Serializable implements TransactionArgument {\n public value: string;\n\n constructor(value: string) {\n super();\n this.value = value;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeStr(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n // Serialize the string as a fixed byte string, i.e., without the length prefix\n const textEncoder = new TextEncoder();\n const fixedStringBytes = textEncoder.encode(this.value);\n // Put those bytes into a vector<u8> and serialize it as a script function argument\n const vectorU8 = MoveVector.U8(fixedStringBytes);\n vectorU8.serializeForScriptFunction(serializer);\n }\n\n static deserialize(deserializer: Deserializer): MoveString {\n return new MoveString(deserializer.deserializeStr());\n }\n}\n\nexport class MoveOption<T extends Serializable & EntryFunctionArgument>\n extends Serializable\n implements EntryFunctionArgument\n{\n private vec: MoveVector<T>;\n\n public readonly value?: T;\n\n constructor(value?: T | null) {\n super();\n if (typeof value !== \"undefined\" && value !== null) {\n this.vec = new MoveVector([value]);\n } else {\n this.vec = new MoveVector([]);\n }\n\n [this.value] = this.vec.values;\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeAsBytes(this);\n }\n\n /**\n * Retrieves the inner value of the MoveOption.\n *\n * This method is inspired by Rust's `Option<T>.unwrap()`, where attempting to unwrap a `None` value results in a panic.\n * This method will throw an error if the value is not present.\n *\n * @example\n * const option = new MoveOption<Bool>(new Bool(true));\n * const value = option.unwrap(); // Returns the Bool instance\n *\n * @throws {Error} Throws an error if the MoveOption does not contain a value.\n *\n * @returns {T} The contained value if present.\n * @group Implementation\n * @category BCS\n */\n unwrap(): T {\n if (!this.isSome()) {\n throw new Error(\"Called unwrap on a MoveOption with no value\");\n } else {\n return this.vec.values[0];\n }\n }\n\n /**\n * Check if the MoveOption has a value.\n *\n * @returns {boolean} Returns true if there is exactly one value in the MoveOption.\n * @group Implementation\n * @category BCS\n */\n isSome(): boolean {\n return this.vec.values.length === 1;\n }\n\n serialize(serializer: Serializer): void {\n // serialize 0 or 1\n // if 1, serialize the value\n this.vec.serialize(serializer);\n }\n\n /**\n * Factory method to generate a MoveOption<U8> from a `number` or `undefined`.\n *\n * @example\n * MoveOption.U8(1).isSome() === true;\n * MoveOption.U8().isSome() === false;\n * MoveOption.U8(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U8> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static U8(value?: number | null): MoveOption<U8> {\n return new MoveOption<U8>(value !== null && value !== undefined ? new U8(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U16> from a `number` or `undefined`.\n *\n * @example\n * MoveOption.U16(1).isSome() === true;\n * MoveOption.U16().isSome() === false;\n * MoveOption.U16(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U16> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static U16(value?: number | null): MoveOption<U16> {\n return new MoveOption<U16>(value !== null && value !== undefined ? new U16(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U32> from a `number` or `undefined`.\n *\n * @example\n * MoveOption.U32(1).isSome() === true;\n * MoveOption.U32().isSome() === false;\n * MoveOption.U32(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U32> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static U32(value?: number | null): MoveOption<U32> {\n return new MoveOption<U32>(value !== null && value !== undefined ? new U32(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U64> from a `number` or a `bigint` or `undefined`.\n *\n * @example\n * MoveOption.U64(1).isSome() === true;\n * MoveOption.U64().isSome() === false;\n * MoveOption.U64(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U64> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static U64(value?: AnyNumber | null): MoveOption<U64> {\n return new MoveOption<U64>(value !== null && value !== undefined ? new U64(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U128> from a `number` or a `bigint` or `undefined`.\n *\n * @example\n * MoveOption.U128(1).isSome() === true;\n * MoveOption.U128().isSome() === false;\n * MoveOption.U128(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U128> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static U128(value?: AnyNumber | null): MoveOption<U128> {\n return new MoveOption<U128>(value !== null && value !== undefined ? new U128(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U256> from a `number` or a `bigint` or `undefined`.\n *\n * @example\n * MoveOption.U256(1).isSome() === true;\n * MoveOption.U256().isSome() === false;\n * MoveOption.U256(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U256> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static U256(value?: AnyNumber | null): MoveOption<U256> {\n return new MoveOption<U256>(value !== null && value !== undefined ? new U256(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<Bool> from a `boolean` or `undefined`.\n *\n * @example\n * MoveOption.Bool(true).isSome() === true;\n * MoveOption.Bool().isSome() === false;\n * MoveOption.Bool(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<Bool> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static Bool(value?: boolean | null): MoveOption<Bool> {\n return new MoveOption<Bool>(value !== null && value !== undefined ? new Bool(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<I8> from a `number` or `undefined`.\n *\n * @example\n * MoveOption.I8(1).isSome() === true;\n * MoveOption.I8().isSome() === false;\n * MoveOption.I8(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<I8> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static I8(value?: number | null): MoveOption<I8> {\n return new MoveOption<I8>(value !== null && value !== undefined ? new I8(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<I16> from a `number` or `undefined`.\n *\n * @example\n * MoveOption.I16(1).isSome() === true;\n * MoveOption.I16().isSome() === false;\n * MoveOption.I16(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<I16> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static I16(value?: number | null): MoveOption<I16> {\n return new MoveOption<I16>(value !== null && value !== undefined ? new I16(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<I32> from a `number` or `undefined`.\n *\n * @example\n * MoveOption.I32(1).isSome() === true;\n * MoveOption.I32().isSome() === false;\n * MoveOption.I32(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<I32> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static I32(value?: number | null): MoveOption<I32> {\n return new MoveOption<I32>(value !== null && value !== undefined ? new I32(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<I64> from a `number` or a `bigint` or `undefined`.\n *\n * @example\n * MoveOption.I64(1).isSome() === true;\n * MoveOption.I64().isSome() === false;\n * MoveOption.I64(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<I64> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static I64(value?: AnyNumber | null): MoveOption<I64> {\n return new MoveOption<I64>(value !== null && value !== undefined ? new I64(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<I128> from a `number` or a `bigint` or `undefined`.\n *\n * @example\n * MoveOption.I128(1).isSome() === true;\n * MoveOption.I128().isSome() === false;\n * MoveOption.I128(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<I128> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static I128(value?: AnyNumber | null): MoveOption<I128> {\n return new MoveOption<I128>(value !== null && value !== undefined ? new I128(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<I256> from a `number` or a `bigint` or `undefined`.\n *\n * @example\n * MoveOption.I256(1).isSome() === true;\n * MoveOption.I256().isSome() === false;\n * MoveOption.I256(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<I256> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static I256(value?: AnyNumber | null): MoveOption<I256> {\n return new MoveOption<I256>(value !== null && value !== undefined ? new I256(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<MoveString> from a `string` or `undefined`.\n *\n * @example\n * MoveOption.MoveString(\"hello\").isSome() === true;\n * MoveOption.MoveString(\"\").isSome() === true;\n * MoveOption.MoveString().isSome() === false;\n * MoveOption.MoveString(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<MoveString> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static MoveString(value?: string | null): MoveOption<MoveString> {\n return new MoveOption<MoveString>(value !== null && value !== undefined ? new MoveString(value) : undefined);\n }\n\n static deserialize<U extends Serializable & EntryFunctionArgument>(\n deserializer: Deserializer,\n cls: Deserializable<U>,\n ): MoveOption<U> {\n const vector = MoveVector.deserialize(deserializer, cls);\n return new MoveOption(vector.values[0]);\n }\n}\n"],"mappings":"wPAiDO,IAAMA,EAAN,MAAMC,UACHC,CAEV,CAWE,YAAYC,EAAkB,CAC5B,MAAM,EACN,KAAK,OAASA,CAChB,CAWA,0BAA0BC,EAA8B,CACtDA,EAAW,iBAAiB,IAAI,CAClC,CAeA,2BAA2BA,EAA8B,CAGvD,GAAI,KAAK,OAAO,CAAC,IAAM,QAAa,EAAE,KAAK,OAAO,CAAC,YAAaC,GAAK,CAChD,IAAIC,EAAW,KAAK,WAAW,CAAC,EACxC,2BAA2BF,CAAU,EAChD,MACF,CACAA,EAAW,uBAAgE,EAC3EA,EAAW,UAAU,IAAI,CAC3B,CAmBA,OAAO,GAAGD,EAAkD,CAC1D,IAAII,EAEJ,GAAI,MAAM,QAAQJ,CAAM,GAAKA,EAAO,SAAW,EAE7CI,EAAU,CAAC,UACF,MAAM,QAAQJ,CAAM,GAAK,OAAOA,EAAO,CAAC,GAAM,SACvDI,EAAUJ,UACD,OAAOA,GAAW,SAAU,CACrC,IAAMK,EAAMC,EAAI,aAAaN,CAAM,EACnCI,EAAU,MAAM,KAAKC,EAAI,aAAa,CAAC,CACzC,SAAWL,aAAkB,WAC3BI,EAAU,MAAM,KAAKJ,CAAM,MAE3B,OAAM,IAAI,MAAM,oEAAoE,EAGtF,OAAO,IAAIF,EAAeM,EAAQ,IAAKG,GAAM,IAAIL,EAAGK,CAAC,CAAC,CAAC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,EAAWC,EAAO,OAAO,CAAC,CAAC,CACxC,CACF","names":["MoveVector","_MoveVector","Serializable","values","serializer","U8","Serialized","numbers","hex","Hex","v","U16","U32","U64","U128","U256","Bool","I8","I16","I32","I64","I128","I256","MoveString","deserializer","cls","length","i","_Serialized","value","Deserializer","vec","_MoveString","fixedStringBytes","MoveOption","_MoveOption","vector"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as l}from"./chunk-F4LHBGG2.mjs";import{a as h}from"./chunk-EIWPAECI.mjs";import{a as x}from"./chunk-2VBY2V4Z.mjs";import{a as m}from"./chunk-TSPG5VED.mjs";import{b as c}from"./chunk-66F7RP7K.mjs";import{b as n}from"./chunk-STY74NUA.mjs";import{sha3_256 as A}from"@noble/hashes/sha3";import{p256 as y}from"@noble/curves/nist";var s=class s extends x{constructor(e){super();this.keyType="secp256r1";let r=n.fromHexInput(e),i=r.toUint8Array().length;if(i!==s.LENGTH&&i!==s.COMPRESSED_LENGTH)throw new Error(`PublicKey length should be ${s.LENGTH} or ${s.COMPRESSED_LENGTH}, received ${i}`);if(i===s.COMPRESSED_LENGTH){let u=y.ProjectivePoint.fromHex(r.toUint8Array());this.key=n.fromHexInput(u.toRawBytes(!1))}else this.key=r}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}bcsToBytes(){let e=new c;return this.serialize(e),e.toUint8Array()}verifySignature(e){let{message:r,signature:i}=e,u=n.fromHexInput(r).toUint8Array(),f=A(u),U=i.toUint8Array();return y.verify(U,f,this.toUint8Array())}async verifySignatureAsync(e){return this.verifySignature({message:e.message,signature:e.signature})}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new s(r)}static load(e){let r=e.deserializeBytes();return new s(r)}static isInstance(e){return"key"in e&&e.key?.data?.length===s.LENGTH&&"keyType"in e&&e.keyType==="secp256r1"}authKey(){let e=new c;return e.serializeU32AsUleb128(2),e.serializeFixedBytes(this.bcsToBytes()),m.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}};s.LENGTH=65,s.COMPRESSED_LENGTH=33;var g=s,a=class a extends l{constructor(t,e){super();let r=l.parseHexInput(t,"secp256r1",e),i=r.toUint8Array().length;if(i!==a.LENGTH)throw new Error(`PrivateKey length should be ${a.LENGTH}, received ${i}`);this.key=r}toUint8Array(){return this.key.toUint8Array()}toString(){return l.formatPrivateKey(this.key.toString(),"secp256r1")}toHexString(){return this.key.toString()}sign(t){let e=n.fromHexInput(t),r=A(e.toUint8Array()),i=y.sign(r,this.key.toUint8Array());return new p(i.toCompactRawBytes())}serialize(t){t.serializeBytes(this.toUint8Array())}static deserialize(t){let e=t.deserializeBytes();return new a(e)}static generate(){let t=y.utils.randomPrivateKey();return new a(t)}publicKey(){let t=y.getPublicKey(this.key.toUint8Array(),!1);return new g(t)}};a.LENGTH=32;var H=a,S=class d extends h{constructor(t,e,r){super(),this.signature=n.fromHexInput(t),this.authenticatorData=n.fromHexInput(e),this.clientDataJSON=n.fromHexInput(r)}toUint8Array(){return this.signature.toUint8Array()}serialize(t){t.serializeU32AsUleb128(0),t.serializeBytes(this.signature.toUint8Array()),t.serializeBytes(this.authenticatorData.toUint8Array()),t.serializeBytes(this.clientDataJSON.toUint8Array())}bcsToBytes(){let t=new c;return this.serialize(t),t.toUint8Array()}bcsToHex(){return n.fromHexInput(this.bcsToBytes())}toStringWithoutPrefix(){return n.fromHexInput(this.bcsToBytes()).toString()}static deserialize(t){let e=t.deserializeUleb128AsU32();if(e!==0)throw new Error(`Invalid id for WebAuthnSignature: ${e}`);let r=t.deserializeBytes(),i=t.deserializeBytes(),u=t.deserializeBytes();return new d(r,i,u)}},o=class o extends h{constructor(t){super();let e=n.fromHexInput(t),r=e.toUint8Array().length;if(r!==o.LENGTH)throw new Error(`Signature length should be ${o.LENGTH}, received ${r}`);let i=y.Signature.fromCompact(e.toUint8Array()).normalizeS().toCompactRawBytes();this.data=n.fromHexInput(i)}toUint8Array(){return this.data.toUint8Array()}toString(){return this.data.toString()}serialize(t){t.serializeBytes(this.data.toUint8Array())}static deserialize(t){let e=t.deserializeBytes();return new o(e)}};o.LENGTH=64;var p=o;export{g as a,H as b,S as c,p as d};
|
|
2
|
-
//# sourceMappingURL=chunk-YJVBGKWM.mjs.map
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|