|
@@ -5,8 +5,9 @@ import {
|
|
|
MsgExecute,
|
|
|
Wallet,
|
|
|
} from '@initia/initia.js'
|
|
|
+import { validatorArray } from './validatorArray'
|
|
|
|
|
|
-class InitiaClient {
|
|
|
+export class InitiaClient {
|
|
|
key: MnemonicKey
|
|
|
lcd: LCDClient
|
|
|
wallet: Wallet
|
|
@@ -52,10 +53,17 @@ class InitiaClient {
|
|
|
}
|
|
|
|
|
|
async stakeInit() {
|
|
|
+ const randomValidator =
|
|
|
+ validatorArray[Math.floor(Math.random() * validatorArray.length)]
|
|
|
const msg = new MsgDelegate(
|
|
|
- 'init1kdwzpz3wzvpdj90gtga4fw5zm9tk4cyrgnjauu', // delegator address
|
|
|
- 'init18sj3x80fdjc6gzfvwl7lf8sxcvuvqjpvcmp6np', // validator's operator addres
|
|
|
+ '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)
|
|
|
}
|
|
|
}
|