ethershell 0.1.0-beta.0 → 0.1.1-beta.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ethershell",
3
3
  "license": "MIT",
4
- "version": "0.1.0-beta.0",
4
+ "version": "0.1.1-beta.0",
5
5
  "description": "Interactive JavaScript console for Ethereum smart contract management",
6
6
  "author": "Alireza Kiakojouri (alirezaethdev@gmail.com)",
7
7
  "repository": {
@@ -34,7 +34,6 @@
34
34
  "blockchain"
35
35
  ],
36
36
  "dependencies": {
37
- "commander": "^12.1.0",
38
37
  "ethers": "^6.13.0",
39
38
  "node-localstorage": "^3.0.5",
40
39
  "solc": "^0.8.29",
@@ -19,7 +19,7 @@ import { createContractProxy } from '../utils/contractProxy.js';
19
19
  * Local storage instance for persisting contract metadata
20
20
  * @type {LocalStorage}
21
21
  */
22
- const localStorage = new LocalStorage('./localStorage');
22
+ const localStorage = new LocalStorage('./ethershell');
23
23
 
24
24
  /**
25
25
  * Map of all deployed and added contracts
@@ -17,14 +17,13 @@ import {
17
17
  import fs from 'fs';
18
18
  import {
19
19
  generateAllTypes,
20
- generateContractTypes
21
20
  } from '../utils/typeGenerator.js';
22
21
 
23
22
  /**
24
23
  * Stored config path
25
24
  * @type {string}
26
25
  */
27
- export const configPath = './localStorage/config.json';
26
+ export const configPath = './ethershell/config.json';
28
27
 
29
28
  /**
30
29
  * Global compiler configuration state
@@ -154,20 +153,20 @@ export function compilerOptions(gasOptimizer, viaIR, optimizerRuns = 200) {
154
153
  compConfig.viaIR = viaIR;
155
154
  compConfig.optimizerRuns = optimizerRuns;
156
155
 
156
+ // Update config file
157
157
  configFile.compiler.optimizer = compConfig.optimizer;
158
158
  configFile.compiler.viaIR = compConfig.viaIR;
159
159
  configFile.compiler.optimizerRuns = compConfig.optimizerRuns;
160
-
161
- // Update config file
162
160
  fs.writeFileSync(configPath, JSON.stringify(configFile, null, 2));
163
161
 
164
162
  // Provide user feedback
165
163
  console.log('✓ Compiler options updated:');
166
164
  console.log(` Gas Optimizer: ${compConfig.optimizer ? 'Enabled' : 'Disabled'}`);
165
+ console.log(` ViaIR: ${compConfig.viaIR ? 'Enabled' : 'Disabled'}`);
167
166
  if (compConfig.optimizer) {
168
167
  console.log(` Optimizer Runs: ${compConfig.optimizerRuns}`);
169
168
  }
170
- console.log(` ViaIR: ${compConfig.viaIR ? 'Enabled' : 'Disabled'}`);
169
+
171
170
  } catch (error) {
172
171
  console.error('Error setting compiler options:', error.message);
173
172
  return null;
@@ -181,7 +180,7 @@ export function compilerOptions(gasOptimizer, viaIR, optimizerRuns = 200) {
181
180
  * const opts = getCompilerOptions();
182
181
  */
183
182
  export function getCompilerOptions() {
184
- return { ...compConfig };
183
+ return { ...configFile.compiler };
185
184
  }
186
185
 
187
186
  /**
@@ -6,17 +6,10 @@
6
6
  */
7
7
 
8
8
  import { ethers } from 'ethers';
9
- import { LocalStorage } from 'node-localstorage';
10
9
  import { configPath } from './build.js';
11
10
  import fs from 'fs';
12
11
  import { changeProvider } from '../utils/configFileUpdate.js';
13
12
 
14
- /**
15
- * Local storage instance for persisting compiler artifacts paths
16
- * @type {LocalStorage}
17
- */
18
- const localStorage = new LocalStorage('./localStorage');
19
-
20
13
  /**
21
14
  * Default JSON-RPC URL for local Ethereum node
22
15
  * @constant {string}
@@ -18,15 +18,14 @@ import {
18
18
  updateAccountMemory,
19
19
  setDefaultAccount
20
20
  } from '../utils/accounter.js';
21
- import { configFile, configPath } from './build.js';
21
+ import { configPath } from './build.js';
22
22
  import fs from 'fs';
23
23
 
24
24
  /**
25
25
  * Array containing all accounts (imported, generated, HD, and node-managed)
26
26
  * @type {Array<Object>}
27
27
  */
28
- export let allAccounts = [];
29
- allAccounts = getWalletJSON();
28
+ export let allAccounts = getWalletJSON();
30
29
 
31
30
  // Set the default account from stored wallets
32
31
  const defWallet = JSON.parse(fs.readFileSync(configPath)).defaultWallet;
@@ -15,7 +15,7 @@ import { serializeBigInts } from './serialize.js';
15
15
  * The path which in wallets json file will be saved.
16
16
  * @type {String}
17
17
  */
18
- const walletJSONPath = './localStorage/wallets.json';
18
+ const walletJSONPath = './ethershell/wallets.json';
19
19
 
20
20
  /**
21
21
  * Delete account(s) by index
@@ -115,7 +115,20 @@ export function updateWalletJSON(walletArr) {
115
115
  * @returns {Object}
116
116
  */
117
117
  export function getWalletJSON() {
118
- return JSON.parse(fs.readFileSync(walletJSONPath));
118
+ if(fs.existsSync(walletJSONPath)){
119
+ const walletJSON = fs.readFileSync(walletJSONPath, 'utf8');
120
+ // Return empry array if wallet is empty
121
+ if(walletJSON.length === 0) {
122
+ return [];
123
+ } else {
124
+ return JSON.parse(fs.readFileSync(walletJSONPath));
125
+ }
126
+ } else {
127
+ // Generate empty wallet.json if it doesn't exist
128
+ const fd = fs.openSync(walletJSONPath, 'w');
129
+ fs.closeSync(fd);
130
+ return [];
131
+ }
119
132
  }
120
133
 
121
134
  export function updateAccountMemory(allAccArr) {
@@ -280,4 +293,4 @@ function _deleteAll() {
280
293
  export function setDefaultAccount(account) {
281
294
  configFile.defaultWallet = serializeBigInts(account);
282
295
  fs.writeFileSync(configPath, JSON.stringify(configFile, null, 2));
283
- }
296
+ }
@@ -16,7 +16,7 @@ import { LocalStorage } from 'node-localstorage';
16
16
  * Local storage instance for persisting compiler artifacts paths
17
17
  * @type {LocalStorage}
18
18
  */
19
- const localStorage = new LocalStorage('./localStorage');
19
+ const localStorage = new LocalStorage('./ethershell');
20
20
 
21
21
  /**
22
22
  * Load a specific version of the Solidity compiler