From dec7d2f08397a84db1a915e396916c22cf97a0a4 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Wed, 14 Aug 2024 17:28:33 +0100 Subject: [PATCH] make install optional --- packages/cli/src/deploy/common.ts | 5 +++++ packages/cli/src/deploy/configToModules.ts | 1 + packages/cli/src/deploy/ensureModules.ts | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/packages/cli/src/deploy/common.ts b/packages/cli/src/deploy/common.ts index 8116043f2b..93cf8797a1 100644 --- a/packages/cli/src/deploy/common.ts +++ b/packages/cli/src/deploy/common.ts @@ -100,4 +100,9 @@ export type Module = DeterministicContract & { readonly name: string; readonly installAsRoot: boolean; readonly installData: Hex; // TODO: figure out better naming for this + /** + * @internal + * Optional modules warn instead of throw if they revert while being installed. + */ + readonly optional?: boolean; }; diff --git a/packages/cli/src/deploy/configToModules.ts b/packages/cli/src/deploy/configToModules.ts index f3186708e2..9eeeaa101b 100644 --- a/packages/cli/src/deploy/configToModules.ts +++ b/packages/cli/src/deploy/configToModules.ts @@ -28,6 +28,7 @@ export async function configToModules( ): Promise { const defaultModules: Module[] = [ { + optional: true, name: "MetadataModule", installAsRoot: false, installData: "0x", diff --git a/packages/cli/src/deploy/ensureModules.ts b/packages/cli/src/deploy/ensureModules.ts index 2fa5ef310a..45df2ad83d 100644 --- a/packages/cli/src/deploy/ensureModules.ts +++ b/packages/cli/src/deploy/ensureModules.ts @@ -59,6 +59,12 @@ export async function ensureModules({ args: [moduleAddress, mod.installData], }); } catch (error) { + if (mod.optional) { + debug( + `optional module ${mod.name} install failed, skipping\n ${error instanceof BaseError ? error.shortMessage : error}`, + ); + return; + } if (error instanceof BaseError && error.message.includes("Module_AlreadyInstalled")) { debug(`module ${mod.name} already installed`); return;