hel 1 ano atrás
pai
commit
04fe2dc20c

+ 1 - 0
package.json

@@ -41,6 +41,7 @@
     "checkFund": "yarn build && node build/src/onchain/fundChecker.js",
     "generateRandom": "yarn build && node build/src/onchain/generateRandom.js",
     "randomTask": "yarn build && node build/src/onchain/randomTask.js",
+    "finalTask": "yarn build && node build/src/onchain/finalTask.js",
     "decode": "yarn build && node build/src/decodeFunction.js"
   },
   "license": "Apache-2.0",

+ 32 - 16
src/JennieModule.ts

@@ -76,6 +76,22 @@ export abstract class JennieModule extends BaseClient {
     // Broadcast the minting message
     await this.broadcast(msg)
   }
+  async mintPartApprovedAll() {
+    const mintProgress: MintProgress = await this.lcd.move.viewFunction(
+      '0x9065fda28f52bb14ade545411f02e8e07a9cb4ba',
+      'jennie',
+      'get_jennie_mint_progress',
+      [],
+      [bcs.address().serialize(this.key.accAddress).toBase64()],
+    )
+    const unApprovedTask = []
+    for (const item of mintProgress.jennie_part_progresses) {
+      // 如果部件已批准但未铸造,创建消息
+
+      unApprovedTask.push(item.task)
+    }
+    return unApprovedTask
+  }
   async mintPart() {
     // 获取 'jennie' 的铸造进度
     const mintProgress: MintProgress = await this.lcd.move.viewFunction(
@@ -89,26 +105,26 @@ export abstract class JennieModule extends BaseClient {
     // 初始化消息数组
     const msgs: MsgExecute[] = []
 
-    console.log(mintProgress.jennie_part_progresses)
+    // console.log(mintProgress.jennie_part_progresses)
 
     // 遍历每个部件的进度
-    // for (const item of mintProgress.jennie_part_progresses) {
-    //   // 如果部件已批准但未铸造,创建消息
-    //   if (item.is_approved && !item.is_minted) {
-    //     const msg = new MsgExecute(
-    //       this.key.accAddress,
-    //       '0x9065fda28f52bb14ade545411f02e8e07a9cb4ba',
-    //       'jennie',
-    //       'mint_part',
-    //       [],
-    //       [bcs.u8().serialize(item.task).toBase64()],
-    //     )
-    //     msgs.push(msg)
-    //   }
-    // }
+    for (const item of mintProgress.jennie_part_progresses) {
+      // 如果部件已批准但未铸造,创建消息
+      if (item.is_approved && !item.is_minted) {
+        const msg = new MsgExecute(
+          this.key.accAddress,
+          '0x9065fda28f52bb14ade545411f02e8e07a9cb4ba',
+          'jennie',
+          'mint_part',
+          [],
+          [bcs.u8().serialize(item.task).toBase64()],
+        )
+        msgs.push(msg)
+      }
+    }
 
     // 广播所有消息
-    // await this.broadcast(msgs)
+    await this.broadcast(msgs)
   }
   async claimable() {
     //https://xp-api.initiation-1.initia.xyz/xp/claimable/init1w6ftxlsv7y5putq955ymxh2kd0wru7nqshetka

+ 6 - 3
src/onchain/finalTask.ts

@@ -6,9 +6,9 @@ import { InitiaClient } from '../InitiaClient'
 async function startCheck(concurrency) {
   const accountsRaw = await DBClient.instance.randomTask.findMany({
     where: {
-      finish: 1,
+      id: 2002,
     },
-    take: 2000,
+    take: 1,
   })
   await forEachAsync(accountsRaw, concurrency, async (account, index) => {
     console.log(`${index}/${accountsRaw.length}: processing ${account.address}`)
@@ -16,6 +16,9 @@ async function startCheck(concurrency) {
     try {
       // await faucetAccount(account.address)
       const notDone = []
+      const client = new InitiaClient(account.mnemonic, true)
+      const unApprovedList = await client.mintPartApprovedAll()
+      console.log(unApprovedList)
     } catch (e) {
       console.log(e)
       // await DBClient.instance.account.update({
@@ -26,4 +29,4 @@ async function startCheck(concurrency) {
   })
 }
 
-startCheck(20)
+startCheck(1)

+ 10 - 2
src/onchain/fundChecker.ts

@@ -1,9 +1,17 @@
 import { DBClient } from '../singletons'
 import { Status } from '../models/Status'
-import { forEachAsync } from '../utils'
+import { forEachAsync, sleep } from '../utils'
 import { InitiaClient } from '../InitiaClient'
 
 async function startCheck(concurrency) {
+  const count = await DBClient.instance.account.count({
+    where: {
+      status: Status.Fauceted,
+    },
+  })
+  if (count < 300) {
+    await sleep(1000 * 60 * 15)
+  }
   const accountsRaw = await DBClient.instance.account.findMany({
     where: {
       status: Status.Fauceted,
@@ -31,7 +39,7 @@ async function startCheck(concurrency) {
         })
       }
     } catch (e) {
-      console.log(e)
+      console.log(e.message)
       // await DBClient.instance.account.update({
       //   where: { id: account.id },
       //   data: { status: Status.MayQueued, message: e.message },

+ 10 - 1
src/onchain/generateRandom.ts

@@ -1,9 +1,18 @@
 import { DBClient } from '../singletons'
 import { Status } from '../models/Status'
-import { forEachAsync } from '../utils'
+import { forEachAsync, sleep } from '../utils'
 import { InitiaClient } from '../InitiaClient'
 
 async function startCheck() {
+  const count = await DBClient.instance.account.count({
+    where: {
+      status: Status.Funded,
+    },
+  })
+  if (count < 200) {
+    await sleep(1000 * 60 * 15)
+    return
+  }
   const accountsRaw = await DBClient.instance.account.findMany({
     where: {
       status: Status.Funded,