@skalenetwork/upgrade-tools 3.0.0-develop.3 → 3.0.0-linter.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,8 @@ const upgrades_core_1 = require("@openzeppelin/upgrades-core");
5
5
  const hardhat_1 = require("hardhat");
6
6
  const fs_1 = require("fs");
7
7
  async function _deployLibrary(libraryName) {
8
- const Library = await hardhat_1.ethers.getContractFactory(libraryName), library = await Library.deploy();
8
+ const Library = await hardhat_1.ethers.getContractFactory(libraryName);
9
+ const library = await Library.deploy();
9
10
  await library.deployed();
10
11
  return library.address;
11
12
  }
@@ -36,7 +37,9 @@ function _linkBytecode(artifact, libraries) {
36
37
  return bytecode;
37
38
  }
38
39
  async function getLinkedContractFactory(contractName, libraries) {
39
- const cArtifact = await hardhat_1.artifacts.readArtifact(contractName), linkedBytecode = _linkBytecode(cArtifact, libraries), ContractFactory = await hardhat_1.ethers.getContractFactory(cArtifact.abi, linkedBytecode);
40
+ const cArtifact = await hardhat_1.artifacts.readArtifact(contractName);
41
+ const linkedBytecode = _linkBytecode(cArtifact, libraries);
42
+ const ContractFactory = await hardhat_1.ethers.getContractFactory(cArtifact.abi, linkedBytecode);
40
43
  return ContractFactory;
41
44
  }
42
45
  exports.getLinkedContractFactory = getLinkedContractFactory;
@@ -53,7 +56,8 @@ async function getContractFactory(contract) {
53
56
  const libraryName = Object.keys(linkReferences[key])[0];
54
57
  libraryNames.push(libraryName);
55
58
  }
56
- const libraries = await deployLibraries(libraryNames), libraryArtifacts = {};
59
+ const libraries = await deployLibraries(libraryNames);
60
+ const libraryArtifacts = {};
57
61
  for (const [libraryName, libraryAddress] of libraries.entries()) {
58
62
  const { bytecode } = await hardhat_1.artifacts.readArtifact(libraryName);
59
63
  libraryArtifacts[libraryName] = {
@@ -56,7 +56,8 @@ async function createMultiSendTransaction(safeAddress, transactions) {
56
56
  operation: 0,
57
57
  });
58
58
  }
59
- const safeService = await getSafeService(), nonce = await safeService.getNextNonce(safeAddress);
59
+ const safeService = await getSafeService();
60
+ const nonce = await safeService.getNextNonce(safeAddress);
60
61
  console.log("Will send tx to Gnosis with nonce", nonce);
61
62
  const options = {
62
63
  safeTxGas: "0",
@@ -65,7 +66,10 @@ async function createMultiSendTransaction(safeAddress, transactions) {
65
66
  gasToken: hardhat_1.ethers.constants.AddressZero,
66
67
  refundReceiver: hardhat_1.ethers.constants.AddressZero,
67
68
  nonce: nonce // Nonce of the Safe, transaction cannot be executed until Safe's nonce is not equal to this nonce
68
- }, ethAdapter = await getEthAdapter(), safeSdk = await protocol_kit_1.default.create({ ethAdapter, safeAddress }), safeTransaction = await safeSdk.createTransaction({ safeTransactionData, options });
69
+ };
70
+ const ethAdapter = await getEthAdapter();
71
+ const safeSdk = await protocol_kit_1.default.create({ ethAdapter, safeAddress });
72
+ const safeTransaction = await safeSdk.createTransaction({ safeTransactionData, options });
69
73
  await estimateSafeTransaction(safeAddress, safeTransactionData);
70
74
  await proposeTransaction(safeAddress, safeTransaction);
71
75
  }
@@ -86,7 +90,12 @@ async function estimateSafeTransaction(safeAddress, safeTransactionData) {
86
90
  console.log(chalk_1.default.green("Send transaction to gnosis safe"));
87
91
  }
