mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
parent
f7ab4577f6
commit
8dddf48904
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
## Current Develop Branch
|
## 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
|
## 6.0.1 Tue Feb 12 2019
|
||||||
|
|
||||||
- [#6139](https://github.com/MetaMask/metamask-extension/pull/6139) Fix advanced gas controls on the confirm screen
|
- [#6139](https://github.com/MetaMask/metamask-extension/pull/6139) Fix advanced gas controls on the confirm screen
|
||||||
|
@ -678,6 +678,9 @@
|
|||||||
"knownAddressRecipient": {
|
"knownAddressRecipient": {
|
||||||
"message": "Known contract address."
|
"message": "Known contract address."
|
||||||
},
|
},
|
||||||
|
"invalidAddressRecipientNotEthNetwork": {
|
||||||
|
"message": "Not ETH network, set to lowercase"
|
||||||
|
},
|
||||||
"invalidGasParams": {
|
"invalidGasParams": {
|
||||||
"message": "Invalid Gas Parameters"
|
"message": "Invalid Gas Parameters"
|
||||||
},
|
},
|
||||||
|
@ -453,6 +453,9 @@
|
|||||||
"invalidAddressRecipient": {
|
"invalidAddressRecipient": {
|
||||||
"message": "Dirección del destinatario invalida"
|
"message": "Dirección del destinatario invalida"
|
||||||
},
|
},
|
||||||
|
"invalidAddressRecipientNotEthNetwork": {
|
||||||
|
"message": "No es una red ETH, convertirlo a minúscula"
|
||||||
|
},
|
||||||
"invalidGasParams": {
|
"invalidGasParams": {
|
||||||
"message": "Parametros de gas inválidos"
|
"message": "Parametros de gas inválidos"
|
||||||
},
|
},
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
"test:mascara:build:locales": "mkdirp dist/chrome && cp -R app/_locales dist/chrome/_locales",
|
"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: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",
|
"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",
|
"sentry:publish": "node ./development/sentry-publish.js",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"lint:fix": "eslint . --fix",
|
"lint:fix": "eslint . --fix",
|
||||||
|
@ -77,6 +77,7 @@ AccountDetailsModal.prototype.render = function () {
|
|||||||
h(QrView, {
|
h(QrView, {
|
||||||
Qr: {
|
Qr: {
|
||||||
data: address,
|
data: address,
|
||||||
|
network: network,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ function QrCodeView () {
|
|||||||
|
|
||||||
QrCodeView.prototype.render = function () {
|
QrCodeView.prototype.render = function () {
|
||||||
const props = this.props
|
const props = this.props
|
||||||
const { message, data } = props.Qr
|
const { message, data, network } = props.Qr
|
||||||
const address = `${isHexPrefixed(data) ? 'ethereum:' : ''}${checksumAddress(data)}`
|
const address = `${isHexPrefixed(data) ? 'ethereum:' : ''}${checksumAddress(data, network)}`
|
||||||
const qrImage = qrCode(4, 'M')
|
const qrImage = qrCode(4, 'M')
|
||||||
qrImage.addData(address)
|
qrImage.addData(address)
|
||||||
qrImage.make()
|
qrImage.make()
|
||||||
@ -51,7 +51,7 @@ QrCodeView.prototype.render = function () {
|
|||||||
h(ReadOnlyInput, {
|
h(ReadOnlyInput, {
|
||||||
wrapperClass: 'ellip-address-wrapper',
|
wrapperClass: 'ellip-address-wrapper',
|
||||||
inputClass: 'qr-ellip-address',
|
inputClass: 'qr-ellip-address',
|
||||||
value: checksumAddress(data),
|
value: checksumAddress(data, network),
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,13 @@ class SelectedAccount extends Component {
|
|||||||
static propTypes = {
|
static propTypes = {
|
||||||
selectedAddress: PropTypes.string,
|
selectedAddress: PropTypes.string,
|
||||||
selectedIdentity: PropTypes.object,
|
selectedIdentity: PropTypes.object,
|
||||||
|
network: PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { t } = this.context
|
const { t } = this.context
|
||||||
const { selectedAddress, selectedIdentity } = this.props
|
const { selectedAddress, selectedIdentity, network } = this.props
|
||||||
const checksummedAddress = checksumAddress(selectedAddress)
|
const checksummedAddress = checksumAddress(selectedAddress, network)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="selected-account">
|
<div className="selected-account">
|
||||||
|
@ -7,6 +7,7 @@ const mapStateToProps = state => {
|
|||||||
return {
|
return {
|
||||||
selectedAddress: selectors.getSelectedAddress(state),
|
selectedAddress: selectors.getSelectedAddress(state),
|
||||||
selectedIdentity: selectors.getSelectedIdentity(state),
|
selectedIdentity: selectors.getSelectedIdentity(state),
|
||||||
|
network: state.metamask.network,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,9 +29,9 @@ export default class SendToRow extends Component {
|
|||||||
t: PropTypes.func,
|
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 { 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)
|
const toWarningObject = getToWarningObject(to, toWarning, tokens, selectedToken)
|
||||||
updateSendTo(to, nickname)
|
updateSendTo(to, nickname)
|
||||||
updateSendToError(toErrorObject)
|
updateSendToError(toErrorObject)
|
||||||
@ -69,7 +69,7 @@ export default class SendToRow extends Component {
|
|||||||
inError={inError}
|
inError={inError}
|
||||||
name={'address'}
|
name={'address'}
|
||||||
network={network}
|
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()}
|
openDropdown={() => openToDropdown()}
|
||||||
placeholder={this.context.t('recipientAddress')}
|
placeholder={this.context.t('recipientAddress')}
|
||||||
to={to}
|
to={to}
|
||||||
|
@ -2,20 +2,21 @@ const {
|
|||||||
REQUIRED_ERROR,
|
REQUIRED_ERROR,
|
||||||
INVALID_RECIPIENT_ADDRESS_ERROR,
|
INVALID_RECIPIENT_ADDRESS_ERROR,
|
||||||
KNOWN_RECIPIENT_ADDRESS_ERROR,
|
KNOWN_RECIPIENT_ADDRESS_ERROR,
|
||||||
|
INVALID_RECIPIENT_ADDRESS_NOT_ETH_NETWORK_ERROR,
|
||||||
} = require('../../send.constants')
|
} = require('../../send.constants')
|
||||||
const { isValidAddress } = require('../../../../util')
|
const { isValidAddress, isEthNetwork } = require('../../../../util')
|
||||||
import { checkExistingAddresses } from '../../../pages/add-token/util'
|
import { checkExistingAddresses } from '../../../pages/add-token/util'
|
||||||
|
|
||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
const contractMap = require('eth-contract-metadata')
|
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 (!to) {
|
||||||
if (!hasHexData) {
|
if (!hasHexData) {
|
||||||
toError = REQUIRED_ERROR
|
toError = REQUIRED_ERROR
|
||||||
}
|
}
|
||||||
} else if (!isValidAddress(to) && !toError) {
|
} else if (!isValidAddress(to, network) && !toError) {
|
||||||
toError = INVALID_RECIPIENT_ADDRESS_ERROR
|
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))) {
|
} else if (selectedToken && (ethUtil.toChecksumAddress(to) in contractMap || checkExistingAddresses(to, tokens))) {
|
||||||
toError = KNOWN_RECIPIENT_ADDRESS_ERROR
|
toError = KNOWN_RECIPIENT_ADDRESS_ERROR
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ describe('SendToRow Component', function () {
|
|||||||
assert.equal(SendToRow.prototype.handleToChange.callCount, 1)
|
assert.equal(SendToRow.prototype.handleToChange.callCount, 1)
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
SendToRow.prototype.handleToChange.getCall(0).args,
|
SendToRow.prototype.handleToChange.getCall(0).args,
|
||||||
['mockNewTo', 'mockNewNickname', 'mockToError', 'mockToWarning']
|
['mockNewTo', 'mockNewNickname', 'mockToError', 'mockToWarning', 'mockNetwork' ]
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -26,6 +26,7 @@ const INSUFFICIENT_FUNDS_ERROR = 'insufficientFunds'
|
|||||||
const INSUFFICIENT_TOKENS_ERROR = 'insufficientTokens'
|
const INSUFFICIENT_TOKENS_ERROR = 'insufficientTokens'
|
||||||
const NEGATIVE_ETH_ERROR = 'negativeETH'
|
const NEGATIVE_ETH_ERROR = 'negativeETH'
|
||||||
const INVALID_RECIPIENT_ADDRESS_ERROR = 'invalidAddressRecipient'
|
const INVALID_RECIPIENT_ADDRESS_ERROR = 'invalidAddressRecipient'
|
||||||
|
const INVALID_RECIPIENT_ADDRESS_NOT_ETH_NETWORK_ERROR = 'invalidAddressRecipientNotEthNetwork'
|
||||||
const REQUIRED_ERROR = 'required'
|
const REQUIRED_ERROR = 'required'
|
||||||
const KNOWN_RECIPIENT_ADDRESS_ERROR = 'knownAddressRecipient'
|
const KNOWN_RECIPIENT_ADDRESS_ERROR = 'knownAddressRecipient'
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ module.exports = {
|
|||||||
INSUFFICIENT_TOKENS_ERROR,
|
INSUFFICIENT_TOKENS_ERROR,
|
||||||
INVALID_RECIPIENT_ADDRESS_ERROR,
|
INVALID_RECIPIENT_ADDRESS_ERROR,
|
||||||
KNOWN_RECIPIENT_ADDRESS_ERROR,
|
KNOWN_RECIPIENT_ADDRESS_ERROR,
|
||||||
|
INVALID_RECIPIENT_ADDRESS_NOT_ETH_NETWORK_ERROR,
|
||||||
MIN_GAS_LIMIT_DEC,
|
MIN_GAS_LIMIT_DEC,
|
||||||
MIN_GAS_LIMIT_HEX,
|
MIN_GAS_LIMIT_HEX,
|
||||||
MIN_GAS_PRICE_DEC,
|
MIN_GAS_PRICE_DEC,
|
||||||
|
@ -125,10 +125,11 @@ WalletView.prototype.render = function () {
|
|||||||
showAccountDetailModal,
|
showAccountDetailModal,
|
||||||
hideSidebar,
|
hideSidebar,
|
||||||
identities,
|
identities,
|
||||||
|
network,
|
||||||
} = this.props
|
} = this.props
|
||||||
// temporary logs + fake extra wallets
|
// temporary logs + fake extra wallets
|
||||||
|
|
||||||
const checksummedAddress = checksumAddress(selectedAddress)
|
const checksummedAddress = checksumAddress(selectedAddress, network)
|
||||||
|
|
||||||
if (!selectedAddress) {
|
if (!selectedAddress) {
|
||||||
throw new Error('selectedAddress should not be ' + String(selectedAddress))
|
throw new Error('selectedAddress should not be ' + String(selectedAddress))
|
||||||
|
@ -60,6 +60,15 @@ module.exports = {
|
|||||||
getTokenAddressFromTokenObject,
|
getTokenAddressFromTokenObject,
|
||||||
checksumAddress,
|
checksumAddress,
|
||||||
addressSlicer,
|
addressSlicer,
|
||||||
|
isEthNetwork,
|
||||||
|
}
|
||||||
|
|
||||||
|
function isEthNetwork (netId) {
|
||||||
|
if (!netId || netId === '1' || netId === '3' || netId === '4' || netId === '42' || netId === '5777') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
function valuesFor (obj) {
|
function valuesFor (obj) {
|
||||||
@ -83,9 +92,10 @@ function miniAddressSummary (address) {
|
|||||||
return checked ? checked.slice(0, 4) + '...' + checked.slice(-4) : '...'
|
return checked ? checked.slice(0, 4) + '...' + checked.slice(-4) : '...'
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidAddress (address) {
|
function isValidAddress (address, network) {
|
||||||
var prefixed = ethUtil.addHexPrefix(address)
|
var prefixed = ethUtil.addHexPrefix(address)
|
||||||
if (address === '0x0000000000000000000000000000000000000000') return false
|
if (address === '0x0000000000000000000000000000000000000000') return false
|
||||||
|
if (!isEthNetwork(network)) return (ethUtil.isValidAddress(prefixed) && address === address.toLowerCase())
|
||||||
return (isAllOneCase(prefixed) && ethUtil.isValidAddress(prefixed)) || ethUtil.isValidChecksumAddress(prefixed)
|
return (isAllOneCase(prefixed) && ethUtil.isValidAddress(prefixed)) || ethUtil.isValidChecksumAddress(prefixed)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,10 +309,13 @@ function getTokenAddressFromTokenObject (token) {
|
|||||||
* Safely checksumms a potentially-null address
|
* Safely checksumms a potentially-null address
|
||||||
*
|
*
|
||||||
* @param {String} [address] - address to checksum
|
* @param {String} [address] - address to checksum
|
||||||
|
* @param {String} [network] - network id
|
||||||
* @returns {String} - checksummed address
|
* @returns {String} - checksummed address
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
function checksumAddress (address) {
|
function checksumAddress (address, network) {
|
||||||
return address ? ethUtil.toChecksumAddress(address) : ''
|
const checksummed = address ? ethUtil.toChecksumAddress(address) : ''
|
||||||
|
return checksummed && network && !isEthNetwork(network) ? checksummed.toLowerCase() : checksummed
|
||||||
}
|
}
|
||||||
|
|
||||||
function addressSlicer (address = '') {
|
function addressSlicer (address = '') {
|
||||||
|
Loading…
Reference in New Issue
Block a user