From fbd40ada31a64e39f3caa6bd3987d77255209ca6 Mon Sep 17 00:00:00 2001 From: jpsains <32621022+jpsains@users.noreply.github.com> Date: Fri, 7 Jun 2024 08:42:29 +0100 Subject: [PATCH] feat: get polygon log (#253) --- packages/adapters-library/src/config.ts | 2 +- .../src/core/provider/CustomJsonRpcProvider.ts | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/adapters-library/src/config.ts b/packages/adapters-library/src/config.ts index 04b86cfc5..419227252 100644 --- a/packages/adapters-library/src/config.ts +++ b/packages/adapters-library/src/config.ts @@ -101,7 +101,7 @@ const ConfigSchema = z ethereum: z.boolean().default(true), optimism: z.boolean().default(true), bsc: z.boolean().default(false), - polygon: z.boolean().default(false), + polygon: z.boolean().default(true), fantom: z.boolean().default(false), base: z.boolean().default(true), arbitrum: z.boolean().default(true), diff --git a/packages/adapters-library/src/core/provider/CustomJsonRpcProvider.ts b/packages/adapters-library/src/core/provider/CustomJsonRpcProvider.ts index 73f5547e4..64122504a 100644 --- a/packages/adapters-library/src/core/provider/CustomJsonRpcProvider.ts +++ b/packages/adapters-library/src/core/provider/CustomJsonRpcProvider.ts @@ -169,6 +169,24 @@ export class CustomJsonRpcProvider extends JsonRpcProvider { throw new NotSupportedUnlimitedGetLogsBlockRange() } + if (this.chainId === Chain.Polygon) { + const transferEventSignature = ethers.id( + 'Transfer(address,address,uint256)', + ) + + const transferFilter = { + fromBlock: 0, + toBlock: 'latest', + topics: [ + transferEventSignature, + '0x0000000000000000000000000000000000000000000000000000000000000000', + ethers.zeroPadValue(address, 32), // to address + ], + } + + return this.getLogs(transferFilter) + } + const transferEventSignature = ethers.id( 'Transfer(address,address,uint256)', )