1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00

Remove KNOWN_ADDRESS_ERROR from error objects (#6578)

* Remove KNOWN_ADDRESS_ERROR from error objects

* Update test comments
This commit is contained in:
Chi Kei Chan 2019-05-08 10:34:56 -07:00 committed by GitHub
parent 7df7f709bf
commit 0497d209b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View File

@ -17,9 +17,8 @@ function getToErrorObject (to, toError = null, hasHexData = false, tokens = [],
} }
} else if (!isValidAddress(to, network) && !toError) { } else if (!isValidAddress(to, network) && !toError) {
toError = isEthNetwork(network) ? INVALID_RECIPIENT_ADDRESS_ERROR : INVALID_RECIPIENT_ADDRESS_NOT_ETH_NETWORK_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))) {
toError = KNOWN_RECIPIENT_ADDRESS_ERROR
} }
return { to: toError } return { to: toError }
} }

View File

@ -55,9 +55,9 @@ describe('send-to-row utils', () => {
}) })
}) })
it('should return a known address recipient if to is truthy but part of state tokens', () => { it('should return null if to is truthy but part of state tokens', () => {
assert.deepEqual(getToErrorObject('0xabc123', undefined, false, [{'address': '0xabc123'}], {'address': '0xabc123'}), { assert.deepEqual(getToErrorObject('0xabc123', undefined, false, [{'address': '0xabc123'}], {'address': '0xabc123'}), {
to: KNOWN_RECIPIENT_ADDRESS_ERROR, to: null,
}) })
}) })
@ -67,14 +67,14 @@ describe('send-to-row utils', () => {
}) })
}) })
it('should return a known address recipient if to is truthy but part of contract metadata', () => { it('should return null if to is truthy but part of contract metadata', () => {
assert.deepEqual(getToErrorObject('0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359', undefined, false, [{'address': '0xabc123'}], {'address': '0xabc123'}), { assert.deepEqual(getToErrorObject('0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359', undefined, false, [{'address': '0xabc123'}], {'address': '0xabc123'}), {
to: KNOWN_RECIPIENT_ADDRESS_ERROR, to: null,
}) })
}) })
it('should null if to is truthy part of contract metadata but selectedToken falsy', () => { it('should null if to is truthy part of contract metadata but selectedToken falsy', () => {
assert.deepEqual(getToErrorObject('0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359', undefined, false, [{'address': '0xabc123'}], {'address': '0xabc123'}), { assert.deepEqual(getToErrorObject('0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359', undefined, false, [{'address': '0xabc123'}], {'address': '0xabc123'}), {
to: KNOWN_RECIPIENT_ADDRESS_ERROR, to: null,
}) })
}) })
}) })