diff --git a/app/scripts/controllers/transactions/tx-gas-utils.js b/app/scripts/controllers/transactions/tx-gas-utils.js index a667f8112eda..3f17475e28b1 100644 --- a/app/scripts/controllers/transactions/tx-gas-utils.js +++ b/app/scripts/controllers/transactions/tx-gas-utils.js @@ -129,14 +129,14 @@ class TxGasUtil { } /** - Writes the gas/stroage on the txParams in the txMeta + Writes the gas/storage on the txParams in the txMeta @param {Object} txMeta - the txMeta object to write to @param {string} blockGasLimitHex - the block gas limit hex @param {string} estimatedGasHex - the estimated gas hex */ setTxGas (txMeta, blockGasLimitHex, { estimatedGasHex, estimatedStorageHex }) { txMeta.estimatedGas = addHexPrefix(estimatedGasHex) - txMeta.estimatedStroage = addHexPrefix(estimatedStorageHex) + txMeta.estimatedStorage = addHexPrefix(estimatedStorageHex) const txParams = txMeta.txParams if (txMeta.simpleSend) { @@ -165,7 +165,7 @@ class TxGasUtil { txParams.gas = recommendedGasHex if (!txMeta.storageLimitSpecified) { - txParams.storageLimit = txMeta.estimatedStroage + txParams.storageLimit = txMeta.estimatedStorage } return } diff --git a/development/local-node.js b/development/local-node.js index 7bffbf891fae..782b23497c90 100644 --- a/development/local-node.js +++ b/development/local-node.js @@ -13,6 +13,11 @@ const ganacheserver = new Ganache({ verbose: true, genBlockInterval: 300, killPo '0x21041DD5AEBE8CD184965BA4AAE490F3B0C2500D87306FE9F32E276757BFDA68', balance: 1e23, }, + { + secretKey: + '0x32A0D91B3930E625501C11F959BCBA312121A181C315751EA219813EDB0822A3', + balance: 1e20, + }, ], }) })() diff --git a/package.json b/package.json index 11019fec8e17..0d8acf9c63a5 100644 --- a/package.json +++ b/package.json @@ -129,7 +129,7 @@ "gaba": "^1.10.0", "human-standard-token-abi": "^2.0.0", "jazzicon": "^2.0.0", - "js-conflux-sdk": "^0.9.0-alpha", + "js-conflux-sdk": "^0.9.1", "json-rpc-engine": "^5.1.6", "json-rpc-middleware-stream": "^2.1.1", "jsonschema": "^1.2.4", diff --git a/test/e2e/address-book.spec.js b/test/e2e/address-book.spec.js index 0abbcb42e43a..abb905403805 100644 --- a/test/e2e/address-book.spec.js +++ b/test/e2e/address-book.spec.js @@ -22,7 +22,7 @@ describe('MetaMask', function () { accounts: [ { secretKey: - '0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9', + '0x57ED903454DEC7321ABB1729A7A3BB0F39B617109F610A74F9B402AAEF955333', balance: 25000000000000000000, }, ], @@ -208,7 +208,7 @@ describe('MetaMask', function () { const inputAddress = await driver.findElement( By.css('input[placeholder="Search, public address (0x)"]') ) - await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970') + await inputAddress.sendKeys('0x1f318c334780961fb129d2a6c30d0763d9a5c970') await driver.delay(regularDelayMs) await driver.clickElement(By.css('.dialog.send__dialog.dialog--message')) diff --git a/test/e2e/contract-test/contract.js b/test/e2e/contract-test/contract.js index f3093c16dbb0..8f476421b574 100644 --- a/test/e2e/contract-test/contract.js +++ b/test/e2e/contract-test/contract.js @@ -180,7 +180,7 @@ const initialize = () => { type: 'constructor', }, ], - code: PiggyBankContractCode, + bytecode: PiggyBankContractCode, }) deployButton.onclick = async () => { contractStatus.innerHTML = 'Deploying' @@ -189,7 +189,6 @@ const initialize = () => { .constructor() .sendTransaction({ from: accounts[0], - storageLimit: 700, gasPrice: 10000000000, }) .confirmed() @@ -213,7 +212,6 @@ const initialize = () => { depositButton.onclick = async () => { contractStatus.innerHTML = 'Deposit initiated' - console.log(piggybankContract.deposit()) const depositResult = await piggybankContract .deposit() .sendTransaction({ @@ -231,6 +229,8 @@ const initialize = () => { .withdraw('0xde0b6b3a7640000') .sendTransaction({ from: accounts[0], + gas: 600000, + storageLimit: 0, gasPrice: 10000000000, }) .confirmed() @@ -413,7 +413,7 @@ const initialize = () => { type: 'event', }, ], - code: HumanStandardTokenContractCode, + bytecode: HumanStandardTokenContractCode, }) const humanstandardtoken = await humanstandardtokenContract @@ -480,7 +480,6 @@ const initialize = () => { .sendTransaction({ from: accounts[0], to: humanstandardtokenContract.address, - gas: 60000, gasPrice: 10000000000, }) .confirmed() diff --git a/test/e2e/ethereum-on.spec.js b/test/e2e/ethereum-on.spec.js index b59f1640725c..bda293003fc6 100644 --- a/test/e2e/ethereum-on.spec.js +++ b/test/e2e/ethereum-on.spec.js @@ -21,7 +21,7 @@ describe('MetaMask', function () { accounts: [ { secretKey: - '0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9', + '0x57ED903454DEC7321ABB1729A7A3BB0F39B617109F610A74F9B402AAEF955333', balance: 25000000000000000000, }, ], diff --git a/test/e2e/from-import-ui.spec.js b/test/e2e/from-import-ui.spec.js index 68510e2f46bc..ce55af8c93a3 100644 --- a/test/e2e/from-import-ui.spec.js +++ b/test/e2e/from-import-ui.spec.js @@ -14,7 +14,7 @@ describe('Using MetaMask with an existing account', function () { const testSeedPhrase = 'forum vessel pink push lonely enact gentle tail admit parrot grunt dress' - const testAddress = '0x0Cc5261AB8cE458dc977078A3623E2BaDD27afD3' + const testAddress = '0x1B5367BB0215070aD6EEF31576bbbB58B024A65c' const testPrivateKey2 = '14abe6f4aab7f9f626fe981c864d0adeb5685f289ac9270c27b8fd790b4235d6' const testPrivateKey3 = @@ -28,7 +28,7 @@ describe('Using MetaMask with an existing account', function () { accounts: [ { secretKey: - '0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9', + '0x57ED903454DEC7321ABB1729A7A3BB0F39B617109F610A74F9B402AAEF955333', balance: 25000000000000000000, }, ], @@ -225,7 +225,7 @@ describe('Using MetaMask with an existing account', function () { const inputAddress = await driver.findElement( By.css('input[placeholder="Search, public address (0x)"]') ) - await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970') + await inputAddress.sendKeys('0x1f318c334780961fb129d2a6c30d0763d9a5c970') const inputAmount = await driver.findElement(By.css('.unit-input__input')) await inputAmount.sendKeys('1') diff --git a/test/e2e/incremental-security.spec.js b/test/e2e/incremental-security.spec.js index c879f164507a..16199b1e68a7 100644 --- a/test/e2e/incremental-security.spec.js +++ b/test/e2e/incremental-security.spec.js @@ -26,7 +26,7 @@ describe('MetaMask', function () { }, { secretKey: - '0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9', + '0x57ED903454DEC7321ABB1729A7A3BB0F39B617109F610A74F9B402AAEF955333', balance: 25000000000000000000, }, ], diff --git a/test/e2e/metamask-responsive-ui.spec.js b/test/e2e/metamask-responsive-ui.spec.js index 5cd28d1d16f3..5534cbcfec8c 100644 --- a/test/e2e/metamask-responsive-ui.spec.js +++ b/test/e2e/metamask-responsive-ui.spec.js @@ -23,7 +23,7 @@ describe('MetaMask', function () { accounts: [ { secretKey: - '0x4CFD3E90FC78B0F86BF7524722150BB8DA9C60CD532564D7FF43F5716514F553', + '0xA7C2DFA78CCA35B33EBC3728BD6229D18A64C95B38E364A9CCE05FF5F832E5D2', balance: 100000000000000000000, }, ], @@ -231,7 +231,7 @@ describe('MetaMask', function () { const inputAddress = await driver.findElement( By.css('input[placeholder="Search, public address (0x)"]') ) - await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970') + await inputAddress.sendKeys('0x1f318c334780961fb129d2a6c30d0763d9a5c970') const inputAmount = await driver.findElement(By.css('.unit-input__input')) await inputAmount.sendKeys('1') diff --git a/test/e2e/metamask-ui.spec.js b/test/e2e/metamask-ui.spec.js index 5a1e8a339fab..fba4326892c3 100644 --- a/test/e2e/metamask-ui.spec.js +++ b/test/e2e/metamask-ui.spec.js @@ -24,7 +24,7 @@ describe('MetaMask', function () { accounts: [ { secretKey: - '0x4CFD3E90FC78B0F86BF7524722150BB8DA9C60CD532564D7FF43F5716514F553', + '0xA7C2DFA78CCA35B33EBC3728BD6229D18A64C95B38E364A9CCE05FF5F832E5D2', balance: 100000000000000000000, }, ], @@ -280,17 +280,18 @@ describe('MetaMask', function () { const inputAddress = await driver.findElement( By.css('input[placeholder="Search, public address (0x)"]') ) - await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970') + await inputAddress.sendKeys('0x1f318c334780961fb129d2a6c30d0763d9a5c970') const inputAmount = await driver.findElement(By.css('.unit-input__input')) await inputAmount.sendKeys('1000') + await driver.delay(tinyDelayMs) const errorAmount = await driver.findElement( - By.css('.send-v2__error-amount') + By.css('.advanced-gas-inputs__gas-edit-row__error-text') ) assert.equal( await errorAmount.getText(), - 'Insufficient funds.', + 'Insufficient balance.', 'send screen should render an insufficient fund error message' ) @@ -365,7 +366,7 @@ describe('MetaMask', function () { const inputAddress = await driver.findElement( By.css('input[placeholder="Search, public address (0x)"]') ) - await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970') + await inputAddress.sendKeys('0x1f318c334780961fb129d2a6c30d0763d9a5c970') const inputAmount = await driver.findElement(By.css('.unit-input__input')) await inputAmount.sendKeys('1') @@ -417,7 +418,7 @@ describe('MetaMask', function () { const inputAddress = await driver.findElement( By.css('input[placeholder="Search, public address (0x)"]') ) - await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970') + await inputAddress.sendKeys('0x1f318c334780961fb129d2a6c30d0763d9a5c970') const inputAmount = await driver.findElement(By.css('.unit-input__input')) await inputAmount.sendKeys('1') @@ -1188,7 +1189,7 @@ describe('MetaMask', function () { const inputAddress = await driver.findElement( By.css('input[placeholder="Search, public address (0x)"]') ) - await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970') + await inputAddress.sendKeys('0x1f318c334780961fb129d2a6c30d0763d9a5c970') const inputAmount = await driver.findElement(By.css('.unit-input__input')) await inputAmount.sendKeys('1') @@ -1239,7 +1240,7 @@ describe('MetaMask', function () { await driver.delay(regularDelayMs) assert( confirmDataText.match( - /0xa9059cbb0000000000000000000000002f318c334780961fb129d2a6c30d0763d9a5c97/ + /0xa9059cbb0000000000000000000000001f318c334780961fb129d2a6c30d0763d9a5c97/ ) ) @@ -1483,7 +1484,7 @@ describe('MetaMask', function () { const confirmDataText = await confirmDataDiv.getText() assert( confirmDataText.match( - /0x095ea7b30000000000000000000000009bc5baf874d2da8d216ae9f137804184ee5afef4/ + /0x095ea7b30000000000000000000000008bc5baf874d2da8d216ae9f137804184ee5afef4/ ) ) }) @@ -1539,7 +1540,7 @@ describe('MetaMask', function () { '.confirm-approve-content__transaction-details-content__secondary-fee' ) ) - assert.equal(await gasAndCollateralFeeInEth.getText(), '0.0006 CFX') + assert.equal(await gasAndCollateralFeeInEth.getText(), '0.0631 CFX') }) it('edits the permission', async function () { @@ -1716,7 +1717,7 @@ describe('MetaMask', function () { By.css('.confirm-approve-content__medium-text') ) const recipientDiv = permissionInfo[1] - assert.equal(await recipientDiv.getText(), '0x2f318C33...C970') + assert.equal(await recipientDiv.getText(), '0x1f318c33...C970') }) it('submits the transaction', async function () { diff --git a/test/e2e/permissions.spec.js b/test/e2e/permissions.spec.js index eca171ff837c..591edbd8cda4 100644 --- a/test/e2e/permissions.spec.js +++ b/test/e2e/permissions.spec.js @@ -21,7 +21,7 @@ describe('MetaMask', function () { accounts: [ { secretKey: - '0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9', + '0x57ED903454DEC7321ABB1729A7A3BB0F39B617109F610A74F9B402AAEF955333', balance: 25000000000000000000, }, ], diff --git a/test/e2e/send-edit.spec.js b/test/e2e/send-edit.spec.js index fa9254239f12..d70096e251ff 100644 --- a/test/e2e/send-edit.spec.js +++ b/test/e2e/send-edit.spec.js @@ -23,7 +23,7 @@ describe('Using MetaMask with an existing account', function () { accounts: [ { secretKey: - '0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9', + '0x57ED903454DEC7321ABB1729A7A3BB0F39B617109F610A74F9B402AAEF955333', balance: 25000000000000000000, }, ], @@ -119,7 +119,7 @@ describe('Using MetaMask with an existing account', function () { const inputAddress = await driver.findElement( By.css('input[placeholder="Search, public address (0x)"]') ) - await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970') + await inputAddress.sendKeys('0x1f318c334780961fb129d2a6c30d0763d9a5c970') const inputAmount = await driver.findElement(By.css('.unit-input__input')) await inputAmount.sendKeys('1') diff --git a/test/e2e/signature-request.spec.js b/test/e2e/signature-request.spec.js index 0eae81955b10..87bf1a95ce24 100644 --- a/test/e2e/signature-request.spec.js +++ b/test/e2e/signature-request.spec.js @@ -25,7 +25,7 @@ describe('MetaMask', function () { await fixtureServer.loadState( path.join(__dirname, 'fixtures', 'imported-account') ) - publicAddress = '0x5cfe73b6021e818b776b421b1c4db2474086a7e1' + publicAddress = '0x1494e65ac65e076c4297a60d929ca5d3db7701b3' const result = await buildWebDriver() driver = result.driver }) diff --git a/test/e2e/tests/simple-send.spec.js b/test/e2e/tests/simple-send.spec.js index 4033337c98c7..9e410e334bc9 100644 --- a/test/e2e/tests/simple-send.spec.js +++ b/test/e2e/tests/simple-send.spec.js @@ -25,7 +25,7 @@ describe('MetaMask Browser Extension', function () { By.css('[data-testid="ens-input"]') ) await recipientAddressField.sendKeys( - '0x985c30949c92df7a0bd42e0f3e3d539ece98db24' + '0x185c30949c92df7a0bd42e0f3e3d539ece98db24' ) const amountField = await driver.findElement( By.css('.unit-input__input') diff --git a/test/e2e/threebox.spec.js b/test/e2e/threebox.spec.js index f2bd86a78201..e4d2b6e0fd8a 100644 --- a/test/e2e/threebox.spec.js +++ b/test/e2e/threebox.spec.js @@ -24,7 +24,7 @@ describe('MetaMask', function () { accounts: [ { secretKey: - '0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9', + '0x57ED903454DEC7321ABB1729A7A3BB0F39B617109F610A74F9B402AAEF955333', balance: 25000000000000000000, }, ], @@ -166,7 +166,7 @@ describe('MetaMask', function () { await driver.delay(tinyDelayMs) await addAddressInputs[1].sendKeys( - '0x2f318C334780961FB129D2a6c30D0763d9a5C970' + '0x1f318c334780961fb129d2a6c30d0763d9a5c970' ) await driver.delay(largeDelayMs * 2) diff --git a/ui/app/components/app/gas-customization/gas-modal-page-container/advanced-tab-content/advanced-tab-content.component.js b/ui/app/components/app/gas-customization/gas-modal-page-container/advanced-tab-content/advanced-tab-content.component.js index c0156a0e186f..5311f1d969c2 100644 --- a/ui/app/components/app/gas-customization/gas-modal-page-container/advanced-tab-content/advanced-tab-content.component.js +++ b/ui/app/components/app/gas-customization/gas-modal-page-container/advanced-tab-content/advanced-tab-content.component.js @@ -1,8 +1,8 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import { decGWEIToHexWEI } from '../../../../../helpers/utils/conversions.util' -import Loading from '../../../../ui/loading-screen' -import GasPriceChart from '../../gas-price-chart' +// import Loading from '../../../../ui/loading-screen' +// import GasPriceChart from '../../gas-price-chart' import AdvancedGasInputs from '../../advanced-gas-inputs' export default class AdvancedTabContent extends Component { @@ -18,15 +18,15 @@ export default class AdvancedTabContent extends Component { customModalGasPriceInHex: PropTypes.string, customModalGasLimitInHex: PropTypes.string, customModalStorageLimitInHex: PropTypes.string, - gasEstimatesLoading: PropTypes.bool, - millisecondsRemaining: PropTypes.number, + // gasEstimatesLoading: PropTypes.bool, + // millisecondsRemaining: PropTypes.number, transactionFee: PropTypes.string, timeRemaining: PropTypes.string, - gasChartProps: PropTypes.object, + // gasChartProps: PropTypes.object, insufficientBalance: PropTypes.bool, customPriceIsSafe: PropTypes.bool, isSpeedUp: PropTypes.bool, - isEthereumNetwork: PropTypes.bool, + // isEthereumNetwork: PropTypes.bool, } // TODO: add timeRemaining back when we have gas station @@ -55,7 +55,7 @@ export default class AdvancedTabContent extends Component { } render () { - const { t } = this.context + // const { t } = this.context const { isSimpleTx, updateCustomGasPrice, @@ -66,12 +66,12 @@ export default class AdvancedTabContent extends Component { customModalGasLimitInHex, customModalStorageLimitInHex, insufficientBalance, - gasChartProps, - gasEstimatesLoading, + // gasChartProps, + // gasEstimatesLoading, customPriceIsSafe, isSpeedUp, transactionFee, - isEthereumNetwork, + // isEthereumNetwork, } = this.props return ( @@ -92,29 +92,29 @@ export default class AdvancedTabContent extends Component { isSpeedUp={isSpeedUp} /> - {isEthereumNetwork ? ( -
-
- {t('liveGasPricePredictions')} -
- {!gasEstimatesLoading ? ( - - ) : ( - - )} -
- {t('slower')} - {t('faster')} -
-
- ) : ( -
- {t('chartOnlyAvailableEth')} -
- )} + {/* {isEthereumNetwork ? ( */} + {/*
*/} + {/*
*/} + {/* {t('liveGasPricePredictions')} */} + {/*
*/} + {/* {!gasEstimatesLoading ? ( */} + {/* */} + {/* ) : ( */} + {/* */} + {/* )} */} + {/*
*/} + {/* {t('slower')} */} + {/* {t('faster')} */} + {/*
*/} + {/*
*/} + {/* ) : ( */} + {/*
*/} + {/* {t('chartOnlyAvailableEth')} */} + {/*
*/} + {/* )} */} ) diff --git a/ui/app/components/app/gas-customization/gas-modal-page-container/advanced-tab-content/tests/advanced-tab-content-component.test.js b/ui/app/components/app/gas-customization/gas-modal-page-container/advanced-tab-content/tests/advanced-tab-content-component.test.js index 7901931ea850..8b297d11cc70 100644 --- a/ui/app/components/app/gas-customization/gas-modal-page-container/advanced-tab-content/tests/advanced-tab-content-component.test.js +++ b/ui/app/components/app/gas-customization/gas-modal-page-container/advanced-tab-content/tests/advanced-tab-content-component.test.js @@ -4,8 +4,8 @@ import shallow from '../../../../../../../lib/shallow-with-context' import sinon from 'sinon' import AdvancedTabContent from '../advanced-tab-content.component.js' -import GasPriceChart from '../../../gas-price-chart' -import Loading from '../../../../../ui/loading-screen' +// import GasPriceChart from '../../../gas-price-chart' +// import Loading from '../../../../../ui/loading-screen' const propsMethodSpies = { updateCustomGasPrice: sinon.spy(), @@ -60,26 +60,26 @@ describe('AdvancedTabContent Component', function () { ) assert(advancedTabChildren.at(1).hasClass('advanced-tab__fee-chart')) - const feeChartDiv = advancedTabChildren.at(1) + // const feeChartDiv = advancedTabChildren.at(1) - assert( - feeChartDiv - .childAt(1) - .childAt(0) - .hasClass('advanced-tab__fee-chart__title') - ) - assert( - feeChartDiv - .childAt(1) - .childAt(1) - .is(GasPriceChart) - ) - assert( - feeChartDiv - .childAt(1) - .childAt(2) - .hasClass('advanced-tab__fee-chart__speed-buttons') - ) + // assert( + // feeChartDiv + // .childAt(1) + // .childAt(0) + // .hasClass('advanced-tab__fee-chart__title') + // ) + // assert( + // feeChartDiv + // .childAt(1) + // .childAt(1) + // .is(GasPriceChart) + // ) + // assert( + // feeChartDiv + // .childAt(1) + // .childAt(2) + // .hasClass('advanced-tab__fee-chart__speed-buttons') + // ) }) it('should render a loading component instead of the chart if gasEstimatesLoading is true', function () { @@ -94,26 +94,26 @@ describe('AdvancedTabContent Component', function () { ) assert(advancedTabChildren.at(1).hasClass('advanced-tab__fee-chart')) - const feeChartDiv = advancedTabChildren.at(1) + // const feeChartDiv = advancedTabChildren.at(1) - assert( - feeChartDiv - .childAt(1) - .childAt(0) - .hasClass('advanced-tab__fee-chart__title') - ) - assert( - feeChartDiv - .childAt(1) - .childAt(1) - .is(Loading) - ) - assert( - feeChartDiv - .childAt(1) - .childAt(2) - .hasClass('advanced-tab__fee-chart__speed-buttons') - ) + // assert( + // feeChartDiv + // .childAt(1) + // .childAt(0) + // .hasClass('advanced-tab__fee-chart__title') + // ) + // assert( + // feeChartDiv + // .childAt(1) + // .childAt(1) + // .is(Loading) + // ) + // assert( + // feeChartDiv + // .childAt(1) + // .childAt(2) + // .hasClass('advanced-tab__fee-chart__speed-buttons') + // ) }) it('should call renderDataSummary with the expected params', function () { diff --git a/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js b/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js index 6228c2f1fe95..ee629e8ffea8 100644 --- a/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js +++ b/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js @@ -93,7 +93,7 @@ const mapStateToProps = (state, ownProps) => { data, } = getTxParams(state, selectedTransaction) const isSimpleTx = !(data || isValidContractAddress(toAddress)) - const customStorageLimitInHex = + const customModalStorageLimitInHex = getCustomStorageLimit(state) || currentStorageLimit || '0x0' const customModalGasPriceInHex = getCustomGasPrice(state) || currentGasPrice const customModalGasLimitInHex = @@ -101,12 +101,13 @@ const mapStateToProps = (state, ownProps) => { const customGasAndCollateralTotal = calcGasAndCollateralTotal( customModalGasLimitInHex, customModalGasPriceInHex, - customStorageLimitInHex + customModalStorageLimitInHex ) const gasButtonInfo = getRenderableBasicEstimateData( state, - customModalGasLimitInHex + customModalGasLimitInHex, + customModalStorageLimitInHex ) const currentCurrency = getCurrentCurrency(state) @@ -156,8 +157,10 @@ const mapStateToProps = (state, ownProps) => { isConfirm: isConfirm(state), customModalGasPriceInHex, customModalGasLimitInHex, + customModalStorageLimitInHex, customGasPrice, - customGasLimit: calcCustomGasLimit(customModalGasLimitInHex), + customGasLimit: calcCustomGasOrStorageLimit(customModalGasLimitInHex), + customStorageLimit: calcCustomGasOrStorageLimit(customModalStorageLimitInHex), customGasAndCollateralTotal, newTotalFiat, currentTimeEstimate: getRenderableTimeEstimate( @@ -313,7 +316,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => { ...transaction, txParams: { ...transaction.txParams, - stroage: storageLimit, + storageLimit, gas: gasLimit, gasPrice, }, @@ -379,8 +382,8 @@ function calcCustomGasPrice (customGasPriceInHex) { return Number(hexWEIToDecGWEI(customGasPriceInHex)) } -function calcCustomGasLimit (customGasLimitInHex) { - return parseInt(customGasLimitInHex, 16) +function calcCustomGasOrStorageLimit (customGasOrStorageLimitInHex) { + return parseInt(customGasOrStorageLimitInHex, 16) } function addHexWEIsToRenderableEth (aHexWEI, bHexWEI) { diff --git a/ui/app/components/app/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js b/ui/app/components/app/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js index 76c1cf40f01a..e92148a1fce1 100644 --- a/ui/app/components/app/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js +++ b/ui/app/components/app/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js @@ -152,10 +152,12 @@ describe('gas-modal-page-container container', function () { isConfirm: true, customGasPrice: 4.294967295, customGasLimit: 2863311530, + customStorageLimit: 4132, currentTimeEstimate: '~1 min 11 sec', newTotalFiat: '839.17', isSimpleTx: true, blockTime: 12, + customModalStorageLimitInHex: '1024', customModalGasLimitInHex: 'aaaaaaaa', customModalGasPriceInHex: 'ffffffff', customGasAndCollateralTotal: 'e2aa6be443c7d956', diff --git a/ui/app/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.component.js b/ui/app/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.component.js index d500e93146bd..61ab26b7a807 100644 --- a/ui/app/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.component.js +++ b/ui/app/pages/send/send-content/send-row-wrapper/send-row-error-message/send-row-error-message.component.js @@ -20,7 +20,7 @@ export default class SendRowErrorMessage extends Component { return errorMessage ? (
{this.context.t(errorMessage)} diff --git a/ui/app/pages/send/send-footer/tests/send-footer-container.test.js b/ui/app/pages/send/send-footer/tests/send-footer-container.test.js index eb9bed1e4398..adb8afcbae56 100644 --- a/ui/app/pages/send/send-footer/tests/send-footer-container.test.js +++ b/ui/app/pages/send/send-footer/tests/send-footer-container.test.js @@ -28,9 +28,12 @@ proxyquire('../send-footer.container.js', { }, '../../../store/actions': actionSpies, '../send.selectors': { + getStorageLimit: (s) => `mockStorageLimit:${s}`, getGasLimit: (s) => `mockGasLimit:${s}`, getGasPrice: (s) => `mockGasPrice:${s}`, getGasTotal: (s) => `mockGasTotal:${s}`, + getStorageTotal: (s) => `mockStorageTotal:${s}`, + getGasAndCollateralTotal: (s) => `mockGasAndCollateralTotal:${s}`, getSelectedToken: (s) => `mockSelectedToken:${s}`, getSendAmount: (s) => `mockAmount:${s}`, getSendEditingTransactionId: (s) => `mockEditingTransactionId:${s}`, diff --git a/ui/app/selectors/custom-gas.js b/ui/app/selectors/custom-gas.js index d445767cc498..2a1cffbea54a 100644 --- a/ui/app/selectors/custom-gas.js +++ b/ui/app/selectors/custom-gas.js @@ -12,7 +12,7 @@ import { import { formatCurrency } from '../helpers/utils/confirm-tx.util' import { decEthToConvertedCurrency as ethTotalToConvertedCurrency } from '../helpers/utils/conversions.util' import { formatETHFee } from '../helpers/utils/formatters' -import { calcGasTotal } from '../pages/send/send.utils' +import { calcGasAndCollateralTotal } from '../pages/send/send.utils' import { addHexPrefix } from 'cfx-util' import { GAS_ESTIMATE_TYPES } from '../helpers/constants/common' @@ -27,6 +27,10 @@ export function getCustomGasLimit (state) { return state.gas.customData.limit } +export function getCustomStorageLimit (state) { + return state.storageLimit.customData.limit +} + export function getCustomGasPrice (state) { return state.gas.customData.price } @@ -35,6 +39,14 @@ export function getCustomGasTotal (state) { return state.gas.customData.total } +export function getCustomStorageLimitTotal (state) { + return state.storageLimit.customData.total +} + +export function getCustomGasAndCollateralTotal (state) { + return state.calcGasAndCollateralTotal.customData.total +} + export function getBasicGasEstimateLoadingStatus (state) { return state.gas.basicEstimateIsLoading } @@ -117,9 +129,10 @@ export function getBasicGasEstimateBlockTime (state) { export function basicPriceEstimateToETHTotal ( estimate, gasLimit, + storageLimit, numberOfDecimals = 9 ) { - return conversionUtil(calcGasTotal(gasLimit, estimate), { + return conversionUtil(calcGasAndCollateralTotal(gasLimit, estimate, storageLimit), { fromNumericBase: 'hex', toNumericBase: 'dec', fromDenomination: 'GWEI', @@ -127,29 +140,30 @@ export function basicPriceEstimateToETHTotal ( }) } -export function getRenderableEthFee (estimate, gasLimit, numberOfDecimals = 9) { +export function getRenderableEthFee (estimate, gasLimit, storageLimit, numberOfDecimals = 9) { return pipe( (x) => conversionUtil(x, { fromNumericBase: 'dec', toNumericBase: 'hex' }), - partialRight(basicPriceEstimateToETHTotal, [gasLimit, numberOfDecimals]), + partialRight(basicPriceEstimateToETHTotal, [gasLimit, storageLimit, numberOfDecimals]), formatETHFee - )(estimate, gasLimit) + )(estimate, gasLimit, storageLimit) } export function getRenderableConvertedCurrencyFee ( estimate, gasLimit, + storageLimit, convertedCurrency, conversionRate ) { return pipe( (x) => conversionUtil(x, { fromNumericBase: 'dec', toNumericBase: 'hex' }), - partialRight(basicPriceEstimateToETHTotal, [gasLimit]), + partialRight(basicPriceEstimateToETHTotal, [gasLimit, storageLimit]), partialRight(ethTotalToConvertedCurrency, [ convertedCurrency, conversionRate, ]), partialRight(formatCurrency, [convertedCurrency]) - )(estimate, gasLimit, convertedCurrency, conversionRate) + )(estimate, gasLimit, storageLimit, convertedCurrency, conversionRate) } export function getTimeEstimateInSeconds (blockWaitEstimate) { @@ -208,7 +222,7 @@ export function getGasPriceInHexWei (price) { )(price) } -export function getRenderableBasicEstimateData (state, gasLimit) { +export function getRenderableBasicEstimateData (state, gasLimit, storageLimit) { if (getBasicGasEstimateLoadingStatus(state)) { return [] } @@ -234,11 +248,12 @@ export function getRenderableBasicEstimateData (state, gasLimit) { return [ { gasEstimateType: GAS_ESTIMATE_TYPES.SLOW, - feeInPrimaryCurrency: getRenderableEthFee(safeLow, gasLimit), + feeInPrimaryCurrency: getRenderableEthFee(safeLow, gasLimit, storageLimit), feeInSecondaryCurrency: showFiat ? getRenderableConvertedCurrencyFee( safeLow, gasLimit, + storageLimit, currentCurrency, conversionRate ) @@ -248,11 +263,12 @@ export function getRenderableBasicEstimateData (state, gasLimit) { }, { gasEstimateType: GAS_ESTIMATE_TYPES.AVERAGE, - feeInPrimaryCurrency: getRenderableEthFee(average, gasLimit), + feeInPrimaryCurrency: getRenderableEthFee(average, gasLimit, storageLimit), feeInSecondaryCurrency: showFiat ? getRenderableConvertedCurrencyFee( average, gasLimit, + storageLimit, currentCurrency, conversionRate ) @@ -262,11 +278,12 @@ export function getRenderableBasicEstimateData (state, gasLimit) { }, { gasEstimateType: GAS_ESTIMATE_TYPES.FAST, - feeInPrimaryCurrency: getRenderableEthFee(fast, gasLimit), + feeInPrimaryCurrency: getRenderableEthFee(fast, gasLimit, storageLimit), feeInSecondaryCurrency: showFiat ? getRenderableConvertedCurrencyFee( fast, gasLimit, + storageLimit, currentCurrency, conversionRate ) @@ -287,6 +304,8 @@ export function getRenderableEstimateDataForSmallButtonsFromGWEI (state) { const showFiat = isMainnet || !!showFiatInTestnets const gasLimit = state.metamask.send.gasLimit || getCustomGasLimit(state) || '0x5208' + const storageLimit = + state.metamask.send.storageLimit || getCustomStorageLimit(state) || '0x0' const conversionRate = state.metamask.conversionRate const currentCurrency = getCurrentCurrency(state) const { @@ -302,6 +321,7 @@ export function getRenderableEstimateDataForSmallButtonsFromGWEI (state) { ? getRenderableConvertedCurrencyFee( safeLow, gasLimit, + storageLimit, currentCurrency, conversionRate ) @@ -309,6 +329,7 @@ export function getRenderableEstimateDataForSmallButtonsFromGWEI (state) { feeInPrimaryCurrency: getRenderableEthFee( safeLow, gasLimit, + storageLimit, NUMBER_OF_DECIMALS_SM_BTNS, true ), @@ -320,6 +341,7 @@ export function getRenderableEstimateDataForSmallButtonsFromGWEI (state) { ? getRenderableConvertedCurrencyFee( average, gasLimit, + storageLimit, currentCurrency, conversionRate ) @@ -327,6 +349,7 @@ export function getRenderableEstimateDataForSmallButtonsFromGWEI (state) { feeInPrimaryCurrency: getRenderableEthFee( average, gasLimit, + storageLimit, NUMBER_OF_DECIMALS_SM_BTNS, true ), @@ -338,6 +361,7 @@ export function getRenderableEstimateDataForSmallButtonsFromGWEI (state) { ? getRenderableConvertedCurrencyFee( fast, gasLimit, + storageLimit, currentCurrency, conversionRate ) @@ -345,6 +369,7 @@ export function getRenderableEstimateDataForSmallButtonsFromGWEI (state) { feeInPrimaryCurrency: getRenderableEthFee( fast, gasLimit, + storageLimit, NUMBER_OF_DECIMALS_SM_BTNS, true ), diff --git a/ui/app/selectors/custom-gas.test.js b/ui/app/selectors/custom-gas.test.js index 611bb5c0f764..1d176f8dd5ee 100644 --- a/ui/app/selectors/custom-gas.test.js +++ b/ui/app/selectors/custom-gas.test.js @@ -4,6 +4,7 @@ import proxyquire from 'proxyquire' const { getCustomGasErrors, getCustomGasLimit, + getCustomStorageLimit, getCustomGasPrice, getCustomGasTotal, getEstimatedGasPrices, @@ -23,8 +24,8 @@ describe('custom-gas selectors', function () { describe('getCustomGasLimit()', function () { it('should return gas.customData.limit', function () { - const mockState = { gas: { customData: { limit: 'mockLimit' } } } - assert.equal(getCustomGasLimit(mockState), 'mockLimit') + const mockState = { gas: { customData: { limit: 'mockGasLimit' } } } + assert.equal(getCustomGasLimit(mockState), 'mockGasLimit') }) }) @@ -40,585 +41,598 @@ describe('custom-gas selectors', function () { const mockState = { gas: { errors: 'mockErrors' } } assert.equal(getCustomGasErrors(mockState), 'mockErrors') }) - }) - describe('getPriceAndTimeEstimates', function () { - it('should return price and time estimates', function () { - const mockState = { - gas: { priceAndTimeEstimates: 'mockPriceAndTimeEstimates' }, - } - assert.equal( - getPriceAndTimeEstimates(mockState), - 'mockPriceAndTimeEstimates' - ) + describe('getPriceAndTimeEstimates', function () { + it('should return price and time estimates', function () { + const mockState = { + gas: { priceAndTimeEstimates: 'mockPriceAndTimeEstimates' }, + } + assert.equal( + getPriceAndTimeEstimates(mockState), + 'mockPriceAndTimeEstimates' + ) + }) }) - }) - describe('getEstimatedGasPrices', function () { - it('should return price and time estimates', function () { - const mockState = { - gas: { - priceAndTimeEstimates: [ - { gasprice: 12, somethingElse: 20 }, - { gasprice: 22, expectedTime: 30 }, - { gasprice: 32, somethingElse: 40 }, - ], - }, - } - assert.deepEqual(getEstimatedGasPrices(mockState), [12, 22, 32]) + describe('getEstimatedGasPrices', function () { + it('should return price and time estimates', function () { + const mockState = { + gas: { + priceAndTimeEstimates: [ + { gasprice: 12, somethingElse: 20 }, + { gasprice: 22, expectedTime: 30 }, + { gasprice: 32, somethingElse: 40 }, + ], + }, + } + assert.deepEqual(getEstimatedGasPrices(mockState), [12, 22, 32]) + }) }) - }) - describe('getEstimatedGasTimes', function () { - it('should return price and time estimates', function () { - const mockState = { - gas: { - priceAndTimeEstimates: [ - { somethingElse: 12, expectedTime: 20 }, - { gasPrice: 22, expectedTime: 30 }, - { somethingElse: 32, expectedTime: 40 }, - ], - }, - } - assert.deepEqual(getEstimatedGasTimes(mockState), [20, 30, 40]) + describe('getEstimatedGasTimes', function () { + it('should return price and time estimates', function () { + const mockState = { + gas: { + priceAndTimeEstimates: [ + { somethingElse: 12, expectedTime: 20 }, + { gasPrice: 22, expectedTime: 30 }, + { somethingElse: 32, expectedTime: 40 }, + ], + }, + } + assert.deepEqual(getEstimatedGasTimes(mockState), [20, 30, 40]) + }) }) - }) - describe('getRenderableBasicEstimateData()', function () { - const tests = [ - { - expectedResult: [ - { - gasEstimateType: 'SLOW', - feeInSecondaryCurrency: '$0.01', - feeInPrimaryCurrency: '0.0000525 CFX', - timeEstimate: '~6 min 36 sec', - priceInHexWei: '0x9502f900', - }, - { - gasEstimateType: 'AVERAGE', - feeInPrimaryCurrency: '0.000084 CFX', - feeInSecondaryCurrency: '$0.02', - priceInHexWei: '0xee6b2800', - timeEstimate: '~5 min 18 sec', - }, - { - gasEstimateType: 'FAST', - feeInSecondaryCurrency: '$0.03', - feeInPrimaryCurrency: '0.000105 CFX', - timeEstimate: '~3 min 18 sec', - priceInHexWei: '0x12a05f200', - }, - ], - mockState: { - metamask: { - conversionRate: 255.71, - currentCurrency: 'usd', - preferences: { - showFiatInTestnets: false, - }, - provider: { - type: 'mainnet', + describe('getRenderableBasicEstimateData()', function () { + const tests = [ + { + expectedResult: [ + { + gasEstimateType: 'SLOW', + feeInSecondaryCurrency: '$0.01', + feeInPrimaryCurrency: '0.0000525 CFX', + timeEstimate: '~6 min 36 sec', + priceInHexWei: '0x9502f900', + }, + { + gasEstimateType: 'AVERAGE', + feeInPrimaryCurrency: '0.000084 CFX', + feeInSecondaryCurrency: '$0.02', + priceInHexWei: '0xee6b2800', + timeEstimate: '~5 min 18 sec', + }, + { + gasEstimateType: 'FAST', + feeInSecondaryCurrency: '$0.03', + feeInPrimaryCurrency: '0.000105 CFX', + timeEstimate: '~3 min 18 sec', + priceInHexWei: '0x12a05f200', }, - }, - gas: { - basicEstimates: { - blockTime: 14.16326530612245, - safeLow: 2.5, - safeLowWait: 6.6, - average: 4, - avgWait: 5.3, - fast: 5, - fastWait: 3.3, - fastest: 10, - fastestWait: 0.5, + ], + mockState: { + metamask: { + conversionRate: 255.71, + currentCurrency: 'usd', + preferences: { + showFiatInTestnets: false, + }, + provider: { + type: 'mainnet', + }, + }, + gas: { + basicEstimates: { + blockTime: 14.16326530612245, + safeLow: 2.5, + safeLowWait: 6.6, + average: 4, + avgWait: 5.3, + fast: 5, + fastWait: 3.3, + fastest: 10, + fastestWait: 0.5, + }, }, }, }, - }, - { - expectedResult: [ - { - gasEstimateType: 'SLOW', - feeInSecondaryCurrency: '$0.27', - feeInPrimaryCurrency: '0.000105 CFX', - timeEstimate: '~13 min 12 sec', - priceInHexWei: '0x12a05f200', - }, - { - feeInPrimaryCurrency: '0.000147 CFX', - feeInSecondaryCurrency: '$0.38', - gasEstimateType: 'AVERAGE', - priceInHexWei: '0x1a13b8600', - timeEstimate: '~10 min 6 sec', - }, - { - gasEstimateType: 'FAST', - feeInSecondaryCurrency: '$0.54', - feeInPrimaryCurrency: '0.00021 CFX', - timeEstimate: '~6 min 36 sec', - priceInHexWei: '0x2540be400', - }, - ], - mockState: { - metamask: { - conversionRate: 2557.1, - currentCurrency: 'usd', - send: { - gasLimit: '0x5208', - }, - preferences: { - showFiatInTestnets: false, + { + expectedResult: [ + { + gasEstimateType: 'SLOW', + feeInSecondaryCurrency: '$0.27', + feeInPrimaryCurrency: '0.000105 CFX', + timeEstimate: '~13 min 12 sec', + priceInHexWei: '0x12a05f200', + }, + { + feeInPrimaryCurrency: '0.000147 CFX', + feeInSecondaryCurrency: '$0.38', + gasEstimateType: 'AVERAGE', + priceInHexWei: '0x1a13b8600', + timeEstimate: '~10 min 6 sec', + }, + { + gasEstimateType: 'FAST', + feeInSecondaryCurrency: '$0.54', + feeInPrimaryCurrency: '0.00021 CFX', + timeEstimate: '~6 min 36 sec', + priceInHexWei: '0x2540be400', }, - provider: { - type: 'mainnet', - }, - }, - gas: { - basicEstimates: { - blockTime: 14.16326530612245, - safeLow: 5, - safeLowWait: 13.2, - average: 7, - avgWait: 10.1, - fast: 10, - fastWait: 6.6, - fastest: 20, - fastestWait: 1.0, + ], + mockState: { + metamask: { + conversionRate: 2557.1, + currentCurrency: 'usd', + send: { + gasLimit: '0x5208', + }, + preferences: { + showFiatInTestnets: false, + }, + provider: { + type: 'mainnet', + }, + }, + gas: { + basicEstimates: { + blockTime: 14.16326530612245, + safeLow: 5, + safeLowWait: 13.2, + average: 7, + avgWait: 10.1, + fast: 10, + fastWait: 6.6, + fastest: 20, + fastestWait: 1.0, + }, }, }, }, - }, - { - expectedResult: [ - { - gasEstimateType: 'SLOW', - feeInSecondaryCurrency: '', - feeInPrimaryCurrency: '0.000105 CFX', - timeEstimate: '~13 min 12 sec', - priceInHexWei: '0x12a05f200', - }, - { - gasEstimateType: 'AVERAGE', - feeInPrimaryCurrency: '0.000147 CFX', - feeInSecondaryCurrency: '', - timeEstimate: '~10 min 6 sec', - priceInHexWei: '0x1a13b8600', - }, - { - gasEstimateType: 'FAST', - feeInSecondaryCurrency: '', - feeInPrimaryCurrency: '0.00021 CFX', - timeEstimate: '~6 min 36 sec', - priceInHexWei: '0x2540be400', - }, - ], - mockState: { - metamask: { - conversionRate: 2557.1, - currentCurrency: 'usd', - send: { - gasLimit: '0x5208', - }, - preferences: { - showFiatInTestnets: false, - }, - provider: { - type: 'rinkeby', + { + expectedResult: [ + { + gasEstimateType: 'SLOW', + feeInSecondaryCurrency: '', + feeInPrimaryCurrency: '0.000105 CFX', + timeEstimate: '~13 min 12 sec', + priceInHexWei: '0x12a05f200', + }, + { + gasEstimateType: 'AVERAGE', + feeInPrimaryCurrency: '0.000147 CFX', + feeInSecondaryCurrency: '', + timeEstimate: '~10 min 6 sec', + priceInHexWei: '0x1a13b8600', + }, + { + gasEstimateType: 'FAST', + feeInSecondaryCurrency: '', + feeInPrimaryCurrency: '0.00021 CFX', + timeEstimate: '~6 min 36 sec', + priceInHexWei: '0x2540be400', }, - }, - gas: { - basicEstimates: { - blockTime: 14.16326530612245, - safeLow: 5, - safeLowWait: 13.2, - average: 7, - avgWait: 10.1, - fast: 10, - fastWait: 6.6, - fastest: 20, - fastestWait: 1.0, + ], + mockState: { + metamask: { + conversionRate: 2557.1, + currentCurrency: 'usd', + send: { + gasLimit: '0x5208', + }, + preferences: { + showFiatInTestnets: false, + }, + provider: { + type: 'rinkeby', + }, + }, + gas: { + basicEstimates: { + blockTime: 14.16326530612245, + safeLow: 5, + safeLowWait: 13.2, + average: 7, + avgWait: 10.1, + fast: 10, + fastWait: 6.6, + fastest: 20, + fastestWait: 1.0, + }, }, }, }, - }, - { - expectedResult: [ - { - gasEstimateType: 'SLOW', - feeInSecondaryCurrency: '$0.27', - feeInPrimaryCurrency: '0.000105 CFX', - timeEstimate: '~13 min 12 sec', - priceInHexWei: '0x12a05f200', - }, - { - gasEstimateType: 'AVERAGE', - feeInPrimaryCurrency: '0.000147 CFX', - feeInSecondaryCurrency: '$0.38', - priceInHexWei: '0x1a13b8600', - timeEstimate: '~10 min 6 sec', - }, - { - gasEstimateType: 'FAST', - feeInSecondaryCurrency: '$0.54', - feeInPrimaryCurrency: '0.00021 CFX', - timeEstimate: '~6 min 36 sec', - priceInHexWei: '0x2540be400', - }, - ], - mockState: { - metamask: { - conversionRate: 2557.1, - currentCurrency: 'usd', - send: { - gasLimit: '0x5208', + { + expectedResult: [ + { + gasEstimateType: 'SLOW', + feeInSecondaryCurrency: '$0.27', + feeInPrimaryCurrency: '0.000105 CFX', + timeEstimate: '~13 min 12 sec', + priceInHexWei: '0x12a05f200', + }, + { + gasEstimateType: 'AVERAGE', + feeInPrimaryCurrency: '0.000147 CFX', + feeInSecondaryCurrency: '$0.38', + priceInHexWei: '0x1a13b8600', + timeEstimate: '~10 min 6 sec', + }, + { + gasEstimateType: 'FAST', + feeInSecondaryCurrency: '$0.54', + feeInPrimaryCurrency: '0.00021 CFX', + timeEstimate: '~6 min 36 sec', + priceInHexWei: '0x2540be400', }, - preferences: { - showFiatInTestnets: true, - }, - provider: { - type: 'rinkeby', - }, - }, - gas: { - basicEstimates: { - blockTime: 14.16326530612245, - safeLow: 5, - safeLowWait: 13.2, - average: 7, - avgWait: 10.1, - fast: 10, - fastWait: 6.6, - fastest: 20, - fastestWait: 1.0, + ], + mockState: { + metamask: { + conversionRate: 2557.1, + currentCurrency: 'usd', + send: { + gasLimit: '0x5208', + }, + preferences: { + showFiatInTestnets: true, + }, + provider: { + type: 'rinkeby', + }, + }, + gas: { + basicEstimates: { + blockTime: 14.16326530612245, + safeLow: 5, + safeLowWait: 13.2, + average: 7, + avgWait: 10.1, + fast: 10, + fastWait: 6.6, + fastest: 20, + fastestWait: 1.0, + }, }, }, }, - }, - { - expectedResult: [ - { - gasEstimateType: 'SLOW', - feeInSecondaryCurrency: '$0.27', - feeInPrimaryCurrency: '0.000105 CFX', - timeEstimate: '~13 min 12 sec', - priceInHexWei: '0x12a05f200', - }, - { - gasEstimateType: 'AVERAGE', - feeInPrimaryCurrency: '0.000147 CFX', - feeInSecondaryCurrency: '$0.38', - priceInHexWei: '0x1a13b8600', - timeEstimate: '~10 min 6 sec', - }, - { - gasEstimateType: 'FAST', - feeInSecondaryCurrency: '$0.54', - feeInPrimaryCurrency: '0.00021 CFX', - timeEstimate: '~6 min 36 sec', - priceInHexWei: '0x2540be400', - }, - ], - mockState: { - metamask: { - conversionRate: 2557.1, - currentCurrency: 'usd', - send: { - gasLimit: '0x5208', - }, - preferences: { - showFiatInTestnets: true, + { + expectedResult: [ + { + gasEstimateType: 'SLOW', + feeInSecondaryCurrency: '$0.27', + feeInPrimaryCurrency: '0.000105 CFX', + timeEstimate: '~13 min 12 sec', + priceInHexWei: '0x12a05f200', + }, + { + gasEstimateType: 'AVERAGE', + feeInPrimaryCurrency: '0.000147 CFX', + feeInSecondaryCurrency: '$0.38', + priceInHexWei: '0x1a13b8600', + timeEstimate: '~10 min 6 sec', + }, + { + gasEstimateType: 'FAST', + feeInSecondaryCurrency: '$0.54', + feeInPrimaryCurrency: '0.00021 CFX', + timeEstimate: '~6 min 36 sec', + priceInHexWei: '0x2540be400', }, - provider: { - type: 'mainnet', - }, - }, - gas: { - basicEstimates: { - blockTime: 14.16326530612245, - safeLow: 5, - safeLowWait: 13.2, - average: 7, - avgWait: 10.1, - fast: 10, - fastWait: 6.6, - fastest: 20, - fastestWait: 1.0, + ], + mockState: { + metamask: { + conversionRate: 2557.1, + currentCurrency: 'usd', + send: { + gasLimit: '0x5208', + }, + preferences: { + showFiatInTestnets: true, + }, + provider: { + type: 'mainnet', + }, + }, + gas: { + basicEstimates: { + blockTime: 14.16326530612245, + safeLow: 5, + safeLowWait: 13.2, + average: 7, + avgWait: 10.1, + fast: 10, + fastWait: 6.6, + fastest: 20, + fastestWait: 1.0, + }, }, }, }, - }, - ] - it('should return renderable data about basic estimates', function () { - tests.forEach((test) => { - assert.deepEqual( - getRenderableBasicEstimateData(test.mockState, '0x5208'), - test.expectedResult - ) + ] + it('should return renderable data about basic estimates', function () { + tests.forEach((test) => { + assert.deepEqual( + getRenderableBasicEstimateData(test.mockState, '0x5208'), + test.expectedResult + ) + }) }) }) - }) - describe('getRenderableEstimateDataForSmallButtonsFromGWEI()', function () { - const tests = [ - { - expectedResult: [ - { - feeInSecondaryCurrency: '$0.13', - feeInPrimaryCurrency: '0.00052 CFX', - gasEstimateType: 'SLOW', - priceInHexWei: '0x5d21dba00', - }, - { - feeInSecondaryCurrency: '$0.16', - feeInPrimaryCurrency: '0.00063 CFX', - gasEstimateType: 'AVERAGE', - priceInHexWei: '0x6fc23ac00', - }, - { - feeInSecondaryCurrency: '$0.27', - feeInPrimaryCurrency: '0.00105 CFX', - gasEstimateType: 'FAST', - priceInHexWei: '0xba43b7400', - }, - ], - mockState: { - metamask: { - conversionRate: 255.71, - currentCurrency: 'usd', - send: { - gasLimit: '0x5208', - }, - preferences: { - showFiatInTestnets: false, + describe('getRenderableEstimateDataForSmallButtonsFromGWEI()', function () { + const tests = [ + { + expectedResult: [ + { + feeInSecondaryCurrency: '$0.13', + feeInPrimaryCurrency: '0.00052 CFX', + gasEstimateType: 'SLOW', + priceInHexWei: '0x5d21dba00', + }, + { + feeInSecondaryCurrency: '$0.16', + feeInPrimaryCurrency: '0.00063 CFX', + gasEstimateType: 'AVERAGE', + priceInHexWei: '0x6fc23ac00', + }, + { + feeInSecondaryCurrency: '$0.27', + feeInPrimaryCurrency: '0.00105 CFX', + gasEstimateType: 'FAST', + priceInHexWei: '0xba43b7400', }, - provider: { - type: 'mainnet', - }, - }, - gas: { - basicEstimates: { - blockTime: 14.16326530612245, - safeLow: 25, - safeLowWait: 6.6, - average: 30, - avgWait: 5.5, - fast: 50, - fastWait: 3.3, - fastest: 100, - fastestWait: 0.5, + ], + mockState: { + metamask: { + conversionRate: 255.71, + currentCurrency: 'usd', + send: { + gasLimit: '0x5208', + storageLimit: '0x0', + }, + preferences: { + showFiatInTestnets: false, + }, + provider: { + type: 'mainnet', + }, + }, + gas: { + basicEstimates: { + blockTime: 14.16326530612245, + safeLow: 25, + safeLowWait: 6.6, + average: 30, + avgWait: 5.5, + fast: 50, + fastWait: 3.3, + fastest: 100, + fastestWait: 0.5, + }, }, }, }, - }, - { - expectedResult: [ - { - feeInSecondaryCurrency: '$2.68', - feeInPrimaryCurrency: '0.00105 CFX', - gasEstimateType: 'SLOW', - priceInHexWei: '0xba43b7400', - }, - { - feeInSecondaryCurrency: '$4.03', - feeInPrimaryCurrency: '0.00157 CFX', - gasEstimateType: 'AVERAGE', - priceInHexWei: '0x1176592e00', - }, - { - feeInSecondaryCurrency: '$5.37', - feeInPrimaryCurrency: '0.0021 CFX', - gasEstimateType: 'FAST', - priceInHexWei: '0x174876e800', - }, - ], - mockState: { - metamask: { - conversionRate: 2557.1, - currentCurrency: 'usd', - send: { - gasLimit: '0x5208', - }, - preferences: { - showFiatInTestnets: false, - }, - provider: { - type: 'mainnet', + { + expectedResult: [ + { + feeInSecondaryCurrency: '$2.68', + feeInPrimaryCurrency: '0.00105 CFX', + gasEstimateType: 'SLOW', + priceInHexWei: '0xba43b7400', + }, + { + feeInSecondaryCurrency: '$4.03', + feeInPrimaryCurrency: '0.00157 CFX', + gasEstimateType: 'AVERAGE', + priceInHexWei: '0x1176592e00', + }, + { + feeInSecondaryCurrency: '$5.37', + feeInPrimaryCurrency: '0.0021 CFX', + gasEstimateType: 'FAST', + priceInHexWei: '0x174876e800', }, - }, - gas: { - basicEstimates: { - blockTime: 14.16326530612245, - safeLow: 50, - safeLowWait: 13.2, - average: 75, - avgWait: 9.6, - fast: 100, - fastWait: 6.6, - fastest: 200, - fastestWait: 1.0, + ], + mockState: { + metamask: { + conversionRate: 2557.1, + currentCurrency: 'usd', + send: { + gasLimit: '0x5208', + storageLimit: '0x0', + }, + preferences: { + showFiatInTestnets: false, + }, + provider: { + type: 'mainnet', + }, + }, + gas: { + basicEstimates: { + blockTime: 14.16326530612245, + safeLow: 50, + safeLowWait: 13.2, + average: 75, + avgWait: 9.6, + fast: 100, + fastWait: 6.6, + fastest: 200, + fastestWait: 1.0, + }, }, }, }, - }, - { - expectedResult: [ - { - feeInSecondaryCurrency: '', - feeInPrimaryCurrency: '0.00105 CFX', - gasEstimateType: 'SLOW', - priceInHexWei: '0xba43b7400', - }, - { - feeInSecondaryCurrency: '', - feeInPrimaryCurrency: '0.00157 CFX', - gasEstimateType: 'AVERAGE', - priceInHexWei: '0x1176592e00', - }, - { - feeInSecondaryCurrency: '', - feeInPrimaryCurrency: '0.0021 CFX', - gasEstimateType: 'FAST', - priceInHexWei: '0x174876e800', - }, - ], - mockState: { - metamask: { - conversionRate: 2557.1, - currentCurrency: 'usd', - send: { - gasLimit: '0x5208', + { + expectedResult: [ + { + feeInSecondaryCurrency: '', + feeInPrimaryCurrency: '0.00105 CFX', + gasEstimateType: 'SLOW', + priceInHexWei: '0xba43b7400', + }, + { + feeInSecondaryCurrency: '', + feeInPrimaryCurrency: '0.00157 CFX', + gasEstimateType: 'AVERAGE', + priceInHexWei: '0x1176592e00', + }, + { + feeInSecondaryCurrency: '', + feeInPrimaryCurrency: '0.0021 CFX', + gasEstimateType: 'FAST', + priceInHexWei: '0x174876e800', }, - preferences: { - showFiatInTestnets: false, - }, - provider: { - type: 'rinkeby', - }, - }, - gas: { - basicEstimates: { - blockTime: 14.16326530612245, - safeLow: 50, - safeLowWait: 13.2, - average: 75, - avgWait: 9.6, - fast: 100, - fastWait: 6.6, - fastest: 200, - fastestWait: 1.0, + ], + mockState: { + metamask: { + conversionRate: 2557.1, + currentCurrency: 'usd', + send: { + gasLimit: '0x5208', + storageLimit: '0x0', + }, + preferences: { + showFiatInTestnets: false, + }, + provider: { + type: 'rinkeby', + }, + }, + gas: { + basicEstimates: { + blockTime: 14.16326530612245, + safeLow: 50, + safeLowWait: 13.2, + average: 75, + avgWait: 9.6, + fast: 100, + fastWait: 6.6, + fastest: 200, + fastestWait: 1.0, + }, }, }, }, - }, - { - expectedResult: [ - { - feeInSecondaryCurrency: '$2.68', - feeInPrimaryCurrency: '0.00105 CFX', - gasEstimateType: 'SLOW', - priceInHexWei: '0xba43b7400', - }, - { - feeInSecondaryCurrency: '$4.03', - feeInPrimaryCurrency: '0.00157 CFX', - gasEstimateType: 'AVERAGE', - priceInHexWei: '0x1176592e00', - }, - { - feeInSecondaryCurrency: '$5.37', - feeInPrimaryCurrency: '0.0021 CFX', - gasEstimateType: 'FAST', - priceInHexWei: '0x174876e800', - }, - ], - mockState: { - metamask: { - conversionRate: 2557.1, - currentCurrency: 'usd', - send: { - gasLimit: '0x5208', - }, - preferences: { - showFiatInTestnets: true, + { + expectedResult: [ + { + feeInSecondaryCurrency: '$2.68', + feeInPrimaryCurrency: '0.00105 CFX', + gasEstimateType: 'SLOW', + priceInHexWei: '0xba43b7400', + }, + { + feeInSecondaryCurrency: '$4.03', + feeInPrimaryCurrency: '0.00157 CFX', + gasEstimateType: 'AVERAGE', + priceInHexWei: '0x1176592e00', + }, + { + feeInSecondaryCurrency: '$5.37', + feeInPrimaryCurrency: '0.0021 CFX', + gasEstimateType: 'FAST', + priceInHexWei: '0x174876e800', }, - provider: { - type: 'rinkeby', - }, - }, - gas: { - basicEstimates: { - blockTime: 14.16326530612245, - safeLow: 50, - safeLowWait: 13.2, - average: 75, - avgWait: 9.6, - fast: 100, - fastWait: 6.6, - fastest: 200, - fastestWait: 1.0, + ], + mockState: { + metamask: { + conversionRate: 2557.1, + currentCurrency: 'usd', + send: { + gasLimit: '0x5208', + storageLimit: '0x0', + }, + preferences: { + showFiatInTestnets: true, + }, + provider: { + type: 'rinkeby', + }, + }, + gas: { + basicEstimates: { + blockTime: 14.16326530612245, + safeLow: 50, + safeLowWait: 13.2, + average: 75, + avgWait: 9.6, + fast: 100, + fastWait: 6.6, + fastest: 200, + fastestWait: 1.0, + }, }, }, }, - }, - { - expectedResult: [ - { - feeInSecondaryCurrency: '$2.68', - feeInPrimaryCurrency: '0.00105 CFX', - gasEstimateType: 'SLOW', - priceInHexWei: '0xba43b7400', - }, - { - feeInSecondaryCurrency: '$4.03', - feeInPrimaryCurrency: '0.00157 CFX', - gasEstimateType: 'AVERAGE', - priceInHexWei: '0x1176592e00', - }, - { - feeInSecondaryCurrency: '$5.37', - feeInPrimaryCurrency: '0.0021 CFX', - gasEstimateType: 'FAST', - priceInHexWei: '0x174876e800', - }, - ], - mockState: { - metamask: { - conversionRate: 2557.1, - currentCurrency: 'usd', - send: { - gasLimit: '0x5208', - }, - preferences: { - showFiatInTestnets: true, - }, - provider: { - type: 'mainnet', + { + expectedResult: [ + { + feeInSecondaryCurrency: '$2.68', + feeInPrimaryCurrency: '0.00105 CFX', + gasEstimateType: 'SLOW', + priceInHexWei: '0xba43b7400', + }, + { + feeInSecondaryCurrency: '$4.03', + feeInPrimaryCurrency: '0.00157 CFX', + gasEstimateType: 'AVERAGE', + priceInHexWei: '0x1176592e00', + }, + { + feeInSecondaryCurrency: '$5.37', + feeInPrimaryCurrency: '0.0021 CFX', + gasEstimateType: 'FAST', + priceInHexWei: '0x174876e800', }, - }, - gas: { - basicEstimates: { - blockTime: 14.16326530612245, - safeLow: 50, - safeLowWait: 13.2, - average: 75, - avgWait: 9.6, - fast: 100, - fastWait: 6.6, - fastest: 200, - fastestWait: 1.0, + ], + mockState: { + metamask: { + conversionRate: 2557.1, + currentCurrency: 'usd', + send: { + gasLimit: '0x5208', + storageLimit: '0x0', + }, + preferences: { + showFiatInTestnets: true, + }, + provider: { + type: 'mainnet', + }, + }, + gas: { + basicEstimates: { + blockTime: 14.16326530612245, + safeLow: 50, + safeLowWait: 13.2, + average: 75, + avgWait: 9.6, + fast: 100, + fastWait: 6.6, + fastest: 200, + fastestWait: 1.0, + }, }, }, }, - }, - ] - it('should return renderable data about basic estimates appropriate for buttons with less info', function () { - tests.forEach((test) => { - assert.deepEqual( - getRenderableEstimateDataForSmallButtonsFromGWEI(test.mockState), - test.expectedResult - ) + ] + it('should return renderable data about basic estimates appropriate for buttons with less info', function () { + tests.forEach((test) => { + assert.deepEqual( + getRenderableEstimateDataForSmallButtonsFromGWEI(test.mockState), + test.expectedResult + ) + }) }) }) }) + + describe('getCustomStorageLimit()', function () { + it('should return gas.customData.limit', function () {}) + const mockState = { + storageLimit: { customData: { limit: 'mockStorageLimit' } }, + } + assert.equal(getCustomStorageLimit(mockState), 'mockStorageLimit') + }) }) diff --git a/ui/app/selectors/custom-storageLimit.js b/ui/app/selectors/custom-storageLimit.js index e9ea96098816..e36682ff552f 100644 --- a/ui/app/selectors/custom-storageLimit.js +++ b/ui/app/selectors/custom-storageLimit.js @@ -6,6 +6,6 @@ export function getCustomStorageLimit (state) { return state.storageLimit.customData.limit } -export function getCustomStorageTotal (state) { +export function getCustomStorageLimitTotal (state) { return state.storageLimit.customData.total } diff --git a/yarn.lock b/yarn.lock index 7f1040950923..2a1764844248 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15301,6 +15301,20 @@ js-conflux-sdk@^0.9.0-alpha: secp256k1 "^3.7.1" superagent "^5.1.0" +js-conflux-sdk@^0.9.1: + version "0.9.1" + resolved "https://registry.yarnpkg.com/js-conflux-sdk/-/js-conflux-sdk-0.9.1.tgz#2b5f15a71d444447520893c5c401b45d2d6dd5b7" + integrity sha512-D87/WhbnXXTtBRBFW2xAS8LAWYaqQfQpHlZkax7K/wjXtWpQh/ik5g7l3lBfzFbaMncvQQos1i4fIzuy7/GFzg== + dependencies: + "@babel/runtime" "^7.8.4" + big.js "^5.2.2" + esm "^3.2.25" + jsbi "^3.1.1" + keccak "^2.0.0" + lodash "^4.17.15" + secp256k1 "^3.7.1" + superagent "^5.1.0" + js-levenshtein@^1.1.3: version "1.1.6" resolved "https://registry.yarnpkg.com/js-levenshtein/-/js-levenshtein-1.1.6.tgz#c6cee58eb3550372df8deb85fad5ce66ce01d59d"