/
unlock-info.js
78 lines (66 loc) · 2.08 KB
/
unlock-info.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const { ethers } = require('hardhat')
const {
getNetwork,
getUnlock,
getProxyAdminAddress,
} = require('@unlock-protocol/hardhat-helpers')
const {
abi: proxyAdminABI,
} = require('@unlock-protocol/hardhat-helpers/dist/ABIs/ProxyAdmin.json')
const getOwners = require('../multisig/owners')
async function main({ unlockAddress, quiet = false }) {
let safeAddress
const { id: chainId, name } = await getNetwork()
if (!unlockAddress) {
;({ unlockAddress, multisig: safeAddress } = await getNetwork())
}
const errorLog = (txt) => console.log(`[${name}]: ⚠️ ${txt}`)
const unlock = await getUnlock(unlockAddress)
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`)
}
if (proxyAdminAddress) {
const proxyAdmin = await ethers.getContractAt(
proxyAdminABI,
proxyAdminAddress
)
proxyAdminOwner = await proxyAdmin.owner()
}
if (proxyAdminOwner !== unlockOwner) {
errorLog(`Unlock contract and ProxyAdmin have different owners!`)
}
let nbOwners
try {
nbOwners = (await getOwners({ safeAddress: unlockOwner })).length
} catch (error) {
errorLog(`Unlock owner is not the team multisig (${safeAddress})!`)
}
if (nbOwners && !isMultisig) {
errorLog(`Multisig in networks package does not match with Unlock owner!`)
}
if (!quiet) {
console.log(
`Unlock deployed on ${name} \n`,
`- address: ${unlockAddress} \n`,
`- unlockVersion: ${await unlock.unlockVersion()} \n`,
`- publicLockVersion: ${await unlock.publicLockLatestVersion()} \n`,
`- owner: ${unlockOwner} ${nbOwners ? `(${nbOwners} owners)` : ''}\n`,
`- proxyAdminAddress: ${proxyAdminAddress} \n`
)
}
}
// execute as standalone
if (require.main === module) {
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})
}
module.exports = main