refactor: wrap `generateBatchRequest` into a more meaningful/descriptive funciton

This commit is contained in:
fernandomg 2020-05-27 08:50:57 -03:00
parent 6fb71d1ec4
commit 3b94bc906c
1 changed files with 8 additions and 5 deletions

View File

@ -51,6 +51,13 @@ export const containsMethodByHash = async (contractAddress, methodHash) => {
return byteCode.indexOf(methodHash.replace('0x', '')) !== -1 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) => { export const getTokenInfos = async (tokenAddress) => {
if (!tokenAddress) { if (!tokenAddress) {
return null return null
@ -65,11 +72,7 @@ export const getTokenInfos = async (tokenAddress) => {
} }
// Otherwise we fetch it, save it to the store and return it // Otherwise we fetch it, save it to the store and return it
const [tokenDecimals, tokenName, tokenSymbol] = await generateBatchRequests({ const [tokenDecimals, tokenName, tokenSymbol] = await getTokenValues(tokenAddress)
abi: ERC20Detailed.abi,
address: tokenAddress,
methods: ['decimals', 'name', 'symbol'],
})
if (tokenDecimals === null) { if (tokenDecimals === null) {
return null return null