diff --git a/src/venn/enable/enable.command.ts b/src/venn/enable/enable.command.ts index e11f926..08e447c 100644 --- a/src/venn/enable/enable.command.ts +++ b/src/venn/enable/enable.command.ts @@ -60,4 +60,12 @@ export class EnableVennCommand extends CommandRunner { parseSubnets(subnet: string, subnetsAccumulator: string[] = []): number[] { return [...subnetsAccumulator, subnet].map(Number).sort(); } + + @Option({ + flags: '-p, --policy
', + description: 'use a custom policy address instead of deploying a new one', + }) + parsePolicy(policy: string): string { + return policy; + } } diff --git a/src/venn/enable/enable.service.ts b/src/venn/enable/enable.service.ts index 66d5655..3e76da8 100644 --- a/src/venn/enable/enable.service.ts +++ b/src/venn/enable/enable.service.ts @@ -24,6 +24,7 @@ export type EnableVennOptions = { network: SupportedVennNetworks; dryRun: boolean; subnets?: number[]; + policy?: string; }; type ContractInformation = { @@ -49,17 +50,27 @@ export class EnableVennService { const contracts = await this.getContractsInformation(networkConfig, provider, options.network); - const newPolicyAddress = await this.deployNewVennPolicy(contracts, wallet, networkConfig, provider); + let policyAddress: string; + if (options.policy) { + // Use custom policy address + policyAddress = await this.validatePolicyAddress(options.policy); + this.logger.step('Using custom policy address'); + this.logger.log(` -> Policy address: ${colors.cyan(policyAddress)}`); + } else { + // Deploy new policy with default configuration + policyAddress = await this.deployNewVennPolicy(contracts, wallet, networkConfig, provider); + } + await this.setFirewallOnConsumers(contracts, networkConfig, wallet, options.network, provider); if (options.dryRun) { await this.enableDryRun(contracts, networkConfig, wallet, provider); } - await this.setAttestationCenterProxyOnConsumers(contracts, networkConfig, wallet, newPolicyAddress, provider); - await this.subscribeConsumersToNewPolicy(contracts, newPolicyAddress, wallet, networkConfig, provider); - await this.registerContractsInProtocolRegistry(newPolicyAddress, networkConfig, wallet, provider); - await this.subscribeToRootSubnet(newPolicyAddress, networkConfig, wallet, provider, subnets); + await this.setAttestationCenterProxyOnConsumers(contracts, networkConfig, wallet, policyAddress, provider); + await this.subscribeConsumersToNewPolicy(contracts, policyAddress, wallet, networkConfig, provider); + await this.registerContractsInProtocolRegistry(policyAddress, networkConfig, wallet, provider); + await this.subscribeToRootSubnet(policyAddress, networkConfig, wallet, provider, subnets); } private async deployNewVennPolicy( @@ -578,4 +589,12 @@ export class EnableVennService { this.logger.debug(` -> Network Safe Call Target address: ${networkAddress}`); return setAddress === networkAddress; } + + private async validatePolicyAddress(policyAddress: string): Promise