fix(wallet): Throwing error when wallet file not passed in correctly

This commit is contained in:
Chris Troutner
2022-03-26 19:20:06 -07:00
parent e0d1aa24d4
commit c45b512fc6
+6 -3
View File
@@ -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) {