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

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.
@@ -2,4 +2,5 @@ import { UnsignedTransaction } from "ethers";
2
2
  import { Submitter } from "./submitter";
3
3
  export declare class EoaSubmitter implements Submitter {
4
4
  submit(transactions: UnsignedTransaction[]): Promise<void>;
5
+ _atomicityWarning(): void;
5
6
  }
@@ -8,12 +8,17 @@ 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
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  exports.EoaSubmitter = void 0;
16
+ const chalk_1 = __importDefault(require("chalk"));
13
17
  const hardhat_1 = require("hardhat");
14
18
  class EoaSubmitter {
15
19
  submit(transactions) {
16
20
  return __awaiter(this, void 0, void 0, function* () {
21
+ this._atomicityWarning();
17
22
  const [deployer] = yield hardhat_1.ethers.getSigners();
18
23
  for (const transaction of transactions) {
19
24
  console.log("Send transaction");
@@ -28,5 +33,16 @@ class EoaSubmitter {
28
33
  }
29
34
  });
30
35
  }
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
+ }
31
47
  }
32
48
  exports.EoaSubmitter = EoaSubmitter;
@@ -0,0 +1,9 @@
1
+ import { BytesLike, Contract, UnsignedTransaction } from "ethers";
2
+ import { SkaleABIFile } from "../types/SkaleABIFile";
3
+ import { SafeSubmitter } from "./safe-submitter";
4
+ export declare class SafeToImaSubmitter extends SafeSubmitter {
5
+ messageProxyForMainnet: Contract;
6
+ targetSchainHash: BytesLike;
7
+ constructor(safeAddress: string, imaAbi: SkaleABIFile, targetSchainHash: BytesLike, chainId?: number);
8
+ submit(transactions: UnsignedTransaction[]): Promise<void>;
9
+ }
@@ -0,0 +1,36 @@
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.SafeToImaSubmitter = void 0;
13
+ const hardhat_1 = require("hardhat");
14
+ const safe_submitter_1 = require("./safe-submitter");
15
+ class SafeToImaSubmitter extends safe_submitter_1.SafeSubmitter {
16
+ constructor(safeAddress, imaAbi, targetSchainHash, chainId) {
17
+ super(safeAddress, chainId);
18
+ this.messageProxyForMainnet = new hardhat_1.ethers.Contract(imaAbi["message_proxy_mainnet_address"], new hardhat_1.ethers.utils.Interface(imaAbi["message_proxy_mainnet_address"]));
19
+ this.targetSchainHash = targetSchainHash;
20
+ }
21
+ submit(transactions) {
22
+ const _super = Object.create(null, {
23
+ submit: { get: () => super.submit }
24
+ });
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const transactionsToIma = transactions.map((transaction) => {
27
+ return {
28
+ to: this.messageProxyForMainnet.address,
29
+ data: this.messageProxyForMainnet.interface.encodeFunctionData("postOutgoingMessage", [this.targetSchainHash, transaction.to, transaction.data])
30
+ };
31
+ });
32
+ yield _super.submit.call(this, transactionsToIma);
33
+ });
34
+ }
35
+ }
36
+ exports.SafeToImaSubmitter = SafeToImaSubmitter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skalenetwork/upgrade-tools",
3
- "version": "2.0.0-refactor.4",
3
+ "version": "2.0.0-refactor.6",
4
4
  "description": "Scripts to support upgrades of smart contracts",
5
5
  "files": [
6
6
  "dist/**/*"