drizzle icon indicating copy to clipboard operation
drizzle copied to clipboard

Feature/dapp initiate web3 connection

Open jklepatch opened this issue 4 years ago • 2 comments

jklepatch avatar Nov 11 '19 15:11 jklepatch

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

jklepatch avatar Nov 11 '19 15:11 jklepatch

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;
}

jklepatch avatar Nov 11 '19 15:11 jklepatch