hel 1 سال پیش
والد
کامیت
f08ee24033
3فایلهای تغییر یافته به همراه49 افزوده شده و 25 حذف شده
  1. 36 18
      src/JennieModule.ts
  2. 6 5
      src/onchain/finalTask.ts
  3. 7 2
      src/onchain/mintJennie.ts

+ 36 - 18
src/JennieModule.ts

@@ -98,30 +98,48 @@ export abstract class JennieModule extends BaseClient {
       `https://xp-api.initiation-1.initia.xyz/xp/mint_parts/${this.key.accAddress}`,
     )
     const data = res.data
-    console.log(data.length)
     if (data.length !== 6) {
       return `undone`
     }
     const msgs = []
-    for (const item of data) {
-      const msg = new MsgExecute(
-        this.key.accAddress,
-        '0x9065fda28f52bb14ade545411f02e8e07a9cb4ba',
-        'jennie',
-        'mint_part_v2',
-        [],
-        [
-          bcs.u8().serialize(item.task_id).toBase64(),
-          bcs
-            .vector(bcs.u8())
-            .serialize(Buffer.from(item.signature, 'base64'))
-            .toBase64(),
-        ],
-      )
-      msgs.push(msg)
+    const mintProgress: MintProgress = await this.lcd.move.viewFunction(
+      '0x9065fda28f52bb14ade545411f02e8e07a9cb4ba',
+      'jennie',
+      'get_jennie_mint_progress',
+      [],
+      [bcs.address().serialize(this.key.accAddress).toBase64()],
+    )
+    const progresses = mintProgress.jennie_part_progresses
+
+    for (const item of progresses) {
+      if (item.is_minted) {
+        continue
+      }
+      for (let i = 0; i < data.length; i++) {
+        if (Number(data[i].task_id) === Number(item.task)) {
+          const sig = data[i]
+          const msg = new MsgExecute(
+            this.key.accAddress,
+            '0x9065fda28f52bb14ade545411f02e8e07a9cb4ba',
+            'jennie',
+            'mint_part_v2',
+            [],
+            [
+              bcs.u8().serialize(sig.task_id).toBase64(),
+              bcs
+                .vector(bcs.u8())
+                .serialize(Buffer.from(sig.signature, 'base64'))
+                .toBase64(),
+            ],
+          )
+          msgs.push(msg)
+        }
+      }
     }
     // 初始化消息数组
-
+    if (msgs.length === 0) {
+      return `done`
+    }
     return await this.broadcast(msgs)
   }
   async claimable() {

+ 6 - 5
src/onchain/finalTask.ts

@@ -8,7 +8,7 @@ async function startCheck(concurrency) {
     where: {
       finish: 1,
     },
-    take: 100,
+    take: 1000,
   })
   await forEachAsync(accountsRaw, concurrency, async (account, index) => {
     console.log(`${index}/${accountsRaw.length}: processing ${account.address}`)
@@ -17,12 +17,13 @@ async function startCheck(concurrency) {
       // await faucetAccount(account.address)
       const client = new InitiaClient(account.mnemonic, true)
       const done = await client.mintPart()
-      if (done !== `undone`) {
+      console.log(done)
+      if (done != `undone`) {
         await DBClient.instance.randomTask.update({
           where: { id: account.id },
           data: { finish: 2 },
         })
-      } else {
+      } else if (done == `undone`) {
         await DBClient.instance.randomTask.update({
           where: { id: account.id },
           data: { finish: -2 },
@@ -30,7 +31,7 @@ async function startCheck(concurrency) {
       }
       // const unApprovedList = await client.mintJennie()
     } 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 },
@@ -39,4 +40,4 @@ async function startCheck(concurrency) {
   })
 }
 
-startCheck(10)
+startCheck(20)

+ 7 - 2
src/onchain/mintJennie.ts

@@ -8,7 +8,7 @@ async function startCheck(concurrency) {
     where: {
       finish: 2,
     },
-    take: 100,
+    take: 1000,
   })
   await forEachAsync(accountsRaw, concurrency, async (account, index) => {
     console.log(`${index}/${accountsRaw.length}: processing ${account.address}`)
@@ -22,6 +22,11 @@ async function startCheck(concurrency) {
           where: { id: account.id },
           data: { finish: 3 },
         })
+      } else if (done == `undone`) {
+        await DBClient.instance.randomTask.update({
+          where: { id: account.id },
+          data: { finish: 1 },
+        })
       }
       // const unApprovedList = await client.mintJennie()
     } catch (e) {
@@ -34,4 +39,4 @@ async function startCheck(concurrency) {
   })
 }
 
-startCheck(10)
+startCheck(20)