From: Ardis Lu Date: Sun, 21 Aug 2022 06:40:00 +0000 (-0700) Subject: Use .map to generate batchPayload X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=d0cc1c1337c7d61f3b0ba45c7f6436f68989caff;p=ens2hex Use .map to generate batchPayload --- 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',