@skalenetwork/upgrade-tools 0.0.1-custom.4 → 0.0.1-custom.8
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/deploy.d.ts +5 -0
- package/dist/deploy.js +99 -0
- package/dist/hardhat.config.d.ts +2 -0
- package/dist/hardhat.config.js +20 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +7 -1
- package/dist/src/abi.d.ts +2 -0
- package/dist/src/abi.js +16 -0
- package/dist/src/deploy.d.ts +5 -0
- package/dist/src/deploy.js +99 -0
- package/dist/src/gnosis-safe.d.ts +25 -0
- package/dist/src/gnosis-safe.js +209 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.js +19 -0
- package/dist/src/multiSend.d.ts +2 -0
- package/dist/src/multiSend.js +46 -0
- package/dist/src/types.d.ts +12 -0
- package/dist/src/types.js +2 -0
- package/dist/src/upgrade.d.ts +6 -0
- package/dist/src/upgrade.js +202 -0
- package/dist/src/verification.d.ts +2 -0
- package/dist/src/verification.js +53 -0
- package/dist/src/version.d.ts +1 -0
- package/dist/src/version.js +34 -0
- package/dist/typechain-types/AccessControlEnumerableUpgradeable.d.ts +175 -0
- package/dist/typechain-types/AccessControlEnumerableUpgradeable.js +2 -0
- package/dist/typechain-types/AccessControlUpgradeable.d.ts +159 -0
- package/dist/typechain-types/AccessControlUpgradeable.js +2 -0
- package/dist/typechain-types/AdminUpgradeabilityProxy.d.ts +145 -0
- package/dist/typechain-types/AdminUpgradeabilityProxy.js +2 -0
- package/dist/typechain-types/ERC165Upgradeable.d.ts +43 -0
- package/dist/typechain-types/ERC165Upgradeable.js +2 -0
- package/dist/typechain-types/IAccessControlEnumerableUpgradeable.d.ts +159 -0
- package/dist/typechain-types/IAccessControlEnumerableUpgradeable.js +2 -0
- package/dist/typechain-types/IAccessControlUpgradeable.d.ts +143 -0
- package/dist/typechain-types/IAccessControlUpgradeable.js +2 -0
- package/dist/typechain-types/IERC165Upgradeable.d.ts +43 -0
- package/dist/typechain-types/IERC165Upgradeable.js +2 -0
- package/dist/typechain-types/ISafeMock.d.ts +67 -0
- package/dist/typechain-types/ISafeMock.js +2 -0
- package/dist/typechain-types/OwnableUpgradeable.d.ts +89 -0
- package/dist/typechain-types/OwnableUpgradeable.js +2 -0
- package/dist/typechain-types/ProxyAdmin.d.ts +153 -0
- package/dist/typechain-types/ProxyAdmin.js +2 -0
- package/dist/typechain-types/SafeMock.d.ts +129 -0
- package/dist/typechain-types/SafeMock.js +2 -0
- package/dist/typechain-types/common.d.ts +21 -0
- package/dist/typechain-types/common.js +2 -0
- package/dist/typechain-types/factories/AccessControlEnumerableUpgradeable__factory.d.ts +35 -0
- package/dist/typechain-types/factories/AccessControlEnumerableUpgradeable__factory.js +266 -0
- package/dist/typechain-types/factories/AccessControlUpgradeable__factory.d.ts +35 -0
- package/dist/typechain-types/factories/AccessControlUpgradeable__factory.js +223 -0
- package/dist/typechain-types/factories/AdminUpgradeabilityProxy__factory.d.ts +74 -0
- package/dist/typechain-types/factories/AdminUpgradeabilityProxy__factory.js +187 -0
- package/dist/typechain-types/factories/ERC165Upgradeable__factory.d.ts +22 -0
- package/dist/typechain-types/factories/ERC165Upgradeable__factory.js +38 -0
- package/dist/typechain-types/factories/IAccessControlEnumerableUpgradeable__factory.d.ts +35 -0
- package/dist/typechain-types/factories/IAccessControlEnumerableUpgradeable__factory.js +234 -0
- package/dist/typechain-types/factories/IAccessControlUpgradeable__factory.d.ts +35 -0
- package/dist/typechain-types/factories/IAccessControlUpgradeable__factory.js +191 -0
- package/dist/typechain-types/factories/IERC165Upgradeable__factory.d.ts +22 -0
- package/dist/typechain-types/factories/IERC165Upgradeable__factory.js +38 -0
- package/dist/typechain-types/factories/ISafeMock__factory.d.ts +18 -0
- package/dist/typechain-types/factories/ISafeMock__factory.js +50 -0
- package/dist/typechain-types/factories/OwnableUpgradeable__factory.d.ts +42 -0
- package/dist/typechain-types/factories/OwnableUpgradeable__factory.js +71 -0
- package/dist/typechain-types/factories/ProxyAdmin__factory.d.ts +49 -0
- package/dist/typechain-types/factories/ProxyAdmin__factory.js +192 -0
- package/dist/typechain-types/factories/SafeMock__factory.d.ts +63 -0
- package/dist/typechain-types/factories/SafeMock__factory.js +144 -0
- package/dist/typechain-types/index.d.ts +22 -0
- package/dist/typechain-types/index.js +25 -0
- package/dist/upgrade.d.ts +6 -0
- package/dist/upgrade.js +209 -0
- package/package.json +15 -5
package/dist/deploy.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function deployLibraries(libraryNames: string[]): Promise<Map<string, string>>;
|
|
2
|
+
export declare function getLinkedContractFactory(contractName: string, libraries: Map<string, string>): Promise<import("ethers").ContractFactory>;
|
|
3
|
+
export declare function getContractKeyInAbiFile(contract: string): string;
|
|
4
|
+
export declare function getManifestFile(): Promise<string>;
|
|
5
|
+
export declare function getContractFactory(contract: string): Promise<import("ethers").ContractFactory>;
|
package/dist/deploy.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
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/hardhat.config.d.ts
CHANGED
package/dist/hardhat.config.js
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("@typechain/hardhat");
|
|
3
4
|
require("@nomiclabs/hardhat-ethers");
|
|
4
|
-
|
|
5
|
+
require("@openzeppelin/hardhat-upgrades");
|
|
6
|
+
const config = {
|
|
7
|
+
solidity: {
|
|
8
|
+
compilers: [
|
|
9
|
+
{
|
|
10
|
+
version: '0.8.11',
|
|
11
|
+
settings: {
|
|
12
|
+
optimizer: {
|
|
13
|
+
enabled: true,
|
|
14
|
+
runs: 200
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
typechain: {
|
|
21
|
+
externalArtifacts: ['node_modules/@openzeppelin/upgrades-core/artifacts/*.json']
|
|
22
|
+
}
|
|
23
|
+
};
|
|
5
24
|
exports.default = config;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -10,4 +10,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./"), exports);
|
|
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/src/abi.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAbi = void 0;
|
|
4
|
+
function getAbi(contractInterface) {
|
|
5
|
+
const abi = JSON.parse(contractInterface.format("json"));
|
|
6
|
+
abi.forEach((obj) => {
|
|
7
|
+
if (obj.type === "function") {
|
|
8
|
+
const func = obj;
|
|
9
|
+
func.inputs.concat(func.outputs).forEach((output) => {
|
|
10
|
+
Object.assign(output, Object.assign({ name: "" }, output));
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return abi;
|
|
15
|
+
}
|
|
16
|
+
exports.getAbi = getAbi;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function deployLibraries(libraryNames: string[]): Promise<Map<string, string>>;
|
|
2
|
+
export declare function getLinkedContractFactory(contractName: string, libraries: Map<string, string>): Promise<import("ethers").ContractFactory>;
|
|
3
|
+
export declare function getContractKeyInAbiFile(contract: string): string;
|
|
4
|
+
export declare function getManifestFile(): Promise<string>;
|
|
5
|
+
export declare function getContractFactory(contract: string): Promise<import("ethers").ContractFactory>;
|
|
@@ -0,0 +1,99 @@
|
|
|
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;
|
|
@@ -0,0 +1,25 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,209 @@
|
|
|
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;
|
|
@@ -0,0 +1,19 @@
|
|
|
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);
|
|
@@ -0,0 +1,46 @@
|
|
|
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;
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
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>(projectName: string, targetVersion: string, contractNamesToUpgrade: string[], deployNewContracts: DeploymentAction<ContractManagerType>, initialize: DeploymentAction<ContractManagerType>, getDeployedVersion: () => Promise<string | undefined>, setVersion: (version: string) => Promise<void>, safeMockAccessRequirements: string[]): Promise<void>;
|
|
6
|
+
export {};
|