diff --git a/CHANGELOG.md b/CHANGELOG.md index 043a560a8..f6d821b36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [9.5.2] +### Fixed +- [#11071](https://github.com/MetaMask/metamask-extension/pull/11071): Fixing address entry error when sending a transaction on a custom network + ## [9.5.1] ### Fixed - [#11048](https://github.com/MetaMask/metamask-extension/pull/11048): Fixed icon on approval screen @@ -2226,7 +2230,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Uncategorized - Added the ability to restore accounts from seed words. -[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v9.5.1...HEAD +[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v9.5.2...HEAD +[9.5.2]: https://github.com/MetaMask/metamask-extension/compare/v9.5.1...v9.5.2 [9.5.1]: https://github.com/MetaMask/metamask-extension/compare/v9.5.0...v9.5.1 [9.5.0]: https://github.com/MetaMask/metamask-extension/compare/v9.4.0...v9.5.0 [9.4.0]: https://github.com/MetaMask/metamask-extension/compare/v9.3.0...v9.4.0 diff --git a/app/manifest/_base.json b/app/manifest/_base.json index 40c975a05..07664ccd7 100644 --- a/app/manifest/_base.json +++ b/app/manifest/_base.json @@ -71,6 +71,6 @@ "notifications" ], "short_name": "__MSG_appName__", - "version": "9.5.1", + "version": "9.5.2", "web_accessible_resources": ["inpage.js", "phishing.html"] } diff --git a/app/scripts/lib/createMetaRPCHandler.js b/app/scripts/lib/createMetaRPCHandler.js index 24ac0ff6a..9b25c6ce7 100644 --- a/app/scripts/lib/createMetaRPCHandler.js +++ b/app/scripts/lib/createMetaRPCHandler.js @@ -2,6 +2,9 @@ import { ethErrors, serializeError } from 'eth-rpc-errors'; const createMetaRPCHandler = (api, outStream) => { return (data) => { + if (outStream._writableState.ended) { + return; + } if (!api[data.method]) { outStream.write({ jsonrpc: '2.0', @@ -13,6 +16,9 @@ const createMetaRPCHandler = (api, outStream) => { return; } api[data.method](...data.params, (err, result) => { + if (outStream._writableState.ended) { + return; + } if (err) { outStream.write({ jsonrpc: '2.0', diff --git a/app/scripts/lib/createMetaRPCHandler.test.js b/app/scripts/lib/createMetaRPCHandler.test.js index e37985105..c3f644ec8 100644 --- a/app/scripts/lib/createMetaRPCHandler.test.js +++ b/app/scripts/lib/createMetaRPCHandler.test.js @@ -58,4 +58,40 @@ describe('createMetaRPCHandler', function () { done(); }); }); + it('can not throw an error for writing an error after end', function (done) { + const api = { + foo: (param1, cb) => { + assert.strictEqual(param1, 'bar'); + cb(new Error('foo-error')); + }, + }; + const streamTest = createThoughStream(); + const handler = createMetaRPCHandler(api, streamTest); + streamTest.end(); + handler({ + id: 1, + method: 'foo', + params: ['bar'], + }); + done(); + }); + it('can not throw an error for write after end', function (done) { + const api = { + foo: (param1, cb) => { + assert.strictEqual(param1, 'bar'); + cb(undefined, { + foo: 'bar', + }); + }, + }; + const streamTest = createThoughStream(); + const handler = createMetaRPCHandler(api, streamTest); + streamTest.end(); + handler({ + id: 1, + method: 'foo', + params: ['bar'], + }); + done(); + }); }); diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 2ae3c6ef1..00b3115c8 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -2024,6 +2024,9 @@ export default class MetamaskController extends EventEmitter { // set up postStream transport outStream.on('data', createMetaRPCHandler(api, outStream)); const handleUpdate = (update) => { + if (outStream._writableState.ended) { + return; + } // send notification to client-side outStream.write({ jsonrpc: '2.0', diff --git a/ui/app/components/ui/identicon/identicon.component.js b/ui/app/components/ui/identicon/identicon.component.js index bad826dc9..d52717d05 100644 --- a/ui/app/components/ui/identicon/identicon.component.js +++ b/ui/app/components/ui/identicon/identicon.component.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import classnames from 'classnames'; import contractMap from '@metamask/contract-metadata'; -import { checksumAddress } from '../../../helpers/utils/util'; +import { checksumAddress, isHex } from '../../../helpers/utils/util'; import Jazzicon from '../jazzicon'; import BlockieIdenticon from './blockieIdenticon'; @@ -85,10 +85,12 @@ export default class Identicon extends PureComponent { } if (address) { - const checksummedAddress = checksumAddress(address); + if (isHex(address)) { + const checksummedAddress = checksumAddress(address); - if (contractMap[checksummedAddress]?.logo) { - return this.renderJazzicon(); + if (contractMap[checksummedAddress]?.logo) { + return this.renderJazzicon(); + } } return ( diff --git a/ui/lib/icon-factory.js b/ui/lib/icon-factory.js index c72f5dfd9..7e8a27aca 100644 --- a/ui/lib/icon-factory.js +++ b/ui/lib/icon-factory.js @@ -1,5 +1,9 @@ import contractMap from '@metamask/contract-metadata'; -import { isValidAddress, checksumAddress } from '../app/helpers/utils/util'; +import { + isValidAddress, + checksumAddress, + isHex, +} from '../app/helpers/utils/util'; let iconFactory; @@ -16,7 +20,12 @@ function IconFactory(jazzicon) { } IconFactory.prototype.iconForAddress = function (address, diameter) { - const addr = checksumAddress(address); + let addr = address; + + if (isHex(address)) { + addr = checksumAddress(address); + } + if (iconExistsFor(addr)) { return imageElFor(addr); }