@dorafactory/maci-sdk 0.0.39 → 0.0.41

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;
@@ -72,3 +72,4 @@ export declare const genAddKeyProof: (depth: number, { coordPubKey, oldKey, deac
72
72
  nullifier: bigint;
73
73
  oldPrivateKey: bigint;
74
74
  } | null>;
75
+ export declare const genRandomKey: () => string;
@@ -13,4 +13,5 @@ export declare class Http {
13
13
  fetch(url: string, options?: any): Promise<Response>;
14
14
  fetchGraphql<T>(query: string, after: string, limit?: number | null): Promise<T>;
15
15
  fetchRest(path: string, options?: any): Promise<any>;
16
+ fetchAllGraphqlPages<T>(query: string, variables: any): Promise<T[]>;
16
17
  }
@@ -1,4 +1,4 @@
1
- import { BalanceResponse, RoundResponse, RoundsResponse, OperatorResponse, OperatorsResponse, CircuitResponse, TransactionResponse, TransactionsResponse, CircuitsResponse, ProofResponse, SignUpEventsResponse, OperatorDelayOperationsResponse, MissRateResponse, SelectiveRoundResponse } from '../../types';
1
+ import { BalanceResponse, RoundResponse, RoundsResponse, OperatorResponse, OperatorsResponse, CircuitResponse, TransactionResponse, TransactionsResponse, CircuitsResponse, ProofResponse, SignUpEventsResponse, OperatorDelayOperationsResponse, MissRateResponse, SelectiveRoundResponse, DeactivateMessage } from '../../types';
2
2
  import { IndexerParams } from './types';
3
3
  import { Http } from '../http';
4
4
  import { Round, UserAccount, Circuit, Operator, Proof, Transaction, Event } from '../query';
@@ -149,4 +149,5 @@ export declare class Indexer {
149
149
  * @returns {Promise<SignUpEventsResponse>} The sign up events response.
150
150
  */
151
151
  getSignUpEventByPubKey(contractAddress: string, pubKey: bigint[]): Promise<SignUpEventsResponse>;
152
+ fetchAllDeactivateLogs(contractAddress: string): Promise<DeactivateMessage[]>;
152
153
  }
@@ -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,15 @@ 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
+ fetchAllDeactivateLogs({ contractAddress, }: {
156
+ contractAddress: string;
157
+ }): Promise<import("../../types").DeactivateMessage[]>;
158
+ claimAMaciRound({ signer, contractAddress, fee, }: {
152
159
  signer: OfflineSigner;
153
160
  contractAddress: string;
161
+ fee?: number | StdFee | 'auto';
154
162
  }): Promise<import("@cosmjs/cosmwasm-stargate").ExecuteResult>;
155
163
  getOracleCertificateConfig(): Promise<import("../oracle-certificate/types").EcosystemsResponse>;
156
164
  /**
@@ -161,11 +169,12 @@ export declare class MACI {
161
169
  * @param amount
162
170
  * @returns
163
171
  */
164
- batchGrantWithBond({ signer, contractAddress, address, amount, }: {
172
+ batchGrantWithBond({ signer, contractAddress, address, amount, fee, }: {
165
173
  signer: OfflineSigner;
166
174
  contractAddress: string;
167
175
  amount: string;
168
176
  address?: string;
177
+ fee?: number | StdFee | 'auto';
169
178
  }): Promise<import("@cosmjs/cosmwasm-stargate").DeliverTxResponse>;
170
179
  /**
171
180
  * Batch revoke with withdraw (for maci)
@@ -174,9 +183,10 @@ export declare class MACI {
174
183
  * @param address
175
184
  * @returns
176
185
  */
177
- batchRevokeWithdraw({ signer, contractAddress, address, }: {
186
+ batchRevokeWithdraw({ signer, contractAddress, address, fee, }: {
178
187
  signer: OfflineSigner;
179
188
  contractAddress: string;
180
189
  address?: string;
190
+ fee?: number | StdFee | 'auto';
181
191
  }): Promise<import("@cosmjs/cosmwasm-stargate").DeliverTxResponse>;
182
192
  }
@@ -4,4 +4,5 @@ export declare class Event {
4
4
  http: Http;
5
5
  constructor(http: Http);
6
6
  getSignUpEventByPubKey(contractAddress: string, pubKey: bigint[]): Promise<SignUpEventsResponse>;
7
+ fetchAllDeactivateLogs(contractAddress: string): Promise<any[]>;
7
8
  }
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
  }
@@ -381,3 +381,12 @@ export type MissRateType = {
381
381
  deactivateCount: number;
382
382
  missRate: number;
383
383
  };
384
+ export type DeactivateMessage = {
385
+ id: string;
386
+ blockHeight: string;
387
+ timestamp: string;
388
+ txHash: string;
389
+ deactivateMessage: string;
390
+ maciContractAddress: string;
391
+ maciOperator: string;
392
+ };
@@ -5,3 +5,20 @@ export declare function isValidAddress(address: string): boolean;
5
5
  * @returns The decimal string representation of the input.
6
6
  */
7
7
  export declare function hexToDecimalString(hexString: string): string;
8
+ /**
9
+ * Converts a hexadecimal string to a BigInt.
10
+ * @param hexString - The hexadecimal string to convert.
11
+ * @returns The BigInt representation of the input.
12
+ */
13
+ export declare function hexToBigInt(hexString: string): bigint;
14
+ /**
15
+ * Parses a public key string into its x and y coordinates.
16
+ * @param publickKey - The public key string to parse (128 characters long).
17
+ * @returns An object containing the x and y coordinates as decimal strings.
18
+ */
19
+ export declare function decompressPublicKey(compressedPubkey: string): {
20
+ x: string;
21
+ y: string;
22
+ };
23
+ export declare function compressPublicKey(decompressedPubkey: any[]): string;
24
+ export declare function transformPubkey(oldPubkey: string): bigint;
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.41",
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 = {
@@ -296,3 +296,26 @@ export const genAddKeyProof = async (
296
296
 
297
297
  return input;
298
298
  };
299
+
300
+ // LIB
301
+ function randomUint256() {
302
+ const buffer = [];
303
+ for (let i = 0; i < 64; i++) {
304
+ buffer.push(
305
+ Math.floor(Math.random() * 256)
306
+ .toString(16)
307
+ .padStart(2, '0')
308
+ );
309
+ }
310
+ return buffer.join('');
311
+ }
312
+
313
+ export const genRandomKey = () => {
314
+ const key = [
315
+ randomUint256(),
316
+ randomUint256(),
317
+ randomUint256(),
318
+ randomUint256(),
319
+ ].join('');
320
+ return ['-----BEGIN MACI KEY-----', key, '-----END MACI KEY-----'].join('\n');
321
+ };
@@ -146,4 +146,34 @@ export class Http {
146
146
  );
147
147
  }
148
148
  }
149
+
150
+ async fetchAllGraphqlPages<T>(query: string, variables: any): Promise<T[]> {
151
+ let hasNextPage = true;
152
+ let offset = 0;
153
+ const limit = 100; // Adjust the limit as needed
154
+ const allData: T[] = [];
155
+
156
+ while (hasNextPage) {
157
+ const response = await this.fetch(this.apiEndpoint, {
158
+ method: 'POST',
159
+ headers: {
160
+ 'Content-Type': 'application/json',
161
+ Accept: 'application/json',
162
+ },
163
+ body: JSON.stringify({
164
+ query,
165
+ variables: { ...variables, limit, offset },
166
+ }),
167
+ }).then((res) => res.json());
168
+
169
+ const key = Object.keys(response.data)[0];
170
+
171
+ const { nodes, pageInfo } = response.data[key];
172
+ allData.push(...nodes);
173
+ hasNextPage = pageInfo.hasNextPage;
174
+ offset += limit;
175
+ }
176
+
177
+ return allData;
178
+ }
149
179
  }
@@ -13,6 +13,7 @@ import {
13
13
  OperatorDelayOperationsResponse,
14
14
  MissRateResponse,
15
15
  SelectiveRoundResponse,
16
+ DeactivateMessage,
16
17
  } from '../../types';
17
18
  import { IndexerParams } from './types';
18
19
  import { Http } from '../http';
@@ -291,4 +292,10 @@ export class Indexer {
291
292
  ): Promise<SignUpEventsResponse> {
292
293
  return await this.event.getSignUpEventByPubKey(contractAddress, pubKey);
293
294
  }
295
+
296
+ async fetchAllDeactivateLogs(
297
+ contractAddress: string
298
+ ): Promise<DeactivateMessage[]> {
299
+ return await this.event.fetchAllDeactivateLogs(contractAddress);
300
+ }
294
301
  }
