From 127043bec1222a463a46f3bc9c0496f9a6579a74 Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Tue, 15 Aug 2023 17:01:16 -0700 Subject: [PATCH] Fix outdated type workarounds --- src/horizon/server.ts | 44 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/src/horizon/server.ts b/src/horizon/server.ts index 316510bcf..07e5b09fc 100644 --- a/src/horizon/server.ts +++ b/src/horizon/server.ts @@ -64,11 +64,7 @@ function _getAmountInLumens(amt: BigNumber) { * @param {string} [opts.authToken] - Allow set custom header `X-Auth-Token`, default: `undefined`. */ export class Server { - /** - * serverURL Horizon Server URL (ex. `https://horizon-testnet.stellar.org`). - * - * TODO: Solve `URI(this.serverURL as any)`. - */ + /** Horizon Server URL (ex. `https://horizon-testnet.stellar.org`). */ public readonly serverURL: URI; constructor(serverURL: string, opts: Server.Options = {}) { @@ -159,7 +155,7 @@ export class Server { // otherwise, retry (by calling the root endpoint) // toString automatically adds the trailing slash - await AxiosClient.get(URI(this.serverURL as any).toString()); + await AxiosClient.get(this.serverURL.toString()); return await this.fetchTimebounds(seconds, true); } @@ -181,9 +177,7 @@ export class Server { * @returns {Promise} Promise that resolves to the fee stats returned by Horizon. */ public async feeStats(): Promise { - const cb = new CallBuilder( - URI(this.serverURL as any), - ); + const cb = new CallBuilder(URI(this.serverURL)); cb.filter.push(["fee_stats"]); return cb.call(); } @@ -309,7 +303,7 @@ export class Server { ); return AxiosClient.post( - URI(this.serverURL as any) + URI(this.serverURL) .segment("transactions") .toString(), `tx=${tx}`, @@ -510,28 +504,28 @@ export class Server { * @returns {AccountCallBuilder} New {@link AccountCallBuilder} object configured by a current Horizon server configuration. */ public accounts(): AccountCallBuilder { - return new AccountCallBuilder(URI(this.serverURL as any)); + return new AccountCallBuilder(URI(this.serverURL)); } /** * @returns {ClaimableBalanceCallBuilder} New {@link ClaimableBalanceCallBuilder} object configured by a current Horizon server configuration. */ public claimableBalances(): ClaimableBalanceCallBuilder { - return new ClaimableBalanceCallBuilder(URI(this.serverURL as any)); + return new ClaimableBalanceCallBuilder(URI(this.serverURL)); } /** * @returns {LedgerCallBuilder} New {@link LedgerCallBuilder} object configured by a current Horizon server configuration. */ public ledgers(): LedgerCallBuilder { - return new LedgerCallBuilder(URI(this.serverURL as any)); + return new LedgerCallBuilder(URI(this.serverURL)); } /** * @returns {TransactionCallBuilder} New {@link TransactionCallBuilder} object configured by a current Horizon server configuration. */ public transactions(): TransactionCallBuilder { - return new TransactionCallBuilder(URI(this.serverURL as any)); + return new TransactionCallBuilder(URI(this.serverURL)); } /** @@ -549,7 +543,7 @@ export class Server { * @returns {OfferCallBuilder} New {@link OfferCallBuilder} object */ public offers(): OfferCallBuilder { - return new OfferCallBuilder(URI(this.serverURL as any)); + return new OfferCallBuilder(URI(this.serverURL)); } /** @@ -559,7 +553,7 @@ export class Server { */ public orderbook(selling: Asset, buying: Asset): OrderbookCallBuilder { return new OrderbookCallBuilder( - URI(this.serverURL as any), + URI(this.serverURL), selling, buying, ); @@ -570,14 +564,14 @@ export class Server { * @returns {TradesCallBuilder} New {@link TradesCallBuilder} object configured by a current Horizon server configuration. */ public trades(): TradesCallBuilder { - return new TradesCallBuilder(URI(this.serverURL as any)); + return new TradesCallBuilder(URI(this.serverURL)); } /** * @returns {OperationCallBuilder} New {@link OperationCallBuilder} object configured by a current Horizon server configuration. */ public operations(): OperationCallBuilder { - return new OperationCallBuilder(URI(this.serverURL as any)); + return new OperationCallBuilder(URI(this.serverURL)); } /** @@ -620,7 +614,7 @@ export class Server { destinationAmount: string, ): PathCallBuilder { return new StrictReceivePathCallBuilder( - URI(this.serverURL as any), + URI(this.serverURL), source, destinationAsset, destinationAmount, @@ -648,7 +642,7 @@ export class Server { destination: string | Asset[], ): PathCallBuilder { return new StrictSendPathCallBuilder( - URI(this.serverURL as any), + URI(this.serverURL), sourceAsset, sourceAmount, destination, @@ -660,7 +654,7 @@ export class Server { * Horizon server configuration. */ public payments(): PaymentCallBuilder { - return new PaymentCallBuilder(URI(this.serverURL as any) as any); + return new PaymentCallBuilder(URI(this.serverURL)); } /** @@ -668,7 +662,7 @@ export class Server { * Horizon server configuration */ public effects(): EffectCallBuilder { - return new EffectCallBuilder(URI(this.serverURL as any) as any); + return new EffectCallBuilder(URI(this.serverURL)); } /** @@ -678,7 +672,7 @@ export class Server { * @private */ public friendbot(address: string): FriendbotBuilder { - return new FriendbotBuilder(URI(this.serverURL as any), address); + return new FriendbotBuilder(URI(this.serverURL), address); } /** @@ -687,7 +681,7 @@ export class Server { * @returns {AssetsCallBuilder} New AssetsCallBuilder instance */ public assets(): AssetsCallBuilder { - return new AssetsCallBuilder(URI(this.serverURL as any)); + return new AssetsCallBuilder(URI(this.serverURL)); } /** @@ -727,7 +721,7 @@ export class Server { offset: number, ): TradeAggregationCallBuilder { return new TradeAggregationCallBuilder( - URI(this.serverURL as any), + URI(this.serverURL), base, counter, start_time,