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

bugfix: fix dapp compat issues #1021

Merged
merged 4 commits into from
Aug 27, 2019
Merged

bugfix: fix dapp compat issues #1021

merged 4 commits into from
Aug 27, 2019

Conversation

bitpshr
Copy link
Contributor

@bitpshr bitpshr commented Aug 23, 2019

Description

This pull request fixes dapp compatibility issues.

  • isApproved should return false by default.
  • eth_personalSign should ducktype address parameter.
  • eth_signTypedData_v3 should verify chainId.

Checklist

  • There is a related GitHub issue
  • Tests are included if applicable
  • Any added code is fully documented

Issue

References #916
Resolves #915
Resolves #951

Copy link
Contributor

@brunobar79 brunobar79 left a comment

Choose a reason for hiding this comment

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

LGTM, added some minor comments

@@ -61,6 +61,10 @@ import DrawerStatusTracker from '../../../core/DrawerStatusTracker';
const { HOMEPAGE_URL } = AppConstants;
const HOMEPAGE_HOST = 'home.metamask.io';

function resemblesAddress(string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we can't use isValidAddress from ethereumjs-util here, can you move it to app/util/address.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't sure if using isValidAddress was sufficient for all cases and defaulted to the logic the extension uses, which is where resemblesAddress came from. I will move this to the address util file for sure.

try {
data = JSON.parse(payload.params[1]);
} catch (e) {
throw new Error('Data must be passed as a valid JSON string.');
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 if you throw here it won't get back to the dapp context.
You should do Promise.reject({ error: error.message, jsonrpc: payload.jsonrpc, id: payload.id });

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Throwing here does get back to the dapp context (the thrown error is caught and shuffled as the RPC response up the chain.) I verified this only in a dapp context using Dan's test page, but I'm happy to explicitly reject if that's preferred.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left this as-is for now to stay in-line with the way we handle invalid data above.


// eslint-disable-next-line eqeqeq
if (chainId && chainId != activeChainId) {
throw new Error(`Provided chainId (${chainId}) must match the active chainId (${activeChainId})`);
Copy link
Contributor

Choose a reason for hiding this comment

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

same as previous comment

@brunobar79 brunobar79 added the needs-qa Any New Features that needs a full manual QA prior to being added to a release. label Aug 23, 2019
@ibrahimtaveras00
Copy link
Contributor

There is an issue with LedgerDEX

When I navigate to LedgerDEX the page keeps refreshing and after signing to log in nothing happens; seen here = https://recordit.co/FtQBLcV1bv

@bitpshr bitpshr merged commit f152a93 into develop Aug 27, 2019
@bitpshr bitpshr deleted the bugfix/dapp-compat branch August 27, 2019 21:58
rickycodes pushed a commit that referenced this pull request Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-qa Any New Features that needs a full manual QA prior to being added to a release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EIP-712 chainID enforcement issues bug Ethfinex trustless not working
3 participants