From 97b13a053096547db0e8a79df3464e4fe78734ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renaud?= Date: Mon, 25 Mar 2024 22:31:03 +0100 Subject: [PATCH] feat(governance): cleaner logs when pulling proxy admin address (#13517) * cleaner logs when `DEPLOYER_PRIVATE_KEY` is not set * get proxy admin address directly from unlock * log admin+ multisig * remove overkill marks * log depoyer key env set correctly --- governance/scripts/getters/unlock-info.js | 39 ++++++++++------------- packages/hardhat-helpers/src/networks.js | 14 ++++++-- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/governance/scripts/getters/unlock-info.js b/governance/scripts/getters/unlock-info.js index 0f9d7078a8c..838b09c37da 100644 --- a/governance/scripts/getters/unlock-info.js +++ b/governance/scripts/getters/unlock-info.js @@ -1,9 +1,5 @@ const { ethers } = require('hardhat') -const { - getNetwork, - getUnlock, - getProxyAdminAddress, -} = require('@unlock-protocol/hardhat-helpers') +const { getNetwork, getUnlock } = require('@unlock-protocol/hardhat-helpers') const { abi: proxyAdminABI, } = require('@unlock-protocol/hardhat-helpers/dist/ABIs/ProxyAdmin.json') @@ -12,7 +8,7 @@ const getOwners = require('../multisig/owners') async function main({ unlockAddress, quiet = false }) { let safeAddress - const { id: chainId, name } = await getNetwork() + const { name } = await getNetwork() if (!unlockAddress) { ;({ unlockAddress, multisig: safeAddress } = await getNetwork()) } @@ -23,34 +19,30 @@ async function main({ unlockAddress, quiet = false }) { const unlockOwner = await unlock.owner() const isMultisig = safeAddress === unlockOwner - let proxyAdminAddress, proxyAdminOwner - try { - proxyAdminAddress = await getProxyAdminAddress({ chainId }) - } catch (error) { - errorLog(`ERROR: Failed to fetch ProxyAdmin address`) - } + const proxyAdminAddress = await unlock.getAdmin() - if (proxyAdminAddress) { - const proxyAdmin = await ethers.getContractAt( - proxyAdminABI, - proxyAdminAddress - ) - proxyAdminOwner = await proxyAdmin.owner() - } + const proxyAdmin = await ethers.getContractAt( + proxyAdminABI, + proxyAdminAddress + ) + const proxyAdminOwner = await proxyAdmin.owner() if (proxyAdminOwner !== unlockOwner) { - errorLog(`Unlock contract and ProxyAdmin have different owners!`) + errorLog(`Unlock contract and ProxyAdmin have different owners`) + } + if (proxyAdminOwner !== safeAddress) { + errorLog(`ProxyAdmin owner is not the team multisig`) } let nbOwners try { nbOwners = (await getOwners({ safeAddress: unlockOwner })).length } catch (error) { - errorLog(`Unlock owner is not the team multisig (${safeAddress})!`) + errorLog(`Unlock owner is not the team multisig`) } if (nbOwners && !isMultisig) { - errorLog(`Multisig in networks package does not match with Unlock owner!`) + errorLog(`Multisig in networks package does not match with Unlock owner`) } if (!quiet) { @@ -60,7 +52,8 @@ async function main({ unlockAddress, quiet = false }) { `- unlockVersion: ${await unlock.unlockVersion()} \n`, `- publicLockVersion: ${await unlock.publicLockLatestVersion()} \n`, `- owner: ${unlockOwner} ${nbOwners ? `(${nbOwners} owners)` : ''}\n`, - `- proxyAdminAddress: ${proxyAdminAddress} \n` + `- proxyAdminAddress: ${proxyAdminAddress} \n`, + `- multisig: ${safeAddress} \n` ) } } diff --git a/packages/hardhat-helpers/src/networks.js b/packages/hardhat-helpers/src/networks.js index 601d510db8d..a4c61bf35c1 100644 --- a/packages/hardhat-helpers/src/networks.js +++ b/packages/hardhat-helpers/src/networks.js @@ -17,6 +17,17 @@ const networks = require('@unlock-protocol/networks') * @returns */ const { DEPLOYER_PRIVATE_KEY } = process.env + +if (!DEPLOYER_PRIVATE_KEY) { + console.error( + `⚠️ Missing DEPLOYER_PRIVATE_KEY environment variable. Please set one. In the meantime, we will use default settings` + ) +} else { + console.error( + `⚠️ Using account from DEPLOYER_PRIVATE_KEY environment variable.` + ) +} + const getAccounts = () => { if (process.env.CI === 'true') { return { @@ -28,9 +39,6 @@ const getAccounts = () => { return [DEPLOYER_PRIVATE_KEY] } - console.error( - `Missing DEPLOYER_PRIVATE_KEY environment variable. Please set one. In the meantime, we will use default settings` - ) return { mnemonic: 'test test test test test test test test test test test junk', initialIndex: 0,