@orbinum/sdk 0.7.5 → 0.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -777,14 +777,7 @@ var EvmExplorer = class _EvmExplorer {
777
777
  async getLatestBlocks(count = 10) {
778
778
  const latest = await this.evm.getBlockNumber();
779
779
  const nums = Array.from({ length: Math.min(count, latest + 1) }, (_, i) => latest - i);
780
- const results = await Promise.all(
781
- nums.map(
782
- (n) => this.evm.request("eth_getBlockByNumber", [
783
- `0x${n.toString(16)}`,
784
- false
785
- ]).catch(() => null)
786
- )
787
- );
780
+ const results = await this.evm.batchRequest(nums.map((n) => ({ method: "eth_getBlockByNumber", params: [`0x${n.toString(16)}`, false] }))).catch(() => nums.map(() => null));
788
781
  return results.filter((b) => b !== null && !!b.hash).map((b) => this.parseBlock(b));
789
782
  }
790
783
  /** Returns a single block by number or hash, or `null` if not found. */
@@ -827,14 +820,18 @@ var EvmExplorer = class _EvmExplorer {
827
820
  const latest = await this.evm.getBlockNumber();
828
821
  const from = Math.max(0, latest - maxBlocks + 1);
829
822
  const blockNums = Array.from({ length: latest - from + 1 }, (_, i) => latest - i);
830
- const blocks = await Promise.all(
831
- blockNums.map(
832
- (n) => this.evm.request("eth_getBlockByNumber", [
833
- `0x${n.toString(16)}`,
834
- true
835
- ]).catch(() => null)
836
- )
837
- );
823
+ const CHUNK = 50;
824
+ const blocks = [];
825
+ for (let i = 0; i < blockNums.length; i += CHUNK) {
826
+ const slice = blockNums.slice(i, i + CHUNK);
827
+ const part = await this.evm.batchRequest(
828
+ slice.map((n) => ({
829
+ method: "eth_getBlockByNumber",
830
+ params: [`0x${n.toString(16)}`, true]
831
+ }))
832
+ ).catch(() => slice.map(() => null));
833
+ blocks.push(...part);
834
+ }
838
835
  const matchingTxs = [];
839
836
  for (const block of blocks) {
840
837
  if (!block?.transactions) continue;
package/dist/index.mjs CHANGED
@@ -650,14 +650,7 @@ var EvmExplorer = class _EvmExplorer {
650
650
  async getLatestBlocks(count = 10) {
651
651
  const latest = await this.evm.getBlockNumber();
652
652
  const nums = Array.from({ length: Math.min(count, latest + 1) }, (_, i) => latest - i);
653
- const results = await Promise.all(
654
- nums.map(
655
- (n) => this.evm.request("eth_getBlockByNumber", [
656
- `0x${n.toString(16)}`,
657
- false
658
- ]).catch(() => null)
659
- )
660
- );
653
+ const results = await this.evm.batchRequest(nums.map((n) => ({ method: "eth_getBlockByNumber", params: [`0x${n.toString(16)}`, false] }))).catch(() => nums.map(() => null));
661
654
  return results.filter((b) => b !== null && !!b.hash).map((b) => this.parseBlock(b));
662
655
  }
663
656
  /** Returns a single block by number or hash, or `null` if not found. */
@@ -700,14 +693,18 @@ var EvmExplorer = class _EvmExplorer {
700
693
  const latest = await this.evm.getBlockNumber();
701
694
  const from = Math.max(0, latest - maxBlocks + 1);
702
695
  const blockNums = Array.from({ length: latest - from + 1 }, (_, i) => latest - i);
703
- const blocks = await Promise.all(
704
- blockNums.map(
705
- (n) => this.evm.request("eth_getBlockByNumber", [
706
- `0x${n.toString(16)}`,
707
- true
708
- ]).catch(() => null)
709
- )
710
- );
696
+ const CHUNK = 50;
697
+ const blocks = [];
698
+ for (let i = 0; i < blockNums.length; i += CHUNK) {
699
+ const slice = blockNums.slice(i, i + CHUNK);
700
+ const part = await this.evm.batchRequest(
701
+ slice.map((n) => ({
702
+ method: "eth_getBlockByNumber",
703
+ params: [`0x${n.toString(16)}`, true]
704
+ }))
705
+ ).catch(() => slice.map(() => null));
706
+ blocks.push(...part);
707
+ }
711
708
  const matchingTxs = [];
712
709
  for (const block of blocks) {
713
710
  if (!block?.transactions) continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbinum/sdk",
3
- "version": "0.7.5",
3
+ "version": "0.7.6",
4
4
  "description": "Official TypeScript SDK for Orbinum.",
5
5
  "author": "Orbinum",
6
6
  "license": "MIT",