Skip to content

Commit

Permalink
Fix faulty null checks (#19)
Browse files Browse the repository at this point in the history
* fix faulty null checks

* 4.1.2

* update eth-json-rpc-errors
  • Loading branch information
rekmarks authored Feb 12, 2020
1 parent 95eaf99 commit 5807e89
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ module.exports = class MetamaskInpageProvider extends SafeEventEmitter {
// construct payload object
let payload
if (
methodOrPayload &&
typeof methodOrPayload === 'object' &&
!Array.isArray(methodOrPayload)
) {
Expand Down Expand Up @@ -262,6 +263,7 @@ module.exports = class MetamaskInpageProvider extends SafeEventEmitter {

// typecheck payload and payload.params
if (
!payload ||
typeof payload !== 'object' ||
Array.isArray(payload) ||
!Array.isArray(params)
Expand Down Expand Up @@ -459,7 +461,11 @@ module.exports = class MetamaskInpageProvider extends SafeEventEmitter {
// handle web3
if (this._web3Ref) {
this._web3Ref.defaultAccount = this.selectedAddress
} else if (window.web3 && typeof window.web3.eth === 'object') {
} else if (
window.web3 &&
window.web3.eth &&
typeof window.web3.eth === 'object'
) {
window.web3.eth.defaultAccount = this.selectedAddress
}
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "metamask-inpage-provider",
"version": "4.1.1",
"version": "4.1.2",
"description": "An ethereum provider that connects over a WebExtension port.",
"main": "index.js",
"scripts": {
Expand All @@ -24,7 +24,7 @@
},
"homepage": "https://github.com/MetaMask/metamask-inpage-provider#readme",
"dependencies": {
"eth-json-rpc-errors": "^2.0.1",
"eth-json-rpc-errors": "^2.0.2",
"fast-deep-equal": "^2.0.1",
"json-rpc-engine": "^5.1.5",
"json-rpc-middleware-stream": "^2.1.1",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,10 @@ eth-json-rpc-errors@^2.0.0:
dependencies:
fast-safe-stringify "^2.0.6"

eth-json-rpc-errors@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/eth-json-rpc-errors/-/eth-json-rpc-errors-2.0.1.tgz#e7a4c4e3c76913dff26dbc021966c72b2822e0f2"
integrity sha512-ldF9fdzkdHAgTWmqh/bgHi7uH+8icAyjcEdFOBGD32zTWd7J66VDo0rBaiaQPowXitiyAcs1R23Mje1gkdIofA==
eth-json-rpc-errors@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/eth-json-rpc-errors/-/eth-json-rpc-errors-2.0.2.tgz#c1965de0301fe941c058e928bebaba2e1285e3c4"
integrity sha512-uBCRM2w2ewusRHGxN8JhcuOb2RN3ueAOYH/0BhqdFmQkZx5lj5+fLKTz0mIVOzd4FG5/kUksCzCD7eTEim6gaA==
dependencies:
fast-safe-stringify "^2.0.6"

Expand Down

0 comments on commit 5807e89

Please sign in to comment.