From 92cdfec60f2e3e109005269c418c40be275fbba0 Mon Sep 17 00:00:00 2001 From: Oleg Nosov Date: Fri, 5 Apr 2024 16:09:30 +0000 Subject: [PATCH] Fixes --- package.json | 2 +- src/utils/async.js | 14 ++++++-------- src/utils/block.js | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 0fda2a421..21659d3dc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@docknetwork/sdk", - "version": "8.0.0", + "version": "8.0.1", "main": "index.js", "license": "MIT", "repository": { diff --git a/src/utils/async.js b/src/utils/async.js index 8585b3f61..a06c354f2 100644 --- a/src/utils/async.js +++ b/src/utils/async.js @@ -114,14 +114,13 @@ export class ReusablePromiseMap { err = e; } finally { const hasQueued = Boolean(this.queue.length); - let deleted = false; if (hasQueued || !this.save || err != null) { - deleted = this.map.get(key) === promise && this.map.delete(key); - } + const deleted = this.map.get(key) === promise && this.map.delete(key); - if (deleted) { - this.shiftQueuedItems(1); + if (deleted) { + this.shiftQueuedItems(1); + } } } @@ -174,7 +173,7 @@ export class ReusablePromiseMap { * @param {function(): Promise} f * @returns {Promise} */ -export const timeout = async (time, f = () => {}) => await new Promise((resolve, reject) => setTimeout(async () => { +export const timeout = async (time, f = () => { }) => await new Promise((resolve, reject) => setTimeout(async () => { try { resolve(await f()); } catch (err) { @@ -264,8 +263,7 @@ export const retry = async ( } throw new Error( - `Promise created by \`${fn}\` didn't resolve within the specified timeout of ${timeLimit} ms ${ - maxAttempts + 1 + `Promise created by \`${fn}\` didn't resolve within the specified timeout of ${timeLimit} ms ${maxAttempts + 1 } times`, ); }; diff --git a/src/utils/block.js b/src/utils/block.js index ed92b0b59..1ba9e81e7 100644 --- a/src/utils/block.js +++ b/src/utils/block.js @@ -91,7 +91,7 @@ export class BlocksProvider { // Fetch the latest block number. It will be recorded in the `this.maxBlockNumber`. await this.lastNumber(); - if (number.toNumber() > this.maxBlockNumber) { + if (number > this.maxBlockNumber) { throw new Error( `Provided block's number ${number} is higher than the latest known block number ${this.maxBlockNumber}`, );