Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add disableHTTP flag #511

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
"typescript": "^5.0.4"
},
"packageManager": "yarn@3.5.0",
"stableVersion": "4.1.9-10"
"stableVersion": "4.1.9-11"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { PriceProvider } from './types';
import { FixedPointNumber as FN, Token } from '@acala-network/sdk-core';

interface AggregatedProviderConfigs {
market: PriceProvider;
market?: PriceProvider;
dex: PriceProvider;
}

export class AggregateProvider implements PriceProvider {
private marketPriceProvider: PriceProvider;
private marketPriceProvider: PriceProvider | undefined;
private dexPriceProvider: PriceProvider;

constructor({ market, dex }: AggregatedProviderConfigs) {
Expand All @@ -22,6 +22,10 @@ export class AggregateProvider implements PriceProvider {
const marketPriceProvider = this.marketPriceProvider;
const dexPriceProvider = this.dexPriceProvider;

if (!marketPriceProvider) {
return dexPriceProvider.subscribe(token);
}

const marketPrice$ = marketPriceProvider.subscribe(token);

return marketPrice$.pipe(
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/wallet/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface WalletConsts {
}

export interface WalletConfigs {
disableHTTP?: boolean;
evmProvider?: EvmRpcProvider;
// overview price providers if need
priceProviders?: PriceProviders;
Expand Down
3 changes: 2 additions & 1 deletion packages/sdk/src/wallet/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ export class Wallet implements BaseSDK {
this.liquidity = new Liquidity(this.api, this);
this.homa = new Homa(this.api, this);
this.web3Name = new DIDWeb3Name();
const disableHTTP = this.configs.disableHTTP;

const market = new MarketPriceProvider();
const market = !disableHTTP ? new MarketPriceProvider() : undefined;
const dex = new DexPriceProvider(this.liquidity);
const aggregate = new AggregateProvider({ market, dex });
const oracle = new OraclePriceProvider(this.api, {
Expand Down
Loading