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

Fix wallet_scanQRCode rpc method #1758

Merged
merged 4 commits into from
Sep 22, 2020
Merged

Fix wallet_scanQRCode rpc method #1758

merged 4 commits into from
Sep 22, 2020

Conversation

EtDu
Copy link
Contributor

@EtDu EtDu commented Aug 9, 2020

Description

Calling provider.request({ method: 'wallet_scanQRCode' }) was returning the error:
'RPC Error: Error: JsonRpcEngine - response has no error or result for request:'
because it wouldn't wait for the QR code to be scanned before passing the response as empty. Now it properly waits for the user to scan before passing the given result.

This also adds the option for a regex parameter outlined in ethereum/EIPs#945 to enable arbitrary (non ETH address) QR code scanning.

Will reply and close #1485 after this is merged.

Issue

https://trello.com/c/J58J4xOC/77-bug-scan-qr-code-missing

@EtDu EtDu requested a review from a team as a code owner August 9, 2020 06:22
@EtDu EtDu added the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Aug 9, 2020
@EtDu EtDu marked this pull request as draft August 9, 2020 06:29
@EtDu EtDu marked this pull request as ready for review August 9, 2020 13:04
result = data.target_address;
} else if (data.scheme) {
result = JSON.stringify(data);
await new Promise((resolve, reject) => {
Copy link
Member

@andrepimenta andrepimenta Aug 13, 2020

Choose a reason for hiding this comment

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

Here I think you can simplify:
wallet_scanQRCode: () => new Promise((resolve, reject) => { ... })

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch

if (regex && !regex.exec(data)) {
reject({ message: 'NO_REGEX_MATCH', data });
} else if (!regex && !/^(0x){1}[0-9a-fA-F]{40}$/i.exec(data.target_address)) {
reject({ message: 'INVALID_ETHEREUM_ADDRESS', data: data.target_address });
Copy link
Contributor

Choose a reason for hiding this comment

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

are these error names standard? I couldn't find these on the link you posted

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR doesn't technically implement the EIP as it's outlined anyway, but there doesn't appear to be a standard for the error names

@estebanmino estebanmino added the needs-qa Any New Features that needs a full manual QA prior to being added to a release. label Sep 1, 2020
@ibrahimtaveras00
Copy link
Contributor

ibrahimtaveras00 commented Sep 16, 2020

@EtDu I went ahead and followed the instructions to reproduce here and I'm still seeing that it's not detected via the link https://cipher-qr-scan.netlify.com/

Screen Shot 2020-09-16 at 12 11 27 PM

I also tried the instructions here as well and doesn't work either, with the following warnings:

Screen Shot 2020-09-16 at 12 31 46 PM

I also tried https://ropsten.kyber.network transfer option on iOS and it still doesn't support it

Screen Shot 2020-09-16 at 12 36 29 PM

Any other dapps you know of to test this with?

@ibrahimtaveras00 ibrahimtaveras00 added QA'd - Issues Found QA has been complete, however issues have been discovered that need to be addressed and removed needs-qa Any New Features that needs a full manual QA prior to being added to a release. labels Sep 16, 2020
@EtDu
Copy link
Contributor Author

EtDu commented Sep 17, 2020

@ibrahimtaveras00
It's not meant to work with the Cipher API. This implementation defines the RPC method wallet_scanQRCode that dApps must access via provider.request(). NOT via provider.scanQRCode. Kyberswap relies on webRTC support (which iOS webview doesn't have). They would need to change their code to work with this implementation if they wanted their scan functionality to work with MetaMask.

To test this, open a webview debug console and type ethereum.request({ method: 'wallet_scanQRCode' })

@ibrahimtaveras00
Copy link
Contributor

@EtDu I get this when I tap X to close the scanner on browser = http://recordit.co/TLdR6OWJxX

Screen Shot 2020-09-18 at 8 52 07 PM

Same on iOS = http://recordit.co/8IbXZ81Phe

@EtDu
Copy link
Contributor Author

EtDu commented Sep 21, 2020

@ibrahimtaveras00 That's an internal error that does not appear in production and has existed before this PR.

Copy link
Contributor

@ibrahimtaveras00 ibrahimtaveras00 left a comment

Choose a reason for hiding this comment

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

👍

@ibrahimtaveras00 ibrahimtaveras00 added QA Passed A successful QA run through has been done and removed QA'd - Issues Found QA has been complete, however issues have been discovered that need to be addressed labels Sep 21, 2020
@EtDu EtDu merged commit 28ab497 into develop Sep 22, 2020
@EtDu EtDu deleted the scan-qr-code branch September 22, 2020 02:47
rickycodes pushed a commit that referenced this pull request Jan 31, 2022
* browser tab: fix wallet_scanQRCode rpc method: wrap in a promise

* BrowserTab: implement regex for scanQRCode

* BrowserTab: return promise in wallet_scanQRCode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) QA Passed A successful QA run through has been done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

scanQRCode seems to be missing
4 participants