mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-22 13:15:49 +00:00
docs: Add documentation for generateFaucetWallet() (#1529)
* docs: Add documentation for generateFaucetWallet()
This commit is contained in:
@@ -93,6 +93,7 @@
|
|||||||
- [isValidSecret](#isvalidsecret)
|
- [isValidSecret](#isvalidsecret)
|
||||||
- [deriveKeypair](#derivekeypair)
|
- [deriveKeypair](#derivekeypair)
|
||||||
- [deriveAddress](#deriveaddress)
|
- [deriveAddress](#deriveaddress)
|
||||||
|
- [generateFaucetWallet](#generatefaucetwallet)
|
||||||
- [signPaymentChannelClaim](#signpaymentchannelclaim)
|
- [signPaymentChannelClaim](#signpaymentchannelclaim)
|
||||||
- [verifyPaymentChannelClaim](#verifypaymentchannelclaim)
|
- [verifyPaymentChannelClaim](#verifypaymentchannelclaim)
|
||||||
- [computeLedgerHash](#computeledgerhash)
|
- [computeLedgerHash](#computeledgerhash)
|
||||||
@@ -6091,6 +6092,38 @@ This method returns a string corresponding to the address derived from the publi
|
|||||||
var address = api.deriveAddress(public_key);
|
var address = api.deriveAddress(public_key);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## generateFaucetWallet
|
||||||
|
|
||||||
|
`generateFaucetWallet(onTestnet = true)`
|
||||||
|
|
||||||
|
Calls the Testnet or Devnet faucet API in order to generate a new, random wallet with some amount of test XRP. This is for testing purposes only.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
**Request**
|
||||||
|
|
||||||
|
Create a new wallet on the Testnet:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const wallet = await api.generateFaucetWallet()
|
||||||
|
```
|
||||||
|
|
||||||
|
**Response**
|
||||||
|
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"account": {
|
||||||
|
"xAddress": "T7i2Q8yGcMcCQa2n6d9EvSEptT4CE6ap7Q1r1fmjstkLfsK",
|
||||||
|
"secret": "ssKCsaRqWh669atvv83bdYRaiHomY",
|
||||||
|
"classicAddress": "r9SYfmVxrb7iuCVfNhW2gqqzapfE2r6juG",
|
||||||
|
"address": "r9SYfmVxrb7iuCVfNhW2gqqzapfE2r6juG"
|
||||||
|
},
|
||||||
|
"amount": 1000,
|
||||||
|
"balance": 1000
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## signPaymentChannelClaim
|
## signPaymentChannelClaim
|
||||||
|
|
||||||
`signPaymentChannelClaim(channel: string, amount: string, privateKey: string): string`
|
`signPaymentChannelClaim(channel: string, amount: string, privateKey: string): string`
|
||||||
@@ -6426,6 +6459,7 @@ The flags are called [AccountSet flags (asf*)](https://xrpl.org/accountset.html#
|
|||||||
`RippleAPI.accountSetFlags.globalFreeze`: Freeze all assets issued by this account.
|
`RippleAPI.accountSetFlags.globalFreeze`: Freeze all assets issued by this account.
|
||||||
`RippleAPI.accountSetFlags.defaultRipple`: Enable [rippling](https://xrpl.org/rippling.html) on this account's trust lines by default.
|
`RippleAPI.accountSetFlags.defaultRipple`: Enable [rippling](https://xrpl.org/rippling.html) on this account's trust lines by default.
|
||||||
`RippleAPI.accountSetFlags.depositAuth`:Enable Deposit Authorization on this account.
|
`RippleAPI.accountSetFlags.depositAuth`:Enable Deposit Authorization on this account.
|
||||||
|
|
||||||
## schemaValidator
|
## schemaValidator
|
||||||
|
|
||||||
Unlike the rest of the ripple-lib API, schemaValidator is a static object on RippleAPI. It provides utility methods that do not use a server.
|
Unlike the rest of the ripple-lib API, schemaValidator is a static object on RippleAPI. It provides utility methods that do not use a server.
|
||||||
|
|||||||
19
docs/src/generateFaucetWallet.md.ejs
Normal file
19
docs/src/generateFaucetWallet.md.ejs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
## generateFaucetWallet
|
||||||
|
|
||||||
|
`generateFaucetWallet(onTestnet = true)`
|
||||||
|
|
||||||
|
Calls the Testnet or Devnet faucet API in order to generate a new, random wallet with some amount of test XRP. This is for testing purposes only.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
**Request**
|
||||||
|
|
||||||
|
Create a new wallet on the Testnet:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const wallet = await api.generateFaucetWallet()
|
||||||
|
```
|
||||||
|
|
||||||
|
**Response**
|
||||||
|
|
||||||
|
<%- renderFixture('responses/generate-faucet-wallet.json') %>
|
||||||
@@ -59,6 +59,7 @@
|
|||||||
<%- include('isValidSecret.md.ejs') %>
|
<%- include('isValidSecret.md.ejs') %>
|
||||||
<%- include('deriveKeypair.md.ejs') %>
|
<%- include('deriveKeypair.md.ejs') %>
|
||||||
<%- include('deriveAddress.md.ejs') %>
|
<%- include('deriveAddress.md.ejs') %>
|
||||||
|
<%- include('generateFaucetWallet.md.ejs') %>
|
||||||
<%- include('signPaymentChannelClaim.md.ejs') %>
|
<%- include('signPaymentChannelClaim.md.ejs') %>
|
||||||
<%- include('verifyPaymentChannelClaim.md.ejs') %>
|
<%- include('verifyPaymentChannelClaim.md.ejs') %>
|
||||||
<%- include('computeLedgerHash.md.ejs') %>
|
<%- include('computeLedgerHash.md.ejs') %>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {RippleAPI} from '..'
|
|||||||
import {errors} from '../common'
|
import {errors} from '../common'
|
||||||
import {GeneratedAddress} from '../offline/generate-address'
|
import {GeneratedAddress} from '../offline/generate-address'
|
||||||
import {isValidAddress} from '../common/schema-validator'
|
import {isValidAddress} from '../common/schema-validator'
|
||||||
|
import {RippledError} from '../common/errors'
|
||||||
|
|
||||||
export interface FaucetWallet {
|
export interface FaucetWallet {
|
||||||
account: GeneratedAddress
|
account: GeneratedAddress
|
||||||
@@ -29,6 +30,9 @@ async function generateFaucetWallet(
|
|||||||
this: RippleAPI,
|
this: RippleAPI,
|
||||||
address?: string
|
address?: string
|
||||||
): Promise<FaucetWallet | void> {
|
): Promise<FaucetWallet | void> {
|
||||||
|
if(!this.isConnected())
|
||||||
|
throw new RippledError("RippleAPI not connected, cannot call faucet")
|
||||||
|
|
||||||
// Initialize some variables
|
// Initialize some variables
|
||||||
let body: Uint8Array
|
let body: Uint8Array
|
||||||
let startingBalance = 0
|
let startingBalance = 0
|
||||||
|
|||||||
10
test/fixtures/responses/generate-faucet-wallet.json
vendored
Normal file
10
test/fixtures/responses/generate-faucet-wallet.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"account": {
|
||||||
|
"xAddress": "T7i2Q8yGcMcCQa2n6d9EvSEptT4CE6ap7Q1r1fmjstkLfsK",
|
||||||
|
"secret": "ssKCsaRqWh669atvv83bdYRaiHomY",
|
||||||
|
"classicAddress": "r9SYfmVxrb7iuCVfNhW2gqqzapfE2r6juG",
|
||||||
|
"address": "r9SYfmVxrb7iuCVfNhW2gqqzapfE2r6juG"
|
||||||
|
},
|
||||||
|
"amount": 1000,
|
||||||
|
"balance": 1000
|
||||||
|
}
|
||||||
3
test/fixtures/responses/index.js
vendored
3
test/fixtures/responses/index.js
vendored
@@ -218,5 +218,6 @@ module.exports = {
|
|||||||
single: require('./combine')
|
single: require('./combine')
|
||||||
},
|
},
|
||||||
submit: require('./submit'),
|
submit: require('./submit'),
|
||||||
ledgerEvent: require('./ledger-event')
|
ledgerEvent: require('./ledger-event'),
|
||||||
|
generateFaucetWallet: require('./generate-faucet-wallet.json')
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user