11import { AptosClient , AptosAccount , Types , TxnBuilderTypes , HexString , BCS } from "aptos" ;
2- import { TypeTagParser } from "aptos/dist/transaction_builder/builder_utils" ;
3- import { UserTransaction , WriteSetChange_WriteResource } from "aptos/dist/generated" ;
4- import { AccountAddress , Identifier , ModuleId , EntryFunction } from "aptos/dist/transaction_builder/aptos_types" ;
2+ import { TransactionPayload_EntryFunctionPayload , UserTransaction , WriteSetChange_WriteResource } from "aptos/dist/generated" ;
53import { AptosParserRepo } from "./parserRepo" ;
6- import { AtomicTypeTag , StructTag , TypeTag } from "./typeTag" ;
4+ import { StructTag } from "./typeTag" ;
75import { U128 , U64 , U8 } from "./builtinTypes" ;
8- import { ActualStringClass , serializeMoveValue , serializeMoveValueWithoutTag , serializeVector } from "." ;
6+ import { ActualStringClass , payloadArg } from "." ;
97
108type AcceptedScriptFuncArgType = any [ ] | U8 | U64 | U128 | HexString | boolean | ActualStringClass ;
119
@@ -15,22 +13,17 @@ export function buildPayload(
1513 funcName : string ,
1614 typeArguments : string [ ] ,
1715 args : AcceptedScriptFuncArgType [ ] ,
18- ) : TxnBuilderTypes . TransactionPayloadEntryFunction {
16+ ) : TransactionPayload_EntryFunctionPayload {
1917
20- const bytes = args . map ( arg => {
21- const serializer = new BCS . Serializer ( ) ;
22- serializeMoveValueWithoutTag ( serializer , arg ) ;
23- return serializer . getBytes ( ) ;
24- } ) ;
18+ const _function = `${ moduleAddress . toString ( ) } ::${ moduleName } ::${ funcName } ` ;
19+ const _arguments = args . map ( a => payloadArg ( a ) ) ;
2520
26-
27- const scriptFunction = new EntryFunction (
28- new ModuleId ( new AccountAddress ( moduleAddress . toUint8Array ( ) ) , new Identifier ( moduleName ) ) ,
29- new Identifier ( funcName ) ,
30- typeArguments . map ( str => new TypeTagParser ( str ) . parseTypeTag ( ) ) ,
31- bytes ,
32- ) ;
33- return new TxnBuilderTypes . TransactionPayloadEntryFunction ( scriptFunction ) ;
21+ return {
22+ type : "entry_function_payload" ,
23+ function : _function ,
24+ type_arguments : typeArguments ,
25+ arguments : _arguments ,
26+ } ;
3427}
3528
3629export async function sendPayloadTx (
0 commit comments