Skip to content

Commit

Permalink
🗞️ Move sleep() helper to io-devtools (#975)
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista authored Nov 4, 2024
1 parent 8e80fd6 commit 36446d0
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .changeset/serious-lizards-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@layerzerolabs/verify-contract": patch
"@layerzerolabs/io-devtools": patch
---

Add sleep helper to io-devtools
1 change: 1 addition & 0 deletions packages/io-devtools/src/async/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './time'
7 changes: 7 additions & 0 deletions packages/io-devtools/src/async/time.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Returns a promise that resolves after the specified number of milliseconds
*
* @param {number} timeout Nap time in milliseconds
* @returns {Promise<void>}
*/
export const sleep = (timeout: number): Promise<void> => new Promise<void>((resolve) => setTimeout(resolve, timeout))
1 change: 1 addition & 0 deletions packages/io-devtools/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './async'
export * from './config'
export * from './filesystem'
export * from './language'
Expand Down
4 changes: 2 additions & 2 deletions packages/verify-contract/src/common/etherscan.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type Logger } from '@layerzerolabs/io-devtools'
import { type Logger, sleep } from '@layerzerolabs/io-devtools'
import { LicenseType } from './licenses'
import { z } from 'zod'
import { retry, sleep } from './promises'
import { retry } from './promises'
import EventEmitter from 'events'
import got from 'got'

Expand Down
5 changes: 0 additions & 5 deletions packages/verify-contract/src/common/promises.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import assert from 'assert'

export const sleep = (timeout: number) =>
new Promise((resolve) => {
setTimeout(resolve, timeout)
})

/**
* Simple async retry functionality
*
Expand Down

0 comments on commit 36446d0

Please sign in to comment.