From 91fa460158370f8bf46029e5c0ab31a5390a477a Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Mon, 9 May 2022 09:26:17 -0700 Subject: [PATCH] fix(production scripts): Improvement to sweep-wallet.js --- production/scripts/sweep-wallet.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/production/scripts/sweep-wallet.js b/production/scripts/sweep-wallet.js index 251ba6d..ca29612 100644 --- a/production/scripts/sweep-wallet.js +++ b/production/scripts/sweep-wallet.js @@ -18,7 +18,8 @@ async function sweepFunds () { try { // Open the wallet files. const walletLib = new WalletAdapter() - const walletInfo = await walletLib.openWallet() + // const walletInfo = await walletLib.openWallet() + const walletInfo = await openWallet(walletLib) const wallet = await walletLib.instanceWallet(walletInfo) console.log('walletInfo: ', walletInfo) @@ -82,3 +83,18 @@ async function sweepFunds () { } } sweepFunds() + +// Open the wallet file, or create one if the file doesn't exist. +// Does not instance the wallet. The output of this function is expected to +// be passed to instanceWallet(). +async function openWallet (walletLib) { + try { + // console.log('this.WALLET_FILE: ', this.WALLET_FILE) + const walletData = await walletLib.jsonFiles.readJSON('./wallet.json') + + return walletData + } catch (err) { + console.error('Error in openWallet()') + throw err + } +}