This repository has been archived by the owner on Aug 19, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new inpage provider package (#21)
* add new inpage provider package * don't send site metadata
- Loading branch information
Showing
6 changed files
with
25 additions
and
39 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters