import { getAxiosClient } from '../utils' import { DBClient } from '../singletons' import polly from 'polly-js' import { forEachAsync } from 'useless-helpers' async function faucetTuc(address: string) { await polly() .waitAndRetry(3) .executeForPromise(async () => { const client = getAxiosClient(true) const res = await client.post( 'https://birdee-faucet.testnet.mesoops.net/', { address: address, coins: ['10000000utuc'], }, ) if (res.data.error) { throw new Error(res.data.error) } }) } async function startFaucet(concurrency: number) { const accounts = await DBClient.instance.account.findMany({ where: { status: 5 }, // take: 500, }) await forEachAsync(accounts, concurrency, async account => { try { await faucetTuc(account.address) await DBClient.instance.account.update({ where: { id: account.id }, data: { status: 6 }, }) } catch (e) { console.log(e) // await DBClient.instance.faucet.update({ // where: { id: account.id }, // data: { tucStatus: Status.FaucetFailed }, // }) } }) } await startFaucet(20)