@skalenetwork/upgrade-tools 2.0.0-refactor.6 → 2.0.0-refactor.8

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.
@@ -1,5 +1,5 @@
1
1
  import { UnsignedTransaction } from "ethers";
2
2
  import { Submitter } from "./submitter";
3
- export declare class AutoSubmitter implements Submitter {
3
+ export declare class AutoSubmitter extends Submitter {
4
4
  submit(transactions: UnsignedTransaction[]): Promise<void>;
5
5
  }
@@ -14,10 +14,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.AutoSubmitter = void 0;
16
16
  const admin_1 = require("@openzeppelin/hardhat-upgrades/dist/admin");
17
+ const submitter_1 = require("./submitter");
17
18
  const hardhat_1 = __importDefault(require("hardhat"));
18
19
  const eoa_submitter_1 = require("./eoa-submitter");
19
20
  const safe_submitter_1 = require("./safe-submitter");
20
- class AutoSubmitter {
21
+ class AutoSubmitter extends submitter_1.Submitter {
21
22
  submit(transactions) {
22
23
  return __awaiter(this, void 0, void 0, function* () {
23
24
  let submitter;
@@ -1,6 +1,5 @@
1
1
  import { UnsignedTransaction } from "ethers";
2
2
  import { Submitter } from "./submitter";
3
- export declare class EoaSubmitter implements Submitter {
3
+ export declare class EoaSubmitter extends Submitter {
4
4
  submit(transactions: UnsignedTransaction[]): Promise<void>;
5
- _atomicityWarning(): void;
6
5
  }
@@ -8,14 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
12
  exports.EoaSubmitter = void 0;
16
- const chalk_1 = __importDefault(require("chalk"));
17
13
  const hardhat_1 = require("hardhat");
18
- class EoaSubmitter {
14
+ const submitter_1 = require("./submitter");
15
+ class EoaSubmitter extends submitter_1.Submitter {
19
16
  submit(transactions) {
20
17
  return __awaiter(this, void 0, void 0, function* () {
21
18
  this._atomicityWarning();
@@ -33,16 +30,5 @@ class EoaSubmitter {
33
30
  }
34
31
  });
35
32
  }
36
- // private
37
- _atomicityWarning() {
38
- if (!process.env.ALLOW_NOT_ATOMIC_UPGRADE) {
39
- console.log(chalk_1.default.red("The upgrade will consist of multiple transactions and will not be atomic"));
40
- console.log(chalk_1.default.red("If not atomic upgrade is OK set ALLOW_NOT_ATOMIC_UPGRADE environment variable"));
41
- process.exit(1);
42
- }
43
- else {
44
- console.log(chalk_1.default.yellow("Not atomic upgrade is performing"));
45
- }
46
- }
47
33
  }
48
34
  exports.EoaSubmitter = EoaSubmitter;
@@ -0,0 +1,6 @@
1
+ import { UnsignedTransaction } from "ethers";
2
+ import { SafeToImaSubmitter } from "./safe-to-ima-submitter";
3
+ export declare class SafeImaLegacyMarionetteSubmitter extends SafeToImaSubmitter {
4
+ marionette: import("ethers").Contract;
5
+ submit(transactions: UnsignedTransaction[]): Promise<void>;
6
+ }
@@ -0,0 +1,69 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SafeImaLegacyMarionetteSubmitter = void 0;
13
+ const hardhat_1 = require("hardhat");
14
+ const safe_to_ima_submitter_1 = require("./safe-to-ima-submitter");
15
+ class SafeImaLegacyMarionetteSubmitter extends safe_to_ima_submitter_1.SafeToImaSubmitter {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.marionette = new hardhat_1.ethers.Contract("0xD2c0DeFACe000000000000000000000000000000", new hardhat_1.ethers.utils.Interface([
19
+ {
20
+ "inputs": [
21
+ {
22
+ "internalType": "address",
23
+ "name": "receiver",
24
+ "type": "address"
25
+ },
26
+ {
27
+ "internalType": "uint256",
28
+ "name": "value",
29
+ "type": "uint256"
30
+ },
31
+ {
32
+ "internalType": "bytes",
33
+ "name": "data",
34
+ "type": "bytes"
35
+ }
36
+ ],
37
+ "name": "encodeFunctionCall",
38
+ "outputs": [
39
+ {
40
+ "internalType": "bytes",
41
+ "name": "",
42
+ "type": "bytes"
43
+ }
44
+ ],
45
+ "stateMutability": "pure",
46
+ "type": "function"
47
+ }
48
+ ]));
49
+ }
50
+ submit(transactions) {
51
+ const _super = Object.create(null, {
52
+ submit: { get: () => super.submit }
53
+ });
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ if (transactions.length > 1) {
56
+ this._atomicityWarning();
57
+ }
58
+ const transactionsToMarionette = [];
59
+ for (const transaction of transactions) {
60
+ transactionsToMarionette.push({
61
+ to: this.marionette.address,
62
+ data: yield this.marionette.functions["encodeFunctionCall"].call(transaction.to ? transaction.to : hardhat_1.ethers.constants.AddressZero, transaction.value ? transaction.value : 0, transaction.data ? transaction.data : "0x")
63
+ });
64
+ }
65
+ yield _super.submit.call(this, transactionsToMarionette);
66
+ });
67
+ }
68
+ }
69
+ exports.SafeImaLegacyMarionetteSubmitter = SafeImaLegacyMarionetteSubmitter;
@@ -1,6 +1,6 @@
1
1
  import { UnsignedTransaction } from "ethers";
2
2
  import { Submitter } from "./submitter";
3
- export declare class SafeSubmitter implements Submitter {
3
+ export declare class SafeSubmitter extends Submitter {
4
4
  safeAddress: string;
5
5
  chainId: number | undefined;
6
6
  constructor(safeAddress: string, chainId?: number);
@@ -14,8 +14,10 @@ const ethers_1 = require("ethers");
14
14
  const hardhat_1 = require("hardhat");
15
15
  const gnosis_safe_1 = require("../gnosis-safe");
16
16
  const multiSend_1 = require("../multiSend");
17
- class SafeSubmitter {
17
+ const submitter_1 = require("./submitter");
18
+ class SafeSubmitter extends submitter_1.Submitter {
18
19
  constructor(safeAddress, chainId) {
20
+ super();
19
21
  this.safeAddress = safeAddress;
20
22
  this.chainId = chainId;
21
23
  }
@@ -23,6 +23,9 @@ class SafeToImaSubmitter extends safe_submitter_1.SafeSubmitter {
23
23
  submit: { get: () => super.submit }
24
24
  });
25
25
  return __awaiter(this, void 0, void 0, function* () {
26
+ if (transactions.length > 1) {
27
+ this._atomicityWarning();
28
+ }
26
29
  const transactionsToIma = transactions.map((transaction) => {
27
30
  return {
28
31
  to: this.messageProxyForMainnet.address,
@@ -1,4 +1,5 @@
1
1
  import { UnsignedTransaction } from "ethers";
2
- export interface Submitter {
3
- submit(transactions: UnsignedTransaction[]): Promise<void>;
2
+ export declare abstract class Submitter {
3
+ abstract submit(transactions: UnsignedTransaction[]): Promise<void>;
4
+ _atomicityWarning(): void;
4
5
  }
@@ -1,2 +1,21 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Submitter = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ class Submitter {
9
+ // private
10
+ _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);
15
+ }
16
+ else {
17
+ console.log(chalk_1.default.yellow("Not atomic upgrade is performing"));
18
+ }
19
+ }
20
+ }
21
+ exports.Submitter = Submitter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skalenetwork/upgrade-tools",
3
- "version": "2.0.0-refactor.6",
3
+ "version": "2.0.0-refactor.8",
4
4
  "description": "Scripts to support upgrades of smart contracts",
5
5
  "files": [
6
6
  "dist/**/*"