From aeb56b333140bde682a8e80a97bcd45650d6d596 Mon Sep 17 00:00:00 2001 From: runtianz Date: Tue, 5 Nov 2024 13:28:36 -0800 Subject: [PATCH] Fix deps, re-export CallArgument --- src/api/transactionSubmission/build.ts | 10 ++++++---- src/transactions/script-composer/index.ts | 10 +++++----- src/types/index.ts | 1 + tests/e2e/transaction/transactionSubmission.test.ts | 5 +++-- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/api/transactionSubmission/build.ts b/src/api/transactionSubmission/build.ts index 83b3c4f47..179726645 100644 --- a/src/api/transactionSubmission/build.ts +++ b/src/api/transactionSubmission/build.ts @@ -13,7 +13,6 @@ import { import { MultiAgentTransaction } from "../../transactions/instances/multiAgentTransaction"; import { SimpleTransaction } from "../../transactions/instances/simpleTransaction"; import { AptosConfig } from "../aptosConfig"; -import { singleSignerED25519 } from "../../../tests/unit/helper"; import { Deserializer } from "../../bcs"; /** @@ -105,6 +104,9 @@ export class Build { * Build a transaction from a series of Move calls. * * This function allows you to create a transaction with a list of Move calls. + * + * Right now we only tested this logic with single signer and we will add support + * for mutli agent transactions if needed. * * @param args.sender - The sender account address. * @param args.builder - The closure to construct the list of calls. @@ -156,7 +158,7 @@ export class Build { * runExample().catch(console.error); * ``` */ - async script_composer(args: { + async scriptComposer(args: { sender: AccountAddressInput; builder: (builder: AptosScriptComposer) => Promise; options?: InputGenerateTransactionOptions; @@ -164,12 +166,12 @@ export class Build { }): Promise { const builder = await args.builder(new AptosScriptComposer(this.config)); const bytes = builder.build(); - const raw_txn = await generateRawTransaction({ + const rawTxn = await generateRawTransaction({ aptosConfig: this.config, payload: TransactionPayloadScript.load(new Deserializer(bytes)), ...args, }); - return new SimpleTransaction(raw_txn); + return new SimpleTransaction(rawTxn); } /** diff --git a/src/transactions/script-composer/index.ts b/src/transactions/script-composer/index.ts index 1cfdde4b7..0ef58d49d 100644 --- a/src/transactions/script-composer/index.ts +++ b/src/transactions/script-composer/index.ts @@ -1,9 +1,9 @@ // Copyright © Aptos Foundation // SPDX-License-Identifier: Apache-2.0 -import { CallArgument, TransactionComposer, initSync, create_wasm } from "@wgb5445/aptos-intent-npm"; +import { TransactionComposer, initSync, create_wasm } from "@wgb5445/aptos-intent-npm"; import { AptosApiType } from "../../utils"; -import { AptosConfig } from "../../api"; +import { AptosConfig } from "../../api/aptosConfig"; import { EntryFunctionArgumentTypes, FunctionABI, @@ -12,11 +12,10 @@ import { } from "../types"; import { convertArgument, fetchMoveFunctionAbi, getFunctionParts, standardizeTypeTags } from "../transactionBuilder"; import { TypeTag } from "../typeTag"; - -let wasm = null; +import { CallArgument } from "../../types"; (async () => { - wasm = initSync(await create_wasm()); + initSync(await create_wasm()); })(); function convertCallArgument( @@ -67,6 +66,7 @@ export class AptosScriptComposer { // Load the calling type arguments into the loader. if (input.typeArguments !== undefined) { for (const typeTag of input.typeArguments) { + // eslint-disable-next-line no-await-in-loop await this.builder.load_type_tag(nodeUrl, typeTag.toString()); } } diff --git a/src/types/index.ts b/src/types/index.ts index a5bb252e5..7db2f1d5d 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,3 +1,4 @@ export * from "./indexer"; export * from "./error"; export * from "./types"; +export { CallArgument } from "@wgb5445/aptos-intent-npm" diff --git a/tests/e2e/transaction/transactionSubmission.test.ts b/tests/e2e/transaction/transactionSubmission.test.ts index bd2800b6a..3f2c30bf6 100644 --- a/tests/e2e/transaction/transactionSubmission.test.ts +++ b/tests/e2e/transaction/transactionSubmission.test.ts @@ -1,7 +1,7 @@ // Copyright © Aptos Foundation // SPDX-License-Identifier: Apache-2.0 -import { CallArgument } from "@wgb5445/aptos-intent-npm"; +//import { CallArgument } from "@wgb5445/aptos-intent-npm"; import { Account, U64, @@ -17,6 +17,7 @@ import { TransactionPayloadScript, generateRawTransaction, SimpleTransaction, + CallArgument, } from "../../../src"; import { MAX_U64_BIG_INT } from "../../../src/bcs/consts"; import { longTestTimeout } from "../../unit/helper"; @@ -90,7 +91,7 @@ describe("transaction submission", () => { expect(response.signature?.type).toBe("single_sender"); }); test.only("with batch withdraw payload", async () => { - const transaction = await aptos.transaction.build.script_composer({ + const transaction = await aptos.transaction.build.scriptComposer({ sender: singleSignerED25519SenderAccount.accountAddress, builder: async (builder) => { const coin = await builder.addBatchedCalls({