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

TW-1282 Use /prices 3route API entry #143

Merged
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions src/utils/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
}

const exchangeRatesWithHoles = await Promise.all(
tokens
tokens!

Check warning on line 43 in src/utils/tokens.ts

View workflow job for this annotation

GitHub Actions / Checks if ts and lint works

Forbidden non-null assertion
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could define someProvider.getState() so that its return type is

Promise<
  { data: undefined; error: unknown }
  | { data: T; error: undefined }
>

+ As I see it, these providers are only a memoization mechanisms, that can be replaced with memoizee.

.filter(
(token): token is ThreeRouteFa12Token | ThreeRouteFa2Token => token.standard !== ThreeRouteStandardEnum.xtz
)
.map(async (token): Promise<TokenExchangeRateEntry | undefined> => {
const { contract, tokenId: rawTokenId, symbol } = token;
const tokenId = isDefined(rawTokenId) ? Number(rawTokenId) : undefined;
const { ask, bid } = exchangeRatesInputs[symbol] ?? { ask: 0, bid: 0 };
const { ask, bid } = exchangeRatesInputs![symbol] ?? { ask: 0, bid: 0 };

Check warning on line 50 in src/utils/tokens.ts

View workflow job for this annotation

GitHub Actions / Checks if ts and lint works

Forbidden non-null assertion

if (ask === 0 && bid === 0) {
logger.error(`Failed to get exchange rate for token ${token.symbol}`);
Expand All @@ -57,7 +57,7 @@

const { data: metadata } = await tokensMetadataProvider.get(contract, tokenId);
const tokensPerTez = ask === 0 ? bid : ask;
const exchangeRate = new BigNumber(1).div(tokensPerTez).times(tezExchangeRate);
const exchangeRate = new BigNumber(1).div(tokensPerTez).times(tezExchangeRate!);

Check warning on line 60 in src/utils/tokens.ts

View workflow job for this annotation

GitHub Actions / Checks if ts and lint works

Forbidden non-null assertion

return {
tokenAddress: contract,
Expand Down
Loading