Skip to content

Commit

Permalink
fix serialization of bigints in transacitons command
Browse files Browse the repository at this point in the history
  • Loading branch information
zoeyTM committed Nov 20, 2024
1 parent 44ebf75 commit 7679cd2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
14 changes: 9 additions & 5 deletions packages/core/src/list-transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ export async function listTransactions(
? exState.result.address
: undefined
: undefined,
params: exState.constructorArgs,
value: networkInteraction.value,
params: exState.constructorArgs.map((arg) =>
typeof arg === "bigint" ? arg.toString() : arg
),
value: networkInteraction.value.toString(),
});

break;
Expand All @@ -116,8 +118,10 @@ export async function listTransactions(
),
name: `${artifact.contractName}#${exState.functionName}`,
to: networkInteraction.to,
params: exState.args,
value: networkInteraction.value,
params: exState.args.map((arg) =>
typeof arg === "bigint" ? arg.toString() : arg
),
value: networkInteraction.value.toString(),
});

break;
Expand All @@ -132,7 +136,7 @@ export async function listTransactions(
lastTxIndex === networkInteraction.transactions.length - 1
),
to: networkInteraction.to,
value: networkInteraction.value,
value: networkInteraction.value.toString(),
});

break;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types/list-transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface TransactionInfo {
name?: string; // can be contract name, function name, or undefined, depending on the type
address?: string;
params?: SolidityParameterType[];
value?: bigint;
value?: string;
}

/**
Expand Down
12 changes: 6 additions & 6 deletions packages/core/test/list-transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("listTransactions", () => {
name: "BasicContract",
address: "0x74e720c9B362ae3A65fF356ad62866511486BBBc",
params: ["0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"],
value: 0n,
value: "0",
},
{
type: "DEPLOYMENT_EXECUTION_STATE",
Expand All @@ -32,7 +32,7 @@ describe("listTransactions", () => {
name: "BasicLibrary",
address: "0x1c947344BA932fC7f3D622600dA0199520A67EFd",
params: [],
value: 0n,
value: "0",
},
{
type: "DEPLOYMENT_EXECUTION_STATE",
Expand All @@ -43,7 +43,7 @@ describe("listTransactions", () => {
name: "BasicLibrary",
address: "0xBdAce15b3211019E272418B8014971c1cefbC8f0",
params: [],
value: 0n,
value: "0",
},
{
type: "CALL_EXECUTION_STATE",
Expand All @@ -54,7 +54,7 @@ describe("listTransactions", () => {
name: "BasicContract#basicFunction",
to: "0x74e720c9B362ae3A65fF356ad62866511486BBBc",
params: [40],
value: 0n,
value: "0",
},
{
type: "DEPLOYMENT_EXECUTION_STATE",
Expand All @@ -65,7 +65,7 @@ describe("listTransactions", () => {
name: "ContractWithLibrary",
address: "0xD369D9aB22D85C2A12bEabc0B581a419789E3755",
params: [],
value: 0n,
value: "0",
},
{
type: "SEND_DATA_EXECUTION_STATE",
Expand All @@ -74,7 +74,7 @@ describe("listTransactions", () => {
"0x2870c7d9f84122caba3739be0dc2246343a87d1b216b57002654b3bd413fe8e2",
status: TransactionStatus.SUCCESS,
to: "0x74e720c9B362ae3A65fF356ad62866511486BBBc",
value: 123n,
value: "123",
},
];

Expand Down

0 comments on commit 7679cd2

Please sign in to comment.