build: makes connection private

This commit is contained in:
Nathan Nichols
2021-09-26 11:06:20 -07:00
parent c260512bf3
commit 028655d682
7 changed files with 17 additions and 9 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "xrpl",
"version": "2.0.0-beta.0",
"version": "2.0.0-beta.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "xrpl",
"version": "2.0.0-beta.0",
"version": "2.0.0-beta.1",
"license": "ISC",
"dependencies": {
"@types/lodash": "^4.14.136",

View File

@@ -164,7 +164,7 @@ const MAX_LIMIT = 400
class Client extends EventEmitter {
// New in > 0.21.0
// non-validated ledger versions are allowed, and passed to rippled as-is.
public readonly connection: Connection
private readonly connection: Connection
// Factor to multiply estimated fee by to provide a cushion in case the
// required fee rises during submission of a transaction. Defaults to 1.2.
@@ -241,6 +241,15 @@ class Client extends EventEmitter {
})
}
/**
* Get the URL of the server the Client is connected to.
*
* @returns The URL of the rippled server this Client is connected to.
*/
public get url(): string {
return this.connection.getUrl()
}
/**
* Returns true if there are more pages of data.
*

View File

@@ -281,7 +281,7 @@ async function hasAddressBalanceIncreased(
* @returns A {@link FaucetNetwork}.
*/
function getFaucetUrl(client: Client): FaucetNetwork | undefined {
const connectionUrl = client.connection.getUrl()
const connectionUrl = client.url
// 'altnet' for Ripple Testnet server and 'testnet' for XRPL Labs Testnet server
if (connectionUrl.includes('altnet') || connectionUrl.includes('testnet')) {

View File

@@ -25,8 +25,7 @@ describe('Client', function () {
it('Client valid options', function () {
const client = new Client('wss://s:1')
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: fix when src/client linting is merged
const privateConnectionUrl = (client.connection as any).url
const privateConnectionUrl = client.url
assert.deepEqual(privateConnectionUrl, 'wss://s:1')
})

View File

@@ -15,7 +15,7 @@ describe('client constructor', function () {
it('Client valid options', function () {
const client = new Client('wss://s:1')
const privateConnectionUrl = client.connection.getUrl()
const privateConnectionUrl = client.url
assert.deepEqual(privateConnectionUrl, 'wss://s:1')
})

View File

@@ -11,7 +11,7 @@ const masterSecret = 'snoPBrXtMeMyMHUVTgbuqAfg1SUTb'
export async function ledgerAccept(client: Client): Promise<void> {
const request = { command: 'ledger_accept' }
await client.connection.request(request)
await client.request(request)
}
export async function fundAccount(

View File

@@ -12,7 +12,7 @@ async function setupClient(this: any, port = defaultPort): Promise<void> {
return tclient
.connect()
.then(async () => {
return tclient.connection.request({
return tclient.request({
command: 'test_command',
data: { openOnOtherPort: true },
})