From 6bdbcd234ea5fb23367081748df83e40007e43a2 Mon Sep 17 00:00:00 2001 From: Agustin Pane Date: Tue, 14 Apr 2020 16:03:14 -0300 Subject: [PATCH] #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 --- src/logic/tokens/store/actions/fetchTokens.js | 2 +- src/logic/tokens/store/actions/loadActiveTokens.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/logic/tokens/store/actions/fetchTokens.js b/src/logic/tokens/store/actions/fetchTokens.js index 1a5baa5c..fdff81a6 100644 --- a/src/logic/tokens/store/actions/fetchTokens.js +++ b/src/logic/tokens/store/actions/fetchTokens.js @@ -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) diff --git a/src/logic/tokens/store/actions/loadActiveTokens.js b/src/logic/tokens/store/actions/loadActiveTokens.js index a7c94995..c58980ba 100644 --- a/src/logic/tokens/store/actions/loadActiveTokens.js +++ b/src/logic/tokens/store/actions/loadActiveTokens.js @@ -11,8 +11,11 @@ import { type GlobalState } from '~/store/index' const loadActiveTokens = () => async (dispatch: ReduxDispatch) => { try { const tokens: Map = 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 = 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))