Skip to content

Commit

Permalink
Adding EntryFunctionArgumentTypes and ScriptFunctionArgumentTypes to …
Browse files Browse the repository at this point in the history
…types.ts for clearer type errors when using incorrect types
  • Loading branch information
xbtmatt committed Oct 11, 2023
1 parent 5735b39 commit ae18d9e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/transactions/instances/transactionPayload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
31 changes: 28 additions & 3 deletions src/transactions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<EntryFunctionArgumentTypes>
| MoveOption<EntryFunctionArgumentTypes>;
export type ScriptFunctionArgumentTypes =
| Bool
| U8
| U16
| U32
| U64
| U128
| U256
| AccountAddress
| MoveObject
| MoveVector<U8>;

/**
* Type that holds all raw transaction instances Aptos SDK supports
Expand Down Expand Up @@ -53,7 +78,7 @@ export type GenerateTransactionPayloadData = EntryFunctionData | ScriptData | Mu
export type EntryFunctionData = {
function: MoveStructType;
type_arguments: Array<TypeTag>;
arguments: Array<EntryFunctionArgument>;
arguments: Array<EntryFunctionArgumentTypes>;
};

/**
Expand All @@ -69,7 +94,7 @@ export type MultiSigData = {
export type ScriptData = {
bytecode: string;
type_arguments: Array<TypeTag>;
arguments: Array<ScriptFunctionArgument>;
arguments: Array<ScriptFunctionArgumentTypes>;
};

/**
Expand Down

0 comments on commit ae18d9e

Please sign in to comment.