Skip to content

Commit

Permalink
Fix outdated type workarounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaptic committed Aug 16, 2023
1 parent 94ac80c commit 127043b
Showing 1 changed file with 19 additions and 25 deletions.
44 changes: 19 additions & 25 deletions src/horizon/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}) {
Expand Down Expand Up @@ -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);
}

Expand All @@ -181,9 +177,7 @@ export class Server {
* @returns {Promise<Horizon.FeeStatsResponse>} Promise that resolves to the fee stats returned by Horizon.
*/
public async feeStats(): Promise<Horizon.FeeStatsResponse> {
const cb = new CallBuilder<Horizon.FeeStatsResponse>(
URI(this.serverURL as any),
);
const cb = new CallBuilder<Horizon.FeeStatsResponse>(URI(this.serverURL));
cb.filter.push(["fee_stats"]);
return cb.call();
}
Expand Down Expand Up @@ -309,7 +303,7 @@ export class Server {
);

return AxiosClient.post(
URI(this.serverURL as any)
URI(this.serverURL)
.segment("transactions")
.toString(),
`tx=${tx}`,
Expand Down Expand Up @@ -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));
}

/**
Expand All @@ -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));
}

/**
Expand All @@ -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,
);
Expand All @@ -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));
}

/**
Expand Down Expand Up @@ -620,7 +614,7 @@ export class Server {
destinationAmount: string,
): PathCallBuilder {
return new StrictReceivePathCallBuilder(
URI(this.serverURL as any),
URI(this.serverURL),
source,
destinationAsset,
destinationAmount,
Expand Down Expand Up @@ -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,
Expand All @@ -660,15 +654,15 @@ 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));
}

/**
* @returns {EffectCallBuilder} New {@link EffectCallBuilder} instance configured with the current
* Horizon server configuration
*/
public effects(): EffectCallBuilder {
return new EffectCallBuilder(URI(this.serverURL as any) as any);
return new EffectCallBuilder(URI(this.serverURL));
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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));
}

/**
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 127043b

Please sign in to comment.