mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 20:25:48 +00:00
fix: make generateFaucetWallet functional (#1669)
This commit is contained in:
@@ -28,16 +28,16 @@ const MAX_ATTEMPTS = 20
|
|||||||
/**
|
/**
|
||||||
* Generates a random wallet with some amount of XRP (usually 1000 XRP).
|
* Generates a random wallet with some amount of XRP (usually 1000 XRP).
|
||||||
*
|
*
|
||||||
* @param client - Client.
|
* @param this - Client.
|
||||||
* @param wallet - An existing XRPL Wallet to fund, if undefined, a new Wallet will be created.
|
* @param wallet - An existing XRPL Wallet to fund, if undefined, a new Wallet will be created.
|
||||||
* @returns A Wallet on the Testnet or Devnet that contains some amount of XRP.
|
* @returns A Wallet on the Testnet or Devnet that contains some amount of XRP.
|
||||||
* @throws When either Client isn't connected or unable to fund wallet address.
|
* @throws When either Client isn't connected or unable to fund wallet address.
|
||||||
*/
|
*/
|
||||||
async function generateFaucetWallet(
|
async function generateFaucetWallet(
|
||||||
client: Client,
|
this: Client,
|
||||||
wallet?: Wallet,
|
wallet?: Wallet,
|
||||||
): Promise<Wallet | undefined> {
|
): Promise<Wallet | undefined> {
|
||||||
if (!client.isConnected()) {
|
if (!this.isConnected()) {
|
||||||
throw new RippledError('Client not connected, cannot call faucet')
|
throw new RippledError('Client not connected, cannot call faucet')
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ async function generateFaucetWallet(
|
|||||||
)
|
)
|
||||||
// Retrieve the existing account balance
|
// Retrieve the existing account balance
|
||||||
const addressToFundBalance = await getAddressXrpBalance(
|
const addressToFundBalance = await getAddressXrpBalance(
|
||||||
client,
|
this,
|
||||||
fundWallet.classicAddress,
|
fundWallet.classicAddress,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -66,9 +66,9 @@ async function generateFaucetWallet(
|
|||||||
: 0
|
: 0
|
||||||
|
|
||||||
// Options to pass to https.request
|
// Options to pass to https.request
|
||||||
const options = getOptions(client, postBody)
|
const options = getOptions(this, postBody)
|
||||||
|
|
||||||
return returnPromise(options, client, startingBalance, fundWallet, postBody)
|
return returnPromise(options, this, startingBalance, fundWallet, postBody)
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line max-params -- Helper function created for organizational purposes
|
// eslint-disable-next-line max-params -- Helper function created for organizational purposes
|
||||||
@@ -222,7 +222,7 @@ async function getAddressXrpBalance(
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof Error) {
|
if (err instanceof Error) {
|
||||||
throw new XRPLFaucetError(
|
throw new XRPLFaucetError(
|
||||||
`Unable to retrieve ${address} balance. Error: ${err.message}`,
|
`Unable to retrieve balance of ${address}. Error: ${err.message}`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
throw err
|
throw err
|
||||||
|
|||||||
Reference in New Issue
Block a user