Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Improve dapp browser #653

Merged
merged 7 commits into from
Apr 16, 2021
Merged

Improve dapp browser #653

merged 7 commits into from
Apr 16, 2021

Conversation

jessgusclark
Copy link
Member

@jessgusclark jessgusclark commented Apr 5, 2021

Improvements to the rWallet Dapp Browser.

sendAsync !== request

Let's talk about this code:

window.ethereum.request = (payload) =>
  new Promise((resolve, reject) =>
    sendAsync(payload).then(response =>
      response.result
        ? resolve(response.result)
        : reject(new Error(response.message || 'provider error'))));

It replaces:

window.ethereum.request = sendAsync;

send and sendAsync both return a JSON RPC object which was handled correctly. However request should return just the value. With the previous code, it returned the RPC object, which was causing errors with newer web3 connectors, such as rlogin.

According to EIP 1193 send and sendAsync are deprecated in favor of request.

This also checks if the response.result is undefined, if it is, it rejects the promise. This is a hacky way to handle the error described in #655.

To Test

I have been using the rLogin Sample App for testing basic functionality.

@jessgusclark jessgusclark marked this pull request as draft April 6, 2021 13:04
request !== sendAsync.

SendAsync returns an JSON-RPC object where as request returns the value. See the specification under EIP-1193 here: https://eips.ethereum.org/EIPS/eip-1193
@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 7, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Contributor

@itofarina itofarina left a comment

Choose a reason for hiding this comment

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

LGTM - tested on iOS simulator.
Thanks @jessgusclark for such a clear description!

src/pages/dapp/browser.js Show resolved Hide resolved
@patogallaiovlabs patogallaiovlabs added this to the v1.4.2 milestone Apr 15, 2021
@patogallaiovlabs patogallaiovlabs merged commit 4b589ee into master Apr 16, 2021
@patogallaiovlabs patogallaiovlabs deleted the improve-dapp branch April 16, 2021 13:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants