Merge branch 'main' into network-id

This commit is contained in:
pdp2121
2023-06-12 14:29:19 -04:00
committed by GitHub
5 changed files with 42 additions and 11 deletions

View File

@@ -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 * 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()` * 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. * 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 ### Removed
* RPCs and utils related to the old sidechain design * RPCs and utils related to the old sidechain design

View File

@@ -16,6 +16,7 @@ export enum FaucetNetwork {
Devnet = 'faucet.devnet.rippletest.net', Devnet = 'faucet.devnet.rippletest.net',
AMMDevnet = 'ammfaucet.devnet.rippletest.net', AMMDevnet = 'ammfaucet.devnet.rippletest.net',
HooksV3Testnet = 'hooks-testnet-v3.xrpl-labs.com', HooksV3Testnet = 'hooks-testnet-v3.xrpl-labs.com',
SidechainDevnet = 'sidechain-faucet.devnet.rippletest.net',
} }
export const FaucetNetworkPaths: Record<string, string> = { export const FaucetNetworkPaths: Record<string, string> = {
@@ -23,6 +24,7 @@ export const FaucetNetworkPaths: Record<string, string> = {
[FaucetNetwork.Devnet]: '/accounts', [FaucetNetwork.Devnet]: '/accounts',
[FaucetNetwork.AMMDevnet]: '/accounts', [FaucetNetwork.AMMDevnet]: '/accounts',
[FaucetNetwork.HooksV3Testnet]: '/accounts', [FaucetNetwork.HooksV3Testnet]: '/accounts',
[FaucetNetwork.SidechainDevnet]: '/accounts',
} }
/** /**
@@ -48,6 +50,16 @@ export function getFaucetHost(client: Client): FaucetNetwork | undefined {
return FaucetNetwork.AMMDevnet 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')) { if (connectionUrl.includes('devnet')) {
return FaucetNetwork.Devnet return FaucetNetwork.Devnet
} }

View File

@@ -1,4 +1,5 @@
import { Transaction, TransactionMetadata } from '../transactions' import { Transaction, TransactionMetadata } from '../transactions'
import { BaseTransaction } from '../transactions/common'
import { BaseRequest, BaseResponse } from './baseMethod' import { BaseRequest, BaseResponse } from './baseMethod'
@@ -38,7 +39,8 @@ export interface TxRequest extends BaseRequest {
* *
* @category Responses * @category Responses
*/ */
export interface TxResponse extends BaseResponse { export interface TxResponse<T extends BaseTransaction = Transaction>
extends BaseResponse {
result: { result: {
/** The SHA-512 hash of the transaction. */ /** The SHA-512 hash of the transaction. */
hash: string 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) * This number measures the number of seconds since the "Ripple Epoch" of January 1, 2000 (00:00 UTC)
*/ */
date?: number date?: number
} & Transaction } & T
/** /**
* If true, the server was able to search all of the specified ledger * 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 * versions, and the transaction was in none of them. If false, the server did

View File

@@ -3,8 +3,9 @@ import { decode, encode } from 'ripple-binary-codec'
import type { Client, SubmitRequest, SubmitResponse, Wallet } from '..' import type { Client, SubmitRequest, SubmitResponse, Wallet } from '..'
import { ValidationError, XrplError } from '../errors' import { ValidationError, XrplError } from '../errors'
import { Signer } from '../models/common' import { Signer } from '../models/common'
import { TxResponse } from '../models/methods' import { TxRequest, TxResponse } from '../models/methods'
import { Transaction } from '../models/transactions' import { Transaction } from '../models/transactions'
import { BaseTransaction } from '../models/transactions/common'
import { hashes } from '../utils' import { hashes } from '../utils'
/** Approximate time for a ledger to close, in milliseconds */ /** 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. * 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. * @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, this: Client,
transaction: Transaction | string, transaction: T | string,
opts?: { opts?: {
// If true, autofill a transaction. // If true, autofill a transaction.
autofill?: boolean autofill?: boolean
@@ -115,7 +116,7 @@ async function submitAndWait(
// A wallet to sign a transaction. It must be provided when submitting an unsigned transaction. // A wallet to sign a transaction. It must be provided when submitting an unsigned transaction.
wallet?: Wallet wallet?: Wallet
}, },
): Promise<TxResponse> { ): Promise<TxResponse<T>> {
const signedTx = await getSignedTx(this, transaction, opts) const signedTx = await getSignedTx(this, transaction, opts)
const lastLedger = getLastLedgerSequence(signedTx) const lastLedger = getLastLedgerSequence(signedTx)
@@ -167,12 +168,14 @@ async function submitRequest(
* latest ledger sequence (meaning it will never be included in a validated ledger). * 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. // 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, client: Client,
txHash: string, txHash: string,
lastLedger: number, lastLedger: number,
submissionResult: string, submissionResult: string,
): Promise<TxResponse> { ): Promise<TxResponse<T>> {
await sleep(LEDGER_CLOSE_TIME) await sleep(LEDGER_CLOSE_TIME)
const latestLedger = await client.getLedgerIndex() const latestLedger = await client.getLedgerIndex()
@@ -185,7 +188,7 @@ async function waitForFinalTransactionOutcome(
} }
const txResponse = await client const txResponse = await client
.request({ .request<TxRequest, TxResponse<T>>({
command: 'tx', command: 'tx',
transaction: txHash, transaction: txHash,
}) })
@@ -194,7 +197,7 @@ async function waitForFinalTransactionOutcome(
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions,@typescript-eslint/no-unsafe-member-access -- ^ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions,@typescript-eslint/no-unsafe-member-access -- ^
const message = error?.data?.error as string const message = error?.data?.error as string
if (message === 'txnNotFound') { if (message === 'txnNotFound') {
return waitForFinalTransactionOutcome( return waitForFinalTransactionOutcome<T>(
client, client,
txHash, txHash,
lastLedger, lastLedger,
@@ -212,7 +215,7 @@ async function waitForFinalTransactionOutcome(
return txResponse return txResponse
} }
return waitForFinalTransactionOutcome( return waitForFinalTransactionOutcome<T>(
client, client,
txHash, txHash,
lastLedger, lastLedger,

View File

@@ -122,6 +122,16 @@ describe('fundWallet', function () {
TIMEOUT, 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( it(
'submit funds wallet with custom amount', 'submit funds wallet with custom amount',
async function () { async function () {