@skalenetwork/upgrade-tools 3.0.0-linter.4 → 3.0.0-linter.41
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/dist/hardhat.config.d.ts +2 -2
- package/dist/hardhat.config.js +5 -3
- package/dist/hardhat.config.js.map +1 -0
- package/dist/src/abi.d.ts +2 -2
- package/dist/src/abi.js +4 -3
- package/dist/src/abi.js.map +1 -0
- package/dist/src/contractFactory.d.ts +4 -0
- package/dist/src/contractFactory.js +84 -0
- package/dist/src/contractFactory.js.map +1 -0
- package/dist/src/deploy.d.ts +4 -4
- package/dist/src/deploy.js +56 -62
- package/dist/src/deploy.js.map +1 -0
- package/dist/src/exitCodes.d.ts +7 -0
- package/dist/src/exitCodes.js +12 -0
- package/dist/src/exitCodes.js.map +1 -0
- package/dist/src/gnosis-safe.d.ts +2 -2
- package/dist/src/gnosis-safe.js +113 -104
- package/dist/src/gnosis-safe.js.map +1 -0
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -0
- package/dist/src/nonceProvider.d.ts +10 -0
- package/dist/src/nonceProvider.js +34 -0
- package/dist/src/nonceProvider.js.map +1 -0
- package/dist/src/submitters/auto-submitter.d.ts +18 -5
- package/dist/src/submitters/auto-submitter.js +107 -95
- package/dist/src/submitters/auto-submitter.js.map +1 -0
- package/dist/src/submitters/eoa-submitter.d.ts +2 -2
- package/dist/src/submitters/eoa-submitter.js +15 -13
- package/dist/src/submitters/eoa-submitter.js.map +1 -0
- package/dist/src/submitters/index.js +1 -0
- package/dist/src/submitters/index.js.map +1 -0
- package/dist/src/submitters/safe-ima-legacy-marionette-submitter.d.ts +4 -3
- package/dist/src/submitters/safe-ima-legacy-marionette-submitter.js +14 -19
- package/dist/src/submitters/safe-ima-legacy-marionette-submitter.js.map +1 -0
- package/dist/src/submitters/safe-ima-marionette-submitter.d.ts +3 -3
- package/dist/src/submitters/safe-ima-marionette-submitter.js +12 -16
- package/dist/src/submitters/safe-ima-marionette-submitter.js.map +1 -0
- package/dist/src/submitters/safe-submitter.d.ts +4 -4
- package/dist/src/submitters/safe-submitter.js +3 -2
- package/dist/src/submitters/safe-submitter.js.map +1 -0
- package/dist/src/submitters/safe-to-ima-submitter.d.ts +11 -6
- package/dist/src/submitters/safe-to-ima-submitter.js +18 -13
- package/dist/src/submitters/safe-to-ima-submitter.js.map +1 -0
- package/dist/src/submitters/submitter.d.ts +3 -3
- package/dist/src/submitters/submitter.js +10 -6
- package/dist/src/submitters/submitter.js.map +1 -0
- package/dist/src/submitters/types/marionette.d.ts +6 -3
- package/dist/src/submitters/types/marionette.js +1 -0
- package/dist/src/submitters/types/marionette.js.map +1 -0
- package/dist/src/types/SkaleManifestData.js +1 -0
- package/dist/src/types/SkaleManifestData.js.map +1 -0
- package/dist/src/upgrader.d.ts +29 -5
- package/dist/src/upgrader.js +143 -101
- package/dist/src/upgrader.js.map +1 -0
- package/dist/src/verification.d.ts +2 -2
- package/dist/src/verification.js +53 -28
- package/dist/src/verification.js.map +1 -0
- package/dist/src/version.js +9 -6
- package/dist/src/version.js.map +1 -0
- package/dist/typechain-types/AdminUpgradeabilityProxy.d.ts +59 -54
- package/dist/typechain-types/AdminUpgradeabilityProxy.js +1 -0
- package/dist/typechain-types/AdminUpgradeabilityProxy.js.map +1 -0
- package/dist/typechain-types/ProxyAdmin.d.ts +94 -137
- package/dist/typechain-types/ProxyAdmin.js +1 -0
- package/dist/typechain-types/ProxyAdmin.js.map +1 -0
- package/dist/typechain-types/common.d.ts +40 -11
- package/dist/typechain-types/common.js +1 -0
- package/dist/typechain-types/common.js.map +1 -0
- package/dist/typechain-types/factories/AdminUpgradeabilityProxy__factory.d.ts +71 -41
- package/dist/typechain-types/factories/AdminUpgradeabilityProxy__factory.js +8 -11
- package/dist/typechain-types/factories/AdminUpgradeabilityProxy__factory.js.map +1 -0
- package/dist/typechain-types/factories/ProxyAdmin__factory.d.ts +129 -41
- package/dist/typechain-types/factories/ProxyAdmin__factory.js +8 -11
- package/dist/typechain-types/factories/ProxyAdmin__factory.js.map +1 -0
- package/dist/typechain-types/factories/index.d.ts +2 -0
- package/dist/typechain-types/factories/index.js +11 -0
- package/dist/typechain-types/factories/index.js.map +1 -0
- package/dist/typechain-types/index.d.ts +1 -0
- package/dist/typechain-types/index.js +26 -1
- package/dist/typechain-types/index.js.map +1 -0
- package/package.json +15 -14
- package/dist/src/multiSend.d.ts +0 -2
- package/dist/src/multiSend.js +0 -47
|
@@ -1,33 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SafeToImaSubmitter = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
4
5
|
const safe_submitter_1 = require("./safe-submitter");
|
|
5
6
|
class SafeToImaSubmitter extends safe_submitter_1.SafeSubmitter {
|
|
6
|
-
constructor(safeAddress, imaInstance,
|
|
7
|
-
super(safeAddress,
|
|
7
|
+
constructor(safeAddress, imaInstance, network) {
|
|
8
|
+
super(safeAddress, network.mainnetChainId);
|
|
8
9
|
this.imaInstance = imaInstance;
|
|
9
|
-
this.targetSchainHash = targetSchainHash;
|
|
10
|
+
this.targetSchainHash = network.targetSchainHash;
|
|
10
11
|
}
|
|
11
12
|
async submit(transactions) {
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
const singleTransaction = 1;
|
|
14
|
+
if (transactions.length > singleTransaction) {
|
|
15
|
+
SafeToImaSubmitter.atomicityWarning();
|
|
14
16
|
}
|
|
15
|
-
const messageProxyForMainnet = await this.
|
|
16
|
-
const
|
|
17
|
-
|
|
17
|
+
const messageProxyForMainnet = await this.getMessageProxyForMainnet();
|
|
18
|
+
const messageProxyForMainnetAddress = await messageProxyForMainnet.getAddress();
|
|
19
|
+
const transactionsToIma = transactions.map((transaction) => ethers_1.Transaction.from({
|
|
18
20
|
"data": messageProxyForMainnet.interface.encodeFunctionData("postOutgoingMessage", [
|
|
19
21
|
this.targetSchainHash,
|
|
20
22
|
transaction.to,
|
|
21
23
|
transaction.data
|
|
22
|
-
])
|
|
24
|
+
]),
|
|
25
|
+
"to": messageProxyForMainnetAddress
|
|
23
26
|
}));
|
|
24
27
|
await super.submit(transactionsToIma);
|
|
25
28
|
}
|
|
26
|
-
async
|
|
27
|
-
if (this.
|
|
28
|
-
this.
|
|
29
|
+
async getMessageProxyForMainnet() {
|
|
30
|
+
if (typeof this.messageProxyForMainnet === "undefined") {
|
|
31
|
+
this.messageProxyForMainnet =
|
|
32
|
+
await this.imaInstance.getContract("MessageProxyForMainnet");
|
|
29
33
|
}
|
|
30
|
-
return this.
|
|
34
|
+
return this.messageProxyForMainnet;
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
37
|
exports.SafeToImaSubmitter = SafeToImaSubmitter;
|
|
38
|
+
//# sourceMappingURL=safe-to-ima-submitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-to-ima-submitter.js","sourceRoot":"","sources":["../../../src/submitters/safe-to-ima-submitter.ts"],"names":[],"mappings":";;;AAAA,mCAA4D;AAE5D,qDAA+C;AAQ/C,MAAa,kBAAmB,SAAQ,8BAAa;IAOjD,YACI,WAAmB,EACnB,WAAqB,EACrB,OAAgB;QAEhB,KAAK,CACD,WAAW,EACX,OAAO,CAAC,cAAc,CACzB,CAAC;QACF,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,MAAM,CAAE,YAA2B;QACrC,MAAM,iBAAiB,GAAG,CAAC,CAAC;QAC5B,IAAI,YAAY,CAAC,MAAM,GAAG,iBAAiB,EAAE;YACzC,kBAAkB,CAAC,gBAAgB,EAAE,CAAC;SACzC;QACD,MAAM,sBAAsB,GAAG,MAAM,IAAI,CAAC,yBAAyB,EAAE,CAAC;QACtE,MAAM,6BAA6B,GAAG,MAAM,sBAAsB,CAAC,UAAU,EAAE,CAAC;QAChF,MAAM,iBAAiB,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,oBAAW,CAAC,IAAI,CAAC;YACzE,MAAM,EAAE,sBAAsB,CAAC,SAAS,CAAC,kBAAkB,CACvD,qBAAqB,EACrB;gBACI,IAAI,CAAC,gBAAgB;gBACrB,WAAW,CAAC,EAAE;gBACd,WAAW,CAAC,IAAI;aACnB,CACJ;YACD,IAAI,EAAE,6BAA6B;SACtC,CAAC,CAAC,CAAC;QACJ,MAAM,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAC1C,CAAC;IAEO,KAAK,CAAC,yBAAyB;QACnC,IAAI,OAAO,IAAI,CAAC,sBAAsB,KAAK,WAAW,EAAE;YACpD,IAAI,CAAC,sBAAsB;gBACvB,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,wBAAwB,CAAC,CAAC;SACpE;QACD,OAAO,IAAI,CAAC,sBAAsB,CAAC;IACvC,CAAC;CACJ;AAhDD,gDAgDC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Transaction } from "ethers";
|
|
2
2
|
export declare abstract class Submitter {
|
|
3
|
-
abstract submit(transactions:
|
|
4
|
-
protected static
|
|
3
|
+
abstract submit(transactions: Transaction[]): Promise<void>;
|
|
4
|
+
protected static atomicityWarning(): void;
|
|
5
5
|
}
|
|
@@ -4,18 +4,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Submitter = void 0;
|
|
7
|
+
const exitCodes_1 = require("../exitCodes");
|
|
7
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
9
|
class Submitter {
|
|
9
10
|
// Protected
|
|
10
|
-
static
|
|
11
|
-
if (
|
|
12
|
-
console.log(chalk_1.default.
|
|
13
|
-
console.log(chalk_1.default.red("If not atomic upgrade is OK set ALLOW_NOT_ATOMIC_UPGRADE environment variable"));
|
|
14
|
-
process.exit(1);
|
|
11
|
+
static atomicityWarning() {
|
|
12
|
+
if (process.env.ALLOW_NOT_ATOMIC_UPGRADE) {
|
|
13
|
+
console.log(chalk_1.default.yellow("Not atomic upgrade is performing"));
|
|
15
14
|
}
|
|
16
15
|
else {
|
|
17
|
-
console.log(chalk_1.default.
|
|
16
|
+
console.log(chalk_1.default.red("The upgrade will consist" +
|
|
17
|
+
" of multiple transactions and will not be atomic"));
|
|
18
|
+
console.log(chalk_1.default.red("If not atomic upgrade is OK" +
|
|
19
|
+
" set ALLOW_NOT_ATOMIC_UPGRADE environment variable"));
|
|
20
|
+
process.exit(exitCodes_1.EXIT_CODES.NOT_ATOMIC_UPGRADE);
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
24
|
exports.Submitter = Submitter;
|
|
25
|
+
//# sourceMappingURL=submitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submitter.js","sourceRoot":"","sources":["../../../src/submitters/submitter.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAwC;AAExC,kDAA0B;AAG1B,MAAsB,SAAS;IAG3B,YAAY;IAEF,MAAM,CAAC,gBAAgB;QAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE;YACtC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,kCAAkC,CAAC,CAAC,CAAC;SACjE;aAAM;YACH,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,0BAA0B;gBAC5C,kDAAkD,CAAC,CAAC,CAAC;YACzD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,6BAA6B;gBAC/C,oDAAoD,CAAC,CAAC,CAAC;YAC3D,OAAO,CAAC,IAAI,CAAC,sBAAU,CAAC,kBAAkB,CAAC,CAAC;SAC/C;IACL,CAAC;CACJ;AAhBD,8BAgBC"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { BigNumberish, BytesLike } from "ethers";
|
|
2
|
-
import { ethers as RawEthers } from "ethers";
|
|
1
|
+
import { BigNumberish, BytesLike, ethers as RawEthers } from "ethers";
|
|
3
2
|
export declare const MARIONETTE_ADDRESS = "0xD2c0DeFACe000000000000000000000000000000";
|
|
4
3
|
type FunctionCallStruct = {
|
|
5
4
|
receiver: string;
|
|
6
5
|
value: BigNumberish;
|
|
7
6
|
data: BytesLike;
|
|
8
7
|
};
|
|
9
|
-
export interface
|
|
8
|
+
export interface LegacyMarionette extends RawEthers.BaseContract {
|
|
9
|
+
encodeFunctionCall(receiver: string, value: BigNumberish, data: BytesLike): Promise<BytesLike>;
|
|
10
|
+
version(): Promise<string>;
|
|
11
|
+
}
|
|
12
|
+
export interface Marionette extends RawEthers.BaseContract {
|
|
10
13
|
encodeFunctionCalls(functionCalls: FunctionCallStruct[]): Promise<BytesLike>;
|
|
11
14
|
version(): Promise<string>;
|
|
12
15
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marionette.js","sourceRoot":"","sources":["../../../../src/submitters/types/marionette.ts"],"names":[],"mappings":";;;AAGa,QAAA,kBAAkB,GAAG,4CAA4C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SkaleManifestData.js","sourceRoot":"","sources":["../../../src/types/SkaleManifestData.ts"],"names":[],"mappings":""}
|
package/dist/src/upgrader.d.ts
CHANGED
|
@@ -1,18 +1,42 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Transaction } from "ethers";
|
|
2
|
+
import { Instance } from "@skalenetwork/skale-contracts-ethers-v6";
|
|
3
|
+
import { NonceProvider } from "./nonceProvider";
|
|
4
|
+
import { ProxyAdmin } from "../typechain-types";
|
|
5
|
+
import Semaphore from 'semaphore-async-await';
|
|
2
6
|
import { Submitter } from "./submitters/submitter";
|
|
3
|
-
|
|
7
|
+
interface Project {
|
|
8
|
+
name: string;
|
|
9
|
+
instance: Instance;
|
|
10
|
+
version: string;
|
|
11
|
+
contractNamesToUpgrade: string[];
|
|
12
|
+
}
|
|
4
13
|
export declare abstract class Upgrader {
|
|
5
14
|
instance: Instance;
|
|
6
15
|
targetVersion: string;
|
|
7
16
|
contractNamesToUpgrade: string[];
|
|
8
17
|
projectName: string;
|
|
9
|
-
transactions:
|
|
18
|
+
transactions: Transaction[];
|
|
10
19
|
submitter: Submitter;
|
|
11
|
-
|
|
20
|
+
nonceProvider?: NonceProvider;
|
|
21
|
+
deploySemaphore: Semaphore;
|
|
22
|
+
constructor(project: Project, submitter?: Submitter);
|
|
12
23
|
abstract getDeployedVersion: () => Promise<string | undefined>;
|
|
13
24
|
abstract setVersion: (newVersion: string) => Promise<void>;
|
|
14
25
|
deployNewContracts?: () => Promise<void>;
|
|
15
26
|
initialize?: () => Promise<void>;
|
|
16
27
|
upgrade(): Promise<void>;
|
|
17
|
-
|
|
28
|
+
static getProxyAdmin(): Promise<ProxyAdmin>;
|
|
29
|
+
private callInitialize;
|
|
30
|
+
private callDeployNewContracts;
|
|
31
|
+
private prepareVersion;
|
|
32
|
+
private writeTransactions;
|
|
33
|
+
private static verify;
|
|
34
|
+
private switchToNewImplementations;
|
|
35
|
+
private deployNewImplementations;
|
|
36
|
+
private protectedDeployNewImplementation;
|
|
37
|
+
private deployNewImplementation;
|
|
38
|
+
private prepareUpgrade;
|
|
39
|
+
private getNormalizedDeployedVersion;
|
|
40
|
+
private checkVersion;
|
|
18
41
|
}
|
|
42
|
+
export {};
|
package/dist/src/upgrader.js
CHANGED
|
@@ -4,137 +4,179 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Upgrader = void 0;
|
|
7
|
-
const
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const upgrades_core_1 = require("@openzeppelin/upgrades-core");
|
|
9
|
+
const hardhat_1 = require("hardhat");
|
|
10
|
+
const auto_submitter_1 = require("./submitters/auto-submitter");
|
|
11
|
+
const exitCodes_1 = require("./exitCodes");
|
|
12
|
+
const nonceProvider_1 = require("./nonceProvider");
|
|
13
|
+
const semaphore_async_await_1 = __importDefault(require("semaphore-async-await"));
|
|
8
14
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const hardhat_2 = require("hardhat");
|
|
10
|
-
const admin_1 = require("@openzeppelin/hardhat-upgrades/dist/admin");
|
|
11
|
-
const version_1 = require("./version");
|
|
12
15
|
const fs_1 = require("fs");
|
|
13
|
-
const
|
|
14
|
-
const
|
|
16
|
+
const contractFactory_1 = require("./contractFactory");
|
|
17
|
+
const version_1 = require("./version");
|
|
15
18
|
const verification_1 = require("./verification");
|
|
16
|
-
const
|
|
19
|
+
const withoutNull = (array) => array.
|
|
20
|
+
filter((element) => element !== null);
|
|
21
|
+
const maxSimultaneousDeployments = 8;
|
|
22
|
+
// 10 minutes
|
|
23
|
+
const deployTimeout = 60e4;
|
|
17
24
|
class Upgrader {
|
|
18
|
-
constructor(
|
|
19
|
-
this.targetVersion =
|
|
20
|
-
if (!
|
|
21
|
-
this.targetVersion = `${
|
|
25
|
+
constructor(project, submitter = new auto_submitter_1.AutoSubmitter()) {
|
|
26
|
+
this.targetVersion = project.version;
|
|
27
|
+
if (!project.version.includes("-")) {
|
|
28
|
+
this.targetVersion = `${project.version}-stable.0`;
|
|
22
29
|
}
|
|
23
|
-
this.instance = instance;
|
|
24
|
-
this.contractNamesToUpgrade = contractNamesToUpgrade;
|
|
25
|
-
this.projectName =
|
|
30
|
+
this.instance = project.instance;
|
|
31
|
+
this.contractNamesToUpgrade = project.contractNamesToUpgrade;
|
|
32
|
+
this.projectName = project.name;
|
|
26
33
|
this.transactions = [];
|
|
27
34
|
this.submitter = submitter;
|
|
35
|
+
this.deploySemaphore = new semaphore_async_await_1.default(maxSimultaneousDeployments);
|
|
28
36
|
}
|
|
29
37
|
// Public
|
|
30
38
|
async upgrade() {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const version = await this.prepareVersion();
|
|
40
|
+
await this.callDeployNewContracts();
|
|
41
|
+
const contractsToUpgrade = await this.deployNewImplementations();
|
|
42
|
+
await this.switchToNewImplementations(contractsToUpgrade, await Upgrader.getProxyAdmin());
|
|
43
|
+
await this.callInitialize();
|
|
44
|
+
// Write version
|
|
45
|
+
await this.setVersion(version);
|
|
46
|
+
await this.writeTransactions(version);
|
|
47
|
+
await this.submitter.submit(this.transactions);
|
|
48
|
+
await Upgrader.verify(contractsToUpgrade);
|
|
49
|
+
console.log("Done");
|
|
50
|
+
}
|
|
51
|
+
static async getProxyAdmin() {
|
|
52
|
+
const manifest = await upgrades_core_1.Manifest.forNetwork(hardhat_1.network.provider);
|
|
53
|
+
const adminDeployment = await manifest.getAdmin();
|
|
54
|
+
if (!adminDeployment) {
|
|
55
|
+
throw new Error("Can't load ProxyAdmin address");
|
|
42
56
|
}
|
|
43
|
-
|
|
44
|
-
|
|
57
|
+
const factory = await hardhat_1.ethers.getContractFactory("ProxyAdmin");
|
|
58
|
+
return factory.attach(adminDeployment.address);
|
|
59
|
+
}
|
|
60
|
+
// Private
|
|
61
|
+
async callInitialize() {
|
|
62
|
+
if (typeof this.initialize !== "undefined") {
|
|
63
|
+
await this.initialize();
|
|
45
64
|
}
|
|
46
|
-
|
|
47
|
-
|
|
65
|
+
}
|
|
66
|
+
async callDeployNewContracts() {
|
|
67
|
+
if (typeof this.deployNewContracts !== "undefined") {
|
|
48
68
|
// Deploy new contracts
|
|
49
69
|
await this.deployNewContracts();
|
|
50
70
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
else {
|
|
70
|
-
console.log(chalk_1.default.gray(`Contract ${contract} is up to date`));
|
|
71
|
-
}
|
|
71
|
+
}
|
|
72
|
+
async prepareVersion() {
|
|
73
|
+
const version = await (0, version_1.getVersion)();
|
|
74
|
+
await this.checkVersion(version);
|
|
75
|
+
console.log(`Will mark updated version as ${version}`);
|
|
76
|
+
return version;
|
|
77
|
+
}
|
|
78
|
+
async writeTransactions(version) {
|
|
79
|
+
const indentation = 4;
|
|
80
|
+
await fs_1.promises.writeFile(`data/transactions-${version}-${hardhat_1.network.name}.json`, JSON.stringify(this.transactions, null, indentation));
|
|
81
|
+
}
|
|
82
|
+
static async verify(contractsToUpgrade) {
|
|
83
|
+
if (process.env.NO_VERIFY) {
|
|
84
|
+
console.log("Skip verification");
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
console.log("Start verification");
|
|
88
|
+
await Promise.all(contractsToUpgrade.map((contract) => (0, verification_1.verify)(contract.name, contract.implementationAddress, [])));
|
|
72
89
|
}
|
|
73
|
-
|
|
90
|
+
}
|
|
91
|
+
async switchToNewImplementations(contractsToUpgrade, proxyAdmin) {
|
|
92
|
+
const proxyAdminAddress = await proxyAdmin.getAddress();
|
|
74
93
|
for (const contract of contractsToUpgrade) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
94
|
+
const infoMessage = `Prepare transaction to upgrade ${contract.name}` +
|
|
95
|
+
` at ${contract.proxyAddress}` +
|
|
96
|
+
` to ${contract.implementationAddress}`;
|
|
97
|
+
console.log(chalk_1.default.yellowBright(infoMessage));
|
|
98
|
+
this.transactions.push(ethers_1.Transaction.from({
|
|
78
99
|
"data": proxyAdmin.interface.encodeFunctionData("upgrade", [
|
|
79
100
|
contract.proxyAddress,
|
|
80
101
|
contract.implementationAddress
|
|
81
|
-
])
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (this.initialize !== undefined) {
|
|
85
|
-
await this.initialize();
|
|
102
|
+
]),
|
|
103
|
+
"to": proxyAdminAddress
|
|
104
|
+
}));
|
|
86
105
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
await
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
106
|
+
}
|
|
107
|
+
async deployNewImplementations() {
|
|
108
|
+
const [deployer] = await hardhat_1.ethers.getSigners();
|
|
109
|
+
this.nonceProvider ?? (this.nonceProvider = await nonceProvider_1.NonceProvider.createForWallet(deployer));
|
|
110
|
+
const contracts = await Promise.all(this.contractNamesToUpgrade.
|
|
111
|
+
map(this.protectedDeployNewImplementation, this));
|
|
112
|
+
return withoutNull(contracts);
|
|
113
|
+
}
|
|
114
|
+
async protectedDeployNewImplementation(contract) {
|
|
115
|
+
await this.deploySemaphore.acquire();
|
|
116
|
+
let result = null;
|
|
117
|
+
try {
|
|
118
|
+
result = await this.deployNewImplementation(contract);
|
|
93
119
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
for (const contract of contractsToUpgrade) {
|
|
97
|
-
await (0, verification_1.verify)(contract.name, contract.implementationAddress, []);
|
|
98
|
-
}
|
|
120
|
+
finally {
|
|
121
|
+
this.deploySemaphore.release();
|
|
99
122
|
}
|
|
100
|
-
|
|
123
|
+
return result;
|
|
101
124
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
125
|
+
async deployNewImplementation(contract) {
|
|
126
|
+
const contractFactory = await (0, contractFactory_1.getContractFactoryAndUpdateManifest)(contract, this.nonceProvider);
|
|
127
|
+
const proxyAddress = await (await this.instance.getContract(contract)).getAddress();
|
|
128
|
+
console.log(`Prepare upgrade of ${contract}`);
|
|
129
|
+
return this.prepareUpgrade(contract, proxyAddress, contractFactory);
|
|
130
|
+
}
|
|
131
|
+
async prepareUpgrade(contractName, proxyAddress, contractFactory) {
|
|
132
|
+
const currentImplementationAddress = await (0, upgrades_core_1.getImplementationAddress)(hardhat_1.network.provider, proxyAddress);
|
|
133
|
+
const nonce = this.nonceProvider?.reserveNonce();
|
|
134
|
+
const newImplementationAddress = await hardhat_1.upgrades.prepareUpgrade(proxyAddress, contractFactory, {
|
|
135
|
+
"timeout": deployTimeout,
|
|
136
|
+
"txOverrides": {
|
|
137
|
+
nonce
|
|
138
|
+
},
|
|
139
|
+
"unsafeAllowLinkedLibraries": true,
|
|
140
|
+
"unsafeAllowRenames": true
|
|
141
|
+
});
|
|
142
|
+
if (newImplementationAddress !== currentImplementationAddress) {
|
|
143
|
+
return {
|
|
144
|
+
"implementationAddress": newImplementationAddress,
|
|
145
|
+
"name": contractName,
|
|
146
|
+
proxyAddress
|
|
147
|
+
};
|
|
108
148
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
Object.assign(manifest, { "libraries": {} });
|
|
149
|
+
console.log(chalk_1.default.gray(`Contract ${contractName} is up to date`));
|
|
150
|
+
if (nonce) {
|
|
151
|
+
this.nonceProvider?.releaseNonce(nonce);
|
|
113
152
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const libraryBytecodeHash = manifest.libraries[libraryName].bytecodeHash;
|
|
122
|
-
if ((0, upgrades_core_1.hashBytecode)(bytecode) !== libraryBytecodeHash) {
|
|
123
|
-
librariesToUpgrade.push(libraryName);
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
async getNormalizedDeployedVersion() {
|
|
156
|
+
const deployedVersion = await this.getDeployedVersion();
|
|
157
|
+
if (deployedVersion) {
|
|
158
|
+
if (!deployedVersion.includes("-")) {
|
|
159
|
+
return `${deployedVersion}-stable.0`;
|
|
124
160
|
}
|
|
125
|
-
|
|
126
|
-
|
|
161
|
+
return deployedVersion;
|
|
162
|
+
}
|
|
163
|
+
return deployedVersion;
|
|
164
|
+
}
|
|
165
|
+
async checkVersion(version) {
|
|
166
|
+
const deployedVersion = await this.getNormalizedDeployedVersion();
|
|
167
|
+
if (deployedVersion) {
|
|
168
|
+
if (deployedVersion !== this.targetVersion) {
|
|
169
|
+
const cannotUpgradeMessage = `This script can't upgrade version ${deployedVersion}` +
|
|
170
|
+
` to ${version}`;
|
|
171
|
+
console.log(chalk_1.default.red(cannotUpgradeMessage));
|
|
172
|
+
process.exit(exitCodes_1.EXIT_CODES.BAD_VERSION);
|
|
127
173
|
}
|
|
128
174
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
manifest.libraries[libraryName] = { "address": libraryAddress,
|
|
133
|
-
"bytecodeHash": (0, upgrades_core_1.hashBytecode)(bytecode) };
|
|
175
|
+
else {
|
|
176
|
+
const cannotCheckMessage = `Can't check currently deployed version of ${this.projectName}`;
|
|
177
|
+
console.log(chalk_1.default.yellow(cannotCheckMessage));
|
|
134
178
|
}
|
|
135
|
-
Object.assign(libraries, oldLibraries);
|
|
136
|
-
await fs_1.promises.writeFile(await (0, deploy_1.getManifestFile)(), JSON.stringify(manifest, null, 4));
|
|
137
|
-
return await (0, deploy_1.getLinkedContractFactory)(contract, libraries);
|
|
138
179
|
}
|
|
139
180
|
}
|
|
140
181
|
exports.Upgrader = Upgrader;
|
|
182
|
+
//# sourceMappingURL=upgrader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrader.js","sourceRoot":"","sources":["../../src/upgrader.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAoD;AACpD,+DAA+E;AAC/E,qCAAkD;AAClD,gEAA0D;AAC1D,2CAAuC;AAEvC,mDAA8C;AAE9C,kFAA8C;AAE9C,kDAA0B;AAC1B,2BAAkC;AAClC,uDAAsE;AACtE,uCAAqC;AACrC,iDAAsC;AAgBtC,MAAM,WAAW,GAAG,CAAI,KAAsB,EAAE,EA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AAM,oBAAoB,GACtB,qCAAqC,eAAe,EAAE;oBACtD,OAAO,OAAO,EAAE,CAAC;gBACrB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC;gBAC7C,OAAO,CAAC,IAAI,CAAC,sBAAU,CAAC,WAAW,CAAC,CAAC;aACxC;SACJ;aAAM;YACH,MAAM,kBAAkB,GACpB,6CAA6C,IAAI,CAAC,WAAW,EAAE,CAAC;YACpE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC;SACjD;IACL,CAAC;CACJ;AA1PD,4BA0PC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
export declare
|
|
1
|
+
export declare const verify: (contractName: string, contractAddress: string, constructorArguments: object) => Promise<void>;
|
|
2
|
+
export declare const verifyProxy: (contractName: string, proxyAddress: string, constructorArguments: object) => Promise<void>;
|
package/dist/src/verification.js
CHANGED
|
@@ -8,35 +8,60 @@ const hardhat_1 = require("hardhat");
|
|
|
8
8
|
const chain_config_1 = require("@nomicfoundation/hardhat-verify/internal/chain-config");
|
|
9
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
10
10
|
const upgrades_core_1 = require("@openzeppelin/upgrades-core");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
catch (e) {
|
|
23
|
-
if (e instanceof Error) {
|
|
24
|
-
if (e.toString().includes("Contract source code already verified")) {
|
|
25
|
-
console.log(chalk_1.default.grey(`${contractName} is already verified`));
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
console.log(chalk_1.default.red(`Contract ${contractName} was not verified on etherscan`));
|
|
29
|
-
console.log(e.toString());
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
console.log("Unknown exception type:", e);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
11
|
+
const RETRIES_AMOUNT = 5;
|
|
12
|
+
const processError = (error, contractName) => {
|
|
13
|
+
if (error instanceof Error) {
|
|
14
|
+
const alreadyVerifiedErrorLine = "Contract source code already verified";
|
|
15
|
+
if (error.toString().includes(alreadyVerifiedErrorLine)) {
|
|
16
|
+
const infoMessage = `${contractName} is already verified`;
|
|
17
|
+
console.log(chalk_1.default.grey(infoMessage));
|
|
18
|
+
return;
|
|
35
19
|
}
|
|
20
|
+
const errorMessage = `Contract ${contractName} was not verified on etherscan`;
|
|
21
|
+
console.log(chalk_1.default.red(errorMessage));
|
|
22
|
+
console.log(error.toString());
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
console.log("Unknown exception type:", error);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const verificationAttempt = async (contractName, contractAddress, constructorArguments) => {
|
|
29
|
+
try {
|
|
30
|
+
await (0, hardhat_1.run)("verify:verify", {
|
|
31
|
+
"address": contractAddress,
|
|
32
|
+
constructorArguments
|
|
33
|
+
});
|
|
34
|
+
return true;
|
|
36
35
|
}
|
|
37
|
-
|
|
36
|
+
catch (error) {
|
|
37
|
+
processError(error, contractName);
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
};
|
|
41
|
+
const verifyWithRetry = async (verificationTarget, attempts) => {
|
|
42
|
+
if (attempts) {
|
|
43
|
+
if (!await verificationAttempt(verificationTarget.contractName, verificationTarget.contractAddress, verificationTarget.constructorArguments)) {
|
|
44
|
+
const failedAttempts = 1;
|
|
45
|
+
await verifyWithRetry(verificationTarget, attempts - failedAttempts);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const verify = async (contractName, contractAddress, constructorArguments) => {
|
|
50
|
+
const { chainId } = await hardhat_1.ethers.provider.getNetwork();
|
|
51
|
+
if (!chain_config_1.builtinChains.map((chain) => chain.chainId).includes(Number(chainId))) {
|
|
52
|
+
const errorMessage = "Verification on this network is not supported";
|
|
53
|
+
console.log(chalk_1.default.grey(errorMessage));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
await verifyWithRetry({
|
|
57
|
+
constructorArguments,
|
|
58
|
+
contractAddress,
|
|
59
|
+
contractName
|
|
60
|
+
}, RETRIES_AMOUNT);
|
|
61
|
+
};
|
|
38
62
|
exports.verify = verify;
|
|
39
|
-
async
|
|
40
|
-
await verify(contractName, await (0, upgrades_core_1.getImplementationAddress)(hardhat_1.network.provider, proxyAddress), constructorArguments);
|
|
41
|
-
}
|
|
63
|
+
const verifyProxy = async (contractName, proxyAddress, constructorArguments) => {
|
|
64
|
+
await (0, exports.verify)(contractName, await (0, upgrades_core_1.getImplementationAddress)(hardhat_1.network.provider, proxyAddress), constructorArguments);
|
|
65
|
+
};
|
|
42
66
|
exports.verifyProxy = verifyProxy;
|
|
67
|
+
//# sourceMappingURL=verification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verification.js","sourceRoot":"","sources":["../../src/verification.ts"],"names":[],"mappings":";;;;;;AAAA,qCAA6C;AAC7C,wFAE+D;AAC/D,kDAA0B;AAC1B,+DAAqE;AAErE,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB,MAAM,YAAY,GAAG,CAAC,KAAc,EAAE,YAAoB,EAAE,EAAE;IAC1D,IAAI,KAAK,YAAY,KAAK,EAAE;QACxB,MAAM,wBAAwB,GAC1B,uCAAuC,CAAC;QAC5C,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC,EAAE;YACrD,MAAM,WAAW,GAAG,GAAG,YAAY,sBAAsB,CAAC;YAC1D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;YACrC,OAAO;SACV;QACD,MAAM,YAAY,GACd,YAAY,YAAY,gCAAgC,CAAC;QAC7D,OA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CAAC,EAAE;QACxE,MAAM,YAAY,GAAG,+CAA+C,CAAC;QACrE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QACtC,OAAO;KACV;IACD,MAAM,eAAe,CACjB;QACI,oBAAoB;QACpB,eAAe;QACf,YAAY;KACf,EACD,cAAc,CACjB,CAAC;AACN,CAAC,CAAC;AAnBW,QAAA,MAAM,UAmBjB;AAEK,MAAM,WAAW,GAAG,KAAK,EAC5B,YAAoB,EACpB,YAAoB,EACpB,oBAA4B,EAC9B,EAAE;IACA,MAAM,IAAA,cAAM,EACR,YAAY,EACZ,MAAM,IAAA,wCAAwB,EAC1B,iBAAO,CAAC,QAAQ,EAChB,YAAY,CACf,EACD,oBAAoB,CACvB,CAAC;AACN,CAAC,CAAC;AAbW,QAAA,WAAW,eAatB"}
|
package/dist/src/version.js
CHANGED
|
@@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getVersion = void 0;
|
|
7
|
-
const child_process_1 = require("child_process");
|
|
8
7
|
const fs_1 = require("fs");
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
9
|
const util_1 = __importDefault(require("util"));
|
|
10
10
|
const exec = util_1.default.promisify(child_process_1.exec);
|
|
11
11
|
class VersionNotFound extends Error {
|
|
12
12
|
}
|
|
13
|
-
async
|
|
14
|
-
if (folder === undefined) {
|
|
13
|
+
const getVersionFilename = async (folder) => {
|
|
14
|
+
if (typeof folder === "undefined") {
|
|
15
15
|
return getVersionFilename((await exec("git rev-parse --show-toplevel")).stdout.trim());
|
|
16
16
|
}
|
|
17
17
|
const VERSION_FILENAME = "VERSION";
|
|
@@ -19,14 +19,16 @@ async function getVersionFilename(folder) {
|
|
|
19
19
|
if ((0, fs_1.existsSync)(path)) {
|
|
20
20
|
return path;
|
|
21
21
|
}
|
|
22
|
-
for (const entry of await fs_1.promises.readdir(folder, {
|
|
23
|
-
"recursive": true
|
|
22
|
+
for (const entry of await fs_1.promises.readdir(folder, {
|
|
23
|
+
"recursive": true,
|
|
24
|
+
"withFileTypes": true
|
|
25
|
+
})) {
|
|
24
26
|
if (entry.isFile() && entry.name === VERSION_FILENAME) {
|
|
25
27
|
return `${entry.path}/${entry.name}`;
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
throw new VersionNotFound("Can't find version file");
|
|
29
|
-
}
|
|
31
|
+
};
|
|
30
32
|
const getVersion = async () => {
|
|
31
33
|
if (process.env.VERSION) {
|
|
32
34
|
return process.env.VERSION;
|
|
@@ -40,3 +42,4 @@ const getVersion = async () => {
|
|
|
40
42
|
}
|
|
41
43
|
};
|
|
42
44
|
exports.getVersion = getVersion;
|
|
45
|
+
//# sourceMappingURL=version.js.map
|