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
15 changes: 15 additions & 0 deletions src/transactions/decoders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,21 @@ export const simplifyTransactionReceipt = (tx: GenLayerTransaction): GenLayerTra
return obj.map(item => simplifyObject(item, path)).filter(item => item !== undefined);
}

// Decoded calldata (`txDataDecoded.callData` / `constructorArgs`, see
// abi/calldata/decoder.ts's TYPE_MAP) is a `Map<string, CalldataEncodable>`,
// not a plain object. `Object.entries()` below only sees a plain object's
// own enumerable properties, so a Map falls through it as `{}` — the
// decoded method name and arguments are silently dropped instead of
// simplified. Convert it to a plain object first so its entries go
// through the same simplification as everything else.
if (obj instanceof Map) {
const result: any = {};
for (const [key, value] of obj.entries()) {
result[key] = simplifyObject(value, path ? `${path}.${key}` : key);
}
return result;
}

if (typeof obj === "object") {
const result: any = {};

Expand Down
36 changes: 36 additions & 0 deletions tests/transactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1112,4 +1112,40 @@ describe("simplifyTransactionReceipt", () => {
expect(genvm.stderr).toBe("some error");
expect(genvm.exit_code).toBe(1);
});

it("should preserve decoded calldata Map (method + args) instead of dropping it", () => {
// Matches decodeCalldata's TYPE_MAP output: a Map<string, CalldataEncodable>,
// not a plain object.
const tx = {
txDataDecoded: {
callData: new Map<string, unknown>([
["", "inspect_delivery"],
["args", ["synthetic-reference"]],
]),
leaderOnly: false,
type: "call",
},
} as any;

const simplified = simplifyTransactionReceipt(tx) as any;

expect(simplified.txDataDecoded.callData).toEqual({
"": "inspect_delivery",
args: ["synthetic-reference"],
});
expect(simplified.txDataDecoded.leaderOnly).toBe(false);
});

it("should preserve a Map-shaped constructorArgs the same way", () => {
const tx = {
txDataDecoded: {
constructorArgs: new Map<string, unknown>([["owner", "0xabc"]]),
type: "deploy",
},
} as any;

const simplified = simplifyTransactionReceipt(tx) as any;

expect(simplified.txDataDecoded.constructorArgs).toEqual({owner: "0xabc"});
});
});