Skip to content
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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions app/scripts/EIP6963.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion app/scripts/inpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Copy link
Member Author

@rekmarks rekmarks May 27, 2023

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.


import shouldInjectProvider from '../../shared/modules/provider-injection';
import { announceProvider } from './EIP6963';

// contexts
const CONTENT_SCRIPT = 'metamask-contentscript';
Expand All @@ -55,9 +58,21 @@ if (shouldInjectProvider()) {
target: CONTENT_SCRIPT,
});

initializeProvider({
const MetaMaskEIP6963ProviderInfo = {
walletId: 'io.metamask',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be based on the build type. io.metamask for stable, io.metamask.flask for Flask etc.

uuid: uuid(),
name: 'MetaMask',
icon: 'https://raw.githubusercontent.com/MetaMask/brand-resources/cb6fd847f3a9cc5e231c749383c3898935e62eab/SVG/metamask-fox.svg',
Copy link
Member Author

Choose a reason for hiding this comment

The 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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Announce immediately after instantiating the provider object and setting it as window.ethereum.

}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@
"ses": "^0.18.4",
"single-call-balance-checker-abi": "^1.0.0",
"unicode-confusables": "^0.1.1",
"uuid": "^8.3.2",
"uuid": "^9.0.0",
"valid-url": "^1.0.9",
"web3-stream-provider": "^4.0.0",
"zxcvbn": "^4.4.2"
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24099,7 +24099,7 @@ __metadata:
ttest: ^2.1.1
typescript: ~4.4.0
unicode-confusables: ^0.1.1
uuid: ^8.3.2
uuid: ^9.0.0
valid-url: ^1.0.9
vinyl: ^2.2.1
vinyl-buffer: ^1.0.1
Expand Down