hel 1 ano atrás
pai
commit
b1c92bce81
6 arquivos alterados com 187 adições e 8 exclusões
  1. 2 1
      package.json
  2. 56 0
      src/BaseClient.ts
  3. 2 1
      src/onchain/week2/week2task2.ts
  4. 121 0
      src/onchain/week3/randomWeek3.ts
  5. 2 2
      src/swapTester.ts
  6. 4 4
      yarn.lock

+ 2 - 1
package.json

@@ -42,6 +42,7 @@
     "generateRandom": "yarn build && node build/src/onchain/generateRandom.js",
     "generateRandomW2": "yarn build && node build/src/onchain/week2/generateRandomW2.js",
     "runWeek2": "yarn build && node build/src/onchain/week2/randomWeek2.js",
+    "runWeek3": "yarn build && node build/src/onchain/week3/randomWeek3.js",
     "runWeek2Task2": "yarn build && node build/src/onchain/week2/week2task2.js",
     "randomTask": "yarn build && node build/src/onchain/randomTask.js",
     "finalTask": "yarn build && node build/src/onchain/finalTask.js",
@@ -51,7 +52,7 @@
   },
   "license": "Apache-2.0",
   "dependencies": {
-    "@initia/initia.js": "^0.2.1",
+    "@initia/initia.js": "0.2.5",
     "@prisma/client": "^5.14.0",
     "axios": "^1.6.8",
     "dotenv": "^16.4.5",

+ 56 - 0
src/BaseClient.ts

@@ -11,6 +11,7 @@ import {
   Msg,
   MsgCreateBridge,
   MsgExecute,
+  MsgInitiateTokenDeposit,
   MsgSetBridgeInfo,
   MsgTransfer,
   Wallet,
@@ -332,4 +333,59 @@ export abstract class BaseClient {
     const broadcast = await this.lcd.tx.broadcastSync(signed)
     console.log(broadcast)
   }
+
+  async newBridge2BlackWings() {
+    const msg = new MsgInitiateTokenDeposit(
+      this.key.accAddress,
+      8,
+      this.key.accAddress,
+      new Coin('uinit', 1000000),
+    )
+    return await this.broadcast(msg)
+  }
+  async newBridge2Noon() {
+    const msg = new MsgInitiateTokenDeposit(
+      this.key.accAddress,
+      17,
+      this.key.accAddress,
+      new Coin('uinit', 1000000),
+    )
+    return await this.broadcast(msg)
+  }
+  async newBridge2Ai() {
+    const msg = new MsgInitiateTokenDeposit(
+      this.key.accAddress,
+      6,
+      this.key.accAddress,
+      new Coin('uinit', 1000000),
+    )
+    return await this.broadcast(msg)
+  }
+  async newBridge2Tucana() {
+    const msg = new MsgInitiateTokenDeposit(
+      this.key.accAddress,
+      14,
+      this.key.accAddress,
+      new Coin('uinit', 1000000),
+    )
+    return await this.broadcast(msg)
+  }
+  async newBridge2Miniwasm() {
+    const msg = new MsgInitiateTokenDeposit(
+      this.key.accAddress,
+      2,
+      this.key.accAddress,
+      new Coin('uinit', 1000000),
+    )
+    return await this.broadcast(msg)
+  }
+  async newBridge2Minimove() {
+    const msg = new MsgInitiateTokenDeposit(
+      this.key.accAddress,
+      1,
+      this.key.accAddress,
+      new Coin('uinit', 1000000),
+    )
+    return await this.broadcast(msg)
+  }
 }

+ 2 - 1
src/onchain/week2/week2task2.ts

@@ -6,6 +6,7 @@ async function startCheck(concurrency) {
   const accountsRaw = await DBClient.instance.randomTask2.findMany({
     where: {
       finish: 1,
+      task2: 1,
     },
     take: 40000,
   })
@@ -34,4 +35,4 @@ async function startCheck(concurrency) {
   })
 }
 
-startCheck(150)
+startCheck(1000)

+ 121 - 0
src/onchain/week3/randomWeek3.ts

