From 95b4d9111631e49d2465df7f4914987cd6757c14 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Fri, 13 Sep 2019 11:32:55 -0300 Subject: [PATCH] Replace `undefined` selectedAddress with `null` (#7161) * Replace `undefined` selectedAddress with `null` The `runtime.Port.postMessage` API will drop keys with a value of `undefined` on Chrome, but not on Firefox. This was a problem for the `publicConfig` stream, which passed the key `selectedAddress` with the value of `undefined` to communicate to dapps that the user had logged out. Instead a `null` is now passed for `selectedAddress` upon logout, which is correctly sent by the `runtime.Port.postMessage` API on both Chrome and Firefox. closes #7101 closes #7109 * Update `metamask-inpage-provider` to v3.0.0 The v3.0.0 update includes a change to the `accountsChanged` event. The event will now emit an empty array instead of an array with `undefined` or `null`. The previous behavior was to emit `[undefined]`. The previous commit would have changed that to `[null]` anyway, so we figured if we're going to make a public-facing change to the event anyway we should change it to be correct. `[undefined]` was never intended, and it technically violates EIP-1193, which states that the `accountsChanged` event should emit an array of strings. --- app/scripts/metamask-controller.js | 2 +- package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 37c3340f4..02f76cd9d 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -367,7 +367,7 @@ module.exports = class MetamaskController extends EventEmitter { const result = { isUnlocked, isEnabled, - selectedAddress: isReady ? selectedAddress : undefined, + selectedAddress: isReady ? selectedAddress : null, networkVersion: network, onboardingcomplete: completedOnboarding, chainId: selectChainId({ network, provider }), diff --git a/package.json b/package.json index d3ae90618..40364ea33 100644 --- a/package.json +++ b/package.json @@ -115,7 +115,7 @@ "lodash.shuffle": "^4.2.0", "loglevel": "^1.4.1", "luxon": "^1.8.2", - "metamask-inpage-provider": "^2.1.0", + "metamask-inpage-provider": "^3.0.0", "metamask-logo": "^2.1.4", "mkdirp": "^0.5.1", "multihashes": "^0.4.12", diff --git a/yarn.lock b/yarn.lock index ee7ef159e..f045ce5d1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14651,10 +14651,10 @@ mersenne-twister@^1.0.1: resolved "https://registry.yarnpkg.com/mersenne-twister/-/mersenne-twister-1.1.0.tgz#f916618ee43d7179efcf641bec4531eb9670978a" integrity sha1-+RZhjuQ9cXnvz2Qb7EUx65Zwl4o= -metamask-inpage-provider@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/metamask-inpage-provider/-/metamask-inpage-provider-2.1.0.tgz#69e23d63893a5e2bb7a09a6ec96c6f1500588673" - integrity sha512-1+m8Mp8/RM9JMTvDHAMt6a7aqwigRMLvU/VKKmHQFi7AZaagG8Fe4wBe8HdAMysRF3NHV/qOMw0UwP3w9m1Vaw== +metamask-inpage-provider@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/metamask-inpage-provider/-/metamask-inpage-provider-3.0.0.tgz#3b9d4bae6f67962b6a7b1a9ee1efaf424f67b6f4" + integrity sha512-44bBCbQwcFF/XGaXSweCWHJaslKhJEFgvcHdxZf9Fm1QfK7VN4U3iAI0BVOLAIkRg0xV3w7xYGLpx2cM1BU7Qw== dependencies: json-rpc-engine "^5.1.3" json-rpc-middleware-stream "^2.1.1"