hel 1 년 전
부모
커밋
369814c10a
7개의 변경된 파일144개의 추가작업 그리고 71개의 파일을 삭제
  1. 26 0
      src/BaseClient.ts
  2. 15 0
      src/InitiaClient.ts
  3. 53 0
      src/InitiaTask.ts
  4. 44 0
      src/JennieModule.ts
  5. 0 69
      src/initiaClient.ts
  6. 4 0
      src/singleModuleAddress.ts
  7. 2 2
      src/swapTester.ts

+ 26 - 0
src/BaseClient.ts

@@ -0,0 +1,26 @@
+import { LCDClient, MnemonicKey, Msg, Wallet } from '@initia/initia.js'
+
+export abstract class BaseClient {
+  key: MnemonicKey
+  lcd: LCDClient
+  wallet: Wallet
+  constructor(mnemonic: string) {
+    this.key = new MnemonicKey({
+      mnemonic: mnemonic,
+    })
+
+    this.lcd = new LCDClient('https://api-initia-testnet.whispernode.com/', {
+      chainId: 'initiation-1',
+    })
+
+    this.wallet = new Wallet(this.lcd, this.key)
+  }
+
+  async broadcast(msg: Msg) {
+    const signed = await this.wallet.createAndSignTx({
+      msgs: [msg],
+    })
+    const broadcast = await this.lcd.tx.broadcast(signed)
+    console.log(broadcast)
+  }
+}

+ 15 - 0
src/InitiaClient.ts

@@ -0,0 +1,15 @@
+import { InitiaTask } from './InitiaTask'
+
+export class InitiaClient extends InitiaTask {
+  constructor(mnemonic: string) {
+    super(mnemonic)
+  }
+
+  async checkBalance() {
+    const balances = await this.lcd.bank.balance(
+      'init14l3c2vxrdvu6y0sqykppey930s4kufsvt97aeu',
+    )
+    console.log(balances)
+    //todo filter balance
+  }
+}

+ 53 - 0
src/InitiaTask.ts

@@ -0,0 +1,53 @@
+import { JennieModule } from './JennieModule'
+import { MsgDelegate, MsgExecute } from '@initia/initia.js'
+import { validatorArray } from './validatorArray'
+
+export abstract class InitiaTask extends JennieModule {
+  constructor(mnemonic: string) {
+    super(mnemonic)
+  }
+  async swapScript() {
+    const msg = new MsgExecute(
+      this.key.accAddress,
+      '0x1',
+      'dex',
+      'swap_script',
+      [],
+      [
+        'sTSuZ4bxDvdClOYn0lGbY7fHQqZzX5hoKSn+qahHRNI=',
+        'jkczvavPfUr8PRTw3UbJv1L7D86eS5lsk54ZW4vIkdk=',
+        'QEIPAAAAAAA=',
+        'AdWGAQAAAAAA',
+      ],
+    )
+    await this.broadcast(msg)
+  }
+  async stakeSingle() {
+    const msg = new MsgExecute(
+      this.key.accAddress,
+      '0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a',
+      'dex_utils',
+      'single_asset_provide_stake',
+      [],
+      [
+        'sTSuZ4bxDvdClOYn0lGbY7fHQqZzX5hoKSn+qahHRNI=',
+        'rM6zskU5Kv4INGt5TPXE/4Xn6ajIL8r1ESrp1kulfMs=',
+        '64YBAAAAAAA=',
+        'AeJwBwAAAAAA',
+        'MmluaXR2YWxvcGVyMXEyYWw1OWd5bHo0MGptczZlbWV5NnBzOGxldWd1aHM3a3ZxaGFn',
+      ],
+    )
+    await this.broadcast(msg)
+  }
+
+  async stakeInit() {
+    const randomValidator =
+      validatorArray[Math.floor(Math.random() * validatorArray.length)]
+    const msg = new MsgDelegate(
+      'init1w6ftxlsv7y5putq955ymxh2kd0wru7nqshetka', // delegator address
+      randomValidator, // validator's operator addres
+      '100000uinit', // delegate amount
+    )
+    await this.broadcast(msg)
+  }
+}

+ 44 - 0
src/JennieModule.ts

