#751 fix - Replaces decimals from backend with decimals from blockchain (#755)

* Replaces decimals from backend with decimals from blockchain

* Removes fetching again token info from blockchain
Fixs decimals cast, now we force to move from bignumber to number
For data already wrong stored as string we remove it to force fetching again the decimals

* Fixs missing symbol

* Add description comment
This commit is contained in:
Agustin Pane 2020-04-14 16:03:14 -03:00 committed by GitHub
parent c40fa07696
commit 6bdbcd234e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -128,7 +128,7 @@ export const getTokenInfos = async (tokenAddress: string) => {
address: tokenAddress,
name: name ? name : tokenSymbol,
symbol: tokenSymbol,
decimals: tokenDecimals,
decimals: tokenDecimals.toNumber(),
logoUri: '',
})
const newTokens = tokens.set(tokenAddress, savedToken)

View File

@ -11,8 +11,11 @@ import { type GlobalState } from '~/store/index'
const loadActiveTokens = () => async (dispatch: ReduxDispatch<GlobalState>) => {
try {
const tokens: Map<string, TokenProps> = await getActiveTokens()
// The filter of strings was made because of the issue #751. Please see: https://github.com/gnosis/safe-react/pull/755#issuecomment-612969340
const tokenRecordsList: List<Token> = List(
Object.values(tokens).map((token: TokenProps): Token => makeToken(token)),
Object.values(tokens)
.filter((t) => typeof t.decimals !== 'string')
.map((token: TokenProps): Token => makeToken(token)),
)
dispatch(saveTokens(tokenRecordsList))