From ae18d9e2e268235cea370f053e5c12f633d78aa7 Mon Sep 17 00:00:00 2001 From: xbtmatt <90358481+xbtmatt@users.noreply.github.com> Date: Wed, 11 Oct 2023 01:46:05 -0700 Subject: [PATCH] Adding EntryFunctionArgumentTypes and ScriptFunctionArgumentTypes to types.ts for clearer type errors when using incorrect types --- .../instances/transactionPayload.ts | 2 +- src/transactions/types.ts | 31 +++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/transactions/instances/transactionPayload.ts b/src/transactions/instances/transactionPayload.ts index 1bec09d80..53e5a27d4 100644 --- a/src/transactions/instances/transactionPayload.ts +++ b/src/transactions/instances/transactionPayload.ts @@ -10,7 +10,7 @@ import { Identifier } from "./identifier"; import { ModuleId } from "./moduleId"; import { ScriptTransactionArgumentVariants, TransactionPayloadVariants } from "../../types"; import { TypeTag } from "../typeTag/typeTag"; -import { EntryFunctionArgument, ScriptFunctionArgument, TransactionArgument } from "./transactionArgument"; +import type { EntryFunctionArgument, ScriptFunctionArgument, TransactionArgument } from "./transactionArgument"; import { EntryFunctionBytes } from "../../bcs/serializable/entry-function-bytes"; import { Bool, U128, U16, U256, U32, U64, U8 } from "../../bcs/serializable/move-primitives"; import { MoveVector } from "../../bcs/serializable/move-structs"; diff --git a/src/transactions/types.ts b/src/transactions/types.ts index 48106002d..ac400c591 100644 --- a/src/transactions/types.ts +++ b/src/transactions/types.ts @@ -13,8 +13,33 @@ import { TransactionPayloadMultisig, TransactionPayloadScript, } from "./instances"; -import { EntryFunctionArgument, ScriptFunctionArgument } from "./instances/transactionArgument"; import { TypeTag } from "./typeTag/typeTag"; +import { MoveObject, MoveOption, MoveVector } from "../bcs/serializable/move-structs"; +import { Bool, U128, U16, U256, U32, U64, U8 } from "../bcs/serializable/move-primitives"; + +export type EntryFunctionArgumentTypes = + | Bool + | U8 + | U16 + | U32 + | U64 + | U128 + | U256 + | AccountAddress + | MoveObject + | MoveVector + | MoveOption; +export type ScriptFunctionArgumentTypes = + | Bool + | U8 + | U16 + | U32 + | U64 + | U128 + | U256 + | AccountAddress + | MoveObject + | MoveVector; /** * Type that holds all raw transaction instances Aptos SDK supports @@ -53,7 +78,7 @@ export type GenerateTransactionPayloadData = EntryFunctionData | ScriptData | Mu export type EntryFunctionData = { function: MoveStructType; type_arguments: Array; - arguments: Array; + arguments: Array; }; /** @@ -69,7 +94,7 @@ export type MultiSigData = { export type ScriptData = { bytecode: string; type_arguments: Array; - arguments: Array; + arguments: Array; }; /**