hel 1 vuosi sitten
vanhempi
commit
e97defbb80

+ 1 - 0
package.json

@@ -43,6 +43,7 @@
     "generateRandomW2": "yarn build && node build/src/onchain/week2/generateRandomW2.js",
     "generateRandomW2": "yarn build && node build/src/onchain/week2/generateRandomW2.js",
     "runWeek2": "yarn build && node build/src/onchain/week2/randomWeek2.js",
     "runWeek2": "yarn build && node build/src/onchain/week2/randomWeek2.js",
     "runWeek3": "yarn build && node build/src/onchain/week3/randomWeek3.js",
     "runWeek3": "yarn build && node build/src/onchain/week3/randomWeek3.js",
+    "task3check": "yarn build && node build/src/onchain/week3/task3check.js",
     "runWeek2Task2": "yarn build && node build/src/onchain/week2/week2task2.js",
     "runWeek2Task2": "yarn build && node build/src/onchain/week2/week2task2.js",
     "randomTask": "yarn build && node build/src/onchain/randomTask.js",
     "randomTask": "yarn build && node build/src/onchain/randomTask.js",
     "finalTask": "yarn build && node build/src/onchain/finalTask.js",
     "finalTask": "yarn build && node build/src/onchain/finalTask.js",

+ 1 - 1
prisma/schema.prisma

@@ -22,7 +22,7 @@ model Account {
   gmail         String?  @db.VarChar(100)
   gmail         String?  @db.VarChar(100)
   status        Int      @default(0)
   status        Int      @default(0)
   message       String?  @db.Text
   message       String?  @db.Text
-  lastRun       DateTime
+  lastRun       DateTime @db.DateTime()
   duid          String?  @db.VarChar(80)
   duid          String?  @db.VarChar(80)
 }
 }
 
 

+ 3 - 1
src/BaseClient.ts

@@ -106,8 +106,10 @@ export abstract class BaseClient {
   async broadcast(msg: Msg | Msg[]) {
   async broadcast(msg: Msg | Msg[]) {
     const signed = await this.wallet.createAndSignTx({
     const signed = await this.wallet.createAndSignTx({
       msgs: Array.isArray(msg) ? msg : [msg],
       msgs: Array.isArray(msg) ? msg : [msg],
+      feeDenoms: ['uinit'],
     })
     })
-    const broadcast = await this.lcd.tx.broadcastSync(signed)
+    const broadcast = await this.lcd.tx.broadcast(signed)
+    console.log(broadcast)
     return broadcast.txhash
     return broadcast.txhash
     // console.log(broadcast)
     // console.log(broadcast)
   }
   }

+ 100 - 42
src/faucet/faucet.ts

@@ -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,

+ 36 - 8
src/onchain/week3/task3check.ts

@@ -13,25 +13,53 @@ async function startCheck(concurrency) {
     console.log(
     console.log(
       `${index}/${accountsRaw.length}: processing ${account.address},account id: ${account.id}`,
       `${index}/${accountsRaw.length}: processing ${account.address},account id: ${account.id}`,
     )
     )
-
     try {
     try {
       const axios = getAxiosClient(true)
       const axios = getAxiosClient(true)
       const res = await axios.get(
       const res = await axios.get(
         `https://xp-api.initiation-1.initia.xyz/xp/weekly/${account.address}/3`,
         `https://xp-api.initiation-1.initia.xyz/xp/weekly/${account.address}/3`,
       )
       )
-      console.log(res.data)
-      const finishedTasks = res.data.finishedTasks
+      // console.log(res.data)
+      const finishedTasks = res.data.finished_tasks
       if (finishedTasks.length === 6) {
       if (finishedTasks.length === 6) {
         await DBClient.instance.randomTask2.update({
         await DBClient.instance.randomTask2.update({
           where: { id: account.id },
           where: { id: account.id },
           data: { finish: 2 },
           data: { finish: 2 },
         })
         })
+      } else {
+        const data = {
+          task1: 0,
+          task2: 0,
+          task3: 0,
+          task4: 0,
+          task5: 0,
+          task6: 0,
+          finish: 0,
+        }
+        if (finishedTasks.includes('op_deposit_initai')) {
+          data.task4 = 1
+        }
+        if (finishedTasks.includes('op_deposit_miniwasm')) {
+          data.task6 = 1
+        }
+        if (finishedTasks.includes('op_deposit_blackwing')) {
+          data.task1 = 1
+        }
+        if (finishedTasks.includes('op_deposit_noon')) {
+          data.task2 = 1
+        }
+        if (finishedTasks.includes('op_deposit_tucana')) {
+          data.task3 = 1
+        }
+        if (finishedTasks.includes('op_deposit_minimove')) {
+          data.task5 = 1
+        }
+        await DBClient.instance.randomTask2.update({
+          where: { id: account.id },
+          data,
+        })
       }
       }
-    } catch (e) {
-      console.log(e.message)
-      return
-    }
+    } catch (e) {}
   })
   })
 }
 }
 
 
