-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Test] Patch in EIP-6963 support #19320
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,10 @@ cleanContextForImports(); | |
import log from 'loglevel'; | ||
import { WindowPostMessageStream } from '@metamask/post-message-stream'; | ||
import { initializeProvider } from '@metamask/providers/dist/initializeInpageProvider'; | ||
import { v4 as uuid } from 'uuid'; | ||
|
||
import shouldInjectProvider from '../../shared/modules/provider-injection'; | ||
import { announceProvider } from './EIP6963'; | ||
|
||
// contexts | ||
const CONTENT_SCRIPT = 'metamask-contentscript'; | ||
|
@@ -55,9 +58,21 @@ if (shouldInjectProvider()) { | |
target: CONTENT_SCRIPT, | ||
}); | ||
|
||
initializeProvider({ | ||
const MetaMaskEIP6963ProviderInfo = { | ||
walletId: 'io.metamask', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be based on the build type. |
||
uuid: uuid(), | ||
name: 'MetaMask', | ||
icon: 'https://raw.githubusercontent.com/MetaMask/brand-resources/cb6fd847f3a9cc5e231c749383c3898935e62eab/SVG/metamask-fox.svg', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm trying to find a better URL for this, but this works. |
||
}; | ||
|
||
const provider = initializeProvider({ | ||
connectionStream: metamaskStream, | ||
logger: log, | ||
shouldShimWeb3: true, | ||
}); | ||
|
||
announceProvider({ | ||
info: MetaMaskEIP6963ProviderInfo, | ||
provider, | ||
}); | ||
Comment on lines
+74
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Announce immediately after instantiating the provider object and setting it as |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will increase the size of the injected script by <12kb unless we tree shake.