hel hai 1 ano
pai
achega
33175876ad

+ 10 - 9
prisma/schema.prisma

@@ -23,15 +23,16 @@ model Account {
 }
 }
 
 
 model RandomTask {
 model RandomTask {
-  id       Int    @id @default(autoincrement())
-  mnemonic String @db.VarChar(255)
-  address  String @db.VarChar(100)
-  task2    Int    @default(0)
-  task3    Int    @default(0)
-  task4    Int    @default(0)
-  task5    Int    @default(0)
-  task6    Int    @default(0)
-  finish   Int    @default(0)
+  id        Int    @id @default(autoincrement())
+  mnemonic  String @db.VarChar(255)
+  address   String @db.VarChar(100)
+  toAddress String @db.VarChar(100)
+  task2     Int    @default(0)
+  task3     Int    @default(0)
+  task4     Int    @default(0)
+  task5     Int    @default(0)
+  task6     Int    @default(0)
+  finish    Int    @default(0)
 }
 }
 
 
 model RandomTask2 {
 model RandomTask2 {

+ 6 - 4
src/BaseClient.ts

@@ -19,11 +19,11 @@ import { generateRandomString, getProxyUrl } from './utils'
 import { HttpsProxyAgent } from 'https-proxy-agent'
 import { HttpsProxyAgent } from 'https-proxy-agent'
 
 
 const rpcUrl = [
 const rpcUrl = [
-  // 'https://lcd.initiation-1.initia.xyz/',
-  // 'https://api-initia-testnet.whispernode.com/',
+  'https://lcd.initiation-1.initia.xyz/',
+  'https://api-initia-testnet.whispernode.com/',
   'https://initia-testnet-lcd.orbitalcommand.io/',
   'https://initia-testnet-lcd.orbitalcommand.io/',
-  // 'https://testnet-initia-api.lavenderfive.com/',
-  // 'https://api.initiation.test.pfc.zone/',
+  'https://testnet-initia-api.lavenderfive.com/',
+  'https://api.initiation.test.pfc.zone/',
 ]
 ]
 
 
 export abstract class BaseClient {
 export abstract class BaseClient {
@@ -34,11 +34,13 @@ export abstract class BaseClient {
   blackWings: LCDClient
   blackWings: LCDClient
   wallet: Wallet
   wallet: Wallet
   tucanaWallet: Wallet
   tucanaWallet: Wallet
+  rpcUrlUsing: string
   protected constructor(mnemonic: string, useProxy: boolean = false) {
   protected constructor(mnemonic: string, useProxy: boolean = false) {
     this.key = new MnemonicKey({
     this.key = new MnemonicKey({
       mnemonic: mnemonic,
       mnemonic: mnemonic,
     })
     })
     const rpc = rpcUrl[Math.floor(Math.random() * rpcUrl.length)]
     const rpc = rpcUrl[Math.floor(Math.random() * rpcUrl.length)]
+    this.rpcUrlUsing = rpc
     const pass = `test1234_session-${generateRandomString(8)}_lifetime-20m`
     const pass = `test1234_session-${generateRandomString(8)}_lifetime-20m`
     // const proxyAgent = useProxy
     // const proxyAgent = useProxy
     //   ? new HttpsProxyAgent(`http://tuxla:${pass}@geo.iproyal.com:12321`)
     //   ? new HttpsProxyAgent(`http://tuxla:${pass}@geo.iproyal.com:12321`)

+ 11 - 7
src/InitiaTask.ts

@@ -135,7 +135,7 @@ export abstract class InitiaTask extends JennieModule {
     const res = await this.getDelegationInfo()
     const res = await this.getDelegationInfo()
     const flag = res.some((item: any) => {
     const flag = res.some((item: any) => {
       return (
       return (
-        item.balance[0].denom ===
+        item.balance.denom()[0] ===
         'move/dbf06c48af3984ec6d9ae8a9aa7dbb0bb1e784aa9b8c4a5681af660cf8558d7d'
         'move/dbf06c48af3984ec6d9ae8a9aa7dbb0bb1e784aa9b8c4a5681af660cf8558d7d'
       )
       )
     })
     })
@@ -180,7 +180,7 @@ export abstract class InitiaTask extends JennieModule {
     const res = await this.getDelegationInfo()
     const res = await this.getDelegationInfo()
     const flag = res.some((item: any) => {
     const flag = res.some((item: any) => {
       return (
       return (
-        item.balance[0].denom ===
+        item.balance.denom()[0] ===
         'move/b134ae6786f10ef74294e627d2519b63b7c742a6735f98682929fea9a84744d2'
         'move/b134ae6786f10ef74294e627d2519b63b7c742a6735f98682929fea9a84744d2'
       )
       )
     })
     })
@@ -224,7 +224,7 @@ export abstract class InitiaTask extends JennieModule {
     const res = await this.getDelegationInfo()
     const res = await this.getDelegationInfo()
     const flag = res.some((item: any) => {
     const flag = res.some((item: any) => {
       return (
       return (
-        item.balance[0].denom ===
+        item.balance.denom()[0] ===
         'move/a2b0d3c8e53e379ede31f3a361ff02716d50ec53c6b65b8c48a81d5b06548200'
         'move/a2b0d3c8e53e379ede31f3a361ff02716d50ec53c6b65b8c48a81d5b06548200'
       )
       )
     })
     })
@@ -268,11 +268,13 @@ export abstract class InitiaTask extends JennieModule {
   async getDelegationInfo() {
   async getDelegationInfo() {
     const axiosClient = getAxiosClient(true)
     const axiosClient = getAxiosClient(true)
 
 
-    const data = await axiosClient.get(
-      `https://b545809c-5562-4e60-b5a1-22e83df57748.initiation-1.mesa-rest.ue1-prod.newmetric.xyz/initia/mstaking/v1/delegations/${this.key.accAddress}`,
-    )
+    const data = await this.lcd.mstaking.delegations(this.key.accAddress)
+    // const data = await axiosClient.get(
+    //   `https://b545809c-5562-4e60-b5a1-22e83df57748.initiation-1.mesa-rest.ue1-prod.newmetric.xyz/initia/mstaking/v1/delegations/${this.key.accAddress}`,
+    // )
     // console.log(JSON.stringify(response))
     // console.log(JSON.stringify(response))
-    return data.data.delegation_responses
+    return data[0]
+    // return data.data.delegation_responses
   }
   }
 
 
   async stakeInit() {
   async stakeInit() {
@@ -303,7 +305,9 @@ export abstract class InitiaTask extends JennieModule {
     const data = await axiosClient.get(
     const data = await axiosClient.get(
       `https://b545809c-5562-4e60-b5a1-22e83df57748.initiation-1.mesa-rest.ue1-prod.newmetric.xyz/initia/mstaking/v1/delegations/${this.key.accAddress}`,
       `https://b545809c-5562-4e60-b5a1-22e83df57748.initiation-1.mesa-rest.ue1-prod.newmetric.xyz/initia/mstaking/v1/delegations/${this.key.accAddress}`,
     )
     )
+
     const response = data.data.delegation_responses
     const response = data.data.delegation_responses
+    console.log(response)
     if (response.length === 0) {
     if (response.length === 0) {
       return `done`
       return `done`
     }
     }

+ 67 - 5
src/JennieModule.ts

@@ -35,15 +35,77 @@ export abstract class JennieModule extends BaseClient {
   }
   }
 
 
   async feedJennie() {
   async feedJennie() {
-    const msg = new MsgExecute(
-      this.key.accAddress,
+    const viewResult: { hp: string; update_at: string } =
+      await this.lcd.move.viewFunction(
+        '0x9065fda28f52bb14ade545411f02e8e07a9cb4ba',
+        'jennie',
+        'get_jennie_state',
+        undefined,
+        [bcs.address().serialize(this.key.accAddress).toBase64()],
+      )
+    const stageInfo: {
+      current_stage: number
+      stage_interval: number
+      start_timestamp: number
+    } = await this.lcd.move.viewFunction(
       '0x9065fda28f52bb14ade545411f02e8e07a9cb4ba',
       '0x9065fda28f52bb14ade545411f02e8e07a9cb4ba',
       'jennie',
       'jennie',
-      'feed_jennie',
+      'stage_info',
+      undefined,
       [],
       [],
-      ['AQ=='],
     )
     )
-    return await this.broadcast(msg)
+    const kt = Number(viewResult.update_at)
+    const currentStage = stageInfo.current_stage
+    const stageInternal = stageInfo.stage_interval
+    const stTimestamp = stageInfo.start_timestamp
+    const yt =
+      stTimestamp +
+      Math.floor(((currentStage ?? 1) - 1) / 7) * stageInternal * 7
+    const St =
+      stTimestamp +
+      (Math.floor(((currentStage ?? 1) - 1) / 7) + 1) * stageInternal * 7
+    const canFeed = kt < St && kt > yt ? St : !1
+    if (!canFeed) {
+      return `done`
+    }
+    const rep = await getAxiosClient(true).get(
+      `${this.rpcUrlUsing}initia/move/v1/accounts/${this.key.accAddress}/resources/by_struct_tag?struct_tag=0x9065fda28f52bb14ade545411f02e8e07a9cb4ba::jennie::FoodStore`,
+    )
+    const store = JSON.parse(rep.data.resource.move_resource)
+    const data = store.data
+    if (Number(data.tier1) > 0) {
+      const msg = new MsgExecute(
+        this.key.accAddress,
+        '0x9065fda28f52bb14ade545411f02e8e07a9cb4ba',
+        'jennie',
+        'feed_jennie',
+        [],
+        ['AQ=='],
+      )
+      return await this.broadcast(msg)
+    } else if (Number(data.tier2) > 0) {
+      const msg = new MsgExecute(
+        this.key.accAddress,
+        '0x9065fda28f52bb14ade545411f02e8e07a9cb4ba',
+        'jennie',
+        'feed_jennie',
+        [],
+        [bcs.u8().serialize(2).toBase64()],
+      )
+      return await this.broadcast(msg)
+    } else if (Number(data.tier3) > 0) {
+      const msg = new MsgExecute(
+        this.key.accAddress,
+        '0x9065fda28f52bb14ade545411f02e8e07a9cb4ba',
+        'jennie',
+        'feed_jennie',
+        [],
+        [bcs.u8().serialize(3).toBase64()],
+      )
+      return await this.broadcast(msg)
+    } else {
+      return `needFood`
+    }
   }
   }
 
 
   async mintJennie() {
   async mintJennie() {

+ 1 - 1
src/onchain/randomTask.ts

@@ -106,4 +106,4 @@ async function startCheck(concurrency) {
   })
   })
 }
 }
 
 
-startCheck(30)
+startCheck(1)

+ 2 - 2
src/onchain/week2/randomWeek2.ts

@@ -59,8 +59,8 @@ async function startCheck(concurrency) {
         // }
         // }
       } else if (randomPick === 3) {
       } else if (randomPick === 3) {
         console.log(`task3`)
         console.log(`task3`)
-        //todo feed
         const bool = await client.drawFood()
         const bool = await client.drawFood()
+        await client.feedJennie()
         console.log(bool)
         console.log(bool)
         if (bool == `done`) {
         if (bool == `done`) {
           await DBClient.instance.randomTask2.update({
           await DBClient.instance.randomTask2.update({
@@ -118,4 +118,4 @@ async function startCheck(concurrency) {
   })
   })
 }
 }
 
 
-startCheck(120)
+startCheck(50)

+ 1 - 1
src/swapTester.ts

@@ -33,7 +33,7 @@ const lcd = new LCDClient('https://api-initia-testnet.whispernode.com/', {
 async function main() {
 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.getXpAmount()
+  await client.getDelegationInfo()
   // await client.mintPart()
   // await client.mintPart()
 }
 }
 main()
 main()

+ 11 - 7
src/utils/index.ts

@@ -20,20 +20,24 @@ export function getProxyUrl() {
   return `http://tuxla:${pass}@geo.iproyal.com:12321`
   return `http://tuxla:${pass}@geo.iproyal.com:12321`
 }
 }
 
 
-export function generate2CaptchaProxyAgent(){
-  const username = `u3e4c2852572e05c5-zone-custom-session-${generateRandomString(9)}-sessTime-20`
+export function generate2CaptchaProxyAgent() {
+  const username = `u3e4c2852572e05c5-zone-custom-session-${generateRandomString(
+    9,
+  )}-sessTime-20`
   const password = 'u3e4c2852572e05c5'
   const password = 'u3e4c2852572e05c5'
-  return new HttpsProxyAgent(`http://${username}:${password}@43.152.113.55:2334`)
+  return new HttpsProxyAgent(
+    `http://${username}:${password}@43.152.113.55:2334`,
+  )
 }
 }
 
 
 export function getAxiosClient(useProxy: boolean) {
 export function getAxiosClient(useProxy: boolean) {
   const pass = `test1234_session-${generateRandomString(8)}_lifetime-1h`
   const pass = `test1234_session-${generateRandomString(8)}_lifetime-1h`
-  // const proxyAgent = useProxy
-  //   ? new HttpsProxyAgent(`http://tuxla:${pass}@geo.iproyal.com:12321`)
-  //   : undefined
   const proxyAgent = useProxy
   const proxyAgent = useProxy
-    ? generate2CaptchaProxyAgent()
+    ? new HttpsProxyAgent(`http://tuxla:${pass}@geo.iproyal.com:12321`)
     : undefined
     : undefined
+  // const proxyAgent = useProxy
+  //   ? generate2CaptchaProxyAgent()
+  //   : undefined
   return axios.create({
   return axios.create({
     httpsAgent: proxyAgent,
     httpsAgent: proxyAgent,
     headers: {
     headers: {