From 028655d682f3b4ce2e44012ecca414cb271fc86a Mon Sep 17 00:00:00 2001 From: Nathan Nichols Date: Sun, 26 Sep 2021 11:06:20 -0700 Subject: [PATCH] build: makes connection private --- package-lock.json | 4 ++-- src/client/index.ts | 11 ++++++++++- src/wallet/generateFaucetWallet.ts | 2 +- test/client.ts | 3 +-- test/client/constructor.ts | 2 +- test/integration/utils.ts | 2 +- test/setupClientWeb.ts | 2 +- 7 files changed, 17 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3500fd0f..95688626 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/src/client/index.ts b/src/client/index.ts index 7ee2d40d..aab521a3 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -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. * diff --git a/src/wallet/generateFaucetWallet.ts b/src/wallet/generateFaucetWallet.ts index 78fab8ab..c0e942af 100644 --- a/src/wallet/generateFaucetWallet.ts +++ b/src/wallet/generateFaucetWallet.ts @@ -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')) { diff --git a/test/client.ts b/test/client.ts index adea6ad6..df54ffef 100644 --- a/test/client.ts +++ b/test/client.ts @@ -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') }) diff --git a/test/client/constructor.ts b/test/client/constructor.ts index de113409..74a23015 100644 --- a/test/client/constructor.ts +++ b/test/client/constructor.ts @@ -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') }) diff --git a/test/integration/utils.ts b/test/integration/utils.ts index f8437800..31f76c4b 100644 --- a/test/integration/utils.ts +++ b/test/integration/utils.ts @@ -11,7 +11,7 @@ const masterSecret = 'snoPBrXtMeMyMHUVTgbuqAfg1SUTb' export async function ledgerAccept(client: Client): Promise { const request = { command: 'ledger_accept' } - await client.connection.request(request) + await client.request(request) } export async function fundAccount( diff --git a/test/setupClientWeb.ts b/test/setupClientWeb.ts index 110bad5c..1d7736d1 100644 --- a/test/setupClientWeb.ts +++ b/test/setupClientWeb.ts @@ -12,7 +12,7 @@ async function setupClient(this: any, port = defaultPort): Promise { return tclient .connect() .then(async () => { - return tclient.connection.request({ + return tclient.request({ command: 'test_command', data: { openOnOtherPort: true }, })