]> git.ardis.lu - erc-1967-inspector/commitdiff
Wrap response in array if it is not an array
authorArdis Lu <ardisglu@gmail.com>
Thu, 10 Apr 2025 03:45:47 +0000 (20:45 -0700)
committerArdis Lu <ardisglu@gmail.com>
Thu, 10 Apr 2025 03:45:47 +0000 (20:45 -0700)
Some RPC providers (e.g., Google Blockchain RPC) will respond with a single object on error, which is not compliant with the JSON-RPC spec. Wrapping the response in an array then flattening ensures the result is an iterable, one-dimensional array.

index.html

index 839961a920dfc6805f745062fd95d4b877f222f1..f8b73c3545b0c2ceeb951c4e2d24079fe6ab427c 100644 (file)
       }).then(r => r.json());
 
       let recurseAddress = null;
-      for (const item of response) {
+      for (const item of [response].flat()) {
         if (item?.result === undefined || Number(item.result) === 0) {
           continue;
         }
       }).then(r => r.json());
 
       let recurseAddress = null;
-      for (const item of response) {
+      for (const item of [response].flat()) {
         if (item?.result === undefined) {
           continue;
         }
This page took 0.040732 seconds and 4 git commands to generate.