Skip to content

Commit

Permalink
Merge branch 'main' into autofill-temp
Browse files Browse the repository at this point in the history
  • Loading branch information
ckeshava authored Jun 27, 2024
2 parents bc803a8 + a067885 commit 07804f2
Show file tree
Hide file tree
Showing 8 changed files with 223 additions and 242 deletions.
370 changes: 218 additions & 152 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/xrpl/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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
* Remove references to the Hooks testnet faucet in the xrpl.js code repository.

### Added
* Add `nfts_by_issuer` clio-only API definition
Expand Down
2 changes: 1 addition & 1 deletion packages/xrpl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"lodash": "^4.17.4",
"react": "^18.2.0",
"run-s": "^0.0.0",
"typedoc": "0.25.0",
"typedoc": "0.26.2",
"ws": "^8.14.2"
},
"resolutions": {
Expand Down
6 changes: 0 additions & 6 deletions packages/xrpl/src/Wallet/defaultFaucets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ export interface FaucetWallet {
export enum FaucetNetwork {
Testnet = 'faucet.altnet.rippletest.net',
Devnet = 'faucet.devnet.rippletest.net',
HooksV3Testnet = 'hooks-testnet-v3.xrpl-labs.com',
}

export const FaucetNetworkPaths: Record<string, string> = {
[FaucetNetwork.Testnet]: '/accounts',
[FaucetNetwork.Devnet]: '/accounts',
[FaucetNetwork.HooksV3Testnet]: '/accounts',
}

/**
Expand All @@ -33,10 +31,6 @@ export const FaucetNetworkPaths: Record<string, string> = {
export function getFaucetHost(client: Client): FaucetNetwork | undefined {
const connectionUrl = client.url

if (connectionUrl.includes('hooks-testnet-v3')) {
return FaucetNetwork.HooksV3Testnet
}

// 'altnet' for Ripple Testnet server and 'testnet' for XRPL Labs Testnet server
if (connectionUrl.includes('altnet') || connectionUrl.includes('testnet')) {
return FaucetNetwork.Testnet
Expand Down
12 changes: 3 additions & 9 deletions packages/xrpl/src/sugar/autofill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const LEDGER_OFFSET = 20
// Mainnet and testnet are exceptions. More context: https://github.com/XRPLF/rippled/pull/4370
const RESTRICTED_NETWORKS = 1024
const REQUIRED_NETWORKID_VERSION = '1.11.0'
const HOOKS_TESTNET_ID = 21338

/**
* Determines whether the source rippled version is not later than the target rippled version.
Expand Down Expand Up @@ -87,8 +86,7 @@ function isNotLaterRippledVersion(source: string, target: string): boolean {

/**
* Determine if the transaction required a networkID to be valid.
* Transaction needs networkID if later than restricted ID and either the network is hooks testnet
* or build version is >= 1.11.0
* Transaction needs networkID if later than restricted ID and build version is >= 1.11.0
*
* @param client -- The connected client.
* @returns True if required networkID, false otherwise.
Expand All @@ -99,12 +97,8 @@ export function txNeedsNetworkID(client: Client): boolean {
client.networkID > RESTRICTED_NETWORKS
) {
if (
(client.buildVersion &&
isNotLaterRippledVersion(
REQUIRED_NETWORKID_VERSION,
client.buildVersion,
)) ||
client.networkID === HOOKS_TESTNET_ID
client.buildVersion &&
isNotLaterRippledVersion(REQUIRED_NETWORKID_VERSION, client.buildVersion)
) {
return true
}
Expand Down
21 changes: 0 additions & 21 deletions packages/xrpl/test/client/autofill.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const NetworkID = 1025
const Fee = '10'
const Sequence = 1432
const LastLedgerSequence = 2908734
const HOOKS_TESTNET_ID = 21338

describe('client.autofill', function () {
let testContext: XrplTestContext
Expand Down Expand Up @@ -202,26 +201,6 @@ describe('client.autofill', function () {
assert.strictEqual(txResult.NetworkID, undefined)
})

// Hooks Testnet requires networkID in transaction regardless of version.
// More context: https://github.com/XRPLF/rippled/pull/4370
it('overrides network ID for hooks testnet', async function () {
await setupMockRippledVersionAndID('1.10.1', HOOKS_TESTNET_ID)
const tx: Payment = {
TransactionType: 'Payment',
Account: 'XVLhHMPHU98es4dbozjVtdWzVrDjtV18pX8yuPT7y4xaEHi',
Amount: '1234',
Destination: 'X7AcgcsBL6XDcUb289X4mJ8djcdyKaB5hJDWMArnXr61cqZ',
Fee,
Sequence,
LastLedgerSequence,
}
testContext.mockRippled!.addResponse('ledger', rippled.ledger.normal)

const txResult = await testContext.client.autofill(tx)

assert.strictEqual(txResult.NetworkID, HOOKS_TESTNET_ID)
})

it('converts Account & Destination X-address to their classic address', async function () {
const tx: Payment = {
TransactionType: 'Payment',
Expand Down
34 changes: 0 additions & 34 deletions packages/xrpl/test/integration/fundWallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,40 +83,6 @@ describe('fundWallet', function () {
// )
// })

it(
'can generate wallet on hooks v3 testnet',
async function () {
const api = new Client('wss://hooks-testnet-v3.xrpl-labs.com')

await api.connect()

const { wallet, balance } = await api.fundWallet(null, {
usageContext: 'integration-test',
})

assert.notStrictEqual(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)
assert.equal(balance, 1000)

/*
* No test for fund given wallet because the hooks v3 testnet faucet
* requires 10 seconds between requests. Would significantly slow down
* the test suite.
*/

await api.disconnect()
},
TIMEOUT,
)

it(
'submit funds wallet with custom amount',
async function () {
Expand Down
19 changes: 0 additions & 19 deletions packages/xrpl/test/wallet/fundWallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ describe('Get Faucet host ', function () {
assert.strictEqual(getFaucetHost(testContext.client), expectedFaucet)
})

it('returns the Hooks V3 Testnet host', function () {
const expectedFaucet = FaucetNetwork.HooksV3Testnet
// @ts-expect-error Intentionally modifying private data for test
testContext.client.connection.url = FaucetNetwork.HooksV3Testnet

assert.strictEqual(getFaucetHost(testContext.client), expectedFaucet)
})

it('returns the correct faucetPath for Devnet host', function () {
const expectedFaucetPath = FaucetNetworkPaths[FaucetNetwork.Devnet]
// @ts-expect-error Intentionally modifying private data for test
Expand All @@ -63,17 +55,6 @@ describe('Get Faucet host ', function () {
)
})

it('returns the correct faucetPath for Hooks V3 Testnet host', function () {
const expectedFaucetPath = FaucetNetworkPaths[FaucetNetwork.HooksV3Testnet]
// @ts-expect-error Intentionally modifying private data for test
testContext.client.connection.url = FaucetNetwork.HooksV3Testnet

assert.strictEqual(
getDefaultFaucetPath(getFaucetHost(testContext.client)),
expectedFaucetPath,
)
})

it('returns the correct faucetPath for undefined host', function () {
const expectedFaucetPath = '/accounts'

Expand Down

0 comments on commit 07804f2

Please sign in to comment.