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
79
80
81
82
83
84
85
import { task } from 'hardhat/config'
import { ethers } from 'ethers'
import dotenv from 'dotenv'
import { prompt } from '../src/prompt'
dotenv.config()
task('mint-initial-supply', 'Mints the initial token supply')
.addParam('mintManagerAddr', 'Address of the mint manager')
.addParam('amount', 'Amount to mint (IN WHOLE OP)', '4294967296')
.addParam(
'pkMinter',
'Private key of the minter',
process.env.PRIVATE_KEY_INITIAL_MINTER
)
.setAction(async (args, hre) => {
const minter = new hre.ethers.Wallet(args.pkMinter).connect(
hre.ethers.provider
)
const amount = args.amount
const amountBase = ethers.utils.parseEther(amount)
console.log('Please verify initial mint amount and recipient.')
console.log('!!! THIS IS A ONE-WAY ACTION !!!')
console.log('')
console.log(`Amount: ${args.amount}`)
console.log(`Amount (base units): ${amountBase.toString()}`)
console.log(`Recipient: ${minter.address}`)
console.log('')
const govToken = await hre.ethers.getContractAt(
'GovernanceToken',
'0x4200000000000000000000000000000000000042'
)
const mintManager = (
await hre.ethers.getContractAt('MintManager', args.mintManagerAddr)
).connect(minter)
const permittedAfter = await mintManager.mintPermittedAfter()
if (!permittedAfter.eq(0)) {
throw new Error('Mint manager has already executed.')
}
const owner = await mintManager.owner()
if (minter.address !== owner) {
throw new Error(
`Mint manager is owned by ${owner}, not ${minter.address}`
)
}
const tokOwner = await govToken.owner()
if (mintManager.address !== tokOwner) {
throw new Error(
`Gov token is owned by ${tokOwner}, not ${mintManager.address}`
)
}
await prompt('Is this OK?')
const tx = await mintManager.mint(minter.address, amountBase, {
gasLimit: 3_000_000,
})
console.log(`Sent transaction ${tx.hash}`)
await tx.wait()
console.log('Successfully minted. Verifying...')
const supply = await govToken.totalSupply()
if (supply.eq(amountBase)) {
console.log('Total supply verified.')
} else {
console.log(
`Total supply invalid! Have: ${supply.toString()}, want: ${amountBase.toString()}.`
)
}
const bal = await govToken.balanceOf(minter.address)
if (bal.eq(amountBase)) {
console.log('Balance verified.')
} else {
console.log(
`Minter balance invalid! Have: ${bal.toString()}, want: ${amountBase.toString()}.`
)
}
})