67P / hubot-kredits

Kosmos Kredits chat/service integrations
https://wiki.kosmos.org/Kredits
MIT License
2 stars 1 forks source link

Properly manage transaction nonces #28

Open raucao opened 5 years ago

raucao commented 5 years ago

See dcbce66796669c96d931a70f0f2e3ba52437af31 for hotfix that doesn't really fix the underlying issue with ethers.js' wallet nonce management.

bumi commented 5 years ago

can we do a eth_gettransactioncount on boot or regularly, store that number and then manually increment the nonce everytime we've sent a transaction?

something like (pseudo code):

let nonce = await provider.getTransactionCount('pending');
nonce++;
[contirbution1, contribution2].forEach(c => {
  await kredits.Contribution.add(attrs, {nonce});
  nonce++;
})
bumi commented 5 years ago

we could maybe use ether.js's waitForTransaction to wait until the transaction is mined and then increment the nonce (or do a provider.getTransactionCount('pending') again) and then do the next transaction.