Skip to content

Commit

Permalink
feat(erc20): get dynamic fees based on contract address
Browse files Browse the repository at this point in the history
  • Loading branch information
schnogz committed Mar 31, 2021
1 parent 8647ddf commit 88d1971
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
11 changes: 8 additions & 3 deletions packages/blockchain-wallet-v4/src/network/api/eth/index.ts
Expand Up @@ -10,11 +10,16 @@ export default ({ apiUrl, get, post }) => {
endPoint: `/eth/account/${address}/isContract`
})

const getEthFees = () =>
get({
const getEthFees = contractAddress => {
const baseUrl = '/mempool/fees/eth'
return get({
url: apiUrl,
endPoint: '/mempool/fees/eth'
endPoint: contractAddress
? `${baseUrl}?contractAddress=${contractAddress}`
: baseUrl,
ignoreQueryParams: true
})
}

const getEthTicker = () =>
get({
Expand Down
10 changes: 8 additions & 2 deletions packages/blockchain-wallet-v4/src/redux/payment/eth/sagas.ts
Expand Up @@ -133,9 +133,15 @@ export default ({ api }) => {
},

* init({ coin, isErc20 }) {
let fees
let contractAddress, fees
try {
fees = yield call(api.getEthFees)
if (isErc20) {
contractAddress = (yield select(
S.kvStore.eth.getErc20ContractAddr,
toLower(coin)
)).getOrFail('missing_contract_addr')
}
fees = yield call(api.getEthFees, contractAddress)
} catch (e) {
throw new Error(FETCH_FEES_FAILURE)
}
Expand Down

0 comments on commit 88d1971

Please sign in to comment.