Fix marketDetails stringKey, do not update state with markets not tracked by Abacus (#61)

This commit is contained in:
Jared Vu 2023-10-06 14:12:40 -07:00 committed by GitHub
parent fa621a085b
commit 62eeab06f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 9 deletions

View File

@ -35,6 +35,7 @@ import { setAssets } from '@/state/assets';
import { setConfigs } from '@/state/configs';
import { setInputs } from '@/state/inputs';
import { setHistoricalFundings, setLiveTrades, setMarkets, setOrderbook } from '@/state/perpetuals';
import { isTruthy } from '../isTruthy';
class AbacusStateNotifier implements AbacusStateNotificationProtocol {
private store: RootStore | undefined;
@ -84,7 +85,7 @@ class AbacusStateNotifier implements AbacusStateNotificationProtocol {
dispatch(setBalances(balances));
}
if (updatedState.account?.stakingBalances) {
const stakingBalances: Record<string, AccountBalance> = {}
const stakingBalances: Record<string, AccountBalance> = {};
for (const { k, v } of updatedState.account.stakingBalances.toArray()) {
stakingBalances[k] = v;
}
@ -108,10 +109,12 @@ class AbacusStateNotifier implements AbacusStateNotificationProtocol {
dispatch(
setMarkets({
markets: Object.fromEntries(
(marketIds || updatedState.marketIds()?.toArray() || []).map((marketId: string) => {
const marketData = updatedState.market(marketId);
return [marketId, marketData];
})
(marketIds || updatedState.marketIds()?.toArray() || [])
.map((marketId: string) => {
const marketData = updatedState.market(marketId);
return [marketId, marketData];
})
.filter(isTruthy)
) as Record<string, PerpetualMarket>,
update: !!marketIds,
})

View File

@ -139,11 +139,9 @@ export const MarketDetails: React.FC = () => {
</Styled.WrapRow>
<Styled.MarketDescription>
{primaryDescriptionKey && (
<p>{stringGetter({ key: STRING_KEYS[primaryDescriptionKey as StringKey] })}</p>
)}
{primaryDescriptionKey && <p>{stringGetter({ key: `APP.${primaryDescriptionKey}` })}</p>}
{secondaryDescriptionKey && (
<p>{stringGetter({ key: STRING_KEYS[secondaryDescriptionKey as StringKey] })}</p>
<p>{stringGetter({ key: `APP.${secondaryDescriptionKey}` })}</p>
)}
</Styled.MarketDescription>