@skalenetwork/upgrade-tools 2.0.1 → 3.0.0-191-version.1

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 (37) hide show
  1. package/dist/hardhat.config.js +1 -0
  2. package/dist/src/deploy.js +43 -63
  3. package/dist/src/gnosis-safe.js +77 -86
  4. package/dist/src/submitters/auto-submitter.d.ts +3 -4
  5. package/dist/src/submitters/auto-submitter.js +79 -96
  6. package/dist/src/submitters/eoa-submitter.js +14 -25
  7. package/dist/src/submitters/safe-ima-legacy-marionette-submitter.js +13 -27
  8. package/dist/src/submitters/safe-ima-marionette-submitter.js +14 -28
  9. package/dist/src/submitters/safe-submitter.js +5 -16
  10. package/dist/src/submitters/safe-to-ima-submitter.d.ts +6 -4
  11. package/dist/src/submitters/safe-to-ima-submitter.js +18 -27
  12. package/dist/src/submitters/types/marionette.d.ts +1 -1
  13. package/dist/src/upgrader.d.ts +3 -4
  14. package/dist/src/upgrader.js +88 -99
  15. package/dist/src/verification.js +25 -36
  16. package/dist/src/version.d.ts +1 -1
  17. package/dist/src/version.js +26 -23
  18. package/dist/typechain-types/AccessControlEnumerableUpgradeable.d.ts +9 -9
  19. package/dist/typechain-types/AccessControlUpgradeable.d.ts +9 -9
  20. package/dist/typechain-types/AdminUpgradeabilityProxy.d.ts +7 -7
  21. package/dist/typechain-types/ContextUpgradeable.d.ts +3 -3
  22. package/dist/typechain-types/ERC165Upgradeable.d.ts +3 -3
  23. package/dist/typechain-types/IAccessControlEnumerableUpgradeable.d.ts +7 -7
  24. package/dist/typechain-types/IAccessControlUpgradeable.d.ts +7 -7
  25. package/dist/typechain-types/IERC165Upgradeable.d.ts +1 -1
  26. package/dist/typechain-types/ISafeMock.d.ts +1 -1
  27. package/dist/typechain-types/Initializable.d.ts +3 -3
  28. package/dist/typechain-types/OwnableUpgradeable.d.ts +5 -5
  29. package/dist/typechain-types/ProxyAdmin.d.ts +3 -3
  30. package/dist/typechain-types/SafeMock.d.ts +5 -5
  31. package/dist/typechain-types/common.d.ts +4 -4
  32. package/dist/typechain-types/factories/AdminUpgradeabilityProxy__factory.d.ts +1 -1
  33. package/dist/typechain-types/factories/ProxyAdmin__factory.d.ts +1 -1
  34. package/dist/typechain-types/factories/SafeMock__factory.d.ts +1 -1
  35. package/package.json +16 -15
  36. package/dist/src/types/SkaleABIFile.d.ts +0 -3
  37. package/dist/src/types/SkaleABIFile.js +0 -2
@@ -18,6 +18,7 @@ const config = {
18
18
  ]
19
19
  },
20
20
  typechain: {
21
+ target: "ethers-v5",
21
22
  externalArtifacts: ['node_modules/@openzeppelin/upgrades-core/artifacts/[!b]*.json']
22
23
  }
23
24
  };
@@ -1,34 +1,20 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.getContractFactory = exports.getManifestFile = exports.getLinkedContractFactory = exports.deployLibraries = void 0;
13
4
  const upgrades_core_1 = require("@openzeppelin/upgrades-core");
14
5
  const hardhat_1 = require("hardhat");
15
6
  const fs_1 = require("fs");
16
- function _deployLibrary(libraryName) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- const Library = yield hardhat_1.ethers.getContractFactory(libraryName);
19
- const library = yield Library.deploy();
20
- yield library.deployed();
21
- return library.address;
22
- });
7
+ async function _deployLibrary(libraryName) {
8
+ const Library = await hardhat_1.ethers.getContractFactory(libraryName), library = await Library.deploy();
9
+ await library.deployed();
10
+ return library.address;
23
11
  }
