import { Amino } from "@chainapsis/ts-amino" ; const { Field , DefineStruct } = Amino ; import { Msg } from "../../core/tx" ; import { AccAddress , ValAddress } from "../../common/address" ; import { Coin } from "../../common/coin" ; import { Int } from "../../common/int" ; import { Dec } from "../../common/decimal" ; import { PubKey } from "../../crypto" ; @ DefineStruct ( ) export class Description { @ Field . String ( 0 , { jsonName : "moniker" } ) public moniker : string ; @ Field . String ( 1 , { jsonName : "identity" } ) public identity : string ; @ Field . String ( 2 , { jsonName : "website" } ) public website : string ; @ Field . String ( 3 , { jsonName : "details" } ) public details : string ; constructor ( moniker , identity , website , details ) { this . moniker = moniker ; this . identity = identity ; this . website = website ; this . details = details ; } } @ DefineStruct ( ) export class CommissionMsg { @ Field . Defined ( 0 , { jsonName : "rate" } ) public rate : Dec ; @ Field . Defined ( 1 , { jsonName : "max_rate" } ) public maxRate : Dec ; @ Field . Defined ( 2 , { jsonName : "max_change_rate" } ) public maxChangeRate : Dec ; constructor ( rate , maxRate , maxChangeRate ) { this . rate = rate ; this . maxRate = maxRate ; this . maxChangeRate = maxChangeRate ; } } @ DefineStruct ( ) export class MsgCreateValidator extends Msg { @ Field . Defined ( 0 , { jsonName : "description" } ) public description : Description ; @ Field . Defined ( 1 , { jsonName : "commission" } ) public commission : CommissionMsg ; @ Field . Defined ( 2 , { jsonName : "min_self_delegation" } ) public minSelfDelegation : Int ; @ Field . Defined ( 3 , { jsonName : "delegator_address" } ) public delegatorAddress : AccAddress ; @ Field . Defined ( 4 , { jsonName : "validator_address" } ) public validatorAddress : ValAddress ; @ Field . Interface ( 5 , { jsonName : "pubkey" } ) public pubKey : PubKey ; @ Field . Defined ( 6 , { jsonName : "value" } ) public value : Coin ; constructor ( description , commission , minSelfDelegation , delegatorAddress , validatorAddress , pubKey , value ) { super ( ) ; this . description = description ; this . commission = commission ; this . minSelfDelegation = minSelfDelegation ; this . delegatorAddress = delegatorAddress ; this . validatorAddress = validatorAddress ; this . pubKey = pubKey ; this . value = value ; } public validateBasic ( ) { } public getSigners ( ) { const addr = [ this . delegatorAddress ] ; if ( this . delegatorAddress . toBytes ( ) . toString ( ) !== this . validatorAddress . toBytes ( ) . toString ( ) ) { addr . push ( new AccAddress ( this . validatorAddress . toBytes ( ) , this . delegatorAddress . bech32Prefix ) ) ; } return addr ; } } @ DefineStruct ( ) export class MsgEditValidator extends Msg { @ Field . Defined ( 0 , { jsonName : "description" } ) public description : Description ; @ Field . Defined ( 1 , { jsonName : "address" } ) public validatorAddress : ValAddress ; @ Field . Defined ( 2 , { jsonName : "commission_rate" } ) public commisionRate : Dec ; @ Field . Defined ( 3 , { jsonName : "min_self_delegation" } ) public minSelfDelegation : Int ; public bech32PrefixAccAddr : string ; constructor ( description , validatorAddress , commisionRate , minSelfDelegation , bech32PrefixAccAddr ) { super ( ) ; this . description = description ; this . validatorAddress = validatorAddress ; this . commisionRate = commisionRate ; this . minSelfDelegation = minSelfDelegation ; this . bech32PrefixAccAddr = bech32PrefixAccAddr ; } public validateBasic ( ) { } public getSigners ( ) { return [ new AccAddress ( this . validatorAddress . toBytes ( ) , this . bech32PrefixAccAddr ) ] ; } } @ DefineStruct ( ) export class MsgDelegate extends Msg { @ Field . Defined ( 0 , { jsonName : "delegator_address" } ) public delegatorAddress : AccAddress ; @ Field . Defined ( 1 , { jsonName : "validator_address" } ) public validatorAddress : ValAddress ; @ Field . Defined ( 2 , { jsonName : "amount" } ) public amount : Coin ; constructor ( delegatorAddress , validatorAddress , amount ) { super ( ) ; this . delegatorAddress = delegatorAddress ; this . validatorAddress = validatorAddress ; this . amount = amount ; } public validateBasic ( ) { } public getSigners ( ) { return [ this . delegatorAddress ] ; } } @ DefineStruct ( ) export class MsgBeginRedelegate extends Msg { @ Field . Defined ( 0 , { jsonName : "delegator_address" } ) public delegatorAddress : AccAddress ; @ Field . Defined ( 1 , { jsonName : "validator_src_address" } ) public validatorSrcAddress : ValAddress ; @ Field . Defined ( 2 , { jsonName : "validator_dst_address" } ) public validatorDstAddress : ValAddress ; @ Field . Defined ( 3 , { jsonName : "amount" } ) public amount : Coin ; constructor ( delegatorAddress , validatorSrcAddress , validatorDstAddress , amount ) { super ( ) ; this . delegatorAddress = delegatorAddress ; this . validatorSrcAddress = validatorSrcAddress ; this . validatorDstAddress = validatorDstAddress ; this . amount = amount ; } public validateBasic ( ) { } public getSigners ( ) { return [ this . delegatorAddress ] ; } } @ DefineStruct ( ) export class MsgUndelegate extends Msg { @ Field . Defined ( 0 , { jsonName : "delegator_address" } ) public delegatorAddress : AccAddress ; @ Field . Defined ( 1 , { jsonName : "validator_address" } ) public validatorAddress : ValAddress ; @ Field . Defined ( 2 , { jsonName : "amount" } ) public amount : Coin ; constructor ( delegatorAddress , validatorAddress , amount ) { super ( ) ; this . delegatorAddress = delegatorAddress ; this . validatorAddress = validatorAddress ; this . amount = amount ; } public validateBasic ( ) { } public getSigners ( ) { return [ this . delegatorAddress ] ; } }