@dorafactory/maci-sdk 0.0.27 → 0.0.28
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/browser.d.mts +42 -1
- package/dist/browser.d.ts +42 -1
- package/dist/browser.js +476 -336
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +476 -336
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts +42 -1
- package/dist/index.d.ts +42 -1
- package/dist/index.js +148 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +148 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/libs/const.ts +5 -2
- package/src/libs/errors/types.ts +3 -1
- package/src/libs/indexer/indexer.ts +15 -0
- package/src/libs/maci/maci.ts +29 -5
- package/src/libs/query/round.ts +112 -0
- package/src/maci.ts +15 -0
- package/src/types/index.ts +18 -0
package/dist/index.d.mts
CHANGED
|
@@ -243,6 +243,7 @@ type RoundType = {
|
|
|
243
243
|
voiceCreditAmount: string;
|
|
244
244
|
preDeactivateRoot: string;
|
|
245
245
|
identity: string;
|
|
246
|
+
funds: string;
|
|
246
247
|
operatorLogoUrl?: string;
|
|
247
248
|
operatorMoniker?: string;
|
|
248
249
|
resultsList?: {
|
|
@@ -250,6 +251,7 @@ type RoundType = {
|
|
|
250
251
|
v2: number;
|
|
251
252
|
}[];
|
|
252
253
|
};
|
|
254
|
+
type SelectiveRoundType = Partial<RoundType>;
|
|
253
255
|
type ProofType = {
|
|
254
256
|
nodes: {
|
|
255
257
|
id: string;
|
|
@@ -454,6 +456,9 @@ type TransactionsResponse = SuccessResponse<{
|
|
|
454
456
|
type RoundResponse = SuccessResponse<{
|
|
455
457
|
round: RoundType;
|
|
456
458
|
}> | ErrorResponse;
|
|
459
|
+
type SelectiveRoundResponse = SuccessResponse<{
|
|
460
|
+
round: SelectiveRoundType;
|
|
461
|
+
}> | ErrorResponse;
|
|
457
462
|
type RoundsResponse = SuccessResponse<{
|
|
458
463
|
rounds: {
|
|
459
464
|
pageInfo: {
|
|
@@ -472,6 +477,14 @@ type RoundGraphqlResponse = {
|
|
|
472
477
|
round: RoundType;
|
|
473
478
|
};
|
|
474
479
|
};
|
|
480
|
+
/**
|
|
481
|
+
* GraphQL response type for selective round fields
|
|
482
|
+
*/
|
|
483
|
+
type SelectiveRoundGraphqlResponse = {
|
|
484
|
+
data: {
|
|
485
|
+
round: SelectiveRoundType;
|
|
486
|
+
};
|
|
487
|
+
};
|
|
475
488
|
type RoundsGraphqlResponse = {
|
|
476
489
|
data: {
|
|
477
490
|
rounds: {
|
|
@@ -548,6 +561,13 @@ declare class Round {
|
|
|
548
561
|
http: Http;
|
|
549
562
|
constructor(http: Http);
|
|
550
563
|
getRoundById(address: string): Promise<RoundResponse>;
|
|
564
|
+
/**
|
|
565
|
+
* Get round information with selective fields
|
|
566
|
+
* @param address Round address
|
|
567
|
+
* @param fields Array of fields to return, returns all fields if empty
|
|
568
|
+
* @returns Round information response
|
|
569
|
+
*/
|
|
570
|
+
getRoundWithFields(address: string, fields?: string[]): Promise<SelectiveRoundResponse>;
|
|
551
571
|
getRounds(after: string, limit?: number): Promise<RoundsResponse>;
|
|
552
572
|
getRoundsByCircuitName(circuitName: string, after: string, limit?: number): Promise<RoundsResponse>;
|
|
553
573
|
getRoundsByStatus(status: string, after: string, limit?: number): Promise<RoundsResponse>;
|
|
@@ -616,6 +636,14 @@ declare class Indexer {
|
|
|
616
636
|
* @returns {Promise<RoundResponse>} The round response.
|
|
617
637
|
*/
|
|
618
638
|
getRoundById(id: string): Promise<RoundResponse>;
|
|
639
|
+
/**
|
|
640
|
+
* @method getRoundWithFields
|
|
641
|
+
* @description Get a round by its address with selective fields.
|
|
642
|
+
* @param {string} address - The address of the round.
|
|
643
|
+
* @param {string[]} [fields] - The fields to retrieve.
|
|
644
|
+
* @returns {Promise<SelectiveRoundResponse>} The round response.
|
|
645
|
+
*/
|
|
646
|
+
getRoundWithFields(address: string, fields?: string[]): Promise<SelectiveRoundResponse>;
|
|
619
647
|
/**
|
|
620
648
|
* @method getRounds
|
|
621
649
|
* @description Get multiple rounds.
|
|
@@ -1760,6 +1788,10 @@ declare class MACI {
|
|
|
1760
1788
|
address: string;
|
|
1761
1789
|
contractAddress: string;
|
|
1762
1790
|
}): Promise<FeegrantAllowanceResponse>;
|
|
1791
|
+
hasFeegrant({ address, contractAddress, }: {
|
|
1792
|
+
address: string;
|
|
1793
|
+
contractAddress: string;
|
|
1794
|
+
}): Promise<boolean>;
|
|
1763
1795
|
queryWhitelistBalanceOf({ signer, address, contractAddress, certificate, mode, }: {
|
|
1764
1796
|
signer: OfflineSigner;
|
|
1765
1797
|
address: string;
|
|
@@ -1985,6 +2017,7 @@ interface NetworkConfig {
|
|
|
1985
2017
|
oracleCodeId: number;
|
|
1986
2018
|
oracleWhitelistBackendPubkey: string;
|
|
1987
2019
|
oracleFeegrantOperator: string;
|
|
2020
|
+
oracleCodeIds: string[];
|
|
1988
2021
|
}
|
|
1989
2022
|
declare function getDefaultParams(network?: 'mainnet' | 'testnet'): NetworkConfig;
|
|
1990
2023
|
|
|
@@ -2054,6 +2087,14 @@ declare class MaciClient {
|
|
|
2054
2087
|
* @returns {Promise<RoundResponse>} The round response.
|
|
2055
2088
|
*/
|
|
2056
2089
|
getRoundById(id: string): Promise<RoundResponse>;
|
|
2090
|
+
/**
|
|
2091
|
+
* @method getRoundWithFields
|
|
2092
|
+
* @description Get a round by its address with selective fields.
|
|
2093
|
+
* @param {string} address - The address of the round.
|
|
2094
|
+
* @param {string[]} [fields] - The fields to retrieve.
|
|
2095
|
+
* @returns {Promise<SelectiveRoundResponse>} The round response.
|
|
2096
|
+
*/
|
|
2097
|
+
getRoundWithFields(address: string, fields?: string[]): Promise<SelectiveRoundResponse>;
|
|
2057
2098
|
/**
|
|
2058
2099
|
* @method getRounds
|
|
2059
2100
|
* @description Get multiple rounds.
|
|
@@ -2168,4 +2209,4 @@ declare function decompressPublicKey(compressedPubkey: string): {
|
|
|
2168
2209
|
};
|
|
2169
2210
|
declare function compressPublicKey(decompressedPubkey: any[]): string;
|
|
2170
2211
|
|
|
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 };
|
|
2212
|
+
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
|
@@ -243,6 +243,7 @@ type RoundType = {
|
|
|
243
243
|
voiceCreditAmount: string;
|
|
244
244
|
preDeactivateRoot: string;
|
|
245
245
|
identity: string;
|
|
246
|
+
funds: string;
|
|
246
247
|
operatorLogoUrl?: string;
|
|
247
248
|
operatorMoniker?: string;
|
|
248
249
|
resultsList?: {
|
|
@@ -250,6 +251,7 @@ type RoundType = {
|
|
|
250
251
|
v2: number;
|
|
251
252
|
}[];
|
|
252
253
|
};
|
|
254
|
+
type SelectiveRoundType = Partial<RoundType>;
|
|
253
255
|
type ProofType = {
|
|
254
256
|
nodes: {
|
|
255
257
|
id: string;
|
|
@@ -454,6 +456,9 @@ type TransactionsResponse = SuccessResponse<{
|
|
|
454
456
|
type RoundResponse = SuccessResponse<{
|
|
455
457
|
round: RoundType;
|
|
456
458
|
}> | ErrorResponse;
|
|
459
|
+
type SelectiveRoundResponse = SuccessResponse<{
|
|
460
|
+
round: SelectiveRoundType;
|
|
461
|
+
}> | ErrorResponse;
|
|
457
462
|
type RoundsResponse = SuccessResponse<{
|
|
458
463
|
rounds: {
|
|
459
464
|
pageInfo: {
|
|
@@ -472,6 +477,14 @@ type RoundGraphqlResponse = {
|
|
|
472
477
|
round: RoundType;
|
|
473
478
|
};
|
|
474
479
|
};
|
|
480
|
+
/**
|
|
481
|
+
* GraphQL response type for selective round fields
|
|
482
|
+
*/
|
|
483
|
+
type SelectiveRoundGraphqlResponse = {
|
|
484
|
+
data: {
|
|
485
|
+
round: SelectiveRoundType;
|
|
486
|
+
};
|
|
487
|
+
};
|
|
475
488
|
type RoundsGraphqlResponse = {
|
|
476
489
|
data: {
|
|
477
490
|
rounds: {
|
|
@@ -548,6 +561,13 @@ declare class Round {
|
|
|
548
561
|
http: Http;
|
|
549
562
|
constructor(http: Http);
|
|
550
563
|
getRoundById(address: string): Promise<RoundResponse>;
|
|
564
|
+
/**
|
|
565
|
+
* Get round information with selective fields
|
|
566
|
+
* @param address Round address
|
|
567
|
+
* @param fields Array of fields to return, returns all fields if empty
|
|
568
|
+
* @returns Round information response
|
|
569
|
+
*/
|
|
570
|
+
getRoundWithFields(address: string, fields?: string[]): Promise<SelectiveRoundResponse>;
|
|
551
571
|
getRounds(after: string, limit?: number): Promise<RoundsResponse>;
|
|
552
572
|
getRoundsByCircuitName(circuitName: string, after: string, limit?: number): Promise<RoundsResponse>;
|
|
553
573
|
getRoundsByStatus(status: string, after: string, limit?: number): Promise<RoundsResponse>;
|
|
@@ -616,6 +636,14 @@ declare class Indexer {
|
|
|
616
636
|
* @returns {Promise<RoundResponse>} The round response.
|
|
617
637
|
*/
|
|
618
638
|
getRoundById(id: string): Promise<RoundResponse>;
|
|
639
|
+
/**
|
|
640
|
+
* @method getRoundWithFields
|
|
641
|
+
* @description Get a round by its address with selective fields.
|
|
642
|
+
* @param {string} address - The address of the round.
|
|
643
|
+
* @param {string[]} [fields] - The fields to retrieve.
|
|
644
|
+
* @returns {Promise<SelectiveRoundResponse>} The round response.
|
|
645
|
+
*/
|
|
646
|
+
getRoundWithFields(address: string, fields?: string[]): Promise<SelectiveRoundResponse>;
|
|
619
647
|
/**
|
|
620
648
|
* @method getRounds
|
|
621
649
|
* @description Get multiple rounds.
|
|
@@ -1760,6 +1788,10 @@ declare class MACI {
|
|
|
1760
1788
|
address: string;
|
|
1761
1789
|
contractAddress: string;
|
|
1762
1790
|
}): Promise<FeegrantAllowanceResponse>;
|
|
1791
|
+
hasFeegrant({ address, contractAddress, }: {
|
|
1792
|
+
address: string;
|
|
1793
|
+
contractAddress: string;
|
|
1794
|
+
}): Promise<boolean>;
|
|
1763
1795
|
queryWhitelistBalanceOf({ signer, address, contractAddress, certificate, mode, }: {
|
|
1764
1796
|
signer: OfflineSigner;
|
|
1765
1797
|
address: string;
|
|
@@ -1985,6 +2017,7 @@ interface NetworkConfig {
|
|
|
1985
2017
|
oracleCodeId: number;
|
|
1986
2018
|
oracleWhitelistBackendPubkey: string;
|
|
1987
2019
|
oracleFeegrantOperator: string;
|
|
2020
|
+
oracleCodeIds: string[];
|
|
1988
2021
|
}
|
|
1989
2022
|
declare function getDefaultParams(network?: 'mainnet' | 'testnet'): NetworkConfig;
|
|
1990
2023
|
|
|
@@ -2054,6 +2087,14 @@ declare class MaciClient {
|
|
|
2054
2087
|
* @returns {Promise<RoundResponse>} The round response.
|
|
2055
2088
|
*/
|
|
2056
2089
|
getRoundById(id: string): Promise<RoundResponse>;
|
|
2090
|
+
/**
|
|
2091
|
+
* @method getRoundWithFields
|
|
2092
|
+
* @description Get a round by its address with selective fields.
|
|
2093
|
+
* @param {string} address - The address of the round.
|
|
2094
|
+
* @param {string[]} [fields] - The fields to retrieve.
|
|
2095
|
+
* @returns {Promise<SelectiveRoundResponse>} The round response.
|
|
2096
|
+
*/
|
|
2097
|
+
getRoundWithFields(address: string, fields?: string[]): Promise<SelectiveRoundResponse>;
|
|
2057
2098
|
/**
|
|
2058
2099
|
* @method getRounds
|
|
2059
2100
|
* @description Get multiple rounds.
|
|
@@ -2168,4 +2209,4 @@ declare function decompressPublicKey(compressedPubkey: string): {
|
|
|
2168
2209
|
};
|
|
2169
2210
|
declare function compressPublicKey(decompressedPubkey: any[]): string;
|
|
2170
2211
|
|
|
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 };
|
|
2212
|
+
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:
|
|
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:
|
|
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.
|
|
4934
|
+
const round = await this.indexer.getRoundWithFields(contractAddress, [
|
|
4935
|
+
"voiceCreditAmount"
|
|
4936
|
+
]);
|
|
4811
4937
|
if (!isErrorResponse(round)) {
|
|
4812
|
-
|
|
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.
|
|
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.
|