diff --git a/CHANGELOG.md b/CHANGELOG.md index ef96ee193..1b7bdde89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ All notable changes to the Aptos TypeScript SDK will be captured in this file. T # Unreleased - Use indexer API via API Gateway - Add signers to entry function ABI for future signature count checking +- [`Breaking`] Add type-safe view functions with ABI support +- Turn off code splitting on CJS # 1.10.0 (2024-03-11) diff --git a/examples/typescript-esm/multisig_v2.ts b/examples/typescript-esm/multisig_v2.ts index 89b1b80d2..17d3148a0 100644 --- a/examples/typescript-esm/multisig_v2.ts +++ b/examples/typescript-esm/multisig_v2.ts @@ -21,7 +21,6 @@ import { Account, Aptos, AptosConfig, - InputViewRequestData, Network, NetworkToNetworkName, MoveString, @@ -30,6 +29,7 @@ import { TransactionPayloadMultiSig, MultiSig, AccountAddress, + InputViewFunctionData, } from "@aptos-labs/ts-sdk"; // Default to devnet, but allow for overriding @@ -90,7 +90,7 @@ const settingUpMultiSigAccount = async () => { // =========================================================================================== // Get the next multisig account address. This will be the same as the account address of the multisig account we'll // be creating. - const payload: InputViewRequestData = { + const payload: InputViewFunctionData = { function: "0x1::multisig_account::get_next_multisig_account_address", functionArguments: [owner1.accountAddress.toString()], }; diff --git a/examples/typescript/swap.ts b/examples/typescript/swap.ts index b254f5d75..01e5acd0c 100644 --- a/examples/typescript/swap.ts +++ b/examples/typescript/swap.ts @@ -19,9 +19,9 @@ import { Aptos, AptosConfig, Ed25519PrivateKey, + InputViewFunctionData, Network, NetworkToNetworkName, - InputViewRequestData, } from "@aptos-labs/ts-sdk"; import { createInterface } from "readline"; // Default to devnet, but allow for overriding @@ -38,7 +38,7 @@ const getOptimalLpAmount = async ( token1Addr: AccountAddress, token2Addr: AccountAddress, ): Promise => { - const payload: InputViewRequestData = { + const payload: InputViewFunctionData = { function: `${swap.toString()}::router::optimal_liquidity_amounts`, functionArguments: [token1Addr, token2Addr, false, "200000", "300000", "200", "300"], }; diff --git a/examples/typescript/your_fungible_asset.ts b/examples/typescript/your_fungible_asset.ts index e87907def..c876e6c8f 100644 --- a/examples/typescript/your_fungible_asset.ts +++ b/examples/typescript/your_fungible_asset.ts @@ -7,7 +7,7 @@ import { AnyNumber, Aptos, AptosConfig, - InputViewRequestData, + InputViewFunctionData, Network, NetworkToNetworkName, } from "@aptos-labs/ts-sdk"; @@ -127,7 +127,7 @@ const getFaBalance = async (owner: Account, assetType: string): Promise /** Return the address of the managed fungible asset that's created when this module is deployed */ async function getMetadata(admin: Account): Promise { - const payload: InputViewRequestData = { + const payload: InputViewFunctionData = { function: `${admin.accountAddress}::fa_coin::get_metadata`, functionArguments: [], }; diff --git a/src/api/general.ts b/src/api/general.ts index 7ae447f54..9e7f7ae1e 100644 --- a/src/api/general.ts +++ b/src/api/general.ts @@ -11,8 +11,8 @@ import { getProcessorStatus, getTableItem, queryIndexer, - view, } from "../internal/general"; +import { view } from "../internal/view"; import { AnyNumber, Block, @@ -23,9 +23,9 @@ import { LedgerVersionArg, MoveValue, TableItemRequest, - InputViewRequestData, } from "../types"; import { ProcessorType } from "../utils/const"; +import { InputViewFunctionData } from "../transactions"; /** * A class to query all `General` Aptos related queries @@ -137,7 +137,7 @@ export class General { * @returns an array of Move values */ async view>(args: { - payload: InputViewRequestData; + payload: InputViewFunctionData; options?: LedgerVersionArg; }): Promise { return view({ aptosConfig: this.config, ...args }); diff --git a/src/internal/ans.ts b/src/internal/ans.ts index 05b070c4d..5361fa5f7 100644 --- a/src/internal/ans.ts +++ b/src/internal/ans.ts @@ -11,12 +11,13 @@ import { AptosConfig } from "../api/aptosConfig"; import { Account, AccountAddress, AccountAddressInput } from "../core"; import { InputGenerateTransactionOptions, SimpleTransaction } from "../transactions/types"; -import { GetANSNameResponse, MoveAddressType, MoveValue, OrderByArg, PaginationArgs, WhereArg } from "../types"; +import { GetANSNameResponse, MoveAddressType, OrderByArg, PaginationArgs, WhereArg } from "../types"; import { GetNamesQuery } from "../types/generated/operations"; import { GetNames } from "../types/generated/queries"; import { CurrentAptosNamesBoolExp } from "../types/generated/types"; import { Network } from "../utils/apiEndpoints"; -import { queryIndexer, view } from "./general"; +import { queryIndexer } from "./general"; +import { view } from "./view"; import { generateTransaction } from "./transactionSubmission"; export const VALIDATION_RULES_DESCRIPTION = [ @@ -85,12 +86,6 @@ function getRouterAddress(aptosConfig: AptosConfig): string { return address; } -const Some = (value: T): MoveValue => ({ vec: [value] }); -const None = (): MoveValue => ({ vec: [] }); -// != here is intentional, we want to check for null and undefined -// eslint-disable-next-line eqeqeq -const Option = (value: T | undefined | null): MoveValue => (value != undefined ? Some(value) : None()); - const unwrapOption = (option: any): T | undefined => { if (!!option && typeof option === "object" && "vec" in option && Array.isArray(option.vec)) { return option.vec[0]; @@ -108,7 +103,7 @@ export async function getOwnerAddress(args: { aptosConfig: AptosConfig; name: st aptosConfig, payload: { function: `${routerAddress}::router::get_owner_addr`, - functionArguments: [domainName, Option(subdomainName)], + functionArguments: [domainName, subdomainName], }, }); @@ -219,7 +214,7 @@ export async function getExpiration(args: { aptosConfig: AptosConfig; name: stri aptosConfig, payload: { function: `${routerAddress}::router::get_expiration`, - functionArguments: [domainName, Option(subdomainName)], + functionArguments: [domainName, subdomainName], }, }); @@ -303,7 +298,7 @@ export async function getTargetAddress(args: { aptosConfig, payload: { function: `${routerAddress}::router::get_target_addr`, - functionArguments: [domainName, Option(subdomainName)], + functionArguments: [domainName, subdomainName], }, }); diff --git a/src/internal/general.ts b/src/internal/general.ts index 7844957a5..673c4a377 100644 --- a/src/internal/general.ts +++ b/src/internal/general.ts @@ -18,10 +18,7 @@ import { GraphqlQuery, LedgerInfo, LedgerVersionArg, - MoveValue, TableItemRequest, - ViewRequest, - InputViewRequestData, } from "../types"; import { GetChainTopUserTransactionsQuery, GetProcessorStatusQuery } from "../types/generated/operations"; import { GetChainTopUserTransactions, GetProcessorStatus } from "../types/generated/queries"; @@ -84,27 +81,6 @@ export async function getTableItem(args: { return response.data as T; } -export async function view = Array>(args: { - aptosConfig: AptosConfig; - payload: InputViewRequestData; - options?: LedgerVersionArg; -}): Promise { - const { aptosConfig, payload, options } = args; - const { data } = await postAptosFullNode({ - aptosConfig, - originMethod: "view", - path: "view", - params: { ledger_version: options?.ledgerVersion }, - body: { - function: payload.function, - type_arguments: payload.typeArguments ?? [], - arguments: payload.functionArguments ?? [], - }, - }); - - return data as T; -} - export async function getChainTopUserTransactions(args: { aptosConfig: AptosConfig; limit: number; diff --git a/src/internal/transactionSubmission.ts b/src/internal/transactionSubmission.ts index 37c9610b2..2ba817485 100644 --- a/src/internal/transactionSubmission.ts +++ b/src/internal/transactionSubmission.ts @@ -20,7 +20,6 @@ import { generateSignedTransaction, sign, generateSigningMessage, - generateTransactionPayloadWithABI, } from "../transactions/transactionBuilder/transactionBuilder"; import { InputGenerateTransactionData, @@ -111,20 +110,14 @@ export async function buildTransactionPayload( // TODO: Add ABI checking later payload = await generateTransactionPayload(data); } else if ("multisigAddress" in data) { - if (data.abi) { - payload = generateTransactionPayloadWithABI({ abi: data.abi, ...data }); - } else { - generateTransactionPayloadData = { - aptosConfig, - multisigAddress: data.multisigAddress, - function: data.function, - functionArguments: data.functionArguments, - typeArguments: data.typeArguments, - }; - payload = await generateTransactionPayload(generateTransactionPayloadData); - } - } else if (data.abi) { - payload = generateTransactionPayloadWithABI({ abi: data.abi, ...data }); + generateTransactionPayloadData = { + aptosConfig, + multisigAddress: data.multisigAddress, + function: data.function, + functionArguments: data.functionArguments, + typeArguments: data.typeArguments, + }; + payload = await generateTransactionPayload(generateTransactionPayloadData); } else { generateTransactionPayloadData = { aptosConfig, diff --git a/src/internal/view.ts b/src/internal/view.ts new file mode 100644 index 000000000..d73964d3f --- /dev/null +++ b/src/internal/view.ts @@ -0,0 +1,35 @@ +// Copyright © Aptos Foundation +// SPDX-License-Identifier: Apache-2.0 + +import { LedgerVersionArg, MimeType, MoveValue } from "../types"; +import { AptosConfig } from "../api/aptosConfig"; +import { generateViewFunctionPayload, InputViewFunctionData } from "../transactions"; +import { Serializer } from "../bcs"; +import { postAptosFullNode } from "../client"; + +export async function view = Array>(args: { + aptosConfig: AptosConfig; + payload: InputViewFunctionData; + options?: LedgerVersionArg; +}): Promise { + const { aptosConfig, payload, options } = args; + const viewFunctionPayload = await generateViewFunctionPayload({ + ...payload, + aptosConfig, + }); + + const serializer = new Serializer(); + viewFunctionPayload.serialize(serializer); + const bytes = serializer.toUint8Array(); + + const { data } = await postAptosFullNode({ + aptosConfig, + path: "view", + originMethod: "view", + contentType: MimeType.BCS_VIEW_FUNCTION, + params: { ledger_version: options?.ledgerVersion }, + body: bytes, + }); + + return data as T; +} diff --git a/src/transactions/transactionBuilder/remoteAbi.ts b/src/transactions/transactionBuilder/remoteAbi.ts index 0a5169cc9..9128186de 100644 --- a/src/transactions/transactionBuilder/remoteAbi.ts +++ b/src/transactions/transactionBuilder/remoteAbi.ts @@ -4,7 +4,13 @@ import { parseTypeTag } from "../typeTag/parser"; import { TypeTag, TypeTagStruct } from "../typeTag"; import { AptosConfig } from "../../api/aptosConfig"; -import { EntryFunctionArgumentTypes, SimpleEntryFunctionArgumentTypes, EntryFunctionABI } from "../types"; +import { + EntryFunctionArgumentTypes, + SimpleEntryFunctionArgumentTypes, + EntryFunctionABI, + ViewFunctionABI, + FunctionABI, +} from "../types"; import { Bool, MoveOption, MoveString, MoveVector, U128, U16, U256, U32, U64, U8 } from "../../bcs"; import { AccountAddress } from "../../core"; import { getModule } from "../../internal/account"; @@ -45,6 +51,18 @@ export function standardizeTypeTags(typeArguments?: Array): Ar ); } +export async function fetchFunctionAbi( + moduleAddress: string, + moduleName: string, + functionName: string, + aptosConfig: AptosConfig, +) { + // This fetch from the API is currently cached + const module = await getModule({ aptosConfig, accountAddress: moduleAddress, moduleName }); + + return module.abi?.exposed_functions.find((func) => func.name === functionName); +} + /** * Fetches the ABI for an entry function from the module * @@ -59,10 +77,7 @@ export async function fetchEntryFunctionAbi( functionName: string, aptosConfig: AptosConfig, ): Promise { - // This fetch from the API is currently cached - const module = await getModule({ aptosConfig, accountAddress: moduleAddress, moduleName }); - - const functionAbi = module.abi?.exposed_functions.find((func) => func.name === functionName); + const functionAbi = await fetchFunctionAbi(moduleAddress, moduleName, functionName, aptosConfig); // If there's no ABI, then the function is invalid if (!functionAbi) { @@ -88,6 +103,49 @@ export async function fetchEntryFunctionAbi( }; } +/** + * Fetches the ABI for an entry function from the module + * + * @param moduleAddress + * @param moduleName + * @param functionName + * @param aptosConfig + */ +export async function fetchViewFunctionAbi( + moduleAddress: string, + moduleName: string, + functionName: string, + aptosConfig: AptosConfig, +): Promise { + const functionAbi = await fetchFunctionAbi(moduleAddress, moduleName, functionName, aptosConfig); + + // If there's no ABI, then the function is invalid + if (!functionAbi) { + throw new Error(`Could not find view function ABI for '${moduleAddress}::${moduleName}::${functionName}'`); + } + + // Non-view functions also can't be used + if (!functionAbi.is_view) { + throw new Error(`'${moduleAddress}::${moduleName}::${functionName}' is not an view function`); + } + + const params: TypeTag[] = []; + for (let i = 0; i < functionAbi.params.length; i += 1) { + params.push(parseTypeTag(functionAbi.params[i], { allowGenerics: true })); + } + + const returnTypes: TypeTag[] = []; + for (let i = 0; i < functionAbi.return.length; i += 1) { + returnTypes.push(parseTypeTag(functionAbi.return[i], { allowGenerics: true })); + } + + return { + typeParameters: functionAbi.generic_type_params, + parameters: params, + returnTypes, + }; +} + /** * Converts a non-BCS encoded argument into BCS encoded, if necessary * @param functionName @@ -97,7 +155,7 @@ export async function fetchEntryFunctionAbi( */ export function convertArgument( functionName: string, - functionAbi: EntryFunctionABI, + functionAbi: FunctionABI, arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes, position: number, genericTypeParams: Array, diff --git a/src/transactions/transactionBuilder/transactionBuilder.ts b/src/transactions/transactionBuilder/transactionBuilder.ts index 5cec0b60f..f68eb46f4 100644 --- a/src/transactions/transactionBuilder/transactionBuilder.ts +++ b/src/transactions/transactionBuilder/transactionBuilder.ts @@ -69,8 +69,10 @@ import { InputGenerateTransactionPayloadDataWithABI, InputEntryFunctionDataWithABI, InputMultiSigDataWithABI, + InputViewFunctionDataWithRemoteABI, + InputViewFunctionDataWithABI, } from "../types"; -import { convertArgument, fetchEntryFunctionAbi, standardizeTypeTags } from "./remoteAbi"; +import { convertArgument, fetchEntryFunctionAbi, fetchViewFunctionAbi, standardizeTypeTags } from "./remoteAbi"; import { memoizeAsync } from "../../utils/memoize"; import { AnyNumber } from "../../types"; import { getFunctionParts, isScriptDataInput } from "./helpers"; @@ -108,12 +110,15 @@ export async function generateTransactionPayload( const { moduleAddress, moduleName, functionName } = getFunctionParts(args.function); - // We fetch the entry function ABI, and then pretend that we already had the ABI - const functionAbi = await memoizeAsync( - async () => fetchEntryFunctionAbi(moduleAddress, moduleName, functionName, args.aptosConfig), - `entry-function-${args.aptosConfig.network}-${moduleAddress}-${moduleName}-${functionName}`, - 1000 * 60 * 5, // 5 minutes - )(); + let functionAbi = args.abi; + if (!functionAbi) { + // We fetch the entry function ABI, and then pretend that we already had the ABI + functionAbi = await memoizeAsync( + async () => fetchEntryFunctionAbi(moduleAddress, moduleName, functionName, args.aptosConfig), + `entry-function-${args.aptosConfig.network}-${moduleAddress}-${moduleName}-${functionName}`, + 1000 * 60 * 5, // 5 minutes + )(); + } // Fill in the ABI return generateTransactionPayloadWithABI({ abi: functionAbi, ...args }); @@ -170,6 +175,54 @@ export function generateTransactionPayloadWithABI( return new TransactionPayloadEntryFunction(entryFunctionPayload); } +export async function generateViewFunctionPayload(args: InputViewFunctionDataWithRemoteABI): Promise { + const { moduleAddress, moduleName, functionName } = getFunctionParts(args.function); + + let functionAbi = args.abi; + // We fetch the entry function ABI, and then pretend that we already had the ABI + if (!functionAbi) { + functionAbi = await memoizeAsync( + async () => fetchViewFunctionAbi(moduleAddress, moduleName, functionName, args.aptosConfig), + `view-function-${args.aptosConfig.network}-${moduleAddress}-${moduleName}-${functionName}`, + 1000 * 60 * 5, // 5 minutes + )(); + } + + // Fill in the ABI + return generateViewFunctionPayloadWithABI({ abi: functionAbi, ...args }); +} + +export function generateViewFunctionPayloadWithABI(args: InputViewFunctionDataWithABI): EntryFunction { + const functionAbi = args.abi; + const { moduleAddress, moduleName, functionName } = getFunctionParts(args.function); + + // Ensure that all type arguments are typed properly + const typeArguments = standardizeTypeTags(args.typeArguments); + + // Check the type argument count against the ABI + if (typeArguments.length !== functionAbi.typeParameters.length) { + throw new Error( + `Type argument count mismatch, expected ${functionAbi.typeParameters.length}, received ${typeArguments.length}`, + ); + } + + // Check all BCS types, and convert any non-BCS types + const functionArguments: Array = args.functionArguments.map((arg, i) => + convertArgument(args.function, functionAbi, arg, i, typeArguments), + ); + + // Check that all arguments are accounted for + if (functionArguments.length !== functionAbi.parameters.length) { + throw new Error( + // eslint-disable-next-line max-len + `Too few arguments for '${moduleAddress}::${moduleName}::${functionName}', expected ${functionAbi.parameters.length} but got ${functionArguments.length}`, + ); + } + + // Generate entry function payload + return EntryFunction.build(`${moduleAddress}::${moduleName}`, functionName, typeArguments, functionArguments); +} + function generateTransactionPayloadScript(args: InputScriptData) { return new TransactionPayloadScript( new Script(Hex.fromHexInput(args.bytecode).toUint8Array(), args.typeArguments ?? [], args.functionArguments), diff --git a/src/transactions/types.ts b/src/transactions/types.ts index b70dfba6c..6858deb8f 100644 --- a/src/transactions/types.ts +++ b/src/transactions/types.ts @@ -146,15 +146,42 @@ export type InputScriptData = { functionArguments: Array; }; +/** + * The data needed to generate an View Function payload + */ +export type InputViewFunctionData = { + function: MoveFunctionId; + typeArguments?: Array; + functionArguments: Array; + abi?: ViewFunctionABI; +}; +export type InputViewFunctionDataWithRemoteABI = InputViewFunctionData & { aptosConfig: AptosConfig }; + +export type InputViewFunctionDataWithABI = Omit & { + abi: ViewFunctionABI; +}; + +export type FunctionABI = { + typeParameters: Array; + parameters: Array; +}; + /** * Interface of an Entry function's ABI. * * This is used to provide type checking and simple input conversion on ABI based transaction submission. */ -export type EntryFunctionABI = { +export type EntryFunctionABI = FunctionABI & { signers?: number; - typeParameters: Array; - parameters: Array; +}; + +/** + * Interface of an View function's ABI. + * + * This is used to provide type checking and simple input conversion on ABI based transaction submission. + */ +export type ViewFunctionABI = FunctionABI & { + returnTypes: Array; }; /** diff --git a/src/types/index.ts b/src/types/index.ts index af55a683a..994abcd96 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -19,6 +19,7 @@ export enum MimeType { * BCS representation, used for transaction submission in BCS input */ BCS_SIGNED_TRANSACTION = "application/x.aptos.signed_transaction+bcs", + BCS_VIEW_FUNCTION = "application/x.aptos.view_function+bcs", } /** @@ -988,34 +989,8 @@ export type Block = { transactions?: Array; }; -/** - * The data needed to generate a View Request payload - */ -export type InputViewRequestData = { - function: MoveFunctionId; - typeArguments?: Array; - functionArguments?: Array; -}; - // REQUEST TYPES -/** - * View request for the Move view function API - * - * `type MoveFunctionId = ${string}::${string}::${string}`; - */ -export type ViewRequest = { - function: MoveFunctionId; - /** - * Type arguments of the function - */ - typeArguments: Array; - /** - * Arguments of the function - */ - functionArguments: Array; -}; - /** * Table Item request for the GetTableItem API */ diff --git a/tests/e2e/api/general.test.ts b/tests/e2e/api/general.test.ts index fb4f6d5a8..c0244fa34 100644 --- a/tests/e2e/api/general.test.ts +++ b/tests/e2e/api/general.test.ts @@ -1,7 +1,7 @@ // Copyright © Aptos Foundation // SPDX-License-Identifier: Apache-2.0 -import { AptosConfig, Aptos, Network, GraphqlQuery, InputViewRequestData, ProcessorType } from "../../../src"; +import { AptosConfig, Aptos, Network, GraphqlQuery, ProcessorType, InputViewFunctionData } from "../../../src"; describe("general api", () => { test("it fetches ledger info", async () => { @@ -101,8 +101,10 @@ describe("general api", () => { const config = new AptosConfig({ network: Network.LOCAL }); const aptos = new Aptos(config); - const payload: InputViewRequestData = { + const payload: InputViewFunctionData = { function: "0x1::chain_id::get", + typeArguments: [], + functionArguments: [], }; const chainId = (await aptos.view({ payload }))[0]; @@ -114,8 +116,10 @@ describe("general api", () => { const config = new AptosConfig({ network: Network.LOCAL }); const aptos = new Aptos(config); - const payload: InputViewRequestData = { + const payload: InputViewFunctionData = { function: "0x1::chain_id::get", + typeArguments: [], + functionArguments: [], }; const chainId = (await aptos.view<[number]>({ payload }))[0]; @@ -127,8 +131,9 @@ describe("general api", () => { const config = new AptosConfig({ network: Network.LOCAL }); const aptos = new Aptos(config); - const payload: InputViewRequestData = { + const payload: InputViewFunctionData = { function: "0x1::account::exists_at", + typeArguments: [], functionArguments: ["0x1"], }; @@ -136,8 +141,9 @@ describe("general api", () => { expect(exists).toBe(true); - const payload2: InputViewRequestData = { + const payload2: InputViewFunctionData = { function: "0x1::account::exists_at", + typeArguments: [], functionArguments: ["0x12345"], }; @@ -150,8 +156,9 @@ describe("general api", () => { const config = new AptosConfig({ network: Network.LOCAL }); const aptos = new Aptos(config); - const payload: InputViewRequestData = { + const payload: InputViewFunctionData = { function: "0x1::account::get_sequence_number", + typeArguments: [], functionArguments: ["0x1"], }; @@ -159,8 +166,9 @@ describe("general api", () => { expect(BigInt(sequenceNumber)).toEqual(BigInt(0)); - const payload2: InputViewRequestData = { + const payload2: InputViewFunctionData = { function: "0x1::account::get_authentication_key", + typeArguments: [], functionArguments: ["0x1"], }; @@ -173,15 +181,16 @@ describe("general api", () => { const config = new AptosConfig({ network: Network.LOCAL }); const aptos = new Aptos(config); - const payload: InputViewRequestData = { + const payload: InputViewFunctionData = { function: "0x1::coin::symbol", typeArguments: ["0x1::aptos_coin::AptosCoin"], + functionArguments: [], }; const symbol = (await aptos.view<[string]>({ payload }))[0]; expect(symbol).toEqual("APT"); - const payload2: InputViewRequestData = { + const payload2: InputViewFunctionData = { function: "0x1::coin::is_account_registered", typeArguments: ["0x1::aptos_coin::AptosCoin"], functionArguments: ["0x1"], @@ -190,7 +199,7 @@ describe("general api", () => { const isRegistered = (await aptos.view<[boolean]>({ payload: payload2 }))[0]; expect(isRegistered).toEqual(false); - const payload3: InputViewRequestData = { + const payload3: InputViewFunctionData = { function: "0x1::coin::supply", typeArguments: ["0x1::aptos_coin::AptosCoin"], functionArguments: [], @@ -204,7 +213,7 @@ describe("general api", () => { const config = new AptosConfig({ network: Network.LOCAL }); const aptos = new Aptos(config); - const payload: InputViewRequestData = { + const payload: InputViewFunctionData = { function: "0x1::account::get_sequence_number", functionArguments: ["0x123456"], }; diff --git a/tsup.config.ts b/tsup.config.ts index 60edab0cf..cb391ff23 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -34,6 +34,7 @@ const COMMON_CONFIG: MandatoryOptions = { format: "cjs", outDir: "dist/common", platform: "node", + splitting: false, }; // ESM config