-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditvalidator.ts
50 lines (44 loc) · 1.38 KB
/
editvalidator.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { Wallet } from '@ethersproject/wallet'
import { createMessageSend, createTxMsgEditValidator } from '@evmos/transactions'
import {
broadcast,
getSender,
LOCALNET_CHAIN,
LOCALNET_FEE,
signTransaction,
signTransactionUsingEIP712,
} from '@hanchon/evmos-ts-wallet'
async function prepareMessage(wallet: Wallet) {
const sender = await getSender(wallet)
const validatorAddress = 'evmosvaloper1can8phtx6t6aq73p3c2ad2l3dwhmewxe0tegst'
const txSimple = createTxMsgEditValidator(
LOCALNET_CHAIN,
sender,
LOCALNET_FEE,
'',
{
moniker: 'a',
identity: 'b',
website: 'c',
securityContact: 'd',
details: 'e',
validatorAddress: validatorAddress,
commissionRate: undefined,
minSelfDelegation: undefined,
},
)
return { sender, txSimple }
}
;(async () => {
const privateMnemonic =
'able fiction rude luggage network scrap between hat found alone cart work update brave true option gaze crush club soft ball soccer raven media'
const wallet = Wallet.fromMnemonic(privateMnemonic)
const msgKeplr = await prepareMessage(wallet)
const resKeplr = await signTransaction(wallet, msgKeplr.txSimple)
const broadcastRes = await broadcast(resKeplr)
if (broadcastRes.tx_response.code === 0) {
console.log('Success sign transaction')
} else {
console.log(`Error payload signature: ${broadcastRes}`)
}
})()