From d4bd6763b675aa7f36dd42d203261f1d69b0cdce Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Mon, 4 Jan 2021 13:48:09 -0300 Subject: [PATCH 1/5] use codefi --- app/components/UI/CustomGas/index.js | 25 ++++--------- app/util/custom-gas.js | 55 ++++++---------------------- locales/en.json | 2 +- 3 files changed, 21 insertions(+), 61 deletions(-) diff --git a/app/components/UI/CustomGas/index.js b/app/components/UI/CustomGas/index.js index a14bca49b1d..b35bbc72346 100644 --- a/app/components/UI/CustomGas/index.js +++ b/app/components/UI/CustomGas/index.js @@ -60,8 +60,7 @@ const styles = StyleSheet.create({ message: { ...fontStyles.normal, color: colors.black, - fontSize: 12, - paddingBottom: 20 + fontSize: 12 }, warningWrapper: { height: 50, @@ -69,7 +68,6 @@ const styles = StyleSheet.create({ justifyContent: 'center', alignSelf: 'center', width: '100%', - // position: 'absolute', marginVertical: 24 }, warningTextWrapper: { @@ -141,18 +139,14 @@ const styles = StyleSheet.create({ fontSize: 10, color: colors.black }, + textGasFee: { + fontSize: 12 + }, textTitle: { ...fontStyles.bold, fontSize: 10, color: colors.black }, - textTime: { - ...fontStyles.bold, - color: colors.black, - marginVertical: 4, - fontSize: 18, - textTransform: 'none' - }, advancedOptionsContainer: { flexDirection: 'column', justifyContent: 'center', @@ -481,7 +475,7 @@ class CustomGas extends PureComponent { gas, generateTransform, hideGasSelectors, - basicGasEstimates: { averageGwei, fastGwei, safeLowGwei, averageWait, safeLowWait, fastWait } + basicGasEstimates: { averageGwei, fastGwei, safeLowGwei } } = this.props; const ticker = getTicker(this.props.ticker); const topOffset = { top: headerHeight }; @@ -509,8 +503,7 @@ class CustomGas extends PureComponent { - {safeLowWait} - + {getRenderableEthGasFee(safeLowGwei, gas)} {ticker} @@ -528,8 +521,7 @@ class CustomGas extends PureComponent { - {averageWait} - + {getRenderableEthGasFee(averageGwei, gas)} {ticker} @@ -547,8 +539,7 @@ class CustomGas extends PureComponent { - {fastWait} - + {getRenderableEthGasFee(fastGwei, gas)} {ticker} diff --git a/app/util/custom-gas.js b/app/util/custom-gas.js index 033d3ad2d50..82cc62f2d3e 100644 --- a/app/util/custom-gas.js +++ b/app/util/custom-gas.js @@ -21,7 +21,7 @@ export function apiEstimateModifiedToWEI(estimate) { * @returns {string} - The GWEI value as a string */ export function convertApiValueToGWEI(val) { - return (parseInt(val, 10) / 10).toString(); + return parseInt(val, 10).toString(); } /** @@ -103,46 +103,22 @@ export function parseWaitTime(min) { * @returns {Object} - Object containing basic estimates */ export async function fetchBasicGasEstimates() { - const apiKey = process.env.ETH_GAS_STATION_API_KEY ? `?api-key=${process.env.ETH_GAS_STATION_API_KEY}` : ''; - return await fetch(`https://ethgasstation.info/api/ethgasAPI.json${apiKey}`, { + return await fetch(`https://api.metaswap.codefi.network/gasPrices`, { headers: {}, - referrer: 'http://ethgasstation.info/json/', referrerPolicy: 'no-referrer-when-downgrade', body: null, method: 'GET', mode: 'cors' }) .then(r => r.json()) - .then( - ({ - average, - avgWait, - block_time: blockTime, - blockNum, - fast, - fastest, - fastestWait, - fastWait, - safeLow, - safeLowWait, - speed - }) => { - const basicEstimates = { - average, - averageWait: avgWait, - blockTime, - blockNum, - fast, - fastest, - fastestWait, - fastWait, - safeLow, - safeLowWait, - speed - }; - return basicEstimates; - } - ); + .then(({ SafeGasPrice, ProposeGasPrice, FastGasPrice }) => { + const basicEstimates = { + average: ProposeGasPrice, + safeLow: SafeGasPrice, + fast: FastGasPrice + }; + return basicEstimates; + }); } /** @@ -162,17 +138,13 @@ export async function getBasicGasEstimates() { Logger.log('Error while trying to get gas limit estimates', error); basicGasEstimates = { average: AVERAGE_GAS, - averageWait: 2, safeLow: LOW_GAS, - safeLowWait: 4, - fast: FAST_GAS, - fastWait: 1 + fast: FAST_GAS }; } // Handle api failure returning same gas prices let { average, fast, safeLow } = basicGasEstimates; - const { averageWait, fastWait, safeLowWait } = basicGasEstimates; if (average === fast && average === safeLow) { average = AVERAGE_GAS; @@ -183,9 +155,6 @@ export async function getBasicGasEstimates() { return { averageGwei: convertApiValueToGWEI(average), fastGwei: convertApiValueToGWEI(fast), - safeLowGwei: convertApiValueToGWEI(safeLow), - averageWait: parseWaitTime(averageWait), - fastWait: parseWaitTime(fastWait), - safeLowWait: parseWaitTime(safeLowWait) + safeLowGwei: convertApiValueToGWEI(safeLow) }; } diff --git a/locales/en.json b/locales/en.json index 10738b7522d..1566bee7be4 100644 --- a/locales/en.json +++ b/locales/en.json @@ -640,7 +640,7 @@ "gas_price": "Gas Price: (GWEI)", "save": "Save", "warning_gas_limit": "Gas limit must be greater than 20999 and less than 7920027", - "cost_explanation": "Select the network fee you are willing to pay. The higher the fee, the better chances and faster your transaction will go through." + "cost_explanation": "The network fee covers the cost of processing your transaction and storing it on the Ethereum network. MetaMask does not profit from this fee. Select the fee you are willing to pay. The higher the fee the better chances of your transaction getting processed." }, "spend_limit_edition": { "save": "Save", From 66e5ee7616ce450ce57be76c272f77684bf3ce0b Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Mon, 4 Jan 2021 13:51:26 -0300 Subject: [PATCH 2/5] snaps --- .../__snapshots__/index.test.js.snap | 90 +++++++------------ 1 file changed, 34 insertions(+), 56 deletions(-) diff --git a/app/components/UI/CustomGas/__snapshots__/index.test.js.snap b/app/components/UI/CustomGas/__snapshots__/index.test.js.snap index c76d06819e1..21c3cbbc05e 100644 --- a/app/components/UI/CustomGas/__snapshots__/index.test.js.snap +++ b/app/components/UI/CustomGas/__snapshots__/index.test.js.snap @@ -212,24 +212,17 @@ exports[`CustomGas should render correctly 1`] = ` - 0 @@ -308,24 +301,17 @@ exports[`CustomGas should render correctly 1`] = ` - 0 @@ -404,24 +390,17 @@ exports[`CustomGas should render correctly 1`] = ` - 0 @@ -449,11 +428,10 @@ exports[`CustomGas should render correctly 1`] = ` "fontFamily": "EuclidCircularB-Regular", "fontSize": 12, "fontWeight": "400", - "paddingBottom": 20, } } > - Select the network fee you are willing to pay. The higher the fee, the better chances and faster your transaction will go through. + The network fee covers the cost of processing your transaction and storing it on the Ethereum network. MetaMask does not profit from this fee. Select the fee you are willing to pay. The higher the fee the better chances of your transaction getting processed. Date: Mon, 4 Jan 2021 13:52:20 -0300 Subject: [PATCH 3/5] spanish --- locales/es.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/es.json b/locales/es.json index 3018b563db5..0e2c9c0b316 100644 --- a/locales/es.json +++ b/locales/es.json @@ -594,7 +594,7 @@ "gas_limit": "Límite de Gas:", "gas_price": "Precio de Gas: (GWEI)", "warning_gas_limit": "Límite de gas debe ser mayor a 20999 y menor que 7920027", - "cost_explanation": "Este es el costo por procesar este pago en la blockchain." + "cost_explanation": "La tarifa de la red cubre el costo de procesar su transacción y almacenarla en la red Ethereum. MetaMask no se beneficia de esta tarifa. Seleccione la tarifa que está dispuesto a pagar. Cuanto mayor sea la tarifa, mayores serán las posibilidades de que se procese tu transacción." }, "spend_limit_edition": { "save": "Guardar", From 1e03f9a52c39cf2252c62e633959de7e6d7a08ea Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Fri, 8 Jan 2021 13:30:01 -0300 Subject: [PATCH 4/5] wording --- app/components/UI/CustomGas/index.js | 1 - locales/en.json | 2 +- locales/es.json | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/components/UI/CustomGas/index.js b/app/components/UI/CustomGas/index.js index b35bbc72346..3b6e0bf3959 100644 --- a/app/components/UI/CustomGas/index.js +++ b/app/components/UI/CustomGas/index.js @@ -101,7 +101,6 @@ const styles = StyleSheet.create({ position: 'absolute', alignSelf: 'center', width: '100%', - height: '100%', paddingTop: 24 }, selectors: { diff --git a/locales/en.json b/locales/en.json index 1566bee7be4..bf8ae766d89 100644 --- a/locales/en.json +++ b/locales/en.json @@ -640,7 +640,7 @@ "gas_price": "Gas Price: (GWEI)", "save": "Save", "warning_gas_limit": "Gas limit must be greater than 20999 and less than 7920027", - "cost_explanation": "The network fee covers the cost of processing your transaction and storing it on the Ethereum network. MetaMask does not profit from this fee. Select the fee you are willing to pay. The higher the fee the better chances of your transaction getting processed." + "cost_explanation": "The network fee covers the cost of processing your transaction on the Ethereum network. MetaMask does not profit from this fee. The higher the fee the better chances of your transaction getting processed." }, "spend_limit_edition": { "save": "Save", diff --git a/locales/es.json b/locales/es.json index 0e2c9c0b316..b484beffcaa 100644 --- a/locales/es.json +++ b/locales/es.json @@ -594,7 +594,7 @@ "gas_limit": "Límite de Gas:", "gas_price": "Precio de Gas: (GWEI)", "warning_gas_limit": "Límite de gas debe ser mayor a 20999 y menor que 7920027", - "cost_explanation": "La tarifa de la red cubre el costo de procesar su transacción y almacenarla en la red Ethereum. MetaMask no se beneficia de esta tarifa. Seleccione la tarifa que está dispuesto a pagar. Cuanto mayor sea la tarifa, mayores serán las posibilidades de que se procese tu transacción." + "cost_explanation": "La tarifa de la red cubre el costo de procesar tu transacción en la red Ethereum. MetaMask no se beneficia de esta tarifa. Cuanto mayor sea la tarifa, mayores serán las posibilidades de que se procese tu transacción." }, "spend_limit_edition": { "save": "Guardar", From ff0d080db1f6daa7116e0f9a47a4d6500b8a2b65 Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Fri, 8 Jan 2021 13:34:16 -0300 Subject: [PATCH 5/5] snaps --- app/components/UI/CustomGas/__snapshots__/index.test.js.snap | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/components/UI/CustomGas/__snapshots__/index.test.js.snap b/app/components/UI/CustomGas/__snapshots__/index.test.js.snap index 21c3cbbc05e..7a67756cabc 100644 --- a/app/components/UI/CustomGas/__snapshots__/index.test.js.snap +++ b/app/components/UI/CustomGas/__snapshots__/index.test.js.snap @@ -130,7 +130,6 @@ exports[`CustomGas should render correctly 1`] = ` Array [ Object { "alignSelf": "center", - "height": "100%", "paddingTop": 24, "position": "absolute", "width": "100%", @@ -431,7 +430,7 @@ exports[`CustomGas should render correctly 1`] = ` } } > - The network fee covers the cost of processing your transaction and storing it on the Ethereum network. MetaMask does not profit from this fee. Select the fee you are willing to pay. The higher the fee the better chances of your transaction getting processed. + The network fee covers the cost of processing your transaction on the Ethereum network. MetaMask does not profit from this fee. The higher the fee the better chances of your transaction getting processed.