From c45b512fc6e0757ef76ab490226b248acdee65c6 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Sat, 26 Mar 2022 19:20:06 -0700 Subject: [PATCH] fix(wallet): Throwing error when wallet file not passed in correctly --- src/adapters/wallet.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/adapters/wallet.js b/src/adapters/wallet.js index 411e6ab..eed29ac 100644 --- a/src/adapters/wallet.js +++ b/src/adapters/wallet.js @@ -34,7 +34,7 @@ class WalletAdapter { // Try to open the wallet.json file. try { - console.log('this.WALLET_FILE: ', this.WALLET_FILE) + // console.log('this.WALLET_FILE: ', this.WALLET_FILE) walletData = await this.jsonFiles.readJSON(this.WALLET_FILE) } catch (err) { // Create a new wallet file if one does not already exist. @@ -69,9 +69,12 @@ class WalletAdapter { // and pass the bch-js information to the minimal-slp-wallet library. async instanceWallet (walletData) { try { - console.log(`instanceWallet() walletData: ${JSON.stringify(walletData, null, 2)}`) + // console.log(`instanceWallet() walletData: ${JSON.stringify(walletData, null, 2)}`) // TODO: throw error if wallet data is not passed in. + if (!walletData.mnemonic) { + throw new Error('Wallet data is not formatted correctly. Can not read mnemonic in wallet file!') + } const advancedConfig = {} if (this.config.useFullStackCash) { @@ -89,7 +92,7 @@ class WalletAdapter { // Wait for wallet to initialize. await this.bchWallet.walletInfoPromise console.log(`BCH wallet initialized. Wallet address: ${this.bchWallet.walletInfo.cashAddress}`) - console.log(`this.bchWallet.walletInfo: ${JSON.stringify(this.bchWallet.walletInfo, null, 2)}`) + // console.log(`this.bchWallet.walletInfo: ${JSON.stringify(this.bchWallet.walletInfo, null, 2)}`) return this.bchWallet } catch (err) {