24
- function deployLibraries(libraryNames) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- const libraries = new Map();
27
- for (const libraryName of libraryNames) {
28
- libraries.set(libraryName, yield _deployLibrary(libraryName));
29
- }
30
- return libraries;
31
- });
12
+ async function deployLibraries(libraryNames) {
13
+ const libraries = new Map();
14
+ for (const libraryName of libraryNames) {
15
+ libraries.set(libraryName, await _deployLibrary(libraryName));
16
+ }
17
+ return libraries;
32
18
  }
33
19
  exports.deployLibraries = deployLibraries;
34
20
  function _linkBytecode(artifact, libraries) {
@@ -49,49 +35,43 @@ function _linkBytecode(artifact, libraries) {
49
35
  }
50
36
  return bytecode;
51
37
  }
52
- function getLinkedContractFactory(contractName, libraries) {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- const cArtifact = yield hardhat_1.artifacts.readArtifact(contractName);
55
- const linkedBytecode = _linkBytecode(cArtifact, libraries);
56
- const ContractFactory = yield hardhat_1.ethers.getContractFactory(cArtifact.abi, linkedBytecode);
57
- return ContractFactory;
58
- });
38
+ async function getLinkedContractFactory(contractName, libraries) {
39
+ const cArtifact = await hardhat_1.artifacts.readArtifact(contractName), linkedBytecode = _linkBytecode(cArtifact, libraries), ContractFactory = await hardhat_1.ethers.getContractFactory(cArtifact.abi, linkedBytecode);
40
+ return ContractFactory;
59
41
  }
60
42
  exports.getLinkedContractFactory = getLinkedContractFactory;
61
- function getManifestFile() {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- return (yield upgrades_core_1.Manifest.forNetwork(hardhat_1.ethers.provider)).file;
64
- });
43
+ async function getManifestFile() {
44
+ return (await upgrades_core_1.Manifest.forNetwork(hardhat_1.ethers.provider)).file;
65
45
  }
66
46
  exports.getManifestFile = getManifestFile;
67
- function getContractFactory(contract) {
68
- return __awaiter(this, void 0, void 0, function* () {
69
- const { linkReferences } = yield hardhat_1.artifacts.readArtifact(contract);
70
- if (!Object.keys(linkReferences).length)
71
- return yield hardhat_1.ethers.getContractFactory(contract);
72
- const libraryNames = [];
73
- for (const key of Object.keys(linkReferences)) {
74
- const libraryName = Object.keys(linkReferences[key])[0];
75
- libraryNames.push(libraryName);
76
- }
77
- const libraries = yield deployLibraries(libraryNames);
78
- const libraryArtifacts = {};
79
- for (const [libraryName, libraryAddress] of libraries.entries()) {
80
- const { bytecode } = yield hardhat_1.artifacts.readArtifact(libraryName);
81
- libraryArtifacts[libraryName] = { "address": libraryAddress, "bytecodeHash": (0, upgrades_core_1.hashBytecode)(bytecode) };
82
- }
83
- let manifest;
84
- try {
85
- manifest = JSON.parse(yield fs_1.promises.readFile(yield getManifestFile(), "utf-8"));
86
- Object.assign(libraryArtifacts, manifest.libraries);
87
- }
88
- finally {
89
- if (manifest !== undefined) {
90
- Object.assign(manifest, { libraries: libraryArtifacts });
91
- }
92
- yield fs_1.promises.writeFile(yield getManifestFile(), JSON.stringify(manifest, null, 4));
47
+ async function getContractFactory(contract) {
48
+ const { linkReferences } = await hardhat_1.artifacts.readArtifact(contract);
49
+ if (!Object.keys(linkReferences).length)
50
+ return await hardhat_1.ethers.getContractFactory(contract);
51
+ const libraryNames = [];
52
+ for (const key of Object.keys(linkReferences)) {
53
+ const libraryName = Object.keys(linkReferences[key])[0];
54
+ libraryNames.push(libraryName);
55
+ }
56
+ const libraries = await deployLibraries(libraryNames), libraryArtifacts = {};
57
+ for (const [libraryName, libraryAddress] of libraries.entries()) {
58
+ const { bytecode } = await hardhat_1.artifacts.readArtifact(libraryName);
59
+ libraryArtifacts[libraryName] = {
60
+ "address": libraryAddress,
61
+ "bytecodeHash": (0, upgrades_core_1.hashBytecode)(bytecode)
62
+ };
63
+ }
64
+ let manifest;
65
+ try {
66
+ manifest = JSON.parse(await fs_1.promises.readFile(await getManifestFile(), "utf-8"));
67
+ Object.assign(libraryArtifacts, manifest.libraries);
68
+ }
69
+ finally {
70
+ if (manifest !== undefined) {
71
+ Object.assign(manifest, { libraries: libraryArtifacts });
93
72
  }
94
- return yield getLinkedContractFactory(contract, libraries);
95
- });
73
+ await fs_1.promises.writeFile(await getManifestFile(), JSON.stringify(manifest, null, 4));
74
+ }
75
+ return await getLinkedContractFactory(contract, libraries);
96
76
  }
97
77
  exports.getContractFactory = getContractFactory;
@@ -1,12 +1,26 @@
1
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
- });
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
10
24
  };
