-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
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.
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) { |
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.
If we can't use isValidAddress
from ethereumjs-util
here, can you move it to app/util/address.js?
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.
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.'); |
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.
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 });
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.
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.
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.
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})`); |
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.
same as previous comment
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 |
Description
This pull request fixes dapp compatibility issues.
isApproved
should returnfalse
by default.eth_personalSign
should ducktype address parameter.eth_signTypedData_v3
should verifychainId
.Checklist
Issue
References #916
Resolves #915
Resolves #951