@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 +13 -16
- package/dist/index.mjs +13 -16
- package/package.json +1 -1
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
|
|
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
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
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
|
|
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
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
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;
|