@skalenetwork/upgrade-tools 2.0.0-refactor.17 → 2.0.0-refactor.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -11
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +0 -1
- package/dist/src/submitters/auto-submitter.js +22 -9
- package/package.json +1 -1
- package/dist/src/upgrade.d.ts +0 -8
- package/dist/src/upgrade.js +0 -234
package/README.md
CHANGED
|
@@ -4,19 +4,74 @@ Scripts to support upgrades of smart contracts. The package contains common used
|
|
|
4
4
|
|
|
5
5
|
## Upgrade scripts
|
|
6
6
|
|
|
7
|
-
To write upgrade script
|
|
7
|
+
To write an upgrade script extend `Upgrader` class.
|
|
8
8
|
|
|
9
9
|
```typescript
|
|
10
|
-
import {
|
|
10
|
+
import { Upgrader } from "@skalenetwork/upgrade-tools";
|
|
11
|
+
|
|
12
|
+
class ExampleContractUpgrader extends Upgrader {
|
|
13
|
+
|
|
14
|
+
getDeployedVersion = async () => {
|
|
15
|
+
return await (await this.getExampleContract()).version();
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
setVersion = async (newVersion: string) => {
|
|
19
|
+
const exampleContract = await this.getExampleContract();
|
|
20
|
+
const setVersionTransaction = {
|
|
21
|
+
to: exampleContract.address,
|
|
22
|
+
data: exampleContract.interface.encodeFunctionData("setVersion", [newVersion])
|
|
23
|
+
};
|
|
24
|
+
this.transactions.push(setVersionTransaction);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async getExampleContract() {
|
|
28
|
+
return await ethers.getContractAt("ExampleContract", this.abi["example_contract_address"] as string);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function main() {
|
|
33
|
+
const abi = JSON.parse(await fs.readFile(process.env.ABI, "utf-8")) as SkaleABIFile;
|
|
34
|
+
|
|
35
|
+
const upgrader = new ExampleContractUpgrader(
|
|
36
|
+
"ExampleContract",
|
|
37
|
+
"1.0.0",
|
|
38
|
+
abi,
|
|
39
|
+
["ExampleContract"]
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
await upgrader.upgrade();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (require.main === module) {
|
|
46
|
+
main()
|
|
47
|
+
.then(() => process.exit(0))
|
|
48
|
+
.catch(error => {
|
|
49
|
+
console.error(error);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Abstract functions
|
|
56
|
+
|
|
57
|
+
The `Upgrader` has 2 abstract functions. It's mandatory to override them:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
abstract getDeployedVersion: () => Promise<string | undefined>
|
|
61
|
+
abstract setVersion: (newVersion: string) => Promise<void>
|
|
11
62
|
```
|
|
12
63
|
|
|
13
|
-
|
|
64
|
+
- `getDeployedVersion` returns string representing a deployed version of the contract
|
|
65
|
+
- `setVersion` creates a transaction to set a new version of the contract
|
|
66
|
+
|
|
67
|
+
### Protected functions
|
|
68
|
+
|
|
69
|
+
There are functions that may be overridden to customize an upgrade process
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
deployNewContracts = () => { return Promise.resolve() };
|
|
73
|
+
initialize = () => { return Promise.resolve() };
|
|
74
|
+
```
|
|
14
75
|
|
|
15
|
-
- `
|
|
16
|
-
- `
|
|
17
|
-
- `getDeployedVersion` - a function to request current version from smart contracts
|
|
18
|
-
- `setVersion` - function that sets version to smart contracts
|
|
19
|
-
- `safeMockAccessRequirements` - list of smart contracts that requires ownership changing for successful upgrade (when EOA + SafeMock are used during upgrade)
|
|
20
|
-
- `contractNamesToUpgrade` - list of smart contracts to upgrade
|
|
21
|
-
- `deployNewContracts` - optional - a function that deploys new smart contracts
|
|
22
|
-
- `initialize` - optional - a function that setup smart contracts after upgrade
|
|
76
|
+
- `deployNewContracts` is called before proxies upgrade and is used to deploy new instances
|
|
77
|
+
- `initialize` is called after proxies upgrade and is used to send initializing transactions
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -21,5 +21,4 @@ __exportStar(require("./multiSend"), exports);
|
|
|
21
21
|
__exportStar(require("./submitters"), exports);
|
|
22
22
|
__exportStar(require("./verification"), exports);
|
|
23
23
|
__exportStar(require("./version"), exports);
|
|
24
|
-
__exportStar(require("./upgrade"), exports);
|
|
25
24
|
__exportStar(require("./upgrader"), exports);
|
|
@@ -45,7 +45,6 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
45
45
|
const safe_ima_legacy_marionette_submitter_1 = require("./safe-ima-legacy-marionette-submitter");
|
|
46
46
|
const fs_1 = require("fs");
|
|
47
47
|
const marionette_1 = require("./types/marionette");
|
|
48
|
-
const safe_ima_marionette_submitter_1 = require("./safe-ima-marionette-submitter");
|
|
49
48
|
class AutoSubmitter extends submitter_1.Submitter {
|
|
50
49
|
submit(transactions) {
|
|
51
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -64,14 +63,28 @@ class AutoSubmitter extends submitter_1.Submitter {
|
|
|
64
63
|
const safeAddress = this._getSafeAddress();
|
|
65
64
|
const schainHash = this._getSchainHash();
|
|
66
65
|
const mainnetChainId = this._getMainnetChainId();
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
// TODO: after marionette has multiSend functionality
|
|
67
|
+
// query version and properly select a submitter
|
|
68
|
+
// based on it
|
|
69
|
+
//
|
|
70
|
+
// if (await this._versionFunctionExists()) {
|
|
71
|
+
// console.log("version() function was found. Use normal Marionette")
|
|
72
|
+
// submitter = new SafeImaMarionetteSubmitter(
|
|
73
|
+
// safeAddress,
|
|
74
|
+
// imaAbi,
|
|
75
|
+
// schainHash,
|
|
76
|
+
// mainnetChainId
|
|
77
|
+
// )
|
|
78
|
+
// } else {
|
|
79
|
+
// console.log("No version() function was found. Use legacy Marionette")
|
|
80
|
+
// submitter = new SafeImaLegacyMarionetteSubmitter(
|
|
81
|
+
// safeAddress,
|
|
82
|
+
// imaAbi,
|
|
83
|
+
// schainHash,
|
|
84
|
+
// mainnetChainId
|
|
85
|
+
// )
|
|
86
|
+
// }
|
|
87
|
+
submitter = new safe_ima_legacy_marionette_submitter_1.SafeImaLegacyMarionetteSubmitter(safeAddress, imaAbi, schainHash, mainnetChainId);
|
|
75
88
|
}
|
|
76
89
|
else {
|
|
77
90
|
// assuming owner is a Gnosis Safe
|
package/package.json
CHANGED
package/dist/src/upgrade.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Contract } from "ethers";
|
|
2
|
-
import { OwnableUpgradeable } from "../typechain-types";
|
|
3
|
-
import { SkaleABIFile } from "./types/SkaleABIFile";
|
|
4
|
-
export declare function getContractFactoryAndUpdateManifest(contract: string): Promise<import("ethers").ContractFactory>;
|
|
5
|
-
declare type DeploymentAction<ContractManagerType extends Contract> = (safeTransactions: string[], abi: SkaleABIFile, contractManager: ContractManagerType) => Promise<void>;
|
|
6
|
-
declare type MultiTransactionAction<ContractManagerType extends Contract> = (abi: SkaleABIFile, contractManager: ContractManagerType) => Promise<string[][]>;
|
|
7
|
-
export declare function upgrade<ContractManagerType extends OwnableUpgradeable>(projectName: string, targetVersion: string, getDeployedVersion: (abi: SkaleABIFile) => Promise<string | undefined>, setVersion: (safeTransaction: string[], abi: SkaleABIFile, newVersion: string) => Promise<void>, safeMockAccessRequirements: string[], contractNamesToUpgrade: string[], deployNewContracts: DeploymentAction<ContractManagerType>, initialize: DeploymentAction<ContractManagerType>, afterUpgrade?: MultiTransactionAction<ContractManagerType>): Promise<void>;
|
|
8
|
-
export {};
|
package/dist/src/upgrade.js
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.upgrade = exports.getContractFactoryAndUpdateManifest = void 0;
|
|
16
|
-
const deploy_1 = require("./deploy");
|
|
17
|
-
const fs_1 = require("fs");
|
|
18
|
-
const hardhat_1 = require("hardhat");
|
|
19
|
-
const hardhat_2 = __importDefault(require("hardhat"));
|
|
20
|
-
const upgrades_core_1 = require("@openzeppelin/upgrades-core");
|
|
21
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
22
|
-
const admin_1 = require("@openzeppelin/hardhat-upgrades/dist/admin");
|
|
23
|
-
const version_1 = require("./version");
|
|
24
|
-
const abi_1 = require("./abi");
|
|
25
|
-
const verification_1 = require("./verification");
|
|
26
|
-
const multiSend_1 = require("./multiSend");
|
|
27
|
-
const gnosis_safe_1 = require("./gnosis-safe");
|
|
28
|
-
function getContractFactoryAndUpdateManifest(contract) {
|
|
29
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
const manifest = JSON.parse(yield fs_1.promises.readFile(yield (0, deploy_1.getManifestFile)(), "utf-8"));
|
|
31
|
-
const { linkReferences } = yield hardhat_1.artifacts.readArtifact(contract);
|
|
32
|
-
if (!Object.keys(linkReferences).length)
|
|
33
|
-
return yield hardhat_1.ethers.getContractFactory(contract);
|
|
34
|
-
const librariesToUpgrade = [];
|
|
35
|
-
const oldLibraries = {};
|
|
36
|
-
if (manifest.libraries === undefined) {
|
|
37
|
-
Object.assign(manifest, { libraries: {} });
|
|
38
|
-
}
|
|
39
|
-
for (const key of Object.keys(linkReferences)) {
|
|
40
|
-
const libraryName = Object.keys(linkReferences[key])[0];
|
|
41
|
-
const { bytecode } = yield hardhat_1.artifacts.readArtifact(libraryName);
|
|
42
|
-
if (manifest.libraries[libraryName] === undefined) {
|
|
43
|
-
librariesToUpgrade.push(libraryName);
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
const libraryBytecodeHash = manifest.libraries[libraryName].bytecodeHash;
|
|
47
|
-
if ((0, upgrades_core_1.hashBytecode)(bytecode) !== libraryBytecodeHash) {
|
|
48
|
-
librariesToUpgrade.push(libraryName);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
oldLibraries[libraryName] = manifest.libraries[libraryName].address;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
const libraries = yield (0, deploy_1.deployLibraries)(librariesToUpgrade);
|
|
55
|
-
for (const [libraryName, libraryAddress] of libraries.entries()) {
|
|
56
|
-
const { bytecode } = yield hardhat_1.artifacts.readArtifact(libraryName);
|
|
57
|
-
manifest.libraries[libraryName] = { "address": libraryAddress, "bytecodeHash": (0, upgrades_core_1.hashBytecode)(bytecode) };
|
|
58
|
-
}
|
|
59
|
-
Object.assign(libraries, oldLibraries);
|
|
60
|
-
yield fs_1.promises.writeFile(yield (0, deploy_1.getManifestFile)(), JSON.stringify(manifest, null, 4));
|
|
61
|
-
return yield (0, deploy_1.getLinkedContractFactory)(contract, libraries);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
exports.getContractFactoryAndUpdateManifest = getContractFactoryAndUpdateManifest;
|
|
65
|
-
function upgrade(projectName, targetVersion, getDeployedVersion, setVersion, safeMockAccessRequirements, contractNamesToUpgrade, deployNewContracts, initialize, afterUpgrade) {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
if (!process.env.ABI) {
|
|
68
|
-
console.log(chalk_1.default.red("Set path to file with ABI and addresses to ABI environment variables"));
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const abiFilename = process.env.ABI;
|
|
72
|
-
const abi = JSON.parse(yield fs_1.promises.readFile(abiFilename, "utf-8"));
|
|
73
|
-
const proxyAdmin = yield (0, admin_1.getManifestAdmin)(hardhat_2.default);
|
|
74
|
-
const contractManagerName = "ContractManager";
|
|
75
|
-
const contractManagerFactory = yield hardhat_1.ethers.getContractFactory(contractManagerName);
|
|
76
|
-
// const contractManager = (contractManagerFactory.attach(abi[getContractKeyInAbiFile(contractManagerName) + "_address"] as string)) as ContractManagerType;
|
|
77
|
-
const contractManager = (contractManagerFactory.attach(abi["Mock"]));
|
|
78
|
-
const deployedVersion = yield getDeployedVersion(abi);
|
|
79
|
-
const version = yield (0, version_1.getVersion)();
|
|
80
|
-
if (deployedVersion) {
|
|
81
|
-
if (deployedVersion !== targetVersion) {
|
|
82
|
-
console.log(chalk_1.default.red(`This script can't upgrade version ${deployedVersion} to ${version}`));
|
|
83
|
-
process.exit(1);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
console.log(chalk_1.default.yellow(`Can't check currently deployed version of ${projectName}`));
|
|
88
|
-
}
|
|
89
|
-
console.log(`Will mark updated version as ${version}`);
|
|
90
|
-
const [deployer] = yield hardhat_1.ethers.getSigners();
|
|
91
|
-
let safe = yield proxyAdmin.owner();
|
|
92
|
-
const safeTransactions = [];
|
|
93
|
-
let safeMock = undefined;
|
|
94
|
-
if ((yield hardhat_1.ethers.provider.getCode(safe)) === "0x") {
|
|
95
|
-
console.log("Owner is not a contract");
|
|
96
|
-
if (deployer.address !== safe) {
|
|
97
|
-
console.log(chalk_1.default.red(`Used address does not have permissions to upgrade ${projectName}`));
|
|
98
|
-
process.exit(1);
|
|
99
|
-
}
|
|
100
|
-
console.log(chalk_1.default.blue("Deploy SafeMock to simulate upgrade via multisig"));
|
|
101
|
-
const safeMockFactory = yield hardhat_1.ethers.getContractFactory("SafeMock");
|
|
102
|
-
safeMock = yield safeMockFactory.deploy();
|
|
103
|
-
yield safeMock.deployTransaction.wait();
|
|
104
|
-
console.log(chalk_1.default.blue("Transfer ownership to SafeMock"));
|
|
105
|
-
safe = safeMock.address;
|
|
106
|
-
yield (yield proxyAdmin.transferOwnership(safe)).wait();
|
|
107
|
-
yield (yield contractManager.transferOwnership(safe)).wait();
|
|
108
|
-
for (const contractName of safeMockAccessRequirements) {
|
|
109
|
-
const contractFactory = yield getContractFactoryAndUpdateManifest(contractName);
|
|
110
|
-
// const contractAddress = abi[getContractKeyInAbiFile(contractName) + "_address"] as string;
|
|
111
|
-
const contractAddress = abi["Mock"];
|
|
112
|
-
const contract = contractFactory.attach(contractAddress);
|
|
113
|
-
console.log(chalk_1.default.blue(`Grant access to ${contractName}`));
|
|
114
|
-
yield (yield contract.grantRole(yield contract.DEFAULT_ADMIN_ROLE(), safe)).wait();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
try {
|
|
119
|
-
const safeMockFactory = yield hardhat_1.ethers.getContractFactory("SafeMock");
|
|
120
|
-
const checkSafeMock = safeMockFactory.attach(safe);
|
|
121
|
-
if (yield checkSafeMock.IS_SAFE_MOCK()) {
|
|
122
|
-
safeMock = checkSafeMock;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
catch (e) {
|
|
126
|
-
console.log(chalk_1.default.yellow("Owner is not SafeMock"));
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
// Deploy new contracts
|
|
130
|
-
yield deployNewContracts(safeTransactions, abi, contractManager);
|
|
131
|
-
// deploy new implementations
|
|
132
|
-
const contractsToUpgrade = [];
|
|
133
|
-
for (const contract of contractNamesToUpgrade) {
|
|
134
|
-
const contractFactory = yield getContractFactoryAndUpdateManifest(contract);
|
|
135
|
-
let _contract = contract;
|
|
136
|
-
if (contract === "BountyV2") {
|
|
137
|
-
if (!abi[ /*getContractKeyInAbiFile(contract) + */"_address"])
|
|
138
|
-
_contract = "Bounty";
|
|
139
|
-
console.log(_contract);
|
|
140
|
-
}
|
|
141
|
-
const proxyAddress = abi[ /*getContractKeyInAbiFile(_contract) + */"_address"];
|
|
142
|
-
console.log(`Prepare upgrade of ${contract}`);
|
|
143
|
-
const newImplementationAddress = yield hardhat_1.upgrades.prepareUpgrade(proxyAddress, contractFactory, {
|
|
144
|
-
unsafeAllowLinkedLibraries: true,
|
|
145
|
-
unsafeAllowRenames: true
|
|
146
|
-
});
|
|
147
|
-
const currentImplementationAddress = yield (0, upgrades_core_1.getImplementationAddress)(hardhat_1.network.provider, proxyAddress);
|
|
148
|
-
if (newImplementationAddress !== currentImplementationAddress) {
|
|
149
|
-
contractsToUpgrade.push({
|
|
150
|
-
proxyAddress,
|
|
151
|
-
implementationAddress: newImplementationAddress,
|
|
152
|
-
name: contract,
|
|
153
|
-
abi: (0, abi_1.getAbi)(contractFactory.interface)
|
|
154
|
-
});
|
|
155
|
-
yield (0, verification_1.verify)(contract, newImplementationAddress, []);
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
console.log(chalk_1.default.gray(`Contract ${contract} is up to date`));
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
// Switch proxies to new implementations
|
|
162
|
-
for (const contract of contractsToUpgrade) {
|
|
163
|
-
console.log(chalk_1.default.yellowBright(`Prepare transaction to upgrade ${contract.name} at ${contract.proxyAddress} to ${contract.implementationAddress}`));
|
|
164
|
-
safeTransactions.push((0, multiSend_1.encodeTransaction)(0, proxyAdmin.address, 0, proxyAdmin.interface.encodeFunctionData("upgrade", [contract.proxyAddress, contract.implementationAddress])));
|
|
165
|
-
abi[ /*getContractKeyInAbiFile(contract.name) + */"_abi"] = contract.abi;
|
|
166
|
-
}
|
|
167
|
-
yield initialize(safeTransactions, abi, contractManager);
|
|
168
|
-
// write version
|
|
169
|
-
yield setVersion(safeTransactions, abi, version);
|
|
170
|
-
yield fs_1.promises.writeFile(`data/transactions-${version}-${hardhat_1.network.name}.json`, JSON.stringify(safeTransactions, null, 4));
|
|
171
|
-
let privateKey = hardhat_1.network.config.accounts[0];
|
|
172
|
-
if (hardhat_1.network.config.accounts === "remote") {
|
|
173
|
-
// Don't have an information about private key
|
|
174
|
-
// Use random one because we most probable run tests
|
|
175
|
-
privateKey = hardhat_1.ethers.Wallet.createRandom().privateKey;
|
|
176
|
-
}
|
|
177
|
-
const safeTx = yield (0, gnosis_safe_1.createMultiSendTransaction)(hardhat_1.ethers, safe, privateKey, safeTransactions, (yield hardhat_1.ethers.provider.getNetwork()).chainId, safeMock !== undefined ? 0 : undefined);
|
|
178
|
-
let transactionsBatches;
|
|
179
|
-
if (afterUpgrade !== undefined) {
|
|
180
|
-
transactionsBatches = yield afterUpgrade(abi, contractManager);
|
|
181
|
-
for (const { index, batch } of transactionsBatches.map((batch, index) => ({ index, batch }))) {
|
|
182
|
-
yield fs_1.promises.writeFile(`data/after-transactions-${index}-${version}-${hardhat_1.network.name}.json`, JSON.stringify(batch, null, 4));
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if (!safeMock) {
|
|
186
|
-
const chainId = (yield hardhat_1.ethers.provider.getNetwork()).chainId;
|
|
187
|
-
yield (0, gnosis_safe_1.sendSafeTransaction)(safe, chainId, safeTx);
|
|
188
|
-
if (transactionsBatches !== undefined) {
|
|
189
|
-
for (const { batch, index } of transactionsBatches.map((batch, index) => ({ batch, index }))) {
|
|
190
|
-
const multiSendTransaction = yield (0, gnosis_safe_1.createMultiSendTransaction)(hardhat_1.ethers, safe, privateKey, batch, safeTx.nonce + index + 1);
|
|
191
|
-
yield (0, gnosis_safe_1.sendSafeTransaction)(safe, chainId, multiSendTransaction);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
console.log(chalk_1.default.blue("Send upgrade transactions to safe mock"));
|
|
197
|
-
try {
|
|
198
|
-
yield (yield deployer.sendTransaction({
|
|
199
|
-
to: safeMock.address,
|
|
200
|
-
value: safeTx.value,
|
|
201
|
-
data: safeTx.data,
|
|
202
|
-
})).wait();
|
|
203
|
-
if (transactionsBatches !== undefined) {
|
|
204
|
-
for (const batch of transactionsBatches) {
|
|
205
|
-
const multiSendTransaction = yield (0, gnosis_safe_1.createMultiSendTransaction)(hardhat_1.ethers, safe, privateKey, batch, 0);
|
|
206
|
-
yield (yield deployer.sendTransaction({
|
|
207
|
-
to: safeMock.address,
|
|
208
|
-
value: multiSendTransaction.value,
|
|
209
|
-
data: multiSendTransaction.data,
|
|
210
|
-
})).wait();
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
console.log(chalk_1.default.blue("Transactions have been sent"));
|
|
214
|
-
}
|
|
215
|
-
catch (exception) {
|
|
216
|
-
console.log(chalk_1.default.red("Error during upgrade"));
|
|
217
|
-
console.log(exception);
|
|
218
|
-
process.exitCode = 13;
|
|
219
|
-
}
|
|
220
|
-
finally {
|
|
221
|
-
console.log(chalk_1.default.blue("Return ownership to wallet"));
|
|
222
|
-
yield (yield safeMock.transferProxyAdminOwnership(contractManager.address, deployer.address)).wait();
|
|
223
|
-
yield (yield safeMock.transferProxyAdminOwnership(proxyAdmin.address, deployer.address)).wait();
|
|
224
|
-
if ((yield proxyAdmin.owner()) !== deployer.address) {
|
|
225
|
-
console.log(chalk_1.default.blue("Something went wrong with ownership transfer"));
|
|
226
|
-
process.exit(1);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
yield fs_1.promises.writeFile(`data/${projectName}-${version}-${hardhat_1.network.name}-abi.json`, JSON.stringify(abi, null, 4));
|
|
231
|
-
console.log("Done");
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
exports.upgrade = upgrade;
|