task3Balance.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { DBClient } from '../../singletons'
  2. import { InitiaClient } from '../../InitiaClient'
  3. import { forEachAsync } from 'useless-helpers'
  4. async function startCheck(concurrency) {
  5. const accountsRaw = await DBClient.instance.randomTask2.findMany({
  6. where: {
  7. finish: -2,
  8. },
  9. take: 10000,
  10. orderBy: {
  11. id: 'asc',
  12. },
  13. })
  14. await forEachAsync(
  15. accountsRaw,
  16. concurrency,
  17. async (account, index) => {
  18. console.log(
  19. `${index}/${accountsRaw.length}: processing ${account.address},account id: ${account.id}`,
  20. )
  21. // await faucetAccount(account.address)
  22. const client = new InitiaClient(account.mnemonic, true)
  23. try {
  24. const gasGot = await client.gasGot()
  25. if (gasGot) {
  26. await DBClient.instance.randomTask2.update({
  27. where: { id: account.id },
  28. data: { finish: 0 },
  29. })
  30. } else {
  31. // await DBClient.instance.randomTask2.update({
  32. // where: { id: account.id },
  33. // data: { finish: -2 },
  34. // })
  35. }
  36. } catch (e) {
  37. // console.log(e)
  38. }
  39. },
  40. { retries: 3 },
  41. )
  42. }
  43. startCheck(50)