@dorafactory/maci-sdk 0.0.27 → 0.0.29

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.
package/dist/index.d.mts CHANGED
@@ -250,6 +250,7 @@ type RoundType = {
250
250
  v2: number;
251
251
  }[];
252
252
  };
253
+ type SelectiveRoundType = Partial<RoundType>;
253
254
  type ProofType = {
254
255
  nodes: {
255
256
  id: string;
@@ -454,6 +455,9 @@ type TransactionsResponse = SuccessResponse<{
454
455
  type RoundResponse = SuccessResponse<{
455
456
  round: RoundType;
456
457
  }> | ErrorResponse;
458
+ type SelectiveRoundResponse = SuccessResponse<{
459
+ round: SelectiveRoundType;
460
+ }> | ErrorResponse;
457
461
  type RoundsResponse = SuccessResponse<{
458
462
  rounds: {
459
463
  pageInfo: {
@@ -472,6 +476,14 @@ type RoundGraphqlResponse = {
472
476
  round: RoundType;
473
477
  };
474
478
  };
479
+ /**
480
+ * GraphQL response type for selective round fields
481
+ */
482
+ type SelectiveRoundGraphqlResponse = {
483
+ data: {
484
+ round: SelectiveRoundType;
485
+ };
486
+ };
475
487
  type RoundsGraphqlResponse = {
476
488
  data: {
477
489
  rounds: {
@@ -548,6 +560,13 @@ declare class Round {
548
560
  http: Http;
549
561
  constructor(http: Http);
550
562
  getRoundById(address: string): Promise<RoundResponse>;
563
+ /**
564
+ * Get round information with selective fields
565
+ * @param address Round address
566
+ * @param fields Array of fields to return, returns all fields if empty
567
+ * @returns Round information response
568
+ */
569
+ getRoundWithFields(address: string, fields?: string[]): Promise<SelectiveRoundResponse>;
551
570
  getRounds(after: string, limit?: number): Promise<RoundsResponse>;
552
571
  getRoundsByCircuitName(circuitName: string, after: string, limit?: number): Promise<RoundsResponse>;
553
572
  getRoundsByStatus(status: string, after: string, limit?: number): Promise<RoundsResponse>;
@@ -616,6 +635,14 @@ declare class Indexer {
616
635
  * @returns {Promise<RoundResponse>} The round response.
617
636
  */
618
637
  getRoundById(id: string): Promise<RoundResponse>;
638
+ /**
639
+ * @method getRoundWithFields
640
+ * @description Get a round by its address with selective fields.
641
+ * @param {string} address - The address of the round.
642
+ * @param {string[]} [fields] - The fields to retrieve.
643
+ * @returns {Promise<SelectiveRoundResponse>} The round response.
644
+ */
645
+ getRoundWithFields(address: string, fields?: string[]): Promise<SelectiveRoundResponse>;
619
646
  /**
620
647
  * @method getRounds
621
648
  * @description Get multiple rounds.
@@ -1760,6 +1787,10 @@ declare class MACI {
1760
1787
  address: string;
1761
1788
  contractAddress: string;
1762
1789
  }): Promise<FeegrantAllowanceResponse>;
1790
+ hasFeegrant({ address, contractAddress, }: {
1791
+ address: string;
1792
+ contractAddress: string;
1793
+ }): Promise<boolean>;
1763
1794
  queryWhitelistBalanceOf({ signer, address, contractAddress, certificate, mode, }: {
1764
1795
  signer: OfflineSigner;
1765
1796
  address: string;
@@ -1985,6 +2016,7 @@ interface NetworkConfig {
1985
2016
  oracleCodeId: number;
1986
2017
  oracleWhitelistBackendPubkey: string;
1987
2018
  oracleFeegrantOperator: string;
2019
+ oracleCodeIds: string[];
1988
2020
  }
1989
2021
  declare function getDefaultParams(network?: 'mainnet' | 'testnet'): NetworkConfig;
1990
2022
 
@@ -2054,6 +2086,14 @@ declare class MaciClient {
2054
2086
  * @returns {Promise<RoundResponse>} The round response.
2055
2087
  */
2056
2088
  getRoundById(id: string): Promise<RoundResponse>;
2089
+ /**
2090
+ * @method getRoundWithFields
2091
+ * @description Get a round by its address with selective fields.
2092
+ * @param {string} address - The address of the round.
2093
+ * @param {string[]} [fields] - The fields to retrieve.
2094
+ * @returns {Promise<SelectiveRoundResponse>} The round response.
2095
+ */
2096
+ getRoundWithFields(address: string, fields?: string[]): Promise<SelectiveRoundResponse>;
2057
2097
  /**
2058
2098
  * @method getRounds
2059
2099
  * @description Get multiple rounds.
@@ -2168,4 +2208,4 @@ declare function decompressPublicKey(compressedPubkey: string): {
2168
2208
  };
2169
2209
  declare function compressPublicKey(decompressedPubkey: any[]): string;
2170
2210
 
2171
- export { type Account, type BalanceResponse, type CertificateEcosystem, Circom, Circuit, type CircuitResponse, type CircuitType, type CircuitsCountGraphqlResponse, type CircuitsResponse, type ClientParams, Contract, type ContractParams, type CreateAMaciRoundParams, type CreateMaciRoundParams, type CreateOracleMaciRoundParams, type CreateRoundParams, type ErrorResponse, Event, Http, Indexer, MACI, MaciCertSystemType, MaciCircuitType, MaciClient, MaciRoundType, type MissRateResponse, type MissRateType, type NetworkConfig, Operator, type OperatorDelayOperationsGraphqlResponse, type OperatorDelayOperationsResponse, type OperatorDelayType, type OperatorResponse, type OperatorType, type OperatorsGraphqlResponse, type OperatorsResponse, OracleCertificate, type PrivateKey, Proof, type ProofGraphqlResponse, type ProofResponse, type ProofType, type PublicKey, Round, type RoundGraphqlResponse, type RoundResponse, type RoundType, type RoundsCountGraphqlResponse, type RoundsGraphqlResponse, type RoundsResponse, type SignUpEventType, type SignUpEventsGraphqlResponse, type SignUpEventsResponse, type SuccessResponse, Transaction, type TransactionGraphqlResponse, type TransactionResponse, type TransactionType, type TransactionsGraphqlResponse, type TransactionsResponse, UserAccount, type VoteCountGraphqlResponse, batchGenMessage, circuits, compressPublicKey, decompressPublicKey, genAddKeyProof, genEcdhSharedKey, genKeypair, genMessageFactory, getDefaultParams, hexToDecimalString, isValidAddress, privateKeyFromTxt, stringizing, validator_operator_set };
2211
+ export { type Account, type BalanceResponse, type CertificateEcosystem, Circom, Circuit, type CircuitResponse, type CircuitType, type CircuitsCountGraphqlResponse, type CircuitsResponse, type ClientParams, Contract, type ContractParams, type CreateAMaciRoundParams, type CreateMaciRoundParams, type CreateOracleMaciRoundParams, type CreateRoundParams, type ErrorResponse, Event, Http, Indexer, MACI, MaciCertSystemType, MaciCircuitType, MaciClient, MaciRoundType, type MissRateResponse, type MissRateType, type NetworkConfig, Operator, type OperatorDelayOperationsGraphqlResponse, type OperatorDelayOperationsResponse, type OperatorDelayType, type OperatorResponse, type OperatorType, type OperatorsGraphqlResponse, type OperatorsResponse, OracleCertificate, type PrivateKey, Proof, type ProofGraphqlResponse, type ProofResponse, type ProofType, type PublicKey, Round, type RoundGraphqlResponse, type RoundResponse, type RoundType, type RoundsCountGraphqlResponse, type RoundsGraphqlResponse, type RoundsResponse, type SelectiveRoundGraphqlResponse, type SelectiveRoundResponse, type SelectiveRoundType, type SignUpEventType, type SignUpEventsGraphqlResponse, type SignUpEventsResponse, type SuccessResponse, Transaction, type TransactionGraphqlResponse, type TransactionResponse, type TransactionType, type TransactionsGraphqlResponse, type TransactionsResponse, UserAccount, type VoteCountGraphqlResponse, batchGenMessage, circuits, compressPublicKey, decompressPublicKey, genAddKeyProof, genEcdhSharedKey, genKeypair, genMessageFactory, getDefaultParams, hexToDecimalString, isValidAddress, privateKeyFromTxt, stringizing, validator_operator_set };
package/dist/index.d.ts CHANGED
@@ -250,6 +250,7 @@ type RoundType = {
250
250
  v2: number;
251
251
  }[];
252
252
  };
253
+ type SelectiveRoundType = Partial<RoundType>;
253
254
  type ProofType = {
254
255
  nodes: {
255
256
  id: string;
@@ -454,6 +455,9 @@ type TransactionsResponse = SuccessResponse<{
454
455
  type RoundResponse = SuccessResponse<{
455
456
  round: RoundType;
456
457
  }> | ErrorResponse;
458
+ type SelectiveRoundResponse = SuccessResponse<{
459
+ round: SelectiveRoundType;
460
+ }> | ErrorResponse;
457
461
  type RoundsResponse = SuccessResponse<{
458
462
  rounds: {
459
463
  pageInfo: {
@@ -472,6 +476,14 @@ type RoundGraphqlResponse = {
472
476
  round: RoundType;
473
477
  };
474
478
  };
479
+ /**
480
+ * GraphQL response type for selective round fields
481
+ */
482
+ type SelectiveRoundGraphqlResponse = {
483
+ data: {
484
+ round: SelectiveRoundType;
485
+ };
486
+ };
475
487
  type RoundsGraphqlResponse = {
476
488
  data: {
477
489
  rounds: {
@@ -548,6 +560,13 @@ declare class Round {
548
560
  http: Http;
549
561
  constructor(http: Http);
550
562
  getRoundById(address: string): Promise<RoundResponse>;
563
+ /**
564
+ * Get round information with selective fields
565
+ * @param address Round address
566
+ * @param fields Array of fields to return, returns all fields if empty
567
+ * @returns Round information response
568
+ */
569
+ getRoundWithFields(address: string, fields?: string[]): Promise<SelectiveRoundResponse>;
551
570
  getRounds(after: string, limit?: number): Promise<RoundsResponse>;
552
571
  getRoundsByCircuitName(circuitName: string, after: string, limit?: number): Promise<RoundsResponse>;
553
572
  getRoundsByStatus(status: string, after: string, limit?: number): Promise<RoundsResponse>;
@@ -616,6 +635,14 @@ declare class Indexer {
616
635
  * @returns {Promise<RoundResponse>} The round response.
617
636
  */
618
637
  getRoundById(id: string): Promise<RoundResponse>;
638
+ /**
639
+ * @method getRoundWithFields
640
+ * @description Get a round by its address with selective fields.
641
+ * @param {string} address - The address of the round.
642
+ * @param {string[]} [fields] - The fields to retrieve.
643
+ * @returns {Promise<SelectiveRoundResponse>} The round response.
644
+ */
645
+ getRoundWithFields(address: string, fields?: string[]): Promise<SelectiveRoundResponse>;
619
646
  /**
620
647
  * @method getRounds
621
648
  * @description Get multiple rounds.
@@ -1760,6 +1787,10 @@ declare class MACI {
1760
1787
  address: string;
1761
1788
  contractAddress: string;
1762
1789
  }): Promise<FeegrantAllowanceResponse>;
1790
+ hasFeegrant({ address, contractAddress, }: {
1791
+ address: string;
1792
+ contractAddress: string;
1793
+ }): Promise<boolean>;
1763
1794
  queryWhitelistBalanceOf({ signer, address, contractAddress, certificate, mode, }: {
1764
1795
  signer: OfflineSigner;
1765
1796
  address: string;
@@ -1985,6 +2016,7 @@ interface NetworkConfig {
1985
2016
  oracleCodeId: number;
1986
2017
  oracleWhitelistBackendPubkey: string;
1987
2018
  oracleFeegrantOperator: string;
2019
+ oracleCodeIds: string[];
1988
2020
  }
1989
2021
  declare function getDefaultParams(network?: 'mainnet' | 'testnet'): NetworkConfig;
1990
2022
 
@@ -2054,6 +2086,14 @@ declare class MaciClient {
2054
2086
  * @returns {Promise<RoundResponse>} The round response.
2055
2087
  */
2056
2088
  getRoundById(id: string): Promise<RoundResponse>;
2089
+ /**
2090
+ * @method getRoundWithFields
2091
+ * @description Get a round by its address with selective fields.
2092
+ * @param {string} address - The address of the round.
2093
+ * @param {string[]} [fields] - The fields to retrieve.
2094
+ * @returns {Promise<SelectiveRoundResponse>} The round response.
2095
+ */
2096
+ getRoundWithFields(address: string, fields?: string[]): Promise<SelectiveRoundResponse>;
2057
2097
  /**
2058
2098
  * @method getRounds
2059
2099
  * @description Get multiple rounds.
@@ -2168,4 +2208,4 @@ declare function decompressPublicKey(compressedPubkey: string): {
2168
2208
  };
2169
2209
  declare function compressPublicKey(decompressedPubkey: any[]): string;
2170
2210
 
2171
- export { type Account, type BalanceResponse, type CertificateEcosystem, Circom, Circuit, type CircuitResponse, type CircuitType, type CircuitsCountGraphqlResponse, type CircuitsResponse, type ClientParams, Contract, type ContractParams, type CreateAMaciRoundParams, type CreateMaciRoundParams, type CreateOracleMaciRoundParams, type CreateRoundParams, type ErrorResponse, Event, Http, Indexer, MACI, MaciCertSystemType, MaciCircuitType, MaciClient, MaciRoundType, type MissRateResponse, type MissRateType, type NetworkConfig, Operator, type OperatorDelayOperationsGraphqlResponse, type OperatorDelayOperationsResponse, type OperatorDelayType, type OperatorResponse, type OperatorType, type OperatorsGraphqlResponse, type OperatorsResponse, OracleCertificate, type PrivateKey, Proof, type ProofGraphqlResponse, type ProofResponse, type ProofType, type PublicKey, Round, type RoundGraphqlResponse, type RoundResponse, type RoundType, type RoundsCountGraphqlResponse, type RoundsGraphqlResponse, type RoundsResponse, type SignUpEventType, type SignUpEventsGraphqlResponse, type SignUpEventsResponse, type SuccessResponse, Transaction, type TransactionGraphqlResponse, type TransactionResponse, type TransactionType, type TransactionsGraphqlResponse, type TransactionsResponse, UserAccount, type VoteCountGraphqlResponse, batchGenMessage, circuits, compressPublicKey, decompressPublicKey, genAddKeyProof, genEcdhSharedKey, genKeypair, genMessageFactory, getDefaultParams, hexToDecimalString, isValidAddress, privateKeyFromTxt, stringizing, validator_operator_set };
2211
+ export { type Account, type BalanceResponse, type CertificateEcosystem, Circom, Circuit, type CircuitResponse, type CircuitType, type CircuitsCountGraphqlResponse, type CircuitsResponse, type ClientParams, Contract, type ContractParams, type CreateAMaciRoundParams, type CreateMaciRoundParams, type CreateOracleMaciRoundParams, type CreateRoundParams, type ErrorResponse, Event, Http, Indexer, MACI, MaciCertSystemType, MaciCircuitType, MaciClient, MaciRoundType, type MissRateResponse, type MissRateType, type NetworkConfig, Operator, type OperatorDelayOperationsGraphqlResponse, type OperatorDelayOperationsResponse, type OperatorDelayType, type OperatorResponse, type OperatorType, type OperatorsGraphqlResponse, type OperatorsResponse, OracleCertificate, type PrivateKey, Proof, type ProofGraphqlResponse, type ProofResponse, type ProofType, type PublicKey, Round, type RoundGraphqlResponse, type RoundResponse, type RoundType, type RoundsCountGraphqlResponse, type RoundsGraphqlResponse, type RoundsResponse, type SelectiveRoundGraphqlResponse, type SelectiveRoundResponse, type SelectiveRoundType, type SignUpEventType, type SignUpEventsGraphqlResponse, type SignUpEventsResponse, type SuccessResponse, Transaction, type TransactionGraphqlResponse, type TransactionResponse, type TransactionType, type TransactionsGraphqlResponse, type TransactionsResponse, UserAccount, type VoteCountGraphqlResponse, batchGenMessage, circuits, compressPublicKey, decompressPublicKey, genAddKeyProof, genEcdhSharedKey, genKeypair, genMessageFactory, getDefaultParams, hexToDecimalString, isValidAddress, privateKeyFromTxt, stringizing, validator_operator_set };
package/dist/index.js CHANGED
@@ -302,7 +302,9 @@ var ERROR = {
302
302
  ERROR_ROUNDS_NOT_FOUND: "ERROR_ROUNDS_NOT_FOUND",
303
303
  ERROR_TRANSACTION_NOT_FOUND: "ERROR_TRANSACTION_NOT_FOUND",
304
304
  ERROR_TRANSACTIONS_NOT_FOUND: "ERROR_TRANSACTIONS_NOT_FOUND",
305
- ERROR_SIGN_UP_EVENTS_NOT_FOUND: "ERROR_SIGN_UP_EVENTS_NOT_FOUND"
305
+ ERROR_SIGN_UP_EVENTS_NOT_FOUND: "ERROR_SIGN_UP_EVENTS_NOT_FOUND",
306
+ ERROR_INVALID_FIELDS: "ERROR_INVALID_FIELDS",
307
+ ERROR_CLAIM_INFOS_NOT_FOUND: "ERROR_CLAIM_INFOS_NOT_FOUND"
306
308
  };
307
309
 
308
310
  // src/libs/query/account.ts
@@ -482,10 +484,11 @@ function getDefaultParams(network = "mainnet") {
482
484
  registryAddress: "dora1smg5qp5trjdkcekdjssqpjehdjf6n4cjss0clyvqcud3t3u3948s8rmgg4",
483
485
  maciCodeId: 106,
484
486
  // oracleCodeId: 116,// 9-4-3-625
485
- oracleCodeId: 117,
487
+ oracleCodeId: 119,
486
488
  // 6-3-3-125
487
489
  oracleWhitelistBackendPubkey: "A61YtCv2ibMZmDeM02nEElil8wlHx1tLKogBk5dPgf/Q",
488
- oracleFeegrantOperator: "dora16s9tljk8dy9ae335yvyzlm8gvkypx9228q8pq8"
490
+ oracleFeegrantOperator: "dora16s9tljk8dy9ae335yvyzlm8gvkypx9228q8pq8",
491
+ oracleCodeIds: ["101", "116", "117", "119"]
489
492
  };
490
493
  case "testnet":
491
494
  return {
@@ -498,10 +501,11 @@ function getDefaultParams(network = "mainnet") {
498
501
  registryAddress: "dora13c8aecstyxrhax9znvvh5zey89edrmd2k5va57pxvpe3fxtfsfeqlhsjnd",
499
502
  maciCodeId: 107,
500
503
  // oracleCodeId: 113, // 9-4-3-625
501
- oracleCodeId: 115,
504
+ oracleCodeId: 123,
502
505
  // 6-3-3-125
503
506
  oracleWhitelistBackendPubkey: "AoYo/zENN/JquagPdG0/NMbWBBYxOM8BVN677mBXJKJQ",
504
- oracleFeegrantOperator: "dora1xp0twdzsdeq4qg3c64v66552deax8zmvq4zw78"
507
+ oracleFeegrantOperator: "dora1xp0twdzsdeq4qg3c64v66552deax8zmvq4zw78",
508
+ oracleCodeIds: ["102", "105", "108", "110", "113", "115", "123"]
505
509
  };
506
510
  }
507
511
  }
@@ -1211,6 +1215,102 @@ var Round = class {
1211
1215
  return handleError(error);
1212
1216
  }
1213
1217
  }
1218
+ /**
1219
+ * Get round information with selective fields
1220
+ * @param address Round address
1221
+ * @param fields Array of fields to return, returns all fields if empty
1222
+ * @returns Round information response
1223
+ */
1224
+ async getRoundWithFields(address, fields) {
1225
+ try {
1226
+ if (!isValidAddress(address)) {
1227
+ return {
1228
+ code: 400,
1229
+ error: {
1230
+ message: "Invalid round address format",
1231
+ type: ERROR.ERROR_ROUND_INVALID_ADDRESS
1232
+ }
1233
+ };
1234
+ }
1235
+ const defaultFields = [
1236
+ "id",
1237
+ "blockHeight",
1238
+ "txHash",
1239
+ "caller",
1240
+ "admin",
1241
+ "operator",
1242
+ "contractAddress",
1243
+ "circuitName",
1244
+ "timestamp",
1245
+ "votingStart",
1246
+ "votingEnd",
1247
+ "status",
1248
+ "period",
1249
+ "actionType",
1250
+ "roundTitle",
1251
+ "roundDescription",
1252
+ "roundLink",
1253
+ "coordinatorPubkeyX",
1254
+ "coordinatorPubkeyY",
1255
+ "voteOptionMap",
1256
+ "results",
1257
+ "allResult",
1258
+ "gasStationEnable",
1259
+ "totalGrant",
1260
+ "baseGrant",
1261
+ "totalBond",
1262
+ "circuitType",
1263
+ "circuitPower",
1264
+ "certificationSystem",
1265
+ "codeId",
1266
+ "maciType",
1267
+ "voiceCreditAmount",
1268
+ "preDeactivateRoot",
1269
+ "identity"
1270
+ // 'funds',
1271
+ ];
1272
+ if (fields && fields.length > 0) {
1273
+ const invalidFields = fields.filter(
1274
+ (field) => !defaultFields.includes(field)
1275
+ );
1276
+ if (invalidFields.length > 0) {
1277
+ return {
1278
+ code: 400,
1279
+ error: {
1280
+ message: `Invalid fields: ${invalidFields.join(", ")}`,
1281
+ type: ERROR.ERROR_INVALID_FIELDS
1282
+ }
1283
+ };
1284
+ }
1285
+ }
1286
+ const selectedFields = fields && fields.length > 0 ? fields : defaultFields;
1287
+ const fieldString = selectedFields.join("\n ");
1288
+ const ROUND_QUERY = `query {
1289
+ round(id: "${address}") {
1290
+ ${fieldString}
1291
+ }
1292
+ }`;
1293
+ const response = await this.http.fetchGraphql(
1294
+ ROUND_QUERY,
1295
+ ""
1296
+ );
1297
+ if (!response || !response.data || !response.data.round) {
1298
+ return {
1299
+ code: 404,
1300
+ error: {
1301
+ message: `No round data found for address ${address}`,
1302
+ type: ERROR.ERROR_ROUND_NOT_FOUND
1303
+ }
1304
+ };
1305
+ }
1306
+ return {
1307
+ code: 200,
1308
+ data: response.data
1309
+ };
1310
+ } catch (error) {
1311
+ return handleError(error);
1312
+ }
1313
+ }
1214
1314
  async getRounds(after, limit) {
1215
1315
  try {
1216
1316
  const ROUND_HISTORY_QUERY = `query ($limit: Int, $after: Cursor) {
@@ -1878,6 +1978,16 @@ var Indexer = class {
1878
1978
  async getRoundById(id) {
1879
1979
  return await this.round.getRoundById(id);
1880
1980
  }
1981
+ /**
1982
+ * @method getRoundWithFields
1983
+ * @description Get a round by its address with selective fields.
1984
+ * @param {string} address - The address of the round.
1985
+ * @param {string[]} [fields] - The fields to retrieve.
1986
+ * @returns {Promise<SelectiveRoundResponse>} The round response.
1987
+ */
1988
+ async getRoundWithFields(address, fields) {
1989
+ return await this.round.getRoundWithFields(address, fields);
1990
+ }
1881
1991
  /**
1882
1992
  * @method getRounds
1883
1993
  * @description Get multiple rounds.
@@ -4792,6 +4902,20 @@ var MACI = class {
4792
4902
  };
4793
4903
  }
4794
4904
  }
4905
+ async hasFeegrant({
4906
+ address,
4907
+ contractAddress
4908
+ }) {
4909
+ try {
4910
+ const response = await this.oracleCertificate.feegrantAllowance(
4911
+ contractAddress,
4912
+ address
4913
+ );
4914
+ return response.spend_limit.length > 0;
4915
+ } catch (error) {
4916
+ return false;
4917
+ }
4918
+ }
4795
4919
  // only for maci and oracle maci, amaci will set the voice credit when deploy the contract
4796
4920
  async queryWhitelistBalanceOf({
4797
4921
  signer,
@@ -4807,9 +4931,15 @@ var MACI = class {
4807
4931
  contractAddress
4808
4932
  });
4809
4933
  if (isWhiteListed) {
4810
- const round = await this.indexer.getRoundById(contractAddress);
4934
+ const round = await this.indexer.getRoundWithFields(contractAddress, [
4935
+ "voiceCreditAmount"
4936
+ ]);
4811
4937
  if (!isErrorResponse(round)) {
4812
- return round.data.round.voiceCreditAmount;
4938
+ if (round.data.round.voiceCreditAmount) {
4939
+ return round.data.round.voiceCreditAmount;
4940
+ } else {
4941
+ return "0";
4942
+ }
4813
4943
  } else {
4814
4944
  throw new Error(
4815
4945
  `Failed to query amaci voice credit: ${round.error.type} ${round.error.message}`
@@ -4867,7 +4997,7 @@ var MACI = class {
4867
4997
  return snapshotHeight;
4868
4998
  }
4869
4999
  async getRoundInfo({ contractAddress }) {
4870
- const roundInfo = await this.indexer.getRoundById(contractAddress);
5000
+ const roundInfo = await this.indexer.getRoundWithFields(contractAddress);
4871
5001
  if (isErrorResponse(roundInfo)) {
4872
5002
  throw new Error(
4873
5003
  `Failed to get round info: ${roundInfo.error.type} ${roundInfo.error.message}`
@@ -5362,6 +5492,16 @@ var MaciClient2 = class {
5362
5492
  async getRoundById(id) {
5363
5493
  return await this.indexer.round.getRoundById(id);
5364
5494
  }
5495
+ /**
5496
+ * @method getRoundWithFields
5497
+ * @description Get a round by its address with selective fields.
5498
+ * @param {string} address - The address of the round.
5499
+ * @param {string[]} [fields] - The fields to retrieve.
5500
+ * @returns {Promise<SelectiveRoundResponse>} The round response.
5501
+ */
5502
+ async getRoundWithFields(address, fields) {
5503
+ return await this.indexer.round.getRoundWithFields(address, fields);
5504
+ }
5365
5505
  /**
5366
5506
  * @method getRounds
5367
5507
  * @description Get multiple rounds.