finalTask.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { DBClient } from '../singletons'
  2. import { Status } from '../models/Status'
  3. import { forEachAsync } from '../utils'
  4. import { InitiaClient } from '../InitiaClient'
  5. async function startCheck(concurrency) {
  6. const accountsRaw = await DBClient.instance.randomTask.findMany({
  7. where: {
  8. finish: 1,
  9. },
  10. take: 100,
  11. })
  12. await forEachAsync(accountsRaw, concurrency, async (account, index) => {
  13. console.log(`${index}/${accountsRaw.length}: processing ${account.address}`)
  14. console.log(account.id)
  15. try {
  16. // await faucetAccount(account.address)
  17. const client = new InitiaClient(account.mnemonic, true)
  18. const done = await client.mintPart()
  19. if (done !== `undone`) {
  20. await DBClient.instance.randomTask.update({
  21. where: { id: account.id },
  22. data: { finish: 2 },
  23. })
  24. } else {
  25. await DBClient.instance.randomTask.update({
  26. where: { id: account.id },
  27. data: { finish: -2 },
  28. })
  29. }
  30. // const unApprovedList = await client.mintJennie()
  31. } catch (e) {
  32. console.log(e)
  33. // await DBClient.instance.account.update({
  34. // where: { id: account.id },
  35. // data: { status: Status.MayQueued, message: e.message },
  36. // })
  37. }
  38. })
  39. }
  40. startCheck(10)