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
|
||||
|
||||
-[#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
|
||||
|
@ -678,6 +678,9 @@
|
||||
"knownAddressRecipient": {
|
||||
"message": "Known contract address."
|
||||
},
|
||||
"invalidAddressRecipientNotEthNetwork": {
|
||||
"message": "Not ETH network, set to lowercase"
|
||||
},
|
||||
"invalidGasParams": {
|
||||
"message": "Invalid Gas Parameters"
|
||||
},
|
||||
|
@ -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"
|
||||
},
|
||||
|
@ -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",
|
||||
|
@ -77,6 +77,7 @@ AccountDetailsModal.prototype.render = function () {
|
||||
h(QrView, {
|
||||
Qr: {
|
||||
data: address,
|
||||
network: network,
|
||||
},
|
||||
}),
|
||||
|
||||
|
@ -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),
|
||||
}),
|
||||
])
|
||||
}
|
||||
|
@ -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">
|
||||
|
@ -7,6 +7,7 @@ const mapStateToProps = state => {
|
||||
return {
|
||||
selectedAddress: selectors.getSelectedAddress(state),
|
||||
selectedIdentity: selectors.getSelectedIdentity(state),
|
||||
network: state.metamask.network,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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' ]
|
||||
)
|
||||
})
|
||||
})
|
||||
|
@ -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,
|
||||
|
@ -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))
|
||||
|
@ -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 = '') {
|
||||
|
Loading…
Reference in New Issue
Block a user