11
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -15,9 +29,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
29
  exports.createMultiSendTransaction = void 0;
16
30
  const chalk_1 = __importDefault(require("chalk"));
17
31
  const hardhat_1 = require("hardhat");
18
- const safe_ethers_lib_1 = __importDefault(require("@safe-global/safe-ethers-lib"));
19
- const safe_service_client_1 = __importDefault(require("@safe-global/safe-service-client"));
20
- const safe_core_sdk_1 = __importDefault(require("@safe-global/safe-core-sdk"));
32
+ const api_kit_1 = __importDefault(require("@safe-global/api-kit"));
33
+ const protocol_kit_1 = __importStar(require("@safe-global/protocol-kit"));
21
34
  var Network;
22
35
  (function (Network) {
23
36
  Network[Network["MAINNET"] = 1] = "MAINNET";
@@ -33,90 +46,68 @@ const URLS = {
33
46
  }
34
47
  };
35
48
  // public functions
36
- function createMultiSendTransaction(safeAddress, transactions) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- const safeTransactionData = [];
39
- for (const transaction of transactions) {
40
- safeTransactionData.push({
41
- to: transaction.to ? transaction.to : hardhat_1.ethers.constants.AddressZero,
42
- data: transaction.data ? transaction.data.toString() : "0x",
43
- value: transaction.value ? transaction.value.toString() : "0",
44
- operation: 0,
45
- });
46
- }
47
- const safeService = yield getSafeService();
48
- const nonce = yield safeService.getNextNonce(safeAddress);
49
- console.log("Will send tx to Gnosis with nonce", nonce);
50
- const options = {
51
- safeTxGas: 0,
52
- baseGas: 0,
53
- gasPrice: 0,
54
- gasToken: hardhat_1.ethers.constants.AddressZero,
55
- refundReceiver: hardhat_1.ethers.constants.AddressZero,
56
- nonce: nonce // Nonce of the Safe, transaction cannot be executed until Safe's nonce is not equal to this nonce
57
- };
58
- const ethAdapter = yield getEthAdapter();
59
- const safeSdk = yield safe_core_sdk_1.default.create({ ethAdapter, safeAddress });
60
- const safeTransaction = yield safeSdk.createTransaction({ safeTransactionData, options });
61
- yield estimateSafeTransaction(safeAddress, safeTransactionData);
62
- yield proposeTransaction(safeAddress, safeTransaction);
63
- });
49
+ async function createMultiSendTransaction(safeAddress, transactions) {
50
+ const safeTransactionData = [];
51
+ for (const transaction of transactions) {
52
+ safeTransactionData.push({
53
+ to: transaction.to ? transaction.to : hardhat_1.ethers.constants.AddressZero,
54
+ data: transaction.data ? transaction.data.toString() : "0x",
55
+ value: transaction.value ? transaction.value.toString() : "0",
56
+ operation: 0,
57
+ });
58
+ }
59
+ const safeService = await getSafeService(), nonce = await safeService.getNextNonce(safeAddress);
60
+ console.log("Will send tx to Gnosis with nonce", nonce);
61
+ const options = {
62
+ safeTxGas: "0",
63
+ baseGas: "0",
64
+ gasPrice: "0",
65
+ gasToken: hardhat_1.ethers.constants.AddressZero,
66
+ refundReceiver: hardhat_1.ethers.constants.AddressZero,
67
+ nonce: nonce // Nonce of the Safe, transaction cannot be executed until Safe's nonce is not equal to this nonce
68
+ }, ethAdapter = await getEthAdapter(), safeSdk = await protocol_kit_1.default.create({ ethAdapter, safeAddress }), safeTransaction = await safeSdk.createTransaction({ safeTransactionData, options });
69
+ await estimateSafeTransaction(safeAddress, safeTransactionData);
70
+ await proposeTransaction(safeAddress, safeTransaction);
64
71
  }
