-
Notifications
You must be signed in to change notification settings - Fork 22
/
MsgCreateAlliance.ts
179 lines (165 loc) 路 4.63 KB
/
MsgCreateAlliance.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import { JSONSerializable } from '../../../../util/json';
import { Any } from '@terra-money/legacy.proto/google/protobuf/any';
import { RewardWeightRange } from '@terra-money/terra.proto/alliance/alliance';
import { MsgCreateAlliance as MsgCreateAlliance_pb } from '@terra-money/terra.proto/alliance/alliance/tx';
import { Duration } from '@terra-money/terra.proto/google/protobuf/duration';
/**
* MsgCreateAlliance is gov content type to create a new alliance
*/
export class MsgCreateAlliance extends JSONSerializable<
MsgCreateAlliance.Amino,
MsgCreateAlliance.Data,
MsgCreateAlliance.Proto
> {
/**
* @description Create a new alliance using the gov module
* @param authority of the proposal
* @param denom of the asset. It could either be a native token or an IBC token
* @param rewardWeight specifies the ratio of rewards that will be given to each alliance asset it does not need to sum to 1. rate = weight / total_weight Native asset is always assumed to have a weight of 1.
* @param takeRate positive take rate is used for liquid staking derivatives. It defines an annualized reward rate that will be redirected to the distribution rewards pool
* @param rewardChangeRate how much the reward weight will change every rewardChangeInterval
* @param rewardChangeInterval how often the reward weight will change
* @param rewardWeightRange set a bound of weight range to limit how much reward weights can scale.
*/
constructor(
public authority: string,
public denom: string,
public rewardWeight: string,
public takeRate: string,
public rewardChangeRate: string,
public rewardChangeInterval?: Duration,
public rewardWeightRange?: RewardWeightRange
) {
super();
}
public static fromAmino(
data: MsgCreateAlliance.Amino,
_?: boolean
): MsgCreateAlliance {
_;
data;
throw new Error('not implemented');
}
public toAmino(_?: boolean): MsgCreateAlliance.Amino {
_;
throw new Error('not implemented');
}
public static fromData(
data: MsgCreateAlliance.Data,
_?: boolean
): MsgCreateAlliance {
_;
const {
authority,
denom,
rewardWeight,
takeRate,
rewardChangeRate,
rewardChangeInterval,
rewardWeightRange,
} = data;
return new MsgCreateAlliance(
authority,
denom,
rewardWeight,
takeRate,
rewardChangeRate,
rewardChangeInterval,
rewardWeightRange
);
}
public toData(_?: boolean): MsgCreateAlliance.Data {
_;
const {
authority,
denom,
rewardWeight,
takeRate,
rewardChangeRate,
rewardChangeInterval,
rewardWeightRange,
} = this;
return {
'@type': '/alliance.alliance.MsgCreateAlliance',
authority,
denom,
rewardWeight,
takeRate,
rewardChangeRate,
rewardChangeInterval,
rewardWeightRange,
};
}
public static fromProto(
proto: MsgCreateAlliance.Proto,
_?: boolean
): MsgCreateAlliance {
_;
return new MsgCreateAlliance(
proto.authority,
proto.denom,
proto.rewardWeight,
proto.takeRate,
proto.rewardChangeRate,
proto.rewardChangeInterval,
proto.rewardWeightRange
);
}
public toProto(_?: boolean): MsgCreateAlliance.Proto {
_;
const {
authority,
denom,
rewardWeight,
takeRate,
rewardChangeRate,
rewardChangeInterval,
rewardWeightRange,
} = this;
return MsgCreateAlliance_pb.fromPartial({
authority,
denom,
rewardWeight,
takeRate,
rewardChangeRate,
rewardChangeInterval,
rewardWeightRange,
});
}
public packAny(_?: boolean): Any {
_;
return Any.fromPartial({
typeUrl: '/alliance.alliance.MsgCreateAlliance',
value: MsgCreateAlliance_pb.encode(this.toProto()).finish(),
});
}
public static unpackAny(msgAny: Any, _?: boolean): MsgCreateAlliance {
_;
return MsgCreateAlliance.fromProto(
MsgCreateAlliance_pb.decode(msgAny.value)
);
}
}
export namespace MsgCreateAlliance {
export interface Amino {
type: 'alliance/MsgCreateAlliance';
authority: string;
denom: string;
rewardWeight: string;
takeRate: string;
rewardChangeRate: string;
rewardChangeInterval?: Duration;
rewardWeightRange?: RewardWeightRange;
}
export interface Data {
'@type': '/alliance.alliance.MsgCreateAlliance';
authority: string;
denom: string;
rewardWeight: string;
takeRate: string;
rewardChangeRate: string;
rewardChangeInterval?: Duration;
rewardWeightRange?: RewardWeightRange;
}
export type Proto = MsgCreateAlliance_pb;
}