ethershell 0.1.1-beta.0 → 0.1.3-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/README.md CHANGED
@@ -35,7 +35,7 @@ An interactive Node.js console for Ethereum smart contract development. Write, c
35
35
  # Install globally:
36
36
  npm i -g ethershell
37
37
 
38
- # Start EtherShell:
38
+ # Start EtherShell in the root directory of your project:
39
39
  ethershell
40
40
 
41
41
  #or
@@ -46,7 +46,7 @@ npx ethershell
46
46
  ### Basic Usage
47
47
 
48
48
  ```bash
49
- # Start the console
49
+ # Start the console in the root directory of your project:
50
50
  ethershell
51
51
 
52
52
  # You should see:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ethershell",
3
3
  "license": "MIT",
4
- "version": "0.1.1-beta.0",
4
+ "version": "0.1.3-beta.0",
5
5
  "description": "Interactive JavaScript console for Ethereum smart contract management",
6
6
  "author": "Alireza Kiakojouri (alirezaethdev@gmail.com)",
7
7
  "repository": {
@@ -267,7 +267,7 @@ export function getHDAccounts() {
267
267
  * deleteAccount(); // Delete all accounts
268
268
  */
269
269
  export function deleteAccount(accPointer) {
270
- if(!accPointer) {
270
+ if(!accPointer && accPointer !== 0) {
271
271
  deleteByIndex(null);
272
272
  console.log(allAccounts);
273
273
  }
@@ -288,6 +288,7 @@ export function deleteAccount(accPointer) {
288
288
 
289
289
  if(Array.isArray(accPointer)) {
290
290
  deleteByIndexArr(accPointer);
291
+ console.log(allAccounts);
291
292
  }
292
293
 
293
294
  if(ethers.Mnemonic.isValidMnemonic(accPointer)) {
@@ -402,6 +403,10 @@ export function changeDefaultAccount(accPointer) {
402
403
  }
403
404
 
404
405
  if(ethers.isHexString(accPointer, 32)) {
406
+ const dupWallet = detectDupWallet(accPointer);
407
+ if(dupWallet.status) {
408
+ throw `Wallets may NOT be duplicated! You are adding wallet index ${dupWallet.index} again!`
409
+ }
405
410
  const newAccount = new ethers.Wallet(accPointer, provider);
406
411
  const newAccObj = {
407
412
  index: allAccounts.length,
@@ -227,6 +227,11 @@ function _deleteBySingIndex(_index) {
227
227
  _index++;
228
228
  }
229
229
  }
230
+
231
+ // Remove from config file if it is default wallet
232
+ if(accountIndex == configFile.defaultWallet.index) {
233
+ deleteDefaultAccount();
234
+ }
230
235
  }
231
236
  }
232
237
 
@@ -282,6 +287,7 @@ function _deleteAll() {
282
287
  allAccounts.splice(0);
283
288
  accounts.splice(0);
284
289
  hdAccounts.splice(0);
290
+ deleteDefaultAccount();
285
291
  fs.writeFileSync(walletJSONPath, JSON.stringify([], null, 2));
286
292
  return;
287
293
  }
@@ -294,3 +300,11 @@ export function setDefaultAccount(account) {
294
300
  configFile.defaultWallet = serializeBigInts(account);
295
301
  fs.writeFileSync(configPath, JSON.stringify(configFile, null, 2));
296
302
  }
303
+
304
+ /**
305
+ * Deletes default account from config file
306
+ */
307
+ export function deleteDefaultAccount() {
308
+ configFile.defaultWallet = {};
309
+ fs.writeFileSync(configPath, JSON.stringify(configFile, null, 2));
310
+ }
@@ -155,7 +155,17 @@ export function createContractProxy(contract, provider, allAccounts) {
155
155
  }
156
156
 
157
157
  // Call the method with remaining args and tx options
158
- return method.apply(method, args);
158
+ const result = await method.apply(method, args);
159
+
160
+ // Check if result is a transaction response (has wait method)
161
+ if (result && typeof result.wait === 'function') {
162
+ // This is a transaction - wait for mining
163
+ const receipt = await result.wait();
164
+ return receipt;
165
+ }
166
+
167
+ // This is a view/pure function result - return as-is
168
+ return result;
159
169
  };
160
170
  }
161
171
  });
package/src/utils/dir.js CHANGED
@@ -57,6 +57,16 @@ export function collectSolFiles(dirPath) {
57
57
  */
58
58
  export function findImports(importPath, basePath) {
59
59
  try {
60
+ // Handle node_modules imports (e.g., @openzeppelin/contracts/...)
61
+ if (importPath.startsWith('@')) {
62
+ const nodeModulesPath = path.resolve(process.cwd(), 'node_modules', importPath);
63
+
64
+ if (fs.existsSync(nodeModulesPath)) {
65
+ const content = fs.readFileSync(nodeModulesPath, 'utf8');
66
+ return { contents: content };
67
+ }
68
+ }
69
+
60
70
  // Resolve relative to the current file's directory
61
71
  const resolvedPath = path.resolve(basePath, importPath);
62
72