Skip to content

Commit

Permalink
feat(governance): cleaner logs when pulling proxy admin address (unlo…
Browse files Browse the repository at this point in the history
…ck-protocol#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
  • Loading branch information
clemsos authored and blahkheart committed Mar 26, 2024
1 parent 1cf8b43 commit e91f22f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
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

0 comments on commit e91f22f

Please sign in to comment.