123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import { DBClient } from '../singletons'
- import { forEachAsync } from '../utils'
- import { InitiaClient } from '../InitiaClient'
- async function startCheck(concurrency) {
- const accountsRaw = await DBClient.instance.account.findMany({
- where: {
- status: -4,
- },
- orderBy: {
- lastRun: 'desc',
- },
- take: 1000,
- })
- await forEachAsync(accountsRaw, concurrency, async (account, index) => {
- console.log(`${index}/${accountsRaw.length}: processing ${account.address}`)
- try {
- // if (Number(account.message) < 1000000) {
- // return
- // }
- const client = new InitiaClient(account.mnemonic, true)
- const gasGot = await client.lcd.bank.balanceByDenom(
- account.address,
- `move/944f8dd8dc49f96c25fea9849f16436dcfa6d564eec802f3ef7f8b3ea85368ff`,
- )
- if (Number(gasGot.amount) < 300000) {
- await DBClient.instance.account.update({
- where: { id: account.id },
- data: { status: -3 },
- //可能领过还没到账的
- })
- return
- }
- // if (!gasGot) {
- // console.log(`gas got:`, gasGot)
- // await DBClient.instance.account.update({
- // where: { id: account.id },
- // data: { status: -2 },
- // //可能领过还没到账的
- // })
- // return
- // }
- const done = await client.feedJennie()
- if (done == `done`) {
- console.log(`done work`)
- await DBClient.instance.account.update({
- where: { id: account.id },
- data: { status: 3 },
- })
- }
- } catch (e) {
- console.log(
- `${index}/${accountsRaw.length}: processing ${account.address}: fail`,
- )
- console.log(
- `${index}/${accountsRaw.length}: processing ${account.address}: ${e.message}`,
- )
- }
- })
- }
- startCheck(20)
|