Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Commit

Permalink
Add new inpage provider package (#21)
Browse files Browse the repository at this point in the history
* add new inpage provider package

* don't send site metadata
  • Loading branch information
rekmarks authored May 4, 2020
1 parent 23f4f2e commit 3a6cb32
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 39 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/inpage.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
"@babel/plugin-proposal-object-rest-spread": "^7.6.2",
"@babel/preset-env": "^7.7.1",
"@metamask/eslint-config": "^1.0.0",
"@metamask/inpage-provider": "^5.0.0",
"babel-loader": "^8.0.6",
"concat-cli": "^4.0.0",
"eslint": "^6.8.0",
"eslint-plugin-json": "^2.0.1",
"husky": "^4.2.1",
"metamask-inpage-provider": "^4.1.2",
"obj-multiplex": "^1.0.0",
"web3": "0.20.7",
"webpack": "^4.41.2",
Expand Down
2 changes: 1 addition & 1 deletion src/content-script/inpage-bundle.js

Large diffs are not rendered by default.

24 changes: 5 additions & 19 deletions src/inpage/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

const MetamaskInpageProvider = require('metamask-inpage-provider')
const { initProvider } = require('@metamask/inpage-provider')
const ObjectMultiplex = require('obj-multiplex')
const pump = require('pump')
const MobilePortStream = require('./MobilePortStream')
Expand All @@ -10,24 +10,10 @@ const metamaskStream = new ReactNativePostMessageStream({
target: 'contentscript',
})

function setupProvider () {

const inpageProvider = new MetamaskInpageProvider(metamaskStream, false)

// compose the inpage provider
// set a high max listener count to avoid unnecesary warnings
inpageProvider.setMaxListeners(100)

// Work around for [email protected] deleting the bound `sendAsync` but not the unbound
// `sendAsync` method on the prototype, causing `this` reference issues
window.ethereum = new Proxy(inpageProvider, {
// straight up lie that we deleted the property so that it doesnt
// throw an error in strict mode
deleteProperty: () => true,
})
}

setupProvider()
initProvider({
connectionStream: metamaskStream,
shouldSendMetadata: false,
})

window.setupStreams = function () {
// the transport-specific streams for communication between inpage and background
Expand Down
30 changes: 15 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,21 @@
resolved "https://registry.yarnpkg.com/@metamask/eslint-config/-/eslint-config-1.0.0.tgz#046012398bb27f56395355c96ef07152925043b7"
integrity sha512-MmxM2sknVhIHyXCjR6LcK57OPJ30gTEX5v/jwC+qXuw4GIgUAPbxFp3AFmFRAJwty3RMjJSbRJ7YlamMq67U8w==

"@metamask/inpage-provider@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@metamask/inpage-provider/-/inpage-provider-5.0.0.tgz#f3961ceb02821255785fe20b1b676bfd944532d7"
integrity sha512-DjQy/hJPKwEhk+L/XPHfR6bSTWsGGXjHCQ3Q/LgieQX/Kv91yyMu+QUu+tWuVi0qX0dSRmaTnFNCF9FWNV1XgA==
dependencies:
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"
loglevel "^1.6.1"
obj-multiplex "^1.0.0"
obs-store "^4.0.3"
pump "^3.0.0"
safe-event-emitter "^1.0.1"

"@types/color-name@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
Expand Down Expand Up @@ -2966,21 +2981,6 @@ memory-fs@^0.5.0:
errno "^0.1.3"
readable-stream "^2.0.1"

metamask-inpage-provider@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/metamask-inpage-provider/-/metamask-inpage-provider-4.1.2.tgz#8068004d51160dc5869c5aa881074284b8db03da"
integrity sha512-HLCW4DdvubLGntez5yB6kOqvptnpgUcUaRenEwzqN+hHQMnA2+1mNLp5IYks30kvX/fI2ACJgekFwIRDFWA9gQ==
dependencies:
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"
loglevel "^1.6.1"
obj-multiplex "^1.0.0"
obs-store "^4.0.3"
pump "^3.0.0"
safe-event-emitter "^1.0.1"

micromatch@^3.0.4, micromatch@^3.1.10, micromatch@^3.1.4:
version "3.1.10"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23"
Expand Down

0 comments on commit 3a6cb32

Please sign in to comment.