Skip to content

Commit

Permalink
Merge pull request #412 from docknetwork/upgrade-tweaks
Browse files Browse the repository at this point in the history
Several fixes
  • Loading branch information
olegnn authored Apr 5, 2024
2 parents 03a69e7 + 92cdfec commit c564cce
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docknetwork/sdk",
"version": "8.0.0",
"version": "8.0.1",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
14 changes: 6 additions & 8 deletions src/utils/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down Expand Up @@ -174,7 +173,7 @@ export class ReusablePromiseMap {
* @param {function(): Promise<T>} f
* @returns {Promise<T>}
*/
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) {
Expand Down Expand Up @@ -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`,
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/utils/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
);
Expand Down

0 comments on commit c564cce

Please sign in to comment.