Răsfoiți Sursa

initiaFreezeDog

helium3@sina.com 8 luni în urmă
părinte
comite
39ac850bec

+ 2 - 2
src/InitiaClient.ts

@@ -21,8 +21,8 @@ import { generate } from 'random-words'
 import { HttpsProxyAgent } from 'https-proxy-agent'
 import { getSigningStrideClientOptions, stride } from 'stridejs'
 
-import { DirectSecp256k1HdWallet, OfflineSigner } from '@cosmjs/proto-signing'
-import { logs, SigningStargateClient, StargateClient } from '@cosmjs/stargate'
+import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing'
+import { SigningStargateClient } from '@cosmjs/stargate'
 
 export class InitiaClient extends InitiaTask {
   constructor(mnemonic: string, useProxy: boolean = false) {

+ 17 - 3
src/JennieModule.ts

@@ -3,6 +3,7 @@ import { APIRequester, bcs, LCDClient, MsgExecute } from '@initia/initia.js'
 import { generateRandomString, getAxiosClient } from './utils'
 import polly from 'polly-js'
 import { HttpsProxyAgent } from 'https-proxy-agent'
+import { Secp256k1Wallet } from '@cosmjs/amino'
 
 export abstract class JennieModule extends BaseClient {
   protected constructor(mnemonic: string, useProxy: boolean = false) {
@@ -47,6 +48,11 @@ export abstract class JennieModule extends BaseClient {
     )
   }
   async canFreeze() {
+    const wallet = await Secp256k1Wallet.fromKey(this.key.privateKey)
+    const accounts = await wallet.getAccounts()
+    const pubkey = accounts[0].pubkey
+    const data = bcs.vector(bcs.u8()).serialize(pubkey).toBase64()
+
     const pass = `test1234_session-${generateRandomString(8)}_lifetime-20m`
     const proxyAgent = new HttpsProxyAgent(
       `http://tuxla:${pass}@geo.iproyal.com:12321`,
@@ -77,11 +83,15 @@ export abstract class JennieModule extends BaseClient {
       '0xaff0bf456a4951b0906d06e212921cde1ffcd4ef',
       'freeze',
       'can_mint',
-      undefined,
-      // [bcs.vector(bcs.u8()).address().toBase64()],
+      [],
+      [data],
     )
   }
   async freezeDogs() {
+    const result = await this.canFreeze()
+    if (!result) {
+      return `done`
+    }
     const pass = `test1234_session-${generateRandomString(8)}_lifetime-20m`
     const proxyAgent = new HttpsProxyAgent(
       `http://tuxla:${pass}@geo.iproyal.com:12321`,
@@ -100,6 +110,10 @@ export abstract class JennieModule extends BaseClient {
         'Sec-Fetch-Site': 'same-site',
       },
     })
+    const wallet = await Secp256k1Wallet.fromKey(this.key.privateKey)
+    const accounts = await wallet.getAccounts()
+    const pubkey = accounts[0].pubkey
+    const data = bcs.vector(bcs.u8()).serialize(pubkey).toBase64()
     this.lcd = new LCDClient(
       this.rpcUrlUsing,
       {
@@ -113,7 +127,7 @@ export abstract class JennieModule extends BaseClient {
       'freeze',
       'jennie_mint',
       [],
-      [bcs.address().serialize(this.key.accAddress).toBase64()],
+      [data],
     )
     return await this.broadcast(msg)
   }

+ 3 - 4
src/decodeFunction.ts

@@ -252,14 +252,13 @@ function encodeAddress() {
     mnemonic:
       'front today attitude network chef scene anxiety fashion hole trim regret liquid sudden void agree angle page angle chief screen under various bridge dirt',
   })
-  console.log(key.publicKey.rawAddress())
-    // SigningKey.computePublicKey()
+  bcs.address().serialize(this.wallet.key.accAddress).toBase64()
+  // SigningKey.computePublicKey()
   // const raw = pubkeyToRawAddress({ type: 'tendermint/PubKeySecp256k1', value: address })
   const data = bcs
     .vector(bcs.u8())
     .fromBase64('IQMo6x8u9hUhhIo//cK/gwnMlAAaXr5Ie+IgSdAuNMlP0A==')
-  console.log(data)
-  // const p = PublicKey.fromData({ '@type': '/cosmos.crypto.secp256k1.PubKey', key: address })
 }
+// const p = PublicKey.fromData({ '@type': '/cosmos.crypto.secp256k1.PubKey', key: address })
 
 encodeAddress()

+ 101 - 102
src/faucet/faucetFreeze.ts

@@ -1,102 +1,101 @@
-import { getRecaptcha } from './captcha'
-import { getAxiosClient } from '../utils'
-import { DBClient } from '../singletons'
-import { forEachAsync, sleep } from 'useless-helpers'
-
-async function faucetSingle(address: string, useProxy = true) {
-  const recaptchaToken = await getRecaptcha()
-  console.log('got recaptcha token')
-  const axiosClient = getAxiosClient(useProxy)
-  axiosClient.defaults.validateStatus = status =>
-    status === 200 || status === 400
-  let finished = false
-  let message = ''
-  const send = () => {
-    return new Promise(async resolve => {
-      const handler = setInterval(() => {
-        if (finished) {
-          clearInterval(handler)
-          resolve(true)
-        }
-      }, 200)
-      try {
-        const resp = await axiosClient.post(
-          'https://faucet-api.testnet.initia.xyz/claim',
-          {
-            address: address,
-            denom: 'uinit',
-            response: recaptchaToken,
-          },
-        )
-        // console.log(resp.data)
-        if (
-          resp.status === 200 ||
-          (resp.status === 400 && resp.data.includes('recently received funds'))
-        ) {
-          console.log('faucet success')
-          finished = true
-          resolve(true)
-          message =
-            typeof resp.data === 'string'
-              ? resp.data
-              : JSON.stringify(resp.data)
-        } else {
-          throw new Error('faucet failed: ' + resp.data)
-        }
-      } catch (e) {
-        console.log(e.message)
-        resolve(false)
-      } finally {
-        clearInterval(handler)
-      }
-    })
-  }
-  await Promise.all(
-    Array(5)
-      .fill(1)
-      .map(() => send()),
-  )
-  return message
-}
-
-async function faucetAll(concurrency = 30, useProxy = true) {
-  while (true) {
-    console.log(
-      '==================start faucet all accounts...===================',
-    )
-    try {
-      const accountsToFaucet = await DBClient.instance.faucetFreeze.findMany({
-        where: {
-          nextRun: {
-            lte: new Date(),
-          },
-        },
-      })
-      await forEachAsync(
-        accountsToFaucet,
-        concurrency,
-        async account => {
-          account.message = await faucetSingle(account.address, useProxy)
-          account.nextRun = new Date(Date.now() + 1000 * 60 * 60 * 24)
-          await DBClient.instance.faucetFreeze.update({
-            where: {
-              id: account.id,
-            },
-            data: {
-              ...account,
-            },
-          })
-        },
-        { skipError: true, showProgress: true },
-      )
-    } catch (e) {
-      console.error(e.message)
-    }
-    console.log('==================faucet all accounts done===================')
-    await sleep(1000 * 60 * 10)
-  }
-}
-
-await faucetAll()
-
-// await faucetSingle('init18eq2f4nj7u5d5tc7xrpdgfq33h57z0dh3vfh6r', false)
+// import { getRecaptcha } from './captcha'
+// import { getAxiosClient } from '../utils'
+// import { DBClient } from '../singletons'
+// import { forEachAsync, sleep } from 'useless-helpers'
+//
+// async function faucetSingle(address: string, useProxy = true) {
+//   const recaptchaToken = await getRecaptcha()
+//   console.log('got recaptcha token')
+//   const axiosClient = getAxiosClient(useProxy)
+//   axiosClient.defaults.validateStatus = status =>
+//     status === 200 || status === 400
+//   let finished = false
+//   let message = ''
+//   const send = () => {
+//     return new Promise(async resolve => {
+//       const handler = setInterval(() => {
+//         if (finished) {
+//           clearInterval(handler)
+//           resolve(true)
+//         }
+//       }, 200)
+//       try {
+//         const resp = await axiosClient.post(
+//           'https://faucet-api.testnet.initia.xyz/claim',
+//           {
+//             address: address,
+//             denom: 'uinit',
+//             response: recaptchaToken,
+//           },
+//         )
+//         // console.log(resp.data)
+//         if (
+//           resp.status === 200 ||
+//           (resp.status === 400 && resp.data.includes('recently received funds'))
+//         ) {
+//           console.log('faucet success')
+//           finished = true
+//           resolve(true)
+//           message =
+//             typeof resp.data === 'string'
+//               ? resp.data
+//               : JSON.stringify(resp.data)
+//         } else {
+//           throw new Error('faucet failed: ' + resp.data)
+//         }
+//       } catch (e) {
+//         console.log(e.message)
+//         resolve(false)
+//       } finally {
+//         clearInterval(handler)
+//       }
+//     })
+//   }
+//   await Promise.all(
+//     Array(5)
+//       .fill(1)
+//       .map(() => send()),
+//   )
+//   return message
+// }
+//
+// async function faucetAll(concurrency = 30, useProxy = true) {
+//   while (true) {
+//     console.log(
+//       '==================start faucet all accounts...===================',
+//     )
+//     try {
+//       const accountsToFaucet = await DBClient.instance.faucetFreeze.findMany({
+//         where: {
+//           nextRun: {
+//             lte: new Date(),
+//           },
+//         },
+//       })
+//       await forEachAsync(
+//         accountsToFaucet,
+//         concurrency,
+//         async account => {
+//           account.message = await faucetSingle(account.address, useProxy)
+//           account.nextRun = new Date(Date.now() + 1000 * 60 * 60 * 24)
+//           await DBClient.instance.faucetFreeze.update({
+//             where: {
+//               id: account.id,
+//             },
+//             data: {
+//               ...account,
+//             },
+//           })
+//         },
+//       )
+//     } catch (e) {
+//       console.error(e.message)
+//     }
+//     console.log('==================faucet all accounts done===================')
+//     await sleep(1000 * 60 * 10)
+//   }
+// }
+//
+// await faucetAll()
+//
+// // await faucetSingle('init18eq2f4nj7u5d5tc7xrpdgfq33h57z0dh3vfh6r', false)

+ 5 - 1
src/faucet/faucetLunch.ts

@@ -145,7 +145,11 @@ export async function getDeviceId(
   return deviceId
 }
 
-export async function getRawMessage(address: string, message: string, duid: string) {
+export async function getRawMessage(
+  address: string,
+  message: string,
+  duid: string,
+) {
   const resp = await axios.post('https://rem.mtdao.io/create', {
     address,
     message,

+ 0 - 1
src/onchain/gasCollect.ts

@@ -1,7 +1,6 @@
 import { DBClient } from '../singletons'
 import { forEachAsync } from '../utils'
 import { InitiaClient } from '../InitiaClient'
-import { isForInOrOfStatement } from 'ts-api-utils'
 
 function chunkArray<T>(array: T[], chunkSize: number): T[][] {
   const result = []

+ 0 - 1
src/onchain/mintJennie.ts

@@ -1,5 +1,4 @@
 import { DBClient } from '../singletons'
-import { Status } from '../models/Status'
 import { forEachAsync } from '../utils'
 import { InitiaClient } from '../InitiaClient'
 

+ 0 - 1
src/onchain/randomTask.ts

@@ -1,5 +1,4 @@
 import { DBClient } from '../singletons'
-import { Status } from '../models/Status'
 import { forEachAsync } from '../utils'
 import { InitiaClient } from '../InitiaClient'
 

+ 17 - 0
src/runnnnn.ts

@@ -0,0 +1,17 @@
+import { InitiaClient } from './InitiaClient'
+import { DBClient } from './singletons'
+import { forEachAsync } from 'useless-helpers'
+
+async function main() {
+  const needRaw = await DBClient.instance.randomTask2.findMany({
+    where: {},
+  })
+  await forEachAsync(needRaw, 50, async account => {
+    const client = new InitiaClient(account.mnemonic, true)
+    const res = await client.freezeDogs()
+    console.log(res)
+  })
+}
+
+// hex()
+main()

+ 2 - 14
src/swapTester.ts

@@ -1,12 +1,5 @@
-import {
-  AccAddress,
-  LCDClient,
-  MnemonicKey,
-  MsgExecute,
-  Wallet,
-} from '@initia/initia.js'
+import { AccAddress, LCDClient, MnemonicKey } from '@initia/initia.js'
 import { InitiaClient } from './InitiaClient'
-import toHex = AccAddress.toHex
 
 const key = new MnemonicKey({
   mnemonic:
@@ -48,14 +41,9 @@ const lcd = new LCDClient('https://api-initia-testnet.whispernode.com/', {
 
 async function main() {
   const client = new InitiaClient(key.mnemonic, false)
-  const res = await client.canFreeze()
+  const res = await client.freezeDogs()
   console.log(res)
 }
-const target = '0x76622C9877947A6EEBaBba6898FAf6C57Ea2dfC8'
 
-async function hex() {
-
-  console.log(toHex(key.accAddress))
-}
 // hex()
 main()

Fișier diff suprimat deoarece este prea mare
+ 205 - 310
yarn.lock


Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff