diff --git a/evm/evm-codec/src/abi-components/function.ts b/evm/evm-codec/src/abi-components/function.ts index 9c22d4e7e..2e9d31031 100644 --- a/evm/evm-codec/src/abi-components/function.ts +++ b/evm/evm-codec/src/abi-components/function.ts @@ -4,7 +4,7 @@ import { slotsCount } from "../utils"; import { Src } from "../src"; import assert from "node:assert"; -type FunctionReturn = T extends Codec +type FunctionReturn = T extends Codec ? U : T extends Struct ? StructTypes diff --git a/evm/evm-codec/test/array.test.ts b/evm/evm-codec/test/array.test.ts index 38e824aff..1737451e9 100644 --- a/evm/evm-codec/test/array.test.ts +++ b/evm/evm-codec/test/array.test.ts @@ -103,8 +103,8 @@ describe("dynamic size array", () => { ]; const data2 = [[1n, 2n, 3n], [], [4n]]; const data3 = [ - [Buffer.from("1234", "hex"), Buffer.from("5678", "hex")], - [Buffer.from("dead", "hex"), Buffer.from("beef", "hex")], + ["0x1234", "0x5678"], + ["0xdead", "0xbeef"], ]; arr1.encode(sink, data1); address.encode(sink, "0x1234567890123456789012345678901234567890"); diff --git a/evm/evm-codec/test/event.test.ts b/evm/evm-codec/test/event.test.ts index f466dd635..904c4042a 100644 --- a/evm/evm-codec/test/event.test.ts +++ b/evm/evm-codec/test/event.test.ts @@ -60,9 +60,9 @@ describe("Event", () => { ), }); expect(decoded).toEqual({ - a: Buffer.from(topics[1].slice(2), "hex"), + a: topics[1], b: "hello", - c: Buffer.from([0x12, 0x34]), + c: "0x1234", d: { _0: 100n, _1: "world" }, e: true, }); diff --git a/evm/evm-codec/test/function.test.ts b/evm/evm-codec/test/function.test.ts index 8c821b5de..6d2f010ae 100644 --- a/evm/evm-codec/test/function.test.ts +++ b/evm/evm-codec/test/function.test.ts @@ -60,12 +60,12 @@ describe("Function", () => { bar: [1n, 2n, 3n], str: { foo: 123n, - bar: Buffer.from([0x12, 0x34, 0x56, 0x78]), + bar: "0x12345678" as const, }, }, arg4: { foo: 100n, - bar: Buffer.from([0x12, 0x34, 0x56, 0x78]), + bar: "0x12345678" as const, }, }; const viemArgs = [ diff --git a/evm/evm-codec/test/src.test.ts b/evm/evm-codec/test/src.test.ts index 9f472dfe1..50c2f61aa 100644 --- a/evm/evm-codec/test/src.test.ts +++ b/evm/evm-codec/test/src.test.ts @@ -85,11 +85,9 @@ describe("src", () => { const src = new Src(encoded); expect(src.u8()).toBe(69); expect(src.string()).toBe(str1); - expect(src.staticBytes(7)).toStrictEqual( - Buffer.from(bytes7.slice(2), "hex") - ); + expect(src.staticBytes(7)).toStrictEqual(bytes7); expect(src.i128()).toBe(-21312312452243312424534213123123123123n); - expect(src.bytes()).toStrictEqual(bytes1); + expect(src.bytes()).toStrictEqual("0x" + bytes1.toString("hex")); expect(src.address()).toBe(address); expect(src.string()).toBe(str2); }); @@ -132,6 +130,6 @@ describe("src", () => { "hex" ); const src = new Src(encoded); - expect(src.bytes()).toStrictEqual(buffer); + expect(src.bytes()).toStrictEqual("0x" + buffer.toString("hex")); }); }); diff --git a/evm/evm-codec/test/struct.bench.ts b/evm/evm-codec/test/struct.bench.ts index 8cc8b9fb0..039c50d09 100644 --- a/evm/evm-codec/test/struct.bench.ts +++ b/evm/evm-codec/test/struct.bench.ts @@ -1,6 +1,6 @@ import { bench, describe } from "vitest"; import { address, array, Codec, Sink, Src, struct, uint256 } from "../src"; -import { decodeAbiParameters, encodeAbiParameters } from "viem"; +import { decodeAbiParameters, encodeAbiParameters, Hex } from "viem"; import { ethers } from "ethers"; const hugeArray = Array.from({ length: 1000 }, (_, i) => BigInt(i)); @@ -11,7 +11,7 @@ class InlinedStructCodec< b: bigint; c: { d: bigint[]; - e: string; + e: Hex; }; } > implements Codec diff --git a/evm/evm-codec/test/struct.test.ts b/evm/evm-codec/test/struct.test.ts index ae36948f3..0189dcb9f 100644 --- a/evm/evm-codec/test/struct.test.ts +++ b/evm/evm-codec/test/struct.test.ts @@ -138,7 +138,7 @@ describe("StructCodec", () => { bar: [1n, 2n, 3n], str: { foo: 123n, - bar: Uint8Array.from([0x12, 0x34, 0x56, 0x78]), + bar: "0x12345678" as const, }, }); compareTypes( @@ -177,7 +177,7 @@ describe("StructCodec", () => { bar: [1n, 2n, 3n], str: { foo: 123n, - bar: Buffer.from([0x12, 0x34, 0x56, 0x78]), + bar: "0x12345678", }, }); });