65
72
  exports.createMultiSendTransaction = createMultiSendTransaction;
66
73
  // private functions
67
- function estimateSafeTransaction(safeAddress, safeTransactionData) {
68
- return __awaiter(this, void 0, void 0, function* () {
69
- console.log("Estimate gas");
70
- const safeService = yield getSafeService();
71
- for (const transaction of safeTransactionData) {
72
- const estimateResponse = yield safeService.estimateSafeTransaction(safeAddress, {
73
- to: transaction.to,
74
- value: transaction.value,
75
- data: transaction.data,
76
- operation: transaction.operation || 0,
77
- });
78
- console.log(chalk_1.default.cyan(`Recommend to set gas limit to ${parseInt(estimateResponse.safeTxGas, 10)}`));
79
- }
80
- console.log(chalk_1.default.green("Send transaction to gnosis safe"));
81
- });
82
- }
83
- function proposeTransaction(safeAddress, safeTransaction) {
84
- return __awaiter(this, void 0, void 0, function* () {
85
- const [safeOwner] = yield hardhat_1.ethers.getSigners();
86
- const ethAdapter = yield getEthAdapter();
87
- const safeSdk = yield safe_core_sdk_1.default.create({ ethAdapter, safeAddress });
88
- const safeTxHash = yield safeSdk.getTransactionHash(safeTransaction);
89
- const senderSignature = yield safeSdk.signTransactionHash(safeTxHash);
90
- const safeService = yield getSafeService();
91
- yield safeService.proposeTransaction({
92
- safeAddress,
93
- safeTransactionData: safeTransaction.data,
94
- safeTxHash,
95
- senderAddress: safeOwner.address,
96
- senderSignature: senderSignature.data
74
+ async function estimateSafeTransaction(safeAddress, safeTransactionData) {
75
+ console.log("Estimate gas");
76
+ const safeService = await getSafeService();
77
+ for (const transaction of safeTransactionData) {
78
+ const estimateResponse = await safeService.estimateSafeTransaction(safeAddress, {
79
+ to: transaction.to,
80
+ value: transaction.value,
81
+ data: transaction.data,
82
+ operation: transaction.operation || 0,
97
83
  });
84
+ console.log(chalk_1.default.cyan(`Recommend to set gas limit to ${parseInt(estimateResponse.safeTxGas, 10)}`));
85
+ }
86
+ console.log(chalk_1.default.green("Send transaction to gnosis safe"));
87
+ }
88
+ async function proposeTransaction(safeAddress, safeTransaction) {
89
+ const [safeOwner] = await hardhat_1.ethers.getSigners(), ethAdapter = await getEthAdapter(), safeSdk = await protocol_kit_1.default.create({ ethAdapter, safeAddress }), safeTxHash = await safeSdk.getTransactionHash(safeTransaction), senderSignature = await safeSdk.signTransactionHash(safeTxHash), safeService = await getSafeService();
90
+ await safeService.proposeTransaction({
91
+ safeAddress,
92
+ safeTransactionData: safeTransaction.data,
93
+ safeTxHash,
94
+ senderAddress: safeOwner.address,
95
+ senderSignature: senderSignature.data
98
96
  });
99
97
  }
100
- function getEthAdapter() {
101
- return __awaiter(this, void 0, void 0, function* () {
102
- const [safeOwner] = yield hardhat_1.ethers.getSigners();
103
- const ethAdapter = new safe_ethers_lib_1.default({
104
- ethers: hardhat_1.ethers,
105
- signerOrProvider: safeOwner
106
- });
107
- return ethAdapter;
98
+ async function getEthAdapter() {
99
+ const [safeOwner] = await hardhat_1.ethers.getSigners(), ethAdapter = new protocol_kit_1.EthersAdapter({
100
+ ethers: hardhat_1.ethers,
101
+ signerOrProvider: safeOwner
108
102
  });
103
+ return ethAdapter;
109
104
  }
110
- function getSafeService() {
111
- return __awaiter(this, void 0, void 0, function* () {
112
- const chainId = (yield hardhat_1.ethers.provider.getNetwork()).chainId;
113
- const ethAdapter = yield getEthAdapter();
114
- const safeService = new safe_service_client_1.default({
115
- txServiceUrl: getSafeTransactionUrl(chainId),
116
- ethAdapter
117
- });
118
- return safeService;
105
+ async function getSafeService() {
106
+ const chainId = (await hardhat_1.ethers.provider.getNetwork()).chainId, ethAdapter = await getEthAdapter(), safeService = new api_kit_1.default({
107
+ txServiceUrl: getSafeTransactionUrl(chainId),
108
+ ethAdapter
119
109
  });
110
+ return safeService;
120
111
  }
121
112
  function getSafeTransactionUrl(chainId) {
122
113
  if (Object.keys(URLS.safe_transaction).includes(chainId.toString())) {
@@ -1,9 +1,8 @@
1
- import { UnsignedTransaction } from "ethers";
1
+ import { Transaction } from "ethers";
2
2
  import { Submitter } from "./submitter";
3
- import { SkaleABIFile } from "../types/SkaleABIFile";
4
3
  export declare class AutoSubmitter extends Submitter {
5
- submit(transactions: UnsignedTransaction[]): Promise<void>;
6
- _getImaAbi(): Promise<SkaleABIFile>;
4
+ submit(transactions: Transaction[]): Promise<void>;
5
+ _getImaInstance(): Promise<import("@skalenetwork/skale-contracts/lib/instance").Instance<import("ethers").BaseContract>>;
7
6
  _getSafeAddress(): string;
8
7
  _getSchainHash(): string;
9
8
  _getMainnetChainId(): number;
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
35
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
27
  };
@@ -43,67 +34,61 @@ const eoa_submitter_1 = require("./eoa-submitter");
43
34
  const safe_submitter_1 = require("./safe-submitter");
44
35
  const chalk_1 = __importDefault(require("chalk"));
45
36
  const safe_ima_legacy_marionette_submitter_1 = require("./safe-ima-legacy-marionette-submitter");
46
- const fs_1 = require("fs");
47
37
  const marionette_1 = require("./types/marionette");
38
+ const skale_contracts_ethers_v5_1 = require("@skalenetwork/skale-contracts-ethers-v5");
48
39
  class AutoSubmitter extends submitter_1.Submitter {
49
- submit(transactions) {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- let submitter;
52
- const proxyAdmin = yield (0, admin_1.getManifestAdmin)(hardhat_1.default);
53
- const owner = yield proxyAdmin.owner();
54
- if ((yield hardhat_1.default.ethers.provider.getCode(owner)) === "0x") {
55
- console.log("Owner is not a contract");
56
- submitter = new eoa_submitter_1.EoaSubmitter();
40
+ async submit(transactions) {
41
+ let submitter;
42
+ // TODO: remove unknown when move everything to ethers 6
43
+ const proxyAdmin = await (0, admin_1.getManifestAdmin)(hardhat_1.default), owner = await proxyAdmin.owner();
44
+ if (await hardhat_1.default.ethers.provider.getCode(owner) === "0x") {
45
+ console.log("Owner is not a contract");
46
+ submitter = new eoa_submitter_1.EoaSubmitter();
47
+ }
48
+ else {
49
+ console.log("Owner is a contract");
50
+ if (hardhat_1.ethers.utils.getAddress(owner) == hardhat_1.ethers.utils.getAddress(marionette_1.MARIONETTE_ADDRESS)) {
51
+ console.log("Marionette owner is detected");
52
+ const imaInstance = await this._getImaInstance(), mainnetChainId = this._getMainnetChainId(), safeAddress = this._getSafeAddress(), schainHash = this._getSchainHash();
53
+ // TODO: after marionette has multiSend functionality
54
+ // query version and properly select a submitter
55
+ // based on it
56
+ //
57
+ // if (await this._versionFunctionExists()) {
58
+ // console.log("version() function was found. Use normal Marionette")
59
+ // submitter = new SafeImaMarionetteSubmitter(
60
+ // safeAddress,
61
+ // imaAbi,
62
+ // schainHash,
63
+ // mainnetChainId
64
+ // )
65
+ // } else {
66
+ // console.log("No version() function was found. Use legacy Marionette")
67
+ // submitter = new SafeImaLegacyMarionetteSubmitter(
68
+ // safeAddress,
69
+ // imaAbi,
70
+ // schainHash,
71
+ // mainnetChainId
72
+ // )
73
+ // }
74
+ submitter = new safe_ima_legacy_marionette_submitter_1.SafeImaLegacyMarionetteSubmitter(safeAddress, imaInstance, schainHash, mainnetChainId);
57
75
  }
58
76
  else {
59
- console.log("Owner is a contract");
60
- if (hardhat_1.ethers.utils.getAddress(owner) == hardhat_1.ethers.utils.getAddress(marionette_1.MARIONETTE_ADDRESS)) {
61
- console.log("Marionette owner is detected");
62
- const imaAbi = yield this._getImaAbi();
63
- const safeAddress = this._getSafeAddress();
64
- const schainHash = this._getSchainHash();
65
- const mainnetChainId = this._getMainnetChainId();
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);
88
- }
89
- else {
90
- // assuming owner is a Gnosis Safe
91
- console.log("Using Gnosis Safe");
92
- submitter = new safe_submitter_1.SafeSubmitter(owner);
93
- }
77
+ // assuming owner is a Gnosis Safe
78
+ console.log("Using Gnosis Safe");
79
+ submitter = new safe_submitter_1.SafeSubmitter(owner);
94
80
  }
95
- yield submitter.submit(transactions);
96
- });
81
+ }
82
+ await submitter.submit(transactions);
97
83
  }
98
84
  // private
99
- _getImaAbi() {
100
- return __awaiter(this, void 0, void 0, function* () {
101
- if (!process.env.IMA_ABI) {
102
- console.log(chalk_1.default.red("Set path to ima abi to IMA_ABI environment variable"));
103
- process.exit(1);
104
- }
105
- return JSON.parse(yield fs_1.promises.readFile(process.env.IMA_ABI, "utf-8"));
106
- });
85
+ async _getImaInstance() {
86
+ if (!process.env.IMA) {
87
+ console.log(chalk_1.default.red("Set target IMA alias to IMA environment variable"));
88
+ process.exit(1);
89
+ }
90
+ const network = await skale_contracts_ethers_v5_1.skaleContracts.getNetworkByProvider(hardhat_1.ethers.provider), ima = await network.getProject("ima");
91
+ return await ima.getInstance(process.env.IMA);
107
92
  }
108
93
  _getSafeAddress() {
109
94
  if (!process.env.SAFE_ADDRESS) {
@@ -138,39 +123,37 @@ class AutoSubmitter extends submitter_1.Submitter {
138
123
  return Number.parseInt(process.env.MAINNET_CHAIN_ID);
139
124
  }
140
125
  }
141
- _versionFunctionExists() {
142
- return __awaiter(this, void 0, void 0, function* () {
143
- const bytecode = yield hardhat_1.default.ethers.provider.getCode(marionette_1.MARIONETTE_ADDRESS);
144
- // If the bytecode doesn't include the function selector version()
145
- // is definitely not present
146
- if (!bytecode.includes(hardhat_1.ethers.utils.id("version()").slice(2, 10))) {
147
- return false;
148
- }
149
- const marionette = new hardhat_1.ethers.Contract(marionette_1.MARIONETTE_ADDRESS, [{
150
- "inputs": [],
151
- "name": "version",
152
- "outputs": [
153
- {
154
- "internalType": "string",
155
- "name": "",
156
- "type": "string"
157
- }
158
- ],
159
- "stateMutability": "view",
160
- "type": "function"
161
- }], hardhat_1.default.ethers.provider);
162
- // If gas estimation doesn't revert then an execution is possible
163
- // given the provided function selector
164
- try {
165
- yield marionette.estimateGas.version();
166
- return true;
167
- }
168
- catch (_a) {
169
- // Otherwise (revert) we assume that there is no entry in the jump table
170
- // meaning that the contract doesn't include version()
171
- return false;
172
- }
173
- });
126
+ async _versionFunctionExists() {
127
+ const bytecode = await hardhat_1.default.ethers.provider.getCode(marionette_1.MARIONETTE_ADDRESS);
128
+ // If the bytecode doesn't include the function selector version()
129
+ // is definitely not present
130
+ if (!bytecode.includes(hardhat_1.ethers.utils.id("version()").slice(2, 10))) {
131
+ return false;
132
+ }
133
+ const marionette = new hardhat_1.ethers.Contract(marionette_1.MARIONETTE_ADDRESS, [{
134
+ "inputs": [],
135
+ "name": "version",
136
+ "outputs": [
137
+ {
138
+ "internalType": "string",
139
+ "name": "",
140
+ "type": "string"
141
+ }
142
+ ],
143
+ "stateMutability": "view",
144
+ "type": "function"
145
+ }], hardhat_1.default.ethers.provider);
146
+ // If gas estimation doesn't revert then an execution is possible
147
+ // given the provided function selector
148
+ try {
149
+ await marionette.estimateGas.version();
150
+ return true;
151
+ }
152
+ catch {
153
+ // Otherwise (revert) we assume that there is no entry in the jump table
154
+ // meaning that the contract doesn't include version()
155
+ return false;
156
+ }
174
157
  }
175
158
  }
176
159
  exports.AutoSubmitter = AutoSubmitter;
@@ -1,34 +1,23 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.EoaSubmitter = void 0;
13
4
  const hardhat_1 = require("hardhat");
14
5
  const submitter_1 = require("./submitter");
15
6
  class EoaSubmitter extends submitter_1.Submitter {
16
- submit(transactions) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- this._atomicityWarning();
19
- const [deployer] = yield hardhat_1.ethers.getSigners();
20
- for (const transaction of transactions) {
21
- console.log("Send transaction");
22
- const response = yield deployer.sendTransaction({
23
- to: transaction.to,
24
- value: transaction.value,
25
- data: transaction.data
26
- });
27
- console.log(`Waiting for a transaction with nonce ${response.nonce}`);
28
- yield response.wait();
29
- console.log("The transaction was sent");
30
- }
31
- });
7
+ async submit(transactions) {
8
+ this._atomicityWarning();
9
+ const [deployer] = await hardhat_1.ethers.getSigners();
10
+ for (const transaction of transactions) {
11
+ console.log("Send transaction");
12
+ const response = await deployer.sendTransaction({
13
+ to: transaction.to,
14
+ value: transaction.value,
15
+ data: transaction.data
16
+ });
17
+ console.log(`Waiting for a transaction with nonce ${response.nonce}`);
18
+ await response.wait();
19
+ console.log("The transaction was sent");
20
+ }
32
21
  }
33
22
  }
34
23
  exports.EoaSubmitter = EoaSubmitter;