-
Notifications
You must be signed in to change notification settings - Fork 39
/
genesis.ts
145 lines (117 loc) · 4.48 KB
/
genesis.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
/* eslint-disable */
import { Deposit, Vote, Proposal, DepositParams, VotingParams, TallyParams } from "./gov";
import { Long, DeepPartial, Exact } from "../../../helpers";
import * as _m0 from "protobufjs/minimal";
export const protobufPackage = "cosmos.gov.v1beta1";
/** GenesisState defines the gov module's genesis state. */
export interface GenesisState {
/** starting_proposal_id is the ID of the starting proposal. */
startingProposalId: Long;
/** deposits defines all the deposits present at genesis. */
deposits: Deposit[];
/** votes defines all the votes present at genesis. */
votes: Vote[];
/** proposals defines all the proposals present at genesis. */
proposals: Proposal[];
/** params defines all the paramaters of related to deposit. */
depositParams?: DepositParams;
/** params defines all the paramaters of related to voting. */
votingParams?: VotingParams;
/** params defines all the paramaters of related to tally. */
tallyParams?: TallyParams;
}
function createBaseGenesisState(): GenesisState {
return {
startingProposalId: Long.UZERO,
deposits: [],
votes: [],
proposals: [],
depositParams: undefined,
votingParams: undefined,
tallyParams: undefined,
};
}
export const GenesisState = {
encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (!message.startingProposalId.isZero()) {
writer.uint32(8).uint64(message.startingProposalId);
}
for (const v of message.deposits) {
Deposit.encode(v!, writer.uint32(18).fork()).ldelim();
}
for (const v of message.votes) {
Vote.encode(v!, writer.uint32(26).fork()).ldelim();
}
for (const v of message.proposals) {
Proposal.encode(v!, writer.uint32(34).fork()).ldelim();
}
if (message.depositParams !== undefined) {
DepositParams.encode(message.depositParams, writer.uint32(42).fork()).ldelim();
}
if (message.votingParams !== undefined) {
VotingParams.encode(message.votingParams, writer.uint32(50).fork()).ldelim();
}
if (message.tallyParams !== undefined) {
TallyParams.encode(message.tallyParams, writer.uint32(58).fork()).ldelim();
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseGenesisState();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.startingProposalId = reader.uint64() as Long;
break;
case 2:
message.deposits.push(Deposit.decode(reader, reader.uint32()));
break;
case 3:
message.votes.push(Vote.decode(reader, reader.uint32()));
break;
case 4:
message.proposals.push(Proposal.decode(reader, reader.uint32()));
break;
case 5:
message.depositParams = DepositParams.decode(reader, reader.uint32());
break;
case 6:
message.votingParams = VotingParams.decode(reader, reader.uint32());
break;
case 7:
message.tallyParams = TallyParams.decode(reader, reader.uint32());
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial<I extends Exact<DeepPartial<GenesisState>, I>>(object: I): GenesisState {
const message = createBaseGenesisState();
message.startingProposalId =
object.startingProposalId !== undefined && object.startingProposalId !== null
? Long.fromValue(object.startingProposalId)
: Long.UZERO;
message.deposits = object.deposits?.map((e) => Deposit.fromPartial(e)) || [];
message.votes = object.votes?.map((e) => Vote.fromPartial(e)) || [];
message.proposals = object.proposals?.map((e) => Proposal.fromPartial(e)) || [];
message.depositParams =
object.depositParams !== undefined && object.depositParams !== null
? DepositParams.fromPartial(object.depositParams)
: undefined;
message.votingParams =
object.votingParams !== undefined && object.votingParams !== null
? VotingParams.fromPartial(object.votingParams)
: undefined;
message.tallyParams =
object.tallyParams !== undefined && object.tallyParams !== null
? TallyParams.fromPartial(object.tallyParams)
: undefined;
return message;
},
};