@aptos-labs/ts-sdk 5.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/{account-BDwBREvt.d.ts → account-BW99GTa5.d.ts} +7 -2
- package/dist/common/chunk-A2XB7TVI.js +4 -0
- package/dist/common/{chunk-6MMUUJHX.js.map → chunk-A2XB7TVI.js.map} +1 -1
- package/dist/common/cli/index.d.ts +1 -1
- package/dist/common/cli/index.js +1 -1
- package/dist/common/index.d.ts +328 -10
- package/dist/common/index.js +34 -34
- package/dist/common/index.js.map +1 -1
- package/dist/esm/{Ed25519Account-8ETkcAk_.d.mts → Ed25519Account-CPwej6wB.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-ClxOwjdh.d.mts → account-BortO8g2.d.mts} +6 -1
- package/dist/esm/api/account/abstraction.d.mts +1 -1
- package/dist/esm/api/account/abstraction.mjs +1 -1
- package/dist/esm/api/account.d.mts +30 -9
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +2 -2
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +3 -3
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.d.mts +1 -1
- package/dist/esm/api/coin.d.mts +1 -1
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +2 -2
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/faucet.d.mts +1 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +2 -2
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.d.mts +1 -1
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +3 -3
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.d.mts +3 -3
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/object.d.mts +1 -1
- package/dist/esm/api/object.mjs +1 -1
- package/dist/esm/api/staking.d.mts +1 -1
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/table.d.mts +1 -1
- package/dist/esm/api/table.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +2 -2
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.d.mts +1 -1
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/helpers.d.mts +1 -1
- package/dist/esm/api/transactionSubmission/management.d.mts +2 -2
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.d.mts +2 -2
- package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.mjs.map +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/fixedBytes.d.mts +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/chunk-2PASUPUO.mjs +2 -0
- package/dist/esm/chunk-2PASUPUO.mjs.map +1 -0
- package/dist/esm/{chunk-V74WPKSY.mjs → chunk-2XQKGWHQ.mjs} +2 -2
- package/dist/esm/{chunk-GFFKEZ56.mjs → chunk-4AI7KQQ7.mjs} +2 -2
- package/dist/esm/{chunk-TGRLDWXV.mjs → chunk-6OWBKU7N.mjs} +2 -2
- package/dist/esm/{chunk-DNRUDMMV.mjs → chunk-7EER7GWV.mjs} +2 -2
- package/dist/esm/{chunk-N3O3ULF7.mjs → chunk-AMXZQPUQ.mjs} +2 -2
- package/dist/esm/chunk-CIJA7ONS.mjs +2 -0
- package/dist/esm/{chunk-5FI4545P.mjs.map → chunk-CIJA7ONS.mjs.map} +1 -1
- package/dist/esm/{chunk-RQX6JOEN.mjs → chunk-EF4FA5I6.mjs} +2 -2
- package/dist/esm/chunk-I7XT6L7S.mjs +2 -0
- package/dist/esm/chunk-I7XT6L7S.mjs.map +1 -0
- package/dist/esm/{chunk-HNBKTJPN.mjs → chunk-JABP65XD.mjs} +2 -2
- package/dist/esm/chunk-L72TIN7T.mjs +4 -0
- package/dist/esm/chunk-L72TIN7T.mjs.map +1 -0
- package/dist/esm/{chunk-EM52Z7T7.mjs → chunk-M3AO73ZL.mjs} +2 -2
- package/dist/esm/chunk-MCFQE4GC.mjs +2 -0
- package/dist/esm/chunk-MCFQE4GC.mjs.map +1 -0
- package/dist/esm/{chunk-LWL57YFU.mjs → chunk-QP2BY4PK.mjs} +2 -2
- package/dist/esm/{chunk-GMQCQDW4.mjs → chunk-SJDCGNWU.mjs} +2 -2
- package/dist/esm/{chunk-ES2KP6BS.mjs → chunk-WHSTLR3F.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 +3 -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 +306 -0
- package/dist/esm/core/crypto/secp256r1.mjs +2 -0
- package/dist/esm/core/crypto/secp256r1.mjs.map +1 -0
- package/dist/esm/core/crypto/signature.d.mts +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 +3 -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-CUPEnP-W.d.mts → federatedKeyless-CTzDAQTu.d.mts} +1 -1
- package/dist/esm/index.d.mts +4 -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 +21 -3
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +2 -2
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.d.mts +1 -1
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +2 -2
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/faucet.d.mts +1 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +2 -2
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.d.mts +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.d.mts +3 -3
- package/dist/esm/internal/keyless.mjs +1 -1
- package/dist/esm/internal/object.d.mts +1 -1
- package/dist/esm/internal/object.mjs +1 -1
- package/dist/esm/internal/staking.d.mts +1 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/table.d.mts +1 -1
- package/dist/esm/internal/table.mjs +1 -1
- package/dist/esm/internal/transaction.d.mts +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +2 -2
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/utils/index.d.mts +1 -1
- package/dist/esm/internal/utils/index.mjs +1 -1
- package/dist/esm/internal/utils/utils.d.mts +1 -1
- package/dist/esm/internal/utils/utils.mjs +1 -1
- package/dist/esm/internal/view.d.mts +1 -1
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.d.mts +1 -1
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.d.mts +1 -1
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.d.mts +1 -1
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.d.mts +1 -1
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/chainId.d.mts +1 -1
- package/dist/esm/transactions/instances/identifier.d.mts +1 -1
- package/dist/esm/transactions/instances/index.d.mts +1 -1
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.d.mts +1 -1
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.d.mts +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.d.mts +1 -1
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.d.mts +1 -1
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.d.mts +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionArgument.d.mts +1 -1
- package/dist/esm/transactions/instances/transactionPayload.d.mts +1 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.d.mts +2 -2
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.d.mts +2 -2
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.d.mts +2 -2
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.d.mts +1 -1
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.d.mts +1 -1
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/transactions/types.d.mts +1 -1
- package/dist/esm/types/index.d.mts +1 -1
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/types/types.d.mts +1 -1
- package/dist/esm/types/types.mjs +1 -1
- package/dist/esm/utils/helpers.d.mts +1 -1
- package/dist/esm/utils/helpers.mjs +1 -1
- package/dist/esm/utils/index.d.mts +1 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/normalizeBundle.d.mts +1 -1
- package/dist/esm/utils/normalizeBundle.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +2 -3
- package/src/api/account.ts +32 -7
- package/src/core/crypto/index.ts +1 -0
- package/src/core/crypto/privateKey.ts +1 -0
- package/src/core/crypto/secp256k1.ts +9 -1
- package/src/core/crypto/secp256r1.ts +495 -0
- package/src/core/crypto/singleKey.ts +11 -0
- package/src/internal/account.ts +33 -0
- package/src/types/types.ts +5 -0
- package/src/version.ts +1 -1
- package/dist/common/chunk-6MMUUJHX.js +0 -4
- package/dist/esm/chunk-5FI4545P.mjs +0 -2
- package/dist/esm/chunk-DIGP2ALY.mjs +0 -4
- package/dist/esm/chunk-DIGP2ALY.mjs.map +0 -1
- package/dist/esm/chunk-IJE2LVZG.mjs +0 -2
- package/dist/esm/chunk-IJE2LVZG.mjs.map +0 -1
- package/dist/esm/chunk-ROT6S6BM.mjs +0 -2
- package/dist/esm/chunk-ROT6S6BM.mjs.map +0 -1
- /package/dist/esm/{chunk-V74WPKSY.mjs.map → chunk-2XQKGWHQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-GFFKEZ56.mjs.map → chunk-4AI7KQQ7.mjs.map} +0 -0
- /package/dist/esm/{chunk-TGRLDWXV.mjs.map → chunk-6OWBKU7N.mjs.map} +0 -0
- /package/dist/esm/{chunk-DNRUDMMV.mjs.map → chunk-7EER7GWV.mjs.map} +0 -0
- /package/dist/esm/{chunk-N3O3ULF7.mjs.map → chunk-AMXZQPUQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-RQX6JOEN.mjs.map → chunk-EF4FA5I6.mjs.map} +0 -0
- /package/dist/esm/{chunk-HNBKTJPN.mjs.map → chunk-JABP65XD.mjs.map} +0 -0
- /package/dist/esm/{chunk-EM52Z7T7.mjs.map → chunk-M3AO73ZL.mjs.map} +0 -0
- /package/dist/esm/{chunk-LWL57YFU.mjs.map → chunk-QP2BY4PK.mjs.map} +0 -0
- /package/dist/esm/{chunk-GMQCQDW4.mjs.map → chunk-SJDCGNWU.mjs.map} +0 -0
- /package/dist/esm/{chunk-ES2KP6BS.mjs.map → chunk-WHSTLR3F.mjs.map} +0 -0
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
// Copyright © Aptos Foundation
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { sha3_256 } from "@noble/hashes/sha3";
|
|
5
|
+
import { p256 } from "@noble/curves/nist.js";
|
|
6
|
+
import { Deserializer, Serializer } from "../../bcs";
|
|
7
|
+
import { Hex } from "../hex";
|
|
8
|
+
import {
|
|
9
|
+
HexInput,
|
|
10
|
+
PrivateKeyVariants,
|
|
11
|
+
SigningScheme as AuthenticationKeyScheme,
|
|
12
|
+
AnyPublicKeyVariant,
|
|
13
|
+
} from "../../types";
|
|
14
|
+
import { PublicKey, VerifySignatureAsyncArgs } from "./publicKey";
|
|
15
|
+
import { PrivateKey } from "./privateKey";
|
|
16
|
+
import { Signature } from "./signature";
|
|
17
|
+
import { AuthenticationKey } from "../authenticationKey";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Represents a Secp256r1 ECDSA public key.
|
|
21
|
+
*
|
|
22
|
+
* @extends PublicKey
|
|
23
|
+
* @property LENGTH - The length of the Secp256r1 public key in bytes.
|
|
24
|
+
* @group Implementation
|
|
25
|
+
* @category Serialization
|
|
26
|
+
*/
|
|
27
|
+
export class Secp256r1PublicKey extends PublicKey {
|
|
28
|
+
// Secp256r1 ecdsa public keys contain a prefix indicating compression and two 32-byte coordinates.
|
|
29
|
+
static readonly LENGTH: number = 65;
|
|
30
|
+
|
|
31
|
+
// If it's compressed, it is only 33 bytes
|
|
32
|
+
static readonly COMPRESSED_LENGTH: number = 33;
|
|
33
|
+
|
|
34
|
+
// Hex value of the public key
|
|
35
|
+
private readonly key: Hex;
|
|
36
|
+
|
|
37
|
+
// Identifier to distinguish from Secp256k1PublicKey
|
|
38
|
+
public readonly keyType: string = "secp256r1";
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Create a new PublicKey instance from a HexInput, which can be a string or Uint8Array.
|
|
42
|
+
* This constructor validates the length of the provided public key data.
|
|
43
|
+
*
|
|
44
|
+
* @param hexInput - A HexInput (string or Uint8Array) representing the public key data.
|
|
45
|
+
* @throws Error if the length of the public key data is not equal to Secp256r1PublicKey.LENGTH or COMPRESSED_LENGTH.
|
|
46
|
+
* @group Implementation
|
|
47
|
+
* @category Serialization
|
|
48
|
+
*/
|
|
49
|
+
constructor(hexInput: HexInput) {
|
|
50
|
+
super();
|
|
51
|
+
|
|
52
|
+
const hex = Hex.fromHexInput(hexInput);
|
|
53
|
+
const keyLength = hex.toUint8Array().length;
|
|
54
|
+
if (keyLength !== Secp256r1PublicKey.LENGTH && keyLength !== Secp256r1PublicKey.COMPRESSED_LENGTH) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`PublicKey length should be ${Secp256r1PublicKey.LENGTH} or ${Secp256r1PublicKey.COMPRESSED_LENGTH}, received ${keyLength}`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (keyLength === Secp256r1PublicKey.COMPRESSED_LENGTH) {
|
|
61
|
+
const point = p256.ProjectivePoint.fromHex(hex.toUint8Array());
|
|
62
|
+
this.key = Hex.fromHexInput(point.toRawBytes(false));
|
|
63
|
+
} else {
|
|
64
|
+
this.key = hex;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Get the data as a Uint8Array representation.
|
|
70
|
+
*
|
|
71
|
+
* @returns Uint8Array representation of the data.
|
|
72
|
+
* @group Implementation
|
|
73
|
+
* @category Serialization
|
|
74
|
+
*/
|
|
75
|
+
toUint8Array(): Uint8Array {
|
|
76
|
+
return this.key.toUint8Array();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Get the public key as a hex string with the 0x prefix.
|
|
81
|
+
*
|
|
82
|
+
* @returns string representation of the public key.
|
|
83
|
+
* @group Implementation
|
|
84
|
+
* @category Serialization
|
|
85
|
+
*/
|
|
86
|
+
toString(): string {
|
|
87
|
+
return this.key.toString();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Converts the public key to BCS (Binary Canonical Serialization) bytes.
|
|
92
|
+
* This function serializes the public key data into a byte array format suitable for transmission or storage.
|
|
93
|
+
*
|
|
94
|
+
* @returns Uint8Array representation of the serialized public key.
|
|
95
|
+
* @group Implementation
|
|
96
|
+
* @category Serialization
|
|
97
|
+
*/
|
|
98
|
+
bcsToBytes() {
|
|
99
|
+
const serializer = new Serializer();
|
|
100
|
+
this.serialize(serializer);
|
|
101
|
+
return serializer.toUint8Array();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Verifies a Secp256r1 signature against the public key.
|
|
106
|
+
*
|
|
107
|
+
* This function checks the validity of a signature for a given message.
|
|
108
|
+
*
|
|
109
|
+
* @param args - The arguments for verifying the signature.
|
|
110
|
+
* @param args.message - The message that was signed.
|
|
111
|
+
* @param args.signature - The signature to verify against the public key.
|
|
112
|
+
* @group Implementation
|
|
113
|
+
* @category Serialization
|
|
114
|
+
*/
|
|
115
|
+
verifySignature(args: { message: HexInput; signature: Signature }): boolean {
|
|
116
|
+
const { message, signature } = args;
|
|
117
|
+
|
|
118
|
+
const msgHex = Hex.fromHexInput(message).toUint8Array();
|
|
119
|
+
const sha3Message = sha3_256(msgHex);
|
|
120
|
+
const rawSignature = signature.toUint8Array();
|
|
121
|
+
|
|
122
|
+
return p256.verify(rawSignature, sha3Message, this.toUint8Array());
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Note: Secp256r1Signatures can be verified synchronously.
|
|
127
|
+
*
|
|
128
|
+
* Verifies the provided signature against the given message.
|
|
129
|
+
* This function helps ensure the integrity and authenticity of the message by confirming that the signature is valid.
|
|
130
|
+
*
|
|
131
|
+
* @param args - The arguments for signature verification.
|
|
132
|
+
* @param args.message - The message that was signed.
|
|
133
|
+
* @param args.signature - The signature to verify, which must be an instance of Secp256r1Signature.
|
|
134
|
+
* @returns A boolean indicating whether the signature is valid for the given message.
|
|
135
|
+
* @group Implementation
|
|
136
|
+
* @category Serialization
|
|
137
|
+
*/
|
|
138
|
+
async verifySignatureAsync(args: VerifySignatureAsyncArgs): Promise<boolean> {
|
|
139
|
+
return this.verifySignature({ message: args.message, signature: args.signature });
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Serializes the data into a byte array using the provided serializer.
|
|
144
|
+
* This function is essential for converting data into a format suitable for transmission or storage.
|
|
145
|
+
*
|
|
146
|
+
* @param serializer - The serializer instance used to convert the data.
|
|
147
|
+
* @group Implementation
|
|
148
|
+
* @category Serialization
|
|
149
|
+
*/
|
|
150
|
+
serialize(serializer: Serializer): void {
|
|
151
|
+
serializer.serializeBytes(this.key.toUint8Array());
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Deserializes a Secp256r1PublicKey from the provided deserializer.
|
|
156
|
+
* This function allows you to reconstruct a Secp256r1PublicKey object from its serialized byte representation.
|
|
157
|
+
*
|
|
158
|
+
* @param deserializer - The deserializer instance used to read the serialized data.
|
|
159
|
+
* @group Implementation
|
|
160
|
+
* @category Serialization
|
|
161
|
+
*/
|
|
162
|
+
static deserialize(deserializer: Deserializer): Secp256r1PublicKey {
|
|
163
|
+
const bytes = deserializer.deserializeBytes();
|
|
164
|
+
return new Secp256r1PublicKey(bytes);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Loads a Secp256r1PublicKey from the provided deserializer.
|
|
169
|
+
*
|
|
170
|
+
* @param deserializer - The deserializer instance used to read the serialized data.
|
|
171
|
+
* @group Implementation
|
|
172
|
+
* @category Serialization
|
|
173
|
+
*/
|
|
174
|
+
static load(deserializer: Deserializer): Secp256r1PublicKey {
|
|
175
|
+
const bytes = deserializer.deserializeBytes();
|
|
176
|
+
return new Secp256r1PublicKey(bytes);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Determines if the provided public key is a valid instance of a Secp256r1 public key.
|
|
181
|
+
* This function checks for the presence of a "key" property and validates the length of the key data.
|
|
182
|
+
*
|
|
183
|
+
* @param publicKey - The public key to validate.
|
|
184
|
+
* @returns A boolean indicating whether the public key is a valid Secp256r1 public key.
|
|
185
|
+
* @group Implementation
|
|
186
|
+
* @category Serialization
|
|
187
|
+
*/
|
|
188
|
+
static isInstance(publicKey: PublicKey): publicKey is Secp256r1PublicKey {
|
|
189
|
+
return (
|
|
190
|
+
"key" in publicKey &&
|
|
191
|
+
(publicKey.key as any)?.data?.length === Secp256r1PublicKey.LENGTH &&
|
|
192
|
+
"keyType" in publicKey &&
|
|
193
|
+
(publicKey as any).keyType === "secp256r1"
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Generates an authentication key from the public key using the Secp256r1 scheme.
|
|
199
|
+
* This function is essential for creating a secure authentication key that can be used for further cryptographic operations.
|
|
200
|
+
*
|
|
201
|
+
* @returns {AuthenticationKey} The generated authentication key.
|
|
202
|
+
* @group Implementation
|
|
203
|
+
* @category Serialization
|
|
204
|
+
*/
|
|
205
|
+
authKey(): AuthenticationKey {
|
|
206
|
+
const serializer = new Serializer();
|
|
207
|
+
serializer.serializeU32AsUleb128(AnyPublicKeyVariant.Secp256r1);
|
|
208
|
+
serializer.serializeFixedBytes(this.bcsToBytes());
|
|
209
|
+
return AuthenticationKey.fromSchemeAndBytes({
|
|
210
|
+
scheme: AuthenticationKeyScheme.SingleKey,
|
|
211
|
+
input: serializer.toUint8Array(),
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Represents a Secp256r1 ECDSA private key, providing functionality to create, sign messages,
|
|
218
|
+
* derive public keys, and serialize/deserialize the key.
|
|
219
|
+
* @group Implementation
|
|
220
|
+
* @category Serialization
|
|
221
|
+
*/
|
|
222
|
+
export class Secp256r1PrivateKey extends PrivateKey {
|
|
223
|
+
/**
|
|
224
|
+
* Length of Secp256r1 ecdsa private key
|
|
225
|
+
* @group Implementation
|
|
226
|
+
* @category Serialization
|
|
227
|
+
*/
|
|
228
|
+
static readonly LENGTH: number = 32;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* The private key bytes
|
|
232
|
+
* @private
|
|
233
|
+
* @group Implementation
|
|
234
|
+
* @category Serialization
|
|
235
|
+
*/
|
|
236
|
+
private readonly key: Hex;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Create a new PrivateKey instance from a Uint8Array or String.
|
|
240
|
+
*
|
|
241
|
+
* [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)
|
|
242
|
+
*
|
|
243
|
+
* @param hexInput A HexInput (string or Uint8Array)
|
|
244
|
+
* @param strict If true, private key must AIP-80 compliant.
|
|
245
|
+
* @group Implementation
|
|
246
|
+
* @category Serialization
|
|
247
|
+
*/
|
|
248
|
+
constructor(hexInput: HexInput, strict?: boolean) {
|
|
249
|
+
super();
|
|
250
|
+
|
|
251
|
+
const privateKeyHex = PrivateKey.parseHexInput(hexInput, PrivateKeyVariants.Secp256r1, strict);
|
|
252
|
+
const keyLength = privateKeyHex.toUint8Array().length;
|
|
253
|
+
if (keyLength !== Secp256r1PrivateKey.LENGTH) {
|
|
254
|
+
throw new Error(`PrivateKey length should be ${Secp256r1PrivateKey.LENGTH}, received ${keyLength}`);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
this.key = privateKeyHex;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Get the private key in bytes (Uint8Array).
|
|
262
|
+
*
|
|
263
|
+
* @returns
|
|
264
|
+
* @group Implementation
|
|
265
|
+
* @category Serialization
|
|
266
|
+
*/
|
|
267
|
+
toUint8Array(): Uint8Array {
|
|
268
|
+
return this.key.toUint8Array();
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Get the private key as a string representation.
|
|
273
|
+
*
|
|
274
|
+
* @returns string representation of the private key
|
|
275
|
+
* @group Implementation
|
|
276
|
+
* @category Serialization
|
|
277
|
+
*/
|
|
278
|
+
toString(): string {
|
|
279
|
+
return PrivateKey.formatPrivateKey(this.key.toString(), PrivateKeyVariants.Secp256r1);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Get the private key as a hex string with the 0x prefix.
|
|
284
|
+
*
|
|
285
|
+
* @returns string representation of the private key.
|
|
286
|
+
*/
|
|
287
|
+
toHexString(): string {
|
|
288
|
+
return this.key.toString();
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Sign the given message with the private key.
|
|
293
|
+
* This function generates a cryptographic signature for the provided message.
|
|
294
|
+
*
|
|
295
|
+
* @param message - A message in HexInput format to be signed.
|
|
296
|
+
* @returns Signature - The generated signature for the provided message.
|
|
297
|
+
* @group Implementation
|
|
298
|
+
* @category Serialization
|
|
299
|
+
*/
|
|
300
|
+
sign(message: HexInput): Secp256r1Signature {
|
|
301
|
+
const msgHex = Hex.fromHexInput(message);
|
|
302
|
+
const sha3Message = sha3_256(msgHex.toUint8Array());
|
|
303
|
+
const signature = p256.sign(sha3Message, this.key.toUint8Array());
|
|
304
|
+
return new Secp256r1Signature(signature.toCompactRawBytes());
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Serializes the data into a byte array using the provided serializer.
|
|
309
|
+
* This function is essential for converting data into a format suitable for transmission or storage.
|
|
310
|
+
*
|
|
311
|
+
* @param serializer - The serializer instance used to convert the data.
|
|
312
|
+
* @group Implementation
|
|
313
|
+
* @category Serialization
|
|
314
|
+
*/
|
|
315
|
+
serialize(serializer: Serializer): void {
|
|
316
|
+
serializer.serializeBytes(this.toUint8Array());
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Deserializes a Secp256r1PrivateKey from the provided deserializer.
|
|
321
|
+
* This function allows you to reconstruct a Secp256r1PrivateKey object from its serialized byte representation.
|
|
322
|
+
*
|
|
323
|
+
* @param deserializer - The deserializer instance used to read the serialized data.
|
|
324
|
+
* @group Implementation
|
|
325
|
+
* @category Serialization
|
|
326
|
+
*/
|
|
327
|
+
static deserialize(deserializer: Deserializer): Secp256r1PrivateKey {
|
|
328
|
+
const bytes = deserializer.deserializeBytes();
|
|
329
|
+
return new Secp256r1PrivateKey(bytes);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Generate a new random private key.
|
|
334
|
+
*
|
|
335
|
+
* @returns Secp256r1PrivateKey - A newly generated Secp256r1 private key.
|
|
336
|
+
* @group Implementation
|
|
337
|
+
* @category Serialization
|
|
338
|
+
*/
|
|
339
|
+
static generate(): Secp256r1PrivateKey {
|
|
340
|
+
const hexInput = p256.utils.randomPrivateKey();
|
|
341
|
+
return new Secp256r1PrivateKey(hexInput);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Derive the Secp256r1PublicKey from this private key.
|
|
346
|
+
*
|
|
347
|
+
* @returns Secp256r1PublicKey The derived public key.
|
|
348
|
+
* @group Implementation
|
|
349
|
+
* @category Serialization
|
|
350
|
+
*/
|
|
351
|
+
publicKey(): Secp256r1PublicKey {
|
|
352
|
+
const bytes = p256.getPublicKey(this.key.toUint8Array(), false);
|
|
353
|
+
return new Secp256r1PublicKey(bytes);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export class WebAuthnSignature extends Signature {
|
|
358
|
+
signature: Hex;
|
|
359
|
+
|
|
360
|
+
authenticatorData: Hex;
|
|
361
|
+
|
|
362
|
+
clientDataJSON: Hex;
|
|
363
|
+
|
|
364
|
+
constructor(signature: HexInput, authenticatorData: HexInput, clientDataJSON: HexInput) {
|
|
365
|
+
super();
|
|
366
|
+
this.signature = Hex.fromHexInput(signature);
|
|
367
|
+
this.authenticatorData = Hex.fromHexInput(authenticatorData);
|
|
368
|
+
this.clientDataJSON = Hex.fromHexInput(clientDataJSON);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
toUint8Array() {
|
|
372
|
+
return this.signature.toUint8Array();
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
serialize(serializer: Serializer) {
|
|
376
|
+
serializer.serializeU32AsUleb128(0);
|
|
377
|
+
serializer.serializeBytes(this.signature.toUint8Array());
|
|
378
|
+
serializer.serializeBytes(this.authenticatorData.toUint8Array());
|
|
379
|
+
serializer.serializeBytes(this.clientDataJSON.toUint8Array());
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
bcsToBytes() {
|
|
383
|
+
const serializer = new Serializer();
|
|
384
|
+
this.serialize(serializer);
|
|
385
|
+
return serializer.toUint8Array();
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
bcsToHex() {
|
|
389
|
+
return Hex.fromHexInput(this.bcsToBytes());
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
toStringWithoutPrefix() {
|
|
393
|
+
return Hex.fromHexInput(this.bcsToBytes()).toString();
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
static deserialize(deserializer: Deserializer) {
|
|
397
|
+
const id = deserializer.deserializeUleb128AsU32();
|
|
398
|
+
if (id !== 0) {
|
|
399
|
+
throw new Error(`Invalid id for WebAuthnSignature: ${id}`);
|
|
400
|
+
}
|
|
401
|
+
const signature = deserializer.deserializeBytes();
|
|
402
|
+
const authenticatorData = deserializer.deserializeBytes();
|
|
403
|
+
const clientDataJSON = deserializer.deserializeBytes();
|
|
404
|
+
return new WebAuthnSignature(signature, authenticatorData, clientDataJSON);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Represents a signature of a message signed using a Secp256r1 ECDSA private key.
|
|
410
|
+
*
|
|
411
|
+
* @group Implementation
|
|
412
|
+
* @category Serialization
|
|
413
|
+
*/
|
|
414
|
+
export class Secp256r1Signature extends Signature {
|
|
415
|
+
/**
|
|
416
|
+
* Secp256r1 ecdsa signatures are 256-bit.
|
|
417
|
+
* @group Implementation
|
|
418
|
+
* @category Serialization
|
|
419
|
+
*/
|
|
420
|
+
static readonly LENGTH = 64;
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* The signature bytes
|
|
424
|
+
* @private
|
|
425
|
+
* @group Implementation
|
|
426
|
+
* @category Serialization
|
|
427
|
+
*/
|
|
428
|
+
private readonly data: Hex;
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Create a new Signature instance from a Uint8Array or String.
|
|
432
|
+
*
|
|
433
|
+
* @param hexInput A HexInput (string or Uint8Array)
|
|
434
|
+
* @group Implementation
|
|
435
|
+
* @category Serialization
|
|
436
|
+
*/
|
|
437
|
+
constructor(hexInput: HexInput) {
|
|
438
|
+
super();
|
|
439
|
+
|
|
440
|
+
const hex = Hex.fromHexInput(hexInput);
|
|
441
|
+
const signatureLength = hex.toUint8Array().length;
|
|
442
|
+
if (signatureLength !== Secp256r1Signature.LENGTH) {
|
|
443
|
+
throw new Error(`Signature length should be ${Secp256r1Signature.LENGTH}, received ${signatureLength}`);
|
|
444
|
+
}
|
|
445
|
+
const signature = p256.Signature.fromCompact(hex.toUint8Array()).normalizeS().toCompactRawBytes();
|
|
446
|
+
this.data = Hex.fromHexInput(signature);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Get the signature in bytes (Uint8Array).
|
|
451
|
+
*
|
|
452
|
+
* @returns Uint8Array representation of the signature
|
|
453
|
+
* @group Implementation
|
|
454
|
+
* @category Serialization
|
|
455
|
+
*/
|
|
456
|
+
toUint8Array(): Uint8Array {
|
|
457
|
+
return this.data.toUint8Array();
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Get the signature as a hex string with the 0x prefix.
|
|
462
|
+
*
|
|
463
|
+
* @returns string representation of the signature
|
|
464
|
+
* @group Implementation
|
|
465
|
+
* @category Serialization
|
|
466
|
+
*/
|
|
467
|
+
toString(): string {
|
|
468
|
+
return this.data.toString();
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Serializes the data into a byte array using the provided serializer.
|
|
473
|
+
* This function is essential for converting data into a format suitable for transmission or storage.
|
|
474
|
+
*
|
|
475
|
+
* @param serializer - The serializer instance used to convert the data.
|
|
476
|
+
* @group Implementation
|
|
477
|
+
* @category Serialization
|
|
478
|
+
*/
|
|
479
|
+
serialize(serializer: Serializer): void {
|
|
480
|
+
serializer.serializeBytes(this.data.toUint8Array());
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Deserializes a Secp256r1Signature from the provided deserializer.
|
|
485
|
+
* This function allows you to reconstruct a Secp256r1Signature object from its serialized byte representation.
|
|
486
|
+
*
|
|
487
|
+
* @param deserializer - The deserializer instance used to read the serialized data.
|
|
488
|
+
* @group Implementation
|
|
489
|
+
* @category Serialization
|
|
490
|
+
*/
|
|
491
|
+
static deserialize(deserializer: Deserializer): Secp256r1Signature {
|
|
492
|
+
const hex = deserializer.deserializeBytes();
|
|
493
|
+
return new Secp256r1Signature(hex);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
@@ -13,6 +13,7 @@ import { KeylessPublicKey, KeylessSignature } from "./keyless";
|
|
|
13
13
|
import { Signature } from "./signature";
|
|
14
14
|
import { FederatedKeylessPublicKey } from "./federatedKeyless";
|
|
15
15
|
import { AptosConfig } from "../../api";
|
|
16
|
+
import { Secp256r1PublicKey, WebAuthnSignature } from "./secp256r1";
|
|
16
17
|
|
|
17
18
|
export type PrivateKeyInput = Ed25519PrivateKey | Secp256k1PrivateKey;
|
|
18
19
|
|
|
@@ -59,6 +60,8 @@ export class AnyPublicKey extends AccountPublicKey {
|
|
|
59
60
|
this.variant = AnyPublicKeyVariant.Ed25519;
|
|
60
61
|
} else if (publicKey instanceof Secp256k1PublicKey) {
|
|
61
62
|
this.variant = AnyPublicKeyVariant.Secp256k1;
|
|
63
|
+
} else if (publicKey instanceof Secp256r1PublicKey) {
|
|
64
|
+
this.variant = AnyPublicKeyVariant.Secp256r1;
|
|
62
65
|
} else if (publicKey instanceof KeylessPublicKey) {
|
|
63
66
|
this.variant = AnyPublicKeyVariant.Keyless;
|
|
64
67
|
} else if (publicKey instanceof FederatedKeylessPublicKey) {
|
|
@@ -188,6 +191,9 @@ export class AnyPublicKey extends AccountPublicKey {
|
|
|
188
191
|
case AnyPublicKeyVariant.Secp256k1:
|
|
189
192
|
publicKey = Secp256k1PublicKey.deserialize(deserializer);
|
|
190
193
|
break;
|
|
194
|
+
case AnyPublicKeyVariant.Secp256r1:
|
|
195
|
+
publicKey = Secp256r1PublicKey.deserialize(deserializer);
|
|
196
|
+
break;
|
|
191
197
|
case AnyPublicKeyVariant.Keyless:
|
|
192
198
|
publicKey = KeylessPublicKey.deserialize(deserializer);
|
|
193
199
|
break;
|
|
@@ -278,6 +284,8 @@ export class AnySignature extends Signature {
|
|
|
278
284
|
this.variant = AnySignatureVariant.Ed25519;
|
|
279
285
|
} else if (signature instanceof Secp256k1Signature) {
|
|
280
286
|
this.variant = AnySignatureVariant.Secp256k1;
|
|
287
|
+
} else if (signature instanceof WebAuthnSignature) {
|
|
288
|
+
this.variant = AnySignatureVariant.WebAuthn;
|
|
281
289
|
} else if (signature instanceof KeylessSignature) {
|
|
282
290
|
this.variant = AnySignatureVariant.Keyless;
|
|
283
291
|
} else {
|
|
@@ -318,6 +326,9 @@ export class AnySignature extends Signature {
|
|
|
318
326
|
case AnySignatureVariant.Secp256k1:
|
|
319
327
|
signature = Secp256k1Signature.deserialize(deserializer);
|
|
320
328
|
break;
|
|
329
|
+
case AnySignatureVariant.WebAuthn:
|
|
330
|
+
signature = WebAuthnSignature.deserialize(deserializer);
|
|
331
|
+
break;
|
|
321
332
|
case AnySignatureVariant.Keyless:
|
|
322
333
|
signature = KeylessSignature.deserialize(deserializer);
|
|
323
334
|
break;
|
package/src/internal/account.ts
CHANGED
|
@@ -745,6 +745,39 @@ export async function getAccountCoinsCount(args: {
|
|
|
745
745
|
return data.current_fungible_asset_balances_aggregate.aggregate.count;
|
|
746
746
|
}
|
|
747
747
|
|
|
748
|
+
/**
|
|
749
|
+
* Retrieves an account's balance for the given asset via the fullnode REST API.
|
|
750
|
+
*
|
|
751
|
+
* - `asset` may be a coin type (Move struct ID, e.g. `0x1::aptos_coin::AptosCoin`) or an FA metadata address.
|
|
752
|
+
* - Calls: `GET /accounts/{accountAddress}/balance/{asset}` and returns the numeric balance.
|
|
753
|
+
*
|
|
754
|
+
* @param args - The parameters for the request.
|
|
755
|
+
* @param args.aptosConfig - The Aptos configuration object.
|
|
756
|
+
* @param args.accountAddress - The account address to query.
|
|
757
|
+
* @param args.asset - The asset identifier (coin type or FA metadata address).
|
|
758
|
+
* @returns The balance as a number.
|
|
759
|
+
* @group Implementation
|
|
760
|
+
*/
|
|
761
|
+
export async function getBalance(args: {
|
|
762
|
+
aptosConfig: AptosConfig;
|
|
763
|
+
accountAddress: AccountAddressInput;
|
|
764
|
+
asset: MoveStructId | AccountAddressInput;
|
|
765
|
+
}): Promise<number> {
|
|
766
|
+
const { aptosConfig, accountAddress, asset } = args;
|
|
767
|
+
|
|
768
|
+
const response = await getAptosFullNode<{}, number>({
|
|
769
|
+
aptosConfig,
|
|
770
|
+
originMethod: "getBalance",
|
|
771
|
+
path: `accounts/${accountAddress}/balance/${asset}`,
|
|
772
|
+
params: {
|
|
773
|
+
accountAddress: accountAddress.toString(),
|
|
774
|
+
asset: asset instanceof Uint8Array ? AccountAddress.from(asset).toString() : asset.toString(),
|
|
775
|
+
},
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
return parseInt(response.data.toString(), 10);
|
|
779
|
+
}
|
|
780
|
+
|
|
748
781
|
/**
|
|
749
782
|
* Retrieves the objects owned by a specified account.
|
|
750
783
|
*
|
package/src/types/types.ts
CHANGED
|
@@ -147,6 +147,7 @@ export enum AccountAuthenticatorVariant {
|
|
|
147
147
|
export enum PrivateKeyVariants {
|
|
148
148
|
Ed25519 = "ed25519",
|
|
149
149
|
Secp256k1 = "secp256k1",
|
|
150
|
+
Secp256r1 = "secp256r1",
|
|
150
151
|
}
|
|
151
152
|
|
|
152
153
|
/**
|
|
@@ -155,6 +156,7 @@ export enum PrivateKeyVariants {
|
|
|
155
156
|
export enum AnyPublicKeyVariant {
|
|
156
157
|
Ed25519 = 0,
|
|
157
158
|
Secp256k1 = 1,
|
|
159
|
+
Secp256r1 = 2,
|
|
158
160
|
Keyless = 3,
|
|
159
161
|
FederatedKeyless = 4,
|
|
160
162
|
}
|
|
@@ -165,6 +167,8 @@ export function anyPublicKeyVariantToString(variant: AnyPublicKeyVariant): strin
|
|
|
165
167
|
return "ed25519";
|
|
166
168
|
case AnyPublicKeyVariant.Secp256k1:
|
|
167
169
|
return "secp256k1";
|
|
170
|
+
case AnyPublicKeyVariant.Secp256r1:
|
|
171
|
+
return "secp256r1";
|
|
168
172
|
case AnyPublicKeyVariant.Keyless:
|
|
169
173
|
return "keyless";
|
|
170
174
|
case AnyPublicKeyVariant.FederatedKeyless:
|
|
@@ -180,6 +184,7 @@ export function anyPublicKeyVariantToString(variant: AnyPublicKeyVariant): strin
|
|
|
180
184
|
export enum AnySignatureVariant {
|
|
181
185
|
Ed25519 = 0,
|
|
182
186
|
Secp256k1 = 1,
|
|
187
|
+
WebAuthn = 2,
|
|
183
188
|
Keyless = 3,
|
|
184
189
|
}
|
|
185
190
|
|
package/src/version.ts
CHANGED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var N=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var h=(r,e,t,n)=>{for(var s=n>1?void 0:n?C(e,t):e,i=r.length-1,u;i>=0;i--)(u=r[i])&&(s=(n?u(e,t,s):u(s))||s);return n&&s&&N(e,t,s),s};var c=class extends Error{constructor(e,t){super(e),this.invalidReason=t}};var _utils = require('@noble/hashes/utils');var O=(n=>(n.TOO_SHORT="too_short",n.INVALID_LENGTH="invalid_length",n.INVALID_HEX_CHARS="invalid_hex_chars",n))(O||{}),_= exports.j =class r{constructor(e){this.data=e}toUint8Array(){return this.data}toStringWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromHexString(e){let t=e;if(t.startsWith("0x")&&(t=t.slice(2)),t.length===0)throw new c("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(t.length%2!==0)throw new c("Hex string must be an even number of hex characters.","invalid_length");try{return new r(_utils.hexToBytes.call(void 0, t))}catch(n){throw new c(`Hex string contains invalid hex characters: ${_optionalChain([n, 'optionalAccess', _2 => _2.message])}`,"invalid_hex_chars")}}static fromHexInput(e){return e instanceof Uint8Array?new r(e):r.fromHexString(e)}static hexInputToUint8Array(e){return e instanceof Uint8Array?e:r.fromHexString(e).toUint8Array()}static hexInputToString(e){return r.fromHexInput(e).toString()}static hexInputToStringWithoutPrefix(e){return r.fromHexInput(e).toStringWithoutPrefix()}static isValid(e){try{return r.fromHexString(e),{valid:!0}}catch(t){return{valid:!1,invalidReason:_optionalChain([t, 'optionalAccess', _3 => _3.invalidReason]),invalidReasonMessage:_optionalChain([t, 'optionalAccess', _4 => _4.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((t,n)=>t===e.data[n])}},_e= exports.k =r=>new TextDecoder().decode(_.fromHexInput(r).toUint8Array());var R=255,U= exports.c =65535,x= exports.d =4294967295,S= exports.e =18446744073709551615n,b= exports.f =340282366920938463463374607431768211455n,v= exports.g =115792089237316195423570985008687907853269984665640564039457584007913129639935n;var m=class{bcsToBytes(){let e=new l;return this.serialize(e),e.toUint8Array()}bcsToHex(){let e=this.bcsToBytes();return _.fromHexInput(e)}toStringWithoutPrefix(){return this.bcsToHex().toStringWithoutPrefix()}toString(){return`0x${this.toStringWithoutPrefix()}`}},l= exports.m =class{constructor(e=64){if(e<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(e),this.offset=0}ensureBufferWillHandleSize(e){for(;this.buffer.byteLength<this.offset+e;){let t=new ArrayBuffer(this.buffer.byteLength*2);new Uint8Array(t).set(new Uint8Array(this.buffer)),this.buffer=t}}appendToBuffer(e){this.ensureBufferWillHandleSize(e.length),new Uint8Array(this.buffer,this.offset).set(e),this.offset+=e.length}serializeWithFunction(e,t,n){this.ensureBufferWillHandleSize(t);let s=new DataView(this.buffer,this.offset);e.apply(s,[0,n,!0]),this.offset+=t}serializeStr(e){let t=new TextEncoder;this.serializeBytes(t.encode(e))}serializeBytes(e){this.serializeU32AsUleb128(e.length),this.appendToBuffer(e)}serializeFixedBytes(e){this.appendToBuffer(e)}serializeBool(e){H(e);let t=e?1:0;this.appendToBuffer(new Uint8Array([t]))}serializeU8(e){this.appendToBuffer(new Uint8Array([e]))}serializeU16(e){this.serializeWithFunction(DataView.prototype.setUint16,2,e)}serializeU32(e){this.serializeWithFunction(DataView.prototype.setUint32,4,e)}serializeU64(e){let t=BigInt(e)&BigInt(x),n=BigInt(e)>>BigInt(32);this.serializeU32(Number(t)),this.serializeU32(Number(n))}serializeU128(e){let t=BigInt(e)&S,n=BigInt(e)>>BigInt(64);this.serializeU64(t),this.serializeU64(n)}serializeU256(e){let t=BigInt(e)&b,n=BigInt(e)>>BigInt(128);this.serializeU128(t),this.serializeU128(n)}serializeU32AsUleb128(e){let t=e,n=[];for(;t>>>7;)n.push(t&127|128),t>>>=7;n.push(t),this.appendToBuffer(new Uint8Array(n))}toUint8Array(){return new Uint8Array(this.buffer).slice(0,this.offset)}serialize(e){e.serialize(this)}serializeVector(e){this.serializeU32AsUleb128(e.length),e.forEach(t=>{t.serialize(this)})}serializeOption(e,t){let n=e!==void 0;this.serializeBool(n),n&&(typeof e=="string"?this.serializeStr(e):e instanceof Uint8Array?t!==void 0?this.serializeFixedBytes(e):this.serializeBytes(e):e.serialize(this))}serializeOptionStr(e){e===void 0?this.serializeU32AsUleb128(0):(this.serializeU32AsUleb128(1),this.serializeStr(e))}};h([f(0,R)],l.prototype,"serializeU8",1),h([f(0,U)],l.prototype,"serializeU16",1),h([f(0,x)],l.prototype,"serializeU32",1),h([f(BigInt(0),S)],l.prototype,"serializeU64",1),h([f(BigInt(0),b)],l.prototype,"serializeU128",1),h([f(BigInt(0),v)],l.prototype,"serializeU256",1),h([f(0,x)],l.prototype,"serializeU32AsUleb128",1);function H(r){if(typeof r!="boolean")throw new Error(`${r} is not a boolean value`)}var D=(r,e,t)=>`${r} is out of range: [${e}, ${t}]`;function P(r,e,t){let n=BigInt(r);if(n>BigInt(t)||n<BigInt(e))throw new Error(D(r,e,t))}function f(r,e){return(t,n,s)=>{let i=s.value;return s.value=function(d){return P(d,r,e),i.apply(this,[d])},s}}var F=(s=>(s.JSON="application/json",s.BCS="application/x-bcs",s.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",s.BCS_VIEW_FUNCTION="application/x.aptos.view_function+bcs",s))(F||{}),W= exports.r =(a=>(a[a.Bool=0]="Bool",a[a.U8=1]="U8",a[a.U64=2]="U64",a[a.U128=3]="U128",a[a.Address=4]="Address",a[a.Signer=5]="Signer",a[a.Vector=6]="Vector",a[a.Struct=7]="Struct",a[a.U16=8]="U16",a[a.U32=9]="U32",a[a.U256=10]="U256",a[a.Reference=254]="Reference",a[a.Generic=255]="Generic",a))(W||{}),I= exports.s =(p=>(p[p.U8=0]="U8",p[p.U64=1]="U64",p[p.U128=2]="U128",p[p.Address=3]="Address",p[p.U8Vector=4]="U8Vector",p[p.Bool=5]="Bool",p[p.U16=6]="U16",p[p.U32=7]="U32",p[p.U256=8]="U256",p[p.Serialized=9]="Serialized",p))(I||{}),z= exports.t =(s=>(s[s.Script=0]="Script",s[s.EntryFunction=2]="EntryFunction",s[s.Multisig=3]="Multisig",s[s.Payload=4]="Payload",s))(z||{}),G= exports.u =(e=>(e[e.V1=0]="V1",e))(G||{}),L= exports.v =(n=>(n[n.Script=0]="Script",n[n.EntryFunction=1]="EntryFunction",n[n.Empty=2]="Empty",n))(L||{}),$= exports.w =(e=>(e[e.V1=0]="V1",e))($||{}),q= exports.x =(t=>(t[t.MultiAgentTransaction=0]="MultiAgentTransaction",t[t.FeePayerTransaction=1]="FeePayerTransaction",t))(q||{}),X= exports.y =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.MultiAgent=2]="MultiAgent",i[i.FeePayer=3]="FeePayer",i[i.SingleSender=4]="SingleSender",i))(X||{}),K= exports.z =(u=>(u[u.Ed25519=0]="Ed25519",u[u.MultiEd25519=1]="MultiEd25519",u[u.SingleKey=2]="SingleKey",u[u.MultiKey=3]="MultiKey",u[u.NoAccountAuthenticator=4]="NoAccountAuthenticator",u[u.Abstraction=5]="Abstraction",u))(K||{}),Y= exports.A =(t=>(t.Ed25519="ed25519",t.Secp256k1="secp256k1",t))(Y||{}),j= exports.B =(s=>(s[s.Ed25519=0]="Ed25519",s[s.Secp256k1=1]="Secp256k1",s[s.Keyless=3]="Keyless",s[s.FederatedKeyless=4]="FederatedKeyless",s))(j||{});function Re(r){switch(r){case 0:return"ed25519";case 1:return"secp256k1";case 3:return"keyless";case 4:return"federated_keyless";default:throw new Error("Unknown public key variant")}}var Z=(n=>(n[n.Ed25519=0]="Ed25519",n[n.Secp256k1=1]="Secp256k1",n[n.Keyless=3]="Keyless",n))(Z||{}),Q= exports.E =(e=>(e[e.Ed25519=0]="Ed25519",e))(Q||{}),J= exports.F =(e=>(e[e.Ed25519=0]="Ed25519",e))(J||{}),V= exports.G =(e=>(e[e.ZkProof=0]="ZkProof",e))(V||{}),ee= exports.H =(e=>(e[e.Groth16=0]="Groth16",e))(ee||{}),te= exports.I =(d=>(d.Pending="pending_transaction",d.User="user_transaction",d.Genesis="genesis_transaction",d.BlockMetadata="block_metadata_transaction",d.StateCheckpoint="state_checkpoint_transaction",d.Validator="validator_transaction",d.BlockEpilogue="block_epilogue_transaction",d))(te||{});function Ue(r){return r.type==="pending_transaction"}function ve(r){return r.type==="user_transaction"}function Ie(r){return r.type==="genesis_transaction"}function Me(r){return r.type==="block_metadata_transaction"}function Ee(r){return r.type==="state_checkpoint_transaction"}function Be(r){return r.type==="validator_transaction"}function Ne(r){return r.type==="block_epilogue_transaction"}function Ce(r){return"signature"in r&&r.type==="ed25519_signature"}function ke(r){return"signature"in r&&r.signature==="secp256k1_ecdsa_signature"}function we(r){return r.type==="multi_agent_signature"}function Oe(r){return r.type==="fee_payer_signature"}function He(r){return r.type==="multi_ed25519_signature"}function De(r){return r.type==="single_sender"}var re=(n=>(n.PRIVATE="private",n.PUBLIC="public",n.FRIEND="friend",n))(re||{}),ne= exports.X =(s=>(s.STORE="store",s.DROP="drop",s.KEY="key",s.COPY="copy",s))(ne||{}),se= exports.Y =(t=>(t.VALIDATOR="validator",t.FULL_NODE="full_node",t))(se||{}),ie= exports.Z =(s=>(s[s.Ed25519=0]="Ed25519",s[s.MultiEd25519=1]="MultiEd25519",s[s.SingleKey=2]="SingleKey",s[s.MultiKey=3]="MultiKey",s))(ie||{}),oe= exports._ =(t=>(t[t.Ed25519=0]="Ed25519",t[t.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",t))(oe||{}),M= exports.$ =(i=>(i[i.DeriveAuid=251]="DeriveAuid",i[i.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",i[i.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",i[i.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",i[i.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",i))(M||{});var pe=(y=>(y.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",y.INVALID_HEX_CHARS="invalid_hex_chars",y.TOO_SHORT="too_short",y.TOO_LONG="too_long",y.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",y.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",y.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",y.INVALID_PADDING_STRICTNESS="INVALID_PADDING_STRICTNESS",y))(pe||{}),o=class o extends m{constructor(e){if(super(),e.length!==o.LENGTH)throw new c("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=e}isSpecial(){return this.data.slice(0,this.data.length-1).every(e=>e===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let e=_utils.bytesToHex.call(void 0, this.data);return this.isSpecial()&&(e=e[e.length-1]),e}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toStringShort(){return`0x${this.toStringShortWithoutPrefix()}`}toStringShortWithoutPrefix(){let e=_utils.bytesToHex.call(void 0, this.data).replace(/^0+/,"");return e===""?"0":e}toUint8Array(){return this.data}serialize(e){e.serializeFixedBytes(this.data)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(3),e.serialize(this)}static deserialize(e){let t=e.deserializeFixedBytes(o.LENGTH);return new o(t)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new c("Hex string must start with a leading 0x.","leading_zero_x_required");let t=o.fromString(e);if(e.length!==o.LONG_STRING_LENGTH+2)if(t.isSpecial()){if(e.length!==3)throw new c(`The given hex string ${e} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,"INVALID_PADDING_ZEROES")}else throw new c(`The given hex string ${e} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return t}static fromString(e,{maxMissingChars:t=4}={}){let n=e;if(e.startsWith("0x")&&(n=e.slice(2)),n.length===0)throw new c("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(n.length>64)throw new c("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");if(t>63||t<0)throw new c(`maxMissingChars must be between or equal to 0 and 63. Received ${t}`,"INVALID_PADDING_STRICTNESS");let s;try{s=_utils.hexToBytes.call(void 0, n.padStart(64,"0"))}catch(u){throw new c(`Hex characters are invalid: ${_optionalChain([u, 'optionalAccess', _5 => _5.message])}`,"invalid_hex_chars")}let i=new o(s);if(n.length<64-t&&!i.isSpecial())throw new c(`Hex string is too short, must be ${64-t} to 64 chars long, excluding the leading 0x. You may need to fix
|
|
2
|
-
the addresss by padding it with 0s before passing it to \`fromString\` (e.g. <addressString>.padStart(64, '0')).
|
|
3
|
-
Received ${e}`,"too_short");return i}static from(e,{maxMissingChars:t=4}={}){return typeof e=="string"?o.fromString(e,{maxMissingChars:t}):e instanceof Uint8Array?new o(e):e}static fromStrict(e){return typeof e=="string"?o.fromStringStrict(e):e instanceof Uint8Array?new o(e):e}static isValid(e){try{return e.strict?o.fromStrict(e.input):o.from(e.input),{valid:!0}}catch(t){return{valid:!1,invalidReason:_optionalChain([t, 'optionalAccess', _6 => _6.invalidReason]),invalidReasonMessage:_optionalChain([t, 'optionalAccess', _7 => _7.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((t,n)=>t===e.data[n])}};o.LENGTH=32,o.LONG_STRING_LENGTH=64,o.ZERO=o.from("0x0"),o.ONE=o.from("0x1"),o.TWO=o.from("0x2"),o.THREE=o.from("0x3"),o.FOUR=o.from("0x4"),o.A=o.from("0xA");var g=o;var _sha3 = require('@noble/hashes/sha3');var T=(r,e)=>{let t=r.bcsToBytes(),n=typeof e=="string"?Buffer.from(e,"utf8"):e,s=new Uint8Array([...t,...n,254]);return new g(_sha3.sha3_256.call(void 0, s))},Ve= exports.da =(r,e)=>{let t=r.bcsToBytes(),n=typeof e=="string"?Buffer.from(e,"utf8"):e,s=new Uint8Array([...t,...n,255]);return new g(_sha3.sha3_256.call(void 0, s))},et= exports.ea =(r,e,t)=>{let n=`${e}::${t}`;return T(r,n)};var _jsbase64 = require('js-base64');async function it(r){return new Promise(e=>{setTimeout(e,r)})}function ot(r){return r instanceof Error?r.message:String(r)}var at=()=>Math.floor(Date.now()/1e3);function pt(r){let e=new Date(r*1e3);return e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),Math.floor(e.getTime()/1e3)}function ut(r){let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e+"==".substring(0,(3-e.length%3)%3);return _jsbase64.decode.call(void 0, t)}function ct(r){let e=r.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4!==0;)e+="=";return new Uint8Array(Buffer.from(e,"base64"))}var gt=(r,e)=>r*10**e,dt= exports.ma =(r,e)=>r/10**e,B=r=>{let e="";for(let t=2;t<r.length;t+=2)e+=String.fromCharCode(parseInt(r.substring(t,t+2),16));return e},lt= exports.na =r=>{let{account_address:e,module_name:t,struct_name:n}=r,s=B(t),i=B(n);return`${e}::${s}::${i}`},yt= exports.oa =r=>typeof r=="object"&&!Array.isArray(r)&&r!==null&&"account_address"in r&&"module_name"in r&&"struct_name"in r&&typeof r.account_address=="string"&&typeof r.module_name=="string"&&typeof r.struct_name=="string";function ht(r){let e=r.split("::");if(e.length!==3)throw new Error(`Invalid function ${r}`);let t=e[0],n=e[1],s=e[2];return{moduleAddress:t,moduleName:n,functionName:s}}function ft(r){let e=r.split("::");return e.length===3&&g.isValid({input:e[0]}).valid}function _t(r,e=6,t=5){return`${r.slice(0,e)}...${r.slice(-t)}`}var ce="0x1::aptos_coin::AptosCoin",xt=g.A.toStringLong();function ge(r){let e=/0x[0-9a-fA-F]+/g;return r.replace(e,t=>g.from(t,{maxMissingChars:63}).toStringShort())}function mt(r){let e=ge(r);return e===ce?g.A:T(g.A,e)}exports.a = h; exports.b = R; exports.c = U; exports.d = x; exports.e = S; exports.f = b; exports.g = v; exports.h = c; exports.i = O; exports.j = _; exports.k = _e; exports.l = m; exports.m = l; exports.n = H; exports.o = D; exports.p = P; exports.q = F; exports.r = W; exports.s = I; exports.t = z; exports.u = G; exports.v = L; exports.w = $; exports.x = q; exports.y = X; exports.z = K; exports.A = Y; exports.B = j; exports.C = Re; exports.D = Z; exports.E = Q; exports.F = J; exports.G = V; exports.H = ee; exports.I = te; exports.J = Ue; exports.K = ve; exports.L = Ie; exports.M = Me; exports.N = Ee; exports.O = Be; exports.P = Ne; exports.Q = Ce; exports.R = ke; exports.S = we; exports.T = Oe; exports.U = He; exports.V = De; exports.W = re; exports.X = ne; exports.Y = se; exports.Z = ie; exports._ = oe; exports.$ = M; exports.aa = pe; exports.ba = g; exports.ca = T; exports.da = Ve; exports.ea = et; exports.fa = it; exports.ga = ot; exports.ha = at; exports.ia = pt; exports.ja = ut; exports.ka = ct; exports.la = gt; exports.ma = dt; exports.na = lt; exports.oa = yt; exports.pa = ht; exports.qa = ft; exports.ra = _t; exports.sa = mt;
|
|
4
|
-
//# sourceMappingURL=chunk-6MMUUJHX.js.map
|