hardhat
Version:
Hardhat is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.
39 lines • 1.93 kB
JavaScript
let UserInterruptionManagerImplementation;
export class LazyUserInterruptionManager {
#hooks;
#userInterruptionManager;
constructor(hooks) {
this.#hooks = hooks;
}
async displayMessage(interruptor, message) {
const userInterruptionManager = await this.#getUserInterruptionManager();
return await userInterruptionManager.displayMessage(interruptor, message);
}
async requestInput(interruptor, inputDescription) {
const userInterruptionManager = await this.#getUserInterruptionManager();
return await userInterruptionManager.requestInput(interruptor, inputDescription);
}
async requestSecretInput(interruptor, inputDescription) {
const userInterruptionManager = await this.#getUserInterruptionManager();
return await userInterruptionManager.requestSecretInput(interruptor, inputDescription);
}
async uninterrupted(f) {
const userInterruptionManager = await this.#getUserInterruptionManager();
return await userInterruptionManager.uninterrupted(f);
}
async #getUserInterruptionManager() {
// Note: `await import` must run BEFORE the instance cache check so that
// concurrent callers share a single microtask-dedupe point — otherwise
// each suspended caller re-enters the branch and constructs its own
// impl, so callers end up holding different impl instances and state,
// which can cause concurrency issues.
if (UserInterruptionManagerImplementation === undefined) {
({ UserInterruptionManagerImplementation } = await import("./user-interruptions.js"));
}
if (this.#userInterruptionManager === undefined) {
this.#userInterruptionManager = new UserInterruptionManagerImplementation(this.#hooks);
}
return this.#userInterruptionManager;
}
}
//# sourceMappingURL=lazy-user-interruptions.js.map