@skalenetwork/upgrade-tools 2.0.0-refactor.9 → 3.0.0-skale-contracts.0
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/README.md +66 -11
- package/dist/hardhat.config.js +1 -0
- package/dist/src/deploy.js +44 -63
- package/dist/src/gnosis-safe.d.ts +2 -2
- package/dist/src/gnosis-safe.js +129 -103
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +0 -1
- package/dist/src/submitters/auto-submitter.d.ts +7 -2
- package/dist/src/submitters/auto-submitter.js +145 -21
- package/dist/src/submitters/eoa-submitter.js +14 -25
- package/dist/src/submitters/safe-ima-legacy-marionette-submitter.js +16 -28
- package/dist/src/submitters/safe-ima-marionette-submitter.d.ts +7 -0
- package/dist/src/submitters/safe-ima-marionette-submitter.js +66 -0
- package/dist/src/submitters/safe-submitter.js +16 -27
- package/dist/src/submitters/safe-to-ima-submitter.d.ts +6 -4
- package/dist/src/submitters/safe-to-ima-submitter.js +19 -27
- package/dist/src/submitters/types/marionette.d.ts +13 -0
- package/dist/src/submitters/types/marionette.js +4 -0
- package/dist/src/upgrader.d.ts +3 -4
- package/dist/src/upgrader.js +81 -101
- package/dist/src/verification.js +23 -36
- package/dist/src/version.js +11 -22
- package/dist/typechain-types/AccessControlEnumerableUpgradeable.d.ts +9 -9
- package/dist/typechain-types/AccessControlUpgradeable.d.ts +9 -9
- package/dist/typechain-types/AdminUpgradeabilityProxy.d.ts +14 -99
- package/dist/typechain-types/ContextUpgradeable.d.ts +3 -3
- package/dist/typechain-types/ERC165Upgradeable.d.ts +3 -3
- package/dist/typechain-types/IAccessControlEnumerableUpgradeable.d.ts +7 -7
- package/dist/typechain-types/IAccessControlUpgradeable.d.ts +7 -7
- package/dist/typechain-types/IERC165Upgradeable.d.ts +1 -1
- package/dist/typechain-types/ISafeMock.d.ts +1 -1
- package/dist/typechain-types/Initializable.d.ts +3 -3
- package/dist/typechain-types/OwnableUpgradeable.d.ts +5 -5
- package/dist/typechain-types/ProxyAdmin.d.ts +3 -3
- package/dist/typechain-types/SafeMock.d.ts +5 -5
- package/dist/typechain-types/common.d.ts +4 -4
- package/dist/typechain-types/factories/AdminUpgradeabilityProxy__factory.d.ts +2 -27
- package/dist/typechain-types/factories/AdminUpgradeabilityProxy__factory.js +1 -71
- package/dist/typechain-types/factories/ProxyAdmin__factory.d.ts +2 -2
- package/dist/typechain-types/factories/ProxyAdmin__factory.js +6 -6
- package/dist/typechain-types/factories/SafeMock__factory.d.ts +1 -1
- package/package.json +8 -7
- package/dist/src/types/SkaleABIFile.d.ts +0 -3
- package/dist/src/types/SkaleABIFile.js +0 -2
- package/dist/src/upgrade.d.ts +0 -8
- package/dist/src/upgrade.js +0 -234
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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,26 +29,136 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
29
|
exports.AutoSubmitter = void 0;
|
|
16
30
|
const admin_1 = require("@openzeppelin/hardhat-upgrades/dist/admin");
|
|
17
31
|
const submitter_1 = require("./submitter");
|
|
18
|
-
const hardhat_1 =
|
|
32
|
+
const hardhat_1 = __importStar(require("hardhat"));
|
|
19
33
|
const eoa_submitter_1 = require("./eoa-submitter");
|
|
20
34
|
const safe_submitter_1 = require("./safe-submitter");
|
|
35
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
36
|
+
const safe_ima_legacy_marionette_submitter_1 = require("./safe-ima-legacy-marionette-submitter");
|
|
37
|
+
const marionette_1 = require("./types/marionette");
|
|
38
|
+
const skale_contracts_1 = require("@skalenetwork/skale-contracts");
|
|
21
39
|
class AutoSubmitter extends submitter_1.Submitter {
|
|
22
|
-
submit(transactions) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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);
|
|
44
|
+
const owner = await proxyAdmin.owner();
|
|
45
|
+
if (await hardhat_1.default.ethers.provider.getCode(owner) === "0x") {
|
|
46
|
+
console.log("Owner is not a contract");
|
|
47
|
+
submitter = new eoa_submitter_1.EoaSubmitter();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
console.log("Owner is a contract");
|
|
51
|
+
if (hardhat_1.ethers.utils.getAddress(owner) == hardhat_1.ethers.utils.getAddress(marionette_1.MARIONETTE_ADDRESS)) {
|
|
52
|
+
console.log("Marionette owner is detected");
|
|
53
|
+
const imaInstance = await this._getImaInstance();
|
|
54
|
+
const safeAddress = this._getSafeAddress();
|
|
55
|
+
const schainHash = this._getSchainHash();
|
|
56
|
+
const mainnetChainId = this._getMainnetChainId();
|
|
57
|
+
// TODO: after marionette has multiSend functionality
|
|
58
|
+
// query version and properly select a submitter
|
|
59
|
+
// based on it
|
|
60
|
+
//
|
|
61
|
+
// if (await this._versionFunctionExists()) {
|
|
62
|
+
// console.log("version() function was found. Use normal Marionette")
|
|
63
|
+
// submitter = new SafeImaMarionetteSubmitter(
|
|
64
|
+
// safeAddress,
|
|
65
|
+
// imaAbi,
|
|
66
|
+
// schainHash,
|
|
67
|
+
// mainnetChainId
|
|
68
|
+
// )
|
|
69
|
+
// } else {
|
|
70
|
+
// console.log("No version() function was found. Use legacy Marionette")
|
|
71
|
+
// submitter = new SafeImaLegacyMarionetteSubmitter(
|
|
72
|
+
// safeAddress,
|
|
73
|
+
// imaAbi,
|
|
74
|
+
// schainHash,
|
|
75
|
+
// mainnetChainId
|
|
76
|
+
// )
|
|
77
|
+
// }
|
|
78
|
+
submitter = new safe_ima_legacy_marionette_submitter_1.SafeImaLegacyMarionetteSubmitter(safeAddress, imaInstance, schainHash, mainnetChainId);
|
|
30
79
|
}
|
|
31
80
|
else {
|
|
32
|
-
|
|
33
|
-
|
|
81
|
+
// assuming owner is a Gnosis Safe
|
|
82
|
+
console.log("Using Gnosis Safe");
|
|
34
83
|
submitter = new safe_submitter_1.SafeSubmitter(owner);
|
|
35
84
|
}
|
|
36
|
-
|
|
37
|
-
|
|
85
|
+
}
|
|
86
|
+
await submitter.submit(transactions);
|
|
87
|
+
}
|
|
88
|
+
// private
|
|
89
|
+
async _getImaInstance() {
|
|
90
|
+
if (!process.env.IMA) {
|
|
91
|
+
console.log(chalk_1.default.red("Set target IMA alias to IMA environment variable"));
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
const network = await skale_contracts_1.skaleContracts.getNetworkByChainId((await hardhat_1.ethers.provider.getNetwork()).chainId);
|
|
95
|
+
const ima = await network.getProject("ima");
|
|
96
|
+
return await ima.getInstance(process.env.IMA);
|
|
97
|
+
}
|
|
98
|
+
_getSafeAddress() {
|
|
99
|
+
if (!process.env.SAFE_ADDRESS) {
|
|
100
|
+
console.log(chalk_1.default.red("Set Gnosis Safe owner address to SAFE_ADDRESS environment variable"));
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
return process.env.SAFE_ADDRESS;
|
|
104
|
+
}
|
|
105
|
+
_getSchainHash() {
|
|
106
|
+
// query Context to get schain hash
|
|
107
|
+
if (!process.env.SCHAIN_HASH) {
|
|
108
|
+
if (!process.env.SCHAIN_NAME) {
|
|
109
|
+
console.log(chalk_1.default.red("Set schain name to SCHAIN_NAME environment variable"));
|
|
110
|
+
console.log(chalk_1.default.red("or schain hash to SCHAIN_HASH environment variable"));
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
return hardhat_1.ethers.utils.solidityKeccak256(["string"], [process.env.SCHAIN_NAME]);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
return process.env.SCHAIN_HASH;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
_getMainnetChainId() {
|
|
122
|
+
if (!process.env.MAINNET_CHAIN_ID) {
|
|
123
|
+
console.log(chalk_1.default.red("Set chainId of mainnet to MAINNET_CHAIN_ID environment variable"));
|
|
124
|
+
console.log(chalk_1.default.red("Use 1 for Ethereum mainnet or 5 for Goerli"));
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
return Number.parseInt(process.env.MAINNET_CHAIN_ID);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async _versionFunctionExists() {
|
|
132
|
+
const bytecode = await hardhat_1.default.ethers.provider.getCode(marionette_1.MARIONETTE_ADDRESS);
|
|
133
|
+
// If the bytecode doesn't include the function selector version()
|
|
134
|
+
// is definitely not present
|
|
135
|
+
if (!bytecode.includes(hardhat_1.ethers.utils.id("version()").slice(2, 10))) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
const marionette = new hardhat_1.ethers.Contract(marionette_1.MARIONETTE_ADDRESS, [{
|
|
139
|
+
"inputs": [],
|
|
140
|
+
"name": "version",
|
|
141
|
+
"outputs": [
|
|
142
|
+
{
|
|
143
|
+
"internalType": "string",
|
|
144
|
+
"name": "",
|
|
145
|
+
"type": "string"
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
"stateMutability": "view",
|
|
149
|
+
"type": "function"
|
|
150
|
+
}], hardhat_1.default.ethers.provider);
|
|
151
|
+
// If gas estimation doesn't revert then an execution is possible
|
|
152
|
+
// given the provided function selector
|
|
153
|
+
try {
|
|
154
|
+
await marionette.estimateGas.version();
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
// Otherwise (revert) we assume that there is no entry in the jump table
|
|
159
|
+
// meaning that the contract doesn't include version()
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
38
162
|
}
|
|
39
163
|
}
|
|
40
164
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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;
|
|
@@ -1,21 +1,13 @@
|
|
|
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.SafeImaLegacyMarionetteSubmitter = void 0;
|
|
13
4
|
const hardhat_1 = require("hardhat");
|
|
14
5
|
const safe_to_ima_submitter_1 = require("./safe-to-ima-submitter");
|
|
6
|
+
const marionette_1 = require("./types/marionette");
|
|
15
7
|
class SafeImaLegacyMarionetteSubmitter extends safe_to_ima_submitter_1.SafeToImaSubmitter {
|
|
16
8
|
constructor() {
|
|
17
9
|
super(...arguments);
|
|
18
|
-
this.marionette = new hardhat_1.ethers.Contract(
|
|
10
|
+
this.marionette = new hardhat_1.ethers.Contract(marionette_1.MARIONETTE_ADDRESS, new hardhat_1.ethers.utils.Interface([
|
|
19
11
|
{
|
|
20
12
|
"inputs": [
|
|
21
13
|
{
|
|
@@ -45,25 +37,21 @@ class SafeImaLegacyMarionetteSubmitter extends safe_to_ima_submitter_1.SafeToIma
|
|
|
45
37
|
"stateMutability": "pure",
|
|
46
38
|
"type": "function"
|
|
47
39
|
}
|
|
48
|
-
]));
|
|
40
|
+
]), hardhat_1.ethers.provider);
|
|
49
41
|
}
|
|
50
|
-
submit(transactions) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
yield _super.submit.call(this, transactionsToMarionette);
|
|
66
|
-
});
|
|
42
|
+
async submit(transactions) {
|
|
43
|
+
if (transactions.length > 1) {
|
|
44
|
+
this._atomicityWarning();
|
|
45
|
+
}
|
|
46
|
+
const transactionsToMarionette = [];
|
|
47
|
+
for (const transaction of transactions) {
|
|
48
|
+
transactionsToMarionette.push({
|
|
49
|
+
to: this.marionette.address,
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
51
|
+
data: await this.marionette.encodeFunctionCall(transaction.to ? transaction.to : hardhat_1.ethers.constants.AddressZero, transaction.value ? transaction.value : 0, transaction.data ? transaction.data : "0x")
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
await super.submit(transactionsToMarionette);
|
|
67
55
|
}
|
|
68
56
|
}
|
|
69
57
|
exports.SafeImaLegacyMarionetteSubmitter = SafeImaLegacyMarionetteSubmitter;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UnsignedTransaction } from "ethers";
|
|
2
|
+
import { SafeToImaSubmitter } from "./safe-to-ima-submitter";
|
|
3
|
+
import { Marionette } from "./types/marionette";
|
|
4
|
+
export declare class SafeImaMarionetteSubmitter extends SafeToImaSubmitter {
|
|
5
|
+
marionette: Marionette;
|
|
6
|
+
submit(transactions: UnsignedTransaction[]): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SafeImaMarionetteSubmitter = void 0;
|
|
4
|
+
const hardhat_1 = require("hardhat");
|
|
5
|
+
const safe_to_ima_submitter_1 = require("./safe-to-ima-submitter");
|
|
6
|
+
const marionette_1 = require("./types/marionette");
|
|
7
|
+
class SafeImaMarionetteSubmitter extends safe_to_ima_submitter_1.SafeToImaSubmitter {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.marionette = new hardhat_1.ethers.Contract(marionette_1.MARIONETTE_ADDRESS, new hardhat_1.ethers.utils.Interface([
|
|
11
|
+
{
|
|
12
|
+
"inputs": [
|
|
13
|
+
{
|
|
14
|
+
"components": [
|
|
15
|
+
{
|
|
16
|
+
"internalType": "address",
|
|
17
|
+
"name": "receiver",
|
|
18
|
+
"type": "address"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"internalType": "uint256",
|
|
22
|
+
"name": "value",
|
|
23
|
+
"type": "uint256"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"internalType": "bytes",
|
|
27
|
+
"name": "data",
|
|
28
|
+
"type": "bytes"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"internalType": "struct IMarionette.FunctionCall[]",
|
|
32
|
+
"name": "functionCalls",
|
|
33
|
+
"type": "tuple[]"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"name": "encodeFunctionCalls",
|
|
37
|
+
"outputs": [
|
|
38
|
+
{
|
|
39
|
+
"internalType": "bytes",
|
|
40
|
+
"name": "",
|
|
41
|
+
"type": "bytes"
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"stateMutability": "pure",
|
|
45
|
+
"type": "function"
|
|
46
|
+
}
|
|
47
|
+
]), hardhat_1.ethers.provider);
|
|
48
|
+
}
|
|
49
|
+
async submit(transactions) {
|
|
50
|
+
const functionCalls = [];
|
|
51
|
+
for (const transaction of transactions) {
|
|
52
|
+
functionCalls.push({
|
|
53
|
+
receiver: transaction.to ? transaction.to : hardhat_1.ethers.constants.AddressZero,
|
|
54
|
+
value: transaction.value ? transaction.value : 0,
|
|
55
|
+
data: (transaction.data ? transaction.data : "0x")
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
await super.submit([
|
|
59
|
+
{
|
|
60
|
+
to: this.marionette.address,
|
|
61
|
+
data: await this.marionette.encodeFunctionCalls(functionCalls)
|
|
62
|
+
}
|
|
63
|
+
]);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.SafeImaMarionetteSubmitter = SafeImaMarionetteSubmitter;
|
|
@@ -1,13 +1,4 @@
|
|
|
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.SafeSubmitter = void 0;
|
|
13
4
|
const ethers_1 = require("ethers");
|
|
@@ -21,24 +12,22 @@ class SafeSubmitter extends submitter_1.Submitter {
|
|
|
21
12
|
this.safeAddress = safeAddress;
|
|
22
13
|
this.chainId = chainId;
|
|
23
14
|
}
|
|
24
|
-
submit(transactions) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
yield (0, gnosis_safe_1.sendSafeTransaction)(this.safeAddress, this.chainId, safeTx);
|
|
41
|
-
});
|
|
15
|
+
async submit(transactions) {
|
|
16
|
+
const safeTransactions = [];
|
|
17
|
+
for (const transaction of transactions) {
|
|
18
|
+
safeTransactions.push((0, multiSend_1.encodeTransaction)(0, transaction.to ? transaction.to : hardhat_1.ethers.constants.AddressZero, transaction.value ? ethers_1.BigNumber.from(transaction.value) : 0, transaction.data ? transaction.data.toString() : "0x"));
|
|
19
|
+
}
|
|
20
|
+
let privateKey = hardhat_1.network.config.accounts[0];
|
|
21
|
+
if (hardhat_1.network.config.accounts === "remote") {
|
|
22
|
+
// Don't have an information about private key
|
|
23
|
+
// Use random one because we most probable run tests
|
|
24
|
+
privateKey = hardhat_1.ethers.Wallet.createRandom().privateKey;
|
|
25
|
+
}
|
|
26
|
+
if (!this.chainId) {
|
|
27
|
+
this.chainId = (await hardhat_1.ethers.provider.getNetwork()).chainId;
|
|
28
|
+
}
|
|
29
|
+
const safeTx = await (0, gnosis_safe_1.createMultiSendTransaction)(hardhat_1.ethers, this.safeAddress, privateKey, safeTransactions, this.chainId);
|
|
30
|
+
await (0, gnosis_safe_1.sendSafeTransaction)(this.safeAddress, this.chainId, safeTx);
|
|
42
31
|
}
|
|
43
32
|
}
|
|
44
33
|
exports.SafeSubmitter = SafeSubmitter;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { BytesLike,
|
|
2
|
-
import { SkaleABIFile } from "../types/SkaleABIFile";
|
|
1
|
+
import { BytesLike, UnsignedTransaction } from "ethers";
|
|
3
2
|
import { SafeSubmitter } from "./safe-submitter";
|
|
3
|
+
import { Instance } from "@skalenetwork/skale-contracts";
|
|
4
4
|
export declare class SafeToImaSubmitter extends SafeSubmitter {
|
|
5
|
-
|
|
5
|
+
imaInstance: Instance;
|
|
6
6
|
targetSchainHash: BytesLike;
|
|
7
|
-
|
|
7
|
+
private _messageProxyForMainnet;
|
|
8
|
+
constructor(safeAddress: string, imaInstance: Instance, targetSchainHash: BytesLike, chainId?: number);
|
|
8
9
|
submit(transactions: UnsignedTransaction[]): Promise<void>;
|
|
10
|
+
private _getMessageProxyForMainnet;
|
|
9
11
|
}
|
|
@@ -1,39 +1,31 @@
|
|
|
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.SafeToImaSubmitter = void 0;
|
|
13
|
-
const hardhat_1 = require("hardhat");
|
|
14
4
|
const safe_submitter_1 = require("./safe-submitter");
|
|
15
5
|
class SafeToImaSubmitter extends safe_submitter_1.SafeSubmitter {
|
|
16
|
-
constructor(safeAddress,
|
|
6
|
+
constructor(safeAddress, imaInstance, targetSchainHash, chainId) {
|
|
17
7
|
super(safeAddress, chainId);
|
|
18
|
-
this.
|
|
8
|
+
this.imaInstance = imaInstance;
|
|
19
9
|
this.targetSchainHash = targetSchainHash;
|
|
20
10
|
}
|
|
21
|
-
submit(transactions) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
to: this.messageProxyForMainnet.address,
|
|
32
|
-
data: this.messageProxyForMainnet.interface.encodeFunctionData("postOutgoingMessage", [this.targetSchainHash, transaction.to, transaction.data])
|
|
33
|
-
};
|
|
34
|
-
});
|
|
35
|
-
yield _super.submit.call(this, transactionsToIma);
|
|
11
|
+
async submit(transactions) {
|
|
12
|
+
if (transactions.length > 1) {
|
|
13
|
+
this._atomicityWarning();
|
|
14
|
+
}
|
|
15
|
+
const messageProxyForMainnet = await this._getMessageProxyForMainnet();
|
|
16
|
+
const transactionsToIma = transactions.map((transaction) => {
|
|
17
|
+
return {
|
|
18
|
+
to: messageProxyForMainnet.address,
|
|
19
|
+
data: messageProxyForMainnet.interface.encodeFunctionData("postOutgoingMessage", [this.targetSchainHash, transaction.to, transaction.data])
|
|
20
|
+
};
|
|
36
21
|
});
|
|
22
|
+
await super.submit(transactionsToIma);
|
|
23
|
+
}
|
|
24
|
+
async _getMessageProxyForMainnet() {
|
|
25
|
+
if (this._messageProxyForMainnet === undefined) {
|
|
26
|
+
this._messageProxyForMainnet = await this.imaInstance.getContract("MessageProxyForMainnet");
|
|
27
|
+
}
|
|
28
|
+
return this._messageProxyForMainnet;
|
|
37
29
|
}
|
|
38
30
|
}
|
|
39
31
|
exports.SafeToImaSubmitter = SafeToImaSubmitter;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BigNumberish, BytesLike } from "ethers";
|
|
2
|
+
import { ethers as RawEthers } from "ethers";
|
|
3
|
+
export declare const MARIONETTE_ADDRESS = "0xD2c0DeFACe000000000000000000000000000000";
|
|
4
|
+
type FunctionCallStruct = {
|
|
5
|
+
receiver: string;
|
|
6
|
+
value: BigNumberish;
|
|
7
|
+
data: BytesLike;
|
|
8
|
+
};
|
|
9
|
+
export interface Marionette extends RawEthers.Contract {
|
|
10
|
+
encodeFunctionCalls(functionCalls: FunctionCallStruct[]): Promise<BytesLike>;
|
|
11
|
+
version(): Promise<string>;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
package/dist/src/upgrader.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { UnsignedTransaction } from "ethers";
|
|
2
|
-
import { SkaleABIFile } from "./types/SkaleABIFile";
|
|
3
2
|
import { Submitter } from "./submitters/submitter";
|
|
3
|
+
import { Instance } from "@skalenetwork/skale-contracts/lib/instance";
|
|
4
4
|
export declare abstract class Upgrader {
|
|
5
|
-
|
|
5
|
+
instance: Instance;
|
|
6
6
|
targetVersion: string;
|
|
7
7
|
contractNamesToUpgrade: string[];
|
|
8
8
|
projectName: string;
|
|
9
9
|
transactions: UnsignedTransaction[];
|
|
10
10
|
submitter: Submitter;
|
|
11
|
-
constructor(projectName: string, targetVersion: string,
|
|
11
|
+
constructor(projectName: string, targetVersion: string, instance: Instance, contractNamesToUpgrade: string[], submitter?: Submitter);
|
|
12
12
|
abstract getDeployedVersion: () => Promise<string | undefined>;
|
|
13
13
|
abstract setVersion: (newVersion: string) => Promise<void>;
|
|
14
14
|
deployNewContracts: () => Promise<void>;
|
|
15
15
|
initialize: () => Promise<void>;
|
|
16
16
|
upgrade(): Promise<void>;
|
|
17
17
|
_getContractFactoryAndUpdateManifest(contract: string): Promise<import("ethers").ContractFactory>;
|
|
18
|
-
_getContractKeyInAbiFile(contract: string): string;
|
|
19
18
|
}
|