@skalenetwork/upgrade-tools 3.0.0-linter.4 → 3.0.0-linter.5

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/abi.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import { Interface } from "ethers/lib/utils";
2
- export declare function getAbi(contractInterface: Interface): [];
2
+ export declare const getAbi: (contractInterface: Interface) => [];
package/dist/src/abi.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAbi = void 0;
4
- function getAbi(contractInterface) {
4
+ const getAbi = (contractInterface) => {
5
5
  const abi = JSON.parse(contractInterface.format("json"));
6
6
  abi.forEach((obj) => {
7
7
  if (obj.type === "function") {
@@ -15,5 +15,5 @@ function getAbi(contractInterface) {
15
15
  }
16
16
  });
17
17
  return abi;
18
- }
18
+ };
19
19
  exports.getAbi = getAbi;
@@ -1,4 +1,4 @@
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 getManifestFile(): Promise<string>;
4
- export declare function getContractFactory(contract: string): Promise<import("ethers").ContractFactory>;
1
+ export declare const deployLibraries: (libraryNames: string[]) => Promise<Map<string, string>>;
2
+ export declare const getLinkedContractFactory: (contractName: string, libraries: Map<string, string>) => Promise<import("ethers").ContractFactory>;
3
+ export declare const getManifestFile: () => Promise<string>;
4
+ export declare const getContractFactory: (contract: string) => Promise<import("ethers").ContractFactory>;
@@ -4,21 +4,21 @@ exports.getContractFactory = exports.getManifestFile = exports.getLinkedContract
4
4
  const upgrades_core_1 = require("@openzeppelin/upgrades-core");
5
5
  const hardhat_1 = require("hardhat");
6
6
  const fs_1 = require("fs");
7
- async function _deployLibrary(libraryName) {
7
+ const _deployLibrary = async (libraryName) => {
8
8
  const Library = await hardhat_1.ethers.getContractFactory(libraryName);
9
9
  const library = await Library.deploy();
10
10
  await library.deployed();
11
11
  return library.address;
12
- }
13
- async function deployLibraries(libraryNames) {
12
+ };
13
+ const deployLibraries = async (libraryNames) => {
14
14
  const libraries = new Map();
15
15
  for (const libraryName of libraryNames) {
16
16
  libraries.set(libraryName, await _deployLibrary(libraryName));
17
17
  }
18
18
  return libraries;
19
- }
19
+ };
20
20
  exports.deployLibraries = deployLibraries;
21
- function _linkBytecode(artifact, libraries) {
21
+ const _linkBytecode = (artifact, libraries) => {
22
22
  let { bytecode } = artifact;
23
23
  for (const [, fileReferences] of Object.entries(artifact.linkReferences)) {
24
24
  for (const [libName, fixups] of Object.entries(fileReferences)) {
@@ -35,19 +35,17 @@ function _linkBytecode(artifact, libraries) {
35
35
  }
36
36
  }
37
37
  return bytecode;
38
- }
39
- async function getLinkedContractFactory(contractName, libraries) {
38
+ };
39
+ const getLinkedContractFactory = async (contractName, libraries) => {
40
40
  const cArtifact = await hardhat_1.artifacts.readArtifact(contractName);
41
41
  const linkedBytecode = _linkBytecode(cArtifact, libraries);
42
42
  const ContractFactory = await hardhat_1.ethers.getContractFactory(cArtifact.abi, linkedBytecode);
43
43
  return ContractFactory;
44
- }
44
+ };
45
45
  exports.getLinkedContractFactory = getLinkedContractFactory;
46
- async function getManifestFile() {
47
- return (await upgrades_core_1.Manifest.forNetwork(hardhat_1.ethers.provider)).file;
48
- }
46
+ const getManifestFile = async () => (await upgrades_core_1.Manifest.forNetwork(hardhat_1.ethers.provider)).file;
49
47
  exports.getManifestFile = getManifestFile;
50
- async function getContractFactory(contract) {
48
+ const getContractFactory = async (contract) => {
51
49
  const { linkReferences } = await hardhat_1.artifacts.readArtifact(contract);
52
50
  if (!Object.keys(linkReferences).length) {
53
51
  return await hardhat_1.ethers.getContractFactory(contract);
@@ -57,7 +55,7 @@ async function getContractFactory(contract) {
57
55
  const libraryName = Object.keys(linkReferences[key])[0];
58
56
  libraryNames.push(libraryName);
59
57
  }
60
- const libraries = await deployLibraries(libraryNames);
58
+ const libraries = await (0, exports.deployLibraries)(libraryNames);
61
59
  const libraryArtifacts = {};
62
60
  for (const [libraryName, libraryAddress] of libraries.entries()) {
63
61
  const { bytecode } = await hardhat_1.artifacts.readArtifact(libraryName);
@@ -68,15 +66,15 @@ async function getContractFactory(contract) {
68
66
  }
69
67
  let manifest;
70
68
  try {
71
- manifest = JSON.parse(await fs_1.promises.readFile(await getManifestFile(), "utf-8"));
69
+ manifest = JSON.parse(await fs_1.promises.readFile(await (0, exports.getManifestFile)(), "utf-8"));
72
70
  Object.assign(libraryArtifacts, manifest.libraries);
73
71
  }
74
72
  finally {
75
73
  if (manifest !== undefined) {
76
74
  Object.assign(manifest, { "libraries": libraryArtifacts });
77
75
  }
78
- await fs_1.promises.writeFile(await getManifestFile(), JSON.stringify(manifest, null, 4));
76
+ await fs_1.promises.writeFile(await (0, exports.getManifestFile)(), JSON.stringify(manifest, null, 4));
79
77
  }
80
- return await getLinkedContractFactory(contract, libraries);
81
- }
78
+ return await (0, exports.getLinkedContractFactory)(contract, libraries);
79
+ };
82
80
  exports.getContractFactory = getContractFactory;
@@ -1,2 +1,2 @@
1
1
  import { UnsignedTransaction } from "ethers";
2
- export declare function createMultiSendTransaction(safeAddress: string, transactions: UnsignedTransaction[]): Promise<void>;
2
+ export declare const createMultiSendTransaction: (safeAddress: string, transactions: UnsignedTransaction[]) => Promise<void>;
@@ -46,7 +46,7 @@ const URLS = {
46
46
  }
47
47
  };
48
48
  // Public functions
49
- async function createMultiSendTransaction(safeAddress, transactions) {
49
+ const createMultiSendTransaction = async (safeAddress, transactions) => {
50
50
  const safeTransactionData = [];
51
51
  for (const transaction of transactions) {
52
52
  safeTransactionData.push({
@@ -80,10 +80,10 @@ async function createMultiSendTransaction(safeAddress, transactions) {
80
80
  options });
81
81
  await estimateSafeTransaction(safeAddress, safeTransactionData);
82
82
  await proposeTransaction(safeAddress, safeTransaction);
83
- }
83
+ };
84
84
  exports.createMultiSendTransaction = createMultiSendTransaction;
85
85
  // Private functions
86
- async function estimateSafeTransaction(safeAddress, safeTransactionData) {
86
+ const estimateSafeTransaction = async (safeAddress, safeTransactionData) => {
87
87
  console.log("Estimate gas");
88
88
  const safeService = await getSafeService();
89
89
  for (const transaction of safeTransactionData) {
@@ -96,8 +96,8 @@ async function estimateSafeTransaction(safeAddress, safeTransactionData) {
96
96
  console.log(chalk_1.default.cyan(`Recommend to set gas limit to ${parseInt(estimateResponse.safeTxGas, 10)}`));
97
97
  }
98
98
  console.log(chalk_1.default.green("Send transaction to gnosis safe"));
99
- }
100
- async function proposeTransaction(safeAddress, safeTransaction) {
99
+ };
100
+ const proposeTransaction = async (safeAddress, safeTransaction) => {
101
101
  const [safeOwner] = await hardhat_1.ethers.getSigners();
102
102
  const ethAdapter = await getEthAdapter();
103
103
  const safeSdk = await protocol_kit_1.default.create({ ethAdapter,
@@ -112,16 +112,16 @@ async function proposeTransaction(safeAddress, safeTransaction) {
112
112
  "senderAddress": safeOwner.address,
113
113
  "senderSignature": senderSignature.data
114
114
  });
115
- }
116
- async function getEthAdapter() {
115
+ };
116
+ const getEthAdapter = async () => {
117
117
  const [safeOwner] = await hardhat_1.ethers.getSigners();
118
118
  const ethAdapter = new protocol_kit_1.EthersAdapter({
119
119
  ethers: hardhat_1.ethers,
120
120
  "signerOrProvider": safeOwner
121
121
  });
122
122
  return ethAdapter;
123
- }
124
- async function getSafeService() {
123
+ };
124
+ const getSafeService = async () => {
125
125
  const { chainId } = await hardhat_1.ethers.provider.getNetwork();
126
126
  const ethAdapter = await getEthAdapter();
127
127
  const safeService = new api_kit_1.default({
@@ -129,10 +129,10 @@ async function getSafeService() {
129
129
  ethAdapter
130
130
  });
131
131
  return safeService;
132
- }
133
- function getSafeTransactionUrl(chainId) {
132
+ };
133
+ const getSafeTransactionUrl = (chainId) => {
134
134
  if (Object.keys(URLS.safe_transaction).includes(chainId.toString())) {
135
135
  return URLS.safe_transaction[chainId];
136
136
  }
137
137
  throw Error(`Can't get safe-transaction url at network with chainId = ${chainId}`);
138
- }
138
+ };
@@ -1,2 +1,2 @@
1
1
  import { BigNumber } from "ethers";
2
- export declare function encodeTransaction(operation: 0 | 1, to: string, value: BigNumber | number, data: string): string;
2
+ export declare const encodeTransaction: (operation: 0 | 1, to: string, value: BigNumber | number, data: string) => string;
@@ -2,10 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.encodeTransaction = void 0;
4
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) {
5
+ const padWithZeros = (value, targetLength) => ("0".repeat(targetLength) + value).slice(-targetLength);
6
+ const encodeTransaction = (operation, to, value, data) => {
9
7
  // / operation as a uint8 with 0 for a call or 1 for a delegatecall (=> 1 byte),
10
8
  // / to as a address (=> 20 bytes),
11
9
  // / value as a uint256 (=> 32 bytes),
@@ -43,5 +41,5 @@ function encodeTransaction(operation, to, value, data) {
43
41
  _dataLength,
44
42
  _data
45
43
  ].join("")}`;
46
- }
44
+ };
47
45
  exports.encodeTransaction = encodeTransaction;
@@ -1,2 +1,2 @@
1
- export declare function verify(contractName: string, contractAddress: string, constructorArguments: object): Promise<void>;
2
- export declare function verifyProxy(contractName: string, proxyAddress: string, constructorArguments: object): Promise<void>;
1
+ export declare const verify: (contractName: string, contractAddress: string, constructorArguments: object) => Promise<void>;
2
+ export declare const verifyProxy: (contractName: string, proxyAddress: string, constructorArguments: object) => Promise<void>;
@@ -8,7 +8,7 @@ const hardhat_1 = require("hardhat");
8
8
  const chain_config_1 = require("@nomicfoundation/hardhat-verify/internal/chain-config");
9
9
  const chalk_1 = __importDefault(require("chalk"));
10
10
  const upgrades_core_1 = require("@openzeppelin/upgrades-core");
11
- async function verify(contractName, contractAddress, constructorArguments) {
11
+ const verify = async (contractName, contractAddress, constructorArguments) => {
12
12
  const { chainId } = await hardhat_1.ethers.provider.getNetwork();
13
13
  if (chain_config_1.builtinChains.find((chain) => chain.chainId === chainId) !== undefined) {
14
14
  for (let retry = 0; retry <= 5; retry += 1) {
@@ -34,9 +34,9 @@ async function verify(contractName, contractAddress, constructorArguments) {
34
34
  }
35
35
  }
36
36
  }
37
- }
37
+ };
38
38
  exports.verify = verify;
39
- async function verifyProxy(contractName, proxyAddress, constructorArguments) {
40
- await verify(contractName, await (0, upgrades_core_1.getImplementationAddress)(hardhat_1.network.provider, proxyAddress), constructorArguments);
41
- }
39
+ const verifyProxy = async (contractName, proxyAddress, constructorArguments) => {
40
+ await (0, exports.verify)(contractName, await (0, upgrades_core_1.getImplementationAddress)(hardhat_1.network.provider, proxyAddress), constructorArguments);
41
+ };
42
42
  exports.verifyProxy = verifyProxy;
@@ -10,7 +10,7 @@ const util_1 = __importDefault(require("util"));
10
10
  const exec = util_1.default.promisify(child_process_1.exec);
11
11
  class VersionNotFound extends Error {
12
12
  }
13
- async function getVersionFilename(folder) {
13
+ const getVersionFilename = async (folder) => {
14
14
  if (folder === undefined) {
15
15
  return getVersionFilename((await exec("git rev-parse --show-toplevel")).stdout.trim());
16
16
  }
@@ -19,14 +19,16 @@ async function getVersionFilename(folder) {
19
19
  if ((0, fs_1.existsSync)(path)) {
20
20
  return path;
21
21
  }
22
- for (const entry of await fs_1.promises.readdir(folder, { "withFileTypes": true,
23
- "recursive": true })) {
22
+ for (const entry of await fs_1.promises.readdir(folder, {
23
+ "withFileTypes": true,
24
+ "recursive": true
25
+ })) {
24
26
  if (entry.isFile() && entry.name === VERSION_FILENAME) {
25
27
  return `${entry.path}/${entry.name}`;
26
28
  }
27
29
  }
28
30
  throw new VersionNotFound("Can't find version file");
29
- }
31
+ };
30
32
  const getVersion = async () => {
31
33
  if (process.env.VERSION) {
32
34
  return process.env.VERSION;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skalenetwork/upgrade-tools",
3
- "version": "3.0.0-linter.4",
3
+ "version": "3.0.0-linter.5",
4
4
  "description": "Scripts to support upgrades of smart contracts",
5
5
  "files": [
6
6
  "dist/**/*"