Skip to content

Commit

Permalink
fix: hide farm if inactive and zero balance
Browse files Browse the repository at this point in the history
  • Loading branch information
esaminu committed Mar 21, 2022
1 parent 24e4988 commit 8bf34c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import BN from 'bn.js';
import React, { useState, useEffect } from 'react';
import { Translate } from 'react-localize-redux';
import { useDispatch, useSelector } from 'react-redux';
Expand Down Expand Up @@ -28,10 +29,10 @@ const renderFarmUi = ({ farmList, contractMetadataByContractId, openModal, token
}

return farmList.map((farm, i) => {
const { token_id, balance, farm_id } = farm;
const { token_id, balance, farm_id, active } = farm;
const currentTokenContractMetadata = contractMetadataByContractId[token_id];

if (!currentTokenContractMetadata) {
if (!currentTokenContractMetadata || (!active && new BN(balance).isZero())) {
return;
}
const fiatValueMetadata = tokenPriceMetadata.tokenFiatValues[token_id];
Expand Down
6 changes: 4 additions & 2 deletions packages/frontend/src/redux/actions/staking.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ export const getValidatorFarmData = (validator, accountId) => async (dispatch, g
const poolSummary = await validator.contract.get_pool_summary();
const farms = await validator.contract.get_farms({ from_index: 0, limit: 300 });

const list = await Promise.all(farms.map(({ token_id, farm_id }) => {
const list = await Promise.all(farms.map(({ token_id, farm_id, active }) => {
try {
dispatch(fetchToken({ contractName: token_id }));
return validator.contract
Expand All @@ -542,13 +542,15 @@ export const getValidatorFarmData = (validator, accountId) => async (dispatch, g
token_id,
balance,
farm_id,
active
}));
} catch (error) {
console.error(error);
return ({
token_id,
farm_id,
balance: 0
balance: 0,
active
});
}

Expand Down

0 comments on commit 8bf34c9

Please sign in to comment.