Skip to content

Commit 4486a95

Browse files
committed
updated info script
1 parent d838c8c commit 4486a95

File tree

4 files changed

+92
-46
lines changed

4 files changed

+92
-46
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,6 @@ sdk/deployments/geth*.json
9696
console.js
9797

9898
.DS_Store
99+
100+
101+
flattened

helpers/contracts.js

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const upgradeProxyContract = async (
111111
deployedContractRef,
112112
signer,
113113
txParams,
114-
force=false,
114+
force = false,
115115
) => {
116116
const proxyAdmin = await getDeployedContractInstance(
117117
network,
@@ -125,40 +125,68 @@ const upgradeProxyContract = async (
125125
ethers.provider,
126126
);
127127

128-
const currentImplAddr = await proxyAdmin.getProxyImplementation(proxy.address);
129-
console.log(`Current implementation for ${contractName} is at`, currentImplAddr);
128+
const currentImplAddr = await proxyAdmin.getProxyImplementation(
129+
proxy.address,
130+
);
131+
console.log(
132+
`Current implementation for ${contractName} is at`,
133+
currentImplAddr,
134+
);
130135

131136
// deploy new implementation
132-
let newImpl;
133-
if(!force) {
137+
let newImplAddress;
138+
if (!force) {
134139
const Factory = await getCompiledContractFactory(ethers, contractName);
135-
newImpl = await upgrades.prepareUpgrade(proxy.address, Factory);
140+
newImplAddress = await upgrades.prepareUpgrade(
141+
proxy.address,
142+
Factory.connect(signer),
143+
);
144+
await sleep(180);
136145
} else {
137-
console.log(`CAUTION: Skpping storage layout verification!`)
138-
console.log(`CANCEL NOW to stop, this action is not reversable`)
146+
console.log(`CAUTION: Skpping storage layout verification!`);
147+
console.log(`CANCEL NOW to stop, this action is not reversable`);
139148
await sleep(10);
140-
newImpl = await deployContract(
149+
const newImpl = await deployContract(
141150
ethers,
142151
contractName,
143152
signer,
144153
[],
145154
txParams,
146155
);
156+
newImplAddress = newImpl.address;
147157
}
148-
console.log(`New implementation for ${contractName} is at`, newImpl.address);
158+
console.log(`New implementation for ${contractName} is at`, newImplAddress);
149159

150160
if ((await proxyAdmin.owner()) == (await signer.getAddress())) {
151161
await proxyAdmin
152162
.connect(signer)
153-
.upgrade(proxy.address, newImpl.address, txParams);
163+
.upgrade(proxy.address, newImplAddress, txParams);
164+
165+
await proxyAdmin
166+
.connect(signer)
167+
.upgrade(
168+
proxy.address,
169+
'0x82E415d7F43D2f56d431124c58221Faa249Ded42',
170+
txParams,
171+
);
154172
} else {
155173
console.log('Signer not proxy onwer, cant upgrade');
156174
console.log(
157-
`Execute proxyAdmin.upgrade(${proxy.address}, ${newImpl.address})`,
175+
`Execute proxyAdmin.upgrade(${proxy.address}, ${newImplAddress})`,
158176
);
159177
}
160178

161-
return newImpl;
179+
const contractData = await readContractDeploymentData(
180+
network,
181+
deployedContractRef,
182+
);
183+
const impl = new ethers.Contract(
184+
newImplAddress,
185+
contractData.abi,
186+
ethers.provider,
187+
);
188+
await impl.deployed();
189+
return impl;
162190
};
163191

164192
const getDeployedContractInstance = async (network, contractName, provider) => {

tasks/info/ampl.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
const ethers = require('ethers');
2+
const {
3+
getAdminAddress,
4+
getImplementationAddress,
5+
} = require('@openzeppelin/upgrades-core');
26

37
const { task } = require('../../helpers/tasks');
48
const { getEthersProvider } = require('../../helpers/utils');
@@ -208,27 +212,35 @@ task(
208212
}
209213

210214
console.log('ProxyAdmin:', proxyAdmin.address);
215+
console.log('ProxyAdmin:onwer', await proxyAdmin.owner());
211216
console.log('XCAmple:', xcAmple.address);
217+
console.log(
218+
'XCAmple:proxyAdmin',
219+
await getAdminAddress(provider, xcAmple.address),
220+
);
212221
console.log(
213222
'XCAmple:implementation',
214-
await proxyAdmin.getProxyImplementation(xcAmple.address),
223+
await getImplementationAddress(provider, xcAmple.address),
215224
);
225+
216226
console.log('XCAmple:owner:', await xcAmple.owner());
217227
console.log('XCAmple:controller:', await xcAmple.controller());
218228
console.log(
219229
'XCAmple:totalSupply:',
220230
toAmplFloatingPt(await xcAmple.totalSupply()),
221231
);
222232

223-
console.log('XCAmpleController:', xcAmple.address);
233+
console.log('XCAmpleController:', xcAmpleController.address);
224234
console.log(
225-
'XCAmpleController:implementation',
226-
await proxyAdmin.getProxyImplementation(xcAmple.address),
235+
'XCAmpleController:proxyAdmin',
236+
await getAdminAddress(provider, xcAmpleController.address),
227237
);
228238
console.log(
229-
'XCAmpleController:owner',
230-
await xcAmpleController.owner(),
239+
'XCAmpleController:implementation',
240+
await getImplementationAddress(provider, xcAmpleController.address),
231241
);
242+
243+
console.log('XCAmpleController:owner', await xcAmpleController.owner());
232244
console.log(
233245
'XCAmpleController:xcAmple',
234246
await xcAmpleController.xcAmple(),

tasks/upgrade.js

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,41 @@
11
const { types } = require('hardhat/config');
22
const { txTask, loadSignerSync, etherscanVerify } = require('../helpers/tasks');
3-
const { getDeployedContractInstance, upgradeProxyContract } = require('../helpers/contracts');
3+
const {
4+
getDeployedContractInstance,
5+
upgradeProxyContract,
6+
} = require('../helpers/contracts');
47

58
txTask(
69
'upgrade:xc_ample',
710
'Uprades the implementation of the xc-ample ERC-20 contract',
811
)
9-
.addParam('force', 'Skip storage layout verification', false, types.boolean)
10-
.setAction(async (args, hre) => {
11-
const txParams = { gasPrice: args.gasPrice, gasLimit: args.gasLimit };
12-
if (txParams.gasPrice == 0) {
13-
txParams.gasPrice = await hre.ethers.provider.getGasPrice();
14-
}
12+
.addParam('force', 'Skip storage layout verification', false, types.boolean)
13+
.setAction(async (args, hre) => {
14+
const txParams = { gasPrice: args.gasPrice, gasLimit: args.gasLimit };
15+
if (txParams.gasPrice == 0) {
16+
txParams.gasPrice = await hre.ethers.provider.getGasPrice();
17+
}
1518

16-
const deployer = await loadSignerSync(args, hre.ethers.provider);
17-
const deployerAddress = await deployer.getAddress();
19+
const deployer = await loadSignerSync(args, hre.ethers.provider);
20+
const deployerAddress = await deployer.getAddress();
1821

19-
console.log('------------------------------------------------------------');
20-
console.log('Deployer:', deployerAddress);
21-
console.log(txParams);
22+
console.log('------------------------------------------------------------');
23+
console.log('Deployer:', deployerAddress);
24+
console.log(txParams);
2225

23-
console.log('------------------------------------------------------------');
24-
console.log('Upgrading xc-ample contract');
25-
const newImpl = await upgradeProxyContract(
26-
hre.ethers,
27-
hre.network.name,
28-
'XCAmple',
29-
'xcAmple',
30-
deployer,
31-
txParams,
32-
args.force
33-
);
26+
console.log('------------------------------------------------------------');
27+
console.log('Upgrading xc-ample contract');
28+
const newImpl = await upgradeProxyContract(
29+
hre.ethers,
30+
hre.network.name,
31+
'XCAmple',
32+
'xcAmple',
33+
deployer,
34+
txParams,
35+
args.force,
36+
);
3437

35-
console.log('------------------------------------------------------------');
36-
console.log('Verify on etherscan');
37-
await etherscanVerify(hre, newImpl.address);
38-
});
38+
console.log('------------------------------------------------------------');
39+
console.log('Verify on etherscan');
40+
await etherscanVerify(hre, newImpl.address);
41+
});

0 commit comments

Comments
 (0)