@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/README.md +5 -3
- package/dist/browser.d.mts +41 -1
- package/dist/browser.d.ts +41 -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 +41 -1
- package/dist/index.d.ts +41 -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 +6 -6
- 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/README.md
CHANGED
|
@@ -161,14 +161,16 @@ const certificate = await client.maci.requestOracleCertificate({
|
|
|
161
161
|
});
|
|
162
162
|
|
|
163
163
|
// 3. Check Gas Station status
|
|
164
|
-
let
|
|
164
|
+
let hasFeegrant = await client.maci.hasFeegrant({
|
|
165
|
+
address,
|
|
165
166
|
contractAddress: 'dora1...',
|
|
166
167
|
});
|
|
167
168
|
|
|
168
169
|
// Wait for Gas Station to be enabled
|
|
169
|
-
while (!
|
|
170
|
+
while (!hasFeegrant) {
|
|
170
171
|
await delay(1000); // Delay 1 second
|
|
171
|
-
|
|
172
|
+
hasFeegrant = await client.maci.hasFeegrant({
|
|
173
|
+
address,
|
|
172
174
|
contractAddress: 'dora1...',
|
|
173
175
|
});
|
|
174
176
|
}
|
package/dist/browser.d.mts
CHANGED
|
@@ -249,6 +249,7 @@ type RoundType = {
|
|
|
249
249
|
v2: number;
|
|
250
250
|
}[];
|
|
251
251
|
};
|
|
252
|
+
type SelectiveRoundType = Partial<RoundType>;
|
|
252
253
|
type ProofType = {
|
|
253
254
|
nodes: {
|
|
254
255
|
id: string;
|
|
@@ -453,6 +454,9 @@ type TransactionsResponse = SuccessResponse<{
|
|
|
453
454
|
type RoundResponse = SuccessResponse<{
|
|
454
455
|
round: RoundType;
|
|
455
456
|
}> | ErrorResponse;
|
|
457
|
+
type SelectiveRoundResponse = SuccessResponse<{
|
|
458
|
+
round: SelectiveRoundType;
|
|
459
|
+
}> | ErrorResponse;
|
|
456
460
|
type RoundsResponse = SuccessResponse<{
|
|
457
461
|
rounds: {
|
|
458
462
|
pageInfo: {
|
|
@@ -471,6 +475,14 @@ type RoundGraphqlResponse = {
|
|
|
471
475
|
round: RoundType;
|
|
472
476
|
};
|
|
473
477
|
};
|
|
478
|
+
/**
|
|
479
|
+
* GraphQL response type for selective round fields
|
|
480
|
+
*/
|
|
481
|
+
type SelectiveRoundGraphqlResponse = {
|
|
482
|
+
data: {
|
|
483
|
+
round: SelectiveRoundType;
|
|
484
|
+
};
|
|
485
|
+
};
|
|
474
486
|
type RoundsGraphqlResponse = {
|
|
475
487
|
data: {
|
|
476
488
|
rounds: {
|
|
@@ -547,6 +559,13 @@ declare class Round {
|
|
|
547
559
|
http: Http;
|
|
548
560
|
constructor(http: Http);
|
|
549
561
|
getRoundById(address: string): Promise<RoundResponse>;
|
|
562
|
+
/**
|
|
563
|
+
* Get round information with selective fields
|
|
564
|
+
* @param address Round address
|
|
565
|
+
* @param fields Array of fields to return, returns all fields if empty
|
|
566
|
+
* @returns Round information response
|
|
567
|
+
*/
|
|
568
|
+
getRoundWithFields(address: string, fields?: string[]): Promise<SelectiveRoundResponse>;
|
|
550
569
|
getRounds(after: string, limit?: number): Promise<RoundsResponse>;
|
|
551
570
|
getRoundsByCircuitName(circuitName: string, after: string, limit?: number): Promise<RoundsResponse>;
|
|
552
571
|
getRoundsByStatus(status: string, after: string, limit?: number): Promise<RoundsResponse>;
|
|
@@ -615,6 +634,14 @@ declare class Indexer {
|
|
|
615
634
|
* @returns {Promise<RoundResponse>} The round response.
|
|
616
635
|
*/
|
|
617
636
|
getRoundById(id: string): Promise<RoundResponse>;
|
|
637
|
+
/**
|
|
638
|
+
* @method getRoundWithFields
|
|
639
|
+
* @description Get a round by its address with selective fields.
|
|
640
|
+
* @param {string} address - The address of the round.
|
|
641
|
+
* @param {string[]} [fields] - The fields to retrieve.
|
|
642
|
+
* @returns {Promise<SelectiveRoundResponse>} The round response.
|
|
643
|
+
*/
|
|
644
|
+
getRoundWithFields(address: string, fields?: string[]): Promise<SelectiveRoundResponse>;
|
|
618
645
|
/**
|
|
619
646
|
* @method getRounds
|
|
620
647
|
* @description Get multiple rounds.
|
|
@@ -1759,6 +1786,10 @@ declare class MACI {
|
|
|
1759
1786
|
address: string;
|
|
1760
1787
|
contractAddress: string;
|
|
1761
1788
|
}): Promise<FeegrantAllowanceResponse>;
|
|
1789
|
+
hasFeegrant({ address, contractAddress, }: {
|
|
1790
|
+
address: string;
|
|
1791
|
+
contractAddress: string;
|
|
1792
|
+
}): Promise<boolean>;
|
|
1762
1793
|
queryWhitelistBalanceOf({ signer, address, contractAddress, certificate, mode, }: {
|
|
1763
1794
|
signer: OfflineSigner;
|
|
1764
1795
|
address: string;
|
|
@@ -1984,6 +2015,7 @@ interface NetworkConfig {
|
|
|
1984
2015
|
oracleCodeId: number;
|
|
1985
2016
|
oracleWhitelistBackendPubkey: string;
|
|
1986
2017
|
oracleFeegrantOperator: string;
|
|
2018
|
+
oracleCodeIds: string[];
|
|
1987
2019
|
}
|
|
1988
2020
|
declare function getDefaultParams(network?: 'mainnet' | 'testnet'): NetworkConfig;
|
|
1989
2021
|
|
|
@@ -2053,6 +2085,14 @@ declare class MaciClient {
|
|
|
2053
2085
|
* @returns {Promise<RoundResponse>} The round response.
|
|
2054
2086
|
*/
|
|
2055
2087
|
getRoundById(id: string): Promise<RoundResponse>;
|
|
2088
|
+
/**
|
|
2089
|
+
* @method getRoundWithFields
|
|
2090
|
+
* @description Get a round by its address with selective fields.
|
|
2091
|
+
* @param {string} address - The address of the round.
|
|
2092
|
+
* @param {string[]} [fields] - The fields to retrieve.
|
|
2093
|
+
* @returns {Promise<SelectiveRoundResponse>} The round response.
|
|
2094
|
+
*/
|
|
2095
|
+
getRoundWithFields(address: string, fields?: string[]): Promise<SelectiveRoundResponse>;
|
|
2056
2096
|
/**
|
|
2057
2097
|
* @method getRounds
|
|
2058
2098
|
* @description Get multiple rounds.
|
|
@@ -2167,4 +2207,4 @@ declare function decompressPublicKey(compressedPubkey: string): {
|
|
|
2167
2207
|
};
|
|
2168
2208
|
declare function compressPublicKey(decompressedPubkey: any[]): string;
|
|
2169
2209
|
|
|
2170
|
-
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 };
|
|
2210
|
+
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/browser.d.ts
CHANGED
|
@@ -249,6 +249,7 @@ type RoundType = {
|
|
|
249
249
|
v2: number;
|
|
250
250
|
}[];
|
|
251
251
|
};
|
|
252
|
+
type SelectiveRoundType = Partial<RoundType>;
|
|
252
253
|
type ProofType = {
|
|
253
254
|
nodes: {
|
|
254
255
|
id: string;
|
|
@@ -453,6 +454,9 @@ type TransactionsResponse = SuccessResponse<{
|
|
|
453
454
|
type RoundResponse = SuccessResponse<{
|
|
454
455
|
round: RoundType;
|
|
455
456
|
}> | ErrorResponse;
|
|
457
|
+
type SelectiveRoundResponse = SuccessResponse<{
|
|
458
|
+
round: SelectiveRoundType;
|
|
459
|
+
}> | ErrorResponse;
|
|
456
460
|
type RoundsResponse = SuccessResponse<{
|
|
457
461
|
rounds: {
|
|
458
462
|
pageInfo: {
|
|
@@ -471,6 +475,14 @@ type RoundGraphqlResponse = {
|
|
|
471
475
|
round: RoundType;
|
|
472
476
|
};
|
|
473
477
|
};
|
|
478
|
+
/**
|
|
479
|
+
* GraphQL response type for selective round fields
|
|
480
|
+
*/
|
|
481
|
+
type SelectiveRoundGraphqlResponse = {
|
|
482
|
+
data: {
|
|
483
|
+
round: SelectiveRoundType;
|
|
484
|
+
};
|
|
485
|
+
};
|
|
474
486
|
type RoundsGraphqlResponse = {
|
|
475
487
|
data: {
|
|
476
488
|
rounds: {
|
|
@@ -547,6 +559,13 @@ declare class Round {
|
|
|
547
559
|
http: Http;
|
|
548
560
|
constructor(http: Http);
|
|
549
561
|
getRoundById(address: string): Promise<RoundResponse>;
|
|
562
|
+
/**
|
|
563
|
+
* Get round information with selective fields
|
|
564
|
+
* @param address Round address
|
|
565
|
+
* @param fields Array of fields to return, returns all fields if empty
|
|
566
|
+
* @returns Round information response
|
|
567
|
+
*/
|
|
568
|
+
getRoundWithFields(address: string, fields?: string[]): Promise<SelectiveRoundResponse>;
|
|
550
569
|
getRounds(after: string, limit?: number): Promise<RoundsResponse>;
|
|
551
570
|
getRoundsByCircuitName(circuitName: string, after: string, limit?: number): Promise<RoundsResponse>;
|
|
552
571
|
getRoundsByStatus(status: string, after: string, limit?: number): Promise<RoundsResponse>;
|
|
@@ -615,6 +634,14 @@ declare class Indexer {
|
|
|
615
634
|
* @returns {Promise<RoundResponse>} The round response.
|
|
616
635
|
*/
|
|
617
636
|
getRoundById(id: string): Promise<RoundResponse>;
|
|
637
|
+
/**
|
|
638
|
+
* @method getRoundWithFields
|
|
639
|
+
* @description Get a round by its address with selective fields.
|
|
640
|
+
* @param {string} address - The address of the round.
|
|
641
|
+
* @param {string[]} [fields] - The fields to retrieve.
|
|
642
|
+
* @returns {Promise<SelectiveRoundResponse>} The round response.
|
|
643
|
+
*/
|
|
644
|
+
getRoundWithFields(address: string, fields?: string[]): Promise<SelectiveRoundResponse>;
|
|
618
645
|
/**
|
|
619
646
|
* @method getRounds
|
|
620
647
|
* @description Get multiple rounds.
|
|
@@ -1759,6 +1786,10 @@ declare class MACI {
|
|
|
1759
1786
|
address: string;
|
|
1760
1787
|
contractAddress: string;
|
|
1761
1788
|
}): Promise<FeegrantAllowanceResponse>;
|
|
1789
|
+
hasFeegrant({ address, contractAddress, }: {
|
|
1790
|
+
address: string;
|
|
1791
|
+
contractAddress: string;
|
|
1792
|
+
}): Promise<boolean>;
|
|
1762
1793
|
queryWhitelistBalanceOf({ signer, address, contractAddress, certificate, mode, }: {
|
|
1763
1794
|
signer: OfflineSigner;
|
|
1764
1795
|
address: string;
|
|
@@ -1984,6 +2015,7 @@ interface NetworkConfig {
|
|
|
1984
2015
|
oracleCodeId: number;
|
|
1985
2016
|
oracleWhitelistBackendPubkey: string;
|
|
1986
2017
|
oracleFeegrantOperator: string;
|
|
2018
|
+
oracleCodeIds: string[];
|
|
1987
2019
|
}
|
|
1988
2020
|
declare function getDefaultParams(network?: 'mainnet' | 'testnet'): NetworkConfig;
|
|
1989
2021
|
|
|
@@ -2053,6 +2085,14 @@ declare class MaciClient {
|
|
|
2053
2085
|
* @returns {Promise<RoundResponse>} The round response.
|
|
2054
2086
|
*/
|
|
2055
2087
|
getRoundById(id: string): Promise<RoundResponse>;
|
|
2088
|
+
/**
|
|
2089
|
+
* @method getRoundWithFields
|
|
2090
|
+
* @description Get a round by its address with selective fields.
|
|
2091
|
+
* @param {string} address - The address of the round.
|
|
2092
|
+
* @param {string[]} [fields] - The fields to retrieve.
|
|
2093
|
+
* @returns {Promise<SelectiveRoundResponse>} The round response.
|
|
2094
|
+
*/
|
|
2095
|
+
getRoundWithFields(address: string, fields?: string[]): Promise<SelectiveRoundResponse>;
|
|
2056
2096
|
/**
|
|
2057
2097
|
* @method getRounds
|
|
2058
2098
|
* @description Get multiple rounds.
|
|
@@ -2167,4 +2207,4 @@ declare function decompressPublicKey(compressedPubkey: string): {
|
|
|
2167
2207
|
};
|
|
2168
2208
|
declare function compressPublicKey(decompressedPubkey: any[]): string;
|
|
2169
2209
|
|
|
2170
|
-
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 };
|
|
2210
|
+
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 };
|