Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(governance): cleaner logs when pulling proxy admin address #13517

Merged
merged 5 commits into from Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 16 additions & 23 deletions 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')
Expand All @@ -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())
}
Expand All @@ -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) {
Expand All @@ -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`
)
}
}
Expand Down
14 changes: 11 additions & 3 deletions packages/hardhat-helpers/src/networks.js
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down