Skip to content

Commit 89c93f8

Browse files
committed
integrate user interruptions flow with ignition UI
1 parent cc35ab0 commit 89c93f8

File tree

21 files changed

+338
-517
lines changed

21 files changed

+338
-517
lines changed

v-next/hardhat-ignition-core/src/deploy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ export async function deploy<
8181
);
8282

8383
if (executionEventListener !== undefined) {
84-
executionEventListener.setModuleId({
84+
await executionEventListener.setModuleId({
8585
type: ExecutionEventType.SET_MODULE_ID,
8686
moduleName: ignitionModule.id,
8787
});
8888

89-
executionEventListener.setStrategy({
89+
await executionEventListener.setStrategy({
9090
type: ExecutionEventType.SET_STRATEGY,
9191
strategy: executionStrategy.name,
9292
});
@@ -101,7 +101,7 @@ export async function deploy<
101101

102102
if (validationResult !== null) {
103103
if (executionEventListener !== undefined) {
104-
executionEventListener.deploymentComplete({
104+
await executionEventListener.deploymentComplete({
105105
type: ExecutionEventType.DEPLOYMENT_COMPLETE,
106106
result: validationResult,
107107
});

v-next/hardhat-ignition-core/src/internal/deployer.ts

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class Deployer {
8181
const isResumed = deployment.isResumed;
8282
let deploymentState = deployment.deploymentState;
8383

84-
this._emitDeploymentStartEvent(
84+
await this._emitDeploymentStartEvent(
8585
ignitionModule.id,
8686
this._deploymentDir,
8787
isResumed,
@@ -140,7 +140,7 @@ export class Deployer {
140140
errors,
141141
};
142142

143-
this._emitDeploymentCompleteEvent(reconciliationErrorResult);
143+
await this._emitDeploymentCompleteEvent(reconciliationErrorResult);
144144

145145
return reconciliationErrorResult;
146146
}
@@ -164,23 +164,23 @@ export class Deployer {
164164
errors,
165165
};
166166

167-
this._emitDeploymentCompleteEvent(previousRunErrorResult);
167+
await this._emitDeploymentCompleteEvent(previousRunErrorResult);
168168

169169
return previousRunErrorResult;
170170
}
171171

172172
if (reconciliationResult.missingExecutedFutures.length > 0) {
173-
this._emitReconciliationWarningsEvent(
173+
await this._emitReconciliationWarningsEvent(
174174
reconciliationResult.missingExecutedFutures,
175175
);
176176
}
177177

178178
const batches = Batcher.batch(ignitionModule, deploymentState);
179179

180-
this._emitDeploymentBatchEvent(batches);
180+
await this._emitDeploymentBatchEvent(batches);
181181

182182
if (this._hasBatchesToExecute(batches)) {
183-
this._emitRunStartEvent();
183+
await this._emitRunStartEvent();
184184

185185
const executionEngine = new ExecutionEngine(
186186
this._deploymentLoader,
@@ -210,7 +210,7 @@ export class Deployer {
210210
ignitionModule,
211211
);
212212

213-
this._emitDeploymentCompleteEvent(result);
213+
await this._emitDeploymentCompleteEvent(result);
214214

215215
return result;
216216
}
@@ -273,18 +273,18 @@ export class Deployer {
273273
return { deploymentState, isResumed: true };
274274
}
275275

276-
private _emitDeploymentStartEvent(
276+
private async _emitDeploymentStartEvent(
277277
moduleId: string,
278278
deploymentDir: string | undefined,
279279
isResumed: boolean,
280280
maxFeeBumps: number,
281281
disableFeeBumping: boolean,
282-
): void {
282+
): Promise<void> {
283283
if (this._executionEventListener === undefined) {
284284
return;
285285
}
286286

287-
this._executionEventListener.deploymentStart({
287+
await this._executionEventListener.deploymentStart({
288288
type: ExecutionEventType.DEPLOYMENT_START,
289289
moduleName: moduleId,
290290
deploymentDir: deploymentDir ?? undefined,
@@ -294,44 +294,48 @@ export class Deployer {
294294
});
295295
}
296296

297-
private _emitReconciliationWarningsEvent(warnings: string[]): void {
297+
private async _emitReconciliationWarningsEvent(
298+
warnings: string[],
299+
): Promise<void> {
298300
if (this._executionEventListener === undefined) {
299301
return;
300302
}
301303

302-
this._executionEventListener.reconciliationWarnings({
304+
await this._executionEventListener.reconciliationWarnings({
303305
type: ExecutionEventType.RECONCILIATION_WARNINGS,
304306
warnings,
305307
});
306308
}
307309

308-
private _emitDeploymentBatchEvent(batches: string[][]): void {
310+
private async _emitDeploymentBatchEvent(batches: string[][]): Promise<void> {
309311
if (this._executionEventListener === undefined) {
310312
return;
311313
}
312314

313-
this._executionEventListener.batchInitialize({
315+
await this._executionEventListener.batchInitialize({
314316
type: ExecutionEventType.BATCH_INITIALIZE,
315317
batches,
316318
});
317319
}
318320

319-
private _emitRunStartEvent(): void {
321+
private async _emitRunStartEvent(): Promise<void> {
320322
if (this._executionEventListener === undefined) {
321323
return;
322324
}
323325

324-
this._executionEventListener.runStart({
326+
await this._executionEventListener.runStart({
325327
type: ExecutionEventType.RUN_START,
326328
});
327329
}
328330

329-
private _emitDeploymentCompleteEvent(result: DeploymentResult): void {
331+
private async _emitDeploymentCompleteEvent(
332+
result: DeploymentResult,
333+
): Promise<void> {
330334
if (this._executionEventListener === undefined) {
331335
return;
332336
}
333337

334-
this._executionEventListener.deploymentComplete({
338+
await this._executionEventListener.deploymentComplete({
335339
type: ExecutionEventType.DEPLOYMENT_COMPLETE,
336340
result,
337341
});

v-next/hardhat-ignition-core/src/internal/deployment-loader/ephemeral-deployment-loader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class EphemeralDeploymentLoader implements DeploymentLoader {
3838
}
3939

4040
public async recordToJournal(message: JournalMessage): Promise<void> {
41-
this._journal.record(message);
41+
await this._journal.record(message);
4242
}
4343

4444
public readFromJournal(): AsyncGenerator<JournalMessage, any, unknown> {

v-next/hardhat-ignition-core/src/internal/deployment-loader/file-deployment-loader.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ export class FileDeploymentLoader implements DeploymentLoader {
6262
public async recordToJournal(message: JournalMessage): Promise<void> {
6363
await this._initialize();
6464

65-
// NOTE: the journal record is sync, even though this call is async
66-
this._journal.record(message);
65+
await this._journal.record(message);
6766
}
6867

6968
public readFromJournal(): AsyncGenerator<JournalMessage, any, unknown> {

v-next/hardhat-ignition-core/src/internal/execution/execution-engine.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class ExecutionEngine {
112112
const futures = getFuturesFromModule(module);
113113

114114
for (const batch of batches) {
115-
this._emitBeginNextBatchEvent();
115+
await this._emitBeginNextBatchEvent();
116116

117117
// TODO: consider changing batcher to return futures rather than ids
118118
const executionBatch = batch.map((futureId) =>
@@ -331,9 +331,9 @@ export class ExecutionEngine {
331331
/**
332332
* Emits an execution event signaling that execution of the next batch has begun.
333333
*/
334-
private _emitBeginNextBatchEvent(): void {
334+
private async _emitBeginNextBatchEvent(): Promise<void> {
335335
if (this._executionEventListener !== undefined) {
336-
this._executionEventListener.beginNextBatch({
336+
await this._executionEventListener.beginNextBatch({
337337
type: ExecutionEventType.BEGIN_NEXT_BATCH,
338338
});
339339
}

v-next/hardhat-ignition-core/src/internal/journal/file-journal.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export class FileJournal implements Journal {
2424
| undefined,
2525
) {}
2626

27-
public record(message: JournalMessage): void {
28-
this._log(message);
27+
public async record(message: JournalMessage): Promise<void> {
28+
await this._log(message);
2929

3030
this._appendJsonLine(this._filePath, message);
3131
}
@@ -66,9 +66,9 @@ export class FileJournal implements Journal {
6666
closeSync(fd);
6767
}
6868

69-
private _log(message: JournalMessage): void {
69+
private async _log(message: JournalMessage): Promise<void> {
7070
if (this._executionEventListener !== undefined) {
71-
emitExecutionEvent(message, this._executionEventListener);
71+
await emitExecutionEvent(message, this._executionEventListener);
7272
}
7373
}
7474
}

v-next/hardhat-ignition-core/src/internal/journal/memory-journal.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export class MemoryJournal implements Journal {
1818
| undefined,
1919
) {}
2020

21-
public record(message: JournalMessage): void {
22-
this._log(message);
21+
public async record(message: JournalMessage): Promise<void> {
22+
await this._log(message);
2323

2424
this._messages.push(message);
2525
}
@@ -30,9 +30,9 @@ export class MemoryJournal implements Journal {
3030
}
3131
}
3232

33-
private _log(message: JournalMessage): void {
33+
private async _log(message: JournalMessage): Promise<void> {
3434
if (this._executionEventListener !== undefined) {
35-
emitExecutionEvent(message, this._executionEventListener);
35+
await emitExecutionEvent(message, this._executionEventListener);
3636
}
3737
}
3838
}

v-next/hardhat-ignition-core/src/internal/journal/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { JournalMessage } from "../../execution/types/messages.js";
66
* @beta
77
*/
88
export interface Journal {
9-
record(message: JournalMessage): void;
9+
record(message: JournalMessage): Promise<void>;
1010

1111
read(): AsyncGenerator<JournalMessage>;
1212
}

0 commit comments

Comments
 (0)