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

web3.js v1 not working with Trust Wallet #58

Closed
superoo7 opened this issue Feb 27, 2019 · 18 comments
Closed

web3.js v1 not working with Trust Wallet #58

superoo7 opened this issue Feb 27, 2019 · 18 comments
Assignees

Comments

@superoo7
Copy link

Can be refer to #3

Currently, I had issue making the code work in TrustWallet, if I write in vanilla js (without webpack or babel), it will work. ( Links to the testing, Code )

I used truffle box to generate a new react project to regenerate the problem.

Version

  • truffle v5.0.5
  • web3 v1.0.0-beta.37
  • TrustWallet Android v1.6.276

Create project

$ npm install -g truffle
$ truffle unbox react
$ cd client
$ yarn
# Change the code in "/src/App.js"
$ yarn dev

On trust wallet, this is what I got:

screenshot_2019-02-27-15-35-04

I added a repo to reproduce this bug. (I tweak a bit of code in "src/App.js"), https://github.com/superoo7/trustwallet-web3-bug

Possible reason

  • Web3 version for Trust Wallet is not v1 yet
  • Babel/Webpack transpile code of async await
@vikmeup
Copy link

vikmeup commented Feb 27, 2019

@superoo7 we do not support sync methods on purpose. Best practice to always use async calls on web3.

@superoo7
Copy link
Author

I tried wrap the function with Promises (error first approach), it still getting that error. The only way i manage to make it work is via "window.web3" with older web3js API (0.20.x)

  public getId(): Promise<number> {
    return new Promise((resolve, reject) => {
      // v1
      this.web3.eth.net.getId((err1, res1) => {
        if (err1) {
          // < v1
          (window.web3!.version as any).getNetwork((err2: any, res2: any) => {
            if (err2) {
              reject(err2);
            }
            resolve(res2);
          });
        } else {
          resolve(res1);
        }
      });
    });
  }

@hewigovens
Copy link

@superoo7 Hi, we're using web3 0.20.x, it's not compatible with 1.0 right now

@codydjango
Copy link

Would be nice if this info was more available. Any estimate on when you will be supporting 1.0 beta?

@hewigovens
Copy link

@superoo7 @codydjango we once supported 1.0 beta, but not compatible with most dapps, and Metamask is still using "0.20.3". I'm afraid we have to wait metamask for web3 1.0

@codydjango
Copy link

Thanks @hewigovens, makes sense to me. We're just at a bit of a weird spot right now, where 1.0 beta has gained a lot of traction and it's increasingly common to reinitialize web3 with the given provider. I think listing Trusts web3 requirements either on the website or github could be really helpful for dapp developers, especially for new developers. I know this would have helped save me at least a couple of hours.

For example, right now the trust website says "Fully functioning Web3 browser that can be used to interact with any decentralized application (DApp)". The Github has no notes for Dapp developers looking to support the trust wallet other than: "If trust provider injected properly isTrust will be true".

I'd like to humbly suggest an extra line of text, something along the lines of: "Trust currently supports Web3 version 0.20.3".

It's becoming increasingly common for Dapp developers to work with 1.0.0 beta, so I think additional clarity could go a long way during this grey period... Thanks for the consideration.

@hewigovens
Copy link

@codydjango readme updated

@BigMurry
Copy link

Trust wallet should work with web3 1.0 and ethers.js as soon as possible or many new dapps will not work at Trust wallet.

@kombos
Copy link

kombos commented Apr 27, 2019

is trust-web3-provider working with web3 1.0 yet ?

@BigMurry
Copy link

Trust wallet should be working at ethers.js, if this issue can be fixed.
ethers-io/ethers.js#489

@vikmeup
Copy link

vikmeup commented Apr 28, 2019

@BigMurry Thanks for debugging and finding a solution 🙏

@HoangJerry
Copy link

I guess they are still working on it. I got the error not confirm transaction at send() function

@vikmeup
Copy link

vikmeup commented Jun 12, 2019

@HoangJerry web3 is quite unstable by nature, we will wait until the final version is released and then adopt, web3 developers tend to break it every other release

@MythicalToken
Copy link

Is this still the case?

"Fully functioning Web3 browser that can be used to interact with any decentralized application (DApp)" is like a bad joke then.

@vikmeup
Copy link

vikmeup commented Apr 16, 2020

Calling async methods is the best practice for using web3.

@vikmeup vikmeup closed this as completed Apr 16, 2020
@MythicalToken
Copy link

Calling async methods is the best practice for using web3.

What about the web.js 1.0 support?

@vikmeup
Copy link

vikmeup commented Apr 16, 2020

What about the web.js 1.0 support?

It does not matter anymore, you should not be using injected provider at all, use your own: https://medium.com/metamask/no-longer-injecting-web3-js-4a899ad6e59e

You only use injected provider to call sign message or transaction

@surajsingla333
Copy link

How can I integrate trust wallet in my browser dApp?

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

No branches or pull requests

9 participants