@skalenetwork/upgrade-tools 3.0.0-linter.4 → 3.0.0-linter.40

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.
Files changed (84) hide show
  1. package/dist/hardhat.config.d.ts +2 -2
  2. package/dist/hardhat.config.js +5 -3
  3. package/dist/hardhat.config.js.map +1 -0
  4. package/dist/src/abi.d.ts +2 -2
  5. package/dist/src/abi.js +4 -3
  6. package/dist/src/abi.js.map +1 -0
  7. package/dist/src/contractFactory.d.ts +4 -0
  8. package/dist/src/contractFactory.js +84 -0
  9. package/dist/src/contractFactory.js.map +1 -0
  10. package/dist/src/deploy.d.ts +4 -4
  11. package/dist/src/deploy.js +56 -62
  12. package/dist/src/deploy.js.map +1 -0
  13. package/dist/src/exitCodes.d.ts +7 -0
  14. package/dist/src/exitCodes.js +12 -0
  15. package/dist/src/exitCodes.js.map +1 -0
  16. package/dist/src/gnosis-safe.d.ts +2 -2
  17. package/dist/src/gnosis-safe.js +113 -104
  18. package/dist/src/gnosis-safe.js.map +1 -0
  19. package/dist/src/index.d.ts +0 -1
  20. package/dist/src/index.js +1 -1
  21. package/dist/src/index.js.map +1 -0
  22. package/dist/src/nonceProvider.d.ts +7 -0
  23. package/dist/src/nonceProvider.js +18 -0
  24. package/dist/src/nonceProvider.js.map +1 -0
  25. package/dist/src/submitters/auto-submitter.d.ts +18 -5
  26. package/dist/src/submitters/auto-submitter.js +107 -95
  27. package/dist/src/submitters/auto-submitter.js.map +1 -0
  28. package/dist/src/submitters/eoa-submitter.d.ts +2 -2
  29. package/dist/src/submitters/eoa-submitter.js +15 -13
  30. package/dist/src/submitters/eoa-submitter.js.map +1 -0
  31. package/dist/src/submitters/index.js +1 -0
  32. package/dist/src/submitters/index.js.map +1 -0
  33. package/dist/src/submitters/safe-ima-legacy-marionette-submitter.d.ts +4 -3
  34. package/dist/src/submitters/safe-ima-legacy-marionette-submitter.js +14 -19
  35. package/dist/src/submitters/safe-ima-legacy-marionette-submitter.js.map +1 -0
  36. package/dist/src/submitters/safe-ima-marionette-submitter.d.ts +3 -3
  37. package/dist/src/submitters/safe-ima-marionette-submitter.js +12 -16
  38. package/dist/src/submitters/safe-ima-marionette-submitter.js.map +1 -0
  39. package/dist/src/submitters/safe-submitter.d.ts +4 -4
  40. package/dist/src/submitters/safe-submitter.js +3 -2
  41. package/dist/src/submitters/safe-submitter.js.map +1 -0
  42. package/dist/src/submitters/safe-to-ima-submitter.d.ts +11 -6
  43. package/dist/src/submitters/safe-to-ima-submitter.js +18 -13
  44. package/dist/src/submitters/safe-to-ima-submitter.js.map +1 -0
  45. package/dist/src/submitters/submitter.d.ts +3 -3
  46. package/dist/src/submitters/submitter.js +10 -6
  47. package/dist/src/submitters/submitter.js.map +1 -0
  48. package/dist/src/submitters/types/marionette.d.ts +6 -3
  49. package/dist/src/submitters/types/marionette.js +1 -0
  50. package/dist/src/submitters/types/marionette.js.map +1 -0
  51. package/dist/src/types/SkaleManifestData.js +1 -0
  52. package/dist/src/types/SkaleManifestData.js.map +1 -0
  53. package/dist/src/upgrader.d.ts +28 -5
  54. package/dist/src/upgrader.js +137 -102
  55. package/dist/src/upgrader.js.map +1 -0
  56. package/dist/src/verification.d.ts +2 -2
  57. package/dist/src/verification.js +53 -28
  58. package/dist/src/verification.js.map +1 -0
  59. package/dist/src/version.js +9 -6
  60. package/dist/src/version.js.map +1 -0
  61. package/dist/typechain-types/AdminUpgradeabilityProxy.d.ts +59 -54
  62. package/dist/typechain-types/AdminUpgradeabilityProxy.js +1 -0
  63. package/dist/typechain-types/AdminUpgradeabilityProxy.js.map +1 -0
  64. package/dist/typechain-types/ProxyAdmin.d.ts +94 -137
  65. package/dist/typechain-types/ProxyAdmin.js +1 -0
  66. package/dist/typechain-types/ProxyAdmin.js.map +1 -0
  67. package/dist/typechain-types/common.d.ts +40 -11
  68. package/dist/typechain-types/common.js +1 -0
  69. package/dist/typechain-types/common.js.map +1 -0
  70. package/dist/typechain-types/factories/AdminUpgradeabilityProxy__factory.d.ts +71 -41
  71. package/dist/typechain-types/factories/AdminUpgradeabilityProxy__factory.js +8 -11
  72. package/dist/typechain-types/factories/AdminUpgradeabilityProxy__factory.js.map +1 -0
  73. package/dist/typechain-types/factories/ProxyAdmin__factory.d.ts +129 -41
  74. package/dist/typechain-types/factories/ProxyAdmin__factory.js +8 -11
  75. package/dist/typechain-types/factories/ProxyAdmin__factory.js.map +1 -0
  76. package/dist/typechain-types/factories/index.d.ts +2 -0
  77. package/dist/typechain-types/factories/index.js +11 -0
  78. package/dist/typechain-types/factories/index.js.map +1 -0
  79. package/dist/typechain-types/index.d.ts +1 -0
  80. package/dist/typechain-types/index.js +26 -1
  81. package/dist/typechain-types/index.js.map +1 -0
  82. package/package.json +15 -14
  83. package/dist/src/multiSend.d.ts +0 -2
  84. 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, targetSchainHash, chainId) {
7
- super(safeAddress, chainId);
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
- if (transactions.length > 1) {
13
- SafeToImaSubmitter._atomicityWarning();
13
+ const singleTransaction = 1;
14
+ if (transactions.length > singleTransaction) {
15
+ SafeToImaSubmitter.atomicityWarning();
14
16
  }
15
- const messageProxyForMainnet = await this._getMessageProxyForMainnet();
16
- const transactionsToIma = transactions.map((transaction) => ({
17
- "to": messageProxyForMainnet.address,
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 _getMessageProxyForMainnet() {
27
- if (this._messageProxyForMainnet === undefined) {
28
- this._messageProxyForMainnet = await this.imaInstance.getContract("MessageProxyForMainnet");
29
+ async getMessageProxyForMainnet() {
30
+ if (typeof this.messageProxyForMainnet === "undefined") {
31
+ this.messageProxyForMainnet =
32
+ await this.imaInstance.getContract("MessageProxyForMainnet");
29
33
  }
30
- return this._messageProxyForMainnet;
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 { UnsignedTransaction } from "ethers";
1
+ import { Transaction } from "ethers";
2
2
  export declare abstract class Submitter {
3
- abstract submit(transactions: UnsignedTransaction[]): Promise<void>;
4
- protected static _atomicityWarning(): void;
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 _atomicityWarning() {
11
- if (!process.env.ALLOW_NOT_ATOMIC_UPGRADE) {
12
- console.log(chalk_1.default.red("The upgrade will consist of multiple transactions and will not be atomic"));
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.yellow("Not atomic upgrade is performing"));
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 Marionette extends RawEthers.Contract {
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
  }
@@ -2,3 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MARIONETTE_ADDRESS = void 0;
4
4
  exports.MARIONETTE_ADDRESS = "0xD2c0DeFACe000000000000000000000000000000";
5
+ //# sourceMappingURL=marionette.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marionette.js","sourceRoot":"","sources":["../../../../src/submitters/types/marionette.ts"],"names":[],"mappings":";;;AAGa,QAAA,kBAAkB,GAAG,4CAA4C,CAAC"}
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=SkaleManifestData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SkaleManifestData.js","sourceRoot":"","sources":["../../../src/types/SkaleManifestData.ts"],"names":[],"mappings":""}
@@ -1,18 +1,41 @@
1
- import { UnsignedTransaction } from "ethers";
1
+ import { Instance } from "@skalenetwork/skale-contracts-ethers-v6";
2
+ import { NonceProvider } from "./nonceProvider";
3
+ import { ProxyAdmin } from "../typechain-types";
4
+ import Semaphore from 'semaphore-async-await';
2
5
  import { Submitter } from "./submitters/submitter";
3
- import { Instance } from "@skalenetwork/skale-contracts-ethers-v5";
6
+ import { Transaction } from "ethers";
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: UnsignedTransaction[];
18
+ transactions: Transaction[];
10
19
  submitter: Submitter;
11
- constructor(projectName: string, targetVersion: string, instance: Instance, contractNamesToUpgrade: string[], submitter?: Submitter);
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
- private static _getContractFactoryAndUpdateManifest;
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 getNormalizedDeployedVersion;
39
+ private checkVersion;
18
40
  }
41
+ export {};
@@ -4,137 +4,172 @@ 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 hardhat_1 = __importDefault(require("hardhat"));
7
+ const upgrades_core_1 = require("@openzeppelin/upgrades-core");
8
+ const hardhat_1 = require("hardhat");
9
+ const auto_submitter_1 = require("./submitters/auto-submitter");
10
+ const exitCodes_1 = require("./exitCodes");
11
+ const nonceProvider_1 = require("./nonceProvider");
12
+ const semaphore_async_await_1 = __importDefault(require("semaphore-async-await"));
13
+ const ethers_1 = require("ethers");
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 deploy_1 = require("./deploy");
14
- const upgrades_core_1 = require("@openzeppelin/upgrades-core");
16
+ const contractFactory_1 = require("./contractFactory");
17
+ const version_1 = require("./version");
15
18
  const verification_1 = require("./verification");
16
- const auto_submitter_1 = require("./submitters/auto-submitter");
19
+ const withoutNull = (array) => array.
20
+ filter((element) => element !== null);
21
+ const maxSimultaneousDeployments = 5;
22
+ // 10 minutes
23
+ const deployTimeout = 60e4;
17
24
  class Upgrader {
18
- constructor(projectName, targetVersion, instance, contractNamesToUpgrade, submitter = new auto_submitter_1.AutoSubmitter()) {
19
- this.targetVersion = targetVersion;
20
- if (!targetVersion.includes("-")) {
21
- this.targetVersion = `${targetVersion}-stable.0`;
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 = 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 proxyAdmin = await (0, admin_1.getManifestAdmin)(hardhat_1.default);
32
- let deployedVersion = await this.getDeployedVersion();
33
- const version = await (0, version_1.getVersion)();
34
- if (deployedVersion) {
35
- if (!deployedVersion.includes("-")) {
36
- deployedVersion += "-stable.0";
37
- }
38
- if (deployedVersion !== this.targetVersion) {
39
- console.log(chalk_1.default.red(`This script can't upgrade version ${deployedVersion} to ${version}`));
40
- process.exit(1);
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
- else {
44
- console.log(chalk_1.default.yellow(`Can't check currently deployed version of ${this.projectName}`));
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
- console.log(`Will mark updated version as ${version}`);
47
- if (this.deployNewContracts !== undefined) {
65
+ }
66
+ async callDeployNewContracts() {
67
+ if (typeof this.deployNewContracts !== "undefined") {
48
68
  // Deploy new contracts
49
69
  await this.deployNewContracts();
50
70
  }
51
- // Deploy new implementations
52
- const contractsToUpgrade = [];
53
- for (const contract of this.contractNamesToUpgrade) {
54
- const contractFactory = await Upgrader._getContractFactoryAndUpdateManifest(contract);
55
- const proxyAddress = (await this.instance.getContract(contract)).address;
56
- console.log(`Prepare upgrade of ${contract}`);
57
- const currentImplementationAddress = await (0, upgrades_core_1.getImplementationAddress)(hardhat_2.network.provider, proxyAddress);
58
- const newImplementationAddress = await hardhat_2.upgrades.prepareUpgrade(proxyAddress, contractFactory, {
59
- "unsafeAllowLinkedLibraries": true,
60
- "unsafeAllowRenames": true
61
- });
62
- if (newImplementationAddress !== currentImplementationAddress) {
63
- contractsToUpgrade.push({
64
- proxyAddress,
65
- "implementationAddress": newImplementationAddress,
66
- "name": contract
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
- // Switch proxies to new implementations
90
+ }
91
+ async switchToNewImplementations(contractsToUpgrade, proxyAdmin) {
92
+ const proxyAdminAddress = await proxyAdmin.getAddress();
74
93
  for (const contract of contractsToUpgrade) {
75
- console.log(chalk_1.default.yellowBright(`Prepare transaction to upgrade ${contract.name} at ${contract.proxyAddress} to ${contract.implementationAddress}`));
76
- this.transactions.push({
77
- "to": proxyAdmin.address,
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
- // Write version
88
- await this.setVersion(version);
89
- await fs_1.promises.writeFile(`data/transactions-${version}-${hardhat_2.network.name}.json`, JSON.stringify(this.transactions, null, 4));
90
- await this.submitter.submit(this.transactions);
91
- if (process.env.NO_VERIFY) {
92
- console.log("Skip verification");
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
- else {
95
- console.log("Start verification");
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
- console.log("Done");
123
+ return result;
101
124
  }
102
- // Private
103
- static async _getContractFactoryAndUpdateManifest(contract) {
104
- const { linkReferences } = await hardhat_2.artifacts.readArtifact(contract);
105
- const manifest = JSON.parse(await fs_1.promises.readFile(await (0, deploy_1.getManifestFile)(), "utf-8"));
106
- if (!Object.keys(linkReferences).length) {
107
- return await hardhat_2.ethers.getContractFactory(contract);
108
- }
109
- const librariesToUpgrade = [];
110
- const oldLibraries = {};
111
- if (manifest.libraries === undefined) {
112
- Object.assign(manifest, { "libraries": {} });
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
+ const currentImplementationAddress = await (0, upgrades_core_1.getImplementationAddress)(hardhat_1.network.provider, proxyAddress);
130
+ const newImplementationAddress = await hardhat_1.upgrades.prepareUpgrade(proxyAddress, contractFactory, {
131
+ "timeout": deployTimeout,
132
+ "txOverrides": {
133
+ "nonce": this.nonceProvider?.reserveNonce()
134
+ },
135
+ "unsafeAllowLinkedLibraries": true,
136
+ "unsafeAllowRenames": true
137
+ });
138
+ if (newImplementationAddress !== currentImplementationAddress) {
139
+ return {
140
+ "implementationAddress": newImplementationAddress,
141
+ "name": contract,
142
+ proxyAddress
143
+ };
113
144
  }
114
- for (const key of Object.keys(linkReferences)) {
115
- const libraryName = Object.keys(linkReferences[key])[0];
116
- const { bytecode } = await hardhat_2.artifacts.readArtifact(libraryName);
117
- if (manifest.libraries[libraryName] === undefined) {
118
- librariesToUpgrade.push(libraryName);
119
- continue;
120
- }
121
- const libraryBytecodeHash = manifest.libraries[libraryName].bytecodeHash;
122
- if ((0, upgrades_core_1.hashBytecode)(bytecode) !== libraryBytecodeHash) {
123
- librariesToUpgrade.push(libraryName);
145
+ console.log(chalk_1.default.gray(`Contract ${contract} is up to date`));
146
+ return null;
147
+ }
148
+ async getNormalizedDeployedVersion() {
149
+ const deployedVersion = await this.getDeployedVersion();
150
+ if (deployedVersion) {
151
+ if (!deployedVersion.includes("-")) {
152
+ return `${deployedVersion}-stable.0`;
124
153
  }
125
- else {
126
- oldLibraries[libraryName] = manifest.libraries[libraryName].address;
154
+ return deployedVersion;
155
+ }
156
+ return deployedVersion;
157
+ }
158
+ async checkVersion(version) {
159
+ const deployedVersion = await this.getNormalizedDeployedVersion();
160
+ if (deployedVersion) {
161
+ if (deployedVersion !== this.targetVersion) {
162
+ const cannotUpgradeMessage = `This script can't upgrade version ${deployedVersion}` +
163
+ ` to ${version}`;
164
+ console.log(chalk_1.default.red(cannotUpgradeMessage));
165
+ process.exit(exitCodes_1.EXIT_CODES.BAD_VERSION);
127
166
  }
128
167
  }
129
- const libraries = await (0, deploy_1.deployLibraries)(librariesToUpgrade);
130
- for (const [libraryName, libraryAddress] of libraries.entries()) {
131
- const { bytecode } = await hardhat_2.artifacts.readArtifact(libraryName);
132
- manifest.libraries[libraryName] = { "address": libraryAddress,
133
- "bytecodeHash": (0, upgrades_core_1.hashBytecode)(bytecode) };
168
+ else {
169
+ const cannotCheckMessage = `Can't check currently deployed version of ${this.projectName}`;
170
+ console.log(chalk_1.default.yellow(cannotCheckMessage));
134
171
  }
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
172
  }
139
173
  }
140
174
  exports.Upgrader = Upgrader;
175
+ //# sourceMappingURL=upgrader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrader.js","sourceRoot":"","sources":["../../src/upgrader.ts"],"names":[],"mappings":";;;;;;AAAA,+DAA+E;AAC/E,qCAAkD;AAClD,gEAA0D;AAC1D,2CAAuC;AAEvC,mDAA8C;AAE9C,kFAA8C;AAE9C,mCAAmC;AACnC,kDAA0B;AAC1B,2BAAkC;AAClC,uDAAsE;AACtE,uCAAqC;AACrC,iDAAsC;AAgBtC,MAAM,WAAW,GAAG,CAAI,KAAsB,EAAE,EAAE,CAAC,KAAK;IACpD,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,IAAI,CAAa,CAAC;AAEtD,MAAM,0BAA0B,GAAG,CAAC,CAAC;AACrC,gCAAgC;AAChC,MAAM,aAAa,GAAG,IAAI,CAAC;AAG3B,MAAsB,QAAQ;IAiB1B,YACI,OAAgB,EAChB,YAAuB,IAAI,8BAAa,EAAE;QAE1C,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;QACrC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAChC,IAAI,CAAC,aAAa,GAAG,GAAG,OAAO,CAAC,OAAO,WAAW,CAAC;SACtD;QACD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC;QAC7D,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;QAChC,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QAC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AAE;gBAChC,OAAO,GAAG,eAAe,WAAW,CAAC;aACxC;YACD,OAAO,eAAe,CAAC;SAC1B;QACD,OAAO,eAAe,CAAC;IAC3B,CAAC;IAEO,KAAK,CAAC,YAAY,CAAE,OAAe;QACvC,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,4BAA4B,EAAE,CAAC;QAClE,IAAI,eAAe,EAAE;YACjB,IAAI,eAAe,KAAK,IAAI,CAAC,aAAa,EAAE;gBACxC,MAAM,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;AA/OD,4BA+OC"}
@@ -1,2 +1,2 @@
1
- export declare function verify(contractName: string, contractAddress: string, constructorArguments: object): Promise<void>;
2
- export declare function verifyProxy(contractName: string, proxyAddress: string, constructorArguments: object): Promise<void>;
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>;
@@ -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
- async function verify(contractName, contractAddress, constructorArguments) {
12
- const { chainId } = await hardhat_1.ethers.provider.getNetwork();
13
- if (chain_config_1.builtinChains.find((chain) => chain.chainId === chainId) !== undefined) {
14
- for (let retry = 0; retry <= 5; retry += 1) {
15
- try {
16
- await (0, hardhat_1.run)("verify:verify", {
17
- "address": contractAddress,
18
- constructorArguments
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 function verifyProxy(contractName, proxyAddress, constructorArguments) {
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,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;K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O;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"}
@@ -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 function getVersionFilename(folder) {
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, { "withFileTypes": true,
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;;;;AAAA,2BAA8C;AAC9C,iDAAgD;AAChD,gDAAwB;AAGxB,MAAM,IAAI,GAAG,cAAI,CAAC,SAAS,CAAC,oBAAS,CAAC,CAAC;AAEvC,MAAM,eAAgB,SAAQ,KAAK;CAAG;AAEtC,MAAM,kBAAkB,GAAG,KAAK,EAAE,MAAe,EAAmB,EAAE;IAClE,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QAC/B,OAAO,kBAAkB,CAAC,CACtB,MAAM,IAAI,CAAC,+BAA+B,CAAC,CAC9C,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;KACpB;IACD,MAAM,gBAAgB,GAAG,SAAS,CAAC;IACnC,MAAM,IAAI,GAAG,GAAG,MAAM,IAAI,gBAAgB,EAAE,CAAC;IAC7C,IAAI,IAAA,eAAU,EAAC,IAAI,CAAC,EAAE;QAClB,OAAO,IAAI,CAAC;KACf;IACD,KAAK,MAAM,KAAK,IAAI,MAAM,aAAE,CAAC,OAAO,CAChC,MAAM,EACN;QACI,WAAW,EAAE,IAAI;QACjB,eAAe,EAAE,IAAI;KACxB,CACJ,EAAE;QACC,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE;YACnD,OAAO,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;SACxC;KACJ;IACD,MAAM,IAAI,eAAe,CAAC,yBAAyB,CAAC,CAAC;AACzD,CAAC,CAAC;AAEK,MAAM,UAAU,GAAG,KAAK,IAAI,EAAE;IACjC,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE;QACrB,OAAO,OAAO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