]> git.ardis.lu - ens2hex/commitdiff
Use .map to generate batchPayload
authorArdis Lu <ardisglu@gmail.com>
Sun, 21 Aug 2022 06:40:00 +0000 (23:40 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sun, 21 Aug 2022 06:40:00 +0000 (23:40 -0700)
index.html

index d2df67e8feee3271197a0152fba02f8fe23050c7..7a25b03bb534e63ebe2e62a1e8cb598b4ab2ff3b 100644 (file)
       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',
This page took 0.039718 seconds and 4 git commands to generate.