|
@@ -1,10 +1,10 @@
|
|
import {
|
|
import {
|
|
- forEachAsync, generate2CaptchaProxyAgent,
|
|
|
|
|
|
+ forEachAsync,
|
|
generateRandomString,
|
|
generateRandomString,
|
|
getAxiosClient,
|
|
getAxiosClient,
|
|
getProxyAgent,
|
|
getProxyAgent,
|
|
} from '../utils'
|
|
} from '../utils'
|
|
-import { getAltchaPayload, getRecaptcha, solveHCaptcha } from './captcha'
|
|
|
|
|
|
+import { getAltchaPayload, solveHCaptcha } from './captcha'
|
|
import { DBClient } from '../singletons'
|
|
import { DBClient } from '../singletons'
|
|
import { Status } from '../models/Status'
|
|
import { Status } from '../models/Status'
|
|
import polly from 'polly-js'
|
|
import polly from 'polly-js'
|
|
@@ -13,6 +13,7 @@ import { ethers } from 'ethers'
|
|
import { v4 as uuidv4 } from 'uuid'
|
|
import { v4 as uuidv4 } from 'uuid'
|
|
import axios from 'axios'
|
|
import axios from 'axios'
|
|
import xrpl from 'xrpl'
|
|
import xrpl from 'xrpl'
|
|
|
|
+import crypto from 'crypto'
|
|
|
|
|
|
export async function faucetAccount(address: string) {
|
|
export async function faucetAccount(address: string) {
|
|
const client = getAxiosClient(true)
|
|
const client = getAxiosClient(true)
|
|
@@ -61,6 +62,11 @@ async function startFaucet(concurrency, index) {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+function hashWithSHA512(data) {
|
|
|
|
+ const hash = crypto.createHash('sha512')
|
|
|
|
+ hash.update(data)
|
|
|
|
+ return hash.digest('hex')
|
|
|
|
+}
|
|
async function faucetLunch(concurrency: number = 8) {
|
|
async function faucetLunch(concurrency: number = 8) {
|
|
const now = new Date()
|
|
const now = new Date()
|
|
const accounts = await DBClient.instance.account.findMany({
|
|
const accounts = await DBClient.instance.account.findMany({
|
|
@@ -73,30 +79,87 @@ async function faucetLunch(concurrency: number = 8) {
|
|
orderBy: {
|
|
orderBy: {
|
|
id: 'desc',
|
|
id: 'desc',
|
|
},
|
|
},
|
|
|
|
+ take: 1,
|
|
})
|
|
})
|
|
|
|
+ // f46818e3b5a63aa6bfe6bb0d5607e85e5caed881ac39bba8cd4de64c40dcfa4698bac6210218c23425af731232eae567017c2627f1a691cfb5c665a7b175a4fd
|
|
|
|
+ // 2a43da0eb4aeab62e6d44e19ea87c1a4bdd4c0a0e4e1ea4ef910769c9f97a2d8dd4a0df55942d51351f6f40a3a06214598a329e287dab31a1b11cf8975ed311e
|
|
|
|
+ // af7eedf65e0f44cd6a82c42d53b90c7e2c3b39285af4e0bee73914331185fd9f
|
|
|
|
+ // a3e6fcfd02c098840d0a934b6082f5c05004fad4b303178276ac8839f3717bd2
|
|
|
|
+ // e3b497c64a50dabdd4a41f5f7a94a91c874f53d88740a0c39100f175fe066c68
|
|
|
|
+ // 0x2bc04dc33a6c298be846d85062ffca9997f1f06b05bc85ae060327975aaf80fb55598d2bb2c2a9489134aaee06e08f1811ba843a0f503106f4cd6e159a86c2aa1c
|
|
|
|
+ // af7eedf65e0f44cd6a82c42d53b90c7e2c3b39285af4e0bee73914331185fd9fa3e6fcfd02c098840d0a934b6082f5c05004fad4b303178276ac8839f3717bd2
|
|
|
|
+ // 0xa383589e8ad01e29906abfb778a9d48c2e5c1980b1c6bfa971b1205e49b6b8f52ddeaa6cdc35f001e6c6f6bbc03c84f650bd5652d1f782f4a95694f55d26325c1c
|
|
await forEachAsync(accounts, concurrency, async (account, index) => {
|
|
await forEachAsync(accounts, concurrency, async (account, index) => {
|
|
console.log(`${index}/${accounts.length}: processing ${account.address}`)
|
|
console.log(`${index}/${accounts.length}: processing ${account.address}`)
|
|
- try {
|
|
|
|
- if (!account.gmail) account.gmail = `${generateRandomString(8)}@gmail.com`
|
|
|
|
- if (!account.xrpPrivateKey)
|
|
|
|
- account.xrpPrivateKey = xrpl.Wallet.generate().seed
|
|
|
|
- if (!account.duid) account.duid = uuidv4().toUpperCase()
|
|
|
|
- await polly()
|
|
|
|
- .waitAndRetry(2)
|
|
|
|
- .executeForPromise(async () => {
|
|
|
|
- const key = new MnemonicKey({ mnemonic: account.mnemonic })
|
|
|
|
- const evmWallet = new ethers.Wallet(key.privateKey.toString('hex'))
|
|
|
|
- const message = JSON.stringify({ signedAt: new Date().toISOString() })
|
|
|
|
- const client = axios.create({
|
|
|
|
- headers: {
|
|
|
|
- 'user-agent':
|
|
|
|
- 'Lunch/1.0 (xyz.lunchlunch.app; build:41; iOS 17.4.1) Alamofire/5.8.0',
|
|
|
|
- 'lunch-app-version': 41,
|
|
|
|
- 'lunch-fiat-currency': 'USD',
|
|
|
|
- 'lunch-app-duid': account.duid,
|
|
|
|
- },
|
|
|
|
- httpsAgent: generate2CaptchaProxyAgent(),
|
|
|
|
- })
|
|
|
|
|
|
+ if (!account.gmail) account.gmail = `${generateRandomString(8)}@gmail.com`
|
|
|
|
+ if (!account.xrpPrivateKey)
|
|
|
|
+ account.xrpPrivateKey = xrpl.Wallet.generate().seed
|
|
|
|
+ if (!account.duid) account.duid = uuidv4().toUpperCase()
|
|
|
|
+ const key = new MnemonicKey({ mnemonic: account.mnemonic })
|
|
|
|
+ const evmWallet = new ethers.Wallet(key.privateKey.toString('hex'))
|
|
|
|
+ const current = new Date().toISOString()
|
|
|
|
+ // const addCurrent = new Date(current.getTime() + 1000 * 60).toISOString()
|
|
|
|
+ // const message = JSON.stringify({ signedAt: new Date().toISOString() })
|
|
|
|
+ const first = hashWithSHA512(current.toString())
|
|
|
|
+ console.log(first)
|
|
|
|
+ const message = current
|
|
|
|
+ const second = await evmWallet.signMessage(first)
|
|
|
|
+ console.log(second)
|
|
|
|
+ const client = axios.create({
|
|
|
|
+ headers: {
|
|
|
|
+ 'user-agent':
|
|
|
|
+ 'Lunch/1.0 (xyz.lunchlunch.app; build:44; iOS 16.0.0) Alamofire/5.8.0',
|
|
|
|
+ 'lunch-app-version': 44,
|
|
|
|
+ 'lunch-fiat-currency': 'USD',
|
|
|
|
+ 'lunch-app-duid': account.duid,
|
|
|
|
+ },
|
|
|
|
+ httpsAgent: getProxyAgent(),
|
|
|
|
+ })
|
|
|
|
+ await polly()
|
|
|
|
+ .waitAndRetry(2)
|
|
|
|
+ .executeForPromise(async () => {
|
|
|
|
+ const resp = await client.post(
|
|
|
|
+ 'https://api.lunchlunch.xyz/v1/auth/sign-in',
|
|
|
|
+ {
|
|
|
|
+ walletAddress: evmWallet.address,
|
|
|
|
+ signedMessage: evmWallet.signMessage(message),
|
|
|
|
+ rawMessage: message,
|
|
|
|
+ },
|
|
|
|
+ )
|
|
|
|
+ console.log(`${index}: sign-in success.`)
|
|
|
|
+ client.defaults.headers[
|
|
|
|
+ 'authorization'
|
|
|
|
+ ] = `Bearer ${resp.data.accessToken}`
|
|
|
|
+
|
|
|
|
+ console.log(resp.data.accessToken)
|
|
|
|
+ const xrplWallet = xrpl.Wallet.fromSeed(account.xrpPrivateKey)
|
|
|
|
+ const register = await client.post(
|
|
|
|
+ 'https://api.lunchlunch.xyz/v1/member/register',
|
|
|
|
+ {
|
|
|
|
+ evmWalletAddress: evmWallet.address,
|
|
|
|
+ initiaWalletAddress: key.accAddress,
|
|
|
|
+ isImportedWallet: true,
|
|
|
|
+ firstInitiaWalletAddress: key.accAddress,
|
|
|
|
+ email: account.gmail,
|
|
|
|
+ xrplWalletAddress: xrplWallet.address,
|
|
|
|
+ },
|
|
|
|
+ )
|
|
|
|
+ console.log(`${index}: register done`)
|
|
|
|
+ await DBClient.instance.account.update({
|
|
|
|
+ where: { id: account.id },
|
|
|
|
+ data: {
|
|
|
|
+ lastRun: new Date(),
|
|
|
|
+ xrpPrivateKey: account.xrpPrivateKey,
|
|
|
|
+ gmail: account.gmail,
|
|
|
|
+ duid: account.duid,
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ const flag = await polly()
|
|
|
|
+ .waitAndRetry(20)
|
|
|
|
+ .executeForPromise(async () => {
|
|
|
|
+ try {
|
|
|
|
+ client.defaults.httpsAgent = getProxyAgent()
|
|
const resp = await client.post(
|
|
const resp = await client.post(
|
|
'https://api.lunchlunch.xyz/v1/auth/sign-in',
|
|
'https://api.lunchlunch.xyz/v1/auth/sign-in',
|
|
{
|
|
{
|
|
@@ -109,21 +172,6 @@ async function faucetLunch(concurrency: number = 8) {
|
|
client.defaults.headers[
|
|
client.defaults.headers[
|
|
'authorization'
|
|
'authorization'
|
|
] = `Bearer ${resp.data.accessToken}`
|
|
] = `Bearer ${resp.data.accessToken}`
|
|
-
|
|
|
|
- const xrplWallet = xrpl.Wallet.fromSeed(account.xrpPrivateKey)
|
|
|
|
- const register = await client.post(
|
|
|
|
- 'https://api.lunchlunch.xyz/v1/member/register',
|
|
|
|
- {
|
|
|
|
- evmWalletAddress: evmWallet.address,
|
|
|
|
- initiaWalletAddress: key.accAddress,
|
|
|
|
- isImportedWallet: true,
|
|
|
|
- firstInitiaWalletAddress: key.accAddress,
|
|
|
|
- email: account.gmail,
|
|
|
|
- xrplWalletAddress: xrplWallet.address,
|
|
|
|
- },
|
|
|
|
- )
|
|
|
|
- console.log(`${index}: register done`)
|
|
|
|
-
|
|
|
|
const airdropResp = await client.post(
|
|
const airdropResp = await client.post(
|
|
'https://api.lunchlunch.xyz/v1/dish/submit-action/airdrop',
|
|
'https://api.lunchlunch.xyz/v1/dish/submit-action/airdrop',
|
|
{
|
|
{
|
|
@@ -131,7 +179,18 @@ async function faucetLunch(concurrency: number = 8) {
|
|
},
|
|
},
|
|
)
|
|
)
|
|
console.log(`${index}: airdrop done`)
|
|
console.log(`${index}: airdrop done`)
|
|
- })
|
|
|
|
|
|
+ return `true`
|
|
|
|
+ } catch (e) {
|
|
|
|
+ console.log(e.response.data)
|
|
|
|
+
|
|
|
|
+ if (e.response.data.statusCode === 429) {
|
|
|
|
+ throw e
|
|
|
|
+ } else {
|
|
|
|
+ return `error: ${e.response.data.toString()}`
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ if (flag === 'true') {
|
|
await DBClient.instance.account.update({
|
|
await DBClient.instance.account.update({
|
|
where: { id: account.id },
|
|
where: { id: account.id },
|
|
data: {
|
|
data: {
|
|
@@ -142,13 +201,12 @@ async function faucetLunch(concurrency: number = 8) {
|
|
duid: account.duid,
|
|
duid: account.duid,
|
|
},
|
|
},
|
|
})
|
|
})
|
|
- } catch (e) {
|
|
|
|
- console.log(e)
|
|
|
|
|
|
+ } else {
|
|
await DBClient.instance.account.update({
|
|
await DBClient.instance.account.update({
|
|
where: { id: account.id },
|
|
where: { id: account.id },
|
|
data: {
|
|
data: {
|
|
|
|
+ message: flag,
|
|
status: Status.FaucetFailed,
|
|
status: Status.FaucetFailed,
|
|
- message: e.message,
|
|
|
|
lastRun: new Date(),
|
|
lastRun: new Date(),
|
|
xrpPrivateKey: account.xrpPrivateKey,
|
|
xrpPrivateKey: account.xrpPrivateKey,
|
|
gmail: account.gmail,
|
|
gmail: account.gmail,
|