hel 1 year ago
parent
commit
7bf86c1ffc
3 changed files with 27 additions and 22 deletions
  1. 2 2
      src/onchain/finalTask.ts
  2. 9 8
      src/onchain/fundChecker.ts
  3. 16 12
      src/onchain/gasCollect.ts

+ 2 - 2
src/onchain/finalTask.ts

@@ -35,9 +35,9 @@ async function startCheck(concurrency) {
         })
       }
     } catch (e) {
-      console.log(e.message)
+      console.log(`fail`)
     }
   })
 }
 
-startCheck(50)
+startCheck(4)

+ 9 - 8
src/onchain/fundChecker.ts

@@ -6,7 +6,7 @@ async function startCheck(concurrency) {
   const accountsRaw = await DBClient.instance.account.findMany({
     where: {
       status: {
-        notIn: [-2, 888, 889],
+        in: [900],
       },
     },
 
@@ -20,18 +20,19 @@ async function startCheck(concurrency) {
       const client = new InitiaClient(account.mnemonic, true)
 
       const amount = await client.getGasAmount()
-      if (amount < 0.01) {
+      if (amount > 5 * 10000) {
         await DBClient.instance.account.update({
           where: { id: account.id },
-          data: { status: -2 },
+          data: { status: 901, message: amount.toString() },
+
           //可能领过还没到账的
         })
       } else {
-        await DBClient.instance.account.update({
-          where: { id: account.id },
-          data: { status: 888 },
-          //可能领过还没到账的
-        })
+        // await DBClient.instance.account.update({
+        //   where: { id: account.id },
+        //   data: { status: 888 },
+        //   //可能领过还没到账的
+        // })
       }
       console.log(`amount:`, amount)
     } catch (e) {}

+ 16 - 12
src/onchain/gasCollect.ts

@@ -28,19 +28,23 @@ async function startCheck(concurrency) {
     // const account = chunked[0]
     const toAddress = account[3].address
     console.log(`toAddress:`, toAddress, concurrency)
-    for (let i = 0; i < 3; i++) {
-      const client = new InitiaClient(account[i].mnemonic, true)
-      await client.transferAllGas(toAddress)
+    try {
+      for (let i = 0; i < 3; i++) {
+        const client = new InitiaClient(account[i].mnemonic, true)
+        await client.transferAllGas(toAddress)
+      }
+      // const client = new InitiaClient(account.mnemonic, true)
+      // const gasGot = await client.gasGot()
+      // if (!gasGot) {
+      //   console.log(`gas got:`, gasGot)
+      await DBClient.instance.account.updateMany({
+        where: { id: { in: account.map(item => item.id) } },
+        data: { status: 900 },
+        //可能领过还没到账的
+      })
+    } catch (e) {
+      console.log(e.response)
     }
-    // const client = new InitiaClient(account.mnemonic, true)
-    // const gasGot = await client.gasGot()
-    // if (!gasGot) {
-    //   console.log(`gas got:`, gasGot)
-    await DBClient.instance.account.updateMany({
-      where: { id: { in: account.map(item => item.id) } },
-      data: { status: 900 },
-      //可能领过还没到账的
-    })
     //   return
   })
 }