Skip to content

Commit

Permalink
feat(Wallet): add USDT and change switch label (#1363)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsimao authored Jun 28, 2023
1 parent ef2e8dd commit 1045cef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/assets/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
"asset": "Asset",
"price": "Price",
"balance": "Balance",
"show_zero_balance": "Show Zero Balance",
"show_all": "Show All",
"total_balance": "Total Balance",
"transferable_balance": "Transferable Balance",
"fund_wallet": "Fund Wallet",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useMediaQuery } from '@/component-library/utils/use-media-query';
import { Cell } from '@/components';
import { AssetCell, DataGrid } from '@/components/DataGrid';
import { GOVERNANCE_TOKEN, WRAPPED_TOKEN } from '@/config/relay-chains';
import { NATIVE_CURRENCIES } from '@/utils/constants/currency';
import { FEE_TICKERS } from '@/utils/constants/currency';
import { getCoinIconProps } from '@/utils/helpers/coin-icon';
import { getTokenPrice } from '@/utils/helpers/prices';
import { BalanceData } from '@/utils/hooks/api/tokens/use-get-balances';
Expand Down Expand Up @@ -43,13 +43,13 @@ const AvailableAssetsTable = ({ balances, pooledTickers }: AvailableAssetsTableP
const { data: vestingData } = useGetVestingData();
const isMobile = useMediaQuery(theme.breakpoints.down('md'));

const [showZeroBalances, setShowZeroBalances] = useState(false);
const [showAllBalances, setShowAllBalances] = useState(false);

const rows: AvailableAssetsRows[] = useMemo(() => {
const data = balances ? Object.values(balances) : [];
const filteredData = showZeroBalances
const filteredData = showAllBalances
? data
: data.filter((balance) => NATIVE_CURRENCIES.includes(balance.currency) || !balance.transferable.isZero());
: data.filter((balance) => FEE_TICKERS.includes(balance.currency.ticker) || !balance.transferable.isZero());

return filteredData.map(
({ currency, transferable }): AvailableAssetsRows => {
Expand Down Expand Up @@ -103,11 +103,11 @@ const AvailableAssetsTable = ({ balances, pooledTickers }: AvailableAssetsTableP
};
}
);
}, [balances, showZeroBalances, isMobile, prices, pooledTickers, vestingData?.isClaimable]);
}, [balances, showAllBalances, isMobile, prices, pooledTickers, vestingData?.isClaimable]);

const actions = (
<Switch isSelected={showZeroBalances} onChange={(e) => setShowZeroBalances(e.target.checked)}>
{t('show_zero_balance')}
<Switch isSelected={showAllBalances} onChange={(e) => setShowAllBalances(e.target.checked)}>
{t('show_all')}
</Switch>
);

Expand Down
3 changes: 3 additions & 0 deletions src/utils/constants/currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const ZERO_GOVERNANCE_TOKEN_AMOUNT = newMonetaryAmount(0, GOVERNANCE_TOKEN, true
const NATIVE_CURRENCIES: Array<CurrencyExt> =
process.env.REACT_APP_RELAY_CHAIN_NAME === POLKADOT ? [Polkadot, InterBtc, Interlay] : [KBtc, Kintsugi, Kusama];

const FEE_TICKERS = [...NATIVE_CURRENCIES.map(({ ticker }) => ticker), 'USDT'];

const COINGECKO_ID_BY_CURRENCY_TICKER: Record<string, typeof COINGECKO_IDS[number]> = Object.freeze({
[Bitcoin.ticker]: 'bitcoin',
[Kintsugi.ticker]: 'kintsugi',
Expand All @@ -33,6 +35,7 @@ const COINGECKO_ID_BY_CURRENCY_TICKER: Record<string, typeof COINGECKO_IDS[numbe

export {
COINGECKO_ID_BY_CURRENCY_TICKER,
FEE_TICKERS,
NATIVE_CURRENCIES,
ZERO_GOVERNANCE_TOKEN_AMOUNT,
ZERO_VOTE_GOVERNANCE_TOKEN_AMOUNT
Expand Down

2 comments on commit 1045cef

@vercel
Copy link

@vercel vercel bot commented on 1045cef Jun 28, 2023

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 1045cef Jun 28, 2023

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.