refactor: clean up getFaucetWallet starting balance (#1677)

This commit is contained in:
Nathan Nichols
2021-09-28 16:42:05 -07:00
committed by Mayukha Vadari
parent 5b9e3dbdc4
commit 02fd0ce323

View File

@@ -53,23 +53,16 @@ async function generateFaucetWallet(
destination: fundWallet.classicAddress,
}),
)
// Retrieve the existing account balance
let addressToFundBalance: undefined | string
let startingBalance = 0
try {
addressToFundBalance = await getAddressXrpBalance(
this,
fundWallet.classicAddress,
startingBalance = Number(
await getAddressXrpBalance(this, fundWallet.classicAddress),
)
} catch {
/* addressToFundBalance remains undefined */
/* startingBalance remains '0' */
}
// Check the address balance is not undefined and is a number
const startingBalance =
addressToFundBalance && !Number.isNaN(Number(addressToFundBalance))
? Number(addressToFundBalance)
: 0
// Options to pass to https.request
const options = getOptions(this, postBody)