mirror of
https://github.com/Xahau/xahau.js.git
synced 2026-04-29 15:37:50 +00:00
fix: remove undefined from generateFaucetWallet return type (#1676)
* fix: remove undefined from generateFaucetWallet return type
This commit is contained in:
committed by
Mayukha Vadari
parent
c3e68cc83f
commit
8df224232c
@@ -36,7 +36,7 @@ const MAX_ATTEMPTS = 20
|
||||
async function generateFaucetWallet(
|
||||
this: Client,
|
||||
wallet?: Wallet,
|
||||
): Promise<Wallet | undefined> {
|
||||
): Promise<Wallet> {
|
||||
if (!this.isConnected()) {
|
||||
throw new RippledError('Client not connected, cannot call faucet')
|
||||
}
|
||||
@@ -76,7 +76,7 @@ async function returnPromise(
|
||||
startingBalance: number,
|
||||
fundWallet: Wallet,
|
||||
postBody: Uint8Array,
|
||||
): Promise<Wallet | undefined> {
|
||||
): Promise<Wallet> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = httpsRequest(options, (response) => {
|
||||
const chunks: Uint8Array[] = []
|
||||
@@ -125,7 +125,7 @@ async function onEnd(
|
||||
client: Client,
|
||||
startingBalance: number,
|
||||
fundWallet: Wallet,
|
||||
resolve: (wallet?: Wallet) => void,
|
||||
resolve: (wallet: Wallet) => void,
|
||||
reject: (err: ErrorConstructor | Error | unknown) => void,
|
||||
): Promise<void> {
|
||||
const body = Buffer.concat(chunks).toString()
|
||||
@@ -159,7 +159,7 @@ async function processSuccessfulResponse(
|
||||
body: string,
|
||||
startingBalance: number,
|
||||
fundWallet: Wallet,
|
||||
resolve: (wallet?: Wallet) => void,
|
||||
resolve: (wallet: Wallet) => void,
|
||||
reject: (err: ErrorConstructor | Error | unknown) => void,
|
||||
): Promise<void> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- We know this is safe and correct
|
||||
|
||||
@@ -16,12 +16,12 @@ describe('generateFaucetWallet', function () {
|
||||
const wallet = await api.generateFaucetWallet()
|
||||
|
||||
assert.notEqual(wallet, undefined)
|
||||
assert(isValidClassicAddress(wallet?.classicAddress ?? ''))
|
||||
assert(isValidXAddress(wallet?.getXAddress() ?? ''))
|
||||
assert(isValidClassicAddress(wallet.classicAddress))
|
||||
assert(isValidXAddress(wallet.getXAddress()))
|
||||
|
||||
const info = await api.request({
|
||||
command: 'account_info',
|
||||
account: wallet?.classicAddress ?? '',
|
||||
account: wallet.classicAddress,
|
||||
})
|
||||
assert.equal(info.result.account_data.Balance, '1000000000')
|
||||
|
||||
@@ -29,8 +29,9 @@ describe('generateFaucetWallet', function () {
|
||||
|
||||
const afterSent = await api.request({
|
||||
command: 'account_info',
|
||||
account: wallet?.classicAddress ?? '',
|
||||
account: wallet.classicAddress,
|
||||
})
|
||||
|
||||
assert.equal(afterSent.result.account_data.Balance, '2000000000')
|
||||
|
||||
await api.disconnect()
|
||||
@@ -42,12 +43,12 @@ describe('generateFaucetWallet', function () {
|
||||
const wallet = await api.generateFaucetWallet()
|
||||
|
||||
assert.notEqual(wallet, undefined)
|
||||
assert(isValidClassicAddress(wallet?.classicAddress ?? ''))
|
||||
assert(isValidXAddress(wallet?.getXAddress() ?? ''))
|
||||
assert(isValidClassicAddress(wallet.classicAddress))
|
||||
assert(isValidXAddress(wallet.getXAddress()))
|
||||
|
||||
const info = await api.request({
|
||||
command: 'account_info',
|
||||
account: wallet?.classicAddress ?? '',
|
||||
account: wallet.classicAddress,
|
||||
})
|
||||
assert.equal(info.result.account_data.Balance, '1000000000')
|
||||
|
||||
@@ -55,7 +56,7 @@ describe('generateFaucetWallet', function () {
|
||||
|
||||
const afterSent = await api.request({
|
||||
command: 'account_info',
|
||||
account: wallet?.classicAddress ?? '',
|
||||
account: wallet.classicAddress,
|
||||
})
|
||||
assert.equal(afterSent.result.account_data.Balance, '2000000000')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user