From 7219e286092b359c01de9313ff1db3f67fd52ee3 Mon Sep 17 00:00:00 2001 From: Ryan Goree Date: Thu, 29 Aug 2024 17:49:01 -0500 Subject: [PATCH 1/2] Refactor `evm-client-viem` to use `eth_getLogs` --- .../evm-client-viem/src/contract/createReadContract.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/evm-client-viem/src/contract/createReadContract.ts b/packages/evm-client-viem/src/contract/createReadContract.ts index 3873c3b..ba6831a 100644 --- a/packages/evm-client-viem/src/contract/createReadContract.ts +++ b/packages/evm-client-viem/src/contract/createReadContract.ts @@ -106,17 +106,14 @@ export function createReadContract({ }, async getEvents(eventName, options) { - const filter = await publicClient.createContractEventFilter({ - address: address, + const events = await publicClient.getContractEvents({ + address, abi: abi as Abi, eventName: eventName as string, - args: options?.filter, fromBlock: options?.fromBlock ?? 'earliest', toBlock: options?.toBlock ?? 'latest', }); - const events = await publicClient.getFilterLogs({ filter }); - return events.map(({ args, blockNumber, data, transactionHash }) => { const objectArgs = Array.isArray(args) ? arrayToObject({ From b19e51a0654d3eb97ed0f06210daa0d1c13a5b12 Mon Sep 17 00:00:00 2001 From: Ryan Goree Date: Thu, 29 Aug 2024 17:52:51 -0500 Subject: [PATCH 2/2] Add changeset --- .changeset/small-ravens-shake.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/small-ravens-shake.md diff --git a/.changeset/small-ravens-shake.md b/.changeset/small-ravens-shake.md new file mode 100644 index 0000000..f254106 --- /dev/null +++ b/.changeset/small-ravens-shake.md @@ -0,0 +1,5 @@ +--- +"@delvtech/evm-client-viem": patch +--- + +Refactor `getEvents` to use `eth_getLogs`