-
Notifications
You must be signed in to change notification settings - Fork 18
/
types.d.ts
360 lines (360 loc) · 12.1 KB
/
types.d.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
import {
Address,
Algorithm,
Amount,
ChainId,
LightTransaction,
PubkeyBundle,
SendTransaction,
SwapAbortTransaction,
SwapClaimTransaction,
SwapOfferTransaction,
TimestampTimeout,
} from "@iov/bcp";
import { As } from "type-tagger";
export interface CashConfiguration {
readonly minimalFee: Amount | null;
}
export interface ValidatorProperties {
readonly power: number;
}
export interface Validator extends ValidatorProperties {
readonly pubkey: PubkeyBundle;
}
/**
* An unordered map from validator pubkey address to remaining properies
*
* The string key is in the form `ed25519_<pubkey_hex>`
*/
export interface Validators {
readonly [index: string]: ValidatorProperties;
}
/** Like Elector from the backend but without the address field */
export interface ElectorProperties {
/** The voting weight of this elector. Max value is 65535 (2^16-1). */
readonly weight: number;
}
export interface Elector extends ElectorProperties {
readonly address: Address;
}
/** An unordered map from elector address to remaining properies */
export interface Electors {
readonly [index: string]: ElectorProperties;
}
export interface Electorate {
readonly id: number;
readonly version: number;
readonly admin: Address;
readonly title: string;
readonly electors: Electors;
/** Sum of all electors' weights */
readonly totalWeight: number;
}
export interface Fraction {
readonly numerator: number;
readonly denominator: number;
}
export interface ElectionRule {
readonly id: number;
readonly version: number;
readonly admin: Address;
/**
* The eligible voters in this rule.
*
* This is an unversioned ID (see `id` field in weave's VersionedIDRef), meaning the
* electorate can change over time without changing this ID. When a proposal with this
* rule is created, the latest version of the electorate will be used.
*/
readonly electorateId: number;
readonly title: string;
/** Voting period in seconds */
readonly votingPeriod: number;
readonly threshold: Fraction;
readonly quorum: Fraction | null;
}
export interface VersionedId {
readonly id: number;
readonly version: number;
}
export declare enum ProposalExecutorResult {
NotRun = 0,
Succeeded = 1,
Failed = 2,
}
export declare enum ProposalResult {
Undefined = 0,
Accepted = 1,
Rejected = 2,
}
export declare enum ProposalStatus {
Submitted = 0,
Closed = 1,
Withdrawn = 2,
}
export declare enum VoteOption {
Yes = 0,
No = 1,
Abstain = 2,
}
export declare enum ActionKind {
CreateTextResolution = "gov_create_text_resolution",
ExecuteProposalBatch = "execute_proposal_batch",
ReleaseEscrow = "escrow_release",
Send = "cash_send",
SetMsgFee = "msgfee_set_msg_fee",
SetValidators = "validators_apply_diff",
UpdateElectionRule = "gov_update_election_rule",
UpdateElectorate = "gov_update_electorate",
}
export interface TallyResult {
readonly totalYes: number;
readonly totalNo: number;
readonly totalAbstain: number;
readonly totalElectorateWeight: number;
}
export interface CreateTextResolutionAction {
readonly kind: ActionKind.CreateTextResolution;
readonly resolution: string;
}
export declare function isCreateTextResolutionAction(
action: ProposalAction,
): action is CreateTextResolutionAction;
export interface ExecuteProposalBatchAction {
readonly kind: ActionKind.ExecuteProposalBatch;
readonly messages: readonly ProposalAction[];
}
export declare function isExecuteProposalBatchAction(
action: ProposalAction,
): action is ExecuteProposalBatchAction;
export interface ReleaseEscrowAction {
readonly kind: ActionKind.ReleaseEscrow;
readonly escrowId: number;
readonly amount: Amount;
}
export declare function isReleaseEscrowAction(action: ProposalAction): action is ReleaseEscrowAction;
export interface SendAction {
readonly kind: ActionKind.Send;
readonly sender: Address;
readonly recipient: Address;
readonly amount: Amount;
readonly memo?: string;
}
export declare function isSendAction(action: ProposalAction): action is SendAction;
export interface SetMsgFeeAction {
readonly kind: ActionKind.SetMsgFee;
readonly msgPath: string;
readonly fee: Amount;
}
export declare function isSetMsgFeeAction(action: ProposalAction): action is SetMsgFeeAction;
export interface SetValidatorsAction {
readonly kind: ActionKind.SetValidators;
readonly validatorUpdates: Validators;
}
export declare function isSetValidatorsAction(action: ProposalAction): action is SetValidatorsAction;
export interface UpdateElectionRuleAction {
readonly kind: ActionKind.UpdateElectionRule;
readonly electionRuleId: number;
readonly threshold?: Fraction;
readonly quorum?: Fraction | null;
readonly votingPeriod: number;
}
export declare function isUpdateElectionRuleAction(
action: ProposalAction,
): action is UpdateElectionRuleAction;
export interface UpdateElectorateAction {
readonly kind: ActionKind.UpdateElectorate;
readonly electorateId: number;
readonly diffElectors: Electors;
}
export declare function isUpdateElectorateAction(action: ProposalAction): action is UpdateElectorateAction;
/** The action to be executed when the proposal is accepted */
export declare type ProposalAction =
| CreateTextResolutionAction
| ExecuteProposalBatchAction
| ReleaseEscrowAction
| SendAction
| SetMsgFeeAction
| SetValidatorsAction
| UpdateElectorateAction
| UpdateElectionRuleAction;
export interface Proposal {
readonly id: number;
readonly title: string;
/**
* The transaction to be executed when the proposal is accepted
*
* This is one of the actions from
* https://htmlpreview.github.io/?https://github.com/iov-one/weave/blob/v0.16.0/docs/proto/index.html#app.ProposalOptions
*/
readonly action: ProposalAction;
readonly description: string;
readonly electionRule: VersionedId;
readonly electorate: VersionedId;
/** Time when the voting on this proposal starts (Unix timestamp) */
readonly votingStartTime: number;
/** Time when the voting on this proposal starts (Unix timestamp) */
readonly votingEndTime: number;
/** Time of the block where the proposal was added to the chain (Unix timestamp) */
readonly submissionTime: number;
/** The author of the proposal must be included in the list of transaction signers. */
readonly author: Address;
readonly state: TallyResult;
readonly status: ProposalStatus;
readonly result: ProposalResult;
readonly executorResult: ProposalExecutorResult;
}
export interface Vote {
readonly proposalId: number;
readonly elector: Elector;
readonly selection: VoteOption;
}
export interface ChainAddressPair {
readonly chainId: ChainId;
readonly address: Address;
}
export interface BnsUsernameNft {
readonly id: string;
readonly owner: Address;
readonly targets: readonly ChainAddressPair[];
}
export interface BnsUsernamesByUsernameQuery {
readonly username: string;
}
export interface BnsUsernamesByOwnerQuery {
readonly owner: Address;
}
export declare type BnsUsernamesQuery = BnsUsernamesByUsernameQuery | BnsUsernamesByOwnerQuery;
export declare function isBnsUsernamesByUsernameQuery(
query: BnsUsernamesQuery,
): query is BnsUsernamesByUsernameQuery;
export declare function isBnsUsernamesByOwnerQuery(
query: BnsUsernamesQuery,
): query is BnsUsernamesByOwnerQuery;
export declare type PrivkeyBytes = Uint8Array & As<"privkey-bytes">;
export interface PrivkeyBundle {
readonly algo: Algorithm;
readonly data: PrivkeyBytes;
}
export interface Result {
readonly key: Uint8Array;
readonly value: Uint8Array;
}
export interface Keyed {
readonly _id: Uint8Array;
}
export interface Decoder<T extends {}> {
readonly decode: (data: Uint8Array) => T;
}
export interface RegisterUsernameTx extends LightTransaction {
readonly kind: "bns/register_username";
readonly username: string;
readonly targets: readonly ChainAddressPair[];
}
export declare function isRegisterUsernameTx(tx: LightTransaction): tx is RegisterUsernameTx;
export interface UpdateTargetsOfUsernameTx extends LightTransaction {
readonly kind: "bns/update_targets_of_username";
/** the username to be updated, must exist on chain */
readonly username: string;
readonly targets: readonly ChainAddressPair[];
}
export declare function isUpdateTargetsOfUsernameTx(tx: LightTransaction): tx is UpdateTargetsOfUsernameTx;
export interface TransferUsernameTx extends LightTransaction {
readonly kind: "bns/transfer_username";
/** the username to be transferred, must exist on chain */
readonly username: string;
readonly newOwner: Address;
}
export declare function isTransferUsernameTx(tx: LightTransaction): tx is TransferUsernameTx;
export interface Participant {
readonly address: Address;
readonly weight: number;
}
export interface CreateMultisignatureTx extends LightTransaction {
readonly kind: "bns/create_multisignature_contract";
readonly participants: readonly Participant[];
readonly activationThreshold: number;
readonly adminThreshold: number;
}
export declare function isCreateMultisignatureTx(tx: LightTransaction): tx is CreateMultisignatureTx;
export interface UpdateMultisignatureTx extends LightTransaction {
readonly kind: "bns/update_multisignature_contract";
readonly contractId: Uint8Array;
readonly participants: readonly Participant[];
readonly activationThreshold: number;
readonly adminThreshold: number;
}
export declare function isUpdateMultisignatureTx(tx: LightTransaction): tx is UpdateMultisignatureTx;
export interface CreateEscrowTx extends LightTransaction {
readonly kind: "bns/create_escrow";
readonly sender: Address;
readonly arbiter: Address;
readonly recipient: Address;
readonly amounts: readonly Amount[];
readonly timeout: TimestampTimeout;
readonly memo?: string;
}
export declare function isCreateEscrowTx(tx: LightTransaction): tx is CreateEscrowTx;
export interface ReleaseEscrowTx extends LightTransaction {
readonly kind: "bns/release_escrow";
readonly escrowId: number;
readonly amounts: readonly Amount[];
}
export declare function isReleaseEscrowTx(tx: LightTransaction): tx is ReleaseEscrowTx;
export interface ReturnEscrowTx extends LightTransaction {
readonly kind: "bns/return_escrow";
readonly escrowId: number;
}
export declare function isReturnEscrowTx(tx: LightTransaction): tx is ReturnEscrowTx;
export interface UpdateEscrowPartiesTx extends LightTransaction {
readonly kind: "bns/update_escrow_parties";
readonly escrowId: number;
readonly sender?: Address;
readonly arbiter?: Address;
readonly recipient?: Address;
}
export declare function isUpdateEscrowPartiesTx(tx: LightTransaction): tx is UpdateEscrowPartiesTx;
export interface CreateProposalTx extends LightTransaction {
readonly kind: "bns/create_proposal";
readonly title: string;
/**
* The transaction to be executed when the proposal is accepted
*
* This is one of the actions from
* https://htmlpreview.github.io/?https://github.com/iov-one/weave/blob/v0.16.0/docs/proto/index.html#app.ProposalOptions
*/
readonly action: ProposalAction;
readonly description: string;
readonly electionRuleId: number;
/** Unix timestamp when the proposal starts */
readonly startTime: number;
/** The author of the proposal must be included in the list of transaction signers. */
readonly author: Address;
}
export declare function isCreateProposalTx(transaction: LightTransaction): transaction is CreateProposalTx;
export interface VoteTx extends LightTransaction {
readonly kind: "bns/vote";
readonly proposalId: number;
readonly selection: VoteOption;
}
export declare function isVoteTx(transaction: LightTransaction): transaction is VoteTx;
export declare type BnsTx =
| SendTransaction
| SwapOfferTransaction
| SwapClaimTransaction
| SwapAbortTransaction
| RegisterUsernameTx
| UpdateTargetsOfUsernameTx
| TransferUsernameTx
| CreateMultisignatureTx
| UpdateMultisignatureTx
| CreateEscrowTx
| ReleaseEscrowTx
| ReturnEscrowTx
| UpdateEscrowPartiesTx
| CreateProposalTx
| VoteTx;
export declare function isBnsTx(transaction: LightTransaction): transaction is BnsTx;
export interface MultisignatureTx extends LightTransaction {
readonly multisig: readonly number[];
}
export declare function isMultisignatureTx(transaction: LightTransaction): transaction is MultisignatureTx;