Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ export const getNetworkConfigFeatures = (): SafeFeatures | undefined => getConfi

export const getNetworkInfo = (): NetworkSettings => getConfig()?.network

export const getTxServiceUriFrom = (safeAddress: string) => `safes/${safeAddress}/transactions/`
export const getTxServiceUriFrom = (safeAddress: string) => `/safes/${safeAddress}/transactions/`

export const getIncomingTxServiceUriTo = (safeAddress: string) => `safes/${safeAddress}/incoming-transfers/`
export const getIncomingTxServiceUriTo = (safeAddress: string) => `/safes/${safeAddress}/incoming-transfers/`

export const getAllTransactionsUriFrom = (safeAddress: string) => `safes/${safeAddress}/all-transactions/`
export const getAllTransactionsUriFrom = (safeAddress: string) => `/safes/${safeAddress}/all-transactions/`

export const getSafeCreationTxUri = (safeAddress: string) => `safes/${safeAddress}/creation/`
export const getSafeCreationTxUri = (safeAddress: string) => `/safes/${safeAddress}/creation/`

export const getGoogleAnalyticsTrackingID = (): string => GOOGLE_ANALYTICS_ID[getNetworkName()]

Expand Down
8 changes: 4 additions & 4 deletions src/config/networks/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import EtherLogo from 'src/assets/icons/icon_etherTokens.svg'
import { EnvironmentSettings, ETHEREUM_NETWORK, NetworkConfig } from 'src/config/networks/network.d'

const baseConfig: EnvironmentSettings = {
txServiceUrl: 'http://localhost:8000/api/v1/',
txServiceUrl: 'http://localhost:8000/api/v1',
relayApiUrl: 'https://safe-relay.staging.gnosisdev.com/api/v1',
safeAppsUrl: 'http://localhost:3002/',
safeAppsUrl: 'http://localhost:3002',
gasPriceOracleUrl: 'https://ethgasstation.info/json/ethgasAPI.json',
rpcServiceUrl: 'http://localhost:4447/',
rpcServiceUrl: 'http://localhost:4447',
networkExplorerName: 'Etherscan',
networkExplorerUrl: 'https://rinkeby.etherscan.io/',
networkExplorerUrl: 'https://rinkeby.etherscan.io',
networkExplorerApiUrl: 'https://api-rinkeby.etherscan.io/api',
}

Expand Down
14 changes: 7 additions & 7 deletions src/config/networks/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import EtherLogo from 'src/assets/icons/icon_etherTokens.svg'
import { EnvironmentSettings, ETHEREUM_NETWORK, NetworkConfig } from 'src/config/networks/network.d'

const baseConfig: EnvironmentSettings = {
txServiceUrl: 'https://safe-transaction.mainnet.staging.gnosisdev.com/api/v1/',
safeAppsUrl: 'https://safe-apps.dev.gnosisdev.com/',
txServiceUrl: 'https://safe-transaction.mainnet.staging.gnosisdev.com/api/v1',
safeAppsUrl: 'https://safe-apps.dev.gnosisdev.com',
gasPriceOracleUrl: 'https://ethgasstation.info/json/ethgasAPI.json',
rpcServiceUrl: 'https://mainnet.infura.io:443/v3/',
rpcServiceUrl: 'https://mainnet.infura.io:443/v3',
networkExplorerName: 'Etherscan',
networkExplorerUrl: 'https://etherscan.io/',
networkExplorerUrl: 'https://etherscan.io',
networkExplorerApiUrl: 'https://api.etherscan.io/api',
}

