From 4240b67e877174805930a0b5b39307a13a8d2e86 Mon Sep 17 00:00:00 2001 From: Dylan-Kerler Date: Fri, 25 Jun 2021 13:59:22 +0100 Subject: [PATCH 1/2] Add arg configuration to proxyAdmin and allow name to act as artifact --- README.md | 5 +++-- src/helpers.ts | 25 +++++++++++++++++++++---- types.ts | 1 + 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 953eb14b..ee6c4592 100644 --- a/README.md +++ b/README.md @@ -1080,8 +1080,9 @@ type ProxyOptionsBase = { viaAdminContract?: // allow to specify a contract that act as a middle man to perform upgrades. Useful and Recommended for Transparent Proxies | string | { - name: string; - artifact?: string | ArtifactData; + name: string; // Custom name - If no artifact name is specified, it will also act as the artifact name + artifact?: string | ArtifactData; // Custom artifact name + args?: any[]; // Arguments that will be passed to the AdminContract constructor }; }; diff --git a/src/helpers.ts b/src/helpers.ts index 9406704a..38bddc39 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -886,7 +886,11 @@ export function addHelpers( let checkABIConflict = true; let viaAdminContract: | string - | {name: string; artifact?: string | ArtifactData} + | { + name: string; + artifact?: string | ArtifactData; + args?: any[]; + } | undefined; if (typeof options.proxy === 'object') { upgradeIndex = options.proxy.upgradeIndex; @@ -1065,9 +1069,16 @@ Note that in this case, the contract deployment will not behave the same if depl } else { proxyAdminName = viaAdminContract.name; if (!viaAdminContract.artifact) { - proxyAdminDeployed = await partialExtension.get(proxyAdminName); + try { + proxyAdminDeployed = await partialExtension.get(proxyAdminName); + } catch (e) { + console.log( + `ProxyAdmin deploy not found - Deploying new ProxyAdmin: ${proxyAdminName}` + ); + } } - proxyAdminArtifactNameOrContract = viaAdminContract.artifact; + proxyAdminArtifactNameOrContract = + viaAdminContract.artifact || viaAdminContract.name; } let proxyAdminContract: ExtendedArtifact | undefined; @@ -1092,6 +1103,12 @@ Note that in this case, the contract deployment will not behave the same if depl } if (!proxyAdminDeployed) { + const args = + typeof options?.proxy === 'object' && + typeof options.proxy.viaAdminContract === 'object' + ? options.proxy.viaAdminContract?.args || [owner] + : [owner]; + proxyAdminDeployed = await _deployOne(proxyAdminName, { from: options.from, autoMine: options.autoMine, @@ -1102,7 +1119,7 @@ Note that in this case, the contract deployment will not behave the same if depl contract: proxyAdminContract, deterministicDeployment: options.deterministicDeployment, skipIfAlreadyDeployed: true, - args: [owner], + args, }); } diff --git a/types.ts b/types.ts index 2a5650b1..53e7a2e6 100644 --- a/types.ts +++ b/types.ts @@ -93,6 +93,7 @@ type ProxyOptionsBase = { | { name: string; artifact?: string | ArtifactData; + args: any[]; }; }; From 0200d4b02c25d203716a4a026ea196005325b9e5 Mon Sep 17 00:00:00 2001 From: Dylan-Kerler Date: Mon, 12 Jul 2021 13:50:49 +0100 Subject: [PATCH 2/2] Remove log --- src/helpers.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/helpers.ts b/src/helpers.ts index 38bddc39..7c933016 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -1071,11 +1071,7 @@ Note that in this case, the contract deployment will not behave the same if depl if (!viaAdminContract.artifact) { try { proxyAdminDeployed = await partialExtension.get(proxyAdminName); - } catch (e) { - console.log( - `ProxyAdmin deploy not found - Deploying new ProxyAdmin: ${proxyAdminName}` - ); - } + } catch (e) {} } proxyAdminArtifactNameOrContract = viaAdminContract.artifact || viaAdminContract.name;