-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@ew-did-registry/did-ipfs-store): is pinned when fully replicated
Showing
7 changed files
with
124 additions
and
65 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const DEFAULT_WAIT_FOR_INTERVAL = 1000; | ||
|
||
/** | ||
* @description asynchronously waits for fulfillment of given condition. Throws error if condition wasn't fulfilled in time | ||
* | ||
* @param condition asynchronous funtion which resolves to boolean | ||
* @param opts.timeout time to wait until `condition` is met, in seconds | ||
* @param opts.interval interval between `condition` checking attempts, in seconds | ||
* @returns | ||
*/ | ||
export const waitFor = async ( | ||
condition: () => Promise<boolean>, | ||
opts: { timeout: number; interval?: number } | ||
) => { | ||
const { timeout, interval = DEFAULT_WAIT_FOR_INTERVAL } = opts; | ||
return new Promise<void>((resolve, reject) => { | ||
let elapsedTime = 0; | ||
const scheduleNextCheck = () => | ||
setTimeout(async () => { | ||
elapsedTime += interval; | ||
try { | ||
if (await condition()) { | ||
resolve(); | ||
} else { | ||
if (elapsedTime > timeout) { | ||
reject(); | ||
} | ||
scheduleNextCheck(); | ||
} | ||
} catch (_) { | ||
scheduleNextCheck(); | ||
} | ||
}, interval); | ||
|
||
scheduleNextCheck(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
import { | ||
Contract, | ||
ContractFactory, | ||
providers, | ||
ethers, | ||
utils, | ||
constants, | ||
|