-
Notifications
You must be signed in to change notification settings - Fork 1
/
upgradeRigs.ts
68 lines (59 loc) · 2.23 KB
/
upgradeRigs.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { ethers, upgrades, network, rigsDeployment, rigsConfig } from "hardhat";
import type { TablelandRigs } from "../typechain-types";
import assert from "assert";
import { BigNumber, utils } from "ethers";
async function main() {
console.log(`\nUpgrading rigs on '${network.name}'...`);
// Get owner account
const [account] = await ethers.getSigners();
if (account.provider === undefined) {
throw Error("missing provider");
}
// Get proxy address
if (rigsDeployment.contractAddress === "") {
throw Error(`no contractAddress entry for '${network.name}'`);
}
console.log(`Using address '${rigsDeployment.contractAddress}'`);
// Check current implementation
const impl = await upgrades.erc1967.getImplementationAddress(
rigsDeployment.contractAddress
);
console.log("Current implementation address:", impl);
// Upgrade proxy
const Factory = await ethers.getContractFactory("TablelandRigs");
const rigs = await (
(await upgrades.upgradeProxy(rigsDeployment.contractAddress, Factory, {
kind: "uups",
timeout: 60 * 10 * 1000,
})) as TablelandRigs
).deployed();
assert(
rigs.address === rigsDeployment.contractAddress,
"contract address changed"
);
// Check new implementation
const impl2 = await upgrades.erc1967.getImplementationAddress(rigs.address);
console.log("New implementation address:", impl2);
// TMP: Manually initialize impl. Once RIG-30 is done we can remove this.
const rigsImpl = Factory.attach(impl2) as TablelandRigs;
const tx = await rigsImpl.initialize(
BigNumber.from(rigsConfig.maxSupply),
utils.parseEther(rigsConfig.etherPrice),
rigsConfig.feeRecipient,
rigsDeployment.royaltyContractAddress,
"0xcb3e8f37cd26c729d6ed94f151517549508020b191327dc78c7657bbd2872a50",
"0xe45a43693f3688d2d97d6e933af863b80f24517da45579e157c6da40b71d77a2"
);
const receipt = await tx.wait();
console.log(`Initialized new impl with txn '${receipt.transactionHash}'`);
// Warn if implementation did not change, ie, nothing happened.
if (impl === impl2) {
console.warn("\nProxy implementation did not change. Is this expected?");
}
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});