88
92
  async function proposeTransaction(safeAddress, safeTransaction) {
89
- const [safeOwner] = await hardhat_1.ethers.getSigners(), ethAdapter = await getEthAdapter(), safeSdk = await protocol_kit_1.default.create({ ethAdapter, safeAddress }), safeTxHash = await safeSdk.getTransactionHash(safeTransaction), senderSignature = await safeSdk.signTransactionHash(safeTxHash), safeService = await getSafeService();
93
+ const [safeOwner] = await hardhat_1.ethers.getSigners();
94
+ const ethAdapter = await getEthAdapter();
95
+ const safeSdk = await protocol_kit_1.default.create({ ethAdapter, safeAddress });
96
+ const safeTxHash = await safeSdk.getTransactionHash(safeTransaction);
97
+ const senderSignature = await safeSdk.signTransactionHash(safeTxHash);
98
+ const safeService = await getSafeService();
90
99
  await safeService.proposeTransaction({
91
100
  safeAddress,
92
101
  safeTransactionData: safeTransaction.data,
@@ -96,14 +105,17 @@ async function proposeTransaction(safeAddress, safeTransaction) {
96
105
  });
97
106
  }
98
107
  async function getEthAdapter() {
99
- const [safeOwner] = await hardhat_1.ethers.getSigners(), ethAdapter = new protocol_kit_1.EthersAdapter({
108
+ const [safeOwner] = await hardhat_1.ethers.getSigners();
109
+ const ethAdapter = new protocol_kit_1.EthersAdapter({
100
110
  ethers: hardhat_1.ethers,
101
111
  signerOrProvider: safeOwner
102
112
  });
103
113
  return ethAdapter;
104
114
  }
105
115
  async function getSafeService() {
106
- const chainId = (await hardhat_1.ethers.provider.getNetwork()).chainId, ethAdapter = await getEthAdapter(), safeService = new api_kit_1.default({
116
+ const chainId = (await hardhat_1.ethers.provider.getNetwork()).chainId;
117
+ const ethAdapter = await getEthAdapter();
118
+ const safeService = new api_kit_1.default({
107
119
  txServiceUrl: getSafeTransactionUrl(chainId),
108
120
  ethAdapter
109
121
  });
@@ -40,7 +40,8 @@ class AutoSubmitter extends submitter_1.Submitter {
40
40
  async submit(transactions) {
41
41
  let submitter;
42
42
  // TODO: remove unknown when move everything to ethers 6
43
- const proxyAdmin = await (0, admin_1.getManifestAdmin)(hardhat_1.default), owner = await proxyAdmin.owner();
43
+ const proxyAdmin = await (0, admin_1.getManifestAdmin)(hardhat_1.default);
44
+ const owner = await proxyAdmin.owner();
44
45
  if (await hardhat_1.default.ethers.provider.getCode(owner) === "0x") {
45
46
  console.log("Owner is not a contract");
46
47
  submitter = new eoa_submitter_1.EoaSubmitter();
@@ -49,7 +50,10 @@ class AutoSubmitter extends submitter_1.Submitter {
49
50
  console.log("Owner is a contract");
50
51
  if (hardhat_1.ethers.utils.getAddress(owner) == hardhat_1.ethers.utils.getAddress(marionette_1.MARIONETTE_ADDRESS)) {
51
52
  console.log("Marionette owner is detected");
52
- const imaInstance = await this._getImaInstance(), mainnetChainId = this._getMainnetChainId(), safeAddress = this._getSafeAddress(), schainHash = this._getSchainHash();
53
+ const imaInstance = await this._getImaInstance();
54
+ const mainnetChainId = this._getMainnetChainId();
55
+ const safeAddress = this._getSafeAddress();
56
+ const schainHash = this._getSchainHash();
53
57
  // TODO: after marionette has multiSend functionality
54
58
  // query version and properly select a submitter
55
59
  // based on it
@@ -87,7 +91,8 @@ class AutoSubmitter extends submitter_1.Submitter {
87
91
  console.log(chalk_1.default.red("Set target IMA alias to IMA environment variable"));
88
92
  process.exit(1);
89
93
  }
90
- const network = await skale_contracts_ethers_v5_1.skaleContracts.getNetworkByProvider(hardhat_1.ethers.provider), ima = await network.getProject("ima");
94
+ const network = await skale_contracts_ethers_v5_1.skaleContracts.getNetworkByProvider(hardhat_1.ethers.provider);
95
+ const ima = await network.getProject("ima");
91
96
  return await ima.getInstance(process.env.IMA);
92
97
  }
93
98
  _getSafeAddress() {
@@ -12,7 +12,8 @@ class SafeToImaSubmitter extends safe_submitter_1.SafeSubmitter {
12
12
  if (transactions.length > 1) {
13
13
  this._atomicityWarning();
14
14
  }
15
- const messageProxyForMainnet = await this._getMessageProxyForMainnet(), transactionsToIma = transactions.map((transaction) => {
15
+ const messageProxyForMainnet = await this._getMessageProxyForMainnet();
16
+ const transactionsToIma = transactions.map((transaction) => {
16
17
  return {
17
18
  to: messageProxyForMainnet.address,
18
19
  data: messageProxyForMainnet.interface.encodeFunctionData("postOutgoingMessage", [this.targetSchainHash, transaction.to, transaction.data])
@@ -52,9 +52,11 @@ class Upgrader {
52
52
  // Deploy new implementations
53
53
  const contractsToUpgrade = [];
54
54
  for (const contract of this.contractNamesToUpgrade) {
55
- const contractFactory = await this._getContractFactoryAndUpdateManifest(contract), proxyAddress = (await this.instance.getContract(contract)).address;
55
+ const contractFactory = await this._getContractFactoryAndUpdateManifest(contract);
56
+ const proxyAddress = (await this.instance.getContract(contract)).address;
56
57
  console.log(`Prepare upgrade of ${contract}`);
57
- const currentImplementationAddress = await (0, upgrades_core_1.getImplementationAddress)(hardhat_2.network.provider, proxyAddress), newImplementationAddress = await hardhat_2.upgrades.prepareUpgrade(proxyAddress, contractFactory, {
58
+ const currentImplementationAddress = await (0, upgrades_core_1.getImplementationAddress)(hardhat_2.network.provider, proxyAddress);
59
+ const newImplementationAddress = await hardhat_2.upgrades.prepareUpgrade(proxyAddress, contractFactory, {
58
60
  unsafeAllowLinkedLibraries: true,
59
61
  unsafeAllowRenames: true
60
62
  });
@@ -95,15 +97,18 @@ class Upgrader {
95
97
  }
96
98
  // private
97
99
  async _getContractFactoryAndUpdateManifest(contract) {
98
- const { linkReferences } = await hardhat_2.artifacts.readArtifact(contract), manifest = JSON.parse(await fs_1.promises.readFile(await (0, deploy_1.getManifestFile)(), "utf-8"));
100
+ const { linkReferences } = await hardhat_2.artifacts.readArtifact(contract);
101
+ const manifest = JSON.parse(await fs_1.promises.readFile(await (0, deploy_1.getManifestFile)(), "utf-8"));
99
102
  if (!Object.keys(linkReferences).length)
100
103
  return await hardhat_2.ethers.getContractFactory(contract);
101
- const librariesToUpgrade = [], oldLibraries = {};
104
+ const librariesToUpgrade = [];
105
+ const oldLibraries = {};
102
106
  if (manifest.libraries === undefined) {
103
107
  Object.assign(manifest, { libraries: {} });
104
108
  }
105
109
  for (const key of Object.keys(linkReferences)) {
106
- const libraryName = Object.keys(linkReferences[key])[0], { bytecode } = await hardhat_2.artifacts.readArtifact(libraryName);
110
+ const libraryName = Object.keys(linkReferences[key])[0];
111
+ const { bytecode } = await hardhat_2.artifacts.readArtifact(libraryName);
107
112
  if (manifest.libraries[libraryName] === undefined) {
108
113
  librariesToUpgrade.push(libraryName);
109
114
  continue;
@@ -14,7 +14,8 @@ async function getVersionFilename(folder) {
14
14
  if (folder === undefined) {
15
15
  return getVersionFilename((await exec("git rev-parse --show-toplevel")).stdout.trim());
16
16
  }
17
- const VERSION_FILENAME = 'VERSION', path = `${folder}/${VERSION_FILENAME}`;
17
+ const VERSION_FILENAME = 'VERSION';
18
+ const path = `${folder}/${VERSION_FILENAME}`;
18
19
  if ((0, fs_1.existsSync)(path)) {
19
20
  return path;
20
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skalenetwork/upgrade-tools",
3
- "version": "3.0.0-develop.3",
3
+ "version": "3.0.0-linter.0",
4
4
  "description": "Scripts to support upgrades of smart contracts",
5
5
  "files": [
6
6
  "dist/**/*"