Skip to content

Commit

Permalink
Merge pull request #504 from interlay/peter/fix-vault-overview-pendin…
Browse files Browse the repository at this point in the history
…g-requests

fix: ss58format accountId in queries
  • Loading branch information
peterslany authored Sep 15, 2022
2 parents 02eb855 + 038a4d8 commit eb5dffa
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/utils/hooks/api/vaults/get-vault-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@interlay/interbtc-api';
import { BitcoinAmount, MonetaryAmount } from '@interlay/monetary-js';
import { AccountId } from '@polkadot/types/interfaces';
import { encodeAddress } from "@polkadot/util-crypto"
import Big from 'big.js';

import { Prices } from '@/common/types/util.types';
Expand All @@ -19,12 +20,11 @@ import {
WRAPPED_TOKEN_SYMBOL,
WrappedTokenAmount
} from '@/config/relay-chains';
import { HYDRA_URL } from '@/constants';
import { HYDRA_URL, SS58_FORMAT } from '@/constants';
import issueCountQuery from '@/services/queries/issue-count-query';
import redeemCountQuery from '@/services/queries/redeem-count-query';
import { ForeignAssetIdLiteral } from '@/types/currency';
import { getTokenPrice } from '@/utils/helpers/prices';

interface VaultData {
apy: Big;
collateralization: Big | undefined;
Expand Down Expand Up @@ -125,6 +125,7 @@ const getVaultData = async (vault: VaultExt, accountId: AccountId, prices: Price
wrappedTokenRewards,
getTokenPrice(prices, WRAPPED_TOKEN_SYMBOL)?.usd
);
const formattedAccountId = encodeAddress(accountId, SS58_FORMAT)

// TODO: move issues and redeems to separate hook
const issues = await fetch(HYDRA_URL, {
Expand All @@ -134,7 +135,7 @@ const getVaultData = async (vault: VaultExt, accountId: AccountId, prices: Price
},
body: JSON.stringify({
query: issueCountQuery(
`vault: {accountId_eq: "${accountId.toString()}", collateralToken: {token_eq: ${collateralTokenIdLiteral}}}, status_eq: Pending` // TODO: add condition for asset_eq when the page is refactored for accepting ForeignAsset currencies too (cf. e.g. issued graph in dashboard for example)
`vault: {accountId_eq: "${formattedAccountId}", collateralToken: {token_eq: ${collateralTokenIdLiteral}}}, status_eq: Pending` // TODO: add condition for asset_eq when the page is refactored for accepting ForeignAsset currencies too (cf. e.g. issued graph in dashboard for example)
)
})
});
Expand All @@ -146,7 +147,7 @@ const getVaultData = async (vault: VaultExt, accountId: AccountId, prices: Price
},
body: JSON.stringify({
query: redeemCountQuery(
`vault: {accountId_eq: "${accountId.toString()}", collateralToken: {token_eq: ${collateralTokenIdLiteral}}}, status_eq: Pending` // TODO: add asset_eq, see comment above
`vault: {accountId_eq: "${formattedAccountId}", collateralToken: {token_eq: ${collateralTokenIdLiteral}}}, status_eq: Pending` // TODO: add asset_eq, see comment above
)
})
});
Expand Down

2 comments on commit eb5dffa

@vercel
Copy link

@vercel vercel bot commented on eb5dffa Sep 15, 2022

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on eb5dffa Sep 15, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.