Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"typescript": "^4.6.4"
},
"dependencies": {
"aptos": "^1.3.7",
"aptos": "^1.3.10",
"big-integer": "^1.6.51",
"elliptic": "^6.5.4",
"json-stable-stringify": "^1.0.1",
Expand Down
16 changes: 13 additions & 3 deletions typescript/src/builtinFuncs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { HexString } from "aptos";
import stringify from "json-stable-stringify";
import { StructInfoType } from "./parserRepo";
import { ActualStringClass } from "./nativeFuncs";
import { AccountAddress } from "aptos/dist/transaction_builder/aptos_types";

export function abortCode(code: any) {
if (code instanceof U64) {
Expand Down Expand Up @@ -256,15 +257,24 @@ export function payloadArg(val: any) {
return val.value.toString();
}
else {
throw new Error("Only expect U8, U64, or U128 for integer types");
throw new Error("Only expect U8, U64, or U128 for UnsignedInt types");
}
}
else if (Array.isArray(val) && val.every(v => v instanceof U8)) {
// For U8[]
return u8ArrayArg(val);
}
else if (val instanceof HexString) {
return val.toShortString();
}
else if (typeof val === 'boolean') {
else if (['boolean', 'string', 'number', 'bigint'].includes(typeof val)) {
// 1. return as it is for js primitive types
// 2. to make sure function payloadArg is idempotent when called more than once
return val
}
else if (val instanceof AccountAddress) {
return val;
}
else if(val.typeTag instanceof StructTag) {
const tag = val.typeTag as StructTag;
if (tag.address.toShortString() === '0x1' && tag.module === 'string' && tag.name === 'String') {
Expand All @@ -277,7 +287,7 @@ export function payloadArg(val: any) {
}
}
else {
throw new Error(`Unexpected value type: ${typeof val}`);
throw new Error(`Unexpected value ${val}`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion typescript/src/txSender.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AptosClient, AptosAccount, Types, TxnBuilderTypes, HexString, BCS, TransactionBuilderEd25519 } from "aptos";
import { TypeTagParser } from "aptos/dist/transaction_builder/builder_utils";
import { $TransactionPayload_EntryFunctionPayload, TransactionPayload_EntryFunctionPayload, TransactionSignature, UserTransaction, WriteSetChange_WriteResource } from "aptos/dist/generated";
import { TransactionPayload_EntryFunctionPayload, TransactionSignature, UserTransaction, WriteSetChange_WriteResource } from "aptos/dist/generated";
import { AccountAddress, Identifier, ModuleId, EntryFunction } from "aptos/dist/transaction_builder/aptos_types";
import { AptosParserRepo } from "./parserRepo";
import { StructTag } from "./typeTag";
Expand Down