-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy path019.chain_state_time_finalize_upgrade.ts
More file actions
62 lines (49 loc) · 1.78 KB
/
019.chain_state_time_finalize_upgrade.ts
File metadata and controls
62 lines (49 loc) · 1.78 KB
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
import type { TransactionResponse } from 'ethers';
import type { HardhatRuntimeEnvironment } from 'hardhat/types';
import type { DeployFunction } from 'hardhat-deploy/dist/types';
import { FuelChainState__factory as FuelChainState } from '../../typechain';
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {
upgrades: { prepareUpgrade },
deployments: { save },
} = hre;
console.log("Upgrading FuelChainState contract");
const contractDeployment = await hre.deployments.get('FuelChainState');
const BLOCKS_PER_COMMIT_INTERVAL = 10800;
const TIME_TO_FINALIZE = 3600 * 24;
const COMMIT_COOLDOWN = TIME_TO_FINALIZE;
const constructorArgs = [
TIME_TO_FINALIZE,
BLOCKS_PER_COMMIT_INTERVAL,
COMMIT_COOLDOWN,
];
const factory = await hre.ethers.getContractFactory('FuelChainState');
const response = (await prepareUpgrade(contractDeployment.address, factory, {
kind: 'uups',
constructorArgs,
getTxResponse: true,
redeployImplementation: 'always',
})) as TransactionResponse;
const receipt = await hre.ethers.provider.getTransactionReceipt(
response.hash
);
const implementation = receipt?.contractAddress ?? '';
if (implementation === '')
throw new Error(
`Upgrade proposal failed for FuelChainState proxy (${contractDeployment.address})`
);
await save('FuelChainState', {
address: contractDeployment.address,
abi: [...FuelChainState.abi],
implementation,
transactionHash: response.hash,
linkedData: {
constructorArgs,
factory: 'FuelChainState',
},
});
console.log(`FuelChainState upgraded to ${implementation}`);
};
func.tags = ['prepare_upgrade_chain_state_time_finalize'];
func.id = 'prepare_upgrade_chain_state_time_finalize';
export default func;