@aptos-labs/ts-sdk 6.1.0 → 6.2.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/README.md +9 -13
- package/dist/common/{account-CSOaJ0SC.d.ts → account-DGpxrkAn.d.ts} +6 -2
- package/dist/common/chunk-2VR6ONNW.js +4 -0
- package/dist/common/{chunk-3NBJLJ2Y.js.map → chunk-2VR6ONNW.js.map} +1 -1
- package/dist/common/cli/index.d.ts +2 -2
- package/dist/common/cli/index.js +1 -1
- package/dist/common/cli/index.js.map +1 -1
- package/dist/common/index.d.ts +2 -2
- package/dist/common/index.js +31 -31
- package/dist/common/index.js.map +1 -1
- package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
- package/dist/esm/account/AbstractedAccount.mjs +1 -1
- package/dist/esm/account/Account.mjs +1 -1
- package/dist/esm/account/AccountUtils.mjs +1 -1
- package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
- package/dist/esm/account/Ed25519Account.mjs +1 -1
- package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
- package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/MultiEd25519Account.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/index.mjs +1 -1
- package/dist/esm/account/utils.mjs +1 -1
- package/dist/esm/api/account/abstraction.mjs +1 -1
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.mjs +1 -1
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/object.mjs +1 -1
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/table.mjs +1 -1
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/helpers.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
- package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
- package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
- package/dist/esm/api/utils.mjs +1 -1
- package/dist/esm/bcs/index.mjs +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/bcs/serializer.mjs +1 -1
- package/dist/esm/{chunk-UZMJ4DAO.mjs → chunk-2VBY2V4Z.mjs} +2 -2
- package/dist/esm/{chunk-DECWO3X5.mjs → chunk-2VHA77EO.mjs} +2 -2
- package/dist/esm/{chunk-VW3Y5EOJ.mjs → chunk-44MMFX5F.mjs} +1 -1
- package/dist/esm/chunk-44MMFX5F.mjs.map +1 -0
- package/dist/esm/chunk-5HHC2YG4.mjs +2 -0
- package/dist/esm/chunk-5LMLIRGK.mjs +2 -0
- package/dist/esm/chunk-5LMLIRGK.mjs.map +1 -0
- package/dist/esm/chunk-66F7RP7K.mjs +2 -0
- package/dist/esm/chunk-66F7RP7K.mjs.map +1 -0
- package/dist/esm/chunk-6CD6PDFJ.mjs +4 -0
- package/dist/esm/chunk-6CD6PDFJ.mjs.map +1 -0
- package/dist/esm/{chunk-YNNDFGVQ.mjs → chunk-A7SQEK23.mjs} +2 -2
- package/dist/esm/chunk-A7SQEK23.mjs.map +1 -0
- package/dist/esm/{chunk-KLDERTLN.mjs → chunk-ASFFADWS.mjs} +2 -2
- package/dist/esm/chunk-AUGTNOKZ.mjs +2 -0
- package/dist/esm/{chunk-QRD5NGNC.mjs.map → chunk-AUGTNOKZ.mjs.map} +1 -1
- package/dist/esm/{chunk-32J7VMLV.mjs → chunk-BT742BFQ.mjs} +2 -2
- package/dist/esm/chunk-BT742BFQ.mjs.map +1 -0
- package/dist/esm/chunk-C2KVLMPH.mjs +2 -0
- package/dist/esm/chunk-C2KVLMPH.mjs.map +1 -0
- package/dist/esm/{chunk-VWXVSRRQ.mjs → chunk-CD3EZCI5.mjs} +2 -2
- package/dist/esm/{chunk-QV37KEZY.mjs → chunk-E3DHFXN4.mjs} +2 -2
- package/dist/esm/{chunk-DE4YVX3L.mjs → chunk-EIWPAECI.mjs} +2 -2
- package/dist/esm/{chunk-US6KOOYS.mjs → chunk-F4LHBGG2.mjs} +2 -2
- package/dist/esm/chunk-F4LHBGG2.mjs.map +1 -0
- package/dist/esm/{chunk-VWLK43JM.mjs → chunk-FDHHQUS3.mjs} +2 -2
- package/dist/esm/{chunk-TIMTVXFU.mjs → chunk-H2T2SU5O.mjs} +2 -2
- package/dist/esm/chunk-H2T2SU5O.mjs.map +1 -0
- package/dist/esm/{chunk-3Q3J4DTI.mjs → chunk-KOVWYU53.mjs} +2 -2
- package/dist/esm/{chunk-QYC3HOQX.mjs → chunk-LDK76MDN.mjs} +2 -2
- package/dist/esm/{chunk-WRV7BWXE.mjs → chunk-NWP2VEMB.mjs} +2 -2
- package/dist/esm/{chunk-UNA3V4UB.mjs → chunk-POQ4FT4E.mjs} +2 -2
- package/dist/esm/{chunk-DRGODFFX.mjs → chunk-Q4KYBAYN.mjs} +2 -2
- package/dist/esm/{chunk-YOT47DDX.mjs → chunk-QRW7MQDA.mjs} +2 -2
- package/dist/esm/chunk-QRW7MQDA.mjs.map +1 -0
- package/dist/esm/{chunk-RSUFVB4P.mjs → chunk-R7PCBRRT.mjs} +2 -2
- package/dist/esm/{chunk-3FDSKP56.mjs → chunk-T32P4APJ.mjs} +2 -2
- package/dist/esm/{chunk-BHVMFSAD.mjs → chunk-TAHLOBRG.mjs} +2 -2
- package/dist/esm/chunk-TAHLOBRG.mjs.map +1 -0
- package/dist/esm/{chunk-POKQD2RK.mjs → chunk-TSPG5VED.mjs} +2 -2
- package/dist/esm/{chunk-YMZF4KMT.mjs → chunk-UPHD2B4I.mjs} +2 -2
- package/dist/esm/{chunk-U5HTF4OK.mjs → chunk-UVJW4DPP.mjs} +1 -1
- package/dist/esm/{chunk-U5HTF4OK.mjs.map → chunk-UVJW4DPP.mjs.map} +1 -1
- package/dist/esm/{chunk-GP3CDQFI.mjs → chunk-UYG4XVVO.mjs} +2 -2
- package/dist/esm/chunk-UYG4XVVO.mjs.map +1 -0
- package/dist/esm/{chunk-UXDYADZV.mjs → chunk-WFZFTRRS.mjs} +2 -2
- package/dist/esm/{chunk-RGXAFBFA.mjs → chunk-X4IR6WX6.mjs} +2 -2
- package/dist/esm/{chunk-SZBXWUBS.mjs → chunk-YJVBGKWM.mjs} +2 -2
- package/dist/esm/{chunk-PDNDARQY.mjs → chunk-YTFJ5W7U.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.d.mts +1 -1
- package/dist/esm/cli/localNode.mjs +1 -1
- package/dist/esm/cli/move.mjs +1 -1
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/core/account/index.mjs +1 -1
- package/dist/esm/core/account/utils/address.mjs +1 -1
- package/dist/esm/core/account/utils/index.mjs +1 -1
- package/dist/esm/core/accountAddress.mjs +1 -1
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/crypto/abstraction.mjs +1 -1
- package/dist/esm/core/crypto/deserializationUtils.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.mjs +1 -1
- package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/keyless.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/privateKey.mjs +1 -1
- package/dist/esm/core/crypto/proof.mjs +1 -1
- package/dist/esm/core/crypto/publicKey.mjs +1 -1
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/crypto/secp256r1.mjs +1 -1
- package/dist/esm/core/crypto/signature.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/crypto/utils.mjs +1 -1
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/errors/index.mjs +1 -1
- package/dist/esm/index.d.mts +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/abstraction.mjs +1 -1
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.mjs +1 -1
- package/dist/esm/internal/object.mjs +1 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/table.mjs +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/utils/index.mjs +1 -1
- package/dist/esm/internal/utils/utils.mjs +1 -1
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/chainId.mjs +1 -1
- package/dist/esm/transactions/instances/identifier.mjs +1 -1
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/utils/const.d.mts +6 -2
- package/dist/esm/utils/const.mjs +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.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +15 -22
- package/src/account/EphemeralKeyPair.ts +0 -1
- package/src/api/aptos.ts +1 -2
- package/src/api/aptosConfig.ts +1 -3
- package/src/api/transactionSubmission/helpers.ts +0 -1
- package/src/bcs/serializable/movePrimitives.ts +0 -1
- package/src/bcs/serializer.ts +1 -5
- package/src/cli/localNode.ts +2 -4
- package/src/cli/move.ts +2 -2
- package/src/core/account/utils/address.ts +3 -3
- package/src/core/crypto/abstraction.ts +0 -3
- package/src/core/crypto/keyless.ts +0 -1
- package/src/core/crypto/privateKey.ts +0 -1
- package/src/core/crypto/singleKey.ts +0 -1
- package/src/internal/account.ts +1 -1
- package/src/internal/keyless.ts +1 -1
- package/src/internal/queries/getAccountAddressesForAuthKey.graphql +4 -1
- package/src/internal/queries/getAuthKeysForPublicKey.graphql +4 -1
- package/src/internal/queries/getTableItemsData.graphql +1 -1
- package/src/internal/queries/getTableItemsMetadata.graphql +2 -2
- package/src/internal/transaction.ts +2 -2
- package/src/transactions/authenticator/account.ts +0 -1
- package/src/transactions/instances/transactionPayload.ts +0 -3
- package/src/transactions/management/accountSequenceNumber.ts +0 -2
- package/src/transactions/transactionBuilder/remoteAbi.ts +1 -2
- package/src/transactions/transactionBuilder/transactionBuilder.ts +1 -3
- package/src/transactions/typeTag/index.ts +0 -3
- package/src/transactions/typeTag/parser.ts +2 -3
- package/src/utils/const.ts +6 -1
- package/src/utils/helpers.ts +3 -4
- package/src/version.ts +1 -1
- package/dist/common/chunk-3NBJLJ2Y.js +0 -4
- package/dist/esm/chunk-32J7VMLV.mjs.map +0 -1
- package/dist/esm/chunk-7FG7RJDS.mjs +0 -2
- package/dist/esm/chunk-7FG7RJDS.mjs.map +0 -1
- package/dist/esm/chunk-BHVMFSAD.mjs.map +0 -1
- package/dist/esm/chunk-CWI5B5KE.mjs +0 -2
- package/dist/esm/chunk-GP3CDQFI.mjs.map +0 -1
- package/dist/esm/chunk-GWM3VCT4.mjs +0 -4
- package/dist/esm/chunk-GWM3VCT4.mjs.map +0 -1
- package/dist/esm/chunk-HHAUJ5E4.mjs +0 -2
- package/dist/esm/chunk-HHAUJ5E4.mjs.map +0 -1
- package/dist/esm/chunk-QRD5NGNC.mjs +0 -2
- package/dist/esm/chunk-TIMTVXFU.mjs.map +0 -1
- package/dist/esm/chunk-US6KOOYS.mjs.map +0 -1
- package/dist/esm/chunk-V5K2RRFT.mjs +0 -2
- package/dist/esm/chunk-V5K2RRFT.mjs.map +0 -1
- package/dist/esm/chunk-VW3Y5EOJ.mjs.map +0 -1
- package/dist/esm/chunk-YNNDFGVQ.mjs.map +0 -1
- package/dist/esm/chunk-YOT47DDX.mjs.map +0 -1
- /package/dist/esm/{chunk-UZMJ4DAO.mjs.map → chunk-2VBY2V4Z.mjs.map} +0 -0
- /package/dist/esm/{chunk-DECWO3X5.mjs.map → chunk-2VHA77EO.mjs.map} +0 -0
- /package/dist/esm/{chunk-CWI5B5KE.mjs.map → chunk-5HHC2YG4.mjs.map} +0 -0
- /package/dist/esm/{chunk-KLDERTLN.mjs.map → chunk-ASFFADWS.mjs.map} +0 -0
- /package/dist/esm/{chunk-VWXVSRRQ.mjs.map → chunk-CD3EZCI5.mjs.map} +0 -0
- /package/dist/esm/{chunk-QV37KEZY.mjs.map → chunk-E3DHFXN4.mjs.map} +0 -0
- /package/dist/esm/{chunk-DE4YVX3L.mjs.map → chunk-EIWPAECI.mjs.map} +0 -0
- /package/dist/esm/{chunk-VWLK43JM.mjs.map → chunk-FDHHQUS3.mjs.map} +0 -0
- /package/dist/esm/{chunk-3Q3J4DTI.mjs.map → chunk-KOVWYU53.mjs.map} +0 -0
- /package/dist/esm/{chunk-QYC3HOQX.mjs.map → chunk-LDK76MDN.mjs.map} +0 -0
- /package/dist/esm/{chunk-WRV7BWXE.mjs.map → chunk-NWP2VEMB.mjs.map} +0 -0
- /package/dist/esm/{chunk-UNA3V4UB.mjs.map → chunk-POQ4FT4E.mjs.map} +0 -0
- /package/dist/esm/{chunk-DRGODFFX.mjs.map → chunk-Q4KYBAYN.mjs.map} +0 -0
- /package/dist/esm/{chunk-RSUFVB4P.mjs.map → chunk-R7PCBRRT.mjs.map} +0 -0
- /package/dist/esm/{chunk-3FDSKP56.mjs.map → chunk-T32P4APJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-POKQD2RK.mjs.map → chunk-TSPG5VED.mjs.map} +0 -0
- /package/dist/esm/{chunk-YMZF4KMT.mjs.map → chunk-UPHD2B4I.mjs.map} +0 -0
- /package/dist/esm/{chunk-UXDYADZV.mjs.map → chunk-WFZFTRRS.mjs.map} +0 -0
- /package/dist/esm/{chunk-RGXAFBFA.mjs.map → chunk-X4IR6WX6.mjs.map} +0 -0
- /package/dist/esm/{chunk-SZBXWUBS.mjs.map → chunk-YJVBGKWM.mjs.map} +0 -0
- /package/dist/esm/{chunk-PDNDARQY.mjs.map → chunk-YTFJ5W7U.mjs.map} +0 -0
package/src/cli/localNode.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { ChildProcessWithoutNullStreams, spawn } from "child_process";
|
|
1
|
+
import { ChildProcessWithoutNullStreams, spawn } from "node:child_process";
|
|
4
2
|
import kill from "tree-kill";
|
|
5
|
-
import { platform } from "os";
|
|
3
|
+
import { platform } from "node:os";
|
|
6
4
|
|
|
7
5
|
import { sleep } from "../utils/helpers";
|
|
8
6
|
|
package/src/cli/move.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { sha3_256 } from "@noble/hashes/sha3";
|
|
2
2
|
import { AccountAddress } from "../../accountAddress";
|
|
3
3
|
import { DeriveScheme } from "../../../types";
|
|
4
|
+
import { TEXT_ENCODER } from "../../../utils/const";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Creates an object address from creator address and seed
|
|
@@ -14,8 +15,7 @@ import { DeriveScheme } from "../../../types";
|
|
|
14
15
|
*/
|
|
15
16
|
export const createObjectAddress = (creatorAddress: AccountAddress, seed: Uint8Array | string): AccountAddress => {
|
|
16
17
|
const creatorBytes = creatorAddress.bcsToBytes();
|
|
17
|
-
|
|
18
|
-
const seedBytes = typeof seed === "string" ? Buffer.from(seed, "utf8") : seed;
|
|
18
|
+
const seedBytes = typeof seed === "string" ? TEXT_ENCODER.encode(seed) : seed;
|
|
19
19
|
|
|
20
20
|
const bytes = new Uint8Array([...creatorBytes, ...seedBytes, DeriveScheme.DeriveObjectAddressFromSeed]);
|
|
21
21
|
|
|
@@ -35,7 +35,7 @@ export const createObjectAddress = (creatorAddress: AccountAddress, seed: Uint8A
|
|
|
35
35
|
export const createResourceAddress = (creatorAddress: AccountAddress, seed: Uint8Array | string): AccountAddress => {
|
|
36
36
|
const creatorBytes = creatorAddress.bcsToBytes();
|
|
37
37
|
|
|
38
|
-
const seedBytes = typeof seed === "string" ?
|
|
38
|
+
const seedBytes = typeof seed === "string" ? TEXT_ENCODER.encode(seed) : seed;
|
|
39
39
|
|
|
40
40
|
const bytes = new Uint8Array([...creatorBytes, ...seedBytes, DeriveScheme.DeriveResourceAccountAddress]);
|
|
41
41
|
|
|
@@ -35,17 +35,14 @@ export class AbstractPublicKey extends AccountPublicKey {
|
|
|
35
35
|
return new AuthenticationKey({ data: this.accountAddress.toUint8Array() });
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
39
38
|
verifySignature(args: VerifySignatureArgs): boolean {
|
|
40
39
|
throw new Error("This function is not implemented for AbstractPublicKey.");
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
44
42
|
async verifySignatureAsync(args: VerifySignatureAsyncArgs): Promise<boolean> {
|
|
45
43
|
throw new Error("This function is not implemented for AbstractPublicKey.");
|
|
46
44
|
}
|
|
47
45
|
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
49
46
|
serialize(serializer: Serializer): void {
|
|
50
47
|
throw new Error("This function is not implemented for AbstractPublicKey.");
|
|
51
48
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Copyright © Aptos Foundation
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
// eslint-disable-next-line max-classes-per-file
|
|
5
4
|
import { JwtPayload, jwtDecode } from "jwt-decode";
|
|
6
5
|
import { sha3_256 } from "@noble/hashes/sha3";
|
|
7
6
|
import { AccountPublicKey, PublicKey } from "./publicKey";
|
|
@@ -61,7 +61,6 @@ export class PrivateKey {
|
|
|
61
61
|
// Remove the prefix if it exists
|
|
62
62
|
let formattedPrivateKey = privateKey;
|
|
63
63
|
if (typeof formattedPrivateKey === "string" && formattedPrivateKey.startsWith(aip80Prefix)) {
|
|
64
|
-
// eslint-disable-next-line prefer-destructuring
|
|
65
64
|
formattedPrivateKey = formattedPrivateKey.split("-")[2];
|
|
66
65
|
}
|
|
67
66
|
|
|
@@ -301,7 +301,6 @@ export class AnySignature extends Signature {
|
|
|
301
301
|
|
|
302
302
|
toUint8Array(): Uint8Array {
|
|
303
303
|
// TODO: keep this warning around for a bit, and eventually change this to return `this.signature.toUint8Array()`.
|
|
304
|
-
// eslint-disable-next-line no-console
|
|
305
304
|
console.warn(
|
|
306
305
|
"[Aptos SDK] Calls to AnySignature.toUint8Array() will soon return the underlying signature bytes. " +
|
|
307
306
|
"Use AnySignature.bcsToBytes() instead.",
|
package/src/internal/account.ts
CHANGED
|
@@ -733,7 +733,7 @@ export async function getAccountCoinsCount(args: {
|
|
|
733
733
|
});
|
|
734
734
|
|
|
735
735
|
if (!data.current_fungible_asset_balances_aggregate.aggregate) {
|
|
736
|
-
throw Error("Failed to get the count of account coins");
|
|
736
|
+
throw new Error("Failed to get the count of account coins");
|
|
737
737
|
}
|
|
738
738
|
|
|
739
739
|
return data.current_fungible_asset_balances_aggregate.aggregate.count;
|
package/src/internal/keyless.ts
CHANGED
|
@@ -110,7 +110,7 @@ export async function getProof(args: {
|
|
|
110
110
|
throw new Error("iat was not found");
|
|
111
111
|
}
|
|
112
112
|
if (maxExpHorizonSecs < ephemeralKeyPair.expiryDateSecs - decodedJwt.iat) {
|
|
113
|
-
throw Error(`The EphemeralKeyPair is too long lived.
|
|
113
|
+
throw new Error(`The EphemeralKeyPair is too long lived. Its lifespan must be less than ${maxExpHorizonSecs}`);
|
|
114
114
|
}
|
|
115
115
|
const json = {
|
|
116
116
|
jwt_b64: jwt,
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
query getAccountAddressesForAuthKey(
|
|
1
|
+
query getAccountAddressesForAuthKey(
|
|
2
|
+
$where_condition: auth_key_account_addresses_bool_exp
|
|
3
|
+
$order_by: [auth_key_account_addresses_order_by!]
|
|
4
|
+
) {
|
|
2
5
|
auth_key_account_addresses(where: $where_condition, order_by: $order_by) {
|
|
3
6
|
auth_key
|
|
4
7
|
account_address
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
query getAuthKeysForPublicKey(
|
|
1
|
+
query getAuthKeysForPublicKey(
|
|
2
|
+
$where_condition: public_key_auth_keys_bool_exp
|
|
3
|
+
$order_by: [public_key_auth_keys_order_by!]
|
|
4
|
+
) {
|
|
2
5
|
public_key_auth_keys(where: $where_condition, order_by: $order_by) {
|
|
3
6
|
public_key
|
|
4
7
|
public_key_type
|
|
@@ -4,7 +4,7 @@ query getTableItemsData(
|
|
|
4
4
|
$limit: Int
|
|
5
5
|
$order_by: [table_items_order_by!]
|
|
6
6
|
) {
|
|
7
|
-
table_items(where: $where_condition, offset: $offset, limit: $limit, order_by: $order_by){
|
|
7
|
+
table_items(where: $where_condition, offset: $offset, limit: $limit, order_by: $order_by) {
|
|
8
8
|
decoded_key
|
|
9
9
|
decoded_value
|
|
10
10
|
key
|
|
@@ -4,8 +4,8 @@ query getTableItemsMetadata(
|
|
|
4
4
|
$limit: Int
|
|
5
5
|
$order_by: [table_metadatas_order_by!]
|
|
6
6
|
) {
|
|
7
|
-
table_metadatas(where: $where_condition, offset: $offset, limit: $limit, order_by: $order_by){
|
|
8
|
-
|
|
7
|
+
table_metadatas(where: $where_condition, offset: $offset, limit: $limit, order_by: $order_by) {
|
|
8
|
+
handle
|
|
9
9
|
key_type
|
|
10
10
|
value_type
|
|
11
11
|
}
|
|
@@ -310,12 +310,12 @@ export async function waitForIndexer(args: {
|
|
|
310
310
|
const { aptosConfig, processorType } = args;
|
|
311
311
|
const minimumLedgerVersion = BigInt(args.minimumLedgerVersion);
|
|
312
312
|
const timeoutMilliseconds = 3000; // 3 seconds
|
|
313
|
-
const startTime =
|
|
313
|
+
const startTime = Date.now();
|
|
314
314
|
let indexerVersion = BigInt(-1);
|
|
315
315
|
|
|
316
316
|
while (indexerVersion < minimumLedgerVersion) {
|
|
317
317
|
// check for timeout
|
|
318
|
-
if (
|
|
318
|
+
if (Date.now() - startTime > timeoutMilliseconds) {
|
|
319
319
|
throw new Error("waitForLastSuccessIndexerVersionSync timeout");
|
|
320
320
|
}
|
|
321
321
|
|
|
@@ -260,7 +260,6 @@ export class AccountAuthenticatorNoAccountAuthenticator extends AccountAuthentic
|
|
|
260
260
|
serializer.serializeU32AsUleb128(AccountAuthenticatorVariant.NoAccountAuthenticator);
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
264
263
|
static load(deserializer: Deserializer): AccountAuthenticatorNoAccountAuthenticator {
|
|
265
264
|
return new AccountAuthenticatorNoAccountAuthenticator();
|
|
266
265
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// Copyright © Aptos Foundation
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
/* eslint-disable max-classes-per-file */
|
|
5
|
-
|
|
6
4
|
import { Deserializer } from "../../bcs/deserializer";
|
|
7
5
|
import { Serializable, Serializer } from "../../bcs/serializer";
|
|
8
6
|
import { EntryFunctionBytes } from "../../bcs/serializable/entryFunctionBytes";
|
|
@@ -656,7 +654,6 @@ export class TransactionExecutableEmpty extends TransactionExecutable {
|
|
|
656
654
|
serializer.serializeU32AsUleb128(TransactionExecutableVariants.Empty);
|
|
657
655
|
}
|
|
658
656
|
|
|
659
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
660
657
|
static load(_: Deserializer): TransactionExecutableEmpty {
|
|
661
658
|
return new TransactionExecutableEmpty();
|
|
662
659
|
}
|
|
@@ -129,7 +129,6 @@ export class AccountSequenceNumber {
|
|
|
129
129
|
while (this.currentNumber! - this.lastUncommintedNumber! >= this.maximumInFlight) {
|
|
130
130
|
await sleep(this.sleepTime);
|
|
131
131
|
if (nowInSeconds() - startTime > this.maxWaitTime) {
|
|
132
|
-
/* eslint-disable no-console */
|
|
133
132
|
console.warn(
|
|
134
133
|
`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`,
|
|
135
134
|
);
|
|
@@ -205,7 +204,6 @@ export class AccountSequenceNumber {
|
|
|
205
204
|
const startTime = nowInSeconds();
|
|
206
205
|
while (this.lastUncommintedNumber !== this.currentNumber) {
|
|
207
206
|
if (nowInSeconds() - startTime > this.maxWaitTime) {
|
|
208
|
-
/* eslint-disable no-console */
|
|
209
207
|
console.warn(
|
|
210
208
|
`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`,
|
|
211
209
|
);
|
|
@@ -78,8 +78,7 @@ import {
|
|
|
78
78
|
import { MoveFunction, MoveModule } from "../../types";
|
|
79
79
|
import { warnIfDevelopment } from "../../utils/helpers";
|
|
80
80
|
import { memoizeAsync } from "../../utils/memoize";
|
|
81
|
-
|
|
82
|
-
const TEXT_ENCODER = new TextEncoder();
|
|
81
|
+
import { TEXT_ENCODER } from "../../utils";
|
|
83
82
|
|
|
84
83
|
/**
|
|
85
84
|
* Convert type arguments to only type tags, allowing for string representations of type tags.
|
|
@@ -708,9 +708,7 @@ export function getAuthenticatorForSimulation(publicKey?: PublicKey) {
|
|
|
708
708
|
return new AnySignature(invalidSignature);
|
|
709
709
|
}),
|
|
710
710
|
bitmap: accountPublicKey.createBitmap({
|
|
711
|
-
bits: Array(accountPublicKey.publicKeys.length)
|
|
712
|
-
.fill(0)
|
|
713
|
-
.map((_, i) => i),
|
|
711
|
+
bits: new Array(accountPublicKey.publicKeys.length).fill(0).map((_, i) => i),
|
|
714
712
|
}),
|
|
715
713
|
}),
|
|
716
714
|
);
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
// Copyright © Aptos Foundation
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
5
|
-
|
|
6
|
-
/* eslint-disable max-classes-per-file */
|
|
7
4
|
import { Deserializer } from "../../bcs/deserializer";
|
|
8
5
|
import { Serializable, Serializer } from "../../bcs/serializer";
|
|
9
6
|
import { AccountAddress } from "../../core";
|
|
@@ -382,7 +382,7 @@ function parseTypeTagInner(str: string, types: Array<TypeTag>, allowGenerics: bo
|
|
|
382
382
|
throw new TypeTagParserError(str, TypeTagParserErrorType.UnexpectedVectorTypeArgumentCount);
|
|
383
383
|
}
|
|
384
384
|
return new TypeTagVector(types[0]);
|
|
385
|
-
default:
|
|
385
|
+
default: {
|
|
386
386
|
// Reference will have to handle the inner type
|
|
387
387
|
if (isRef(trimmedStr)) {
|
|
388
388
|
const actualType = trimmedStr.substring(1);
|
|
@@ -403,14 +403,12 @@ function parseTypeTagInner(str: string, types: Array<TypeTag>, allowGenerics: bo
|
|
|
403
403
|
}
|
|
404
404
|
|
|
405
405
|
// Parse for a struct tag
|
|
406
|
-
// eslint-disable-next-line no-case-declarations
|
|
407
406
|
const structParts = trimmedStr.split("::");
|
|
408
407
|
if (structParts.length !== 3) {
|
|
409
408
|
throw new TypeTagParserError(str, TypeTagParserErrorType.UnexpectedStructFormat);
|
|
410
409
|
}
|
|
411
410
|
|
|
412
411
|
// Validate struct address
|
|
413
|
-
// eslint-disable-next-line no-case-declarations
|
|
414
412
|
let address: AccountAddress;
|
|
415
413
|
try {
|
|
416
414
|
address = AccountAddress.fromString(structParts[0]);
|
|
@@ -429,5 +427,6 @@ function parseTypeTagInner(str: string, types: Array<TypeTag>, allowGenerics: bo
|
|
|
429
427
|
return new TypeTagStruct(
|
|
430
428
|
new StructTag(address, new Identifier(structParts[1]), new Identifier(structParts[2]), types),
|
|
431
429
|
);
|
|
430
|
+
}
|
|
432
431
|
}
|
|
433
432
|
}
|
package/src/utils/const.ts
CHANGED
|
@@ -24,7 +24,7 @@ export enum AptosApiType {
|
|
|
24
24
|
* @group Implementation
|
|
25
25
|
* @category Utils
|
|
26
26
|
*/
|
|
27
|
-
export const DEFAULT_MAX_GAS_AMOUNT =
|
|
27
|
+
export const DEFAULT_MAX_GAS_AMOUNT = 2000000;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* The minimum max gas amount that the SDK will allow for a transaction.
|
|
@@ -109,3 +109,8 @@ export enum ProcessorType {
|
|
|
109
109
|
* where project-id can contain letters, numbers, hyphens, and underscores
|
|
110
110
|
*/
|
|
111
111
|
export const FIREBASE_AUTH_ISS_PATTERN = /^https:\/\/securetoken\.google\.com\/[a-zA-Z0-9-_]+$/;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Shared TextEncoder instance for string serialization to avoid repeated instantiation.
|
|
115
|
+
*/
|
|
116
|
+
export const TEXT_ENCODER = new TextEncoder();
|
package/src/utils/helpers.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright © Aptos Foundation
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { decode } from "js-base64";
|
|
4
|
+
import { Base64, decode } from "js-base64";
|
|
5
5
|
import { MoveFunctionId, MoveStructId } from "../types";
|
|
6
6
|
import { AccountAddress } from "../core/accountAddress";
|
|
7
7
|
import { createObjectAddress } from "../core/account/utils/address";
|
|
@@ -43,7 +43,6 @@ export function warnIfDevelopment(message: string): void {
|
|
|
43
43
|
process.env.APTOS_SDK_WARNINGS === "true");
|
|
44
44
|
|
|
45
45
|
if (isDevelopment) {
|
|
46
|
-
// eslint-disable-next-line no-console
|
|
47
46
|
console.warn(message);
|
|
48
47
|
}
|
|
49
48
|
}
|
|
@@ -122,8 +121,8 @@ export function base64UrlToBytes(base64Url: string): Uint8Array {
|
|
|
122
121
|
while (base64.length % 4 !== 0) {
|
|
123
122
|
base64 += "=";
|
|
124
123
|
}
|
|
125
|
-
// Use
|
|
126
|
-
return
|
|
124
|
+
// Use js-base64 to convert base64 to Uint8Array
|
|
125
|
+
return Base64.toUint8Array(base64);
|
|
127
126
|
}
|
|
128
127
|
|
|
129
128
|
/**
|
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 $=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var g=(r,e,t,n)=>{for(var s=n>1?void 0:n?X(e,t):e,o=r.length-1,a;o>=0;o--)(a=r[o])&&(s=(n?a(e,t,s):a(s))||s);return n&&s&&$(e,t,s),s};var d=class extends Error{constructor(e,t){super(e),this.invalidReason=t}};var _utils = require('@noble/hashes/utils');var K=(n=>(n.TOO_SHORT="too_short",n.INVALID_LENGTH="invalid_length",n.INVALID_HEX_CHARS="invalid_hex_chars",n))(K||{}),f= exports.v =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 d("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 d("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 d(`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])}},De= exports.w =r=>new TextDecoder().decode(f.fromHexInput(r).toUint8Array());var M=255,U= exports.c =65535,x= exports.d =4294967295,m= exports.e =18446744073709551615n,I= exports.f =340282366920938463463374607431768211455n,T= exports.g =115792089237316195423570985008687907853269984665640564039457584007913129639935n,N= exports.h =-128,B= exports.i =127,E= exports.j =-32768,w= exports.k =32767,k= exports.l =-2147483648,C= exports.m =2147483647,O= exports.n =-9223372036854775808n,z= exports.o =9223372036854775807n,D= exports.p =-170141183460469231731687303715884105728n,G= exports.q =170141183460469231731687303715884105727n,F= exports.r =-57896044618658097711785492504343953926634992332820282019728792003956564819968n,H= exports.s =57896044618658097711785492504343953926634992332820282019728792003956564819967n;var b=class{bcsToBytes(){let e=new c;return this.serialize(e),e.toUint8Array()}bcsToHex(){let e=this.bcsToBytes();return f.fromHexInput(e)}toStringWithoutPrefix(){return this.bcsToHex().toStringWithoutPrefix()}toString(){return`0x${this.toStringWithoutPrefix()}`}},Y=256,Z=new TextEncoder,A=[],Q=8;function J(){let r=A.pop();return r?(r.reset(),r):new c}function V(r){A.length<Q&&A.push(r)}var c=class{constructor(e=64){if(e<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(e),this.dataView=new DataView(this.buffer),this.offset=0}ensureBufferWillHandleSize(e){let t=this.offset+e;if(this.buffer.byteLength>=t)return;let n=Math.max(Math.floor(this.buffer.byteLength*1.5),t+Y),s=new ArrayBuffer(n);new Uint8Array(s).set(new Uint8Array(this.buffer,0,this.offset)),this.buffer=s,this.dataView=new DataView(this.buffer)}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),e.apply(this.dataView,[this.offset,n,!0]),this.offset+=t}serializeStr(e){this.serializeBytes(Z.encode(e))}serializeBytes(e){this.serializeU32AsUleb128(e.length),this.appendToBuffer(e)}serializeFixedBytes(e){this.appendToBuffer(e)}serializeBool(e){ee(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)&m,n=BigInt(e)>>BigInt(64);this.serializeU64(t),this.serializeU64(n)}serializeU256(e){let t=BigInt(e)&I,n=BigInt(e)>>BigInt(128);this.serializeU128(t),this.serializeU128(n)}serializeI8(e){this.serializeWithFunction(DataView.prototype.setInt8,1,e)}serializeI16(e){this.serializeWithFunction(DataView.prototype.setInt16,2,e)}serializeI32(e){this.serializeWithFunction(DataView.prototype.setInt32,4,e)}serializeI64(e){let t=BigInt(e),n=t<0?(BigInt(1)<<BigInt(64))+t:t,s=n&BigInt(x),o=n>>BigInt(32);this.serializeU32(Number(s)),this.serializeU32(Number(o))}serializeI128(e){let t=BigInt(e),n=t<0?(BigInt(1)<<BigInt(128))+t:t,s=n&m,o=n>>BigInt(64);this.serializeU64(s),this.serializeU64(o)}serializeI256(e){let t=BigInt(e),n=t<0?(BigInt(1)<<BigInt(256))+t:t,s=n&I,o=n>>BigInt(128);this.serializeU128(s),this.serializeU128(o)}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,0,this.offset).slice()}reset(){this.offset>0&&new Uint8Array(this.buffer,0,this.offset).fill(0),this.offset=0}getOffset(){return this.offset}toUint8ArrayView(){return new Uint8Array(this.buffer,0,this.offset)}serialize(e){e.serialize(this)}serializeAsBytes(e){let t=J();try{e.serialize(t);let n=t.toUint8ArrayView();this.serializeBytes(n)}finally{V(t)}}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))}};g([l(0,M)],c.prototype,"serializeU8",1),g([l(0,U)],c.prototype,"serializeU16",1),g([l(0,x)],c.prototype,"serializeU32",1),g([l(BigInt(0),m)],c.prototype,"serializeU64",1),g([l(BigInt(0),I)],c.prototype,"serializeU128",1),g([l(BigInt(0),T)],c.prototype,"serializeU256",1),g([l(N,B)],c.prototype,"serializeI8",1),g([l(E,w)],c.prototype,"serializeI16",1),g([l(k,C)],c.prototype,"serializeI32",1),g([l(O,z)],c.prototype,"serializeI64",1),g([l(D,G)],c.prototype,"serializeI128",1),g([l(F,H)],c.prototype,"serializeI256",1),g([l(0,x)],c.prototype,"serializeU32AsUleb128",1);function ee(r){if(typeof r!="boolean")throw new Error(`${r} is not a boolean value`)}var te=(r,e,t)=>`${r} is out of range: [${e}, ${t}]`;function re(r,e,t){let n=BigInt(r);if(n>BigInt(t)||n<BigInt(e))throw new Error(te(r,e,t))}function l(r,e){return(t,n,s)=>{let o=s.value;return s.value=function(_){return re(_,r,e),o.apply(this,[_])},s}}var ne=(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))(ne||{}),se= exports.D =(i=>(i[i.Bool=0]="Bool",i[i.U8=1]="U8",i[i.U64=2]="U64",i[i.U128=3]="U128",i[i.Address=4]="Address",i[i.Signer=5]="Signer",i[i.Vector=6]="Vector",i[i.Struct=7]="Struct",i[i.U16=8]="U16",i[i.U32=9]="U32",i[i.U256=10]="U256",i[i.I8=11]="I8",i[i.I16=12]="I16",i[i.I32=13]="I32",i[i.I64=14]="I64",i[i.I128=15]="I128",i[i.I256=16]="I256",i[i.Reference=254]="Reference",i[i.Generic=255]="Generic",i))(se||{}),W= exports.E =(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[p.I8=10]="I8",p[p.I16=11]="I16",p[p.I32=12]="I32",p[p.I64=13]="I64",p[p.I128=14]="I128",p[p.I256=15]="I256",p))(W||{}),oe= exports.F =(s=>(s[s.Script=0]="Script",s[s.EntryFunction=2]="EntryFunction",s[s.Multisig=3]="Multisig",s[s.Payload=4]="Payload",s))(oe||{}),ie= exports.G =(e=>(e[e.V1=0]="V1",e))(ie||{}),ae= exports.H =(n=>(n[n.Script=0]="Script",n[n.EntryFunction=1]="EntryFunction",n[n.Empty=2]="Empty",n))(ae||{}),pe= exports.I =(e=>(e[e.V1=0]="V1",e))(pe||{}),ue= exports.J =(t=>(t[t.MultiAgentTransaction=0]="MultiAgentTransaction",t[t.FeePayerTransaction=1]="FeePayerTransaction",t))(ue||{}),ce= exports.K =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.MultiAgent=2]="MultiAgent",o[o.FeePayer=3]="FeePayer",o[o.SingleSender=4]="SingleSender",o))(ce||{}),de= exports.L =(a=>(a[a.Ed25519=0]="Ed25519",a[a.MultiEd25519=1]="MultiEd25519",a[a.SingleKey=2]="SingleKey",a[a.MultiKey=3]="MultiKey",a[a.NoAccountAuthenticator=4]="NoAccountAuthenticator",a[a.Abstraction=5]="Abstraction",a))(de||{}),ge= exports.M =(n=>(n.Ed25519="ed25519",n.Secp256k1="secp256k1",n.Secp256r1="secp256r1",n))(ge||{}),le= exports.N =(a=>(a[a.Ed25519=0]="Ed25519",a[a.Secp256k1=1]="Secp256k1",a[a.Secp256r1=2]="Secp256r1",a[a.Keyless=3]="Keyless",a[a.FederatedKeyless=4]="FederatedKeyless",a[a.SlhDsaSha2_128s=5]="SlhDsaSha2_128s",a))(le||{});function $e(r){switch(r){case 0:return"ed25519";case 1:return"secp256k1";case 2:return"secp256r1";case 3:return"keyless";case 4:return"federated_keyless";case 5:return"slh_dsa_sha2_128s";default:throw new Error("Unknown public key variant")}}var ye=(o=>(o[o.Ed25519=0]="Ed25519",o[o.Secp256k1=1]="Secp256k1",o[o.WebAuthn=2]="WebAuthn",o[o.Keyless=3]="Keyless",o[o.SlhDsaSha2_128s=4]="SlhDsaSha2_128s",o))(ye||{}),_e= exports.Q =(e=>(e[e.Ed25519=0]="Ed25519",e))(_e||{}),he= exports.R =(e=>(e[e.Ed25519=0]="Ed25519",e))(he||{}),fe= exports.S =(e=>(e[e.ZkProof=0]="ZkProof",e))(fe||{}),xe= exports.T =(e=>(e[e.Groth16=0]="Groth16",e))(xe||{}),me= exports.U =(_=>(_.Pending="pending_transaction",_.User="user_transaction",_.Genesis="genesis_transaction",_.BlockMetadata="block_metadata_transaction",_.StateCheckpoint="state_checkpoint_transaction",_.Validator="validator_transaction",_.BlockEpilogue="block_epilogue_transaction",_))(me||{});function Xe(r){return r.type==="pending_transaction"}function qe(r){return r.type==="user_transaction"}function je(r){return r.type==="genesis_transaction"}function Ke(r){return r.type==="block_metadata_transaction"}function Ye(r){return r.type==="state_checkpoint_transaction"}function Ze(r){return r.type==="validator_transaction"}function Qe(r){return r.type==="block_epilogue_transaction"}function Je(r){return"signature"in r&&r.type==="ed25519_signature"}function Ve(r){return"signature"in r&&r.signature==="secp256k1_ecdsa_signature"}function et(r){return r.type==="multi_agent_signature"}function tt(r){return r.type==="fee_payer_signature"}function rt(r){return r.type==="multi_ed25519_signature"}function nt(r){return r.type==="single_sender"}var Ie=(n=>(n.PRIVATE="private",n.PUBLIC="public",n.FRIEND="friend",n))(Ie||{}),be= exports.ha =(s=>(s.STORE="store",s.DROP="drop",s.KEY="key",s.COPY="copy",s))(be||{}),Ae= exports.ia =(t=>(t.VALIDATOR="validator",t.FULL_NODE="full_node",t))(Ae||{}),Se= exports.ja =(s=>(s[s.Ed25519=0]="Ed25519",s[s.MultiEd25519=1]="MultiEd25519",s[s.SingleKey=2]="SingleKey",s[s.MultiKey=3]="MultiKey",s))(Se||{}),ve= exports.ka =(t=>(t[t.Ed25519=0]="Ed25519",t[t.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",t))(ve||{}),P= exports.la =(o=>(o[o.DeriveAuid=251]="DeriveAuid",o[o.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",o[o.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",o[o.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",o[o.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",o))(P||{});var Re=(t=>(t[t.Independent=0]="Independent",t[t.FollowsDomain=1]="FollowsDomain",t))(Re||{}),Me= exports.na =(n=>(n.Expired="expired",n.InGracePeriod="in_grace_period",n.Active="active",n))(Me||{});var Te=(h=>(h.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",h.INVALID_HEX_CHARS="invalid_hex_chars",h.TOO_SHORT="too_short",h.TOO_LONG="too_long",h.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",h.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",h.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",h.INVALID_PADDING_STRICTNESS="INVALID_PADDING_STRICTNESS",h))(Te||{}),u=class u extends b{constructor(e){if(super(),e.length!==u.LENGTH)throw new d("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){e.serializeAsBytes(this)}serializeForScriptFunction(e){e.serializeU32AsUleb128(3),e.serialize(this)}static deserialize(e){let t=e.deserializeFixedBytes(u.LENGTH);return new u(t)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new d("Hex string must start with a leading 0x.","leading_zero_x_required");let t=u.fromString(e);if(e.length!==u.LONG_STRING_LENGTH+2)if(t.isSpecial()){if(e.length!==3)throw new d(`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 d(`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 d("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(n.length>64)throw new d("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 d(`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(a){throw new d(`Hex characters are invalid: ${_optionalChain([a, 'optionalAccess', _5 => _5.message])}`,"invalid_hex_chars")}let o=new u(s);if(n.length<64-t&&!o.isSpecial())throw new d(`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 o}static from(e,{maxMissingChars:t=4}={}){return typeof e=="string"?u.fromString(e,{maxMissingChars:t}):e instanceof Uint8Array?new u(e):e}static fromStrict(e){return typeof e=="string"?u.fromStringStrict(e):e instanceof Uint8Array?new u(e):e}static isValid(e){try{return e.strict?u.fromStrict(e.input):u.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])}};u.LENGTH=32,u.LONG_STRING_LENGTH=64,u.ZERO=u.from("0x0"),u.ONE=u.from("0x1"),u.TWO=u.from("0x2"),u.THREE=u.from("0x3"),u.FOUR=u.from("0x4"),u.A=u.from("0xA");var y=u;var _sha3 = require('@noble/hashes/sha3');var R=(r,e)=>{let t=r.bcsToBytes(),n=typeof e=="string"?Buffer.from(e,"utf8"):e,s=new Uint8Array([...t,...n,254]);return new y(_sha3.sha3_256.call(void 0, s))},bt= exports.ra =(r,e)=>{let t=r.bcsToBytes(),n=typeof e=="string"?Buffer.from(e,"utf8"):e,s=new Uint8Array([...t,...n,255]);return new y(_sha3.sha3_256.call(void 0, s))},At= exports.sa =(r,e)=>{let t=r.bcsToBytes(),n=e.bcsToBytes(),s=new Uint8Array([...t,...n,252]);return new y(_sha3.sha3_256.call(void 0, s))},St= exports.ta =(r,e,t)=>{let n=`${e}::${t}`;return R(r,n)};var _jsbase64 = require('js-base64');function Tt(){try{return typeof globalThis<"u"&&"Bun"in globalThis}catch (e2){return!1}}function Nt(r){typeof process<"u"&&process.env&&(process.env.NODE_ENV==="development"||process.env.NODE_ENV==="test"||process.env.APTOS_SDK_WARNINGS==="true")&&console.warn(r)}async function Bt(r){return new Promise(e=>{setTimeout(e,r)})}function Et(r){return r instanceof Error?r.message:String(r)}var wt=()=>Math.floor(Date.now()/1e3);function kt(r){let e=new Date(r*1e3);return e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),Math.floor(e.getTime()/1e3)}function Ct(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 Ot(r){let e=r.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4!==0;)e+="=";return new Uint8Array(Buffer.from(e,"base64"))}var zt=(r,e)=>r*10**e,Dt= exports.Da =(r,e)=>r/10**e,L=r=>{let e="";for(let t=2;t<r.length;t+=2)e+=String.fromCharCode(parseInt(r.substring(t,t+2),16));return e},Gt= exports.Ea =r=>{let{account_address:e,module_name:t,struct_name:n}=r,s=L(t),o=L(n);return`${e}::${s}::${o}`},Ft= exports.Fa =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 Wt(r){let e=r.split("::");return e.length===3&&y.isValid({input:e[0]}).valid}function Pt(r,e=6,t=5){return`${r.slice(0,e)}...${r.slice(-t)}`}var Be="0x1::aptos_coin::AptosCoin";function Ee(r){let e=/0x[0-9a-fA-F]+/g;return r.replace(e,t=>y.from(t,{maxMissingChars:63}).toStringShort())}function Lt(r){let e=Ee(r);return e===Be?y.A:R(y.A,e)}exports.a = g; exports.b = M; exports.c = U; exports.d = x; exports.e = m; exports.f = I; exports.g = T; exports.h = N; exports.i = B; exports.j = E; exports.k = w; exports.l = k; exports.m = C; exports.n = O; exports.o = z; exports.p = D; exports.q = G; exports.r = F; exports.s = H; exports.t = d; exports.u = K; exports.v = f; exports.w = De; exports.x = b; exports.y = c; exports.z = ee; exports.A = te; exports.B = re; exports.C = ne; exports.D = se; exports.E = W; exports.F = oe; exports.G = ie; exports.H = ae; exports.I = pe; exports.J = ue; exports.K = ce; exports.L = de; exports.M = ge; exports.N = le; exports.O = $e; exports.P = ye; exports.Q = _e; exports.R = he; exports.S = fe; exports.T = xe; exports.U = me; exports.V = Xe; exports.W = qe; exports.X = je; exports.Y = Ke; exports.Z = Ye; exports._ = Ze; exports.$ = Qe; exports.aa = Je; exports.ba = Ve; exports.ca = et; exports.da = tt; exports.ea = rt; exports.fa = nt; exports.ga = Ie; exports.ha = be; exports.ia = Ae; exports.ja = Se; exports.ka = ve; exports.la = P; exports.ma = Re; exports.na = Me; exports.oa = Te; exports.pa = y; exports.qa = R; exports.ra = bt; exports.sa = At; exports.ta = St; exports.ua = Tt; exports.va = Nt; exports.wa = Bt; exports.xa = Et; exports.ya = wt; exports.za = kt; exports.Aa = Ct; exports.Ba = Ot; exports.Ca = zt; exports.Da = Dt; exports.Ea = Gt; exports.Fa = Ft; exports.Ga = Ht; exports.Ha = Wt; exports.Ia = Pt; exports.Ja = Lt;
|
|
4
|
-
//# sourceMappingURL=chunk-3NBJLJ2Y.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bcs/serializable/movePrimitives.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n/* eslint-disable max-classes-per-file */\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":"kNAqCO,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,UAAUE,EAA8B,CACtCA,EAAW,YAAY,KAAK,KAAK,CACnC,CAEA,0BAA0BA,EAA8B,CACtDA,EAAW,iBAAiB,IAAI,CAClC,CAEA,2BAA2BA,EAA8B,CACvDA,EAAW,uBAA0D,EACrEA,EAAW,UAAU,IAAI,CAC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BAA2BA,EAA8B,CACvDA,EAAW,wBAA2D,EACtEA,EAAW,UAAU,IAAI,CAC3B,CAEA,OAAO,YAAYC,EAAiC,CAClD,OAAO,IAAIiC,EAAIjC,EAAa,eAAe,CAAC,CAC9C,CACF,EAWaoC,EAAN,MAAMC,UAAazC,CAA4C,CAGpE,YAAYC,EAAkB,CAC5B,MAAM,EACNO,EAAsBP,EAAOyC,EAAkBC,CAAgB,EAC/D,KAAK,MAAQ,OAAO1C,CAAK,CAC3B,CAEA,UAAUE,EAA8B,CACtCA,EAAW,cAAc,KAAK,KAAK,CACrC,CAEA,0BAA0BA,EAA8B,CACtDA,EAAW,iBAAiB,IAAI,CAClC,CAEA,2BAA2BA,EAA8B,CACvDA,EAAW,wBAA4D,EACvEA,EAAW,UAAU,IAAI,CAC3B,CAEA,OAAO,YAAYC,EAAkC,CACnD,OAAO,IAAIqC,EAAKrC,EAAa,gBAAgB,CAAC,CAChD,CACF,EAWawC,EAAN,MAAMC,UAAa7C,CAA4C,CAGpE,YAAYC,EAAkB,CAC5B,MAAM,EACNO,EAAsBP,EAAO6C,EAAkBC,CAAgB,EAC/D,KAAK,MAAQ,OAAO9C,CAAK,CAC3B,CAEA,UAAUE,EAA8B,CACtCA,EAAW,cAAc,KAAK,KAAK,CACrC,CAEA,0BAA0BA,EAA8B,CACtDA,EAAW,iBAAiB,IAAI,CAClC,CAEA,2BAA2BA,EAA8B,CACvDA,EAAW,wBAA4D,EACvEA,EAAW,UAAU,IAAI,CAC3B,CAEA,OAAO,YAAYC,EAAkC,CACnD,OAAO,IAAIyC,EAAKzC,EAAa,gBAAgB,CAAC,CAChD,CACF","names":["Bool","_Bool","Serializable","value","ensureBoolean","serializer","deserializer","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,2 +0,0 @@
|
|
|
1
|
-
import{a as i}from"./chunk-HHAUJ5E4.mjs";import{b as r}from"./chunk-VWLK43JM.mjs";import{decode as u}from"js-base64";function f(){try{return typeof globalThis<"u"&&"Bun"in globalThis}catch{return!1}}function _(e){typeof process<"u"&&process.env&&(process.env.NODE_ENV==="development"||process.env.NODE_ENV==="test"||process.env.APTOS_SDK_WARNINGS==="true")&&console.warn(e)}async function x(e){return new Promise(n=>{setTimeout(n,e)})}function A(e){return e instanceof Error?e.message:String(e)}var v=()=>Math.floor(Date.now()/1e3);function h(e){let n=new Date(e*1e3);return n.setMinutes(0),n.setSeconds(0),n.setMilliseconds(0),Math.floor(n.getTime()/1e3)}function S(e){let n=e.replace(/-/g,"+").replace(/_/g,"/"),t=n+"==".substring(0,(3-n.length%3)%3);return u(t)}function b(e){let n=e.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4!==0;)n+="=";return new Uint8Array(Buffer.from(n,"base64"))}var y=(e,n)=>e*10**n,T=(e,n)=>e/10**n,a=e=>{let n="";for(let t=2;t<e.length;t+=2)n+=String.fromCharCode(parseInt(e.substring(t,t+2),16));return n},M=e=>{let{account_address:n,module_name:t,struct_name:o}=e,s=a(t),c=a(o);return`${n}::${s}::${c}`},N=e=>typeof e=="object"&&!Array.isArray(e)&&e!==null&&"account_address"in e&&"module_name"in e&&"struct_name"in e&&typeof e.account_address=="string"&&typeof e.module_name=="string"&&typeof e.struct_name=="string";function w(e){let n=e.split("::");if(n.length!==3)throw new Error(`Invalid function ${e}`);let t=n[0],o=n[1],s=n[2];return{moduleAddress:t,moduleName:o,functionName:s}}function I(e){let n=e.split("::");return n.length===3&&r.isValid({input:n[0]}).valid}function E(e,n=6,t=5){return`${e.slice(0,n)}...${e.slice(-t)}`}var d="0x1::aptos_coin::AptosCoin";function m(e){let n=/0x[0-9a-fA-F]+/g;return e.replace(n,t=>r.from(t,{maxMissingChars:63}).toStringShort())}function D(e){let n=m(e);return n===d?r.A:i(r.A,n)}export{f as a,_ as b,x as c,A as d,v as e,h as f,S as g,b as h,y as i,T as j,M as k,N as l,w as m,I as n,E as o,D as p};
|
|
2
|
-
//# sourceMappingURL=chunk-7FG7RJDS.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/helpers.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { decode } from \"js-base64\";\nimport { MoveFunctionId, MoveStructId } from \"../types\";\nimport { AccountAddress } from \"../core/accountAddress\";\nimport { createObjectAddress } from \"../core/account/utils/address\";\n\n/**\n * Checks if the current runtime environment is Bun.\n * This is useful for detecting Bun-specific compatibility issues.\n *\n * @returns true if running in Bun, false otherwise.\n * @group Implementation\n * @category Utils\n */\nexport function isBun(): boolean {\n try {\n // Bun exposes a global `Bun` object.\n return typeof globalThis !== \"undefined\" && \"Bun\" in globalThis;\n } catch {\n return false;\n }\n}\n\n/**\n * Logs a warning message to the console only in development environments.\n * This function helps reduce information leakage in production while maintaining\n * helpful warnings during development.\n *\n * @param message - The warning message to log.\n * @group Implementation\n * @category Utils\n */\nexport function warnIfDevelopment(message: string): void {\n // Check common environment variables to determine if we're in development\n // This works in Node.js, bundlers like webpack/vite, and most build systems\n const isDevelopment =\n typeof process !== \"undefined\" &&\n process.env &&\n (process.env.NODE_ENV === \"development\" ||\n process.env.NODE_ENV === \"test\" ||\n process.env.APTOS_SDK_WARNINGS === \"true\");\n\n if (isDevelopment) {\n // eslint-disable-next-line no-console\n console.warn(message);\n }\n}\n\n/**\n * Sleep for the specified amount of time in milliseconds.\n * This function can be used to introduce delays in asynchronous operations.\n *\n * @param timeMs - The time in milliseconds to sleep.\n * @group Implementation\n * @category Utils\n */\nexport async function sleep(timeMs: number): Promise<null> {\n return new Promise((resolve) => {\n setTimeout(resolve, timeMs);\n });\n}\n\n/**\n * Get the error message from an unknown error.\n *\n * @param error The error to get the message from\n * @returns The error message\n * @group Implementation\n * @category Utils\n */\nexport function getErrorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/**\n * @group Implementation\n * @category Utils\n */\nexport const nowInSeconds = () => Math.floor(Date.now() / 1000);\n\n/**\n * Floors the given timestamp to the nearest whole hour.\n * This function is useful for normalizing timestamps to hourly intervals.\n *\n * @param timestampInSeconds - The timestamp in seconds to be floored.\n * @group Implementation\n * @category Utils\n */\nexport function floorToWholeHour(timestampInSeconds: number): number {\n const date = new Date(timestampInSeconds * 1000);\n // Reset minutes and seconds to zero\n date.setMinutes(0);\n date.setSeconds(0);\n date.setMilliseconds(0);\n return Math.floor(date.getTime() / 1000);\n}\n\n/**\n * Decodes a base64 URL-encoded string into its original form.\n * This function is useful for converting base64 URL-encoded data back to a readable format.\n *\n * @param base64Url - The base64 URL-encoded string to decode.\n * @returns The decoded string.\n * @group Implementation\n * @category Utils\n */\nexport function base64UrlDecode(base64Url: string): string {\n // Replace base64url-specific characters\n const base64 = base64Url.replace(/-/g, \"+\").replace(/_/g, \"/\");\n // Pad the string with '=' characters if needed\n const paddedBase64 = base64 + \"==\".substring(0, (3 - (base64.length % 3)) % 3);\n const decodedString = decode(paddedBase64);\n return decodedString;\n}\n\nexport function base64UrlToBytes(base64Url: string): Uint8Array {\n // Convert Base64Url to Base64\n let base64 = base64Url.replace(/-/g, \"+\").replace(/_/g, \"/\");\n // Add padding if needed\n while (base64.length % 4 !== 0) {\n base64 += \"=\";\n }\n // Use Buffer to convert base64 to Uint8Array\n return new Uint8Array(Buffer.from(base64, \"base64\"));\n}\n\n/**\n * Amount is represented in the smallest unit format on chain, this function converts\n * a human-readable amount format to the smallest unit format\n * @example\n * human-readable amount format: 500\n * on chain amount format when decimal is 8: 50000000000\n *\n * @param value The value in human-readable format\n * @param decimal The token decimal\n * @returns The value in the smallest units\n * @group Implementation\n * @category Utils\n */\nexport const convertAmountFromHumanReadableToOnChain = (value: number, decimal: number) => value * 10 ** decimal;\n\n/**\n * Amount is represented in the smallest unit format on chain, this function converts\n * the smallest unit format to a human-readable amount format\n * @example\n * human-readable amount format: 500\n * on chain amount format when decimal is 8: 50000000000\n *\n * @param value The value in human-readable format\n * @param decimal The token decimal\n * @returns The value in the smallest units\n * @group Implementation\n * @category Utils\n */\nexport const convertAmountFromOnChainToHumanReadable = (value: number, decimal: number) => value / 10 ** decimal;\n\n/**\n * Convert a hex string to an ascii string with the `0x` prefix.\n *\n * `0x6170746f735f636f696e` --> `aptos_coin`\n *\n * @param hex The hex string to convert (e.g. `0x6170746f735f636f696e`)\n * @returns The ascii string\n * @group Implementation\n * @category Utils\n */\nconst hexToAscii = (hex: string) => {\n let str = \"\";\n for (let n = 2; n < hex.length; n += 2) {\n str += String.fromCharCode(parseInt(hex.substring(n, n + 2), 16));\n }\n return str;\n};\n\n/**\n * Convert an encoded struct to a MoveStructId.\n *\n * @example\n * const structObj = {\n * account_address: \"0x1\",\n * module_name: \"0x6170746f735f636f696e\",\n * struct_name: \"0x4170746f73436f696e\",\n * };\n * // structId is \"0x1::aptos_coin::AptosCoin\"\n * const structId = parseEncodedStruct(structObj);\n *\n * @param structObj The struct with account_address, module_name, and struct_name properties\n * @returns The MoveStructId\n * @group Implementation\n * @category Utils\n */\nexport const parseEncodedStruct = (structObj: {\n account_address: string;\n module_name: string;\n struct_name: string;\n}): MoveStructId => {\n const { account_address, module_name, struct_name } = structObj;\n const moduleName = hexToAscii(module_name);\n const structName = hexToAscii(struct_name);\n return `${account_address}::${moduleName}::${structName}`;\n};\n\n/**\n * Determines whether the given object is an encoded struct type with the following properties:\n * - account_address: string\n * - module_name: string\n * - struct_name: string\n *\n * @param structObj The object to check\n * @returns Whether the object is an encoded struct type\n * @group Implementation\n * @category Utils\n */\nexport const isEncodedStruct = (\n structObj: any,\n): structObj is {\n account_address: string;\n module_name: string;\n struct_name: string;\n} =>\n typeof structObj === \"object\" &&\n !Array.isArray(structObj) &&\n structObj !== null &&\n \"account_address\" in structObj &&\n \"module_name\" in structObj &&\n \"struct_name\" in structObj &&\n typeof structObj.account_address === \"string\" &&\n typeof structObj.module_name === \"string\" &&\n typeof structObj.struct_name === \"string\";\n\n/**\n * Splits a function identifier into its constituent parts: module address, module name, and function name.\n * This function helps in validating and extracting details from a function identifier string.\n *\n * @param functionArg - The function identifier string in the format \"moduleAddress::moduleName::functionName\".\n * @returns An object containing the module address, module name, and function name.\n * @throws Error if the function identifier does not contain exactly three parts.\n * @group Implementation\n * @category Transactions\n */\nexport function getFunctionParts(functionArg: MoveFunctionId) {\n const funcNameParts = functionArg.split(\"::\");\n if (funcNameParts.length !== 3) {\n throw new Error(`Invalid function ${functionArg}`);\n }\n const moduleAddress = funcNameParts[0];\n const moduleName = funcNameParts[1];\n const functionName = funcNameParts[2];\n return { moduleAddress, moduleName, functionName };\n}\n\n/**\n * Validates the provided function information.\n *\n * @param functionInfo - The function information to validate.\n * @returns Whether the function information is valid.\n * @group Implementation\n * @category Utils\n */\nexport function isValidFunctionInfo(functionInfo: string): boolean {\n const parts = functionInfo.split(\"::\");\n return parts.length === 3 && AccountAddress.isValid({ input: parts[0] }).valid;\n}\n\n/**\n * Truncates the provided wallet address at the middle with an ellipsis.\n *\n * @param address - The wallet address to truncate.\n * @param start - The number of characters to show at the beginning of the address.\n * @param end - The number of characters to show at the end of the address.\n * @returns The truncated address.\n * @group Implementation\n * @category Utils\n */\nexport function truncateAddress(address: string, start: number = 6, end: number = 5) {\n return `${address.slice(0, start)}...${address.slice(-end)}`;\n}\n\n/**\n * Constants for metadata address calculation\n */\nconst APTOS_COIN_TYPE_STR = \"0x1::aptos_coin::AptosCoin\";\n\n/**\n * Helper function to standardize Move type string by converting all addresses to short form,\n * including addresses within nested type parameters\n */\nfunction standardizeMoveTypeString(input: string): string {\n // Regular expression to match addresses in the type string, including those within type parameters\n // This regex matches \"0x\" followed by hex digits, handling both standalone addresses and those within <>\n const addressRegex = /0x[0-9a-fA-F]+/g;\n\n return input.replace(addressRegex, (match) =>\n // Use AccountAddress to handle the address\n AccountAddress.from(match, { maxMissingChars: 63 }).toStringShort(),\n );\n}\n\n/**\n * Calculates the paired FA metadata address for a given coin type.\n * This function is tolerant of various address formats in the coin type string,\n * including complex nested types.\n *\n * @example\n * // All these formats are valid and will produce the same result:\n * pairedFaMetadataAddress(\"0x1::aptos_coin::AptosCoin\") // simple form\n * pairedFaMetadataAddress(\"0x0000000000000000000000000000000000000000000000000000000000000001::aptos_coin::AptosCoin\") // long form\n * pairedFaMetadataAddress(\"0x00001::aptos_coin::AptosCoin\") // with leading zeros\n * pairedFaMetadataAddress(\"0x1::coin::Coin<0x1412::a::struct<0x0001::aptos_coin::AptosCoin>>\") // nested type parameters\n *\n * @param coinType - The coin type string in any of these formats:\n * - Short form address: \"0x1::aptos_coin::AptosCoin\"\n * - Long form address: \"0x0000000000000000000000000000000000000000000000000000000000000001::aptos_coin::AptosCoin\"\n * - With leading zeros: \"0x00001::aptos_coin::AptosCoin\"\n * - With nested types: \"0x1::coin::Coin<0x1412::a::struct<0x0001::aptos_coin::AptosCoin>>\"\n * @returns The calculated metadata address as an AccountAddress instance\n */\nexport function pairedFaMetadataAddress(coinType: `0x${string}::${string}::${string}`): AccountAddress {\n // Standardize the coin type string to handle any address format\n const standardizedMoveTypeName = standardizeMoveTypeString(coinType);\n\n return standardizedMoveTypeName === APTOS_COIN_TYPE_STR\n ? AccountAddress.A\n : createObjectAddress(AccountAddress.A, standardizedMoveTypeName);\n}\n"],"mappings":"kFAGA,OAAS,UAAAA,MAAc,YAahB,SAASC,GAAiB,CAC/B,GAAI,CAEF,OAAO,OAAO,WAAe,KAAe,QAAS,UACvD,MAAQ,CACN,MAAO,EACT,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,QAAQC,EAAeC,GAElCT,EAAe,KAAKS,EAAO,CAAE,gBAAiB,EAAG,CAAC,EAAE,cAAc,CACpE,CACF,CAqBO,SAASC,EAAwBC,EAA+D,CAErG,IAAMC,EAA2BN,EAA0BK,CAAQ,EAEnE,OAAOC,IAA6BP,EAChCL,EAAe,EACfa,EAAoBb,EAAe,EAAGY,CAAwB,CACpE","names":["decode","isBun","warnIfDevelopment","message","sleep","timeMs","resolve","getErrorMessage","error","nowInSeconds","floorToWholeHour","timestampInSeconds","date","base64UrlDecode","base64Url","base64","paddedBase64","decode","base64UrlToBytes","convertAmountFromHumanReadableToOnChain","value","decimal","convertAmountFromOnChainToHumanReadable","hexToAscii","hex","str","n","parseEncodedStruct","structObj","account_address","module_name","struct_name","moduleName","structName","isEncodedStruct","getFunctionParts","functionArg","funcNameParts","moduleAddress","functionName","isValidFunctionInfo","functionInfo","parts","AccountAddress","truncateAddress","address","start","end","APTOS_COIN_TYPE_STR","standardizeMoveTypeString","input","addressRegex","match","pairedFaMetadataAddress","coinType","standardizedMoveTypeName","createObjectAddress"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/const.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Types of API endpoints used for routing requests in the Aptos network.\n * @group Implementation\n * @category Utils\n */\nexport enum AptosApiType {\n FULLNODE = \"Fullnode\",\n INDEXER = \"Indexer\",\n FAUCET = \"Faucet\",\n PEPPER = \"Pepper\",\n PROVER = \"Prover\",\n}\n\n/**\n * The default max gas amount when none is given.\n *\n * This is the maximum number of gas units that will be used by a transaction before being rejected.\n *\n * Note that max gas amount varies based on the transaction. A larger transaction will go over this\n * default gas amount, and the value will need to be changed for the specific transaction.\n * @group Implementation\n * @category Utils\n */\nexport const DEFAULT_MAX_GAS_AMOUNT = 200000;\n\n/**\n * The minimum max gas amount that the SDK will allow for a transaction.\n *\n * This value acts as a floor to prevent transactions from being built with a max gas amount\n * below the network's minimum transaction gas units, which would cause\n * MAX_GAS_UNITS_BELOW_MIN_TRANSACTION_GAS_UNITS errors.\n * @group Implementation\n * @category Utils\n */\nexport const MIN_MAX_GAS_AMOUNT = 2000;\n\n/**\n * The default transaction expiration seconds from now.\n *\n * This time is how long until the blockchain nodes will reject the transaction.\n *\n * Note that the transaction expiration time varies based on network connection and network load. It may need to be\n * increased for the transaction to be processed.\n * @group Implementation\n * @category Utils\n */\nexport const DEFAULT_TXN_EXP_SEC_FROM_NOW = 20;\n\n/**\n * The default number of seconds to wait for a transaction to be processed.\n *\n * This time is the amount of time that the SDK will wait for a transaction to be processed when waiting for\n * the results of the transaction. It may take longer based on network connection and network load.\n * @group Implementation\n * @category Utils\n */\nexport const DEFAULT_TXN_TIMEOUT_SEC = 20;\n\n/**\n * The default gas currency for the network.\n * @group Implementation\n * @category Utils\n */\nexport const APTOS_COIN = \"0x1::aptos_coin::AptosCoin\";\n/**\n * @group Implementation\n * @category Utils\n */\nexport const APTOS_FA = \"0x000000000000000000000000000000000000000000000000000000000000000a\";\n/**\n * @group Implementation\n * @category Utils\n */\nexport const RAW_TRANSACTION_SALT = \"APTOS::RawTransaction\";\n/**\n * @group Implementation\n * @category Utils\n */\nexport const RAW_TRANSACTION_WITH_DATA_SALT = \"APTOS::RawTransactionWithData\";\n\nexport const ACCOUNT_ABSTRACTION_SIGNING_DATA_SALT = \"APTOS::AASigningData\";\n\n/**\n * Supported processor types for the indexer API, sourced from the processor_status table in the indexer database.\n * {@link https://cloud.hasura.io/public/graphiql?endpoint=https://api.mainnet.aptoslabs.com/v1/graphql}\n * @group Implementation\n * @category Utils\n */\nexport enum ProcessorType {\n ACCOUNT_RESTORATION_PROCESSOR = \"account_restoration_processor\",\n ACCOUNT_TRANSACTION_PROCESSOR = \"account_transactions_processor\",\n DEFAULT = \"default_processor\",\n EVENTS_PROCESSOR = \"events_processor\",\n // Fungible asset processor also handles coins\n FUNGIBLE_ASSET_PROCESSOR = \"fungible_asset_processor\",\n STAKE_PROCESSOR = \"stake_processor\",\n // Token V2 processor replaces Token processor (not only for digital assets)\n TOKEN_V2_PROCESSOR = \"token_v2_processor\",\n USER_TRANSACTION_PROCESSOR = \"user_transaction_processor\",\n OBJECT_PROCESSOR = \"objects_processor\",\n}\n\n/**\n * Regular expression pattern for Firebase Auth issuer URLs\n * Matches URLs in the format: https://securetoken.google.com/[project-id]\n * where project-id can contain letters, numbers, hyphens, and underscores\n */\nexport const FIREBASE_AUTH_ISS_PATTERN = /^https:\\/\\/securetoken\\.google\\.com\\/[a-zA-Z0-9-_]+$/;\n"],"mappings":"AAQO,IAAKA,OACVA,EAAA,SAAW,WACXA,EAAA,QAAU,UACVA,EAAA,OAAS,SACTA,EAAA,OAAS,SACTA,EAAA,OAAS,SALCA,OAAA,IAkBCC,EAAyB,IAWzBC,EAAqB,IAYrBC,EAA+B,GAU/BC,EAA0B,GAO1BC,EAAa,6BAKbC,EAAW,qEAKXC,EAAuB,wBAKvBC,EAAiC,gCAEjCC,EAAwC,uBAQzCC,OACVA,EAAA,8BAAgC,gCAChCA,EAAA,8BAAgC,iCAChCA,EAAA,QAAU,oBACVA,EAAA,iBAAmB,mBAEnBA,EAAA,yBAA2B,2BAC3BA,EAAA,gBAAkB,kBAElBA,EAAA,mBAAqB,qBACrBA,EAAA,2BAA6B,6BAC7BA,EAAA,iBAAmB,oBAXTA,OAAA,IAmBCC,EAA4B","names":["AptosApiType","DEFAULT_MAX_GAS_AMOUNT","MIN_MAX_GAS_AMOUNT","DEFAULT_TXN_EXP_SEC_FROM_NOW","DEFAULT_TXN_TIMEOUT_SEC","APTOS_COIN","APTOS_FA","RAW_TRANSACTION_SALT","RAW_TRANSACTION_WITH_DATA_SALT","ACCOUNT_ABSTRACTION_SIGNING_DATA_SALT","ProcessorType","FIREBASE_AUTH_ISS_PATTERN"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/aptosConfig.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport aptosClient from \"@aptos-labs/aptos-client\";\nimport {\n AptosSettings,\n ClientConfig,\n Client,\n FullNodeConfig,\n IndexerConfig,\n FaucetConfig,\n TransactionGenerationConfig,\n PluginConfig,\n TransactionSubmitter,\n} from \"../types\";\nimport {\n NetworkToNodeAPI,\n NetworkToFaucetAPI,\n NetworkToIndexerAPI,\n Network,\n NetworkToPepperAPI,\n NetworkToProverAPI,\n} from \"../utils/apiEndpoints\";\nimport { AptosApiType, DEFAULT_MAX_GAS_AMOUNT, DEFAULT_TXN_EXP_SEC_FROM_NOW } from \"../utils/const\";\nimport { isBun } from \"../utils/helpers\";\n\n/**\n * Represents the configuration settings for an Aptos SDK client instance.\n * This class allows customization of various endpoints and client settings.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * async function runExample() {\n * // Create a configuration for connecting to the Aptos testnet\n * const config = new AptosConfig({ network: Network.TESTNET });\n *\n * // Initialize the Aptos client with the configuration\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client initialized:\", aptos);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Client\n */\nexport class AptosConfig {\n /**\n * The Network that this SDK is associated with. Defaults to DEVNET\n * @group Client\n */\n readonly network: Network;\n\n /**\n * The client instance the SDK uses. Defaults to `@aptos-labs/aptos-client\n * @group Client\n */\n readonly client: Client;\n\n /**\n * The optional hardcoded fullnode URL to send requests to instead of using the network\n * @group Client\n */\n readonly fullnode?: string;\n\n /**\n * The optional hardcoded faucet URL to send requests to instead of using the network\n * @group Client\n */\n readonly faucet?: string;\n\n /**\n * The optional hardcoded pepper service URL to send requests to instead of using the network\n * @group Client\n */\n readonly pepper?: string;\n\n /**\n * The optional hardcoded prover service URL to send requests to instead of using the network\n * @group Client\n */\n readonly prover?: string;\n\n /**\n * The optional hardcoded indexer URL to send requests to instead of using the network\n * @group Client\n */\n readonly indexer?: string;\n\n /**\n * Optional client configurations\n * @group Client\n */\n readonly clientConfig?: ClientConfig;\n\n /**\n * Optional specific Fullnode configurations\n * @group Client\n */\n readonly fullnodeConfig?: FullNodeConfig;\n\n /**\n * Optional specific Indexer configurations\n * @group Client\n */\n readonly indexerConfig?: IndexerConfig;\n\n /**\n * Optional specific Faucet configurations\n * @group Client\n */\n readonly faucetConfig?: FaucetConfig;\n\n /**\n * Optional specific Transaction Generation configurations\n * @group Client\n */\n readonly transactionGenerationConfig?: TransactionGenerationConfig;\n\n /**\n * Optional plugin config to override client behavior.\n * @group Client\n */\n private pluginConfig?: PluginConfig;\n\n /**\n * Initializes an instance of the Aptos client with the specified settings.\n * This allows users to configure various aspects of the client, such as network and endpoints.\n *\n * @param settings - Optional configuration settings for the Aptos client.\n * @param settings.network - The network to connect to, defaults to `Network.DEVNET`.\n * @param settings.fullnode - The fullnode endpoint to use for requests.\n * @param settings.faucet - The faucet endpoint for obtaining test tokens.\n * @param settings.pepper - The pepper used for transaction signing.\n * @param settings.prover - The prover endpoint for transaction verification.\n * @param settings.indexer - The indexer endpoint for querying blockchain data.\n * @param settings.client - Custom client settings, defaults to a standard Aptos client.\n * @param settings.clientConfig - Additional configuration for the client.\n * @param settings.fullnodeConfig - Additional configuration for the fullnode.\n * @param settings.indexerConfig - Additional configuration for the indexer.\n * @param settings.faucetConfig - Additional configuration for the faucet.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * async function runExample() {\n * // Create a new Aptos client with default settings\n * const config = new AptosConfig({ network: Network.TESTNET }); // Specify the network\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client initialized:\", aptos);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Client\n */\n constructor(settings?: AptosSettings) {\n // If there are any endpoint overrides, they are custom networks, keep that in mind\n if (settings?.fullnode || settings?.indexer || settings?.faucet || settings?.pepper || settings?.prover) {\n if (settings?.network === Network.CUSTOM) {\n // eslint-disable-next-line no-console\n console.info(\"Note: using CUSTOM network will require queries to lookup ChainId\");\n } else if (!settings?.network) {\n throw new Error(\"Custom endpoints require a network to be specified\");\n }\n }\n\n // Warn Bun users about HTTP/2 compatibility issues.\n // Bun's HTTP/2 support is not fully mature yet, so we recommend disabling it.\n if (isBun() && settings?.clientConfig?.http2 !== false) {\n // eslint-disable-next-line no-console\n console.warn(\n \"[Aptos SDK] Bun does not fully support HTTP/2, which is enabled by default in this SDK. \" +\n \"It is recommended to disable HTTP/2 by setting `clientConfig: { http2: false }` in your AptosConfig. \" +\n \"For example: new AptosConfig({ network: Network.TESTNET, clientConfig: { http2: false } })\",\n );\n }\n\n this.network = settings?.network ?? Network.DEVNET;\n this.fullnode = settings?.fullnode;\n this.faucet = settings?.faucet;\n this.pepper = settings?.pepper;\n this.prover = settings?.prover;\n this.indexer = settings?.indexer;\n this.client = settings?.client ?? { provider: aptosClient };\n this.clientConfig = settings?.clientConfig ?? {};\n this.fullnodeConfig = settings?.fullnodeConfig ?? {};\n this.indexerConfig = settings?.indexerConfig ?? {};\n this.faucetConfig = settings?.faucetConfig ?? {};\n this.transactionGenerationConfig = settings?.transactionGenerationConfig ?? {};\n this.pluginConfig = settings?.pluginSettings\n ? {\n ...settings.pluginSettings,\n IGNORE_TRANSACTION_SUBMITTER: false,\n }\n : undefined;\n }\n\n /**\n * Returns the URL endpoint to send the request to based on the specified API type.\n * If a custom URL was provided in the configuration, that URL is returned. Otherwise, the URL endpoint is derived from the network.\n *\n * @param apiType - The type of Aptos API to get the URL for. This can be one of the following: FULLNODE, FAUCET, INDEXER, PEPPER, PROVER.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network, AptosApiType } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Getting the request URL for the FULLNODE API\n * const url = config.getRequestUrl(AptosApiType.FULLNODE);\n * console.log(\"Request URL for FULLNODE:\", url);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Client\n */\n getRequestUrl(apiType: AptosApiType): string {\n switch (apiType) {\n case AptosApiType.FULLNODE:\n if (this.fullnode !== undefined) return this.fullnode;\n if (this.network === Network.CUSTOM) throw new Error(\"Please provide a custom full node url\");\n return NetworkToNodeAPI[this.network];\n case AptosApiType.FAUCET:\n if (this.faucet !== undefined) return this.faucet;\n if (this.network === Network.TESTNET) {\n throw new Error(\n \"There is no way to programmatically mint testnet APT, you must use the minting site at https://aptos.dev/network/faucet\",\n );\n }\n if (this.network === Network.MAINNET) {\n throw new Error(\"There is no mainnet faucet\");\n }\n if (this.network === Network.CUSTOM) throw new Error(\"Please provide a custom faucet url\");\n return NetworkToFaucetAPI[this.network];\n case AptosApiType.INDEXER:\n if (this.indexer !== undefined) return this.indexer;\n if (this.network === Network.CUSTOM) throw new Error(\"Please provide a custom indexer url\");\n return NetworkToIndexerAPI[this.network];\n case AptosApiType.PEPPER:\n if (this.pepper !== undefined) return this.pepper;\n if (this.network === Network.CUSTOM) throw new Error(\"Please provide a custom pepper service url\");\n return NetworkToPepperAPI[this.network];\n case AptosApiType.PROVER:\n if (this.prover !== undefined) return this.prover;\n if (this.network === Network.CUSTOM) throw new Error(\"Please provide a custom prover service url\");\n return NetworkToProverAPI[this.network];\n default:\n throw Error(`apiType ${apiType} is not supported`);\n }\n }\n\n /**\n * Checks if the provided URL is a known pepper service endpoint.\n *\n * @param url - The URL to check against the known pepper service endpoints.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * const url = \"https://example.pepper.service\"; // replace with a real pepper service URL\n *\n * // Check if the URL is a known pepper service endpoint\n * const isPepperService = config.isPepperServiceRequest(url);\n *\n * console.log(`Is the URL a known pepper service? ${isPepperService}`);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Client\n */\n isPepperServiceRequest(url: string): boolean {\n return NetworkToPepperAPI[this.network] === url;\n }\n\n /**\n * Checks if the provided URL is a known prover service endpoint.\n *\n * @param url - The URL to check against known prover service endpoints.\n * @returns A boolean indicating whether the URL is a known prover service endpoint.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * // Check if the URL is a known prover service endpoint\n * const url = \"https://prover.testnet.aptos.dev\"; // replace with a real URL if needed\n * const isProver = config.isProverServiceRequest(url);\n *\n * console.log(`Is the URL a known prover service? ${isProver}`);\n * ```\n * @group Client\n */\n isProverServiceRequest(url: string): boolean {\n return NetworkToProverAPI[this.network] === url;\n }\n\n getDefaultMaxGasAmount(): number {\n return this.transactionGenerationConfig?.defaultMaxGasAmount ?? DEFAULT_MAX_GAS_AMOUNT;\n }\n\n getDefaultTxnExpirySecFromNow(): number {\n return this.transactionGenerationConfig?.defaultTxnExpirySecFromNow ?? DEFAULT_TXN_EXP_SEC_FROM_NOW;\n }\n\n /**\n * If you have set a custom transaction submitter, you can use this to determine\n * whether to use it or not. For example, to stop using the transaction submitter:\n *\n * @example\n * ```\n * aptos.config.setIgnoreTransactionSubmitter(true);\n * ```\n *\n * @group Client\n */\n setIgnoreTransactionSubmitter(ignore: boolean) {\n if (this.pluginConfig) {\n this.pluginConfig.IGNORE_TRANSACTION_SUBMITTER = ignore;\n }\n }\n\n /**\n * If a custom transaction submitter has been specified in the PluginConfig and\n * IGNORE_TRANSACTION_SUBMITTER is false, this will return a transaction submitter\n * that should be used instead of the default transaction submission behavior.\n */\n getTransactionSubmitter(): TransactionSubmitter | undefined {\n if (this.pluginConfig === undefined) {\n return undefined;\n }\n\n if (this.pluginConfig.IGNORE_TRANSACTION_SUBMITTER === true) {\n return undefined;\n }\n\n return this.pluginConfig.TRANSACTION_SUBMITTER;\n }\n}\n"],"mappings":"8JAGA,OAAOA,MAAiB,2BA4CjB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AAY,OAAW,OAAO,KAAK,QAC5C,GAAI,KAAK,UAAY,SAAgB,MAAM,IAAI,MAAM,qCAAqC,EAC1F,OAAOC,EAAoB,KAAK,OAAO,EACzC,aACE,GAAI,KAAK,SAAW,OAAW,OAAO,KAAK,OAC3C,GAAI,KAAK,UAAY,SAAgB,MAAM,IAAI,MAAM,4CAA4C,EACjG,OAAOC,EAAmB,KAAK,OAAO,EACxC,aACE,GAAI,KAAK,SAAW,OAAW,OAAO,KAAK,OAC3C,GAAI,KAAK,UAAY,SAAgB,MAAM,IAAI,MAAM,4CAA4C,EACjG,OAAOC,EAAmB,KAAK,OAAO,EACxC,QACE,MAAM,MAAM,WAAWL,CAAO,mBAAmB,CACrD,CACF,CA0BA,uBAAuBM,EAAsB,CAC3C,OAAOF,EAAmB,KAAK,OAAO,IAAME,CAC9C,CAuBA,uBAAuBA,EAAsB,CAC3C,OAAOD,EAAmB,KAAK,OAAO,IAAMC,CAC9C,CAEA,wBAAiC,CAC/B,OAAO,KAAK,6BAA6B,qBAAuB,GAClE,CAEA,+BAAwC,CACtC,OAAO,KAAK,6BAA6B,4BAA8B,EACzE,CAaA,8BAA8BC,EAAiB,CACzC,KAAK,eACP,KAAK,aAAa,6BAA+BA,EAErD,CAOA,yBAA4D,CAC1D,GAAI,KAAK,eAAiB,QAItB,KAAK,aAAa,+BAAiC,GAIvD,OAAO,KAAK,aAAa,qBAC3B,CACF","names":["aptosClient","AptosConfig","settings","isBun","aptosClient","apiType","NetworkToNodeAPI","NetworkToFaucetAPI","NetworkToIndexerAPI","NetworkToPepperAPI","NetworkToProverAPI","url","ignore"]}
|