@skalenetwork/upgrade-tools 0.0.1-custom.8 → 0.0.1-develop.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.
- package/dist/src/gnosis-safe.d.ts +1 -1
- package/dist/src/gnosis-safe.js +12 -32
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +6 -1
- package/dist/src/upgrade.d.ts +2 -1
- package/dist/src/upgrade.js +7 -6
- package/dist/typechain-types/AccessControlEnumerableUpgradeable.d.ts +8 -0
- package/dist/typechain-types/AccessControlUpgradeable.d.ts +8 -0
- package/dist/typechain-types/ContextUpgradeable.d.ts +40 -0
- package/dist/{types.js → typechain-types/ContextUpgradeable.js} +0 -0
- package/dist/typechain-types/ERC165Upgradeable.d.ts +13 -3
- package/dist/typechain-types/ISafeMock.d.ts +20 -1
- package/dist/typechain-types/Initializable.d.ts +40 -0
- package/dist/typechain-types/Initializable.js +2 -0
- package/dist/typechain-types/OwnableUpgradeable.d.ts +8 -0
- package/dist/typechain-types/SafeMock.d.ts +44 -1
- package/dist/typechain-types/factories/AccessControlEnumerableUpgradeable__factory.js +13 -0
- package/dist/typechain-types/factories/AccessControlUpgradeable__factory.js +13 -0
- package/dist/typechain-types/factories/ContextUpgradeable__factory.d.ts +18 -0
- package/dist/typechain-types/factories/ContextUpgradeable__factory.js +32 -0
- package/dist/typechain-types/factories/ERC165Upgradeable__factory.d.ts +15 -2
- package/dist/typechain-types/factories/ERC165Upgradeable__factory.js +13 -0
- package/dist/typechain-types/factories/ISafeMock__factory.d.ts +5 -1
- package/dist/typechain-types/factories/ISafeMock__factory.js +64 -0
- package/dist/typechain-types/factories/Initializable__factory.d.ts +18 -0
- package/dist/typechain-types/factories/Initializable__factory.js +32 -0
- package/dist/typechain-types/factories/OwnableUpgradeable__factory.js +13 -0
- package/dist/typechain-types/factories/SafeMock__factory.d.ts +4 -11
- package/dist/typechain-types/factories/SafeMock__factory.js +104 -1
- package/dist/typechain-types/index.d.ts +4 -0
- package/dist/typechain-types/index.js +5 -1
- package/package.json +21 -10
- package/dist/abi.d.ts +0 -2
- package/dist/abi.js +0 -16
- package/dist/deploy.d.ts +0 -5
- package/dist/deploy.js +0 -99
- package/dist/gnosis-safe.d.ts +0 -25
- package/dist/gnosis-safe.js +0 -209
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -19
- package/dist/multiSend.d.ts +0 -2
- package/dist/multiSend.js +0 -46
- package/dist/types.d.ts +0 -12
- package/dist/upgrade.d.ts +0 -6
- package/dist/upgrade.js +0 -210
- package/dist/verification.d.ts +0 -2
- package/dist/verification.js +0 -53
- package/dist/version.d.ts +0 -1
- package/dist/version.js +0 -34
package/dist/deploy.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
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.getContractFactory = exports.getManifestFile = exports.getContractKeyInAbiFile = exports.getLinkedContractFactory = exports.deployLibraries = void 0;
|
|
13
|
-
const upgrades_core_1 = require("@openzeppelin/upgrades-core");
|
|
14
|
-
const hardhat_1 = require("hardhat");
|
|
15
|
-
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
|
-
});
|
|
23
|
-
}
|
|
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
|
-
});
|
|
32
|
-
}
|
|
33
|
-
exports.deployLibraries = deployLibraries;
|
|
34
|
-
function _linkBytecode(artifact, libraries) {
|
|
35
|
-
let bytecode = artifact.bytecode;
|
|
36
|
-
for (const [, fileReferences] of Object.entries(artifact.linkReferences)) {
|
|
37
|
-
for (const [libName, fixups] of Object.entries(fileReferences)) {
|
|
38
|
-
const addr = libraries.get(libName);
|
|
39
|
-
if (addr === undefined) {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
for (const fixup of fixups) {
|
|
43
|
-
bytecode =
|
|
44
|
-
bytecode.substr(0, 2 + fixup.start * 2) +
|
|
45
|
-
addr.substr(2) +
|
|
46
|
-
bytecode.substr(2 + (fixup.start + fixup.length) * 2);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return bytecode;
|
|
51
|
-
}
|
|
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
|
-
});
|
|
59
|
-
}
|
|
60
|
-
exports.getLinkedContractFactory = getLinkedContractFactory;
|
|
61
|
-
function getContractKeyInAbiFile(contract) {
|
|
62
|
-
return contract.replace(/([a-zA-Z])(?=[A-Z])/g, '$1_').toLowerCase();
|
|
63
|
-
}
|
|
64
|
-
exports.getContractKeyInAbiFile = getContractKeyInAbiFile;
|
|
65
|
-
function getManifestFile() {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
return (yield upgrades_core_1.Manifest.forNetwork(hardhat_1.ethers.provider)).file;
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
exports.getManifestFile = getManifestFile;
|
|
71
|
-
function getContractFactory(contract) {
|
|
72
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
const { linkReferences } = yield hardhat_1.artifacts.readArtifact(contract);
|
|
74
|
-
if (!Object.keys(linkReferences).length)
|
|
75
|
-
return yield hardhat_1.ethers.getContractFactory(contract);
|
|
76
|
-
const libraryNames = [];
|
|
77
|
-
for (const key of Object.keys(linkReferences)) {
|
|
78
|
-
const libraryName = Object.keys(linkReferences[key])[0];
|
|
79
|
-
libraryNames.push(libraryName);
|
|
80
|
-
}
|
|
81
|
-
const libraries = yield deployLibraries(libraryNames);
|
|
82
|
-
const libraryArtifacts = {};
|
|
83
|
-
for (const [libraryName, libraryAddress] of libraries.entries()) {
|
|
84
|
-
const { bytecode } = yield hardhat_1.artifacts.readArtifact(libraryName);
|
|
85
|
-
libraryArtifacts[libraryName] = { "address": libraryAddress, "bytecodeHash": (0, upgrades_core_1.hashBytecode)(bytecode) };
|
|
86
|
-
}
|
|
87
|
-
let manifest;
|
|
88
|
-
try {
|
|
89
|
-
manifest = JSON.parse(yield fs_1.promises.readFile(yield getManifestFile(), "utf-8"));
|
|
90
|
-
Object.assign(libraryArtifacts, manifest.libraries);
|
|
91
|
-
}
|
|
92
|
-
finally {
|
|
93
|
-
Object.assign(manifest, { libraries: libraryArtifacts });
|
|
94
|
-
yield fs_1.promises.writeFile(yield getManifestFile(), JSON.stringify(manifest, null, 4));
|
|
95
|
-
}
|
|
96
|
-
return yield getLinkedContractFactory(contract, libraries);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
exports.getContractFactory = getContractFactory;
|
package/dist/gnosis-safe.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { ethers } from "ethers";
|
|
2
|
-
import { HardhatEthersHelpers } from "@nomiclabs/hardhat-ethers/types";
|
|
3
|
-
declare type Ethers = typeof ethers & HardhatEthersHelpers;
|
|
4
|
-
interface SafeMultisigTransaction {
|
|
5
|
-
safe: string;
|
|
6
|
-
to: string;
|
|
7
|
-
value: number;
|
|
8
|
-
data?: string;
|
|
9
|
-
operation: number;
|
|
10
|
-
gasToken?: string;
|
|
11
|
-
safeTxGas: number;
|
|
12
|
-
baseGas: number;
|
|
13
|
-
gasPrice: number;
|
|
14
|
-
refundReceiver?: string;
|
|
15
|
-
nonce: number;
|
|
16
|
-
contractTransactionHash: string;
|
|
17
|
-
sender: string;
|
|
18
|
-
signature?: string;
|
|
19
|
-
origin?: string;
|
|
20
|
-
}
|
|
21
|
-
export declare function getSafeTransactionUrl(chainId: number): string;
|
|
22
|
-
export declare function getSafeRelayUrl(chainId: number): string;
|
|
23
|
-
export declare function createMultiSendTransaction(ethers: Ethers, safeAddress: string, privateKey: string, transactions: string[], isSafeMock?: boolean): Promise<SafeMultisigTransaction>;
|
|
24
|
-
export declare function sendSafeTransaction(safe: string, chainId: number, safeTx: SafeMultisigTransaction): Promise<void>;
|
|
25
|
-
export {};
|
package/dist/gnosis-safe.js
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
-
};
|
|
33
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
exports.sendSafeTransaction = exports.createMultiSendTransaction = exports.getSafeRelayUrl = exports.getSafeTransactionUrl = void 0;
|
|
35
|
-
const axios_1 = __importDefault(require("axios"));
|
|
36
|
-
const ethers_eip712_1 = require("ethers-eip712");
|
|
37
|
-
const ethUtil = __importStar(require("ethereumjs-util"));
|
|
38
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
39
|
-
var Network;
|
|
40
|
-
(function (Network) {
|
|
41
|
-
Network[Network["MAINNET"] = 1] = "MAINNET";
|
|
42
|
-
Network[Network["RINKEBY"] = 4] = "RINKEBY";
|
|
43
|
-
Network[Network["GANACHE"] = 1337] = "GANACHE";
|
|
44
|
-
Network[Network["HARDHAT"] = 31337] = "HARDHAT";
|
|
45
|
-
})(Network || (Network = {}));
|
|
46
|
-
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
47
|
-
const ADDRESSES = {
|
|
48
|
-
multiSend: {
|
|
49
|
-
[Network.MAINNET]: "0x8D29bE29923b68abfDD21e541b9374737B49cdAD",
|
|
50
|
-
[Network.RINKEBY]: "0x8D29bE29923b68abfDD21e541b9374737B49cdAD",
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
const URLS = {
|
|
54
|
-
safe_transaction: {
|
|
55
|
-
[Network.MAINNET]: "https://safe-transaction.mainnet.gnosis.io",
|
|
56
|
-
[Network.RINKEBY]: "https://safe-transaction.rinkeby.gnosis.io",
|
|
57
|
-
},
|
|
58
|
-
safe_relay: {
|
|
59
|
-
[Network.MAINNET]: "https://safe-relay.mainnet.gnosis.io",
|
|
60
|
-
[Network.RINKEBY]: "https://safe-relay.rinkeby.gnosis.io",
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
function getMultiSendAddress(chainId) {
|
|
64
|
-
if (chainId === Network.MAINNET) {
|
|
65
|
-
return ADDRESSES.multiSend[chainId];
|
|
66
|
-
}
|
|
67
|
-
else if (chainId === Network.RINKEBY) {
|
|
68
|
-
return ADDRESSES.multiSend[chainId];
|
|
69
|
-
}
|
|
70
|
-
else if ([Network.GANACHE, Network.HARDHAT].includes(chainId)) {
|
|
71
|
-
return ZERO_ADDRESS;
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
throw Error(`Can't get multiSend contract at network with chainId = ${chainId}`);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function getSafeTransactionUrl(chainId) {
|
|
78
|
-
if (chainId === Network.MAINNET) {
|
|
79
|
-
return URLS.safe_transaction[chainId];
|
|
80
|
-
}
|
|
81
|
-
else if (chainId === 4) {
|
|
82
|
-
return URLS.safe_transaction[chainId];
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
throw Error(`Can't get safe-transaction url at network with chainId = ${chainId}`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.getSafeTransactionUrl = getSafeTransactionUrl;
|
|
89
|
-
function getSafeRelayUrl(chainId) {
|
|
90
|
-
if (chainId === 1) {
|
|
91
|
-
return URLS.safe_relay[chainId];
|
|
92
|
-
}
|
|
93
|
-
else if (chainId === 4) {
|
|
94
|
-
return URLS.safe_relay[chainId];
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
throw Error(`Can't get safe-relay url at network with chainId = ${chainId}`);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
exports.getSafeRelayUrl = getSafeRelayUrl;
|
|
101
|
-
function concatTransactions(transactions) {
|
|
102
|
-
return "0x" + transactions.map((transaction) => {
|
|
103
|
-
if (transaction.startsWith("0x")) {
|
|
104
|
-
return transaction.slice(2);
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
return transaction;
|
|
108
|
-
}
|
|
109
|
-
}).join("");
|
|
110
|
-
}
|
|
111
|
-
function createMultiSendTransaction(ethers, safeAddress, privateKey, transactions, isSafeMock = false) {
|
|
112
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
const chainId = (yield ethers.provider.getNetwork()).chainId;
|
|
114
|
-
const multiSendAddress = getMultiSendAddress(chainId);
|
|
115
|
-
const multiSendAbi = [{ "constant": false, "inputs": [{ "internalType": "bytes", "name": "transactions", "type": "bytes" }], "name": "multiSend", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }];
|
|
116
|
-
const multiSend = new ethers.Contract(multiSendAddress, new ethers.utils.Interface(multiSendAbi), ethers.provider);
|
|
117
|
-
let nonce = 0;
|
|
118
|
-
if (!isSafeMock) {
|
|
119
|
-
try {
|
|
120
|
-
const nonceResponse = yield axios_1.default.get(`${getSafeTransactionUrl(chainId)}/api/v1/safes/${safeAddress}/`);
|
|
121
|
-
nonce = nonceResponse.data.nonce;
|
|
122
|
-
}
|
|
123
|
-
catch (e) {
|
|
124
|
-
if (!(e instanceof Error) || !e.toString().startsWith("Error: Can't get safe-transaction url")) {
|
|
125
|
-
throw e;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
const tx = {
|
|
130
|
-
"safe": safeAddress,
|
|
131
|
-
"to": multiSend.address,
|
|
132
|
-
"value": 0,
|
|
133
|
-
"data": multiSend.interface.encodeFunctionData("multiSend", [concatTransactions(transactions)]),
|
|
134
|
-
"operation": 1,
|
|
135
|
-
"gasToken": ZERO_ADDRESS,
|
|
136
|
-
"safeTxGas": 0,
|
|
137
|
-
"baseGas": 0,
|
|
138
|
-
"gasPrice": 0,
|
|
139
|
-
"refundReceiver": ZERO_ADDRESS,
|
|
140
|
-
"nonce": nonce, // Nonce of the Safe, transaction cannot be executed until Safe's nonce is not equal to this nonce
|
|
141
|
-
};
|
|
142
|
-
const typedData = {
|
|
143
|
-
types: {
|
|
144
|
-
EIP712Domain: [
|
|
145
|
-
{ name: "verifyingContract", type: "address" },
|
|
146
|
-
],
|
|
147
|
-
SafeTx: [
|
|
148
|
-
{ type: "address", name: "to" },
|
|
149
|
-
{ type: "uint256", name: "value" },
|
|
150
|
-
{ type: "bytes", name: "data" },
|
|
151
|
-
{ type: "uint8", name: "operation" },
|
|
152
|
-
{ type: "uint256", name: "safeTxGas" },
|
|
153
|
-
{ type: "uint256", name: "baseGas" },
|
|
154
|
-
{ type: "uint256", name: "gasPrice" },
|
|
155
|
-
{ type: "address", name: "gasToken" },
|
|
156
|
-
{ type: "address", name: "refundReceiver" },
|
|
157
|
-
{ type: "uint256", name: "nonce" },
|
|
158
|
-
]
|
|
159
|
-
},
|
|
160
|
-
primaryType: 'SafeTx',
|
|
161
|
-
domain: {
|
|
162
|
-
verifyingContract: safeAddress
|
|
163
|
-
},
|
|
164
|
-
message: Object.assign(Object.assign({}, tx), { data: ethers.utils.arrayify(tx.data) })
|
|
165
|
-
};
|
|
166
|
-
const digest = ethers_eip712_1.TypedDataUtils.encodeDigest(typedData);
|
|
167
|
-
const digestHex = ethers.utils.hexlify(digest);
|
|
168
|
-
const privateKeyBuffer = ethUtil.toBuffer(privateKey);
|
|
169
|
-
const { r, s, v } = ethUtil.ecsign(ethUtil.toBuffer(digestHex), privateKeyBuffer);
|
|
170
|
-
const signature = ethUtil.toRpcSig(v, r, s).toString();
|
|
171
|
-
const txToSend = Object.assign(Object.assign({}, tx), { "contractTransactionHash": digestHex,
|
|
172
|
-
// Owner of the Safe proposing the transaction. Must match one of the signatures
|
|
173
|
-
"sender": ethers.utils.getAddress(ethUtil.bufferToHex(ethUtil.privateToAddress(privateKeyBuffer))), "signature": signature, "origin": "Upgrade skale-manager" // Give more information about the transaction, e.g. "My Custom Safe app"
|
|
174
|
-
});
|
|
175
|
-
return txToSend;
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
exports.createMultiSendTransaction = createMultiSendTransaction;
|
|
179
|
-
function sendSafeTransaction(safe, chainId, safeTx) {
|
|
180
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
-
try {
|
|
182
|
-
console.log("Estimate gas");
|
|
183
|
-
const estimateRequest = safeTx;
|
|
184
|
-
try {
|
|
185
|
-
const estimateResponse = yield axios_1.default.post(`${getSafeRelayUrl(chainId)}/api/v2/safes/${safe}/transactions/estimate/`, estimateRequest);
|
|
186
|
-
console.log(chalk_1.default.cyan(`Recommend to set gas limit to ${parseInt(estimateResponse.data.safeTxGas, 10) + parseInt(estimateResponse.data.baseGas, 10)}`));
|
|
187
|
-
}
|
|
188
|
-
catch (e) {
|
|
189
|
-
console.log(chalk_1.default.red("Failed to estimate gas"));
|
|
190
|
-
console.log(e);
|
|
191
|
-
}
|
|
192
|
-
console.log(chalk_1.default.green("Send transaction to gnosis safe"));
|
|
193
|
-
yield axios_1.default.post(`${getSafeTransactionUrl(chainId)}/api/v1/safes/${safe}/multisig-transactions/`, safeTx);
|
|
194
|
-
}
|
|
195
|
-
catch (e) {
|
|
196
|
-
if (axios_1.default.isAxiosError(e)) {
|
|
197
|
-
if (e.response) {
|
|
198
|
-
console.log(JSON.stringify(e.response.data, null, 4));
|
|
199
|
-
console.log(chalk_1.default.red(`Request failed with ${e.response.status} code`));
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
console.log(chalk_1.default.red("Request failed with unknown reason"));
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
throw e;
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
exports.sendSafeTransaction = sendSafeTransaction;
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./abi"), exports);
|
|
14
|
-
__exportStar(require("./deploy"), exports);
|
|
15
|
-
__exportStar(require("./gnosis-safe"), exports);
|
|
16
|
-
__exportStar(require("./multiSend"), exports);
|
|
17
|
-
__exportStar(require("./upgrade"), exports);
|
|
18
|
-
__exportStar(require("./verification"), exports);
|
|
19
|
-
__exportStar(require("./version"), exports);
|
package/dist/multiSend.d.ts
DELETED
package/dist/multiSend.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.encodeTransaction = void 0;
|
|
4
|
-
const ethers_1 = require("ethers");
|
|
5
|
-
function padWithZeros(value, targetLength) {
|
|
6
|
-
return ("0".repeat(targetLength) + value).slice(-targetLength);
|
|
7
|
-
}
|
|
8
|
-
function encodeTransaction(operation, to, value, data) {
|
|
9
|
-
/// operation as a uint8 with 0 for a call or 1 for a delegatecall (=> 1 byte),
|
|
10
|
-
/// to as a address (=> 20 bytes),
|
|
11
|
-
/// value as a uint256 (=> 32 bytes),
|
|
12
|
-
/// data length as a uint256 (=> 32 bytes),
|
|
13
|
-
/// data as bytes.
|
|
14
|
-
let _operation;
|
|
15
|
-
if (operation === 0) {
|
|
16
|
-
_operation = "00";
|
|
17
|
-
}
|
|
18
|
-
else if (operation === 1) {
|
|
19
|
-
_operation = "01";
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
throw Error(`Operation has an incorrect value`);
|
|
23
|
-
}
|
|
24
|
-
let _to = to;
|
|
25
|
-
if (to.startsWith("0x")) {
|
|
26
|
-
_to = _to.slice(2);
|
|
27
|
-
}
|
|
28
|
-
_to = padWithZeros(_to, 20 * 2);
|
|
29
|
-
const _value = padWithZeros(ethers_1.BigNumber.from(value).toHexString().slice(2), 32 * 2);
|
|
30
|
-
let _data = data;
|
|
31
|
-
if (data.startsWith("0x")) {
|
|
32
|
-
_data = _data.slice(2);
|
|
33
|
-
}
|
|
34
|
-
if (_data.length % 2 !== 0) {
|
|
35
|
-
_data = "0" + _data;
|
|
36
|
-
}
|
|
37
|
-
const _dataLength = padWithZeros((_data.length / 2).toString(16), 32 * 2);
|
|
38
|
-
return "0x" + [
|
|
39
|
-
_operation,
|
|
40
|
-
_to,
|
|
41
|
-
_value,
|
|
42
|
-
_dataLength,
|
|
43
|
-
_data,
|
|
44
|
-
].join("");
|
|
45
|
-
}
|
|
46
|
-
exports.encodeTransaction = encodeTransaction;
|
package/dist/types.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ManifestData } from "@openzeppelin/upgrades-core";
|
|
2
|
-
export interface SkaleManifestData extends ManifestData {
|
|
3
|
-
libraries: {
|
|
4
|
-
[libraryName: string]: {
|
|
5
|
-
address: string;
|
|
6
|
-
bytecodeHash: string;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export interface SkaleABIFile {
|
|
11
|
-
[key: string]: string | [];
|
|
12
|
-
}
|
package/dist/upgrade.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { SkaleABIFile } from "./types";
|
|
2
|
-
import { Contract } from "ethers";
|
|
3
|
-
export declare function getContractFactoryAndUpdateManifest(contract: string): Promise<import("ethers").ContractFactory>;
|
|
4
|
-
declare type DeploymentAction<ContractManagerType extends Contract> = (safeTransactions: string[], abi: SkaleABIFile, contractManager: ContractManagerType) => Promise<void>;
|
|
5
|
-
export declare function upgrade<ContractManagerType extends Contract>(targetVersion: string, contractNamesToUpgrade: string[], deployNewContracts: DeploymentAction<ContractManagerType>, initialize: DeploymentAction<ContractManagerType>, getDeployedVersion: () => Promise<string | undefined>, setVersion: () => Promise<void>): Promise<void>;
|
|
6
|
-
export {};
|
package/dist/upgrade.js
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.upgrade = exports.getContractFactoryAndUpdateManifest = void 0;
|
|
16
|
-
const deploy_1 = require("./deploy");
|
|
17
|
-
const fs_1 = require("fs");
|
|
18
|
-
const hardhat_1 = require("hardhat");
|
|
19
|
-
const hardhat_2 = __importDefault(require("hardhat"));
|
|
20
|
-
const upgrades_core_1 = require("@openzeppelin/upgrades-core");
|
|
21
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
22
|
-
const admin_1 = require("@openzeppelin/hardhat-upgrades/dist/admin");
|
|
23
|
-
function getContractFactoryAndUpdateManifest(contract) {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
const manifest = JSON.parse(yield fs_1.promises.readFile(yield (0, deploy_1.getManifestFile)(), "utf-8"));
|
|
26
|
-
const { linkReferences } = yield hardhat_1.artifacts.readArtifact(contract);
|
|
27
|
-
if (!Object.keys(linkReferences).length)
|
|
28
|
-
return yield hardhat_1.ethers.getContractFactory(contract);
|
|
29
|
-
const librariesToUpgrade = [];
|
|
30
|
-
const oldLibraries = {};
|
|
31
|
-
if (manifest.libraries === undefined) {
|
|
32
|
-
Object.assign(manifest, { libraries: {} });
|
|
33
|
-
}
|
|
34
|
-
for (const key of Object.keys(linkReferences)) {
|
|
35
|
-
const libraryName = Object.keys(linkReferences[key])[0];
|
|
36
|
-
const { bytecode } = yield hardhat_1.artifacts.readArtifact(libraryName);
|
|
37
|
-
if (manifest.libraries[libraryName] === undefined) {
|
|
38
|
-
librariesToUpgrade.push(libraryName);
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
const libraryBytecodeHash = manifest.libraries[libraryName].bytecodeHash;
|
|
42
|
-
if ((0, upgrades_core_1.hashBytecode)(bytecode) !== libraryBytecodeHash) {
|
|
43
|
-
librariesToUpgrade.push(libraryName);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
oldLibraries[libraryName] = manifest.libraries[libraryName].address;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const libraries = yield (0, deploy_1.deployLibraries)(librariesToUpgrade);
|
|
50
|
-
for (const [libraryName, libraryAddress] of libraries.entries()) {
|
|
51
|
-
const { bytecode } = yield hardhat_1.artifacts.readArtifact(libraryName);
|
|
52
|
-
manifest.libraries[libraryName] = { "address": libraryAddress, "bytecodeHash": (0, upgrades_core_1.hashBytecode)(bytecode) };
|
|
53
|
-
}
|
|
54
|
-
Object.assign(libraries, oldLibraries);
|
|
55
|
-
yield fs_1.promises.writeFile(yield (0, deploy_1.getManifestFile)(), JSON.stringify(manifest, null, 4));
|
|
56
|
-
return yield (0, deploy_1.getLinkedContractFactory)(contract, libraries);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
exports.getContractFactoryAndUpdateManifest = getContractFactoryAndUpdateManifest;
|
|
60
|
-
function upgrade(targetVersion, contractNamesToUpgrade, deployNewContracts, initialize, getDeployedVersion, setVersion) {
|
|
61
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
if (!process.env.ABI) {
|
|
63
|
-
console.log(chalk_1.default.red("Set path to file with ABI and addresses to ABI environment variables"));
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const abiFilename = process.env.ABI;
|
|
67
|
-
const abi = JSON.parse(yield fs_1.promises.readFile(abiFilename, "utf-8"));
|
|
68
|
-
const proxyAdmin = yield (0, admin_1.getManifestAdmin)(hardhat_2.default);
|
|
69
|
-
const contractManagerName = "ContractManager";
|
|
70
|
-
const contractManagerFactory = yield hardhat_1.ethers.getContractFactory(contractManagerName);
|
|
71
|
-
const contractManager = (contractManagerFactory.attach(abi[getContractKeyInAbiFile(contractManagerName) + "_address"]));
|
|
72
|
-
const deployedVersion = yield getDeployedVersion();
|
|
73
|
-
const version = yield getVersion();
|
|
74
|
-
if (deployedVersion) {
|
|
75
|
-
if (deployedVersion !== targetVersion) {
|
|
76
|
-
console.log(chalk_1.default.red(`This script can't upgrade version ${deployedVersion} to ${version}`));
|
|
77
|
-
process.exit(1);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
console.log(chalk_1.default.yellow("Can't check currently deployed version of skale-manager"));
|
|
82
|
-
}
|
|
83
|
-
console.log(`Will mark updated version as ${version}`);
|
|
84
|
-
const [deployer] = yield hardhat_1.ethers.getSigners();
|
|
85
|
-
let safe = yield proxyAdmin.owner();
|
|
86
|
-
const safeTransactions = [];
|
|
87
|
-
let safeMock;
|
|
88
|
-
if ((yield hardhat_1.ethers.provider.getCode(safe)) === "0x") {
|
|
89
|
-
console.log("Owner is not a contract");
|
|
90
|
-
if (deployer.address !== safe) {
|
|
91
|
-
console.log(chalk_1.default.red("Used address does not have permissions to upgrade skale-manager"));
|
|
92
|
-
process.exit(1);
|
|
93
|
-
}
|
|
94
|
-
console.log(chalk_1.default.blue("Deploy SafeMock to simulate upgrade via multisig"));
|
|
95
|
-
const safeMockFactory = yield hardhat_1.ethers.getContractFactory("SafeMock");
|
|
96
|
-
safeMock = (yield safeMockFactory.deploy());
|
|
97
|
-
yield safeMock.deployTransaction.wait();
|
|
98
|
-
console.log(chalk_1.default.blue("Transfer ownership to SafeMock"));
|
|
99
|
-
safe = safeMock.address;
|
|
100
|
-
yield (yield proxyAdmin.transferOwnership(safe)).wait();
|
|
101
|
-
yield (yield contractManager.transferOwnership(safe)).wait();
|
|
102
|
-
for (const contractName of ["SkaleToken"].concat(contractNamesToUpgrade
|
|
103
|
-
.filter(name => !['ContractManager', 'TimeHelpers', 'Decryption', 'ECDH', 'SyncManager'].includes(name)))) {
|
|
104
|
-
const contractFactory = yield getContractFactoryAndUpdateManifest(contractName);
|
|
105
|
-
let _contract = contractName;
|
|
106
|
-
if (contractName === "BountyV2") {
|
|
107
|
-
if (!abi[getContractKeyInAbiFile(contractName) + "_address"])
|
|
108
|
-
_contract = "Bounty";
|
|
109
|
-
}
|
|
110
|
-
const contractAddress = abi[getContractKeyInAbiFile(_contract) + "_address"];
|
|
111
|
-
const contract = contractFactory.attach(contractAddress);
|
|
112
|
-
console.log(chalk_1.default.blue(`Grant access to ${contractName}`));
|
|
113
|
-
yield (yield contract.grantRole(yield contract.DEFAULT_ADMIN_ROLE(), safe)).wait();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
try {
|
|
118
|
-
const safeMockFactory = yield hardhat_1.ethers.getContractFactory("SafeMock");
|
|
119
|
-
const checkSafeMock = (safeMockFactory.attach(safe));
|
|
120
|
-
if (yield checkSafeMock.IS_SAFE_MOCK()) {
|
|
121
|
-
safeMock = checkSafeMock;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
catch (e) {
|
|
125
|
-
console.log(chalk_1.default.yellow("Owner is not SafeMock"));
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
// Deploy new contracts
|
|
129
|
-
yield deployNewContracts(safeTransactions, abi, contractManager);
|
|
130
|
-
// deploy new implementations
|
|
131
|
-
const contractsToUpgrade = [];
|
|
132
|
-
for (const contract of contractNamesToUpgrade) {
|
|
133
|
-
const contractFactory = yield getContractFactoryAndUpdateManifest(contract);
|
|
134
|
-
let _contract = contract;
|
|
135
|
-
if (contract === "BountyV2") {
|
|
136
|
-
if (!abi[getContractKeyInAbiFile(contract) + "_address"])
|
|
137
|
-
_contract = "Bounty";
|
|
138
|
-
}
|
|
139
|
-
const proxyAddress = abi[getContractKeyInAbiFile(_contract) + "_address"];
|
|
140
|
-
console.log(`Prepare upgrade of ${contract}`);
|
|
141
|
-
const newImplementationAddress = yield upgrades.prepareUpgrade(proxyAddress, contractFactory, {
|
|
142
|
-
unsafeAllowLinkedLibraries: true,
|
|
143
|
-
unsafeAllowRenames: true
|
|
144
|
-
});
|
|
145
|
-
const currentImplementationAddress = yield getImplementationAddress(network.provider, proxyAddress);
|
|
146
|
-
if (newImplementationAddress !== currentImplementationAddress) {
|
|
147
|
-
contractsToUpgrade.push({
|
|
148
|
-
proxyAddress,
|
|
149
|
-
implementationAddress: newImplementationAddress,
|
|
150
|
-
name: contract,
|
|
151
|
-
abi: getAbi(contractFactory.interface)
|
|
152
|
-
});
|
|
153
|
-
yield verify(contract, newImplementationAddress, []);
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
console.log(chalk_1.default.gray(`Contract ${contract} is up to date`));
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
// Switch proxies to new implementations
|
|
160
|
-
for (const contract of contractsToUpgrade) {
|
|
161
|
-
console.log(chalk_1.default.yellowBright(`Prepare transaction to upgrade ${contract.name} at ${contract.proxyAddress} to ${contract.implementationAddress}`));
|
|
162
|
-
safeTransactions.push(encodeTransaction(0, proxyAdmin.address, 0, proxyAdmin.interface.encodeFunctionData("upgrade", [contract.proxyAddress, contract.implementationAddress])));
|
|
163
|
-
abi[getContractKeyInAbiFile(contract.name) + "_abi"] = contract.abi;
|
|
164
|
-
}
|
|
165
|
-
yield initialize(safeTransactions, abi, contractManager);
|
|
166
|
-
// write version
|
|
167
|
-
if (safeMock) {
|
|
168
|
-
console.log(chalk_1.default.blue("Grant access to set version"));
|
|
169
|
-
yield (yield skaleManager.grantRole(yield skaleManager.DEFAULT_ADMIN_ROLE(), safe)).wait();
|
|
170
|
-
}
|
|
171
|
-
safeTransactions.push(encodeTransaction(0, skaleManager.address, 0, skaleManager.interface.encodeFunctionData("setVersion", [version])));
|
|
172
|
-
yield fs_1.promises.writeFile(`data/transactions-${version}-${network.name}.json`, JSON.stringify(safeTransactions, null, 4));
|
|
173
|
-
let privateKey = network.config.accounts[0];
|
|
174
|
-
if (network.config.accounts === "remote") {
|
|
175
|
-
// Don't have an information about private key
|
|
176
|
-
// Use random one because we most probable run tests
|
|
177
|
-
privateKey = hardhat_1.ethers.Wallet.createRandom().privateKey;
|
|
178
|
-
}
|
|
179
|
-
const safeTx = yield createMultiSendTransaction(hardhat_1.ethers, safe, privateKey, safeTransactions, safeMock !== undefined);
|
|
180
|
-
if (!safeMock) {
|
|
181
|
-
const chainId = (yield hardhat_1.ethers.provider.getNetwork()).chainId;
|
|
182
|
-
yield sendSafeTransaction(safe, chainId, safeTx);
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
console.log(chalk_1.default.blue("Send upgrade transactions to safe mock"));
|
|
186
|
-
try {
|
|
187
|
-
yield (yield deployer.sendTransaction({
|
|
188
|
-
to: safeMock.address,
|
|
189
|
-
value: safeTx.value,
|
|
190
|
-
data: safeTx.data,
|
|
191
|
-
})).wait();
|
|
192
|
-
}
|
|
193
|
-
finally {
|
|
194
|
-
console.log(chalk_1.default.blue("Return ownership to wallet"));
|
|
195
|
-
yield (yield safeMock.transferProxyAdminOwnership(contractManager.address, deployer.address)).wait();
|
|
196
|
-
yield (yield safeMock.transferProxyAdminOwnership(proxyAdmin.address, deployer.address)).wait();
|
|
197
|
-
if ((yield proxyAdmin.owner()) === deployer.address) {
|
|
198
|
-
yield (yield safeMock.destroy({ gasLimit: 1000000 })).wait();
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
console.log(chalk_1.default.blue("Something went wrong with ownership transfer"));
|
|
202
|
-
process.exit(1);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
yield fs_1.promises.writeFile(`data/skale-manager-${version}-${network.name}-abi.json`, JSON.stringify(abi, null, 4));
|
|
207
|
-
console.log("Done");
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
exports.upgrade = upgrade;
|
package/dist/verification.d.ts
DELETED