From d0cc1c1337c7d61f3b0ba45c7f6436f68989caff Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Sat, 20 Aug 2022 23:40:00 -0700 Subject: [PATCH] Use .map to generate batchPayload --- index.html | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/index.html b/index.html index d2df67e..7a25b03 100644 --- a/index.html +++ b/index.html @@ -124,21 +124,18 @@ const parsed = new Set(combined.split('\n').map(c => c.split(',')).flat().map(e => e.trim())); // Split on newline or comma, flatten, trim whitespace, de-duplicate const cleaned = [...parsed].filter(name => name.slice(-4) === '.eth'); // Remove anything that does not end in '.eth' - const batchPayload = []; - for (const [index, name] of cleaned.entries()) { - batchPayload.push({ - jsonrpc: '2.0', - method: 'eth_call', - params: [ - { - to: '0x4976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41', // ENS PublicResolver - data: `0x3b3b57de${namehash(name)}` // 0x3b3b57de is the byte signature for the function "addr(bytes32)" in ENS PublicResolver - }, - 'latest' - ], - id: index - }); - } + const batchPayload = cleaned.map((name, index) => ({ + jsonrpc: '2.0', + method: 'eth_call', + params: [ + { + to: '0x4976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41', // ENS PublicResolver + data: `0x3b3b57de${namehash(name)}` // 0x3b3b57de is the byte signature for the function "addr(bytes32)" in ENS PublicResolver + }, + 'latest' + ], + id: index + })); const batchResponse = await fetch('https://cloudflare-eth.com/', { method: 'POST', -- 2.47.3