forked from MoonKnightDev/v3-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path06_upgrade_pull_10.ts
50 lines (40 loc) · 1.57 KB
/
06_upgrade_pull_10.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
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DiamondCut } from "../src/types";
import { FacetCutAction, getSelectors } from "../src/utils/diamondCut";
const UPGRADE_NAME = "06_upgrade_pull_10";
// const DIAMOND_ADDRESS = "0xfe2a4643a8DE03f7706980AA18B0f298B1561497"; // FUSD
const DIAMOND_ADDRESS = "0x1570E893853897d806697F252300e32d99218fC2"; // DEI
const deploy = async function ({ deployments, getNamedAccounts, ethers }: HardhatRuntimeEnvironment) {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();
// Deploy new Accounts
const Accounts = await deploy("Accounts", { from: deployer });
console.log("Deployed: %o", {
Accounts: Accounts.address,
});
const facetCuts: Array<{
facetAddress: string;
action: FacetCutAction;
functionSelectors: string[];
}> = [];
// Replace ALL from Accounts
facetCuts.push({
facetAddress: Accounts.address,
action: FacetCutAction.Replace,
functionSelectors: getSelectors(await ethers.getContractAt("Accounts", DIAMOND_ADDRESS)).selectors,
});
// Get the DiamondCut
const diamondCut = (await ethers.getContractAt("DiamondCut", DIAMOND_ADDRESS)) as DiamondCut;
// Cut the facets
const tx = await diamondCut.diamondCut(facetCuts, ethers.constants.AddressZero, "0x", {
from: deployer,
gasLimit: 8000000,
});
const receipt = await tx.wait();
if (!receipt.status) {
throw Error(`Diamond upgrade failed: ${tx.hash}`);
}
console.log("Diamond successfully upgraded: %o", receipt);
};
export default deploy;
deploy.tags = [UPGRADE_NAME];