move fetchTokenList function to separate api folder, add fetchToken func

This commit is contained in:
Mikhail Mikheev 2019-04-23 13:42:45 +04:00
parent 3e62d3b7be
commit 39ccb7b288
4 changed files with 28 additions and 9 deletions

View File

@ -0,0 +1,12 @@
// @flow
import axios from 'axios'
import { getRelayUrl } from '~/config/index'
const fetchToken = (tokenAddress: string) => {
const apiUrl = getRelayUrl()
const url = `${apiUrl}/tokens/${tokenAddress}`
return axios.get(url)
}
export default fetchToken

View File

@ -0,0 +1,12 @@
// @flow
import axios from 'axios'
import { getRelayUrl } from '~/config/index'
const fetchTokenList = () => {
const apiUrl = getRelayUrl()
const url = `${apiUrl}/tokens`
return axios.get(url)
}
export default fetchTokenList

View File

@ -0,0 +1,3 @@
// @flow
export { default as fetchTokenList } from './fetchTokenList'
export { default as fetchToken } from './fetchToken'

View File

@ -1,16 +1,15 @@
// @flow
import { List } from 'immutable'
import contract from 'truffle-contract'
import axios from 'axios'
import type { Dispatch as ReduxDispatch } from 'redux'
import StandardToken from '@gnosis.pm/util-contracts/build/contracts/GnosisStandardToken.json'
import HumanFriendlyToken from '@gnosis.pm/util-contracts/build/contracts/HumanFriendlyToken.json'
import { getWeb3 } from '~/logic/wallets/getWeb3'
import { type GlobalState } from '~/store/index'
import { makeToken, type TokenProps } from '~/logic/tokens/store/model/token'
import { fetchTokenList } from '~/logic/tokens/api'
import { ensureOnce } from '~/utils/singleton'
import saveTokens from './saveTokens'
import { getRelayUrl } from '~/config/index'
const createStandardTokenContract = async () => {
const web3 = getWeb3()
@ -31,13 +30,6 @@ export const getHumanFriendlyToken = ensureOnce(createHumanFriendlyTokenContract
export const getStandardTokenContract = ensureOnce(createStandardTokenContract)
const fetchTokenList = async () => {
const apiUrl = getRelayUrl()
const url = `${apiUrl}/tokens`
const errMsg = 'Error querying safe balances'
return axios.get(url, errMsg)
}
export const fetchTokens = () => async (dispatch: ReduxDispatch<GlobalState>) => {
try {
const {