@skalenetwork/upgrade-tools 2.0.0-refactor.15 → 2.0.0-refactor.17
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/dist/src/submitters/auto-submitter.d.ts +1 -0
- package/dist/src/submitters/auto-submitter.js +45 -2
- package/dist/src/submitters/safe-ima-legacy-marionette-submitter.js +2 -1
- package/dist/src/submitters/safe-ima-marionette-submitter.d.ts +7 -0
- package/dist/src/submitters/safe-ima-marionette-submitter.js +80 -0
- package/dist/src/submitters/types/marionette.d.ts +13 -0
- package/dist/src/submitters/types/marionette.js +4 -0
- package/package.json +1 -1
|
@@ -44,6 +44,8 @@ const safe_submitter_1 = require("./safe-submitter");
|
|
|
44
44
|
const chalk_1 = __importDefault(require("chalk"));
|
|
45
45
|
const safe_ima_legacy_marionette_submitter_1 = require("./safe-ima-legacy-marionette-submitter");
|
|
46
46
|
const fs_1 = require("fs");
|
|
47
|
+
const marionette_1 = require("./types/marionette");
|
|
48
|
+
const safe_ima_marionette_submitter_1 = require("./safe-ima-marionette-submitter");
|
|
47
49
|
class AutoSubmitter extends submitter_1.Submitter {
|
|
48
50
|
submit(transactions) {
|
|
49
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -56,13 +58,20 @@ class AutoSubmitter extends submitter_1.Submitter {
|
|
|
56
58
|
}
|
|
57
59
|
else {
|
|
58
60
|
console.log("Owner is a contract");
|
|
59
|
-
if (hardhat_1.ethers.utils.getAddress(owner) == hardhat_1.ethers.utils.getAddress(
|
|
61
|
+
if (hardhat_1.ethers.utils.getAddress(owner) == hardhat_1.ethers.utils.getAddress(marionette_1.MARIONETTE_ADDRESS)) {
|
|
60
62
|
console.log("Marionette owner is detected");
|
|
61
63
|
const imaAbi = yield this._getImaAbi();
|
|
62
64
|
const safeAddress = this._getSafeAddress();
|
|
63
65
|
const schainHash = this._getSchainHash();
|
|
64
66
|
const mainnetChainId = this._getMainnetChainId();
|
|
65
|
-
|
|
67
|
+
if (yield this._versionFunctionExists()) {
|
|
68
|
+
console.log("version() function was found. Use normal Marionette");
|
|
69
|
+
submitter = new safe_ima_marionette_submitter_1.SafeImaMarionetteSubmitter(safeAddress, imaAbi, schainHash, mainnetChainId);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
console.log("No version() function was found. Use legacy Marionette");
|
|
73
|
+
submitter = new safe_ima_legacy_marionette_submitter_1.SafeImaLegacyMarionetteSubmitter(safeAddress, imaAbi, schainHash, mainnetChainId);
|
|
74
|
+
}
|
|
66
75
|
}
|
|
67
76
|
else {
|
|
68
77
|
// assuming owner is a Gnosis Safe
|
|
@@ -116,5 +125,39 @@ class AutoSubmitter extends submitter_1.Submitter {
|
|
|
116
125
|
return Number.parseInt(process.env.MAINNET_CHAIN_ID);
|
|
117
126
|
}
|
|
118
127
|
}
|
|
128
|
+
_versionFunctionExists() {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
const bytecode = yield hardhat_1.default.ethers.provider.getCode(marionette_1.MARIONETTE_ADDRESS);
|
|
131
|
+
// If the bytecode doesn't include the function selector version()
|
|
132
|
+
// is definitely not present
|
|
133
|
+
if (!bytecode.includes(hardhat_1.ethers.utils.id("version()").slice(2, 10))) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
const marionette = new hardhat_1.ethers.Contract(marionette_1.MARIONETTE_ADDRESS, [{
|
|
137
|
+
"inputs": [],
|
|
138
|
+
"name": "version",
|
|
139
|
+
"outputs": [
|
|
140
|
+
{
|
|
141
|
+
"internalType": "string",
|
|
142
|
+
"name": "",
|
|
143
|
+
"type": "string"
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"stateMutability": "view",
|
|
147
|
+
"type": "function"
|
|
148
|
+
}], hardhat_1.default.ethers.provider);
|
|
149
|
+
// If gas estimation doesn't revert then an execution is possible
|
|
150
|
+
// given the provided function selector
|
|
151
|
+
try {
|
|
152
|
+
yield marionette.estimateGas.version();
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
catch (_a) {
|
|
156
|
+
// Otherwise (revert) we assume that there is no entry in the jump table
|
|
157
|
+
// meaning that the contract doesn't include version()
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
119
162
|
}
|
|
120
163
|
exports.AutoSubmitter = AutoSubmitter;
|
|
@@ -12,10 +12,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.SafeImaLegacyMarionetteSubmitter = void 0;
|
|
13
13
|
const hardhat_1 = require("hardhat");
|
|
14
14
|
const safe_to_ima_submitter_1 = require("./safe-to-ima-submitter");
|
|
15
|
+
const marionette_1 = require("./types/marionette");
|
|
15
16
|
class SafeImaLegacyMarionetteSubmitter extends safe_to_ima_submitter_1.SafeToImaSubmitter {
|
|
16
17
|
constructor() {
|
|
17
18
|
super(...arguments);
|
|
18
|
-
this.marionette = new hardhat_1.ethers.Contract(
|
|
19
|
+
this.marionette = new hardhat_1.ethers.Contract(marionette_1.MARIONETTE_ADDRESS, new hardhat_1.ethers.utils.Interface([
|
|
19
20
|
{
|
|
20
21
|
"inputs": [
|
|
21
22
|
{
|
|
@@ -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,80 @@
|
|
|
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.SafeImaMarionetteSubmitter = void 0;
|
|
13
|
+
const hardhat_1 = require("hardhat");
|
|
14
|
+
const safe_to_ima_submitter_1 = require("./safe-to-ima-submitter");
|
|
15
|
+
const marionette_1 = require("./types/marionette");
|
|
16
|
+
class SafeImaMarionetteSubmitter extends safe_to_ima_submitter_1.SafeToImaSubmitter {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.marionette = new hardhat_1.ethers.Contract(marionette_1.MARIONETTE_ADDRESS, new hardhat_1.ethers.utils.Interface([
|
|
20
|
+
{
|
|
21
|
+
"inputs": [
|
|
22
|
+
{
|
|
23
|
+
"components": [
|
|
24
|
+
{
|
|
25
|
+
"internalType": "address",
|
|
26
|
+
"name": "receiver",
|
|
27
|
+
"type": "address"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"internalType": "uint256",
|
|
31
|
+
"name": "value",
|
|
32
|
+
"type": "uint256"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"internalType": "bytes",
|
|
36
|
+
"name": "data",
|
|
37
|
+
"type": "bytes"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"internalType": "struct IMarionette.FunctionCall[]",
|
|
41
|
+
"name": "functionCalls",
|
|
42
|
+
"type": "tuple[]"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"name": "encodeFunctionCalls",
|
|
46
|
+
"outputs": [
|
|
47
|
+
{
|
|
48
|
+
"internalType": "bytes",
|
|
49
|
+
"name": "",
|
|
50
|
+
"type": "bytes"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"stateMutability": "pure",
|
|
54
|
+
"type": "function"
|
|
55
|
+
}
|
|
56
|
+
]), hardhat_1.ethers.provider);
|
|
57
|
+
}
|
|
58
|
+
submit(transactions) {
|
|
59
|
+
const _super = Object.create(null, {
|
|
60
|
+
submit: { get: () => super.submit }
|
|
61
|
+
});
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const functionCalls = [];
|
|
64
|
+
for (const transaction of transactions) {
|
|
65
|
+
functionCalls.push({
|
|
66
|
+
receiver: transaction.to ? transaction.to : hardhat_1.ethers.constants.AddressZero,
|
|
67
|
+
value: transaction.value ? transaction.value : 0,
|
|
68
|
+
data: (transaction.data ? transaction.data : "0x")
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
yield _super.submit.call(this, [
|
|
72
|
+
{
|
|
73
|
+
to: this.marionette.address,
|
|
74
|
+
data: yield this.marionette.encodeFunctionCalls(functionCalls)
|
|
75
|
+
}
|
|
76
|
+
]);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.SafeImaMarionetteSubmitter = SafeImaMarionetteSubmitter;
|
|
@@ -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
|
+
declare 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 {};
|