Skip to content

Commit

Permalink
make install optional
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Aug 14, 2024
1 parent f6d872b commit dec7d2f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/cli/src/deploy/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
1 change: 1 addition & 0 deletions packages/cli/src/deploy/configToModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export async function configToModules<config extends World>(
): Promise<readonly Module[]> {
const defaultModules: Module[] = [
{
optional: true,
name: "MetadataModule",
installAsRoot: false,
installData: "0x",
Expand Down
6 changes: 6 additions & 0 deletions packages/cli/src/deploy/ensureModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit dec7d2f

Please sign in to comment.