fundChecker.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { DBClient } from '../singletons'
  2. import { forEachAsync } from '../utils'
  3. import { InitiaClient } from '../InitiaClient'
  4. async function startCheck(concurrency) {
  5. const accountsRaw = await DBClient.instance.account.findMany({
  6. where: {
  7. status: {
  8. notIn: [-2, 888, 889],
  9. },
  10. },
  11. take: 50000,
  12. })
  13. await forEachAsync(accountsRaw, concurrency, async (account, index) => {
  14. console.log(`${index}/${accountsRaw.length}: processing ${account.address}`)
  15. try {
  16. // await faucetAccount(account.address)
  17. const client = new InitiaClient(account.mnemonic, true)
  18. const amount = await client.getGasAmount()
  19. if (amount < 0.01) {
  20. await DBClient.instance.account.update({
  21. where: { id: account.id },
  22. data: { status: -2 },
  23. //可能领过还没到账的
  24. })
  25. } else {
  26. await DBClient.instance.account.update({
  27. where: { id: account.id },
  28. data: { status: 888 },
  29. //可能领过还没到账的
  30. })
  31. }
  32. console.log(`amount:`, amount)
  33. } catch (e) {}
  34. })
  35. }
  36. startCheck(20)