Expand All @@ -18,12 +18,12 @@ const mainnet: NetworkConfig = {
},
staging: {
...baseConfig,
safeAppsUrl: 'https://safe-apps.staging.gnosisdev.com/',
safeAppsUrl: 'https://safe-apps.staging.gnosisdev.com',
},
production: {
...baseConfig,
txServiceUrl: 'https://safe-transaction.mainnet.gnosis.io/api/v1/',
safeAppsUrl: 'https://apps.gnosis-safe.io/',
txServiceUrl: 'https://safe-transaction.mainnet.gnosis.io/api/v1',
safeAppsUrl: 'https://apps.gnosis-safe.io',
},
},
network: {
Expand Down
12 changes: 6 additions & 6 deletions src/config/networks/rinkeby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import EtherLogo from 'src/assets/icons/icon_etherTokens.svg'
import { EnvironmentSettings, ETHEREUM_NETWORK, NetworkConfig } from 'src/config/networks/network.d'

const baseConfig: EnvironmentSettings = {
txServiceUrl: 'https://safe-transaction.staging.gnosisdev.com/api/v1/',
safeAppsUrl: 'https://safe-apps.dev.gnosisdev.com/',
txServiceUrl: 'https://safe-transaction.staging.gnosisdev.com/api/v1',
safeAppsUrl: 'https://safe-apps.dev.gnosisdev.com',
gasPriceOracleUrl: 'https://ethgasstation.info/json/ethgasAPI.json',
rpcServiceUrl: 'https://rinkeby.infura.io:443/v3/',
rpcServiceUrl: 'https://rinkeby.infura.io:443/v3',
networkExplorerName: 'Etherscan',
networkExplorerUrl: 'https://rinkeby.etherscan.io/',
networkExplorerUrl: 'https://rinkeby.etherscan.io',
networkExplorerApiUrl: 'https://api-rinkeby.etherscan.io/api',
}

Expand All @@ -22,8 +22,8 @@ const rinkeby: NetworkConfig = {
},
production: {
...baseConfig,
txServiceUrl: 'https://safe-transaction.rinkeby.gnosis.io/api/v1/',
safeAppsUrl: 'https://apps.gnosis-safe.io/',
txServiceUrl: 'https://safe-transaction.rinkeby.gnosis.io/api/v1',
safeAppsUrl: 'https://apps.gnosis-safe.io',
},
},
network: {
Expand Down
8 changes: 4 additions & 4 deletions src/config/networks/xdai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { ETHEREUM_NETWORK, NetworkConfig } from 'src/config/networks/network.d'
const xDai: NetworkConfig = {
environment: {
production: {
txServiceUrl: 'https://safe-transaction.xdai.gnosis.io/api/v1/',
safeAppsUrl: 'https://apps.gnosis-safe.io/',
txServiceUrl: 'https://safe-transaction.xdai.gnosis.io/api/v1',
safeAppsUrl: 'https://apps.gnosis-safe.io',
gasPrice: 1e9,
rpcServiceUrl: 'https://rpc.xdaichain.com/',
rpcServiceUrl: 'https://rpc.xdaichain.com',
networkExplorerName: 'Blockscout',
networkExplorerUrl: 'https://blockscout.com/poa/xdai/',
networkExplorerUrl: 'https://blockscout.com/poa/xdai',
networkExplorerApiUrl: 'https://blockscout.com/poa/xdai/api',
},
},
Expand Down
4 changes: 1 addition & 3 deletions src/logic/currencyValues/__tests__/fetchSafeTokens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ describe('fetchTokenCurrenciesBalances', () => {
// then
expect(result).toStrictEqual(expectedResult)
expect(axios.get).toHaveBeenCalled()
expect(axios.get).toBeCalledWith(`${apiUrl}safes/${safeAddress}/balances/usd/?exclude_spam=${excludeSpamTokens}`, {
params: { limit: 3000 },
})
expect(axios.get).toBeCalledWith(`${apiUrl}/safes/${safeAddress}/balances/usd/?exclude_spam=${excludeSpamTokens}`)
})
})
8 changes: 2 additions & 6 deletions src/logic/currencyValues/api/fetchTokenCurrenciesBalances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@ const fetchTokenCurrenciesBalances = (
excludeSpamTokens = true,
): Promise<AxiosResponse<BalanceEndpoint[]>> => {
const apiUrl = getTxServiceUrl()
const url = `${apiUrl}safes/${safeAddress}/balances/usd/?exclude_spam=${excludeSpamTokens}`
const url = `${apiUrl}/safes/${safeAddress}/balances/usd/?exclude_spam=${excludeSpamTokens}`

return axios.get(url, {
params: {
limit: 3000,
},
})
return axios.get(url)
}

