mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-21 12:45:50 +00:00
add amount field to faucet (#2129)
* add optional amount field to `fundWallet`
This commit is contained in:
@@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xrpl-announce) for release announcements. We recommend that xrpl.js (ripple-lib) users stay up-to-date with the latest stable release.
|
Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xrpl-announce) for release announcements. We recommend that xrpl.js (ripple-lib) users stay up-to-date with the latest stable release.
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
### Added
|
||||||
|
* Optional custom amount field to `fundWallet`.
|
||||||
## 2.5.0 (2022-10-13)
|
## 2.5.0 (2022-10-13)
|
||||||
### Added
|
### Added
|
||||||
* Support for ExpandedSignerList amendment that expands the maximum signer list to 32 entries.
|
* Support for ExpandedSignerList amendment that expands the maximum signer list to 32 entries.
|
||||||
* Add `cookie` and `data` to `ValidationStream` interface
|
* Add `cookie` and `data` to `ValidationStream` interface
|
||||||
* Addtional check for memos field format, provide more detailed error messages.
|
* Additional check for memos field format, provide more detailed error messages.
|
||||||
|
|
||||||
## 2.4.0 (2022-09-01)
|
## 2.4.0 (2022-09-01)
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -47,15 +47,18 @@ const MAX_ATTEMPTS = 20
|
|||||||
* automatically. In other environments, or if you would like to customize the
|
* automatically. In other environments, or if you would like to customize the
|
||||||
* faucet host in devnet or testnet, you should provide the host using this
|
* faucet host in devnet or testnet, you should provide the host using this
|
||||||
* option.
|
* option.
|
||||||
|
* @param options.amount - A custom amount to fund, if undefined or null, the default amount will be 1000.
|
||||||
* @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,
|
||||||
* and that wallet's balance in XRP.
|
* and that wallet's balance in 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.
|
||||||
*/
|
*/
|
||||||
|
// eslint-disable-next-line max-lines-per-function -- this function needs to display and do with more information.
|
||||||
async function fundWallet(
|
async function fundWallet(
|
||||||
this: Client,
|
this: Client,
|
||||||
wallet?: Wallet | null,
|
wallet?: Wallet | null,
|
||||||
options?: {
|
options?: {
|
||||||
faucetHost?: string
|
faucetHost?: string
|
||||||
|
amount?: string
|
||||||
},
|
},
|
||||||
): Promise<{
|
): Promise<{
|
||||||
wallet: Wallet
|
wallet: Wallet
|
||||||
@@ -76,6 +79,7 @@ async function fundWallet(
|
|||||||
new TextEncoder().encode(
|
new TextEncoder().encode(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
destination: walletToFund.classicAddress,
|
destination: walletToFund.classicAddress,
|
||||||
|
xrpAmount: options?.amount,
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -129,4 +129,21 @@ describe('fundWallet', function () {
|
|||||||
|
|
||||||
await api.disconnect()
|
await api.disconnect()
|
||||||
})
|
})
|
||||||
|
it('submit funds wallet with custom amount', async function () {
|
||||||
|
const api = new Client('wss://s.altnet.rippletest.net:51233')
|
||||||
|
|
||||||
|
await api.connect()
|
||||||
|
const { wallet, balance } = await api.fundWallet(null, { amount: '2000' })
|
||||||
|
assert.equal(balance, '2000')
|
||||||
|
assert.notEqual(wallet, undefined)
|
||||||
|
assert(isValidClassicAddress(wallet.classicAddress))
|
||||||
|
assert(isValidXAddress(wallet.getXAddress()))
|
||||||
|
|
||||||
|
const info = await api.request({
|
||||||
|
command: 'account_info',
|
||||||
|
account: wallet.classicAddress,
|
||||||
|
})
|
||||||
|
assert.equal(dropsToXrp(info.result.account_data.Balance), balance)
|
||||||
|
await api.disconnect()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user