@@ -0,0 +1,121 @@
+import { forEachAsync } from '../../utils'
+import { DBClient } from '../../singletons'
+import { InitiaClient } from '../../InitiaClient'
+
+async function startCheck(concurrency) {
+  const accountsRaw = await DBClient.instance.randomTask2.findMany({
+    where: {
+      finish: 0,
+    },
+    take: 40000,
+  })
+  await forEachAsync(accountsRaw, concurrency, async (account, index) => {
+    console.log(
+      `${index}/${accountsRaw.length}: processing ${account.address},account id: ${account.id}`,
+    )
+
+    try {
+      // await faucetAccount(account.address)
+      const notDone = []
+
+      if (account.task1 === 0) {
+        notDone.push(1)
+      }
+      if (account.task2 === 0) {
+        notDone.push(2)
+      }
+      if (account.task3 === 0) {
+        notDone.push(3)
+      }
+      if (account.task4 === 0) {
+        notDone.push(4)
+      }
+      if (account.task5 === 0) {
+        notDone.push(5)
+      }
+      if (account.task6 === 0) {
+        notDone.push(6)
+      }
+
+      console.log(`notDone`, notDone)
+
+      if (notDone.length === 0) {
+        await DBClient.instance.randomTask2.update({
+          where: { id: account.id },
+          data: { finish: 1 },
+        })
+      }
+
+      const randomPick = notDone[Math.floor(Math.random() * notDone.length)]
+
+      const client = new InitiaClient(account.mnemonic, true)
+      if (randomPick === 2) {
+        console.log(`task2`)
+        const bool = await client.newBridge2Noon()
+        if (bool) {
+          await DBClient.instance.randomTask2.update({
+            where: { id: account.id },
+            data: { task2: 1 },
+          })
+        }
+      } else if (randomPick === 3) {
+        console.log(`task3`)
+        const bool = await client.newBridge2Tucana()
+        if (bool) {
+          await DBClient.instance.randomTask2.update({
+            where: { id: account.id },
+            data: { task3: 1 },
+          })
+        }
+      } else if (randomPick === 4) {
+        console.log(`task4`)
+        const bool = await client.newBridge2Ai()
+
+        if (bool) {
+          await DBClient.instance.randomTask2.update({
+            where: { id: account.id },
+            data: { task4: 1 },
+          })
+        }
+      } else if (randomPick === 5) {
+        console.log(`task5`)
+        const bool = await client.newBridge2Minimove()
+
+        console.log(bool)
+        if (bool) {
+          await DBClient.instance.randomTask2.update({
+            where: { id: account.id },
+            data: { task5: 1 },
+          })
+        }
+      } else if (randomPick === 6) {
+        console.log(`task6`)
+        const bool = await client.newBridge2Miniwasm()
+        if (bool) {
+          await DBClient.instance.randomTask2.update({
+            where: { id: account.id },
+            data: { task6: 1 },
+          })
+        }
+      } else if (randomPick === 1) {
+        console.log(`task6`)
+        const bool = await client.newBridge2BlackWings()
+        if (bool == `done`) {
+          await DBClient.instance.randomTask2.update({
+            where: { id: account.id },
+            data: { task1: 1 },
+          })
+        }
+      }
+    } catch (e) {
+      console.log(e.message)
+      return
+      // await DBClient.instance.account.update({
+      //   where: { id: account.id },
+      //   data: { status: Status.MayQueued, message: e.message },
+      // })
+    }
+  })
+}
+
+startCheck(150)

+ 2 - 2
src/swapTester.ts

@@ -3,7 +3,7 @@ import { InitiaClient } from './InitiaClient'
 
 const key = new MnemonicKey({
   mnemonic:
-    'scheme address way popular shrug fall rail eyebrow buzz learn cross involve spatial rookie ostrich grocery chest ice glory security slogan summer also comfort',
+    'visual giant rely tooth recall explain vital tunnel snow road airport cake',
   // 'deal earth suggest craft impact vocal outdoor perfect winter nice unhappy lizard',
   // 'language tooth rug border arm essence badge rough ahead unaware bag night stay auto spawn february odor equip hub demand three setup used sentence',
   // 'grass spawn flavor cancel borrow only furnace must planet they hub mask dignity rotate report bubble nurse renew ten eagle purity mass dial fever',
@@ -36,7 +36,7 @@ async function main() {
   const client = new InitiaClient(key.mnemonic, false)
   // await client.nameRegister()
   // await client.drawFood()
-  const a = await client.stakeEthSingle()
+  const a = await client.newBridge2Noon()
   console.log(a)
   // await client.mintPart()
 }

+ 4 - 4
yarn.lock

@@ -1025,10 +1025,10 @@
   dependencies:
     browser-headers "^0.4.1"
 
-"@initia/initia.js@^0.2.1":
-  version "0.2.2"
-  resolved "https://registry.yarnpkg.com/@initia/initia.js/-/initia.js-0.2.2.tgz#8cdd7dd93640c1b83c0209c21b61f3286b52af0e"
-  integrity sha512-0pp0WYvh7L2YFdnxIBv5VFdyBQgSR5OOucybGCELC/5YxdwOI62UALoDMyxhbEwKyK8C0HKmepFgkJB1ugtcMA==
+"@initia/initia.js@0.2.5":
+  version "0.2.5"
+  resolved "https://registry.yarnpkg.com/@initia/initia.js/-/initia.js-0.2.5.tgz#a96901ce89ad319c67d7c5d3273563dbddaac922"
+  integrity sha512-smK0h2MlroXJQCY8yR73bUKuIU3WRnB3vPzbIDnCQKZHcqIZ5A8Sl/qz6LQX9cWeAlvuyDYnFDyd+UgSqLOYqg==
   dependencies:
     "@initia/initia.proto" "^0.2.0"
     "@initia/opinit.proto" "^0.0.8"