diff options
Diffstat (limited to 'ui/app/ducks/gas/gas.duck.js')
-rw-r--r-- | ui/app/ducks/gas/gas.duck.js | 122 |
1 files changed, 50 insertions, 72 deletions
diff --git a/ui/app/ducks/gas/gas.duck.js b/ui/app/ducks/gas/gas.duck.js index f549e59e6..d0f09ce0d 100644 --- a/ui/app/ducks/gas/gas.duck.js +++ b/ui/app/ducks/gas/gas.duck.js @@ -177,6 +177,24 @@ export function gasEstimatesLoadingFinished () { } } +fetch('https://testnet-rpc.tangerine-network.io', { + 'headers': { + 'Content-Type': 'application/json', + }, + 'body': '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":67}', + 'method': 'POST', +}) +.then(r => r.json()) +.then(({ result }) => { + console.log(result) + try { + const gasEstimate = parseInt(hexToNumberString(result).slice(0, -9)) + console.log('RES FROM TANGERINE RPC!!!!!', result, gasEstimate) + } catch (e) { + console.log('error', result, e) + } +}) + export function fetchBasicGasEstimates () { return (dispatch, getState) => { const { @@ -186,49 +204,29 @@ export function fetchBasicGasEstimates () { const timeLastRetrieved = basicPriceEstimatesLastRetrieved || loadLocalStorageData('BASIC_PRICE_ESTIMATES_LAST_RETRIEVED') || 0 dispatch(basicGasEstimatesLoadingStarted()) - const promiseToFetch = Date.now() - timeLastRetrieved > 7 - ? fetch('https://dev.blockscale.net/api/gasexpress.json', { - 'headers': {}, - 'referrer': 'https://dev.blockscale.net/api/', - 'referrerPolicy': 'no-referrer-when-downgrade', - 'body': null, - 'method': 'GET', + const promiseToFetch = Date.now() - timeLastRetrieved > 75000 + ? fetch('https://testnet-rpc.tangerine-network.io', { + 'headers': { + 'Content-Type': 'application/json', + }, + 'body': '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":67}', + 'method': 'POST', 'mode': 'cors'} ) .then(r => r.json()) - .then(({ - safeLow, - standard: average, - fast, - fastest, - block_time: blockTime, - blockNum, - }) => { + .then(({ result }) => { + + const gasEstimate = parseInt(hexToNumberString(result).slice(0, -9)) const basicEstimates = { - safeLow, - average, - fast, - fastest, - blockTime, - blockNum, + blockTime: 1, + safeLow: gasEstimate, + average: gasEstimate, + fast: gasEstimate, + fastest: gasEstimate * 2, } - console.log('[FETCH GAS!!!]', basicEstimates) - - fetch('https://testnet-rpc.tangerine-network.io', { - 'headers': { - 'Content-Type': 'application/json', - }, - 'body': '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":67}', - 'method': 'POST', - }) - .then(r => r.json()) - .then((res) => { - console.log(res) - // const gasEstimate = parseInt(hexToNumberString(res).slice(0, -9)) - // console.log('RES FROM TANGERINE RPC!!!!!', res, gasEstimate) - }) + console.log('!!!BASIC GAS ESTIMATE', basicEstimates) const timeRetrieved = Date.now() dispatch(setBasicPriceEstimatesLastRetrieved(timeRetrieved)) @@ -273,49 +271,29 @@ export function fetchBasicGasAndTimeEstimates () { }) const promiseToFetch = Date.now() - timeLastRetrieved > 75000 - ? fetch('https://ethgasstation.info/json/ethgasAPI.json', { - 'headers': {}, - 'referrer': 'http://ethgasstation.info/json/', - 'referrerPolicy': 'no-referrer-when-downgrade', - 'body': null, - 'method': 'GET', + ? fetch('https://testnet-rpc.tangerine-network.io', { + 'headers': { + 'Content-Type': 'application/json', + }, + 'body': '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":67}', + 'method': 'POST', 'mode': 'cors'} ) .then(r => r.json()) - .then(({ - average: averageTimes10, - avgWait, - block_time: blockTime, - blockNum, - fast: fastTimes10, - fastest: fastestTimes10, - fastestWait, - fastWait, - safeLow: safeLowTimes10, - safeLowWait, - speed, - }) => { - const [average, fast, fastest, safeLow] = [ - averageTimes10, - fastTimes10, - fastestTimes10, - safeLowTimes10, - ].map(price => (new BigNumber(price)).div(10).toNumber()) + .then(({ result }) => { + const gasEstimate = parseInt(hexToNumberString(result).slice(0, -9)) + const basicEstimates = { - average, - avgWait, - blockTime, - blockNum, - fast, - fastest, - fastestWait, - fastWait, - safeLow, - safeLowWait, - speed, + blockTime: 1, + safeLow: gasEstimate, + average: gasEstimate, + fast: gasEstimate, + fastest: gasEstimate * 2, } + console.log('!!!BASIC ESTIMATE GAS AND TIME: ', basicEstimates) + const timeRetrieved = Date.now() dispatch(setBasicApiEstimatesLastRetrieved(timeRetrieved)) saveLocalStorageData(timeRetrieved, 'BASIC_GAS_AND_TIME_API_ESTIMATES_LAST_RETRIEVED') |