hel 1 жил өмнө
parent
commit
9e554a3fb7

+ 3 - 3
src/BaseClient.ts

@@ -4,7 +4,7 @@ export abstract class BaseClient {
   key: MnemonicKey
   lcd: LCDClient
   wallet: Wallet
-  constructor(mnemonic: string) {
+  protected constructor(mnemonic: string) {
     this.key = new MnemonicKey({
       mnemonic: mnemonic,
     })
@@ -16,9 +16,9 @@ export abstract class BaseClient {
     this.wallet = new Wallet(this.lcd, this.key)
   }
 
-  async broadcast(msg: Msg) {
+  async broadcast(msg: Msg | Msg[]) {
     const signed = await this.wallet.createAndSignTx({
-      msgs: [msg],
+      msgs: Array.isArray(msg) ? msg : [msg],
     })
     const broadcast = await this.lcd.tx.broadcast(signed)
     console.log(broadcast)

+ 31 - 5
src/InitiaTask.ts

@@ -3,7 +3,7 @@ import { MsgDelegate, MsgExecute } from '@initia/initia.js'
 import { validatorArray } from './validatorArray'
 
 export abstract class InitiaTask extends JennieModule {
-  constructor(mnemonic: string) {
+  protected constructor(mnemonic: string) {
     super(mnemonic)
   }
   async swapScript() {
@@ -14,14 +14,40 @@ export abstract class InitiaTask extends JennieModule {
       'swap_script',
       [],
       [
-        'sTSuZ4bxDvdClOYn0lGbY7fHQqZzX5hoKSn+qahHRNI=',
+        '2/BsSK85hOxtmuipqn27C7HnhKqbjEpWga9mDPhVjX0=',
         'jkczvavPfUr8PRTw3UbJv1L7D86eS5lsk54ZW4vIkdk=',
         'QEIPAAAAAAA=',
-        'AdWGAQAAAAAA',
+        'ASCLDAAAAAAA',
       ],
     )
     await this.broadcast(msg)
   }
+
+  async nameRegister() {
+    const msgs = []
+    msgs.push(
+      new MsgExecute(
+        this.key.accAddress,
+        '0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a',
+        'usernames',
+        'register_domain',
+        [],
+        ['B2RhbW5icm8=', '4IfhAQAAAAA='],
+      ),
+    )
+    msgs.push(
+      new MsgExecute(
+        this.key.accAddress,
+        '0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a',
+        'usernames',
+        'set_name',
+        [],
+        ['B2RhbW5icm8='],
+      ),
+    )
+    await this.broadcast(msgs)
+  }
+
   async stakeSingle() {
     const msg = new MsgExecute(
       this.key.accAddress,
@@ -32,9 +58,9 @@ export abstract class InitiaTask extends JennieModule {
       [
         'sTSuZ4bxDvdClOYn0lGbY7fHQqZzX5hoKSn+qahHRNI=',
         'rM6zskU5Kv4INGt5TPXE/4Xn6ajIL8r1ESrp1kulfMs=',
-        '64YBAAAAAAA=',
+        '64YBAAAAAAA=', //amount
         'AeJwBwAAAAAA',
-        'MmluaXR2YWxvcGVyMXEyYWw1OWd5bHo0MGptczZlbWV5NnBzOGxldWd1aHM3a3ZxaGFn',
+        'MmluaXR2YWxvcGVyMXEyYWw1OWd5bHo0MGptczZlbWV5NnBzOGxldWd1aHM3a3ZxaGFn', //validator
       ],
     )
     await this.broadcast(msg)

+ 1 - 1
src/JennieModule.ts

@@ -2,7 +2,7 @@ import { BaseClient } from './BaseClient'
 import { MsgExecute } from '@initia/initia.js'
 
 export abstract class JennieModule extends BaseClient {
-  constructor(mnemonic: string) {
+  protected constructor(mnemonic: string) {
     super(mnemonic)
   }
   async drawFood() {

+ 4 - 1
src/main.ts

@@ -14,7 +14,10 @@ export enum Delays {
  * @param {number=} [delay=Delays.Medium] - A number of milliseconds to delay resolution of the Promise.
  * @returns {Promise<string>}
  */
-function delayedHello(name: string, delay: number = Delays.Medium): Promise<string> {
+function delayedHello(
+  name: string,
+  delay: number = Delays.Medium,
+): Promise<string> {
   return new Promise((resolve: (value?: string) => void) =>
     setTimeout(() => resolve(`Hello, ${name}`), delay),
   )

+ 1 - 1
src/swapTester.ts

@@ -31,6 +31,6 @@ const msg = new MsgExecute(
 
 async function main() {
   const client = new InitiaClient(key.mnemonic)
-  await client.feedJennie()
+  await client.swapScript()
 }
 main()