From 3b94bc906c56e5fef5c8b63b18ece02da5f4fb2b Mon Sep 17 00:00:00 2001 From: fernandomg Date: Wed, 27 May 2020 08:50:57 -0300 Subject: [PATCH] refactor: wrap `generateBatchRequest` into a more meaningful/descriptive funciton --- src/logic/tokens/store/actions/fetchTokens.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/logic/tokens/store/actions/fetchTokens.ts b/src/logic/tokens/store/actions/fetchTokens.ts index f96d6660..0e178f47 100644 --- a/src/logic/tokens/store/actions/fetchTokens.ts +++ b/src/logic/tokens/store/actions/fetchTokens.ts @@ -51,6 +51,13 @@ export const containsMethodByHash = async (contractAddress, methodHash) => { return byteCode.indexOf(methodHash.replace('0x', '')) !== -1 } +const getTokenValues = (tokenAddress) => + generateBatchRequests({ + abi: ERC20Detailed.abi, + address: tokenAddress, + methods: ['decimals', 'name', 'symbol'], + }) + export const getTokenInfos = async (tokenAddress) => { if (!tokenAddress) { return null @@ -65,11 +72,7 @@ export const getTokenInfos = async (tokenAddress) => { } // Otherwise we fetch it, save it to the store and return it - const [tokenDecimals, tokenName, tokenSymbol] = await generateBatchRequests({ - abi: ERC20Detailed.abi, - address: tokenAddress, - methods: ['decimals', 'name', 'symbol'], - }) + const [tokenDecimals, tokenName, tokenSymbol] = await getTokenValues(tokenAddress) if (tokenDecimals === null) { return null