ethershell 0.1.2-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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ethershell",
3
3
  "license": "MIT",
4
- "version": "0.1.2-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
  });