trufflesuite / drizzle

Reactive Ethereum dapp UI suite
906 stars 238 forks source link

Feature/dapp initiate web3 connection #57

Open jklepatch opened 4 years ago

jklepatch commented 4 years ago

https://github.com/trufflesuite/drizzle/issues/20

jklepatch commented 4 years ago

I stumbled upon 2 problems:

  1. When we create web3 contract instances, we don't have any address available yet for the from field. Can Web3 send calls with no from field? Otherwise we could use a dummy address.

  2. When we call connectWallet(), we need to wait for the saga of the web3 initialization to resolve. We could have a re-try loop for that:

let attempts = 0;
while(true) {
  if(attempts > 4) throw new Error('connect wallet failed');
  if(typeof web3 !== 'undefined') {
    yield delay(10);
     attempts++; 
     next;
   }
  // rest of connect wallet saga
  break;
}