-startCheck(50)
+startCheck(300)

+ 19 - 6
src/swapTester.ts

@@ -1,11 +1,18 @@
-import { LCDClient, MnemonicKey, MsgExecute, Wallet } from '@initia/initia.js'
+import {
+  AccAddress,
+  LCDClient,
+  MnemonicKey,
+  MsgExecute,
+  Wallet,
+} from '@initia/initia.js'
 import { InitiaClient } from './InitiaClient'
 import { InitiaClient } from './InitiaClient'
+import toHex = AccAddress.toHex
 
 
 const key = new MnemonicKey({
 const key = new MnemonicKey({
   mnemonic:
   mnemonic:
-    'visual giant rely tooth recall explain vital tunnel snow road airport cake',
-  // 'deal earth suggest craft impact vocal outdoor perfect winter nice unhappy lizard',
-  // 'language tooth rug border arm essence badge rough ahead unaware bag night stay auto spawn february odor equip hub demand three setup used sentence',
+    // 'visual giant rely tooth recall explain vital tunnel snow road airport cake',
+    // 'deal earth suggest craft impact vocal outdoor perfect winter nice unhappy lizard',
+    'language tooth rug border arm essence badge rough ahead unaware bag night stay auto spawn february odor equip hub demand three setup used sentence',
   // 'grass spawn flavor cancel borrow only furnace must planet they hub mask dignity rotate report bubble nurse renew ten eagle purity mass dial fever',
   // 'grass spawn flavor cancel borrow only furnace must planet they hub mask dignity rotate report bubble nurse renew ten eagle purity mass dial fever',
 })
 })
 console.log('mnemonic:', key.mnemonic)
 console.log('mnemonic:', key.mnemonic)
@@ -36,8 +43,14 @@ async function main() {
   const client = new InitiaClient(key.mnemonic, false)
   const client = new InitiaClient(key.mnemonic, false)
   // await client.nameRegister()
   // await client.nameRegister()
   // await client.drawFood()
   // await client.drawFood()
-  const a = await client.newBridge2Noon()
+  const a = await client.newBridge2Miniwasm()
   console.log(a)
   console.log(a)
   // await client.mintPart()
   // await client.mintPart()
 }
 }
-main()
+// main()
+const target = '0x76622C9877947A6EEBaBba6898FAf6C57Ea2dfC8'
+
+async function hex() {
+  console.log(toHex(key.accAddress))
+}
+// hex()

+ 10 - 0
src/utils/balanceChecker.ts

@@ -0,0 +1,10 @@
+// import { LCDClient } from '@initia/initia.js'
+//
+// const url = 'https://lcd.initiation-1.initia.xyz/'
+// const lcd = new LCDClient(
+//   rpc,
+//   {
+//     chainId: 'initiation-1',
+//   },
+//   useProxy ? requester : null,
+// )