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

Replace public config store with RPC methods/notifications #109

Merged
merged 6 commits into from
Dec 1, 2020

Conversation

rekmarks
Copy link
Member

@rekmarks rekmarks commented Nov 24, 2020

  • Deletes the public config stream, _publicConfigStore, and publicConfigStore getter
  • Gets state previously received through public config stream with RPC method and notifications
    • New RPC Methods
      • wallet_getProviderState
    • New RPC Notifications
      • wallet_unlockStateChanged
      • wallet_chainChanged

Corresponding PR in extension: MetaMask/metamask-extension#8640

CI: https://app.circleci.com/pipelines/github/MetaMask/inpage-provider?branch=delete-public-config

@rekmarks rekmarks requested a review from a team as a code owner November 24, 2020 18:23
@rekmarks rekmarks force-pushed the delete-public-config branch 2 times, most recently from 0a8fc81 to 616d041 Compare November 28, 2020 19:14
@rekmarks rekmarks changed the title Replace public config stream with RPC methods/notifications Replace public config store with RPC methods/notifications Nov 28, 2020
@Gudahtt
Copy link
Member

Gudahtt commented Nov 30, 2020

How does this relate to the breaking changes? Did you just want to bundle it with them for the sake of avoiding another breaking change release, or is it functionally tied to them in some way?

@rekmarks
Copy link
Member Author

Ah, we're bundling this breaking change with all the rest just for the sake of convenience!

* Delete public config store
* Replace public config stream with notifications
* Remove lock/unlock events; isUnlocked default false
* Fix annotations, rename a function
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

Should we be using metamask_ here instead of wallet_? 🤔

I had thought we were, as a general rule, using metamask_ for methods that are internal-only or that we have no plans to standardize, and wallet_ for things that might be standardized at some point. These methods seem to me of internal relevance only, at least at the moment.

@rekmarks
Copy link
Member Author

rekmarks commented Dec 1, 2020

@Gudahtt, good point. I had considered that but never executed. Done in: 2fe974d

src/MetaMaskInpageProvider.js Outdated Show resolved Hide resolved
@@ -18,7 +18,7 @@ async function sendSiteMetadata (engine, log) {
// call engine.handle directly to avoid normal RPC request handling
engine.handle(
{
method: 'wallet_sendDomainMetadata',
method: 'metamask_sendDomainMetadata',
Copy link
Member

Choose a reason for hiding this comment

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

This seems out of scope for this PR, and wallet_ might be the more appropriate prefix for this method anyway. We had talked about encouraging dapps to set their own metadata. So we might want to consider documenting this as-is.

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 always considered it to be kind of a hack, personally, and I think there's more work to be done on specifying the method before we commit to publishing its interface.

As to the out of scope, yeah kind of, but while we're here? 😅

Copy link
Member

@Gudahtt Gudahtt Dec 1, 2020

Choose a reason for hiding this comment

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

I think there's more work to be done on specifying the method before we commit to publishing its interface.

Makes sense. I hadn't really thought through whether it was ready to be public-facing in its current form.

It would have been better if this was metamask_ in the first place., but... it still seems better to leave it as is for now 🤷‍♂️ Technically dapps might already be sending this? Also the less provider changes we make, the less broken things with embedded providers will be (e.g. extensions, and dapps that import our provider as a workaround to that Firefox CSP bug). But I guess I won't block on it. Embedded providers will be fairly broken either way.

Copy link
Member

Choose a reason for hiding this comment

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

Actually... maybe we can preserve the public config store in the extension to support old embedded providers, at least for a short while? 🤔 I don't know how feasible this is - I'll have to look more closely at the extension PRs.

src/MetaMaskInpageProvider.js Show resolved Hide resolved
// this will get the exposed accounts, if any
try {
this._rpcRequest(
{ method: 'eth_accounts', params: [] },
Copy link
Member

Choose a reason for hiding this comment

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

Could we bundle the accounts with the unlock notification, to avoid this second call? It would simplify things a great deal. I think it would let us remove the entire isInternal parameter altogether, and that 'eth_accounts' unexpectedly updated accounts warning

Copy link
Member

Choose a reason for hiding this comment

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

I guess this can wait for a subsequent PR either way though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, this is actually very feasible now. Let's do that in a follow-up!

src/MetaMaskInpageProvider.js Show resolved Hide resolved
src/MetaMaskInpageProvider.js Outdated Show resolved Hide resolved
@rekmarks rekmarks requested a review from Gudahtt December 1, 2020 20:18
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

@rekmarks
Copy link
Member Author

rekmarks commented Dec 1, 2020

@rekmarks rekmarks merged commit 6edacf9 into main Dec 1, 2020
@rekmarks rekmarks deleted the delete-public-config branch December 1, 2020 23:05
Gudahtt added a commit that referenced this pull request Jan 20, 2021
This event is deprecated, and is not part of EIP-1193. However we did
not plan to remove this; it was removed accidentally as part of #109.
It should now behave exactly as it did in v6.
Gudahtt added a commit that referenced this pull request Jan 20, 2021
This event is deprecated, and is not part of EIP-1193. However we did
not plan to remove this; it was removed accidentally as part of #109.
It should now behave exactly as it did in v6.
Gudahtt added a commit that referenced this pull request Jan 20, 2021
This event is deprecated, and is not part of EIP-1193. However we did not plan to remove this; it was removed accidentally as part of #109. It should now behave exactly as it did in v6.3.0.

The text of the deprecation warning for this event has also been updated to provide a recommended alternative.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants