@dorafactory/maci-sdk 0.0.39 → 0.0.40

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.
@@ -10,7 +10,7 @@ export declare class Contract {
10
10
  feegrantOperator: string;
11
11
  whitelistBackendPubkey: string;
12
12
  constructor({ rpcEndpoint, registryAddress, maciCodeId, oracleCodeId, feegrantOperator, whitelistBackendPubkey, }: ContractParams);
13
- createAMaciRound({ signer, startVoting, endVoting, operator, whitelist, title, description, link, maxVoter, maxOption, voiceCreditAmount, circuitType, preDeactivateRoot, }: CreateAMaciRoundParams & {
13
+ createAMaciRound({ signer, startVoting, endVoting, operator, whitelist, title, description, link, maxVoter, maxOption, voiceCreditAmount, circuitType, preDeactivateRoot, fee, }: CreateAMaciRoundParams & {
14
14
  signer: OfflineSigner;
15
15
  }): Promise<{
16
16
  contractAddress: string;
@@ -21,10 +21,10 @@ export declare class Contract {
21
21
  gasWanted: bigint;
22
22
  gasUsed: bigint;
23
23
  }>;
24
- createMaciRound({ signer, operatorPubkey, startVoting, endVoting, whitelist, title, description, link, maxVoter, maxOption, circuitType, certSystemType, }: CreateMaciRoundParams & {
24
+ createMaciRound({ signer, operatorPubkey, startVoting, endVoting, whitelist, title, description, link, maxVoter, maxOption, circuitType, certSystemType, fee, }: CreateMaciRoundParams & {
25
25
  signer: OfflineSigner;
26
26
  }): Promise<import("@cosmjs/cosmwasm-stargate").InstantiateResult>;
27
- createOracleMaciRound({ signer, operatorPubkey, startVoting, endVoting, title, description, link, voteOptionMap, circuitType, whitelistEcosystem, whitelistSnapshotHeight, whitelistVotingPowerArgs, }: CreateOracleMaciRoundParams & {
27
+ createOracleMaciRound({ signer, operatorPubkey, startVoting, endVoting, title, description, link, voteOptionMap, circuitType, whitelistEcosystem, whitelistSnapshotHeight, whitelistVotingPowerArgs, fee, }: CreateOracleMaciRoundParams & {
28
28
  signer: OfflineSigner;
29
29
  }): Promise<import("@cosmjs/cosmwasm-stargate").InstantiateResult>;
30
30
  queryRoundInfo({ signer, roundAddress, }: {
@@ -1,6 +1,7 @@
1
+ import { OfflineSigner } from '@cosmjs/proto-signing';
2
+ import { StdFee } from '@cosmjs/amino';
1
3
  import { Whitelist as RegistryWhitelist } from './ts/Registry.types';
2
4
  import { Whitelist as MaciWhitelist } from './ts/Maci.types';
3
- import { OfflineSigner } from '@cosmjs/proto-signing';
4
5
  import { MaciCircuitType, MaciCertSystemType, CertificateEcosystem } from '../../types';
5
6
  export type CreateRoundParams = {
6
7
  signer?: OfflineSigner;
@@ -10,6 +11,7 @@ export type CreateRoundParams = {
10
11
  startVoting: Date;
11
12
  endVoting: Date;
12
13
  circuitType: MaciCircuitType;
14
+ fee?: number | StdFee | 'auto';
13
15
  };
14
16
  export type CreateAMaciRoundParams = {
15
17
  maxVoter: number;
@@ -4,6 +4,7 @@ import { Contract } from '../contract';
4
4
  import { Indexer } from '../indexer';
5
5
  import { OracleCertificate } from '../oracle-certificate';
6
6
  import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate';
7
+ import { StdFee } from '@cosmjs/stargate';
7
8
  import { CertificateEcosystem, ErrorResponse, RoundType } from '../../types';
8
9
  import { SignatureResponse } from '../oracle-certificate/types';
9
10
  import { OracleWhitelistConfig } from '../contract/ts/OracleMaci.types';
@@ -95,7 +96,7 @@ export declare class MACI {
95
96
  address?: string;
96
97
  contractAddress: string;
97
98
  }): Promise<SignatureResponse>;
98
- signup({ signer, address, contractAddress, maciKeypair, oracleCertificate, gasStation, }: {
99
+ signup({ signer, address, contractAddress, maciKeypair, oracleCertificate, gasStation, fee, }: {
99
100
  signer: OfflineSigner;
100
101
  address?: string;
101
102
  contractAddress: string;
@@ -105,6 +106,7 @@ export declare class MACI {
105
106
  signature: string;
106
107
  };
107
108
  gasStation?: boolean;
109
+ fee?: StdFee;
108
110
  }): Promise<import("@cosmjs/cosmwasm-stargate").ExecuteResult>;
109
111
  private processVoteOptions;
110
112
  vote({ signer, address, stateIdx, contractAddress, selectedOptions, operatorCoordPubKey, maciKeypair, gasStation, }: {
@@ -130,14 +132,15 @@ export declare class MACI {
130
132
  contractAddress: string;
131
133
  gasStation: boolean;
132
134
  }): Promise<import("@cosmjs/cosmwasm-stargate").DeliverTxResponse>;
133
- signupSimple({ client, address, pubKey, contractAddress, gasStation, }: {
135
+ signupSimple({ client, address, pubKey, contractAddress, gasStation, fee, }: {
134
136
  client: SigningCosmWasmClient;
135
137
  address: string;
136
138
  pubKey: PubKey;
137
139
  contractAddress: string;
138
140
  gasStation?: boolean;
141
+ fee?: StdFee;
139
142
  }): Promise<import("@cosmjs/cosmwasm-stargate").ExecuteResult>;
140
- signupOracle({ client, address, pubKey, contractAddress, oracleCertificate, gasStation, }: {
143
+ signupOracle({ client, address, pubKey, contractAddress, oracleCertificate, gasStation, fee, }: {
141
144
  client: SigningCosmWasmClient;
142
145
  address: string;
143
146
  pubKey: PubKey;
@@ -147,10 +150,12 @@ export declare class MACI {
147
150
  signature: string;
148
151
  };
149
152
  gasStation?: boolean;
153
+ fee?: StdFee;
150
154
  }): Promise<import("@cosmjs/cosmwasm-stargate").ExecuteResult>;
151
- claimAMaciRound({ signer, contractAddress, }: {
155
+ claimAMaciRound({ signer, contractAddress, fee, }: {
152
156
  signer: OfflineSigner;
153
157
  contractAddress: string;
158
+ fee?: number | StdFee | 'auto';
154
159
  }): Promise<import("@cosmjs/cosmwasm-stargate").ExecuteResult>;
155
160
  getOracleCertificateConfig(): Promise<import("../oracle-certificate/types").EcosystemsResponse>;
156
161
  /**
@@ -161,11 +166,12 @@ export declare class MACI {
161
166
  * @param amount
162
167
  * @returns
163
168
  */
164
- batchGrantWithBond({ signer, contractAddress, address, amount, }: {
169
+ batchGrantWithBond({ signer, contractAddress, address, amount, fee, }: {
165
170
  signer: OfflineSigner;
166
171
  contractAddress: string;
167
172
  amount: string;
168
173
  address?: string;
174
+ fee?: number | StdFee | 'auto';
169
175
  }): Promise<import("@cosmjs/cosmwasm-stargate").DeliverTxResponse>;
170
176
  /**
171
177
  * Batch revoke with withdraw (for maci)
@@ -174,9 +180,10 @@ export declare class MACI {
174
180
  * @param address
175
181
  * @returns
176
182
  */
177
- batchRevokeWithdraw({ signer, contractAddress, address, }: {
183
+ batchRevokeWithdraw({ signer, contractAddress, address, fee, }: {
178
184
  signer: OfflineSigner;
179
185
  contractAddress: string;
180
186
  address?: string;
187
+ fee?: number | StdFee | 'auto';
181
188
  }): Promise<import("@cosmjs/cosmwasm-stargate").DeliverTxResponse>;
182
189
  }
package/dist/maci.d.ts CHANGED
@@ -5,6 +5,7 @@ import { OfflineSigner } from '@cosmjs/proto-signing';
5
5
  import { Keypair, PubKey } from './libs/crypto';
6
6
  import { OracleWhitelistConfig } from './libs/contract/ts/OracleMaci.types';
7
7
  import { SignatureResponse } from './libs/oracle-certificate/types';
8
+ import { StdFee } from '@cosmjs/amino';
8
9
  /**
9
10
  * @class MaciClient
10
11
  * @description This class is used to interact with Maci Client.
@@ -147,7 +148,7 @@ export declare class MaciClient {
147
148
  address?: string;
148
149
  contractAddress: string;
149
150
  }): Promise<SignatureResponse>;
150
- signup({ signer, address, contractAddress, maciKeypair, oracleCertificate, gasStation, }: {
151
+ signup({ signer, address, contractAddress, maciKeypair, oracleCertificate, gasStation, fee, }: {
151
152
  signer?: OfflineSigner;
152
153
  address?: string;
153
154
  contractAddress: string;
@@ -157,6 +158,7 @@ export declare class MaciClient {
157
158
  signature: string;
158
159
  };
159
160
  gasStation?: boolean;
161
+ fee?: StdFee;
160
162
  }): Promise<import("@cosmjs/cosmwasm-stargate").ExecuteResult>;
161
163
  vote({ signer, address, stateIdx, contractAddress, selectedOptions, operatorCoordPubKey, maciKeypair, gasStation, }: {
162
164
  signer?: OfflineSigner;
@@ -171,20 +173,23 @@ export declare class MaciClient {
171
173
  maciKeypair?: Keypair;
172
174
  gasStation?: boolean;
173
175
  }): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
174
- claimAMaciRound({ signer, contractAddress, }: {
176
+ claimAMaciRound({ signer, contractAddress, fee, }: {
175
177
  signer?: OfflineSigner;
176
178
  contractAddress: string;
179
+ fee?: number | StdFee | 'auto';
177
180
  }): Promise<import("@cosmjs/cosmwasm-stargate").ExecuteResult>;
178
181
  getOracleCertificateConfig(): Promise<import("./libs/oracle-certificate/types").EcosystemsResponse>;
179
- batchGrantWithBond({ signer, contractAddress, address, amount, }: {
182
+ batchGrantWithBond({ signer, contractAddress, address, amount, fee, }: {
180
183
  signer?: OfflineSigner;
181
184
  contractAddress: string;
182
185
  address?: string;
183
186
  amount: string;
187
+ fee?: number | StdFee | 'auto';
184
188
  }): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
185
- batchRevokeWithdraw({ signer, contractAddress, address, }: {
189
+ batchRevokeWithdraw({ signer, contractAddress, address, fee, }: {
186
190
  signer?: OfflineSigner;
187
191
  contractAddress: string;
188
192
  address?: string;
193
+ fee?: number | StdFee | 'auto';
189
194
  }): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
190
195
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dorafactory/maci-sdk",
3
- "version": "0.0.39",
3
+ "version": "0.0.40",
4
4
  "description": "SDK for interacting with maci",
5
5
  "keywords": [
6
6
  "maci",
@@ -57,6 +57,7 @@ export class Contract {
57
57
  voiceCreditAmount,
58
58
  circuitType,
59
59
  preDeactivateRoot,
60
+ fee = 'auto',
60
61
  }: CreateAMaciRoundParams & { signer: OfflineSigner }) {
61
62
  const start_time = (startVoting.getTime() * 10 ** 6).toString();
62
63
  const end_time = (endVoting.getTime() * 10 ** 6).toString();
@@ -89,7 +90,7 @@ export class Contract {
89
90
  certificationSystem: '0',
90
91
  circuitType,
91
92
  },
92
- 'auto',
93
+ fee,
93
94
  undefined,
94
95
  [requiredFee]
95
96
  );
@@ -125,6 +126,7 @@ export class Contract {
125
126
  maxOption,
126
127
  circuitType,
127
128
  certSystemType,
129
+ fee = 'auto',
128
130
  }: CreateMaciRoundParams & { signer: OfflineSigner }) {
129
131
  const start_time = (startVoting.getTime() * 10 ** 6).toString();
130
132
  const end_time = (endVoting.getTime() * 10 ** 6).toString();
@@ -148,6 +150,7 @@ export class Contract {
148
150
  maxVoter,
149
151
  maxOption
150
152
  );
153
+
151
154
  const instantiateResponse = await client.instantiate(
152
155
  address,
153
156
  this.maciCodeId,
@@ -173,7 +176,7 @@ export class Contract {
173
176
  qtr_lib: QTR_LIB,
174
177
  },
175
178
  `[MACI] ${title}`,
176
- 'auto'
179
+ fee
177
180
  );
178
181
 
179
182
  return instantiateResponse;
@@ -192,6 +195,7 @@ export class Contract {
192
195
  whitelistEcosystem,
193
196
  whitelistSnapshotHeight,
194
197
  whitelistVotingPowerArgs,
198
+ fee = 'auto',
195
199
  }: CreateOracleMaciRoundParams & { signer: OfflineSigner }) {
196
200
  const start_time = (startVoting.getTime() * 1_000_000).toString();
197
201
  const end_time = (endVoting.getTime() * 1_000_000).toString();
@@ -207,6 +211,7 @@ export class Contract {
207
211
  0,
208
212
  0
209
213
  );
214
+
210
215
  const instantiateResponse = await client.instantiate(
211
216
  address,
212
217
  this.oracleCodeId,
@@ -230,7 +235,7 @@ export class Contract {
230
235
  feegrant_operator: this.feegrantOperator,
231
236
  },
232
237
  `[Oracle MACI] ${title}`,
233
- 'auto'
238
+ fee
234
239
  );
235
240
 
236
241
  return instantiateResponse;
@@ -1,6 +1,8 @@
1
+ import { OfflineSigner } from '@cosmjs/proto-signing';
2
+ import { StdFee } from '@cosmjs/amino';
3
+
1
4
  import { Whitelist as RegistryWhitelist } from './ts/Registry.types';
2
5
  import { Whitelist as MaciWhitelist } from './ts/Maci.types';
3
- import { OfflineSigner } from '@cosmjs/proto-signing';
4
6
  import {
5
7
  MaciCircuitType,
6
8
  MaciCertSystemType,
@@ -15,6 +17,7 @@ export type CreateRoundParams = {
15
17
  startVoting: Date;
16
18
  endVoting: Date;
17
19
  circuitType: MaciCircuitType;
20
+ fee?: number | StdFee | 'auto';
18
21
  };
19
22
 
20
23
  export type CreateAMaciRoundParams = {
@@ -444,6 +444,7 @@ export class MACI {
444
444
  maciKeypair,
445
445
  oracleCertificate,
446
446
  gasStation = false,
447
+ fee,
447
448
  }: {
448
449
  signer: OfflineSigner;
449
450
  address?: string;
@@ -454,6 +455,7 @@ export class MACI {
454
455
  signature: string;
455
456
  };
456
457
  gasStation?: boolean;
458
+ fee?: StdFee;
457
459
  }) {
458
460
  try {
459
461
  if (!address) {
@@ -477,6 +479,7 @@ export class MACI {
477
479
  contractAddress,
478
480
  oracleCertificate,
479
481
  gasStation,
482
+ fee,
480
483
  });
481
484
  } else {
482
485
  return await this.signupSimple({
@@ -485,6 +488,7 @@ export class MACI {
485
488
  pubKey: maciKeypair.pubKey,
486
489
  contractAddress,
487
490
  gasStation,
491
+ fee,
488
492
  });
489
493
  }
490
494
  } catch (error) {
@@ -667,15 +671,17 @@ export class MACI {
667
671
  pubKey,
668
672
  contractAddress,
669
673
  gasStation,
674
+ fee,
670
675
  }: {
671
676
  client: SigningCosmWasmClient;
672
677
  address: string;
673
678
  pubKey: PubKey;
674
679
  contractAddress: string;
675
680
  gasStation?: boolean;
681
+ fee?: StdFee;
676
682
  }) {
677
683
  const gasPrice = GasPrice.fromString('100000000000peaka');
678
- const fee = calculateFee(60000000, gasPrice);
684
+ fee = fee || calculateFee(60000000, gasPrice);
679
685
 
680
686
  if (gasStation === true) {
681
687
  const grantFee: StdFee = {
@@ -720,6 +726,7 @@ export class MACI {
720
726
  contractAddress,
721
727
  oracleCertificate,
722
728
  gasStation,
729
+ fee,
723
730
  }: {
724
731
  client: SigningCosmWasmClient;
725
732
  address: string;
@@ -730,9 +737,10 @@ export class MACI {
730
737
  signature: string;
731
738
  };
732
739
  gasStation?: boolean;
740
+ fee?: StdFee;
733
741
  }) {
734
742
  const gasPrice = GasPrice.fromString('100000000000peaka');
735
- const fee = calculateFee(60000000, gasPrice);
743
+ fee = fee || calculateFee(60000000, gasPrice);
736
744
 
737
745
  if (gasStation === true) {
738
746
  const grantFee: StdFee = {
@@ -777,16 +785,18 @@ export class MACI {
777
785
  async claimAMaciRound({
778
786
  signer,
779
787
  contractAddress,
788
+ fee = 'auto',
780
789
  }: {
781
790
  signer: OfflineSigner;
782
791
  contractAddress: string;
792
+ fee?: number | StdFee | 'auto';
783
793
  }) {
784
794
  const client = await this.contract.amaciClient({
785
795
  signer,
786
796
  contractAddress,
787
797
  });
788
798
 
789
- return client.claim();
799
+ return client.claim(fee);
790
800
  }
791
801
 
792
802
  async getOracleCertificateConfig() {
@@ -807,11 +817,13 @@ export class MACI {
807
817
  contractAddress,
808
818
  address,
809
819
  amount,
820
+ fee = 'auto',
810
821
  }: {
811
822
  signer: OfflineSigner;
812
823
  contractAddress: string;
813
824
  amount: string;
814
825
  address?: string;
826
+ fee?: number | StdFee | 'auto';
815
827
  }) {
816
828
  const client = await this.contract.contractClient({
817
829
  signer,
@@ -861,7 +873,7 @@ export class MACI {
861
873
  ];
862
874
 
863
875
  try {
864
- const result = await client.signAndBroadcast(address, msgs, 'auto');
876
+ const result = await client.signAndBroadcast(address, msgs, fee);
865
877
  return result;
866
878
  } catch (err) {
867
879
  throw err;
@@ -879,10 +891,12 @@ export class MACI {
879
891
  signer,
880
892
  contractAddress,
881
893
  address,
894
+ fee = 'auto',
882
895
  }: {
883
896
  signer: OfflineSigner;
884
897
  contractAddress: string;
885
898
  address?: string;
899
+ fee?: number | StdFee | 'auto';
886
900
  }) {
887
901
  const client = await this.contract.contractClient({
888
902
  signer,
@@ -924,7 +938,7 @@ export class MACI {
924
938
  ];
925
939
 
926
940
  try {
927
- const result = await client.signAndBroadcast(address, msgs, 'auto');
941
+ const result = await client.signAndBroadcast(address, msgs, fee);
928
942
  return result;
929
943
  } catch (err) {
930
944
  throw err;
package/src/maci.ts CHANGED
@@ -17,6 +17,7 @@ import {
17
17
  } from './libs/crypto';
18
18
  import { OracleWhitelistConfig } from './libs/contract/ts/OracleMaci.types';
19
19
  import { SignatureResponse } from './libs/oracle-certificate/types';
20
+ import { StdFee } from '@cosmjs/amino';
20
21
 
21
22
  /**
22
23
  * @class MaciClient
@@ -450,6 +451,7 @@ export class MaciClient {
450
451
  maciKeypair,
451
452
  oracleCertificate,
452
453
  gasStation = false,
454
+ fee,
453
455
  }: {
454
456
  signer?: OfflineSigner;
455
457
  address?: string;
@@ -460,6 +462,7 @@ export class MaciClient {
460
462
  signature: string;
461
463
  };
462
464
  gasStation?: boolean;
465
+ fee?: StdFee;
463
466
  }) {
464
467
  return await this.maci.signup({
465
468
  signer: this.getSigner(signer),
@@ -468,6 +471,7 @@ export class MaciClient {
468
471
  maciKeypair,
469
472
  oracleCertificate,
470
473
  gasStation,
474
+ fee,
471
475
  });
472
476
  }
473
477
 
@@ -508,14 +512,16 @@ export class MaciClient {
508
512
  async claimAMaciRound({
509
513
  signer,
510
514
  contractAddress,
515
+ fee = 'auto',
511
516
  }: {
512
517
  signer?: OfflineSigner;
513
518
  contractAddress: string;
519
+ fee?: number | StdFee | 'auto';
514
520
  }) {
515
- signer = this.getSigner(signer);
516
521
  return await this.maci.claimAMaciRound({
517
- signer,
522
+ signer: this.getSigner(signer),
518
523
  contractAddress,
524
+ fee,
519
525
  });
520
526
  }
521
527
 
@@ -528,11 +534,13 @@ export class MaciClient {
528
534
  contractAddress,
529
535
  address,
530
536
  amount,
537
+ fee = 'auto',
531
538
  }: {
532
539
  signer?: OfflineSigner;
533
540
  contractAddress: string;
534
541
  address?: string;
535
542
  amount: string;
543
+ fee?: number | StdFee | 'auto';
536
544
  }) {
537
545
  if (!address) {
538
546
  address = await this.getAddress(signer);
@@ -542,6 +550,7 @@ export class MaciClient {
542
550
  contractAddress,
543
551
  address,
544
552
  amount,
553
+ fee,
545
554
  });
546
555
  }
547
556
 
@@ -549,10 +558,12 @@ export class MaciClient {
549
558
  signer,
550
559
  contractAddress,
551
560
  address,
561
+ fee = 'auto',
552
562
  }: {
553
563
  signer?: OfflineSigner;
554
564
  contractAddress: string;
555
565
  address?: string;
566
+ fee?: number | StdFee | 'auto';
556
567
  }) {
557
568
  if (!address) {
558
569
  address = await this.getAddress(signer);
@@ -561,6 +572,7 @@ export class MaciClient {
561
572
  signer: this.getSigner(signer),
562
573
  contractAddress,
563
574
  address,
575
+ fee,
564
576
  });
565
577
  }
566
578
  }