@@ -1,5 +1,11 @@
1
1
  import { OfflineSigner } from '@cosmjs/proto-signing';
2
- import { Keypair, batchGenMessage, PubKey, stringizing } from '../crypto';
2
+ import {
3
+ Keypair,
4
+ batchGenMessage,
5
+ PubKey,
6
+ stringizing,
7
+ genAddKeyProof,
8
+ } from '../crypto';
3
9
  import { Contract } from '../contract';
4
10
  import { Indexer } from '../indexer';
5
11
  import { OracleCertificate } from '../oracle-certificate';
@@ -444,6 +450,7 @@ export class MACI {
444
450
  maciKeypair,
445
451
  oracleCertificate,
446
452
  gasStation = false,
453
+ fee,
447
454
  }: {
448
455
  signer: OfflineSigner;
449
456
  address?: string;
@@ -454,6 +461,7 @@ export class MACI {
454
461
  signature: string;
455
462
  };
456
463
  gasStation?: boolean;
464
+ fee?: StdFee;
457
465
  }) {
458
466
  try {
459
467
  if (!address) {
@@ -477,6 +485,7 @@ export class MACI {
477
485
  contractAddress,
478
486
  oracleCertificate,
479
487
  gasStation,
488
+ fee,
480
489
  });
481
490
  } else {
482
491
  return await this.signupSimple({
@@ -485,6 +494,7 @@ export class MACI {
485
494
  pubKey: maciKeypair.pubKey,
486
495
  contractAddress,
487
496
  gasStation,
497
+ fee,
488
498
  });
489
499
  }
490
500
  } catch (error) {
@@ -667,15 +677,17 @@ export class MACI {
667
677
  pubKey,
668
678
  contractAddress,
669
679
  gasStation,
680
+ fee,
670
681
  }: {
671
682
  client: SigningCosmWasmClient;
672
683
  address: string;
673
684
  pubKey: PubKey;
674
685
  contractAddress: string;
675
686
  gasStation?: boolean;
687
+ fee?: StdFee;
676
688
  }) {
677
689
  const gasPrice = GasPrice.fromString('100000000000peaka');
678
- const fee = calculateFee(60000000, gasPrice);
690
+ fee = fee || calculateFee(60000000, gasPrice);
679
691
 
680
692
  if (gasStation === true) {
681
693
  const grantFee: StdFee = {
@@ -720,6 +732,7 @@ export class MACI {
720
732
  contractAddress,
721
733
  oracleCertificate,
722
734
  gasStation,
735
+ fee,
723
736
  }: {
724
737
  client: SigningCosmWasmClient;
725
738
  address: string;
@@ -730,9 +743,10 @@ export class MACI {
730
743
  signature: string;
731
744
  };
732
745
  gasStation?: boolean;
746
+ fee?: StdFee;
733
747
  }) {
734
748
  const gasPrice = GasPrice.fromString('100000000000peaka');
735
- const fee = calculateFee(60000000, gasPrice);
749
+ fee = fee || calculateFee(60000000, gasPrice);
736
750
 
737
751
  if (gasStation === true) {
738
752
  const grantFee: StdFee = {
@@ -774,19 +788,138 @@ export class MACI {
774
788
  );
775
789
  }
776
790
 
791
+ // async submitDeactivate({
792
+ // signer,
793
+ // client,
794
+ // address,
795
+ // maciAccount,
796
+ // contractAddress,
797
+ // gasStation,
798
+ // fee,
799
+ // }: {
800
+ // signer: OfflineSigner;
801
+ // client: SigningCosmWasmClient;
802
+ // address?: string;
803
+ // maciAccount: Keypair;
804
+ // contractAddress: string;
805
+ // gasStation: boolean;
806
+ // fee?: StdFee;
807
+ // }) {
808
+ // try {
809
+ // address = address || (await signer.getAccounts())[0].address;
810
+
811
+ // const stateIdx = await this.getStateIdxInc({
812
+ // signer,
813
+ // address,
814
+ // contractAddress,
815
+ // });
816
+
817
+ // const operatorCoordPubKey = await this.getRoundInfo({
818
+ // contractAddress,
819
+ // });
820
+
821
+ // const payload = batchGenMessage(
822
+ // Number(stateIdx),
823
+ // maciAccount,
824
+ // [
825
+ // BigInt(operatorCoordPubKey.coordinatorPubkeyX),
826
+ // BigInt(operatorCoordPubKey.coordinatorPubkeyY),
827
+ // ],
828
+ // [[0, 0]]
829
+ // );
830
+
831
+ // const { msg, encPubkeys } = payload[0];
832
+
833
+ // const gasPrice = GasPrice.fromString('100000000000peaka');
834
+ // fee = fee || calculateFee(20000000, gasPrice);
835
+
836
+ // return client.execute(
837
+ // address,
838
+ // contractAddress,
839
+ // stringizing({
840
+ // publish_deactivate_message: {
841
+ // enc_pub_key: {
842
+ // x: encPubkeys[0],
843
+ // y: encPubkeys[1],
844
+ // },
845
+ // message: {
846
+ // data: msg,
847
+ // },
848
+ // },
849
+ // }),
850
+ // gasStation === true
851
+ // ? {
852
+ // amount: fee.amount,
853
+ // gas: fee.gas,
854
+ // granter: contractAddress,
855
+ // }
856
+ // : fee
857
+ // );
858
+ // } catch (error) {
859
+ // throw Error(`Submit deactivate failed! ${error}`);
860
+ // }
861
+ // }
862
+
863
+ async fetchAllDeactivateLogs({
864
+ contractAddress,
865
+ }: {
866
+ contractAddress: string;
867
+ }) {
868
+ const deactivates =
869
+ await this.indexer.fetchAllDeactivateLogs(contractAddress);
870
+ return deactivates;
871
+ }
872
+
873
+ // async addNewKey({
874
+ // signer,
875
+ // client,
876
+ // address,
877
+ // maciAccount,
878
+ // contractAddress,
879
+ // gasStation,
880
+ // fee,
881
+ // }: {
882
+ // signer: OfflineSigner;
883
+ // client: SigningCosmWasmClient;
884
+ // address?: string;
885
+ // maciAccount: Keypair;
886
+ // contractAddress: string;
887
+ // gasStation: boolean;
888
+ // fee?: StdFee;
889
+ // }) {
890
+ // const deactivates = await this.fetchAllDeactivateLogs({
891
+ // contractAddress,
892
+ // });
893
+
894
+ // const roundInfo = await this.getRoundInfo({
895
+ // contractAddress,
896
+ // });
897
+
898
+ // const inputObj = await genAddKeyProof(4, {
899
+ // coordPubKey: [
900
+ // BigInt(roundInfo.coordinatorPubkeyX),
901
+ // BigInt(roundInfo.coordinatorPubkeyY),
902
+ // ],
903
+ // oldKey: maciAccount,
904
+ // deactivates: deactivates.map((d: any) => d.map(BigInt)),
905
+ // });
906
+ // }
907
+
777
908
  async claimAMaciRound({
778
909
  signer,
779
910
  contractAddress,
911
+ fee = 'auto',
780
912
  }: {
781
913
  signer: OfflineSigner;
782
914
  contractAddress: string;
915
+ fee?: number | StdFee | 'auto';
783
916
  }) {
784
917
  const client = await this.contract.amaciClient({
785
918
  signer,
786
919
  contractAddress,
787
920
  });
788
921
 
789
- return client.claim();
922
+ return client.claim(fee);
790
923
  }
791
924
 
792
925
  async getOracleCertificateConfig() {
@@ -807,11 +940,13 @@ export class MACI {
807
940
  contractAddress,
808
941
  address,
809
942
  amount,
943
+ fee = 'auto',
810
944
  }: {
811
945
  signer: OfflineSigner;
812
946
  contractAddress: string;
813
947
  amount: string;
814
948
  address?: string;
949
+ fee?: number | StdFee | 'auto';
815
950
  }) {
816
951
  const client = await this.contract.contractClient({
817
952
  signer,
@@ -861,7 +996,7 @@ export class MACI {
861
996
  ];
862
997
 
863
998
  try {
864
- const result = await client.signAndBroadcast(address, msgs, 'auto');
999
+ const result = await client.signAndBroadcast(address, msgs, fee);
865
1000
  return result;
866
1001
  } catch (err) {
867
1002
  throw err;
@@ -879,10 +1014,12 @@ export class MACI {
879
1014
  signer,
880
1015
  contractAddress,
881
1016
  address,
1017
+ fee = 'auto',
882
1018
  }: {
883
1019
  signer: OfflineSigner;
884
1020
  contractAddress: string;
885
1021
  address?: string;
1022
+ fee?: number | StdFee | 'auto';
886
1023
  }) {
887
1024
  const client = await this.contract.contractClient({
888
1025
  signer,
@@ -924,7 +1061,7 @@ export class MACI {
924
1061
  ];
925
1062
 
926
1063
  try {
927
- const result = await client.signAndBroadcast(address, msgs, 'auto');
1064
+ const result = await client.signAndBroadcast(address, msgs, fee);
928
1065
  return result;
929
1066
  } catch (err) {
930
1067
  throw err;