@@ -0,0 +1,44 @@
+import { BaseClient } from './BaseClient'
+import { MsgExecute } from '@initia/initia.js'
+
+export abstract class JennieModule extends BaseClient {
+  constructor(mnemonic: string) {
+    super(mnemonic)
+  }
+  async drawFood() {
+    const msg = new MsgExecute(
+      this.key.accAddress,
+      '0x9065fda28f52bb14ade545411f02e8e07a9cb4ba',
+      'jennie',
+      'draw_food',
+      [],
+      ['AQ=='],
+    )
+
+    await this.broadcast(msg)
+  }
+
+  async feedJennie() {
+    const msg = new MsgExecute(
+      this.key.accAddress,
+      '0x9065fda28f52bb14ade545411f02e8e07a9cb4ba',
+      'jennie',
+      'feed_jennie',
+      [],
+      ['AQ=='],
+    )
+    await this.broadcast(msg)
+  }
+
+  async mintJennie() {
+    const msg = new MsgExecute(
+      this.key.accAddress,
+      '0x9065fda28f52bb14ade545411f02e8e07a9cb4ba',
+      'jennie',
+      'mint_jennie',
+      [],
+      [],
+    )
+    await this.broadcast(msg)
+  }
+}

+ 0 - 69
src/initiaClient.ts

@@ -1,69 +0,0 @@
-import {
-  LCDClient,
-  MnemonicKey,
-  MsgDelegate,
-  MsgExecute,
-  Wallet,
-} from '@initia/initia.js'
-import { validatorArray } from './validatorArray'
-
-export class InitiaClient {
-  key: MnemonicKey
-  lcd: LCDClient
-  wallet: Wallet
-  constructor(mnemonic: string) {
-    this.key = new MnemonicKey({
-      mnemonic: mnemonic,
-    })
-
-    this.lcd = new LCDClient('https://api-initia-testnet.whispernode.com/', {
-      chainId: 'initiation-1',
-    })
-
-    this.wallet = new Wallet(this.lcd, this.key)
-  }
-
-  async checkBalance() {
-    const balances = await this.lcd.bank.balance(
-      'init14l3c2vxrdvu6y0sqykppey930s4kufsvt97aeu',
-    )
-    console.log(balances)
-    //todo filter balance
-  }
-
-  async swapScript() {
-    const msg = new MsgExecute(
-      this.key.accAddress,
-      '0x1',
-      'dex',
-      'swap_script',
-      [],
-      [
-        'sTSuZ4bxDvdClOYn0lGbY7fHQqZzX5hoKSn+qahHRNI=',
-        'jkczvavPfUr8PRTw3UbJv1L7D86eS5lsk54ZW4vIkdk=',
-        'QEIPAAAAAAA=',
-        'AdWGAQAAAAAA',
-      ],
-    )
-    const signed = await this.wallet.createAndSignTx({
-      msgs: [msg],
-    })
-    const broadcast = await this.lcd.tx.broadcast(signed)
-    console.log(broadcast)
-  }
-
-  async stakeInit() {
-    const randomValidator =
-      validatorArray[Math.floor(Math.random() * validatorArray.length)]
-    const msg = new MsgDelegate(
-      'init1w6ftxlsv7y5putq955ymxh2kd0wru7nqshetka', // delegator address
-      randomValidator, // validator's operator addres
-      '100000uinit', // delegate amount
-    )
-    const signed = await this.wallet.createAndSignTx({
-      msgs: [msg],
-    })
-    const broadcast = await this.lcd.tx.broadcast(signed)
-    console.log(broadcast)
-  }
-}

+ 4 - 0
src/singleModuleAddress.ts

@@ -0,0 +1,4 @@
+export const singleModuleAddress = {
+  TIA: '0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a',
+}
+//todo 添加

+ 2 - 2
src/swapTester.ts

@@ -1,5 +1,5 @@
 import { LCDClient, MnemonicKey, MsgExecute, Wallet } from '@initia/initia.js'
-import { InitiaClient } from './initiaClient'
+import { InitiaClient } from './InitiaClient'
 
 const key = new MnemonicKey({
   mnemonic:
@@ -31,6 +31,6 @@ const msg = new MsgExecute(
 
 async function main() {
   const client = new InitiaClient(key.mnemonic)
-  await client.stakeInit()
+  await client.feedJennie()
 }
 main()