1
1
import { 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" ;
5
3
import { AptosParserRepo } from "./parserRepo" ;
6
- import { AtomicTypeTag , StructTag , TypeTag } from "./typeTag" ;
4
+ import { StructTag } from "./typeTag" ;
7
5
import { U128 , U64 , U8 } from "./builtinTypes" ;
8
- import { ActualStringClass , serializeMoveValue , serializeMoveValueWithoutTag , serializeVector } from "." ;
6
+ import { ActualStringClass , payloadArg } from "." ;
9
7
10
8
type AcceptedScriptFuncArgType = any [ ] | U8 | U64 | U128 | HexString | boolean | ActualStringClass ;
11
9
@@ -15,22 +13,17 @@ export function buildPayload(
15
13
funcName : string ,
16
14
typeArguments : string [ ] ,
17
15
args : AcceptedScriptFuncArgType [ ] ,
18
- ) : TxnBuilderTypes . TransactionPayloadEntryFunction {
16
+ ) : TransactionPayload_EntryFunctionPayload {
19
17
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 ) ) ;
25
20
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
+ } ;
34
27
}
35
28
36
29
export async function sendPayloadTx (
0 commit comments