From e550d199f69915191ecf913e07fb12c810772bcb Mon Sep 17 00:00:00 2001 From: Victor Creed <69458664+creed-victor@users.noreply.github.com> Date: Wed, 3 Feb 2021 17:24:54 +0200 Subject: [PATCH 1/6] changed node url to more powerful ones (#348) --- src/utils/classifiers.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/utils/classifiers.ts b/src/utils/classifiers.ts index 4ab4ab105..d6dec7e52 100644 --- a/src/utils/classifiers.ts +++ b/src/utils/classifiers.ts @@ -32,17 +32,13 @@ export const networkNames = { }; export const rpcNodes = { - 30: 'https://mainnet.sovryn.app/rpc', - // 30: 'https://mainnetbackup.sovryn.app/rpc', - 31: 'https://testnet.sovryn.app/rpc', + 30: 'https://mainnet2.sovryn.app/rpc', + 31: 'https://testnet2.sovryn.app/rpc', }; export const readNodes = { - 30: 'wss://mainnet.sovryn.app/ws', - // 30: 'wss://mainnetbackup.sovryn.app/ws', - 31: 'wss://testnet.sovryn.app/ws', - // 30: 'https://public-node.rsk.co', - // 31: 'https://public-node.testnet.rsk.co', + 30: 'wss://mainnet2.sovryn.app/ws', + 31: 'wss://testnet2.sovryn.app/ws', }; export const fastBtcApis = { From e5b33c8368de7300114e6738f01c20107e48e1fc Mon Sep 17 00:00:00 2001 From: Victor Creed <69458664+creed-victor@users.noreply.github.com> Date: Fri, 5 Feb 2021 14:52:38 +0200 Subject: [PATCH 2/6] csov-2 added to my wallet; hide top-up history (#356) --- src/app/components/UserAssets/index.tsx | 52 +++++++++++++++++------ src/app/containers/WalletPage/index.tsx | 3 +- src/utils/blockchain/contracts.testnet.ts | 5 +++ src/utils/blockchain/contracts.ts | 6 ++- 4 files changed, 51 insertions(+), 15 deletions(-) diff --git a/src/app/components/UserAssets/index.tsx b/src/app/components/UserAssets/index.tsx index 40d597b3b..60bc1b733 100644 --- a/src/app/components/UserAssets/index.tsx +++ b/src/app/components/UserAssets/index.tsx @@ -13,7 +13,6 @@ import { translations } from '../../../locales/i18n'; import { useAccount, useIsConnected } from '../../hooks/useAccount'; import { AssetsDictionary } from '../../../utils/dictionaries/assets-dictionary'; import { AssetDetails } from '../../../utils/models/asset-details'; -import { useAssetBalanceOf } from '../../hooks/useAssetBalanceOf'; import { weiToFixed } from '../../../utils/blockchain/math-helpers'; import { LoadableValue } from '../LoadableValue'; import { useCachedAssetPrice } from '../../hooks/trading/useCachedAssetPrice'; @@ -24,8 +23,9 @@ import { numberToUSD, weiToNumberFormat, } from '../../../utils/display-text/format'; - -// import { actions } from 'app/containers/FastBtcForm/slice'; +import { contractReader } from '../../../utils/sovryn/contract-reader'; +import { getTokenContractName } from '../../../utils/blockchain/contract-helpers'; +import { Sovryn } from '../../../utils/sovryn'; export function UserAssets() { const { t } = useTranslation(); @@ -87,25 +87,56 @@ interface AssetProps { function AssetRow({ item }: AssetProps) { const { t } = useTranslation(); - const tokens = useAssetBalanceOf(item.asset); + const account = useAccount(); + const [loading, setLoading] = useState(true); + const [tokens, setTokens] = useState('0'); const dollars = useCachedAssetPrice(item.asset, Asset.USDT); - // const dispatch = useDispatch(); const history = useHistory(); const [dollarValue, setDollarValue] = useState('0'); + useEffect(() => { + const get = async () => { + setLoading(true); + let tokenA: string = '0'; + if (item.asset === Asset.BTC) { + tokenA = await Sovryn.getWeb3().eth.getBalance(account); + } else { + tokenA = await contractReader.call( + getTokenContractName(item.asset), + 'balanceOf', + [account], + ); + } + + let tokenB: string = '0'; + if (item.asset === Asset.CSOV) { + tokenB = await contractReader.call('CSOV2_token', 'balanceOf', [ + account, + ]); + } + setTokens( + bignumber(tokenA) + .add(tokenB || '0') + .toFixed(0), + ); + setLoading(false); + }; + get().catch(); + }, [item.asset, account]); + useEffect(() => { if ([Asset.USDT, Asset.DOC].includes(item.asset)) { - setDollarValue(tokens.value); + setDollarValue(tokens); } else { setDollarValue( - bignumber(tokens.value) + bignumber(tokens) .mul(dollars.value) .div(10 ** item.decimals) .toFixed(0), ); } - }, [dollars.value, tokens.value, item.asset, item.decimals]); + }, [dollars.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