Skip to content

Commit 55e9873

Browse files
jarrodwattsclaude
andcommitted
fix: serialize BigInt values in readContract responses
readContract returns BigInt for uint256 fields which JSON.stringify can't handle. Convert recursively to strings before returning. Bumps CLI to 0.1.6. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e04d06c commit 55e9873

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

packages/agw-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@abstract-foundation/agw-cli",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"type": "module",
55
"description": "Agent-first CLI for Abstract Global Wallet workflows",
66
"license": "MIT",

packages/agw-cli/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ async function main(): Promise<void> {
145145
program
146146
.name("agw-cli")
147147
.description("Agent-first CLI for Abstract Global Wallet workflows.")
148-
.version("0.1.5")
148+
.version("0.1.6")
149149
.showHelpAfterError();
150150

151151
program

packages/agw-core/src/tools/write-contract.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ import { assertToolCapability } from "./capability-guard.js";
44
import { resolveToolNetworkConfig } from "./network.js";
55
import type { ToolHandler } from "./types.js";
66

7+
function toJsonSafe(value: unknown): unknown {
8+
if (typeof value === "bigint") return value.toString();
9+
if (Array.isArray(value)) return value.map(toJsonSafe);
10+
if (value !== null && typeof value === "object") {
11+
return Object.fromEntries(
12+
Object.entries(value).map(([k, v]) => [k, toJsonSafe(v)]),
13+
);
14+
}
15+
return value;
16+
}
17+
718
function isViewOrPure(abi: Abi, functionName: string): boolean {
819
const fn = abi.find(
920
(item): item is AbiFunction =>
@@ -109,7 +120,7 @@ export const writeContractTool: ToolHandler = {
109120
} as never);
110121

111122
return {
112-
result,
123+
result: toJsonSafe(result),
113124
accountAddress: session.accountAddress,
114125
chainId: session.chainId,
115126
contract: { address, functionName, args: args ?? [] },

0 commit comments

Comments
 (0)