aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md10
-rw-r--r--app/_locales/en/messages.json3
-rw-r--r--app/_locales/es/messages.json3
-rw-r--r--app/manifest.json2
-rw-r--r--app/scripts/controllers/network/network.js2
-rw-r--r--app/scripts/controllers/recent-blocks.js31
-rw-r--r--app/scripts/metamask-controller.js1
-rw-r--r--package.json2
-rw-r--r--test/e2e/beta/metamask-beta-ui.spec.js48
-rw-r--r--ui/app/components/modals/account-details-modal.js1
-rw-r--r--ui/app/components/pages/add-token/add-token.component.js20
-rw-r--r--ui/app/components/pages/add-token/index.scss20
-rw-r--r--ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.container.js10
-rw-r--r--ui/app/components/pages/first-time-flow/create-password/import-with-seed-phrase/import-with-seed-phrase.component.js6
-rw-r--r--ui/app/components/qr-code.js6
-rw-r--r--ui/app/components/selected-account/selected-account.component.js5
-rw-r--r--ui/app/components/selected-account/selected-account.container.js1
-rw-r--r--ui/app/components/send/send-content/send-to-row/send-to-row.component.js6
-rw-r--r--ui/app/components/send/send-content/send-to-row/send-to-row.utils.js9
-rw-r--r--ui/app/components/send/send-content/send-to-row/tests/send-to-row-component.test.js2
-rw-r--r--ui/app/components/send/send.constants.js2
-rw-r--r--ui/app/components/wallet-view.js3
-rw-r--r--ui/app/util.js19
23 files changed, 181 insertions, 31 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 964b698ea..c8fb53cd8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,16 @@
## Current Develop Branch
+-[#5973] (https://github.com/MetaMask/metamask-extension/pull/5973): Fix incorrectly showing checksums on non-ETH blockchains (issue 5838)
+
+## 6.0.1 Tue Feb 12 2019
+
+- [#6139](https://github.com/MetaMask/metamask-extension/pull/6139) Fix advanced gas controls on the confirm screen
+- [#6134](https://github.com/MetaMask/metamask-extension/pull/6134) Trim whitespace from seed phrase during import
+- [#6119](https://github.com/MetaMask/metamask-extension/pull/6119) Update Italian translation
+- [#6125](https://github.com/MetaMask/metamask-extension/pull/6125) Improved Traditional Chinese translation
+
+
## 6.0.0 Thu Feb 07 2019
- [#6082](https://github.com/MetaMask/metamask-extension/pull/6082): Migrate all users to the new UI
diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json
index 2ace2c2a8..662ab8548 100644
--- a/app/_locales/en/messages.json
+++ b/app/_locales/en/messages.json
@@ -678,6 +678,9 @@
"knownAddressRecipient": {
"message": "Known contract address."
},
+ "invalidAddressRecipientNotEthNetwork": {
+ "message": "Not ETH network, set to lowercase"
+ },
"invalidGasParams": {
"message": "Invalid Gas Parameters"
},
diff --git a/app/_locales/es/messages.json b/app/_locales/es/messages.json
index 15910c871..04e0c9f05 100644
--- a/app/_locales/es/messages.json
+++ b/app/_locales/es/messages.json
@@ -453,6 +453,9 @@
"invalidAddressRecipient": {
"message": "Dirección del destinatario invalida"
},
+ "invalidAddressRecipientNotEthNetwork": {
+ "message": "No es una red ETH, convertirlo a minúscula"
+ },
"invalidGasParams": {
"message": "Parametros de gas inválidos"
},
diff --git a/app/manifest.json b/app/manifest.json
index 120223aca..77dcc1412 100644
--- a/app/manifest.json
+++ b/app/manifest.json
@@ -1,7 +1,7 @@
{
"name": "__MSG_appName__",
"short_name": "__MSG_appName__",
- "version": "6.0.0",
+ "version": "6.0.1",
"manifest_version": 2,
"author": "https://metamask.io",
"description": "__MSG_appDescription__",
diff --git a/app/scripts/controllers/network/network.js b/app/scripts/controllers/network/network.js
index 1a251bce1..2958ba3b0 100644
--- a/app/scripts/controllers/network/network.js
+++ b/app/scripts/controllers/network/network.js
@@ -158,7 +158,7 @@ module.exports = class NetworkController extends EventEmitter {
_switchNetwork (opts) {
this.setNetworkState('loading')
this._configureProvider(opts)
- this.emit('networkDidChange')
+ this.emit('networkDidChange', opts.type)
}
_configureProvider (opts) {
diff --git a/app/scripts/controllers/recent-blocks.js b/app/scripts/controllers/recent-blocks.js
index d270f6f44..982ad2aa4 100644
--- a/app/scripts/controllers/recent-blocks.js
+++ b/app/scripts/controllers/recent-blocks.js
@@ -3,6 +3,14 @@ const extend = require('xtend')
const EthQuery = require('eth-query')
const log = require('loglevel')
const pify = require('pify')
+const {
+ ROPSTEN,
+ RINKEBY,
+ KOVAN,
+ MAINNET,
+} = require('./network/enums')
+const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET]
+
class RecentBlocksController {
@@ -24,7 +32,7 @@ class RecentBlocksController {
*
*/
constructor (opts = {}) {
- const { blockTracker, provider } = opts
+ const { blockTracker, provider, networkController } = opts
this.blockTracker = blockTracker
this.ethQuery = new EthQuery(provider)
this.historyLength = opts.historyLength || 40
@@ -33,13 +41,30 @@ class RecentBlocksController {
recentBlocks: [],
}, opts.initState)
this.store = new ObservableStore(initState)
-
- this.blockTracker.on('latest', async (newBlockNumberHex) => {
+ const blockListner = async (newBlockNumberHex) => {
try {
await this.processBlock(newBlockNumberHex)
} catch (err) {
log.error(err)
}
+ }
+ let isListening = false
+ const { type } = networkController.getProviderConfig()
+ if (!INFURA_PROVIDER_TYPES.includes(type) && type !== 'loading') {
+ this.blockTracker.on('latest', blockListner)
+ isListening = true
+ }
+ networkController.on('networkDidChange', (newType) => {
+ if (INFURA_PROVIDER_TYPES.includes(newType) && isListening) {
+ this.blockTracker.removeListener('latest', blockListner)
+ } else if (
+ !INFURA_PROVIDER_TYPES.includes(type) &&
+ type !== 'loading' &&
+ !isListening
+ ) {
+ this.blockTracker.on('latest', blockListner)
+
+ }
})
this.backfill()
}
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 8de17d7f0..65cc2d3eb 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -126,6 +126,7 @@ module.exports = class MetamaskController extends EventEmitter {
this.recentBlocksController = new RecentBlocksController({
blockTracker: this.blockTracker,
provider: this.provider,
+ networkController: this.networkController,
})
// account tracker watches balances, nonces, and any code at their address.
diff --git a/package.json b/package.json
index a2c308979..02dc3278c 100644
--- a/package.json
+++ b/package.json
@@ -38,7 +38,7 @@
"test:mascara:build:locales": "mkdirp dist/chrome && cp -R app/_locales dist/chrome/_locales",
"test:mascara:build:background": "browserify mascara/src/background.js -o dist/mascara/background.js",
"test:mascara:build:tests": "browserify test/integration/lib/first-time.js -o dist/mascara/tests.js",
- "ganache:start": "ganache-cli --noVMErrorsOnRPCResponse -m 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent'",
+ "ganache:start": "ganache-cli --noVMErrorsOnRPCResponse -i 5777 -m 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent'",
"sentry:publish": "node ./development/sentry-publish.js",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
diff --git a/test/e2e/beta/metamask-beta-ui.spec.js b/test/e2e/beta/metamask-beta-ui.spec.js
index a824763e0..bde031301 100644
--- a/test/e2e/beta/metamask-beta-ui.spec.js
+++ b/test/e2e/beta/metamask-beta-ui.spec.js
@@ -480,12 +480,36 @@ describe('MetaMask', function () {
})
})
- describe('Send ETH from dapp', () => {
+ describe('Send ETH from dapp using advanced gas controls', () => {
let windowHandles
let extension
let popup
let dapp
+ it('goes to the settings screen', async () => {
+ await driver.findElement(By.css('.account-menu__icon')).click()
+ await delay(regularDelayMs)
+
+ const settingsButton = await findElement(driver, By.xpath(`//div[contains(text(), 'Settings')]`))
+ settingsButton.click()
+
+ await findElement(driver, By.css('.tab-bar'))
+
+ const advancedGasTitle = await findElement(driver, By.xpath(`//span[contains(text(), 'Advanced gas controls')]`))
+ await driver.executeScript('arguments[0].scrollIntoView(true)', advancedGasTitle)
+
+ const advancedGasToggle = await findElement(driver, By.css('.settings-page__content-row:nth-of-type(11) .settings-page__content-item-col > div'))
+ await advancedGasToggle.click()
+ windowHandles = await driver.getAllWindowHandles()
+ extension = windowHandles[0]
+ await closeAllWindowHandlesExcept(driver, [extension])
+
+ const metamaskHomeButton = await findElement(driver, By.css('.app-header__logo-container'))
+ await metamaskHomeButton.click()
+
+ await delay(largeDelayMs)
+ })
+
it('starts a send transaction inside the dapp', async () => {
await openNewPage(driver, 'http://127.0.0.1:8080/')
await delay(regularDelayMs)
@@ -516,6 +540,17 @@ describe('MetaMask', function () {
await assertElementNotPresent(webdriver, driver, By.xpath(`//li[contains(text(), 'Data')]`))
+ const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-gas-inputs__gas-edit-row__input'))
+ await gasPriceInput.clear()
+ await delay(tinyDelayMs)
+
+ await gasPriceInput.sendKeys(Key.BACK_SPACE)
+ await gasPriceInput.sendKeys(Key.BACK_SPACE)
+ await gasPriceInput.sendKeys('10')
+ await delay(tinyDelayMs)
+ await gasLimitInput.sendKeys('5')
+ await delay(tinyDelayMs)
+
const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`), 10000)
await confirmButton.click()
await delay(regularDelayMs)
@@ -532,6 +567,17 @@ describe('MetaMask', function () {
const txValues = await findElement(driver, By.css('.transaction-list-item__amount--primary'))
await driver.wait(until.elementTextMatches(txValues, /-3\s*ETH/), 10000)
})
+
+ it('the transaction has the expected gas price', async function () {
+ const txValues = await findElement(driver, By.css('.transaction-list-item__amount--primary'))
+ await txValues.click()
+ await delay(tinyDelayMs)
+ await findElement(driver, By.xpath(`//div[contains(text(), 'Gas Price (GWEI)')]`))
+
+ await findElement(driver, By.xpath(`//span[contains(text(), '7')]`))
+
+ txValues.click()
+ })
})
describe('Navigate transactions', () => {
diff --git a/ui/app/components/modals/account-details-modal.js b/ui/app/components/modals/account-details-modal.js
index 248ffe008..67d8eb0fd 100644
--- a/ui/app/components/modals/account-details-modal.js
+++ b/ui/app/components/modals/account-details-modal.js
@@ -77,6 +77,7 @@ AccountDetailsModal.prototype.render = function () {
h(QrView, {
Qr: {
data: address,
+ network: network,
},
}),
diff --git a/ui/app/components/pages/add-token/add-token.component.js b/ui/app/components/pages/add-token/add-token.component.js
index 82299bf88..e860d33bc 100644
--- a/ui/app/components/pages/add-token/add-token.component.js
+++ b/ui/app/components/pages/add-token/add-token.component.js
@@ -43,6 +43,7 @@ class AddToken extends Component {
customDecimalsError: null,
autoFilled: false,
displayedTab: SEARCH_TAB,
+ forceEditSymbol: false,
}
}
@@ -225,6 +226,7 @@ class AddToken extends Component {
customSymbolError,
customDecimalsError,
autoFilled,
+ forceEditSymbol,
} = this.state
return (
@@ -241,14 +243,28 @@ class AddToken extends Component {
/>
<TextField
id="custom-symbol"
- label={this.context.t('tokenSymbol')}
+ label={(
+ <div className="add-token__custom-symbol__label-wrapper">
+ <span className="add-token__custom-symbol__label">
+ {this.context.t('tokenSymbol')}
+ </span>
+ {(autoFilled && !forceEditSymbol) && (
+ <div
+ className="add-token__custom-symbol__edit"
+ onClick={() => this.setState({ forceEditSymbol: true })}
+ >
+ {this.context.t('edit')}
+ </div>
+ )}
+ </div>
+ )}
type="text"
value={customSymbol}
onChange={e => this.handleCustomSymbolChange(e.target.value)}
error={customSymbolError}
fullWidth
margin="normal"
- disabled={autoFilled}
+ disabled={autoFilled && !forceEditSymbol}
/>
<TextField
id="custom-decimals"
diff --git a/ui/app/components/pages/add-token/index.scss b/ui/app/components/pages/add-token/index.scss
index 39e86b97b..1690c7654 100644
--- a/ui/app/components/pages/add-token/index.scss
+++ b/ui/app/components/pages/add-token/index.scss
@@ -22,4 +22,24 @@
&__token-list {
margin-top: 16px;
}
+
+ &__custom-symbol {
+
+ &__label-wrapper {
+ display: flex;
+ flex-flow: row nowrap;
+ }
+
+ &__label {
+ flex: 0 0 auto;
+ }
+
+ &__edit {
+ flex: 1 1 auto;
+ text-align: right;
+ color: $curious-blue;
+ padding-right: 4px;
+ cursor: pointer;
+ }
+ }
}
diff --git a/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.container.js b/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.container.js
index 2ecbe4a64..e11b35459 100644
--- a/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.container.js
+++ b/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.container.js
@@ -17,7 +17,7 @@ import { getHexGasTotal } from '../../../helpers/confirm-transaction/util'
import { isBalanceSufficient, calcGasTotal } from '../../send/send.utils'
import { conversionGreaterThan } from '../../../conversion-util'
import { MIN_GAS_LIMIT_DEC } from '../../send/send.constants'
-import { addressSlicer, valuesFor } from '../../../util'
+import { checksumAddress, addressSlicer, valuesFor } from '../../../util'
import { getMetaMaskAccounts, getAdvancedInlineGasShown } from '../../../selectors'
const casedContractMap = Object.keys(contractMap).reduce((acc, base) => {
@@ -77,7 +77,11 @@ const mapStateToProps = (state, props) => {
const toAddress = propsToAddress || txParamsToAddress
const toName = identities[toAddress]
? identities[toAddress].name
- : casedContractMap[toAddress] ? casedContractMap[toAddress].name : addressSlicer(toAddress)
+ : (
+ casedContractMap[toAddress]
+ ? casedContractMap[toAddress].name
+ : addressSlicer(checksumAddress(toAddress))
+ )
const isTxReprice = Boolean(lastGasPrice)
@@ -221,7 +225,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
validate: validateEditGas,
}),
cancelAllTransactions: () => dispatchCancelAllTransactions(valuesFor(unapprovedTxs)),
- updateGasAndCalculate,
+ updateGasAndCalculate: dispatchUpdateGasAndCalculate,
}
}
diff --git a/ui/app/components/pages/first-time-flow/create-password/import-with-seed-phrase/import-with-seed-phrase.component.js b/ui/app/components/pages/first-time-flow/create-password/import-with-seed-phrase/import-with-seed-phrase.component.js
index 8d81e5d8e..6f8ab031a 100644
--- a/ui/app/components/pages/first-time-flow/create-password/import-with-seed-phrase/import-with-seed-phrase.component.js
+++ b/ui/app/components/pages/first-time-flow/create-password/import-with-seed-phrase/import-with-seed-phrase.component.js
@@ -30,6 +30,7 @@ export default class ImportWithSeedPhrase extends PureComponent {
parseSeedPhrase = (seedPhrase) => {
return seedPhrase
+ .trim()
.match(/\w+/g)
.join(' ')
}
@@ -38,9 +39,10 @@ export default class ImportWithSeedPhrase extends PureComponent {
let seedPhraseError = ''
if (seedPhrase) {
- if (this.parseSeedPhrase(seedPhrase).split(' ').length !== 12) {
+ const parsedSeedPhrase = this.parseSeedPhrase(seedPhrase)
+ if (parsedSeedPhrase.split(' ').length !== 12) {
seedPhraseError = this.context.t('seedPhraseReq')
- } else if (!validateMnemonic(seedPhrase)) {
+ } else if (!validateMnemonic(parsedSeedPhrase)) {
seedPhraseError = this.context.t('invalidSeedPhrase')
}
}
diff --git a/ui/app/components/qr-code.js b/ui/app/components/qr-code.js
index d3242ddf5..1c07e244c 100644
--- a/ui/app/components/qr-code.js
+++ b/ui/app/components/qr-code.js
@@ -25,8 +25,8 @@ function QrCodeView () {
QrCodeView.prototype.render = function () {
const props = this.props
- const { message, data } = props.Qr
- const address = `${isHexPrefixed(data) ? 'ethereum:' : ''}${checksumAddress(data)}`
+ const { message, data, network } = props.Qr
+ const address = `${isHexPrefixed(data) ? 'ethereum:' : ''}${checksumAddress(data, network)}`
const qrImage = qrCode(4, 'M')
qrImage.addData(address)
qrImage.make()
@@ -51,7 +51,7 @@ QrCodeView.prototype.render = function () {
h(ReadOnlyInput, {
wrapperClass: 'ellip-address-wrapper',
inputClass: 'qr-ellip-address',
- value: checksumAddress(data),
+ value: checksumAddress(data, network),
}),
])
}
diff --git a/ui/app/components/selected-account/selected-account.component.js b/ui/app/components/selected-account/selected-account.component.js
index 4f98df9b6..47c56e312 100644
--- a/ui/app/components/selected-account/selected-account.component.js
+++ b/ui/app/components/selected-account/selected-account.component.js
@@ -17,12 +17,13 @@ class SelectedAccount extends Component {
static propTypes = {
selectedAddress: PropTypes.string,
selectedIdentity: PropTypes.object,
+ network: PropTypes.string,
}
render () {
const { t } = this.context
- const { selectedAddress, selectedIdentity } = this.props
- const checksummedAddress = checksumAddress(selectedAddress)
+ const { selectedAddress, selectedIdentity, network } = this.props
+ const checksummedAddress = checksumAddress(selectedAddress, network)
return (
<div className="selected-account">
diff --git a/ui/app/components/selected-account/selected-account.container.js b/ui/app/components/selected-account/selected-account.container.js
index f9e061d15..1c8d17d8d 100644
--- a/ui/app/components/selected-account/selected-account.container.js
+++ b/ui/app/components/selected-account/selected-account.container.js
@@ -7,6 +7,7 @@ const mapStateToProps = state => {
return {
selectedAddress: selectors.getSelectedAddress(state),
selectedIdentity: selectors.getSelectedIdentity(state),
+ network: state.metamask.network,
}
}
diff --git a/ui/app/components/send/send-content/send-to-row/send-to-row.component.js b/ui/app/components/send/send-content/send-to-row/send-to-row.component.js
index 0f26dd55c..3fbf9a76b 100644
--- a/ui/app/components/send/send-content/send-to-row/send-to-row.component.js
+++ b/ui/app/components/send/send-content/send-to-row/send-to-row.component.js
@@ -29,9 +29,9 @@ export default class SendToRow extends Component {
t: PropTypes.func,
}
- handleToChange (to, nickname = '', toError, toWarning) {
+ handleToChange (to, nickname = '', toError, toWarning, network) {
const { hasHexData, updateSendTo, updateSendToError, updateGas, tokens, selectedToken, updateSendToWarning } = this.props
- const toErrorObject = getToErrorObject(to, toError, hasHexData)
+ const toErrorObject = getToErrorObject(to, toError, hasHexData, tokens, selectedToken, network)
const toWarningObject = getToWarningObject(to, toWarning, tokens, selectedToken)
updateSendTo(to, nickname)
updateSendToError(toErrorObject)
@@ -69,7 +69,7 @@ export default class SendToRow extends Component {
inError={inError}
name={'address'}
network={network}
- onChange={({ toAddress, nickname, toError, toWarning }) => this.handleToChange(toAddress, nickname, toError, toWarning)}
+ onChange={({ toAddress, nickname, toError, toWarning }) => this.handleToChange(toAddress, nickname, toError, toWarning, this.props.network)}
openDropdown={() => openToDropdown()}
placeholder={this.context.t('recipientAddress')}
to={to}
diff --git a/ui/app/components/send/send-content/send-to-row/send-to-row.utils.js b/ui/app/components/send/send-content/send-to-row/send-to-row.utils.js
index 4a8add42e..2bd3ea45e 100644
--- a/ui/app/components/send/send-content/send-to-row/send-to-row.utils.js
+++ b/ui/app/components/send/send-content/send-to-row/send-to-row.utils.js
@@ -2,20 +2,21 @@ const {
REQUIRED_ERROR,
INVALID_RECIPIENT_ADDRESS_ERROR,
KNOWN_RECIPIENT_ADDRESS_ERROR,
+ INVALID_RECIPIENT_ADDRESS_NOT_ETH_NETWORK_ERROR,
} = require('../../send.constants')
-const { isValidAddress } = require('../../../../util')
+const { isValidAddress, isEthNetwork } = require('../../../../util')
import { checkExistingAddresses } from '../../../pages/add-token/util'
const ethUtil = require('ethereumjs-util')
const contractMap = require('eth-contract-metadata')
-function getToErrorObject (to, toError = null, hasHexData = false, tokens = [], selectedToken = null) {
+function getToErrorObject (to, toError = null, hasHexData = false, tokens = [], selectedToken = null, network) {
if (!to) {
if (!hasHexData) {
toError = REQUIRED_ERROR
}
- } else if (!isValidAddress(to) && !toError) {
- toError = INVALID_RECIPIENT_ADDRESS_ERROR
+ } else if (!isValidAddress(to, network) && !toError) {
+ toError = isEthNetwork(network) ? INVALID_RECIPIENT_ADDRESS_ERROR : INVALID_RECIPIENT_ADDRESS_NOT_ETH_NETWORK_ERROR
} else if (selectedToken && (ethUtil.toChecksumAddress(to) in contractMap || checkExistingAddresses(to, tokens))) {
toError = KNOWN_RECIPIENT_ADDRESS_ERROR
}
diff --git a/ui/app/components/send/send-content/send-to-row/tests/send-to-row-component.test.js b/ui/app/components/send/send-content/send-to-row/tests/send-to-row-component.test.js
index d3732307f..d4d054057 100644
--- a/ui/app/components/send/send-content/send-to-row/tests/send-to-row-component.test.js
+++ b/ui/app/components/send/send-content/send-to-row/tests/send-to-row-component.test.js
@@ -159,7 +159,7 @@ describe('SendToRow Component', function () {
assert.equal(SendToRow.prototype.handleToChange.callCount, 1)
assert.deepEqual(
SendToRow.prototype.handleToChange.getCall(0).args,
- ['mockNewTo', 'mockNewNickname', 'mockToError', 'mockToWarning']
+ ['mockNewTo', 'mockNewNickname', 'mockToError', 'mockToWarning', 'mockNetwork' ]
)
})
})
diff --git a/ui/app/components/send/send.constants.js b/ui/app/components/send/send.constants.js
index e79734a54..490bc6fd2 100644
--- a/ui/app/components/send/send.constants.js
+++ b/ui/app/components/send/send.constants.js
@@ -26,6 +26,7 @@ const INSUFFICIENT_FUNDS_ERROR = 'insufficientFunds'
const INSUFFICIENT_TOKENS_ERROR = 'insufficientTokens'
const NEGATIVE_ETH_ERROR = 'negativeETH'
const INVALID_RECIPIENT_ADDRESS_ERROR = 'invalidAddressRecipient'
+const INVALID_RECIPIENT_ADDRESS_NOT_ETH_NETWORK_ERROR = 'invalidAddressRecipientNotEthNetwork'
const REQUIRED_ERROR = 'required'
const KNOWN_RECIPIENT_ADDRESS_ERROR = 'knownAddressRecipient'
@@ -44,6 +45,7 @@ module.exports = {
INSUFFICIENT_TOKENS_ERROR,
INVALID_RECIPIENT_ADDRESS_ERROR,
KNOWN_RECIPIENT_ADDRESS_ERROR,
+ INVALID_RECIPIENT_ADDRESS_NOT_ETH_NETWORK_ERROR,
MIN_GAS_LIMIT_DEC,
MIN_GAS_LIMIT_HEX,
MIN_GAS_PRICE_DEC,
diff --git a/ui/app/components/wallet-view.js b/ui/app/components/wallet-view.js
index 6732010a3..4566cb390 100644
--- a/ui/app/components/wallet-view.js
+++ b/ui/app/components/wallet-view.js
@@ -125,10 +125,11 @@ WalletView.prototype.render = function () {
showAccountDetailModal,
hideSidebar,
identities,
+ network,
} = this.props
// temporary logs + fake extra wallets
- const checksummedAddress = checksumAddress(selectedAddress)
+ const checksummedAddress = checksumAddress(selectedAddress, network)
if (!selectedAddress) {
throw new Error('selectedAddress should not be ' + String(selectedAddress))
diff --git a/ui/app/util.js b/ui/app/util.js
index 31757e7c3..e27956a45 100644
--- a/ui/app/util.js
+++ b/ui/app/util.js
@@ -60,6 +60,15 @@ module.exports = {
getTokenAddressFromTokenObject,
checksumAddress,
addressSlicer,
+ isEthNetwork,
+}
+
+function isEthNetwork (netId) {
+ if (!netId || netId === '1' || netId === '3' || netId === '4' || netId === '42' || netId === '5777') {
+ return true
+ }
+
+ return false
}
function valuesFor (obj) {
@@ -83,9 +92,10 @@ function miniAddressSummary (address) {
return checked ? checked.slice(0, 4) + '...' + checked.slice(-4) : '...'
}
-function isValidAddress (address) {
+function isValidAddress (address, network) {
var prefixed = ethUtil.addHexPrefix(address)
if (address === '0x0000000000000000000000000000000000000000') return false
+ if (!isEthNetwork(network)) return (ethUtil.isValidAddress(prefixed) && address === address.toLowerCase())
return (isAllOneCase(prefixed) && ethUtil.isValidAddress(prefixed)) || ethUtil.isValidChecksumAddress(prefixed)
}
@@ -299,10 +309,13 @@ function getTokenAddressFromTokenObject (token) {
* Safely checksumms a potentially-null address
*
* @param {String} [address] - address to checksum
+ * @param {String} [network] - network id
* @returns {String} - checksummed address
+ *
*/
-function checksumAddress (address) {
- return address ? ethUtil.toChecksumAddress(address) : ''
+function checksumAddress (address, network) {
+ const checksummed = address ? ethUtil.toChecksumAddress(address) : ''
+ return checksummed && network && !isEthNetwork(network) ? checksummed.toLowerCase() : checksummed
}
function addressSlicer (address = '') {