drizzle
drizzle copied to clipboard
Feature/dapp initiate web3 connection
https://github.com/trufflesuite/drizzle/issues/20
I stumbled upon 2 problems:
-
When we create web3 contract instances, we don't have any address available yet for the
from
field. Can Web3 send calls with nofrom
field? Otherwise we could use a dummy address. -
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;
}