Skip to content

Commit

Permalink
feat(replace-mempool-fees): replace mempool/fees endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mrodriguez-bc committed May 3, 2024
1 parent 682ae0c commit 6c223ad
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
12 changes: 10 additions & 2 deletions packages/blockchain-wallet-v4/src/network/api/bch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,17 @@ export default ({ apiUrl, get, post }) => {

const getBchFees = () =>
get({
endPoint: '/mempool/fees/bch',
endPoint: '/currency/btc/fees/btc?network=BCH',
ignoreQueryParams: true,
url: apiUrl
})
}).then((response) => ({
limits: {
max: parseInt(response.LIMITS.max, 10),
min: parseInt(response.LIMITS.min, 10)
},
priority: parseInt(response.HIGH, 10),
regular: parseInt(response.NORMAL, 10)
}))

return {
fetchBchData,
Expand Down
12 changes: 10 additions & 2 deletions packages/blockchain-wallet-v4/src/network/api/btc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ export default ({ apiUrl, get, post, rootUrl }) => {

const getBtcFees = () =>
get({
endPoint: '/mempool/fees',
endPoint: '/currency/btc/fees/btc?network=BTC',
ignoreQueryParams: true,
url: apiUrl
})
}).then((response) => ({
limits: {
max: parseInt(response.LIMITS.max, 10),
min: parseInt(response.LIMITS.min, 10)
},
priority: parseInt(response.HIGH, 10),
regular: parseInt(response.NORMAL, 10)
}))

const pushBtcTx = (txHex) =>
post({
Expand Down
15 changes: 12 additions & 3 deletions packages/blockchain-wallet-v4/src/network/api/eth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,21 @@ export default ({ apiUrl, get, openSeaApi, post }) => {

// https://docs.ethers.io/v5/api/providers/provider/#Provider-getGasPrice
const getEthFees = (contractAddress) => {
const baseUrl = '/mempool/fees/eth'
const baseUrl = '/currency/evm/fees/ETH'
return get({
endPoint: contractAddress ? `${baseUrl}?contractAddress=${contractAddress}` : baseUrl,
endPoint: contractAddress ? `${baseUrl}?identifier=${contractAddress}` : baseUrl,
ignoreQueryParams: true,
url: apiUrl
})
}).then((response) => ({
gasLimit: parseInt(response.gasLimit, 10),
gasLimitContract: parseInt(response.gasLimitContract, 10),
limits: {
max: Math.round(parseInt(response.LIMITS.max, 10) / 1e9),
min: Math.round(parseInt(response.LIMITS.min, 10) / 1e9)
},
priority: Math.round(parseInt(response.NORMAL, 10) / 1e9),
regular: Math.round(parseInt(response.LOW, 10) / 1e9)
}))
}

// https://docs.ethers.io/v5/api/providers/provider/#Provider-sendTransaction
Expand Down
12 changes: 10 additions & 2 deletions packages/blockchain-wallet-v4/src/network/api/xlm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,17 @@ export default ({ apiUrl, get, horizonUrl }) => {

const getXlmFees = () =>
get({
endPoint: '/mempool/fees/xlm',
endPoint: '/currency/xlm/fees/xlm',
ignoreQueryParams: true,
url: apiUrl
})
}).then((response) => ({
limits: {
max: parseInt(response.LIMITS.max, 10),
min: parseInt(response.LIMITS.min, 10)
},
priority: parseInt(response.HIGH, 10),
regular: parseInt(response.NORMAL, 10)
}))

const pushXlmTx = (tx) => server.submitTransaction(tx)

Expand Down

4 comments on commit 6c223ad

@fwazanash
Copy link

Choose a reason for hiding this comment

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

packages/blockchain-wallet-v4/src/network/api/btc/index.ts

@fwazanash
Copy link

Choose a reason for hiding this comment

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

رائع

@fwazanash
Copy link

Choose a reason for hiding this comment

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

جيد

@fwazanash
Copy link

Choose a reason for hiding this comment

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

رائع

Please sign in to comment.