-
Notifications
You must be signed in to change notification settings - Fork 22
/
MsgSetWithdrawAddress.ts
128 lines (116 loc) 路 3.58 KB
/
MsgSetWithdrawAddress.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import { JSONSerializable } from '../../../util/json';
import { AccAddress } from '../../bech32';
import { Any } from '@terra-money/terra.proto/google/protobuf/any';
// there's no difference between two protos
// import { MsgSetWithdrawAddress as MsgSetWithdrawAddress_legacy_pb } from '@terra-money/legacy.proto/cosmos/distribution/v1beta1/tx';
import { MsgSetWithdrawAddress as MsgSetWithdrawAddress_pb } from '@terra-money/terra.proto/cosmos/distribution/v1beta1/tx';
/**
* A validator can withdraw their outstanding commission rewards accrued from all
* delegations (not including its self-delegation) into their associated account's
* withdraw address.
*/
export class MsgSetWithdrawAddress extends JSONSerializable<
MsgSetWithdrawAddress.Amino,
MsgSetWithdrawAddress.Data,
MsgSetWithdrawAddress.Proto
> {
/**
* @param delegator_address delegator's account address
* @param withdraw_address desired new withdraw address
*/
constructor(
public delegator_address: AccAddress,
public withdraw_address: AccAddress
) {
super();
}
public static fromAmino(
data: MsgSetWithdrawAddress.Amino,
_?: boolean
): MsgSetWithdrawAddress {
_;
const {
value: { delegator_address, withdraw_address },
} = data;
return new MsgSetWithdrawAddress(delegator_address, withdraw_address);
}
public toAmino(isClassic?: boolean): MsgSetWithdrawAddress.Amino {
const { delegator_address, withdraw_address } = this;
return {
type: isClassic
? 'distribution/MsgModifyWithdrawAddress'
: 'cosmos-sdk/MsgModifyWithdrawAddress',
value: {
delegator_address,
withdraw_address,
},
};
}
public static fromData(
data: MsgSetWithdrawAddress.Data,
_?: boolean
): MsgSetWithdrawAddress {
_;
const { delegator_address, withdraw_address } = data;
return new MsgSetWithdrawAddress(delegator_address, withdraw_address);
}
public toData(_?: boolean): MsgSetWithdrawAddress.Data {
_;
const { delegator_address, withdraw_address } = this;
return {
'@type': '/cosmos.distribution.v1beta1.MsgSetWithdrawAddress',
delegator_address,
withdraw_address,
};
}
public static fromProto(
proto: MsgSetWithdrawAddress.Proto,
_?: boolean
): MsgSetWithdrawAddress {
_;
return new MsgSetWithdrawAddress(
proto.delegatorAddress,
proto.withdrawAddress
);
}
public toProto(_?: boolean): MsgSetWithdrawAddress.Proto {
_;
const { delegator_address, withdraw_address } = this;
return MsgSetWithdrawAddress_pb.fromPartial({
delegatorAddress: delegator_address,
withdrawAddress: withdraw_address,
});
}
public packAny(isClassic?: boolean): Any {
return Any.fromPartial({
typeUrl: '/cosmos.distribution.v1beta1.MsgSetWithdrawAddress',
value: MsgSetWithdrawAddress_pb.encode(this.toProto(isClassic)).finish(),
});
}
public static unpackAny(
msgAny: Any,
isClassic?: boolean
): MsgSetWithdrawAddress {
return MsgSetWithdrawAddress.fromProto(
MsgSetWithdrawAddress_pb.decode(msgAny.value),
isClassic
);
}
}
export namespace MsgSetWithdrawAddress {
export interface Amino {
type:
| 'distribution/MsgModifyWithdrawAddress'
| 'cosmos-sdk/MsgModifyWithdrawAddress';
value: {
delegator_address: AccAddress;
withdraw_address: AccAddress;
};
}
export interface Data {
'@type': '/cosmos.distribution.v1beta1.MsgSetWithdrawAddress';
delegator_address: AccAddress;
withdraw_address: AccAddress;
}
export type Proto = MsgSetWithdrawAddress_pb;
}