hel 1 سال پیش
والد
کامیت
3ade39b686
4فایلهای تغییر یافته به همراه37 افزوده شده و 20 حذف شده
  1. 1 1
      src/BaseClient.ts
  2. 19 2
      src/JennieModule.ts
  3. 16 16
      src/onchain/finalTask.ts
  4. 1 1
      src/onchain/fundChecker.ts

+ 1 - 1
src/BaseClient.ts

@@ -109,7 +109,7 @@ export abstract class BaseClient {
         new Coins([
           new Coin(
             'move/944f8dd8dc49f96c25fea9849f16436dcfa6d564eec802f3ef7f8b3ea85368ff',
-            randLimit.toString(),
+            randLimit / 2,
           ),
         ]),
       ),

+ 19 - 2
src/JennieModule.ts

@@ -1,5 +1,5 @@
 import { BaseClient } from './BaseClient'
-import { bcs, MsgExecute } from '@initia/initia.js'
+import { bcs, Coin, Coins, Fee, MsgExecute } from '@initia/initia.js'
 import { getAxiosClient } from './utils'
 
 export abstract class JennieModule extends BaseClient {
@@ -20,6 +20,7 @@ export abstract class JennieModule extends BaseClient {
   async drawFood() {
     const xp = await this.getXpAmount()
     if (Number(xp) < 200) {
+      await this.claimableXp()
       return `done`
     }
     const msg = new MsgExecute(
@@ -258,7 +259,23 @@ export abstract class JennieModule extends BaseClient {
             .toBase64(),
         ],
       )
-      return await this.broadcast(msg)
+      const randLimit = 370000 + Math.floor(Math.random() * 10000)
+      const signed = await this.wallet.createAndSignTx({
+        msgs: Array.isArray(msg) ? msg : [msg],
+        fee: new Fee(
+          randLimit,
+          new Coins([
+            new Coin(
+              'move/944f8dd8dc49f96c25fea9849f16436dcfa6d564eec802f3ef7f8b3ea85368ff',
+              randLimit / 2,
+            ),
+          ]),
+        ),
+      })
+      const broadcast = await this.lcd.tx.broadcastAsync(signed)
+      // console.log(broadcast.raw_log)
+      // console.log(this.key.accAddress)
+      return broadcast.txhash
     } else {
       return `done`
     }

+ 16 - 16
src/onchain/finalTask.ts

@@ -8,27 +8,27 @@ async function startCheck(concurrency) {
       status: 2,
     },
     orderBy: {
-      lastRun: 'asc',
+      lastRun: 'desc',
     },
-    take: 100000,
+    take: 1,
   })
   await forEachAsync(accountsRaw, concurrency, async (account, index) => {
     console.log(`${index}/${accountsRaw.length}: processing ${account.address}`)
     try {
-      if (Number(account.message) < 1000000) {
-        return
-      }
+      // if (Number(account.message) < 1000000) {
+      //   return
+      // }
       const client = new InitiaClient(account.mnemonic, true)
-      const gasGot = await client.gasGot()
-      if (!gasGot) {
-        console.log(`gas got:`, gasGot)
-        await DBClient.instance.account.update({
-          where: { id: account.id },
-          data: { status: -2 },
-          //可能领过还没到账的
-        })
-        return
-      }
+      // const gasGot = await client.gasGot()
+      // if (!gasGot) {
+      //   console.log(`gas got:`, gasGot)
+      //   await DBClient.instance.account.update({
+      //     where: { id: account.id },
+      //     data: { status: -2 },
+      //     //可能领过还没到账的
+      //   })
+      //   return
+      // }
 
       const done = await client.feedJennie()
       if (done == `done`) {
@@ -44,4 +44,4 @@ async function startCheck(concurrency) {
   })
 }
 
-startCheck(25)
+startCheck(1)

+ 1 - 1
src/onchain/fundChecker.ts

@@ -41,4 +41,4 @@ async function startCheck(concurrency) {
   })
 }
 
-startCheck(100)
+startCheck(1)