move fetchTokenList function to separate api folder, add fetchToken func
This commit is contained in:
parent
3e62d3b7be
commit
39ccb7b288
|
@ -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
|
|
@ -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
|
|
@ -0,0 +1,3 @@
|
||||||
|
// @flow
|
||||||
|
export { default as fetchTokenList } from './fetchTokenList'
|
||||||
|
export { default as fetchToken } from './fetchToken'
|
|
@ -1,16 +1,15 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { List } from 'immutable'
|
import { List } from 'immutable'
|
||||||
import contract from 'truffle-contract'
|
import contract from 'truffle-contract'
|
||||||
import axios from 'axios'
|
|
||||||
import type { Dispatch as ReduxDispatch } from 'redux'
|
import type { Dispatch as ReduxDispatch } from 'redux'
|
||||||
import StandardToken from '@gnosis.pm/util-contracts/build/contracts/GnosisStandardToken.json'
|
import StandardToken from '@gnosis.pm/util-contracts/build/contracts/GnosisStandardToken.json'
|
||||||
import HumanFriendlyToken from '@gnosis.pm/util-contracts/build/contracts/HumanFriendlyToken.json'
|
import HumanFriendlyToken from '@gnosis.pm/util-contracts/build/contracts/HumanFriendlyToken.json'
|
||||||
import { getWeb3 } from '~/logic/wallets/getWeb3'
|
import { getWeb3 } from '~/logic/wallets/getWeb3'
|
||||||
import { type GlobalState } from '~/store/index'
|
import { type GlobalState } from '~/store/index'
|
||||||
import { makeToken, type TokenProps } from '~/logic/tokens/store/model/token'
|
import { makeToken, type TokenProps } from '~/logic/tokens/store/model/token'
|
||||||
|
import { fetchTokenList } from '~/logic/tokens/api'
|
||||||
import { ensureOnce } from '~/utils/singleton'
|
import { ensureOnce } from '~/utils/singleton'
|
||||||
import saveTokens from './saveTokens'
|
import saveTokens from './saveTokens'
|
||||||
import { getRelayUrl } from '~/config/index'
|
|
||||||
|
|
||||||
const createStandardTokenContract = async () => {
|
const createStandardTokenContract = async () => {
|
||||||
const web3 = getWeb3()
|
const web3 = getWeb3()
|
||||||
|
@ -31,13 +30,6 @@ export const getHumanFriendlyToken = ensureOnce(createHumanFriendlyTokenContract
|
||||||
|
|
||||||
export const getStandardTokenContract = ensureOnce(createStandardTokenContract)
|
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>) => {
|
export const fetchTokens = () => async (dispatch: ReduxDispatch<GlobalState>) => {
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
|
|
Loading…
Reference in New Issue