export default fetchTokenCurrenciesBalances
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const getAllTransactionsUri = (safeAddress: string): string => {
const address = checksumAddress(safeAddress)
const base = getAllTransactionsUriFrom(address)

return `${host}${base}`
return `${host}/${base}`
}

const fetchAllTransactions = async (
Expand Down
2 changes: 1 addition & 1 deletion src/logic/safe/transactions/incomingTxHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export const buildIncomingTxServiceUrl = (safeAddress: string): string => {
const address = checksumAddress(safeAddress)
const base = getIncomingTxServiceUriTo(address)

return `${host}${base}`
return `${host}/${base}`
}
2 changes: 1 addition & 1 deletion src/logic/safe/transactions/txHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const buildTxServiceUrl = (safeAddress: string): string => {
const host = getTxServiceUrl()
const address = checksumAddress(safeAddress)
const base = getTxServiceUriFrom(address)
return `${host}${base}?has_confirmations=True`
return `${host}/${base}?has_confirmations=True`
}

const SUCCESS_STATUS = 201 // CREATED status
Expand Down
24 changes: 24 additions & 0 deletions src/logic/tokens/api/fetchErc20AndErc721AssetsList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import axios, { AxiosResponse } from 'axios'

import { getTxServiceUrl } from 'src/config/index'

type TokenResult = {
address: string
decimals?: number
logoUri: string
name: string
symbol: string
type: string
}

export const fetchErc20AndErc721AssetsList = async (): Promise<AxiosResponse<{ results: TokenResult[] }>> => {
const apiUrl = getTxServiceUrl()

const url = `${apiUrl}/tokens/`

return axios.get<{ results: TokenResult[] }>(url, {
params: {
limit: 3000,
},
})
}
16 changes: 0 additions & 16 deletions src/logic/tokens/api/fetchToken.ts

This file was deleted.

8 changes: 2 additions & 6 deletions src/logic/tokens/api/fetchTokenBalanceList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ import { getTxServiceUrl } from 'src/config/index'

const fetchTokenBalanceList = (safeAddress) => {
const apiUrl = getTxServiceUrl()
const url = `${apiUrl}safes/${safeAddress}/balances/`
const url = `${apiUrl}/safes/${safeAddress}/balances/`

return axios.get(url, {
params: {
limit: 3000,
},
})
return axios.get(url)
}

export default fetchTokenBalanceList
16 changes: 0 additions & 16 deletions src/logic/tokens/api/fetchTokenList.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/logic/tokens/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default as fetchTokenList } from './fetchTokenList'
export { default as fetchToken } from './fetchToken'
export { fetchErc20AndErc721AssetsList } from './fetchErc20AndErc721AssetsList'
10 changes: 6 additions & 4 deletions src/logic/tokens/store/actions/fetchTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import contract from 'truffle-contract'
import saveTokens from './saveTokens'

import generateBatchRequests from 'src/logic/contracts/generateBatchRequests'
import { fetchTokenList } from 'src/logic/tokens/api'
import { fetchErc20AndErc721AssetsList } from 'src/logic/tokens/api'
import { makeToken, Token } from 'src/logic/tokens/store/model/token'
import { tokensSelector } from 'src/logic/tokens/store/selectors'
import { getWeb3 } from 'src/logic/wallets/getWeb3'
Expand Down Expand Up @@ -98,13 +98,15 @@ export const fetchTokens = () => async (

const {
data: { results: tokenList },
} = await fetchTokenList()
} = await fetchErc20AndErc721AssetsList()

if (currentSavedTokens && currentSavedTokens.size === tokenList.length) {
const erc20Tokens = tokenList.filter((token) => token.type.toLowerCase() === 'erc20')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move erc20 string to a constant variable?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's mandatory now. Probably when we work on #1408 we'll address this in a most consistent way.


if (currentSavedTokens?.size === erc20Tokens.length) {
return
}

const tokens = List(tokenList.map((token) => makeToken(token)))
const tokens = List(erc20Tokens.map((token) => makeToken(token)))

dispatch(saveTokens(tokens))
} catch (err) {
Expand Down