|
@@ -1,24 +1,16 @@
|
|
|
import { DBClient } from '../singletons'
|
|
|
-import { Status } from '../models/Status'
|
|
|
-import { forEachAsync, sleep } from '../utils'
|
|
|
+import { forEachAsync } from '../utils'
|
|
|
import { InitiaClient } from '../InitiaClient'
|
|
|
|
|
|
async function startCheck(concurrency) {
|
|
|
- const count = await DBClient.instance.account.count({
|
|
|
- where: {
|
|
|
- status: Status.FaucetFailed,
|
|
|
- },
|
|
|
- })
|
|
|
- if (count < 300) {
|
|
|
- console.log(`waiting for more accounts`)
|
|
|
-
|
|
|
- await sleep(1000 * 60 * 60)
|
|
|
- }
|
|
|
const accountsRaw = await DBClient.instance.account.findMany({
|
|
|
where: {
|
|
|
- status: Status.FaucetFailed,
|
|
|
+ status: {
|
|
|
+ notIn: [-2, 888, 889],
|
|
|
+ },
|
|
|
},
|
|
|
- take: 24000,
|
|
|
+
|
|
|
+ take: 50000,
|
|
|
})
|
|
|
await forEachAsync(accountsRaw, concurrency, async (account, index) => {
|
|
|
console.log(`${index}/${accountsRaw.length}: processing ${account.address}`)
|
|
@@ -27,27 +19,23 @@ async function startCheck(concurrency) {
|
|
|
|
|
|
const client = new InitiaClient(account.mnemonic, true)
|
|
|
|
|
|
- const bool = await client.funded()
|
|
|
- console.log(bool)
|
|
|
- if (bool) {
|
|
|
+ const amount = await client.getGasAmount()
|
|
|
+ if (amount < 0.01) {
|
|
|
await DBClient.instance.account.update({
|
|
|
where: { id: account.id },
|
|
|
- data: { status: Status.Funded },
|
|
|
+ data: { status: -2 },
|
|
|
+ //可能领过还没到账的
|
|
|
})
|
|
|
} else {
|
|
|
await DBClient.instance.account.update({
|
|
|
where: { id: account.id },
|
|
|
- data: { status: Status.MayQueued },
|
|
|
+ data: { status: 888 },
|
|
|
+ //可能领过还没到账的
|
|
|
})
|
|
|
}
|
|
|
- } catch (e) {
|
|
|
- console.log(e.message)
|
|
|
- await DBClient.instance.account.update({
|
|
|
- where: { id: account.id },
|
|
|
- data: { status: Status.MayQueued, message: e.message },
|
|
|
- })
|
|
|
- }
|
|
|
+ console.log(`amount:`, amount)
|
|
|
+ } catch (e) {}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-startCheck(100)
|
|
|
+startCheck(20)
|