-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy path017.portal_upgrade.ts
54 lines (41 loc) · 1.62 KB
/
017.portal_upgrade.ts
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
import { password } from '@inquirer/prompts';
import type { TransactionResponse } from 'ethers';
import { parseEther } from 'ethers';
import type { HardhatRuntimeEnvironment } from 'hardhat/types';
import type { DeployFunction } from 'hardhat-deploy/dist/types';
import { FuelMessagePortalV3__factory as FuelMessagePortal } from '../../typechain';
const RATE_LIMIT_DURATION = 3600 * 24 * 7;
// Global deposit cap: 19572 ETH
const ETH_DEPOSIT_CAP = parseEther('19572');
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {
ethers,
upgrades: { prepareUpgrade },
deployments: { get, save },
} = hre;
const privateKey = await password({ message: 'Enter private key' });
const deployer = new ethers.Wallet(privateKey, ethers.provider);
const { address } = await get('FuelMessagePortal');
const constructorArgs = [ETH_DEPOSIT_CAP.toString(), RATE_LIMIT_DURATION];
const tx = (await prepareUpgrade(address, new FuelMessagePortal(deployer), {
constructorArgs,
getTxResponse: true,
})) as TransactionResponse;
const receipt = await tx.wait();
const implementation = receipt?.contractAddress ?? '';
if (implementation === '')
throw new Error(
`Upgrade proposal failed for FuelMessagePortal proxy (${address})`
);
console.log('Proposed FuelMessagePortal upgrade to', implementation);
await save('FuelMessagePortal', {
address,
abi: [...FuelMessagePortal.abi],
implementation,
linkedData: { factory: 'FuelMessagePortalV3', constructorArgs },
});
return true;
};
func.tags = ['upgrade_portal'];
func.id = 'upgrade_portal';
export default func;