Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove blockscale, replace with ethgasstation #7059

Merged
merged 1 commit into from
Aug 22, 2019
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
24 changes: 12 additions & 12 deletions ui/app/ducks/gas/gas-duck.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,10 @@ describe('Gas Duck', () => {
assert.deepEqual(
global.fetch.getCall(0).args,
[
'https://dev.blockscale.net/api/gasexpress.json',
'https://ethgasstation.info/json/ethgasAPI.json',
{
'headers': {},
'referrer': 'https://dev.blockscale.net/api/',
'referrer': 'http://ethgasstation.info/json/',
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious to know why http is used here instead of https. I noticed other fetches to ethgasstation set this referrer as well.

'referrerPolicy': 'no-referrer-when-downgrade',
'body': null,
'method': 'GET',
Expand All @@ -341,12 +341,12 @@ describe('Gas Duck', () => {
[{
type: SET_BASIC_GAS_ESTIMATE_DATA,
value: {
average: 20,
average: 2,
blockTime: 'mockBlock_time',
blockNum: 'mockBlockNum',
fast: 30,
fastest: 40,
safeLow: 10,
fast: 3,
fastest: 4,
safeLow: 1,
},
}]
)
Expand Down Expand Up @@ -420,10 +420,10 @@ describe('Gas Duck', () => {
assert.deepEqual(
global.fetch.getCall(0).args,
[
'https://dev.blockscale.net/api/gasexpress.json',
'https://ethgasstation.info/json/ethgasAPI.json',
{
'headers': {},
'referrer': 'https://dev.blockscale.net/api/',
'referrer': 'http://ethgasstation.info/json/',
'referrerPolicy': 'no-referrer-when-downgrade',
'body': null,
'method': 'GET',
Expand All @@ -440,12 +440,12 @@ describe('Gas Duck', () => {
[{
type: SET_BASIC_GAS_ESTIMATE_DATA,
value: {
average: 20,
average: 2,
blockTime: 'mockBlock_time',
blockNum: 'mockBlockNum',
fast: 30,
fastest: 40,
safeLow: 10,
fast: 3,
fastest: 4,
safeLow: 1,
},
}]
)
Expand Down
29 changes: 19 additions & 10 deletions ui/app/ducks/gas/gas.duck.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,23 +198,31 @@ export function fetchBasicGasEstimates () {
}

async function fetchExternalBasicGasEstimates (dispatch) {
const response = await fetch('https://dev.blockscale.net/api/gasexpress.json', {
const response = await fetch('https://ethgasstation.info/json/ethgasAPI.json', {
'headers': {},
'referrer': 'https://dev.blockscale.net/api/',
'referrer': 'http://ethgasstation.info/json/',
'referrerPolicy': 'no-referrer-when-downgrade',
'body': null,
'method': 'GET',
'mode': 'cors'}
)
'mode': 'cors',
})

const {
safeLow,
standard: average,
fast,
fastest,
safeLow: safeLowTimes10,
average: averageTimes10,
fast: fastTimes10,
fastest: fastestTimes10,
block_time: blockTime,
blockNum,
} = await response.json()

const [average, fast, fastest, safeLow] = [
averageTimes10,
fastTimes10,
fastestTimes10,
safeLowTimes10,
].map(price => (new BigNumber(price)).div(10).toNumber())

const basicEstimates = {
safeLow,
average,
Expand Down Expand Up @@ -260,8 +268,9 @@ async function fetchExternalBasicGasAndTimeEstimates (dispatch) {
'referrerPolicy': 'no-referrer-when-downgrade',
'body': null,
'method': 'GET',
'mode': 'cors'}
)
'mode': 'cors',
})

const {
average: averageTimes10,
avgWait,
Expand Down
34 changes: 17 additions & 17 deletions ui/app/selectors/custom-gas.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ function getRenderableBasicEstimateData (state, gasLimit) {
gas: {
basicEstimates: {
safeLow,
average,
fast,
fastest,
safeLowWait,
fastestWait,
avgWait,
fastWait,
},
},
Expand All @@ -260,21 +260,21 @@ function getRenderableBasicEstimateData (state, gasLimit) {
},
{
labelKey: 'average',
feeInPrimaryCurrency: getRenderableEthFee(fast, gasLimit),
feeInPrimaryCurrency: getRenderableEthFee(average, gasLimit),
feeInSecondaryCurrency: showFiat
? getRenderableConvertedCurrencyFee(fast, gasLimit, currentCurrency, conversionRate)
? getRenderableConvertedCurrencyFee(average, gasLimit, currentCurrency, conversionRate)
: '',
timeEstimate: fastWait && getRenderableTimeEstimate(fastWait),
priceInHexWei: getGasPriceInHexWei(fast),
timeEstimate: avgWait && getRenderableTimeEstimate(avgWait),
priceInHexWei: getGasPriceInHexWei(average),
},
{
labelKey: 'fast',
feeInPrimaryCurrency: getRenderableEthFee(fastest, gasLimit),
feeInPrimaryCurrency: getRenderableEthFee(fast, gasLimit),
feeInSecondaryCurrency: showFiat
? getRenderableConvertedCurrencyFee(fastest, gasLimit, currentCurrency, conversionRate)
? getRenderableConvertedCurrencyFee(fast, gasLimit, currentCurrency, conversionRate)
: '',
timeEstimate: fastestWait && getRenderableTimeEstimate(fastestWait),
priceInHexWei: getGasPriceInHexWei(fastest),
timeEstimate: fastWait && getRenderableTimeEstimate(fastWait),
priceInHexWei: getGasPriceInHexWei(fast),
},
]
}
Expand All @@ -294,8 +294,8 @@ function getRenderableEstimateDataForSmallButtonsFromGWEI (state) {
gas: {
basicEstimates: {
safeLow,
average,
fast,
fastest,
},
},
} = state
Expand All @@ -312,18 +312,18 @@ function getRenderableEstimateDataForSmallButtonsFromGWEI (state) {
{
labelKey: 'average',
feeInSecondaryCurrency: showFiat
? getRenderableConvertedCurrencyFee(fast, gasLimit, currentCurrency, conversionRate)
? getRenderableConvertedCurrencyFee(average, gasLimit, currentCurrency, conversionRate)
: '',
feeInPrimaryCurrency: getRenderableEthFee(fast, gasLimit, NUMBER_OF_DECIMALS_SM_BTNS, true),
priceInHexWei: getGasPriceInHexWei(fast, true),
feeInPrimaryCurrency: getRenderableEthFee(average, gasLimit, NUMBER_OF_DECIMALS_SM_BTNS, true),
priceInHexWei: getGasPriceInHexWei(average, true),
},
{
labelKey: 'fast',
feeInSecondaryCurrency: showFiat
? getRenderableConvertedCurrencyFee(fastest, gasLimit, currentCurrency, conversionRate)
? getRenderableConvertedCurrencyFee(fast, gasLimit, currentCurrency, conversionRate)
: '',
feeInPrimaryCurrency: getRenderableEthFee(fastest, gasLimit, NUMBER_OF_DECIMALS_SM_BTNS, true),
priceInHexWei: getGasPriceInHexWei(fastest, true),
feeInPrimaryCurrency: getRenderableEthFee(fast, gasLimit, NUMBER_OF_DECIMALS_SM_BTNS, true),
priceInHexWei: getGasPriceInHexWei(fast, true),
},
]
}
Loading