@aptos-labs/ts-sdk 1.36.0-zeta.0 → 1.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/{accountAddress-C685VEzA.d.ts → accountAddress-DZH9Wn5l.d.ts} +28 -1
- package/dist/common/chunk-MVCKMP5U.js +4 -0
- package/dist/common/{chunk-5GUWOXQG.js.map → chunk-MVCKMP5U.js.map} +1 -1
- package/dist/common/cli/index.d.ts +1 -1
- package/dist/common/cli/index.js +1 -1
- package/dist/common/cli/index.js.map +1 -1
- package/dist/common/index.d.ts +221 -31
- package/dist/common/index.js +9 -9
- package/dist/common/index.js.map +1 -1
- package/dist/esm/{Ed25519Account-6KGApCPu.d.mts → Ed25519Account-CDURCT1q.d.mts} +56 -0
- package/dist/esm/account/AbstractKeylessAccount.d.mts +2 -2
- package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
- package/dist/esm/account/AbstractedAccount.d.mts +1 -1
- package/dist/esm/account/AbstractedAccount.mjs +1 -1
- package/dist/esm/account/Account.d.mts +3 -3
- package/dist/esm/account/Account.mjs +1 -1
- package/dist/esm/account/AccountUtils.d.mts +2 -2
- package/dist/esm/account/AccountUtils.mjs +1 -1
- package/dist/esm/account/Ed25519Account.d.mts +4 -4
- package/dist/esm/account/Ed25519Account.mjs +1 -1
- package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
- package/dist/esm/account/FederatedKeylessAccount.d.mts +2 -2
- package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
- package/dist/esm/account/KeylessAccount.d.mts +2 -2
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/MultiEd25519Account.d.mts +35 -13
- package/dist/esm/account/MultiEd25519Account.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.d.mts +6 -2
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.d.mts +4 -4
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/index.d.mts +2 -2
- 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.d.mts +85 -6
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +1 -1
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +2 -2
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +1 -1
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/experimental.mjs +1 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +1 -1
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +2 -2
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.d.mts +2 -2
- 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.d.mts +1 -1
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.d.mts +1 -1
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.d.mts +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/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/{chunk-AIPHJFJL.mjs → chunk-3IGJ2IMB.mjs} +2 -2
- package/dist/esm/{chunk-CWL7ZA3P.mjs → chunk-5MMTP427.mjs} +2 -2
- package/dist/esm/chunk-6374Q7AG.mjs +2 -0
- package/dist/esm/{chunk-3RVAGHAA.mjs.map → chunk-6374Q7AG.mjs.map} +1 -1
- package/dist/esm/{chunk-AEGA5N2W.mjs → chunk-6J64BOS7.mjs} +2 -2
- package/dist/esm/chunk-7H44HTYE.mjs +4 -0
- package/dist/esm/chunk-7H44HTYE.mjs.map +1 -0
- package/dist/esm/{chunk-6KE4JZD6.mjs → chunk-7VEWPUCH.mjs} +2 -2
- package/dist/esm/chunk-ANTUWHYB.mjs +2 -0
- package/dist/esm/chunk-ANTUWHYB.mjs.map +1 -0
- package/dist/esm/{chunk-R6QCPXQG.mjs → chunk-B373VRCY.mjs} +2 -2
- package/dist/esm/chunk-B373VRCY.mjs.map +1 -0
- package/dist/esm/{chunk-TTY5GFMN.mjs → chunk-BSH7B2QT.mjs} +2 -2
- package/dist/esm/chunk-EYLZD4JU.mjs +4 -0
- package/dist/esm/chunk-EYLZD4JU.mjs.map +1 -0
- package/dist/esm/chunk-GPG64UZT.mjs +2 -0
- package/dist/esm/{chunk-X5YB74NB.mjs.map → chunk-GPG64UZT.mjs.map} +1 -1
- package/dist/esm/{chunk-PSZYS4RG.mjs → chunk-HRHICHDX.mjs} +2 -2
- package/dist/esm/{chunk-XLDMPCLF.mjs → chunk-JG4T5BDZ.mjs} +2 -2
- package/dist/esm/{chunk-35CO4BP4.mjs → chunk-LBA4CTUV.mjs} +2 -2
- package/dist/esm/{chunk-RXMLONF7.mjs → chunk-NZXPT44W.mjs} +2 -2
- package/dist/esm/{chunk-KXVD52Y6.mjs → chunk-POELQOLD.mjs} +2 -2
- package/dist/esm/chunk-PR72YXRK.mjs +2 -0
- package/dist/esm/chunk-PR72YXRK.mjs.map +1 -0
- package/dist/esm/{chunk-3EUHEZND.mjs → chunk-PXG3WJIU.mjs} +2 -2
- package/dist/esm/{chunk-TBY3VMMV.mjs → chunk-TTFYJM6A.mjs} +2 -2
- package/dist/esm/{chunk-EODSU3YN.mjs → chunk-VNUNIQAY.mjs} +2 -2
- package/dist/esm/{chunk-WB26DWOY.mjs → chunk-YHJHXLYS.mjs} +2 -2
- package/dist/esm/{chunk-7YTGBTWH.mjs → chunk-YHKWV7NV.mjs} +2 -2
- package/dist/esm/cli/index.mjs +1 -1
- package/dist/esm/cli/localNode.mjs +1 -1
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.d.mts +5 -1
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.d.mts +1 -1
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.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.d.mts +18 -0
- 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/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.mjs +1 -1
- package/dist/esm/core/crypto/federatedKeyless.d.mts +2 -2
- package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
- package/dist/esm/core/crypto/index.d.mts +1 -1
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/keyless.d.mts +1 -1
- package/dist/esm/core/crypto/keyless.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.d.mts +2 -2
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.d.mts +4 -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/signature.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.d.mts +4 -1
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/index.d.mts +1 -1
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/errors/index.mjs +1 -1
- package/dist/esm/{federatedKeyless-Qe_j8OqV.d.mts → federatedKeyless-J5bdbbLQ.d.mts} +20 -20
- package/dist/esm/index.d.mts +5 -5
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/abstraction.mjs +1 -1
- package/dist/esm/internal/account.d.mts +49 -6
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +1 -1
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +1 -1
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.mjs +1 -1
- package/dist/esm/internal/experimental.mjs +1 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +1 -1
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.d.mts +2 -2
- 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.d.mts +1 -1
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/utils/index.d.mts +1 -1
- package/dist/esm/internal/utils/index.mjs +1 -1
- package/dist/esm/internal/utils/utils.d.mts +2 -19
- 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/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.d.mts +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.d.mts +1 -1
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.d.mts +1 -1
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/scriptComposer/index.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/types/index.d.mts +1 -1
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/types/types.d.mts +10 -1
- package/dist/esm/types/types.mjs +1 -1
- package/dist/esm/utils/helpers.d.mts +27 -1
- package/dist/esm/utils/helpers.mjs +1 -1
- package/dist/esm/utils/index.d.mts +3 -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 +7 -1
- package/src/account/Account.ts +20 -0
- package/src/account/Ed25519Account.ts +26 -1
- package/src/account/MultiEd25519Account.ts +28 -1
- package/src/account/MultiKeyAccount.ts +2 -0
- package/src/account/SingleKeyAccount.ts +35 -1
- package/src/api/account.ts +84 -4
- package/src/client/get.ts +45 -18
- package/src/core/accountAddress.ts +25 -0
- package/src/core/crypto/federatedKeyless.ts +8 -2
- package/src/core/crypto/keyless.ts +93 -60
- package/src/core/crypto/multiEd25519.ts +2 -2
- package/src/core/crypto/multiKey.ts +24 -13
- package/src/core/crypto/singleKey.ts +12 -2
- package/src/internal/account.ts +84 -7
- package/src/internal/utils/utils.ts +2 -32
- package/src/types/types.ts +10 -0
- package/src/utils/helpers.ts +50 -0
- package/src/version.ts +1 -1
- package/dist/common/chunk-5GUWOXQG.js +0 -4
- package/dist/esm/chunk-3RVAGHAA.mjs +0 -2
- package/dist/esm/chunk-LQOSHBB7.mjs +0 -4
- package/dist/esm/chunk-LQOSHBB7.mjs.map +0 -1
- package/dist/esm/chunk-NFPNWY6Z.mjs +0 -4
- package/dist/esm/chunk-NFPNWY6Z.mjs.map +0 -1
- package/dist/esm/chunk-R6QCPXQG.mjs.map +0 -1
- package/dist/esm/chunk-TNWABITK.mjs +0 -2
- package/dist/esm/chunk-TNWABITK.mjs.map +0 -1
- package/dist/esm/chunk-X5YB74NB.mjs +0 -2
- package/dist/esm/chunk-ZELTLAUN.mjs +0 -2
- package/dist/esm/chunk-ZELTLAUN.mjs.map +0 -1
- /package/dist/esm/{chunk-AIPHJFJL.mjs.map → chunk-3IGJ2IMB.mjs.map} +0 -0
- /package/dist/esm/{chunk-CWL7ZA3P.mjs.map → chunk-5MMTP427.mjs.map} +0 -0
- /package/dist/esm/{chunk-AEGA5N2W.mjs.map → chunk-6J64BOS7.mjs.map} +0 -0
- /package/dist/esm/{chunk-6KE4JZD6.mjs.map → chunk-7VEWPUCH.mjs.map} +0 -0
- /package/dist/esm/{chunk-TTY5GFMN.mjs.map → chunk-BSH7B2QT.mjs.map} +0 -0
- /package/dist/esm/{chunk-PSZYS4RG.mjs.map → chunk-HRHICHDX.mjs.map} +0 -0
- /package/dist/esm/{chunk-XLDMPCLF.mjs.map → chunk-JG4T5BDZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-35CO4BP4.mjs.map → chunk-LBA4CTUV.mjs.map} +0 -0
- /package/dist/esm/{chunk-RXMLONF7.mjs.map → chunk-NZXPT44W.mjs.map} +0 -0
- /package/dist/esm/{chunk-KXVD52Y6.mjs.map → chunk-POELQOLD.mjs.map} +0 -0
- /package/dist/esm/{chunk-3EUHEZND.mjs.map → chunk-PXG3WJIU.mjs.map} +0 -0
- /package/dist/esm/{chunk-TBY3VMMV.mjs.map → chunk-TTFYJM6A.mjs.map} +0 -0
- /package/dist/esm/{chunk-EODSU3YN.mjs.map → chunk-VNUNIQAY.mjs.map} +0 -0
- /package/dist/esm/{chunk-WB26DWOY.mjs.map → chunk-YHJHXLYS.mjs.map} +0 -0
- /package/dist/esm/{chunk-7YTGBTWH.mjs.map → chunk-YHKWV7NV.mjs.map} +0 -0
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
verifyKeylessSignatureWithJwkAndConfig,
|
|
16
16
|
} from "./keyless";
|
|
17
17
|
import { AptosConfig } from "../../api";
|
|
18
|
+
import { Signature } from "..";
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Represents the FederatedKeylessPublicKey public key
|
|
@@ -76,11 +77,16 @@ export class FederatedKeylessPublicKey extends AccountPublicKey {
|
|
|
76
77
|
*/
|
|
77
78
|
verifySignature(args: {
|
|
78
79
|
message: HexInput;
|
|
79
|
-
signature:
|
|
80
|
+
signature: Signature;
|
|
80
81
|
jwk: MoveJWK;
|
|
81
82
|
keylessConfig: KeylessConfiguration;
|
|
82
83
|
}): boolean {
|
|
83
|
-
|
|
84
|
+
try {
|
|
85
|
+
verifyKeylessSignatureWithJwkAndConfig({ ...args, publicKey: this });
|
|
86
|
+
return true;
|
|
87
|
+
} catch (error) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
84
90
|
}
|
|
85
91
|
|
|
86
92
|
serialize(serializer: Serializer): void {
|
|
@@ -171,29 +171,19 @@ export class KeylessPublicKey extends AccountPublicKey {
|
|
|
171
171
|
*/
|
|
172
172
|
verifySignature(args: {
|
|
173
173
|
message: HexInput;
|
|
174
|
-
signature:
|
|
174
|
+
signature: Signature;
|
|
175
175
|
jwk: MoveJWK;
|
|
176
176
|
keylessConfig: KeylessConfiguration;
|
|
177
177
|
}): boolean {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
* @param serializer.expHorizonSecs - The expiration horizon in seconds.
|
|
188
|
-
* @param serializer.extraField - An optional additional field for serialization.
|
|
189
|
-
* @param serializer.overrideAudVal - An optional override value for auditing.
|
|
190
|
-
* @param serializer.trainingWheelsSignature - An optional signature for training wheels.
|
|
191
|
-
* @group Implementation
|
|
192
|
-
* @category Serialization
|
|
193
|
-
*/
|
|
194
|
-
serialize(serializer: Serializer): void {
|
|
195
|
-
serializer.serializeStr(this.iss);
|
|
196
|
-
serializer.serializeBytes(this.idCommitment);
|
|
178
|
+
try {
|
|
179
|
+
verifyKeylessSignatureWithJwkAndConfig({ ...args, publicKey: this });
|
|
180
|
+
return true;
|
|
181
|
+
} catch (error) {
|
|
182
|
+
if (error instanceof KeylessError) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
197
187
|
}
|
|
198
188
|
|
|
199
189
|
/**
|
|
@@ -209,7 +199,7 @@ export class KeylessPublicKey extends AccountPublicKey {
|
|
|
209
199
|
async verifySignatureAsync(args: {
|
|
210
200
|
aptosConfig: AptosConfig;
|
|
211
201
|
message: HexInput;
|
|
212
|
-
signature:
|
|
202
|
+
signature: Signature;
|
|
213
203
|
options?: { throwErrorWithReason?: boolean };
|
|
214
204
|
}): Promise<boolean> {
|
|
215
205
|
return verifyKeylessSignature({
|
|
@@ -218,6 +208,24 @@ export class KeylessPublicKey extends AccountPublicKey {
|
|
|
218
208
|
});
|
|
219
209
|
}
|
|
220
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Serializes the current instance into a format suitable for transmission or storage.
|
|
213
|
+
* This function ensures that all relevant fields are properly serialized, including the proof and optional fields.
|
|
214
|
+
*
|
|
215
|
+
* @param serializer - The serializer instance used to perform the serialization.
|
|
216
|
+
* @param serializer.proof - The proof to be serialized.
|
|
217
|
+
* @param serializer.expHorizonSecs - The expiration horizon in seconds.
|
|
218
|
+
* @param serializer.extraField - An optional additional field for serialization.
|
|
219
|
+
* @param serializer.overrideAudVal - An optional override value for auditing.
|
|
220
|
+
* @param serializer.trainingWheelsSignature - An optional signature for training wheels.
|
|
221
|
+
* @group Implementation
|
|
222
|
+
* @category Serialization
|
|
223
|
+
*/
|
|
224
|
+
serialize(serializer: Serializer): void {
|
|
225
|
+
serializer.serializeStr(this.iss);
|
|
226
|
+
serializer.serializeBytes(this.idCommitment);
|
|
227
|
+
}
|
|
228
|
+
|
|
221
229
|
/**
|
|
222
230
|
* Deserializes a ZeroKnowledgeSig object from the provided deserializer.
|
|
223
231
|
* This function allows you to reconstruct a ZeroKnowledgeSig instance from its serialized form.
|
|
@@ -332,7 +340,7 @@ export async function verifyKeylessSignature(args: {
|
|
|
332
340
|
publicKey: KeylessPublicKey | FederatedKeylessPublicKey;
|
|
333
341
|
aptosConfig: AptosConfig;
|
|
334
342
|
message: HexInput;
|
|
335
|
-
signature:
|
|
343
|
+
signature: Signature;
|
|
336
344
|
keylessConfig?: KeylessConfiguration;
|
|
337
345
|
jwk?: MoveJWK;
|
|
338
346
|
options?: { throwErrorWithReason?: boolean };
|
|
@@ -342,12 +350,24 @@ export async function verifyKeylessSignature(args: {
|
|
|
342
350
|
publicKey,
|
|
343
351
|
message,
|
|
344
352
|
signature,
|
|
345
|
-
jwk
|
|
353
|
+
jwk,
|
|
346
354
|
keylessConfig = await getKeylessConfig({ aptosConfig }),
|
|
347
355
|
options,
|
|
348
356
|
} = args;
|
|
349
357
|
try {
|
|
350
|
-
|
|
358
|
+
if (!(signature instanceof KeylessSignature)) {
|
|
359
|
+
throw KeylessError.fromErrorType({
|
|
360
|
+
type: KeylessErrorType.SIGNATURE_TYPE_INVALID,
|
|
361
|
+
details: "Not a keyless signature",
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
verifyKeylessSignatureWithJwkAndConfig({
|
|
365
|
+
message,
|
|
366
|
+
publicKey,
|
|
367
|
+
signature,
|
|
368
|
+
jwk: jwk ? jwk : await fetchJWK({ aptosConfig, publicKey, kid: signature.getJwkKid() }),
|
|
369
|
+
keylessConfig,
|
|
370
|
+
});
|
|
351
371
|
return true;
|
|
352
372
|
} catch (error) {
|
|
353
373
|
if (options?.throwErrorWithReason) {
|
|
@@ -371,12 +391,18 @@ export async function verifyKeylessSignature(args: {
|
|
|
371
391
|
export function verifyKeylessSignatureWithJwkAndConfig(args: {
|
|
372
392
|
publicKey: KeylessPublicKey | FederatedKeylessPublicKey;
|
|
373
393
|
message: HexInput;
|
|
374
|
-
signature:
|
|
394
|
+
signature: Signature;
|
|
375
395
|
keylessConfig: KeylessConfiguration;
|
|
376
396
|
jwk: MoveJWK;
|
|
377
|
-
}):
|
|
397
|
+
}): void {
|
|
378
398
|
const { publicKey, message, signature, keylessConfig, jwk } = args;
|
|
379
399
|
const { verificationKey, maxExpHorizonSecs, trainingWheelsPubkey } = keylessConfig;
|
|
400
|
+
if (!(signature instanceof KeylessSignature)) {
|
|
401
|
+
throw KeylessError.fromErrorType({
|
|
402
|
+
type: KeylessErrorType.SIGNATURE_TYPE_INVALID,
|
|
403
|
+
details: "Not a keyless signature",
|
|
404
|
+
});
|
|
405
|
+
}
|
|
380
406
|
if (!(signature.ephemeralCertificate.signature instanceof ZeroKnowledgeSig)) {
|
|
381
407
|
throw KeylessError.fromErrorType({
|
|
382
408
|
type: KeylessErrorType.SIGNATURE_TYPE_INVALID,
|
|
@@ -431,7 +457,6 @@ export function verifyKeylessSignatureWithJwkAndConfig(args: {
|
|
|
431
457
|
});
|
|
432
458
|
}
|
|
433
459
|
}
|
|
434
|
-
return true;
|
|
435
460
|
}
|
|
436
461
|
|
|
437
462
|
/**
|
|
@@ -1326,39 +1351,47 @@ export class Groth16VerificationKey {
|
|
|
1326
1351
|
verifyProof(args: { publicInputsHash: bigint; groth16Proof: Groth16Zkp }): boolean {
|
|
1327
1352
|
const { publicInputsHash, groth16Proof } = args;
|
|
1328
1353
|
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1354
|
+
try {
|
|
1355
|
+
// Get proof points
|
|
1356
|
+
const proofA = groth16Proof.a.toProjectivePoint();
|
|
1357
|
+
const proofB = groth16Proof.b.toProjectivePoint();
|
|
1358
|
+
const proofC = groth16Proof.c.toProjectivePoint();
|
|
1359
|
+
|
|
1360
|
+
// Get verification key points
|
|
1361
|
+
const vkAlpha1 = this.alphaG1.toProjectivePoint();
|
|
1362
|
+
const vkBeta2 = this.betaG2.toProjectivePoint();
|
|
1363
|
+
const vkGamma2 = this.gammaG2.toProjectivePoint();
|
|
1364
|
+
const vkDelta2 = this.deltaG2.toProjectivePoint();
|
|
1365
|
+
const vkIC = this.gammaAbcG1.map((g1) => g1.toProjectivePoint());
|
|
1366
|
+
|
|
1367
|
+
const { Fp12 } = bn254.fields;
|
|
1368
|
+
|
|
1369
|
+
// Check that the following pairing equation holds:
|
|
1370
|
+
// e(A_1, B_2) = e(\alpha_1, \beta_2) + e(\ic_0 + public_inputs_hash \ic_1, \gamma_2) + e(C_1, \delta_2)
|
|
1371
|
+
// Where A_1, B_2, C_1 are the proof points and \alpha_1, \beta_2, \gamma_2, \delta_2, \ic_0, \ic_1
|
|
1372
|
+
// are the verification key points
|
|
1373
|
+
|
|
1374
|
+
// \ic_0 + public_inputs_hash \ic_1
|
|
1375
|
+
let accum = vkIC[0].add(vkIC[1].multiply(publicInputsHash));
|
|
1376
|
+
// e(\ic_0 + public_inputs_hash \ic_1, \gamma_2)
|
|
1377
|
+
const pairingAccumGamma = bn254.pairing(accum, vkGamma2);
|
|
1378
|
+
// e(A_1, B_2)
|
|
1379
|
+
const pairingAB = bn254.pairing(proofA, proofB);
|
|
1380
|
+
// e(\alpha_1, \beta_2)
|
|
1381
|
+
const pairingAlphaBeta = bn254.pairing(vkAlpha1, vkBeta2);
|
|
1382
|
+
// e(C_1, \delta_2)
|
|
1383
|
+
const pairingCDelta = bn254.pairing(proofC, vkDelta2);
|
|
1384
|
+
// Get the result of the right hand side of the pairing equation
|
|
1385
|
+
const product = Fp12.mul(pairingAlphaBeta, Fp12.mul(pairingAccumGamma, pairingCDelta));
|
|
1386
|
+
// Check if the left hand side equals the right hand side
|
|
1387
|
+
return Fp12.eql(pairingAB, product);
|
|
1388
|
+
} catch (error) {
|
|
1389
|
+
throw KeylessError.fromErrorType({
|
|
1390
|
+
type: KeylessErrorType.PROOF_VERIFICATION_FAILED,
|
|
1391
|
+
error,
|
|
1392
|
+
details: "Error encountered when checking zero knowledge relation",
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1362
1395
|
}
|
|
1363
1396
|
|
|
1364
1397
|
/**
|
|
@@ -106,7 +106,7 @@ export class MultiEd25519PublicKey extends AbstractMultiKey {
|
|
|
106
106
|
* @group Implementation
|
|
107
107
|
* @category Serialization
|
|
108
108
|
*/
|
|
109
|
-
verifySignature(args: { message: HexInput; signature:
|
|
109
|
+
verifySignature(args: { message: HexInput; signature: Signature }): boolean {
|
|
110
110
|
const { message, signature } = args;
|
|
111
111
|
if (!(signature instanceof MultiEd25519Signature)) {
|
|
112
112
|
return false;
|
|
@@ -144,7 +144,7 @@ export class MultiEd25519PublicKey extends AbstractMultiKey {
|
|
|
144
144
|
async verifySignatureAsync(args: {
|
|
145
145
|
aptosConfig: AptosConfig;
|
|
146
146
|
message: HexInput;
|
|
147
|
-
signature:
|
|
147
|
+
signature: Signature;
|
|
148
148
|
}): Promise<boolean> {
|
|
149
149
|
return this.verifySignature(args);
|
|
150
150
|
}
|
|
@@ -2,7 +2,7 @@ import { SigningScheme as AuthenticationKeyScheme, HexInput } from "../../types"
|
|
|
2
2
|
import { Deserializer } from "../../bcs/deserializer";
|
|
3
3
|
import { Serializer } from "../../bcs/serializer";
|
|
4
4
|
import { AuthenticationKey } from "../authenticationKey";
|
|
5
|
-
import { AccountPublicKey, PublicKey,
|
|
5
|
+
import { AccountPublicKey, PublicKey, VerifySignatureAsyncArgs } from "./publicKey";
|
|
6
6
|
import { Signature } from "./signature";
|
|
7
7
|
import { AnyPublicKey, AnySignature } from "./singleKey";
|
|
8
8
|
import { AptosConfig } from "../../api";
|
|
@@ -208,21 +208,32 @@ export class MultiKey extends AbstractMultiKey {
|
|
|
208
208
|
async verifySignatureAsync(args: {
|
|
209
209
|
aptosConfig: AptosConfig;
|
|
210
210
|
message: HexInput;
|
|
211
|
-
signature:
|
|
211
|
+
signature: Signature;
|
|
212
|
+
options?: { throwErrorWithReason?: boolean };
|
|
212
213
|
}): Promise<boolean> {
|
|
213
|
-
const {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
214
|
+
const { signature } = args;
|
|
215
|
+
try {
|
|
216
|
+
if (!(signature instanceof MultiKeySignature)) {
|
|
217
|
+
throw new Error("Signature is not a MultiKeySignature");
|
|
218
|
+
}
|
|
219
|
+
if (signature.signatures.length !== this.signaturesRequired) {
|
|
220
|
+
throw new Error("The number of signatures does not match the number of required signatures");
|
|
221
|
+
}
|
|
222
|
+
const signerIndices = signature.bitMapToSignerIndices();
|
|
223
|
+
for (let i = 0; i < signature.signatures.length; i += 1) {
|
|
224
|
+
const singleSignature = signature.signatures[i];
|
|
225
|
+
const publicKey = this.publicKeys[signerIndices[i]];
|
|
226
|
+
if (!(await publicKey.verifySignatureAsync({ ...args, signature: singleSignature }))) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return true;
|
|
231
|
+
} catch (error) {
|
|
232
|
+
if (args.options?.throwErrorWithReason) {
|
|
233
|
+
throw error;
|
|
223
234
|
}
|
|
235
|
+
return false;
|
|
224
236
|
}
|
|
225
|
-
return true;
|
|
226
237
|
}
|
|
227
238
|
|
|
228
239
|
/**
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "../../types";
|
|
8
8
|
import { AuthenticationKey } from "../authenticationKey";
|
|
9
9
|
import { Ed25519PrivateKey, Ed25519PublicKey, Ed25519Signature } from "./ed25519";
|
|
10
|
-
import { AccountPublicKey, PublicKey
|
|
10
|
+
import { AccountPublicKey, PublicKey } from "./publicKey";
|
|
11
11
|
import { Secp256k1PrivateKey, Secp256k1PublicKey, Secp256k1Signature } from "./secp256k1";
|
|
12
12
|
import { KeylessPublicKey, KeylessSignature } from "./keyless";
|
|
13
13
|
import { Signature } from "./signature";
|
|
@@ -85,6 +85,9 @@ export class AnyPublicKey extends AccountPublicKey {
|
|
|
85
85
|
*/
|
|
86
86
|
verifySignature(args: { message: HexInput; signature: AnySignature }): boolean {
|
|
87
87
|
const { message, signature } = args;
|
|
88
|
+
if (this.publicKey instanceof KeylessPublicKey) {
|
|
89
|
+
throw new Error("Use verifySignatureAsync to verify Keyless signatures");
|
|
90
|
+
}
|
|
88
91
|
return this.publicKey.verifySignature({
|
|
89
92
|
message,
|
|
90
93
|
signature: signature.signature,
|
|
@@ -106,8 +109,15 @@ export class AnyPublicKey extends AccountPublicKey {
|
|
|
106
109
|
async verifySignatureAsync(args: {
|
|
107
110
|
aptosConfig: AptosConfig;
|
|
108
111
|
message: HexInput;
|
|
109
|
-
signature:
|
|
112
|
+
signature: Signature;
|
|
113
|
+
options?: { throwErrorWithReason?: boolean };
|
|
110
114
|
}): Promise<boolean> {
|
|
115
|
+
if (!(args.signature instanceof AnySignature)) {
|
|
116
|
+
if (args.options?.throwErrorWithReason) {
|
|
117
|
+
throw new Error("Signature must be an instance of AnySignature");
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
111
121
|
return await this.publicKey.verifySignatureAsync({
|
|
112
122
|
...args,
|
|
113
123
|
signature: args.signature.signature,
|
package/src/internal/account.ts
CHANGED
|
@@ -9,9 +9,15 @@
|
|
|
9
9
|
* @group Implementation
|
|
10
10
|
*/
|
|
11
11
|
import { AptosConfig } from "../api/aptosConfig";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
getAptosFullNode,
|
|
14
|
+
getPageWithObfuscatedCursor,
|
|
15
|
+
paginateWithCursor,
|
|
16
|
+
paginateWithObfuscatedCursor,
|
|
17
|
+
} from "../client";
|
|
13
18
|
import {
|
|
14
19
|
AccountData,
|
|
20
|
+
CursorPaginationArgs,
|
|
15
21
|
GetAccountCoinsDataResponse,
|
|
16
22
|
GetAccountCollectionsWithOwnedTokenResponse,
|
|
17
23
|
GetAccountOwnedTokensFromCollectionResponse,
|
|
@@ -32,7 +38,7 @@ import { AccountAddress, AccountAddressInput } from "../core/accountAddress";
|
|
|
32
38
|
import { Account, Ed25519Account, MultiEd25519Account } from "../account";
|
|
33
39
|
import { AnyPublicKey, Ed25519PublicKey, PrivateKey } from "../core/crypto";
|
|
34
40
|
import { queryIndexer } from "./general";
|
|
35
|
-
import {
|
|
41
|
+
import { getModule as getModuleUtil, getInfo as getInfoUtil } from "./utils";
|
|
36
42
|
import {
|
|
37
43
|
GetAccountCoinsCountQuery,
|
|
38
44
|
GetAccountCoinsDataQuery,
|
|
@@ -93,9 +99,50 @@ export async function getInfo(args: {
|
|
|
93
99
|
export async function getModules(args: {
|
|
94
100
|
aptosConfig: AptosConfig;
|
|
95
101
|
accountAddress: AccountAddressInput;
|
|
96
|
-
options?:
|
|
102
|
+
options?: { limit?: number } & LedgerVersionArg;
|
|
97
103
|
}): Promise<MoveModuleBytecode[]> {
|
|
98
|
-
|
|
104
|
+
const { aptosConfig, accountAddress, options } = args;
|
|
105
|
+
return paginateWithObfuscatedCursor<{}, MoveModuleBytecode[]>({
|
|
106
|
+
aptosConfig,
|
|
107
|
+
originMethod: "getModules",
|
|
108
|
+
path: `accounts/${AccountAddress.from(accountAddress).toString()}/modules`,
|
|
109
|
+
params: {
|
|
110
|
+
ledger_version: options?.ledgerVersion,
|
|
111
|
+
limit: options?.limit ?? 1000,
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Retrieves the modules associated with a specified account address.
|
|
118
|
+
*
|
|
119
|
+
* @param args - The arguments for retrieving modules.
|
|
120
|
+
* @param args.aptosConfig - The configuration for connecting to the Aptos blockchain.
|
|
121
|
+
* @param args.accountAddress - The address of the account whose modules are to be retrieved.
|
|
122
|
+
* @param args.options - Optional parameters for pagination and ledger version.
|
|
123
|
+
* @param args.options.cursor - The starting point for pagination. Note, this is obfuscated and is not an index.
|
|
124
|
+
* @param args.options.limit - The maximum number of modules to retrieve (default is 100).
|
|
125
|
+
* @param args.options.ledgerVersion - The specific ledger version to query.
|
|
126
|
+
* @group Implementation
|
|
127
|
+
*/
|
|
128
|
+
export async function getModulesPage(args: {
|
|
129
|
+
aptosConfig: AptosConfig;
|
|
130
|
+
accountAddress: AccountAddressInput;
|
|
131
|
+
options?: CursorPaginationArgs & LedgerVersionArg;
|
|
132
|
+
}): Promise<{ modules: MoveModuleBytecode[]; cursor: string | undefined }> {
|
|
133
|
+
const { aptosConfig, accountAddress, options } = args;
|
|
134
|
+
const { response, cursor } = await getPageWithObfuscatedCursor<{}, MoveModuleBytecode[]>({
|
|
135
|
+
aptosConfig,
|
|
136
|
+
originMethod: "getModulesPage",
|
|
137
|
+
path: `accounts/${AccountAddress.from(accountAddress).toString()}/modules`,
|
|
138
|
+
params: {
|
|
139
|
+
ledger_version: options?.ledgerVersion,
|
|
140
|
+
cursor: options?.cursor,
|
|
141
|
+
limit: options?.limit ?? 100,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
return { modules: response.data, cursor };
|
|
99
146
|
}
|
|
100
147
|
|
|
101
148
|
/**
|
|
@@ -153,7 +200,6 @@ export async function getTransactions(args: {
|
|
|
153
200
|
* @param args.aptosConfig - The configuration settings for Aptos.
|
|
154
201
|
* @param args.accountAddress - The address of the account to fetch resources for.
|
|
155
202
|
* @param args.options - Optional pagination and ledger version parameters.
|
|
156
|
-
* @param args.options.offset - The starting point for pagination. Note, this is obfuscated and is not an index.
|
|
157
203
|
* @param args.options.limit - The maximum number of resources to retrieve (default is 999).
|
|
158
204
|
* @param args.options.ledgerVersion - The specific ledger version to query.
|
|
159
205
|
* @group Implementation
|
|
@@ -161,7 +207,7 @@ export async function getTransactions(args: {
|
|
|
161
207
|
export async function getResources(args: {
|
|
162
208
|
aptosConfig: AptosConfig;
|
|
163
209
|
accountAddress: AccountAddressInput;
|
|
164
|
-
options?:
|
|
210
|
+
options?: { limit?: number } & LedgerVersionArg;
|
|
165
211
|
}): Promise<MoveResource[]> {
|
|
166
212
|
const { aptosConfig, accountAddress, options } = args;
|
|
167
213
|
return paginateWithObfuscatedCursor<{}, MoveResource[]>({
|
|
@@ -170,12 +216,43 @@ export async function getResources(args: {
|
|
|
170
216
|
path: `accounts/${AccountAddress.from(accountAddress).toString()}/resources`,
|
|
171
217
|
params: {
|
|
172
218
|
ledger_version: options?.ledgerVersion,
|
|
173
|
-
offset: options?.offset,
|
|
174
219
|
limit: options?.limit ?? 999,
|
|
175
220
|
},
|
|
176
221
|
});
|
|
177
222
|
}
|
|
178
223
|
|
|
224
|
+
/**
|
|
225
|
+
* Retrieves a page of resources associated with a specific account address.
|
|
226
|
+
*
|
|
227
|
+
* @param args - The arguments for retrieving resources.
|
|
228
|
+
* @param args.aptosConfig - The configuration settings for Aptos.
|
|
229
|
+
* @param args.accountAddress - The address of the account to fetch resources for.
|
|
230
|
+
* @param args.options - Optional pagination and ledger version parameters.
|
|
231
|
+
* @param args.options.cursor - The starting point for pagination. Note, this is obfuscated and is not an index.
|
|
232
|
+
* @param args.options.limit - The maximum number of resources to retrieve (default is 100).
|
|
233
|
+
* @param args.options.ledgerVersion - The specific ledger version to query.
|
|
234
|
+
* @group Implementation
|
|
235
|
+
*/
|
|
236
|
+
export async function getResourcesPage(args: {
|
|
237
|
+
aptosConfig: AptosConfig;
|
|
238
|
+
accountAddress: AccountAddressInput;
|
|
239
|
+
options?: CursorPaginationArgs & LedgerVersionArg;
|
|
240
|
+
}): Promise<{ resources: MoveResource[]; cursor: string | undefined }> {
|
|
241
|
+
const { aptosConfig, accountAddress, options } = args;
|
|
242
|
+
const { response, cursor } = await getPageWithObfuscatedCursor<{}, MoveResource[]>({
|
|
243
|
+
aptosConfig,
|
|
244
|
+
originMethod: "getResourcesPage",
|
|
245
|
+
path: `accounts/${AccountAddress.from(accountAddress).toString()}/resources`,
|
|
246
|
+
params: {
|
|
247
|
+
ledger_version: options?.ledgerVersion,
|
|
248
|
+
cursor: options?.cursor,
|
|
249
|
+
limit: options?.limit ?? 100,
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
return { resources: response.data, cursor };
|
|
254
|
+
}
|
|
255
|
+
|
|
179
256
|
/**
|
|
180
257
|
* Retrieves a specific resource of a given type for the specified account address.
|
|
181
258
|
*
|
|
@@ -1,39 +1,9 @@
|
|
|
1
1
|
import { AccountAddress, AccountAddressInput } from "../../core/accountAddress";
|
|
2
|
-
import { MoveModuleBytecode, LedgerVersionArg,
|
|
2
|
+
import { MoveModuleBytecode, LedgerVersionArg, AccountData } from "../../types/types";
|
|
3
3
|
import { AptosConfig } from "../../api/aptosConfig";
|
|
4
|
-
import { getAptosFullNode
|
|
4
|
+
import { getAptosFullNode } from "../../client";
|
|
5
5
|
import { memoizeAsync } from "../../utils/memoize";
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Retrieves the modules associated with a specified account address.
|
|
9
|
-
*
|
|
10
|
-
* @param args - The arguments for retrieving modules.
|
|
11
|
-
* @param args.aptosConfig - The configuration for connecting to the Aptos blockchain.
|
|
12
|
-
* @param args.accountAddress - The address of the account whose modules are to be retrieved.
|
|
13
|
-
* @param args.options - Optional parameters for pagination and ledger version.
|
|
14
|
-
* @param args.options.limit - The maximum number of modules to retrieve (default is 1000).
|
|
15
|
-
* @param args.options.offset - The starting point for pagination. Note, this is obfuscated and is not an index.
|
|
16
|
-
* @param args.options.ledgerVersion - The specific ledger version to query.
|
|
17
|
-
* @group Implementation
|
|
18
|
-
*/
|
|
19
|
-
export async function getModules(args: {
|
|
20
|
-
aptosConfig: AptosConfig;
|
|
21
|
-
accountAddress: AccountAddressInput;
|
|
22
|
-
options?: PaginationArgs & LedgerVersionArg;
|
|
23
|
-
}): Promise<MoveModuleBytecode[]> {
|
|
24
|
-
const { aptosConfig, accountAddress, options } = args;
|
|
25
|
-
return paginateWithObfuscatedCursor<{}, MoveModuleBytecode[]>({
|
|
26
|
-
aptosConfig,
|
|
27
|
-
originMethod: "getModules",
|
|
28
|
-
path: `accounts/${AccountAddress.from(accountAddress).toString()}/modules`,
|
|
29
|
-
params: {
|
|
30
|
-
ledger_version: options?.ledgerVersion,
|
|
31
|
-
offset: options?.offset,
|
|
32
|
-
limit: options?.limit ?? 1000,
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
7
|
/**
|
|
38
8
|
* Retrieves account information for a specified account address.
|
|
39
9
|
*
|
package/src/types/types.ts
CHANGED
|
@@ -237,6 +237,16 @@ export interface PaginationArgs {
|
|
|
237
237
|
limit?: number;
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Defines the parameters for paginating query results, including the starting position and maximum number of items to return.
|
|
242
|
+
* @param cursor Specifies the starting position of the query result. Default is at the beginning if undefined. This is not a number and must come from the API.
|
|
243
|
+
* @param limit Specifies the maximum number of items to return. Default is 25.
|
|
244
|
+
*/
|
|
245
|
+
export interface CursorPaginationArgs {
|
|
246
|
+
cursor?: string;
|
|
247
|
+
limit?: number;
|
|
248
|
+
}
|
|
249
|
+
|
|
240
250
|
/**
|
|
241
251
|
* Represents the arguments for specifying a token standard.
|
|
242
252
|
*
|
package/src/utils/helpers.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { decode } from "js-base64";
|
|
5
5
|
import { MoveFunctionId, MoveStructId } from "../types";
|
|
6
6
|
import { AccountAddress } from "../core/accountAddress";
|
|
7
|
+
import { createObjectAddress } from "../core/account/utils/address";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Sleep for the specified amount of time in milliseconds.
|
|
@@ -235,3 +236,52 @@ export function isValidFunctionInfo(functionInfo: string): boolean {
|
|
|
235
236
|
export function truncateAddress(address: string, start: number = 6, end: number = 5) {
|
|
236
237
|
return `${address.slice(0, start)}...${address.slice(-end)}`;
|
|
237
238
|
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Constants for metadata address calculation
|
|
242
|
+
*/
|
|
243
|
+
const APTOS_COIN_TYPE_STR = "0x1::aptos_coin::AptosCoin";
|
|
244
|
+
const APT_METADATA_ADDRESS_HEX = AccountAddress.A.toStringLong();
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Helper function to standardize Move type string by converting all addresses to short form,
|
|
248
|
+
* including addresses within nested type parameters
|
|
249
|
+
*/
|
|
250
|
+
function standardizeMoveTypeString(input: string): string {
|
|
251
|
+
// Regular expression to match addresses in the type string, including those within type parameters
|
|
252
|
+
// This regex matches "0x" followed by hex digits, handling both standalone addresses and those within <>
|
|
253
|
+
const addressRegex = /0x[0-9a-fA-F]+/g;
|
|
254
|
+
|
|
255
|
+
return input.replace(addressRegex, (match) => {
|
|
256
|
+
// Use AccountAddress to handle the address
|
|
257
|
+
return AccountAddress.from(match, { maxMissingChars: 63 }).toStringShort();
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Calculates the paired FA metadata address for a given coin type.
|
|
263
|
+
* This function is tolerant of various address formats in the coin type string,
|
|
264
|
+
* including complex nested types.
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* // All these formats are valid and will produce the same result:
|
|
268
|
+
* pairedFaMetadataAddress("0x1::aptos_coin::AptosCoin") // simple form
|
|
269
|
+
* pairedFaMetadataAddress("0x0000000000000000000000000000000000000000000000000000000000000001::aptos_coin::AptosCoin") // long form
|
|
270
|
+
* pairedFaMetadataAddress("0x00001::aptos_coin::AptosCoin") // with leading zeros
|
|
271
|
+
* pairedFaMetadataAddress("0x1::coin::Coin<0x1412::a::struct<0x0001::aptos_coin::AptosCoin>>") // nested type parameters
|
|
272
|
+
*
|
|
273
|
+
* @param coinType - The coin type string in any of these formats:
|
|
274
|
+
* - Short form address: "0x1::aptos_coin::AptosCoin"
|
|
275
|
+
* - Long form address: "0x0000000000000000000000000000000000000000000000000000000000000001::aptos_coin::AptosCoin"
|
|
276
|
+
* - With leading zeros: "0x00001::aptos_coin::AptosCoin"
|
|
277
|
+
* - With nested types: "0x1::coin::Coin<0x1412::a::struct<0x0001::aptos_coin::AptosCoin>>"
|
|
278
|
+
* @returns The calculated metadata address as an AccountAddress instance
|
|
279
|
+
*/
|
|
280
|
+
export function pairedFaMetadataAddress(coinType: `0x${string}::${string}::${string}`): AccountAddress {
|
|
281
|
+
// Standardize the coin type string to handle any address format
|
|
282
|
+
const standardizedMoveTypeName = standardizeMoveTypeString(coinType);
|
|
283
|
+
|
|
284
|
+
return standardizedMoveTypeName === APTOS_COIN_TYPE_STR
|
|
285
|
+
? AccountAddress.A
|
|
286
|
+
: createObjectAddress(AccountAddress.A, standardizedMoveTypeName);
|
|
287
|
+
}
|
package/src/version.ts
CHANGED