mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 12:15:51 +00:00
Merge branch 'main' into network-id
This commit is contained in:
@@ -13,6 +13,10 @@ Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xr
|
||||
* Fixed the location of `signer_lists` in the `account_info` response so that it matches rippled
|
||||
* Guard check for signing algorithm used in `Wallet.generate()`
|
||||
* Null and undefined values in transactions are now treated as though the field was not passed in.
|
||||
* Improved the type definition of the return value of `submitAndWait()`
|
||||
|
||||
### Changed
|
||||
* Added sidechain devnet support to faucet generation
|
||||
|
||||
### Removed
|
||||
* RPCs and utils related to the old sidechain design
|
||||
|
||||
@@ -16,6 +16,7 @@ export enum FaucetNetwork {
|
||||
Devnet = 'faucet.devnet.rippletest.net',
|
||||
AMMDevnet = 'ammfaucet.devnet.rippletest.net',
|
||||
HooksV3Testnet = 'hooks-testnet-v3.xrpl-labs.com',
|
||||
SidechainDevnet = 'sidechain-faucet.devnet.rippletest.net',
|
||||
}
|
||||
|
||||
export const FaucetNetworkPaths: Record<string, string> = {
|
||||
@@ -23,6 +24,7 @@ export const FaucetNetworkPaths: Record<string, string> = {
|
||||
[FaucetNetwork.Devnet]: '/accounts',
|
||||
[FaucetNetwork.AMMDevnet]: '/accounts',
|
||||
[FaucetNetwork.HooksV3Testnet]: '/accounts',
|
||||
[FaucetNetwork.SidechainDevnet]: '/accounts',
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,6 +50,16 @@ export function getFaucetHost(client: Client): FaucetNetwork | undefined {
|
||||
return FaucetNetwork.AMMDevnet
|
||||
}
|
||||
|
||||
if (connectionUrl.includes('sidechain-net1')) {
|
||||
return FaucetNetwork.SidechainDevnet
|
||||
}
|
||||
|
||||
if (connectionUrl.includes('sidechain-net2')) {
|
||||
throw new XRPLFaucetError(
|
||||
'Cannot fund an account on an issuing chain. Accounts must be created via the bridge.',
|
||||
)
|
||||
}
|
||||
|
||||
if (connectionUrl.includes('devnet')) {
|
||||
return FaucetNetwork.Devnet
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Transaction, TransactionMetadata } from '../transactions'
|
||||
import { BaseTransaction } from '../transactions/common'
|
||||
|
||||
import { BaseRequest, BaseResponse } from './baseMethod'
|
||||
|
||||
@@ -38,7 +39,8 @@ export interface TxRequest extends BaseRequest {
|
||||
*
|
||||
* @category Responses
|
||||
*/
|
||||
export interface TxResponse extends BaseResponse {
|
||||
export interface TxResponse<T extends BaseTransaction = Transaction>
|
||||
extends BaseResponse {
|
||||
result: {
|
||||
/** The SHA-512 hash of the transaction. */
|
||||
hash: string
|
||||
@@ -55,7 +57,7 @@ export interface TxResponse extends BaseResponse {
|
||||
* This number measures the number of seconds since the "Ripple Epoch" of January 1, 2000 (00:00 UTC)
|
||||
*/
|
||||
date?: number
|
||||
} & Transaction
|
||||
} & T
|
||||
/**
|
||||
* If true, the server was able to search all of the specified ledger
|
||||
* versions, and the transaction was in none of them. If false, the server did
|
||||
|
||||
@@ -3,8 +3,9 @@ import { decode, encode } from 'ripple-binary-codec'
|
||||
import type { Client, SubmitRequest, SubmitResponse, Wallet } from '..'
|
||||
import { ValidationError, XrplError } from '../errors'
|
||||
import { Signer } from '../models/common'
|
||||
import { TxResponse } from '../models/methods'
|
||||
import { TxRequest, TxResponse } from '../models/methods'
|
||||
import { Transaction } from '../models/transactions'
|
||||
import { BaseTransaction } from '../models/transactions/common'
|
||||
import { hashes } from '../utils'
|
||||
|
||||
/** Approximate time for a ledger to close, in milliseconds */
|
||||
@@ -104,9 +105,9 @@ async function submit(
|
||||
* ledger, the promise returned by `submitAndWait()` will be rejected with an error.
|
||||
* @returns A promise that contains TxResponse, that will return when the transaction has been validated.
|
||||
*/
|
||||
async function submitAndWait(
|
||||
async function submitAndWait<T extends Transaction = Transaction>(
|
||||
this: Client,
|
||||
transaction: Transaction | string,
|
||||
transaction: T | string,
|
||||
opts?: {
|
||||
// If true, autofill a transaction.
|
||||
autofill?: boolean
|
||||
@@ -115,7 +116,7 @@ async function submitAndWait(
|
||||
// A wallet to sign a transaction. It must be provided when submitting an unsigned transaction.
|
||||
wallet?: Wallet
|
||||
},
|
||||
): Promise<TxResponse> {
|
||||
): Promise<TxResponse<T>> {
|
||||
const signedTx = await getSignedTx(this, transaction, opts)
|
||||
|
||||
const lastLedger = getLastLedgerSequence(signedTx)
|
||||
@@ -167,12 +168,14 @@ async function submitRequest(
|
||||
* latest ledger sequence (meaning it will never be included in a validated ledger).
|
||||
*/
|
||||
// eslint-disable-next-line max-params, max-lines-per-function -- this function needs to display and do with more information.
|
||||
async function waitForFinalTransactionOutcome(
|
||||
async function waitForFinalTransactionOutcome<
|
||||
T extends BaseTransaction = Transaction,
|
||||
>(
|
||||
client: Client,
|
||||
txHash: string,
|
||||
lastLedger: number,
|
||||
submissionResult: string,
|
||||
): Promise<TxResponse> {
|
||||
): Promise<TxResponse<T>> {
|
||||
await sleep(LEDGER_CLOSE_TIME)
|
||||
|
||||
const latestLedger = await client.getLedgerIndex()
|
||||
@@ -185,7 +188,7 @@ async function waitForFinalTransactionOutcome(
|
||||
}
|
||||
|
||||
const txResponse = await client
|
||||
.request({
|
||||
.request<TxRequest, TxResponse<T>>({
|
||||
command: 'tx',
|
||||
transaction: txHash,
|
||||
})
|
||||
@@ -194,7 +197,7 @@ async function waitForFinalTransactionOutcome(
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions,@typescript-eslint/no-unsafe-member-access -- ^
|
||||
const message = error?.data?.error as string
|
||||
if (message === 'txnNotFound') {
|
||||
return waitForFinalTransactionOutcome(
|
||||
return waitForFinalTransactionOutcome<T>(
|
||||
client,
|
||||
txHash,
|
||||
lastLedger,
|
||||
@@ -212,7 +215,7 @@ async function waitForFinalTransactionOutcome(
|
||||
return txResponse
|
||||
}
|
||||
|
||||
return waitForFinalTransactionOutcome(
|
||||
return waitForFinalTransactionOutcome<T>(
|
||||
client,
|
||||
txHash,
|
||||
lastLedger,
|
||||
|
||||
@@ -122,6 +122,16 @@ describe('fundWallet', function () {
|
||||
TIMEOUT,
|
||||
)
|
||||
|
||||
it(
|
||||
'can generate and fund wallets on sidechain devnet',
|
||||
async function () {
|
||||
await generate_faucet_wallet_and_fund_again(
|
||||
'wss://sidechain-net1.devnet.rippletest.net:51233',
|
||||
)
|
||||
},
|
||||
TIMEOUT,
|
||||
)
|
||||
|
||||
it(
|
||||
'submit funds wallet with custom amount',
|
||||
async function () {
|
||||
|
||||
Reference in New Issue
Block a user