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

EIP-1102: Transitionary API #5256

Merged
merged 3 commits into from Sep 14, 2018
Merged

EIP-1102: Transitionary API #5256

merged 3 commits into from Sep 14, 2018

Conversation

bitpshr
Copy link
Contributor

@bitpshr bitpshr commented Sep 13, 2018

This pull request adds a transitionary EIP-1102 API so dapps can begin preemptively calling it. Specifically, this pull request does the following:

  1. Assigns the provider to window.ethereum
  2. Adds a provider#enable method

Note: User-rejection can be tested by passing an object into the enable method with a mockRejection property set to true:

ethereum.enable({ mockRejection: true })

@metamaskbot
Copy link
Collaborator

Builds ready [4929d16]: mascara, chrome, firefox, edge, opera

// Augment the provider with its enable method
inpageProvider.enable = function () {
return new Promise((resolve) => {
resolve(inpageProvider.send({ method: 'eth_accounts' }).result)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does inpageProvider.send({ method: 'eth_accounts' }) return a synchronous result, for grabbing .result off of?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I would rather use the async method and return that method, these sync methods historically are unreliable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. We can't return it directly since enable technically resolves directly to the array of accounts, but we can definitely use the async version.

danfinlay
danfinlay previously approved these changes Sep 13, 2018
Copy link
Contributor

@2-am-zzz 2-am-zzz left a comment

Choose a reason for hiding this comment

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

11/02 incoming my dudettes and dudes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants