-
Notifications
You must be signed in to change notification settings - Fork 22
/
MsgFundCommunityPool.ts
123 lines (111 loc) 路 3.24 KB
/
MsgFundCommunityPool.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
import { JSONSerializable } from '../../../util/json';
import { AccAddress } from '../../bech32';
import { Coins } from '../../Coins';
import { Any } from '@terra-money/terra.proto/google/protobuf/any';
// there's no difference between two protos
// import { MsgFundCommunityPool as MsgFundCommunityPool_legacy_pb } from '@terra-money/legacy.proto/cosmos/distribution/v1beta1/tx';
import { MsgFundCommunityPool as MsgFundCommunityPool_pb } from '@terra-money/terra.proto/cosmos/distribution/v1beta1/tx';
export class MsgFundCommunityPool extends JSONSerializable<
MsgFundCommunityPool.Amino,
MsgFundCommunityPool.Data,
MsgFundCommunityPool.Proto
> {
public amount: Coins;
/**
* @param depositor depositor's account address
* @param amount coins to fund the community pool
*/
constructor(public depositor: AccAddress, amount: Coins.Input) {
super();
this.amount = new Coins(amount);
}
public static fromAmino(
data: MsgFundCommunityPool.Amino,
_?: boolean
): MsgFundCommunityPool {
const {
value: { depositor, amount },
} = data;
_;
return new MsgFundCommunityPool(depositor, Coins.fromAmino(amount));
}
public toAmino(isClassic?: boolean): MsgFundCommunityPool.Amino {
const { depositor, amount } = this;
return {
type: isClassic
? 'distribution/MsgFundCommunityPool'
: 'cosmos-sdk/MsgFundCommunityPool',
value: {
depositor,
amount: amount.toAmino(),
},
};
}
public static fromData(
proto: MsgFundCommunityPool.Data,
_?: boolean
): MsgFundCommunityPool {
_;
const { depositor, amount } = proto;
return new MsgFundCommunityPool(depositor, Coins.fromData(amount));
}
public toData(_?: boolean): MsgFundCommunityPool.Data {
_;
const { depositor, amount } = this;
return {
'@type': '/cosmos.distribution.v1beta1.MsgFundCommunityPool',
depositor,
amount: amount.toData(),
};
}
public static fromProto(
proto: MsgFundCommunityPool.Proto,
_?: Boolean
): MsgFundCommunityPool {
_;
return new MsgFundCommunityPool(
proto.depositor,
Coins.fromProto(proto.amount)
);
}
public toProto(_?: boolean): MsgFundCommunityPool.Proto {
_;
const { depositor, amount } = this;
return MsgFundCommunityPool_pb.fromPartial({
amount: amount.toProto(),
depositor,
});
}
public packAny(isClassic?: boolean): Any {
return Any.fromPartial({
typeUrl: '/cosmos.distribution.v1beta1.MsgFundCommunityPool',
value: MsgFundCommunityPool_pb.encode(this.toProto(isClassic)).finish(),
});
}
public static unpackAny(
msgAny: Any,
isClassic?: boolean
): MsgFundCommunityPool {
return MsgFundCommunityPool.fromProto(
MsgFundCommunityPool_pb.decode(msgAny.value),
isClassic
);
}
}
export namespace MsgFundCommunityPool {
export interface Amino {
type:
| 'distribution/MsgFundCommunityPool'
| 'cosmos-sdk/MsgFundCommunityPool';
value: {
depositor: AccAddress;
amount: Coins.Amino;
};
}
export interface Data {
'@type': '/cosmos.distribution.v1beta1.MsgFundCommunityPool';
depositor: AccAddress;
amount: Coins.Data;
}
export type Proto = MsgFundCommunityPool_pb;
}