hel 1 năm trước cách đây
mục cha
commit
fa80d49a24
3 tập tin đã thay đổi với 38 bổ sung27 xóa
  1. 17 4
      src/InitiaTask.ts
  2. 10 12
      src/JennieModule.ts
  3. 11 11
      src/onchain/randomTask.ts

+ 17 - 4
src/InitiaTask.ts

@@ -127,10 +127,23 @@ export abstract class InitiaTask extends JennieModule {
   }
 
   async claimReward() {
-    const msg = new MsgWithdrawDelegatorReward(
-      this.key.accAddress,
-      'initvaloper1r3cuy3q2gxh0mpj2nu0cnpqtutaxx9z87r6qtt',
+    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}`,
     )
-    return await this.broadcast(msg)
+    const response = data.data.delegation_responses
+    // console.log(response)
+    // return false
+    const msgs = []
+
+    response.forEach((item: any) => {
+      const msg = new MsgWithdrawDelegatorReward(
+        this.key.accAddress,
+        item.delegation.validator_address,
+      )
+      msgs.push(msg)
+    })
+    return await this.broadcast(msgs)
   }
 }

+ 10 - 12
src/JennieModule.ts

@@ -77,20 +77,18 @@ export abstract class JennieModule extends BaseClient {
     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 axios = getAxiosClient(true)
+    const res = await axios.get(
+      `https://xp-api.initiation-1.initia.xyz/xp/mint_parts/${this.key.accAddress}`,
     )
-    const unApprovedTask = []
-    for (const item of mintProgress.jennie_part_progresses) {
-      // 如果部件已批准但未铸造,创建消息
-
-      unApprovedTask.push(item.task)
+    const data = res.data
+    console.log(data)
+    let undone = [1, 2, 3, 4, 5, 6]
+    for (const item of data) {
+      const task = item.task_id + 1
+      undone = undone.filter(value => value !== task)
     }
-    return unApprovedTask
+    console.log(undone)
   }
   async mintPart() {
     // 获取 'jennie' 的铸造进度

+ 11 - 11
src/onchain/randomTask.ts

@@ -86,20 +86,20 @@ async function startCheck(concurrency) {
             where: { id: account.id },
             data: { task5: 1 },
           })
-        } else if (randomPick === 6) {
-          console.log(`task6`)
-          const bool = await client.claimReward()
-          console.log(bool)
-          if (bool) {
-            await DBClient.instance.randomTask.update({
-              where: { id: account.id },
-              data: { task6: 1 },
-            })
-          }
+        }
+      } else if (randomPick === 6) {
+        console.log(`task6`)
+        const bool = await client.claimReward()
+        console.log(bool)
+        if (bool) {
+          await DBClient.instance.randomTask.update({
+            where: { id: account.id },
+            data: { task6: 1 },
+          })
         }
       }
     } catch (e) {
-      console.log(e.message)
+      console.log(e)
       // await DBClient.instance.account.update({
       //   where: { id: account.id },
       //   data: { status: Status.MayQueued, message: e.message },