@dorafactory/maci-sdk 0.1.1 → 0.1.2-pre.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,567 @@
1
+ /**
2
+ * This file was automatically generated by @cosmwasm/ts-codegen@1.11.1.
3
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
+ * and run the @cosmwasm/ts-codegen generate command to regenerate this file.
5
+ */
6
+
7
+ import {
8
+ CosmWasmClient,
9
+ SigningCosmWasmClient,
10
+ ExecuteResult,
11
+ } from '@cosmjs/cosmwasm-stargate';
12
+ import { Coin, StdFee } from '@cosmjs/amino';
13
+ import {
14
+ Addr,
15
+ InstantiateMsg,
16
+ ExecuteMsg,
17
+ Uint128,
18
+ Uint256,
19
+ Timestamp,
20
+ Uint64,
21
+ PubKey,
22
+ RoundInfo,
23
+ QueryMsg,
24
+ Config,
25
+ Boolean,
26
+ NullableMaciContractInfo,
27
+ MaciContractInfo,
28
+ ArrayOfMaciContractInfo,
29
+ ArrayOfOperatorInfo,
30
+ OperatorInfo,
31
+ } from './Saas.types';
32
+ export interface SaasReadOnlyInterface {
33
+ contractAddress: string;
34
+ config: () => Promise<Config>;
35
+ operators: () => Promise<ArrayOfOperatorInfo>;
36
+ isOperator: ({ address }: { address: Addr }) => Promise<Boolean>;
37
+ balance: () => Promise<Uint128>;
38
+ maciContracts: ({
39
+ limit,
40
+ startAfter,
41
+ }: {
42
+ limit?: number;
43
+ startAfter?: number;
44
+ }) => Promise<ArrayOfMaciContractInfo>;
45
+ operatorMaciContracts: ({
46
+ limit,
47
+ operator,
48
+ startAfter,
49
+ }: {
50
+ limit?: number;
51
+ operator: Addr;
52
+ startAfter?: number;
53
+ }) => Promise<ArrayOfMaciContractInfo>;
54
+ maciContract: ({
55
+ contractId,
56
+ }: {
57
+ contractId: number;
58
+ }) => Promise<NullableMaciContractInfo>;
59
+ oracleMaciCodeId: () => Promise<Uint64>;
60
+ }
61
+ export class SaasQueryClient implements SaasReadOnlyInterface {
62
+ client: CosmWasmClient;
63
+ contractAddress: string;
64
+ constructor(client: CosmWasmClient, contractAddress: string) {
65
+ this.client = client;
66
+ this.contractAddress = contractAddress;
67
+ this.config = this.config.bind(this);
68
+ this.operators = this.operators.bind(this);
69
+ this.isOperator = this.isOperator.bind(this);
70
+ this.balance = this.balance.bind(this);
71
+ this.maciContracts = this.maciContracts.bind(this);
72
+ this.operatorMaciContracts = this.operatorMaciContracts.bind(this);
73
+ this.maciContract = this.maciContract.bind(this);
74
+ this.oracleMaciCodeId = this.oracleMaciCodeId.bind(this);
75
+ }
76
+ config = async (): Promise<Config> => {
77
+ return this.client.queryContractSmart(this.contractAddress, {
78
+ config: {},
79
+ });
80
+ };
81
+ operators = async (): Promise<ArrayOfOperatorInfo> => {
82
+ return this.client.queryContractSmart(this.contractAddress, {
83
+ operators: {},
84
+ });
85
+ };
86
+ isOperator = async ({ address }: { address: Addr }): Promise<Boolean> => {
87
+ return this.client.queryContractSmart(this.contractAddress, {
88
+ is_operator: {
89
+ address,
90
+ },
91
+ });
92
+ };
93
+ balance = async (): Promise<Uint128> => {
94
+ return this.client.queryContractSmart(this.contractAddress, {
95
+ balance: {},
96
+ });
97
+ };
98
+ maciContracts = async ({
99
+ limit,
100
+ startAfter,
101
+ }: {
102
+ limit?: number;
103
+ startAfter?: number;
104
+ }): Promise<ArrayOfMaciContractInfo> => {
105
+ return this.client.queryContractSmart(this.contractAddress, {
106
+ maci_contracts: {
107
+ limit,
108
+ start_after: startAfter,
109
+ },
110
+ });
111
+ };
112
+ operatorMaciContracts = async ({
113
+ limit,
114
+ operator,
115
+ startAfter,
116
+ }: {
117
+ limit?: number;
118
+ operator: Addr;
119
+ startAfter?: number;
120
+ }): Promise<ArrayOfMaciContractInfo> => {
121
+ return this.client.queryContractSmart(this.contractAddress, {
122
+ operator_maci_contracts: {
123
+ limit,
124
+ operator,
125
+ start_after: startAfter,
126
+ },
127
+ });
128
+ };
129
+ maciContract = async ({
130
+ contractId,
131
+ }: {
132
+ contractId: number;
133
+ }): Promise<NullableMaciContractInfo> => {
134
+ return this.client.queryContractSmart(this.contractAddress, {
135
+ maci_contract: {
136
+ contract_id: contractId,
137
+ },
138
+ });
139
+ };
140
+ oracleMaciCodeId = async (): Promise<Uint64> => {
141
+ return this.client.queryContractSmart(this.contractAddress, {
142
+ oracle_maci_code_id: {},
143
+ });
144
+ };
145
+ }
146
+ export interface SaasInterface extends SaasReadOnlyInterface {
147
+ contractAddress: string;
148
+ sender: string;
149
+ updateConfig: (
150
+ {
151
+ admin,
152
+ denom,
153
+ registryContract,
154
+ }: {
155
+ admin?: Addr;
156
+ denom?: string;
157
+ registryContract?: Addr;
158
+ },
159
+ fee?: number | StdFee | 'auto',
160
+ memo?: string,
161
+ _funds?: Coin[]
162
+ ) => Promise<ExecuteResult>;
163
+ addOperator: (
164
+ {
165
+ operator,
166
+ }: {
167
+ operator: Addr;
168
+ },
169
+ fee?: number | StdFee | 'auto',
170
+ memo?: string,
171
+ _funds?: Coin[]
172
+ ) => Promise<ExecuteResult>;
173
+ removeOperator: (
174
+ {
175
+ operator,
176
+ }: {
177
+ operator: Addr;
178
+ },
179
+ fee?: number | StdFee | 'auto',
180
+ memo?: string,
181
+ _funds?: Coin[]
182
+ ) => Promise<ExecuteResult>;
183
+ deposit: (
184
+ fee?: number | StdFee | 'auto',
185
+ memo?: string,
186
+ _funds?: Coin[]
187
+ ) => Promise<ExecuteResult>;
188
+ withdraw: (
189
+ {
190
+ amount,
191
+ recipient,
192
+ }: {
193
+ amount: Uint128;
194
+ recipient?: Addr;
195
+ },
196
+ fee?: number | StdFee | 'auto',
197
+ memo?: string,
198
+ _funds?: Coin[]
199
+ ) => Promise<ExecuteResult>;
200
+ updateOracleMaciCodeId: (
201
+ {
202
+ codeId,
203
+ }: {
204
+ codeId: number;
205
+ },
206
+ fee?: number | StdFee | 'auto',
207
+ memo?: string,
208
+ _funds?: Coin[]
209
+ ) => Promise<ExecuteResult>;
210
+ createOracleMaciRound: (
211
+ {
212
+ certificationSystem,
213
+ circuitType,
214
+ coordinator,
215
+ endTime,
216
+ maxVoters,
217
+ roundInfo,
218
+ startTime,
219
+ voteOptionMap,
220
+ whitelistBackendPubkey,
221
+ }: {
222
+ certificationSystem: Uint256;
223
+ circuitType: Uint256;
224
+ coordinator: PubKey;
225
+ endTime: Timestamp;
226
+ maxVoters: number;
227
+ roundInfo: RoundInfo;
228
+ startTime: Timestamp;
229
+ voteOptionMap: string[];
230
+ whitelistBackendPubkey: string;
231
+ },
232
+ fee?: number | StdFee | 'auto',
233
+ memo?: string,
234
+ _funds?: Coin[]
235
+ ) => Promise<ExecuteResult>;
236
+ setRoundInfo: (
237
+ {
238
+ contractAddr,
239
+ roundInfo,
240
+ }: {
241
+ contractAddr: string;
242
+ roundInfo: RoundInfo;
243
+ },
244
+ fee?: number | StdFee | 'auto',
245
+ memo?: string,
246
+ _funds?: Coin[]
247
+ ) => Promise<ExecuteResult>;
248
+ setVoteOptionsMap: (
249
+ {
250
+ contractAddr,
251
+ voteOptionMap,
252
+ }: {
253
+ contractAddr: string;
254
+ voteOptionMap: string[];
255
+ },
256
+ fee?: number | StdFee | 'auto',
257
+ memo?: string,
258
+ _funds?: Coin[]
259
+ ) => Promise<ExecuteResult>;
260
+ grantToVoter: (
261
+ {
262
+ baseAmount,
263
+ contractAddr,
264
+ grantee,
265
+ }: {
266
+ baseAmount: Uint128;
267
+ contractAddr: string;
268
+ grantee: Addr;
269
+ },
270
+ fee?: number | StdFee | 'auto',
271
+ memo?: string,
272
+ _funds?: Coin[]
273
+ ) => Promise<ExecuteResult>;
274
+ }
275
+ export class SaasClient extends SaasQueryClient implements SaasInterface {
276
+ client: SigningCosmWasmClient;
277
+ sender: string;
278
+ contractAddress: string;
279
+ constructor(
280
+ client: SigningCosmWasmClient,
281
+ sender: string,
282
+ contractAddress: string
283
+ ) {
284
+ super(client, contractAddress);
285
+ this.client = client;
286
+ this.sender = sender;
287
+ this.contractAddress = contractAddress;
288
+ this.updateConfig = this.updateConfig.bind(this);
289
+ this.addOperator = this.addOperator.bind(this);
290
+ this.removeOperator = this.removeOperator.bind(this);
291
+ this.deposit = this.deposit.bind(this);
292
+ this.withdraw = this.withdraw.bind(this);
293
+ this.updateOracleMaciCodeId = this.updateOracleMaciCodeId.bind(this);
294
+ this.createOracleMaciRound = this.createOracleMaciRound.bind(this);
295
+ this.setRoundInfo = this.setRoundInfo.bind(this);
296
+ this.setVoteOptionsMap = this.setVoteOptionsMap.bind(this);
297
+ this.grantToVoter = this.grantToVoter.bind(this);
298
+ }
299
+ updateConfig = async (
300
+ {
301
+ admin,
302
+ denom,
303
+ registryContract,
304
+ }: {
305
+ admin?: Addr;
306
+ denom?: string;
307
+ registryContract?: Addr;
308
+ },
309
+ fee: number | StdFee | 'auto' = 'auto',
310
+ memo?: string,
311
+ _funds?: Coin[]
312
+ ): Promise<ExecuteResult> => {
313
+ return await this.client.execute(
314
+ this.sender,
315
+ this.contractAddress,
316
+ {
317
+ update_config: {
318
+ admin,
319
+ denom,
320
+ registry_contract: registryContract,
321
+ },
322
+ },
323
+ fee,
324
+ memo,
325
+ _funds
326
+ );
327
+ };
328
+ addOperator = async (
329
+ {
330
+ operator,
331
+ }: {
332
+ operator: Addr;
333
+ },
334
+ fee: number | StdFee | 'auto' = 'auto',
335
+ memo?: string,
336
+ _funds?: Coin[]
337
+ ): Promise<ExecuteResult> => {
338
+ return await this.client.execute(
339
+ this.sender,
340
+ this.contractAddress,
341
+ {
342
+ add_operator: {
343
+ operator,
344
+ },
345
+ },
346
+ fee,
347
+ memo,
348
+ _funds
349
+ );
350
+ };
351
+ removeOperator = async (
352
+ {
353
+ operator,
354
+ }: {
355
+ operator: Addr;
356
+ },
357
+ fee: number | StdFee | 'auto' = 'auto',
358
+ memo?: string,
359
+ _funds?: Coin[]
360
+ ): Promise<ExecuteResult> => {
361
+ return await this.client.execute(
362
+ this.sender,
363
+ this.contractAddress,
364
+ {
365
+ remove_operator: {
366
+ operator,
367
+ },
368
+ },
369
+ fee,
370
+ memo,
371
+ _funds
372
+ );
373
+ };
374
+ deposit = async (
375
+ fee: number | StdFee | 'auto' = 'auto',
376
+ memo?: string,
377
+ _funds?: Coin[]
378
+ ): Promise<ExecuteResult> => {
379
+ return await this.client.execute(
380
+ this.sender,
381
+ this.contractAddress,
382
+ {
383
+ deposit: {},
384
+ },
385
+ fee,
386
+ memo,
387
+ _funds
388
+ );
389
+ };
390
+ withdraw = async (
391
+ {
392
+ amount,
393
+ recipient,
394
+ }: {
395
+ amount: Uint128;
396
+ recipient?: Addr;
397
+ },
398
+ fee: number | StdFee | 'auto' = 'auto',
399
+ memo?: string,
400
+ _funds?: Coin[]
401
+ ): Promise<ExecuteResult> => {
402
+ return await this.client.execute(
403
+ this.sender,
404
+ this.contractAddress,
405
+ {
406
+ withdraw: {
407
+ amount,
408
+ recipient,
409
+ },
410
+ },
411
+ fee,
412
+ memo,
413
+ _funds
414
+ );
415
+ };
416
+ updateOracleMaciCodeId = async (
417
+ {
418
+ codeId,
419
+ }: {
420
+ codeId: number;
421
+ },
422
+ fee: number | StdFee | 'auto' = 'auto',
423
+ memo?: string,
424
+ _funds?: Coin[]
425
+ ): Promise<ExecuteResult> => {
426
+ return await this.client.execute(
427
+ this.sender,
428
+ this.contractAddress,
429
+ {
430
+ update_oracle_maci_code_id: {
431
+ code_id: codeId,
432
+ },
433
+ },
434
+ fee,
435
+ memo,
436
+ _funds
437
+ );
438
+ };
439
+ createOracleMaciRound = async (
440
+ {
441
+ certificationSystem,
442
+ circuitType,
443
+ coordinator,
444
+ endTime,
445
+ maxVoters,
446
+ roundInfo,
447
+ startTime,
448
+ voteOptionMap,
449
+ whitelistBackendPubkey,
450
+ }: {
451
+ certificationSystem: Uint256;
452
+ circuitType: Uint256;
453
+ coordinator: PubKey;
454
+ endTime: Timestamp;
455
+ maxVoters: number;
456
+ roundInfo: RoundInfo;
457
+ startTime: Timestamp;
458
+ voteOptionMap: string[];
459
+ whitelistBackendPubkey: string;
460
+ },
461
+ fee: number | StdFee | 'auto' = 'auto',
462
+ memo?: string,
463
+ _funds?: Coin[]
464
+ ): Promise<ExecuteResult> => {
465
+ return await this.client.execute(
466
+ this.sender,
467
+ this.contractAddress,
468
+ {
469
+ create_oracle_maci_round: {
470
+ certification_system: certificationSystem,
471
+ circuit_type: circuitType,
472
+ coordinator,
473
+ end_time: endTime,
474
+ max_voters: maxVoters.toString(),
475
+ round_info: roundInfo,
476
+ start_time: startTime,
477
+ vote_option_map: voteOptionMap,
478
+ whitelist_backend_pubkey: whitelistBackendPubkey,
479
+ },
480
+ },
481
+ fee,
482
+ memo,
483
+ _funds
484
+ );
485
+ };
486
+ setRoundInfo = async (
487
+ {
488
+ contractAddr,
489
+ roundInfo,
490
+ }: {
491
+ contractAddr: string;
492
+ roundInfo: RoundInfo;
493
+ },
494
+ fee: number | StdFee | 'auto' = 'auto',
495
+ memo?: string,
496
+ _funds?: Coin[]
497
+ ): Promise<ExecuteResult> => {
498
+ return await this.client.execute(
499
+ this.sender,
500
+ this.contractAddress,
501
+ {
502
+ set_round_info: {
503
+ contract_addr: contractAddr,
504
+ round_info: roundInfo,
505
+ },
506
+ },
507
+ fee,
508
+ memo,
509
+ _funds
510
+ );
511
+ };
512
+ setVoteOptionsMap = async (
513
+ {
514
+ contractAddr,
515
+ voteOptionMap,
516
+ }: {
517
+ contractAddr: string;
518
+ voteOptionMap: string[];
519
+ },
520
+ fee: number | StdFee | 'auto' = 'auto',
521
+ memo?: string,
522
+ _funds?: Coin[]
523
+ ): Promise<ExecuteResult> => {
524
+ return await this.client.execute(
525
+ this.sender,
526
+ this.contractAddress,
527
+ {
528
+ set_vote_options_map: {
529
+ contract_addr: contractAddr,
530
+ vote_option_map: voteOptionMap,
531
+ },
532
+ },
533
+ fee,
534
+ memo,
535
+ _funds
536
+ );
537
+ };
538
+ grantToVoter = async (
539
+ {
540
+ baseAmount,
541
+ contractAddr,
542
+ grantee,
543
+ }: {
544
+ baseAmount: Uint128;
545
+ contractAddr: string;
546
+ grantee: Addr;
547
+ },
548
+ fee: number | StdFee | 'auto' = 'auto',
549
+ memo?: string,
550
+ _funds?: Coin[]
551
+ ): Promise<ExecuteResult> => {
552
+ return await this.client.execute(
553
+ this.sender,
554
+ this.contractAddress,
555
+ {
556
+ grant_to_voter: {
557
+ base_amount: baseAmount,
558
+ contract_addr: contractAddr,
559
+ grantee,
560
+ },
561
+ },
562
+ fee,
563
+ memo,
564
+ _funds
565
+ );
566
+ };
567
+ }
@@ -0,0 +1,147 @@
1
+ /**
2
+ * This file was automatically generated by @cosmwasm/ts-codegen@1.11.1.
3
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
+ * and run the @cosmwasm/ts-codegen generate command to regenerate this file.
5
+ */
6
+
7
+ export type Addr = string;
8
+ export interface InstantiateMsg {
9
+ admin: Addr;
10
+ denom: string;
11
+ oracle_maci_code_id: number;
12
+ registry_contract?: Addr | null;
13
+ }
14
+ export type ExecuteMsg =
15
+ | {
16
+ update_config: {
17
+ admin?: Addr | null;
18
+ denom?: string | null;
19
+ registry_contract?: Addr | null;
20
+ };
21
+ }
22
+ | {
23
+ add_operator: {
24
+ operator: Addr;
25
+ };
26
+ }
27
+ | {
28
+ remove_operator: {
29
+ operator: Addr;
30
+ };
31
+ }
32
+ | {
33
+ deposit: {};
34
+ }
35
+ | {
36
+ withdraw: {
37
+ amount: Uint128;
38
+ recipient?: Addr | null;
39
+ };
40
+ }
41
+ | {
42
+ update_oracle_maci_code_id: {
43
+ code_id: number;
44
+ };
45
+ }
46
+ | {
47
+ create_oracle_maci_round: {
48
+ certification_system: Uint256;
49
+ circuit_type: Uint256;
50
+ coordinator: PubKey;
51
+ end_time: Timestamp;
52
+ max_voters: number;
53
+ round_info: RoundInfo;
54
+ start_time: Timestamp;
55
+ vote_option_map: string[];
56
+ whitelist_backend_pubkey: string;
57
+ };
58
+ }
59
+ | {
60
+ set_round_info: {
61
+ contract_addr: string;
62
+ round_info: RoundInfo;
63
+ };
64
+ }
65
+ | {
66
+ set_vote_options_map: {
67
+ contract_addr: string;
68
+ vote_option_map: string[];
69
+ };
70
+ }
71
+ | {
72
+ grant_to_voter: {
73
+ base_amount: Uint128;
74
+ contract_addr: string;
75
+ grantee: Addr;
76
+ };
77
+ };
78
+ export type Uint128 = string;
79
+ export type Uint256 = string;
80
+ export type Timestamp = Uint64;
81
+ export type Uint64 = string;
82
+ export interface PubKey {
83
+ x: Uint256;
84
+ y: Uint256;
85
+ }
86
+ export interface RoundInfo {
87
+ description: string;
88
+ link: string;
89
+ title: string;
90
+ }
91
+ export type QueryMsg =
92
+ | {
93
+ config: {};
94
+ }
95
+ | {
96
+ operators: {};
97
+ }
98
+ | {
99
+ is_operator: {
100
+ address: Addr;
101
+ };
102
+ }
103
+ | {
104
+ balance: {};
105
+ }
106
+ | {
107
+ maci_contracts: {
108
+ limit?: number | null;
109
+ start_after?: number | null;
110
+ };
111
+ }
112
+ | {
113
+ operator_maci_contracts: {
114
+ limit?: number | null;
115
+ operator: Addr;
116
+ start_after?: number | null;
117
+ };
118
+ }
119
+ | {
120
+ maci_contract: {
121
+ contract_id: number;
122
+ };
123
+ }
124
+ | {
125
+ oracle_maci_code_id: {};
126
+ };
127
+ export interface Config {
128
+ admin: Addr;
129
+ denom: string;
130
+ registry_contract?: Addr | null;
131
+ }
132
+ export type Boolean = boolean;
133
+ export type NullableMaciContractInfo = MaciContractInfo | null;
134
+ export interface MaciContractInfo {
135
+ code_id: number;
136
+ contract_address: Addr;
137
+ created_at: Timestamp;
138
+ creation_fee: Uint128;
139
+ creator_operator: Addr;
140
+ round_title: string;
141
+ }
142
+ export type ArrayOfMaciContractInfo = MaciContractInfo[];
143
+ export type ArrayOfOperatorInfo = OperatorInfo[];
144
+ export interface OperatorInfo {
145
+ added_at: Timestamp;
146
+ address: Addr;
147
+ }
@@ -38,6 +38,7 @@ export type CreateMaciRoundParams = {
38
38
  } & CreateRoundParams;
39
39
 
40
40
  export type CreateOracleMaciRoundParams = {
41
+ maxVoter: number;
41
42
  voteOptionMap: string[];
42
43
  operatorPubkey: bigint | string;
43
44
  whitelistEcosystem: CertificateEcosystem;
@@ -47,6 +48,14 @@ export type CreateOracleMaciRoundParams = {
47
48
  slope: string;
48
49
  threshold: string;
49
50
  };
50
- // whitelistBackendPubkey?: string;
51
- // feegrantOperator?: string;
51
+ whitelistBackendPubkey?: string;
52
+ feegrantOperator?: string;
53
+ } & CreateRoundParams;
54
+
55
+ export type CreateSaasOracleMaciRoundParams = {
56
+ maxVoter: number;
57
+ voteOptionMap: string[];
58
+ operatorPubkey: bigint | string;
59
+ whitelistBackendPubkey?: string;
60
+ feegrantOperator?: string;
52
61
  } & CreateRoundParams;