Currently, ZkWalletAccount has unresolved promise inside its constructor and it's cumbersome to manually wait them resolved outside. For example, the code using ZkWalletAccount has to be check the if the promise returned by this.node.tracker.addAccounts(account) resolved or not by checking length of tracker.transferTrackers doing something similar to following code.
const wallet = new ZkWalletAccount(config)
await new Promise((resolve) => {
// polling to check the transferTrackers length
setInterval(() => {
if (wallet.node.tracker.transferTrackers === 1) {
clearInterval(); resolve()
}, 500)
})
// now wallet is initialized properly.
Instead of doing this, implement async constructor and wait it initialized. and this can be used like this
Currently, ZkWalletAccount has unresolved promise inside its constructor and it's cumbersome to manually wait them resolved outside. For example, the code using ZkWalletAccount has to be check the if the promise returned by
this.node.tracker.addAccounts(account)
resolved or not by checking length oftracker.transferTrackers
doing something similar to following code.Instead of doing this, implement async constructor and wait it initialized. and this can be used like this