@aptos-labs/ts-sdk 7.3.0 → 7.5.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/LICENSE +43 -43
- package/README.md +19 -20
- package/dist/api/account/abstraction.d.ts +10 -0
- package/dist/api/account/abstraction.d.ts.map +1 -1
- package/dist/api/account/abstraction.js +19 -6
- package/dist/api/account/abstraction.js.map +1 -1
- package/dist/api/ans.d.ts +9 -0
- package/dist/api/ans.d.ts.map +1 -1
- package/dist/api/ans.js +5 -0
- package/dist/api/ans.js.map +1 -1
- package/dist/api/coin.d.ts +2 -0
- package/dist/api/coin.d.ts.map +1 -1
- package/dist/api/coin.js +1 -0
- package/dist/api/coin.js.map +1 -1
- package/dist/api/digitalAsset.d.ts +30 -0
- package/dist/api/digitalAsset.d.ts.map +1 -1
- package/dist/api/digitalAsset.js +15 -0
- package/dist/api/digitalAsset.js.map +1 -1
- package/dist/api/fungibleAsset.d.ts +4 -0
- package/dist/api/fungibleAsset.d.ts.map +1 -1
- package/dist/api/fungibleAsset.js +2 -0
- package/dist/api/fungibleAsset.js.map +1 -1
- package/dist/api/keyless.d.ts +38 -1
- package/dist/api/keyless.d.ts.map +1 -1
- package/dist/api/keyless.js +29 -1
- package/dist/api/keyless.js.map +1 -1
- package/dist/api/transaction.d.ts +41 -1
- package/dist/api/transaction.d.ts.map +1 -1
- package/dist/api/transaction.js +42 -2
- package/dist/api/transaction.js.map +1 -1
- package/dist/api/transactionSubmission/build.d.ts +7 -5
- package/dist/api/transactionSubmission/build.d.ts.map +1 -1
- package/dist/api/transactionSubmission/build.js +13 -5
- package/dist/api/transactionSubmission/build.js.map +1 -1
- package/dist/api/transactionSubmission/simulate.d.ts +7 -3
- package/dist/api/transactionSubmission/simulate.d.ts.map +1 -1
- package/dist/api/transactionSubmission/simulate.js +7 -3
- package/dist/api/transactionSubmission/simulate.js.map +1 -1
- package/dist/bcs/serializable/moveStructs.d.ts +72 -28
- package/dist/bcs/serializable/moveStructs.d.ts.map +1 -1
- package/dist/bcs/serializable/moveStructs.js +76 -28
- package/dist/bcs/serializable/moveStructs.js.map +1 -1
- package/dist/functions/keyless.d.ts +1 -1
- package/dist/functions/keyless.d.ts.map +1 -1
- package/dist/functions/keyless.js +1 -1
- package/dist/functions/keyless.js.map +1 -1
- package/dist/functions/transaction.d.ts +1 -1
- package/dist/functions/transaction.d.ts.map +1 -1
- package/dist/functions/transaction.js +1 -1
- package/dist/functions/transaction.js.map +1 -1
- package/dist/internal/abstraction.d.ts +35 -0
- package/dist/internal/abstraction.d.ts.map +1 -1
- package/dist/internal/abstraction.js +38 -3
- package/dist/internal/abstraction.js.map +1 -1
- package/dist/internal/account.d.ts +6 -0
- package/dist/internal/account.d.ts.map +1 -1
- package/dist/internal/account.js +55 -37
- package/dist/internal/account.js.map +1 -1
- package/dist/internal/ans.d.ts +11 -0
- package/dist/internal/ans.d.ts.map +1 -1
- package/dist/internal/ans.js +19 -7
- package/dist/internal/ans.js.map +1 -1
- package/dist/internal/coin.d.ts +2 -0
- package/dist/internal/coin.d.ts.map +1 -1
- package/dist/internal/coin.js +3 -1
- package/dist/internal/coin.js.map +1 -1
- package/dist/internal/digitalAsset.d.ts +30 -0
- package/dist/internal/digitalAsset.d.ts.map +1 -1
- package/dist/internal/digitalAsset.js +45 -15
- package/dist/internal/digitalAsset.js.map +1 -1
- package/dist/internal/fungibleAsset.d.ts +4 -0
- package/dist/internal/fungibleAsset.d.ts.map +1 -1
- package/dist/internal/fungibleAsset.js +6 -2
- package/dist/internal/fungibleAsset.js.map +1 -1
- package/dist/internal/keyless.d.ts +39 -1
- package/dist/internal/keyless.d.ts.map +1 -1
- package/dist/internal/keyless.js +71 -13
- package/dist/internal/keyless.js.map +1 -1
- package/dist/internal/transaction.d.ts +24 -1
- package/dist/internal/transaction.d.ts.map +1 -1
- package/dist/internal/transaction.js +125 -4
- package/dist/internal/transaction.js.map +1 -1
- package/dist/internal/transactionSubmission.d.ts +2 -0
- package/dist/internal/transactionSubmission.d.ts.map +1 -1
- package/dist/internal/transactionSubmission.js +3 -1
- package/dist/internal/transactionSubmission.js.map +1 -1
- package/dist/transactions/management/transactionWorker.d.ts +10 -6
- package/dist/transactions/management/transactionWorker.d.ts.map +1 -1
- package/dist/transactions/management/transactionWorker.js +28 -24
- package/dist/transactions/management/transactionWorker.js.map +1 -1
- package/dist/transactions/transactionBuilder/index.d.ts +1 -0
- package/dist/transactions/transactionBuilder/index.d.ts.map +1 -1
- package/dist/transactions/transactionBuilder/index.js +1 -0
- package/dist/transactions/transactionBuilder/index.js.map +1 -1
- package/dist/transactions/transactionBuilder/scriptAbi.d.ts +10 -0
- package/dist/transactions/transactionBuilder/scriptAbi.d.ts.map +1 -0
- package/dist/transactions/transactionBuilder/scriptAbi.js +863 -0
- package/dist/transactions/transactionBuilder/scriptAbi.js.map +1 -0
- package/dist/transactions/transactionBuilder/transactionBuilder.d.ts.map +1 -1
- package/dist/transactions/transactionBuilder/transactionBuilder.js +65 -1
- package/dist/transactions/transactionBuilder/transactionBuilder.js.map +1 -1
- package/dist/transactions/types.d.ts +9 -4
- package/dist/transactions/types.d.ts.map +1 -1
- package/dist/types/keyless.d.ts +2 -2
- package/dist/types/keyless.d.ts.map +1 -1
- package/dist/types/types.d.ts +2 -2
- package/dist/types/types.d.ts.map +1 -1
- package/dist/utils/const.d.ts +11 -0
- package/dist/utils/const.d.ts.map +1 -1
- package/dist/utils/const.js +11 -0
- package/dist/utils/const.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +26 -25
- package/src/api/account/abstraction.ts +23 -6
- package/src/api/ans.ts +9 -0
- package/src/api/coin.ts +2 -0
- package/src/api/digitalAsset.ts +30 -0
- package/src/api/fungibleAsset.ts +4 -0
- package/src/api/keyless.ts +39 -1
- package/src/api/transaction.ts +48 -1
- package/src/api/transactionSubmission/build.ts +16 -6
- package/src/api/transactionSubmission/simulate.ts +7 -3
- package/src/bcs/serializable/moveStructs.ts +80 -28
- package/src/functions/keyless.ts +1 -0
- package/src/functions/transaction.ts +1 -0
- package/src/internal/abstraction.ts +41 -3
- package/src/internal/account.ts +60 -38
- package/src/internal/ans.ts +25 -7
- package/src/internal/coin.ts +4 -1
- package/src/internal/digitalAsset.ts +60 -9
- package/src/internal/fungibleAsset.ts +8 -2
- package/src/internal/keyless.ts +91 -14
- package/src/internal/transaction.ts +154 -4
- package/src/internal/transactionSubmission.ts +4 -1
- package/src/transactions/management/transactionWorker.ts +35 -23
- package/src/transactions/transactionBuilder/index.ts +1 -0
- package/src/transactions/transactionBuilder/scriptAbi.ts +1145 -0
- package/src/transactions/transactionBuilder/transactionBuilder.ts +91 -6
- package/src/transactions/types.ts +10 -4
- package/src/types/keyless.ts +2 -2
- package/src/types/types.ts +2 -2
- package/src/utils/const.ts +12 -0
- package/src/version.ts +1 -1
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { sha3_256 as sha3Hash } from "@noble/hashes/sha3.js";
|
|
10
10
|
import { AptosConfig } from "../../api/aptosConfig.js";
|
|
11
|
+
import { Serialized } from "../../bcs/index.js";
|
|
11
12
|
import { MAX_U64_BIG_INT } from "../../bcs/consts.js";
|
|
12
13
|
import { AccountAddress, AccountAddressInput, Hex, PublicKey } from "../../core/index.js";
|
|
13
14
|
import {
|
|
@@ -56,6 +57,7 @@ import {
|
|
|
56
57
|
TransactionPayloadScript,
|
|
57
58
|
} from "../instances/index.js";
|
|
58
59
|
import { SignedTransaction } from "../instances/signedTransaction.js";
|
|
60
|
+
import { StructTag, TypeTag, TypeTagReference, TypeTagStruct, TypeTagVector } from "../typeTag/index.js";
|
|
59
61
|
import {
|
|
60
62
|
AnyRawTransaction,
|
|
61
63
|
AnyTransactionPayloadInstance,
|
|
@@ -77,8 +79,11 @@ import {
|
|
|
77
79
|
InputViewFunctionDataWithRemoteABI,
|
|
78
80
|
InputViewFunctionDataWithABI,
|
|
79
81
|
FunctionABI,
|
|
82
|
+
ScriptFunctionArgumentTypes,
|
|
83
|
+
SimpleEntryFunctionArgumentTypes,
|
|
80
84
|
} from "../types.js";
|
|
81
85
|
import { convertArgument, fetchEntryFunctionAbi, fetchViewFunctionAbi, standardizeTypeTags } from "./remoteAbi.js";
|
|
86
|
+
import { parseScriptAbi } from "./scriptAbi.js";
|
|
82
87
|
import { memoizeAsync } from "../../utils/memoize.js";
|
|
83
88
|
import { isScriptDataInput } from "./helpers.js";
|
|
84
89
|
import { SimpleTransaction } from "../instances/simpleTransaction.js";
|
|
@@ -351,13 +356,93 @@ export function generateViewFunctionPayloadWithABI(args: InputViewFunctionDataWi
|
|
|
351
356
|
* @group Implementation
|
|
352
357
|
* @category Transactions
|
|
353
358
|
*/
|
|
354
|
-
function
|
|
359
|
+
function isScriptFunctionArgument(
|
|
360
|
+
arg: ScriptFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes | EntryFunctionArgumentTypes,
|
|
361
|
+
): arg is ScriptFunctionArgumentTypes {
|
|
362
|
+
return (
|
|
363
|
+
typeof arg === "object" &&
|
|
364
|
+
arg !== null &&
|
|
365
|
+
"serializeForScriptFunction" in arg &&
|
|
366
|
+
typeof arg.serializeForScriptFunction === "function"
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function instantiateScriptType(type: TypeTag, typeArguments: Array<TypeTag>): TypeTag {
|
|
371
|
+
if (type.isGeneric()) {
|
|
372
|
+
const resolved = typeArguments[type.value];
|
|
373
|
+
if (resolved === undefined) {
|
|
374
|
+
throw new Error(`Generic argument ${type.toString()} is invalid for script parameter`);
|
|
375
|
+
}
|
|
376
|
+
return resolved;
|
|
377
|
+
}
|
|
378
|
+
if (type.isVector()) {
|
|
379
|
+
return new TypeTagVector(instantiateScriptType(type.value, typeArguments));
|
|
380
|
+
}
|
|
381
|
+
if (type instanceof TypeTagReference) {
|
|
382
|
+
return new TypeTagReference(instantiateScriptType(type.value, typeArguments));
|
|
383
|
+
}
|
|
384
|
+
if (type instanceof TypeTagStruct) {
|
|
385
|
+
return new TypeTagStruct(
|
|
386
|
+
new StructTag(
|
|
387
|
+
type.value.address,
|
|
388
|
+
type.value.moduleName,
|
|
389
|
+
type.value.name,
|
|
390
|
+
type.value.typeArgs.map((argument) => instantiateScriptType(argument, typeArguments)),
|
|
391
|
+
),
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
return type;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
function isNativeScriptArgumentType(type: TypeTag): boolean {
|
|
398
|
+
if (type.isVector()) return type.value.isU8();
|
|
399
|
+
return type.isPrimitive() && !type.isSigner();
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
function generateTransactionPayloadScript(args: InputScriptData): TransactionPayloadScript {
|
|
403
|
+
const typeArguments = standardizeTypeTags(args.typeArguments);
|
|
404
|
+
|
|
405
|
+
if (args.functionArguments.every(isScriptFunctionArgument)) {
|
|
406
|
+
return new TransactionPayloadScript(
|
|
407
|
+
new Script(Hex.fromHexInput(args.bytecode).toUint8Array(), typeArguments, args.functionArguments),
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
const abi = parseScriptAbi(args.bytecode);
|
|
412
|
+
if (typeArguments.length !== abi.typeParameters.length) {
|
|
413
|
+
throw new Error(
|
|
414
|
+
`Type argument count mismatch, expected ${abi.typeParameters.length}, received ${typeArguments.length}`,
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
if (args.functionArguments.length !== abi.parameters.length) {
|
|
418
|
+
throw new Error(
|
|
419
|
+
`Script function argument count mismatch, expected ${abi.parameters.length}, received ${args.functionArguments.length}`,
|
|
420
|
+
);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
const parameterTypes = abi.parameters.map((parameter) => instantiateScriptType(parameter, typeArguments));
|
|
424
|
+
const instantiatedAbi = { ...abi, parameters: parameterTypes };
|
|
425
|
+
const functionArguments = args.functionArguments.map((arg, index): ScriptFunctionArgumentTypes => {
|
|
426
|
+
if (isScriptFunctionArgument(arg)) return arg;
|
|
427
|
+
let converted: EntryFunctionArgumentTypes;
|
|
428
|
+
try {
|
|
429
|
+
converted = convertArgument("script", instantiatedAbi, arg, index, typeArguments);
|
|
430
|
+
} catch (error) {
|
|
431
|
+
if (error instanceof Error && error.message.startsWith("Struct/enum arguments require async conversion.")) {
|
|
432
|
+
throw new Error(
|
|
433
|
+
`Script custom struct/enum arguments must be passed as Serialized containing the BCS-encoded bytes. ` +
|
|
434
|
+
`Type: '${parameterTypes[index].toString()}', position: ${index}`,
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
throw error;
|
|
438
|
+
}
|
|
439
|
+
return isNativeScriptArgumentType(parameterTypes[index]) && isScriptFunctionArgument(converted)
|
|
440
|
+
? converted
|
|
441
|
+
: new Serialized(converted.bcsToBytes());
|
|
442
|
+
});
|
|
443
|
+
|
|
355
444
|
return new TransactionPayloadScript(
|
|
356
|
-
new Script(
|
|
357
|
-
Hex.fromHexInput(args.bytecode).toUint8Array(),
|
|
358
|
-
standardizeTypeTags(args.typeArguments),
|
|
359
|
-
args.functionArguments,
|
|
360
|
-
),
|
|
445
|
+
new Script(Hex.fromHexInput(args.bytecode).toUint8Array(), typeArguments, functionArguments),
|
|
361
446
|
);
|
|
362
447
|
}
|
|
363
448
|
|
|
@@ -339,7 +339,7 @@ export type InputMultiSigDataWithRemoteABI = {
|
|
|
339
339
|
export type InputScriptData = {
|
|
340
340
|
bytecode: HexInput;
|
|
341
341
|
typeArguments?: Array<TypeArgument>;
|
|
342
|
-
functionArguments: Array<ScriptFunctionArgumentTypes>;
|
|
342
|
+
functionArguments: Array<ScriptFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes>;
|
|
343
343
|
};
|
|
344
344
|
|
|
345
345
|
/**
|
|
@@ -412,6 +412,11 @@ export type FunctionABI = {
|
|
|
412
412
|
parameters: Array<TypeTag>;
|
|
413
413
|
};
|
|
414
414
|
|
|
415
|
+
export type ScriptABI = FunctionABI & {
|
|
416
|
+
/** Number of leading signer parameters supplied by transaction authentication. */
|
|
417
|
+
signers: number;
|
|
418
|
+
};
|
|
419
|
+
|
|
415
420
|
/**
|
|
416
421
|
* Interface for an Entry function's ABI, enabling type checking and input conversion for ABI-based transaction submissions.
|
|
417
422
|
* @group Implementation
|
|
@@ -503,10 +508,10 @@ export type InputSimulateTransactionData = {
|
|
|
503
508
|
*/
|
|
504
509
|
transaction: AnyRawTransaction;
|
|
505
510
|
/**
|
|
506
|
-
*
|
|
511
|
+
* The primary sender's public key. Omit it to skip the sender's public/authentication-key check during
|
|
512
|
+
* simulation.
|
|
507
513
|
* @group Implementation
|
|
508
514
|
* @category Transactions
|
|
509
|
-
* This is optional and can be undefined to skip the public/auth key check during the transaction simulation.
|
|
510
515
|
*/
|
|
511
516
|
signerPublicKey?: PublicKey;
|
|
512
517
|
/**
|
|
@@ -516,7 +521,8 @@ export type InputSimulateTransactionData = {
|
|
|
516
521
|
*/
|
|
517
522
|
secondarySignersPublicKeys?: Array<PublicKey | undefined>;
|
|
518
523
|
/**
|
|
519
|
-
*
|
|
524
|
+
* The public key for the fee payer in a sponsored transaction. Omit it to skip the fee payer's
|
|
525
|
+
* public/authentication-key check during simulation.
|
|
520
526
|
* @group Implementation
|
|
521
527
|
* @category Transactions
|
|
522
528
|
*/
|
package/src/types/keyless.ts
CHANGED
|
@@ -30,12 +30,12 @@ export type ProverResponse = {
|
|
|
30
30
|
* @category Types
|
|
31
31
|
*/
|
|
32
32
|
export type PepperFetchRequest = {
|
|
33
|
-
jwt_b64:
|
|
33
|
+
jwt_b64: string;
|
|
34
34
|
epk: string;
|
|
35
35
|
exp_date_secs: number;
|
|
36
36
|
epk_blinder: string;
|
|
37
37
|
uid_key: string;
|
|
38
|
-
derivation_path
|
|
38
|
+
derivation_path?: string;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
/**
|
package/src/types/types.ts
CHANGED
|
@@ -1040,7 +1040,7 @@ export type WriteSetChangeDeleteTableItem = {
|
|
|
1040
1040
|
state_key_hash: string;
|
|
1041
1041
|
handle: string;
|
|
1042
1042
|
key: string;
|
|
1043
|
-
data?: DeletedTableData;
|
|
1043
|
+
data?: DeletedTableData | null;
|
|
1044
1044
|
};
|
|
1045
1045
|
|
|
1046
1046
|
/**
|
|
@@ -1072,7 +1072,7 @@ export type WriteSetChangeWriteTableItem = {
|
|
|
1072
1072
|
handle: string;
|
|
1073
1073
|
key: string;
|
|
1074
1074
|
value: string;
|
|
1075
|
-
data?: DecodedTableData;
|
|
1075
|
+
data?: DecodedTableData | null;
|
|
1076
1076
|
};
|
|
1077
1077
|
|
|
1078
1078
|
/**
|
package/src/utils/const.ts
CHANGED
|
@@ -67,6 +67,18 @@ export const DEFAULT_TXN_EXP_SEC_FROM_NOW = 20;
|
|
|
67
67
|
*/
|
|
68
68
|
export const DEFAULT_TXN_TIMEOUT_SEC = 20;
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* The default number of seconds to wait for an indexer processor to catch up
|
|
72
|
+
* to a requested ledger version.
|
|
73
|
+
*
|
|
74
|
+
* Public networks and a busy local testnet can lag several seconds behind the
|
|
75
|
+
* fullnode. Callers that need a different budget can pass `timeoutMilliseconds`
|
|
76
|
+
* to `waitForIndexer`.
|
|
77
|
+
* @group Implementation
|
|
78
|
+
* @category Utils
|
|
79
|
+
*/
|
|
80
|
+
export const DEFAULT_INDEXER_SYNC_TIMEOUT_SEC = 10;
|
|
81
|
+
|
|
70
82
|
/**
|
|
71
83
|
* The default gas currency for the network.
|
|
72
84
|
* @group Implementation
|
package/src/version.ts
CHANGED