@dorafactory/maci-sdk 0.0.1
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 +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +4157 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4123 -0
- package/dist/index.mjs.map +1 -0
- package/dist/libs/const.d.ts +117 -0
- package/dist/libs/contract/config.d.ts +29 -0
- package/dist/libs/contract/contract.d.ts +37 -0
- package/dist/libs/contract/index.d.ts +1 -0
- package/dist/libs/contract/ts/AMaci.client.d.ts +216 -0
- package/dist/libs/contract/ts/AMaci.types.d.ts +203 -0
- package/dist/libs/contract/ts/Maci.client.d.ts +206 -0
- package/dist/libs/contract/ts/Maci.types.d.ts +217 -0
- package/dist/libs/contract/ts/OracleMaci.client.d.ts +206 -0
- package/dist/libs/contract/ts/OracleMaci.types.d.ts +253 -0
- package/dist/libs/contract/ts/Registry.client.d.ts +128 -0
- package/dist/libs/contract/ts/Registry.types.d.ts +110 -0
- package/dist/libs/contract/types.d.ts +50 -0
- package/dist/libs/contract/utils.d.ts +67 -0
- package/dist/libs/contract/vars.d.ts +65 -0
- package/dist/libs/errors/index.d.ts +28 -0
- package/dist/libs/errors/types.d.ts +14 -0
- package/dist/libs/http/http.d.ts +16 -0
- package/dist/libs/http/index.d.ts +1 -0
- package/dist/libs/index.d.ts +4 -0
- package/dist/libs/indexer/index.d.ts +1 -0
- package/dist/libs/indexer/indexer.d.ts +133 -0
- package/dist/libs/indexer/types.d.ts +7 -0
- package/dist/libs/query/account.d.ts +7 -0
- package/dist/libs/query/circuit.d.ts +8 -0
- package/dist/libs/query/index.d.ts +6 -0
- package/dist/libs/query/operator.d.ts +9 -0
- package/dist/libs/query/proof.d.ts +7 -0
- package/dist/libs/query/round.d.ts +11 -0
- package/dist/libs/query/transaction.d.ts +9 -0
- package/dist/maci.d.ts +151 -0
- package/dist/types/index.d.ts +254 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +154 -0
- package/src/index.ts +11 -0
- package/src/libs/const.ts +196 -0
- package/src/libs/contract/config.ts +117 -0
- package/src/libs/contract/contract.ts +330 -0
- package/src/libs/contract/index.ts +1 -0
- package/src/libs/contract/ts/AMaci.client.ts +893 -0
- package/src/libs/contract/ts/AMaci.types.ts +252 -0
- package/src/libs/contract/ts/Maci.client.ts +906 -0
- package/src/libs/contract/ts/Maci.types.ts +263 -0
- package/src/libs/contract/ts/OracleMaci.client.ts +561 -0
- package/src/libs/contract/ts/OracleMaci.types.ts +254 -0
- package/src/libs/contract/ts/Registry.client.ts +466 -0
- package/src/libs/contract/ts/Registry.types.ts +127 -0
- package/src/libs/contract/types.ts +57 -0
- package/src/libs/contract/utils.ts +175 -0
- package/src/libs/contract/vars.ts +420 -0
- package/src/libs/errors/index.ts +122 -0
- package/src/libs/errors/types.ts +14 -0
- package/src/libs/http/http.ts +152 -0
- package/src/libs/http/index.ts +1 -0
- package/src/libs/index.ts +4 -0
- package/src/libs/indexer/index.ts +1 -0
- package/src/libs/indexer/indexer.ts +240 -0
- package/src/libs/indexer/types.ts +8 -0
- package/src/libs/query/account.ts +39 -0
- package/src/libs/query/circuit.ts +99 -0
- package/src/libs/query/index.ts +6 -0
- package/src/libs/query/operator.ts +263 -0
- package/src/libs/query/proof.ts +76 -0
- package/src/libs/query/round.ts +533 -0
- package/src/libs/query/transaction.ts +204 -0
- package/src/maci.ts +313 -0
- package/src/types/index.ts +301 -0
- package/src/utils/index.ts +44 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const ERROR: {
|
|
2
|
+
ERROR_ADDRESS_NOT_FOUND: string;
|
|
3
|
+
ERROR_CIRCUIT_NOT_FOUND: string;
|
|
4
|
+
ERROR_OPERATOR_INVALID_ADDRESS: string;
|
|
5
|
+
ERROR_OPERATOR_NOT_FOUND: string;
|
|
6
|
+
ERROR_OPERATORS_NOT_FOUND: string;
|
|
7
|
+
ERROR_PROOF_NOT_FOUND: string;
|
|
8
|
+
ERROR_ROUND_INVALID_ADDRESS: string;
|
|
9
|
+
ERROR_ROUND_INVALID_STATUS: string;
|
|
10
|
+
ERROR_ROUND_NOT_FOUND: string;
|
|
11
|
+
ERROR_ROUNDS_NOT_FOUND: string;
|
|
12
|
+
ERROR_TRANSACTION_NOT_FOUND: string;
|
|
13
|
+
ERROR_TRANSACTIONS_NOT_FOUND: string;
|
|
14
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type FetchOptions = RequestInit & {
|
|
2
|
+
next?: {
|
|
3
|
+
revalidate?: boolean | number;
|
|
4
|
+
};
|
|
5
|
+
};
|
|
6
|
+
export declare class Http {
|
|
7
|
+
private customFetch?;
|
|
8
|
+
private apiEndpoint;
|
|
9
|
+
private restEndpoint;
|
|
10
|
+
private defaultOptions?;
|
|
11
|
+
constructor(apiEndpoint: string, restEndpoint: string, customFetch?: typeof fetch | undefined, defaultOptions?: FetchOptions);
|
|
12
|
+
private getFetch;
|
|
13
|
+
fetch(url: string): Promise<Response>;
|
|
14
|
+
fetchGraphql<T>(query: string, after: string, limit?: number | null): Promise<T>;
|
|
15
|
+
fetchRest(path: string): Promise<any>;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Http } from './http';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Indexer } from './indexer';
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { BalanceResponse, RoundResponse, RoundsResponse, OperatorResponse, OperatorsResponse, CircuitResponse, TransactionResponse, TransactionsResponse, CircuitsResponse, ProofResponse } from '../../types';
|
|
2
|
+
import { IndexerParams } from './types';
|
|
3
|
+
import { Http } from '../http';
|
|
4
|
+
import { Round, Account, Circuit, Operator, Proof, Transaction } from '../query';
|
|
5
|
+
/**
|
|
6
|
+
* @class Indexer
|
|
7
|
+
* @description This class is used to interact with Maci Indexer.
|
|
8
|
+
*/
|
|
9
|
+
export declare class Indexer {
|
|
10
|
+
restEndpoint: string;
|
|
11
|
+
apiEndpoint: string;
|
|
12
|
+
registryAddress: string;
|
|
13
|
+
http: Http;
|
|
14
|
+
round: Round;
|
|
15
|
+
account: Account;
|
|
16
|
+
circuit: Circuit;
|
|
17
|
+
operator: Operator;
|
|
18
|
+
proof: Proof;
|
|
19
|
+
transaction: Transaction;
|
|
20
|
+
/**
|
|
21
|
+
* @constructor
|
|
22
|
+
* @param {IndexerParams} params - The parameters for the Maci Indexer instance.
|
|
23
|
+
*/
|
|
24
|
+
constructor({ restEndpoint, apiEndpoint, registryAddress, http, }: IndexerParams);
|
|
25
|
+
/**
|
|
26
|
+
* @method balanceOf
|
|
27
|
+
* @description Get the balance of a specific address.
|
|
28
|
+
* @param {string} address - The address to check the balance for.
|
|
29
|
+
* @returns {Promise<BalanceResponse>} The balance response.
|
|
30
|
+
*/
|
|
31
|
+
balanceOf(address: string): Promise<BalanceResponse>;
|
|
32
|
+
/**
|
|
33
|
+
* @method getRoundById
|
|
34
|
+
* @description Get a round by its ID.
|
|
35
|
+
* @param {string} id - The ID of the round.
|
|
36
|
+
* @returns {Promise<RoundResponse>} The round response.
|
|
37
|
+
*/
|
|
38
|
+
getRoundById(id: string): Promise<RoundResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* @method getRounds
|
|
41
|
+
* @description Get multiple rounds.
|
|
42
|
+
* @param {string} after - The cursor to start after.
|
|
43
|
+
* @param {number} [limit] - The number of rounds to retrieve.
|
|
44
|
+
* @returns {Promise<RoundsResponse>} The rounds response.
|
|
45
|
+
*/
|
|
46
|
+
getRounds(after: string, limit?: number): Promise<RoundsResponse>;
|
|
47
|
+
/**
|
|
48
|
+
* @method getRoundsByStatus
|
|
49
|
+
* @description Get rounds by their status.
|
|
50
|
+
* @param {string} status - The status of the rounds to retrieve.
|
|
51
|
+
* @param {string} after - The cursor to start after.
|
|
52
|
+
* @param {number} [limit] - The number of rounds to retrieve.
|
|
53
|
+
* @returns {Promise<RoundsResponse>} The rounds response.
|
|
54
|
+
*/
|
|
55
|
+
getRoundsByStatus(status: string, after: string, limit?: number): Promise<RoundsResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* @method getRoundsByCircuitName
|
|
58
|
+
* @description Get rounds by their circuit name.
|
|
59
|
+
* @param {string} name - The name of the circuit.
|
|
60
|
+
* @param {string} after - The cursor to start after.
|
|
61
|
+
* @param {number} [limit] - The number of rounds to retrieve.
|
|
62
|
+
* @returns {Promise<RoundsResponse>} The rounds response.
|
|
63
|
+
*/
|
|
64
|
+
getRoundsByCircuitName(name: string, after: string, limit?: number): Promise<RoundsResponse>;
|
|
65
|
+
/**
|
|
66
|
+
* @method getRoundsByOperator
|
|
67
|
+
* @description Get rounds by their operator address.
|
|
68
|
+
* @param {string} address - The address of the operator.
|
|
69
|
+
* @param {string} after - The cursor to start after.
|
|
70
|
+
* @param {number} [limit] - The number of rounds to retrieve.
|
|
71
|
+
* @returns {Promise<RoundsResponse>} The rounds response.
|
|
72
|
+
*/
|
|
73
|
+
getRoundsByOperator(address: string, after: string, limit?: number): Promise<RoundsResponse>;
|
|
74
|
+
/**
|
|
75
|
+
* @method getOperatorByAddress
|
|
76
|
+
* @description Get an operator by their address.
|
|
77
|
+
* @param {string} address - The address of the operator.
|
|
78
|
+
* @returns {Promise<OperatorResponse>} The operator response.
|
|
79
|
+
*/
|
|
80
|
+
getOperatorByAddress(address: string): Promise<OperatorResponse>;
|
|
81
|
+
/**
|
|
82
|
+
* @method getOperators
|
|
83
|
+
* @description Get multiple operators.
|
|
84
|
+
* @param {string} after - The cursor to start after.
|
|
85
|
+
* @param {number} [limit] - The number of operators to retrieve.
|
|
86
|
+
* @returns {Promise<OperatorsResponse>} The operators response.
|
|
87
|
+
*/
|
|
88
|
+
getOperators(after: string, limit?: number): Promise<OperatorsResponse>;
|
|
89
|
+
/**
|
|
90
|
+
* @method getCircuitByName
|
|
91
|
+
* @description Get a circuit by its name.
|
|
92
|
+
* @param {string} name - The name of the circuit.
|
|
93
|
+
* @returns {Promise<CircuitResponse>} The circuit response.
|
|
94
|
+
*/
|
|
95
|
+
getCircuitByName(name: string): Promise<CircuitResponse>;
|
|
96
|
+
/**
|
|
97
|
+
* @method getCircuits
|
|
98
|
+
* @description Get all available circuits.
|
|
99
|
+
* @returns {Promise<CircuitsResponse>} The circuits response.
|
|
100
|
+
*/
|
|
101
|
+
getCircuits(): Promise<CircuitsResponse>;
|
|
102
|
+
/**
|
|
103
|
+
* @method getTransactionByHash
|
|
104
|
+
* @description Get a transaction by its hash.
|
|
105
|
+
* @param {string} hash - The hash of the transaction.
|
|
106
|
+
* @returns {Promise<TransactionResponse>} The transaction response.
|
|
107
|
+
*/
|
|
108
|
+
getTransactionByHash(hash: string): Promise<TransactionResponse>;
|
|
109
|
+
/**
|
|
110
|
+
* @method getTransactions
|
|
111
|
+
* @description Get multiple transactions.
|
|
112
|
+
* @param {string} after - The cursor to start after.
|
|
113
|
+
* @param {number} [limit] - The number of transactions to retrieve.
|
|
114
|
+
* @returns {Promise<TransactionsResponse>} The transactions response.
|
|
115
|
+
*/
|
|
116
|
+
getTransactions(after: string, limit?: number): Promise<TransactionsResponse>;
|
|
117
|
+
/**
|
|
118
|
+
* @method getTransactionsByContractAddress
|
|
119
|
+
* @description Get transactions by contract address.
|
|
120
|
+
* @param {string} address - The contract address.
|
|
121
|
+
* @param {string} after - The cursor to start after.
|
|
122
|
+
* @param {number} [limit] - The number of transactions to retrieve.
|
|
123
|
+
* @returns {Promise<TransactionsResponse>} The transactions response.
|
|
124
|
+
*/
|
|
125
|
+
getTransactionsByContractAddress(address: string, after: string, limit?: number): Promise<TransactionsResponse>;
|
|
126
|
+
/**
|
|
127
|
+
* @method getProofByContractAddress
|
|
128
|
+
* @description Get proof data by contract address.
|
|
129
|
+
* @param {string} address - The contract address.
|
|
130
|
+
* @returns {Promise<ProofResponse>} The proof response.
|
|
131
|
+
*/
|
|
132
|
+
getProofByContractAddress(address: string): Promise<ProofResponse>;
|
|
133
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Http } from '../../libs';
|
|
2
|
+
import { CircuitResponse, CircuitsResponse } from '../../types';
|
|
3
|
+
export declare class Circuit {
|
|
4
|
+
http: Http;
|
|
5
|
+
constructor(http: Http);
|
|
6
|
+
getCircuitByName(name: string): Promise<CircuitResponse>;
|
|
7
|
+
getCircuits(): Promise<CircuitsResponse>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Http } from '../../libs';
|
|
2
|
+
import { OperatorResponse, OperatorsResponse } from '../../types';
|
|
3
|
+
export declare class Operator {
|
|
4
|
+
http: Http;
|
|
5
|
+
amaciRegistryContract: string;
|
|
6
|
+
constructor(http: Http, amaciRegistryContract: string);
|
|
7
|
+
getOperatorByAddress(address: string): Promise<OperatorResponse>;
|
|
8
|
+
getOperators(after: string, limit?: number): Promise<OperatorsResponse>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RoundsResponse, RoundResponse } from '../../types';
|
|
2
|
+
import { Http } from '../../libs';
|
|
3
|
+
export declare class Round {
|
|
4
|
+
http: Http;
|
|
5
|
+
constructor(http: Http);
|
|
6
|
+
getRoundById(address: string): Promise<RoundResponse>;
|
|
7
|
+
getRounds(after: string, limit?: number): Promise<RoundsResponse>;
|
|
8
|
+
getRoundsByCircuitName(circuitName: string, after: string, limit?: number): Promise<RoundsResponse>;
|
|
9
|
+
getRoundsByStatus(status: string, after: string, limit?: number): Promise<RoundsResponse>;
|
|
10
|
+
getRoundsByOperator(operator: string, after: string, limit?: number): Promise<RoundsResponse>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TransactionsResponse, TransactionResponse } from '../../types';
|
|
2
|
+
import { Http } from '../../libs';
|
|
3
|
+
export declare class Transaction {
|
|
4
|
+
http: Http;
|
|
5
|
+
constructor(http: Http);
|
|
6
|
+
getTransactionByHash(txHash: string): Promise<TransactionResponse>;
|
|
7
|
+
getTransactions(after: string, limit?: number): Promise<TransactionsResponse>;
|
|
8
|
+
getTransactionsByContractAddress(address: string, after: string, limit?: number): Promise<TransactionsResponse>;
|
|
9
|
+
}
|
package/dist/maci.d.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { BalanceResponse, ClientParams, RoundResponse, RoundsResponse, OperatorResponse, OperatorsResponse, CircuitResponse, TransactionResponse, TransactionsResponse, CircuitsResponse, ProofResponse } from './types';
|
|
2
|
+
import { Http, Indexer, Contract } from './libs';
|
|
3
|
+
import { CreateAMaciRoundParams, CreateMaciRoundParams, CreateOracleMaciRoundParams } from './libs/contract/types';
|
|
4
|
+
import { OfflineSigner } from '@cosmjs/proto-signing';
|
|
5
|
+
/**
|
|
6
|
+
* @class MaciClient
|
|
7
|
+
* @description This class is used to interact with Maci Client.
|
|
8
|
+
*/
|
|
9
|
+
export declare class MaciClient {
|
|
10
|
+
rpcEndpoint: string;
|
|
11
|
+
restEndpoint: string;
|
|
12
|
+
apiEndpoint: string;
|
|
13
|
+
registryAddress: string;
|
|
14
|
+
maciCodeId: number;
|
|
15
|
+
oracleCodeId: number;
|
|
16
|
+
http: Http;
|
|
17
|
+
indexer: Indexer;
|
|
18
|
+
contract: Contract;
|
|
19
|
+
/**
|
|
20
|
+
* @constructor
|
|
21
|
+
* @param {ClientParams} params - The parameters for the Maci Client instance.
|
|
22
|
+
*/
|
|
23
|
+
constructor({ network, rpcEndpoint, restEndpoint, apiEndpoint, registryAddress, maciCodeId, oracleCodeId, customFetch, defaultOptions, }: ClientParams);
|
|
24
|
+
oracleMaciClient({ signer, contractAddress, }: {
|
|
25
|
+
signer: OfflineSigner;
|
|
26
|
+
contractAddress: string;
|
|
27
|
+
}): Promise<import("./libs/contract/ts/OracleMaci.client").OracleMaciClient>;
|
|
28
|
+
registryClient({ signer, contractAddress, }: {
|
|
29
|
+
signer: OfflineSigner;
|
|
30
|
+
contractAddress: string;
|
|
31
|
+
}): Promise<import("./libs/contract/ts/Registry.client").RegistryClient>;
|
|
32
|
+
maciClient({ signer, contractAddress, }: {
|
|
33
|
+
signer: OfflineSigner;
|
|
34
|
+
contractAddress: string;
|
|
35
|
+
}): Promise<import("./libs/contract/ts/Maci.client").MaciClient>;
|
|
36
|
+
amaciClient({ signer, contractAddress, }: {
|
|
37
|
+
signer: OfflineSigner;
|
|
38
|
+
contractAddress: string;
|
|
39
|
+
}): Promise<import("./libs/contract/ts/AMaci.client").AMaciClient>;
|
|
40
|
+
createAMaciRound(params: CreateAMaciRoundParams): Promise<string>;
|
|
41
|
+
createMaciRound(params: CreateMaciRoundParams): Promise<import("@cosmjs/cosmwasm-stargate").InstantiateResult>;
|
|
42
|
+
createOracleMaciRound(params: CreateOracleMaciRoundParams): Promise<import("@cosmjs/cosmwasm-stargate").InstantiateResult>;
|
|
43
|
+
/**
|
|
44
|
+
* @method balanceOf
|
|
45
|
+
* @description Get the balance of a specific address.
|
|
46
|
+
* @param {string} address - The address to check the balance for.
|
|
47
|
+
* @returns {Promise<BalanceResponse>} The balance response.
|
|
48
|
+
*/
|
|
49
|
+
balanceOf(address: string): Promise<BalanceResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* @method getRoundById
|
|
52
|
+
* @description Get a round by its ID.
|
|
53
|
+
* @param {string} id - The ID of the round.
|
|
54
|
+
* @returns {Promise<RoundResponse>} The round response.
|
|
55
|
+
*/
|
|
56
|
+
getRoundById(id: string): Promise<RoundResponse>;
|
|
57
|
+
/**
|
|
58
|
+
* @method getRounds
|
|
59
|
+
* @description Get multiple rounds.
|
|
60
|
+
* @param {string} after - The cursor to start after.
|
|
61
|
+
* @param {number} [limit] - The number of rounds to retrieve.
|
|
62
|
+
* @returns {Promise<RoundsResponse>} The rounds response.
|
|
63
|
+
*/
|
|
64
|
+
getRounds(after: string, limit?: number): Promise<RoundsResponse>;
|
|
65
|
+
/**
|
|
66
|
+
* @method getRoundsByStatus
|
|
67
|
+
* @description Get rounds by their status.
|
|
68
|
+
* @param {string} status - The status of the rounds to retrieve.
|
|
69
|
+
* @param {string} after - The cursor to start after.
|
|
70
|
+
* @param {number} [limit] - The number of rounds to retrieve.
|
|
71
|
+
* @returns {Promise<RoundsResponse>} The rounds response.
|
|
72
|
+
*/
|
|
73
|
+
getRoundsByStatus(status: string, after: string, limit?: number): Promise<RoundsResponse>;
|
|
74
|
+
/**
|
|
75
|
+
* @method getRoundsByCircuitName
|
|
76
|
+
* @description Get rounds by their circuit name.
|
|
77
|
+
* @param {string} name - The name of the circuit.
|
|
78
|
+
* @param {string} after - The cursor to start after.
|
|
79
|
+
* @param {number} [limit] - The number of rounds to retrieve.
|
|
80
|
+
* @returns {Promise<RoundsResponse>} The rounds response.
|
|
81
|
+
*/
|
|
82
|
+
getRoundsByCircuitName(name: string, after: string, limit?: number): Promise<RoundsResponse>;
|
|
83
|
+
/**
|
|
84
|
+
* @method getRoundsByOperator
|
|
85
|
+
* @description Get rounds by their operator address.
|
|
86
|
+
* @param {string} address - The address of the operator.
|
|
87
|
+
* @param {string} after - The cursor to start after.
|
|
88
|
+
* @param {number} [limit] - The number of rounds to retrieve.
|
|
89
|
+
* @returns {Promise<RoundsResponse>} The rounds response.
|
|
90
|
+
*/
|
|
91
|
+
getRoundsByOperator(address: string, after: string, limit?: number): Promise<RoundsResponse>;
|
|
92
|
+
/**
|
|
93
|
+
* @method getOperatorByAddress
|
|
94
|
+
* @description Get an operator by their address.
|
|
95
|
+
* @param {string} address - The address of the operator.
|
|
96
|
+
* @returns {Promise<OperatorResponse>} The operator response.
|
|
97
|
+
*/
|
|
98
|
+
getOperatorByAddress(address: string): Promise<OperatorResponse>;
|
|
99
|
+
/**
|
|
100
|
+
* @method getOperators
|
|
101
|
+
* @description Get multiple operators.
|
|
102
|
+
* @param {string} after - The cursor to start after.
|
|
103
|
+
* @param {number} [limit] - The number of operators to retrieve.
|
|
104
|
+
* @returns {Promise<OperatorsResponse>} The operators response.
|
|
105
|
+
*/
|
|
106
|
+
getOperators(after: string, limit?: number): Promise<OperatorsResponse>;
|
|
107
|
+
/**
|
|
108
|
+
* @method getCircuitByName
|
|
109
|
+
* @description Get a circuit by its name.
|
|
110
|
+
* @param {string} name - The name of the circuit.
|
|
111
|
+
* @returns {Promise<CircuitResponse>} The circuit response.
|
|
112
|
+
*/
|
|
113
|
+
getCircuitByName(name: string): Promise<CircuitResponse>;
|
|
114
|
+
/**
|
|
115
|
+
* @method getCircuits
|
|
116
|
+
* @description Get all available circuits.
|
|
117
|
+
* @returns {Promise<CircuitsResponse>} The circuits response.
|
|
118
|
+
*/
|
|
119
|
+
getCircuits(): Promise<CircuitsResponse>;
|
|
120
|
+
/**
|
|
121
|
+
* @method getTransactionByHash
|
|
122
|
+
* @description Get a transaction by its hash.
|
|
123
|
+
* @param {string} hash - The hash of the transaction.
|
|
124
|
+
* @returns {Promise<TransactionResponse>} The transaction response.
|
|
125
|
+
*/
|
|
126
|
+
getTransactionByHash(hash: string): Promise<TransactionResponse>;
|
|
127
|
+
/**
|
|
128
|
+
* @method getTransactions
|
|
129
|
+
* @description Get multiple transactions.
|
|
130
|
+
* @param {string} after - The cursor to start after.
|
|
131
|
+
* @param {number} [limit] - The number of transactions to retrieve.
|
|
132
|
+
* @returns {Promise<TransactionsResponse>} The transactions response.
|
|
133
|
+
*/
|
|
134
|
+
getTransactions(after: string, limit?: number): Promise<TransactionsResponse>;
|
|
135
|
+
/**
|
|
136
|
+
* @method getTransactionsByContractAddress
|
|
137
|
+
* @description Get transactions by contract address.
|
|
138
|
+
* @param {string} address - The contract address.
|
|
139
|
+
* @param {string} after - The cursor to start after.
|
|
140
|
+
* @param {number} [limit] - The number of transactions to retrieve.
|
|
141
|
+
* @returns {Promise<TransactionsResponse>} The transactions response.
|
|
142
|
+
*/
|
|
143
|
+
getTransactionsByContractAddress(address: string, after: string, limit?: number): Promise<TransactionsResponse>;
|
|
144
|
+
/**
|
|
145
|
+
* @method getProofByContractAddress
|
|
146
|
+
* @description Get proof data by contract address.
|
|
147
|
+
* @param {string} address - The contract address.
|
|
148
|
+
* @returns {Promise<ProofResponse>} The proof response.
|
|
149
|
+
*/
|
|
150
|
+
getProofByContractAddress(address: string): Promise<ProofResponse>;
|
|
151
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { FetchOptions } from '../libs/http/http';
|
|
2
|
+
export type ClientParams = {
|
|
3
|
+
network: 'mainnet' | 'testnet';
|
|
4
|
+
rpcEndpoint?: string;
|
|
5
|
+
restEndpoint?: string;
|
|
6
|
+
apiEndpoint?: string;
|
|
7
|
+
registryAddress?: string;
|
|
8
|
+
maciCodeId?: number;
|
|
9
|
+
oracleCodeId?: number;
|
|
10
|
+
customFetch?: typeof fetch;
|
|
11
|
+
defaultOptions?: FetchOptions;
|
|
12
|
+
};
|
|
13
|
+
export type ContractParams = {
|
|
14
|
+
rpcEndpoint: string;
|
|
15
|
+
registryAddress: string;
|
|
16
|
+
maciCodeId: number;
|
|
17
|
+
oracleCodeId: number;
|
|
18
|
+
};
|
|
19
|
+
export type TransactionType = {
|
|
20
|
+
id: string;
|
|
21
|
+
blockHeight: string;
|
|
22
|
+
txHash: string;
|
|
23
|
+
timestamp: string;
|
|
24
|
+
type: string;
|
|
25
|
+
status: string;
|
|
26
|
+
circuitName: string;
|
|
27
|
+
fee: string;
|
|
28
|
+
gasUsed: string;
|
|
29
|
+
gasWanted: string;
|
|
30
|
+
caller: string;
|
|
31
|
+
contractAddress: string;
|
|
32
|
+
};
|
|
33
|
+
export type RoundType = {
|
|
34
|
+
id: string;
|
|
35
|
+
blockHeight: string;
|
|
36
|
+
txHash: string;
|
|
37
|
+
caller: string;
|
|
38
|
+
admin: string;
|
|
39
|
+
operator: string;
|
|
40
|
+
contractAddress: string;
|
|
41
|
+
circuitName: string;
|
|
42
|
+
timestamp: string;
|
|
43
|
+
votingStart: string;
|
|
44
|
+
votingEnd: string;
|
|
45
|
+
status: string;
|
|
46
|
+
period: string;
|
|
47
|
+
actionType: string;
|
|
48
|
+
roundTitle: string;
|
|
49
|
+
roundDescription: string;
|
|
50
|
+
roundLink: string;
|
|
51
|
+
coordinatorPubkeyX: string;
|
|
52
|
+
coordinatorPubkeyY: string;
|
|
53
|
+
voteOptionMap: string;
|
|
54
|
+
results: string;
|
|
55
|
+
allResult: string;
|
|
56
|
+
gasStationEnable: boolean;
|
|
57
|
+
totalGrant: string;
|
|
58
|
+
baseGrant: string;
|
|
59
|
+
totalBond: string;
|
|
60
|
+
circuitType: string;
|
|
61
|
+
circuitPower: string;
|
|
62
|
+
certificationSystem: string;
|
|
63
|
+
codeId: string;
|
|
64
|
+
maciType: string;
|
|
65
|
+
voiceCreditAmount: string;
|
|
66
|
+
preDeactivateRoot: string;
|
|
67
|
+
identity: string;
|
|
68
|
+
operatorLogoUrl?: string;
|
|
69
|
+
operatorMoniker?: string;
|
|
70
|
+
resultsList?: {
|
|
71
|
+
v: number;
|
|
72
|
+
v2: number;
|
|
73
|
+
}[];
|
|
74
|
+
};
|
|
75
|
+
export type ProofType = {
|
|
76
|
+
nodes: {
|
|
77
|
+
id: string;
|
|
78
|
+
blockHeight: string;
|
|
79
|
+
txHash: string;
|
|
80
|
+
contractAddress: string;
|
|
81
|
+
timestamp: string;
|
|
82
|
+
actionType: string;
|
|
83
|
+
commitment: string;
|
|
84
|
+
proof: string;
|
|
85
|
+
}[];
|
|
86
|
+
};
|
|
87
|
+
export type OperatorType = {
|
|
88
|
+
id: string;
|
|
89
|
+
validatorAddress: string;
|
|
90
|
+
operatorAddress: string;
|
|
91
|
+
coordinatorPubkeyX: string;
|
|
92
|
+
coordinatorPubkeyY: string;
|
|
93
|
+
identity: string;
|
|
94
|
+
logoUrl: string;
|
|
95
|
+
moniker: string;
|
|
96
|
+
activeRoundsCount: number;
|
|
97
|
+
completedRoundsCount: number;
|
|
98
|
+
};
|
|
99
|
+
export type CircuitType = {
|
|
100
|
+
maciType: string;
|
|
101
|
+
circuitType: string;
|
|
102
|
+
displayName: string;
|
|
103
|
+
repoUrl: string;
|
|
104
|
+
zipUrl: string;
|
|
105
|
+
roundCount?: number;
|
|
106
|
+
};
|
|
107
|
+
export type CircuitsCountGraphqlResponse = {
|
|
108
|
+
data: {
|
|
109
|
+
rounds: {
|
|
110
|
+
totalCount: number;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
export type ErrorResponse = {
|
|
115
|
+
code: number;
|
|
116
|
+
error: {
|
|
117
|
+
message: string;
|
|
118
|
+
type: string;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
export type SuccessResponse<T> = {
|
|
122
|
+
code: 200;
|
|
123
|
+
data: T;
|
|
124
|
+
};
|
|
125
|
+
export type CircuitResponse = SuccessResponse<{
|
|
126
|
+
circuit: CircuitType;
|
|
127
|
+
}> | ErrorResponse;
|
|
128
|
+
export type CircuitsResponse = SuccessResponse<{
|
|
129
|
+
circuits: CircuitType[];
|
|
130
|
+
}> | ErrorResponse;
|
|
131
|
+
export type BalanceResponse = SuccessResponse<{
|
|
132
|
+
balance: string;
|
|
133
|
+
}> | ErrorResponse;
|
|
134
|
+
export type OperatorResponse = SuccessResponse<{
|
|
135
|
+
operator: OperatorType;
|
|
136
|
+
}> | ErrorResponse;
|
|
137
|
+
export type OperatorsResponse = SuccessResponse<{
|
|
138
|
+
operators: {
|
|
139
|
+
pageInfo: {
|
|
140
|
+
endCursor: string;
|
|
141
|
+
hasNextPage: boolean;
|
|
142
|
+
};
|
|
143
|
+
edges: {
|
|
144
|
+
cursor: string;
|
|
145
|
+
node: OperatorType;
|
|
146
|
+
}[];
|
|
147
|
+
totalCount: number;
|
|
148
|
+
};
|
|
149
|
+
}> | ErrorResponse;
|
|
150
|
+
export type OperatorsGraphqlResponse = {
|
|
151
|
+
data: {
|
|
152
|
+
operators: {
|
|
153
|
+
pageInfo: {
|
|
154
|
+
endCursor: string;
|
|
155
|
+
hasNextPage: boolean;
|
|
156
|
+
};
|
|
157
|
+
edges: {
|
|
158
|
+
cursor: string;
|
|
159
|
+
node: OperatorType;
|
|
160
|
+
}[];
|
|
161
|
+
totalCount: number;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
export type RoundsCountGraphqlResponse = {
|
|
166
|
+
data: {
|
|
167
|
+
activeRoundsCount: {
|
|
168
|
+
totalCount: number;
|
|
169
|
+
};
|
|
170
|
+
completedRoundsCount: {
|
|
171
|
+
totalCount: number;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
export type TransactionGraphqlResponse = {
|
|
176
|
+
data: {
|
|
177
|
+
transaction: TransactionType;
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
export type TransactionResponse = SuccessResponse<{
|
|
181
|
+
transaction: TransactionType;
|
|
182
|
+
}> | ErrorResponse;
|
|
183
|
+
export type TransactionsGraphqlResponse = {
|
|
184
|
+
data: {
|
|
185
|
+
transactions: {
|
|
186
|
+
pageInfo: {
|
|
187
|
+
endCursor: string;
|
|
188
|
+
hasNextPage: boolean;
|
|
189
|
+
};
|
|
190
|
+
edges: {
|
|
191
|
+
cursor: string;
|
|
192
|
+
node: TransactionType;
|
|
193
|
+
}[];
|
|
194
|
+
totalCount: number;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
export type TransactionsResponse = SuccessResponse<{
|
|
199
|
+
transactions: {
|
|
200
|
+
pageInfo: {
|
|
201
|
+
endCursor: string;
|
|
202
|
+
hasNextPage: boolean;
|
|
203
|
+
};
|
|
204
|
+
edges: {
|
|
205
|
+
cursor: string;
|
|
206
|
+
node: TransactionType;
|
|
207
|
+
}[];
|
|
208
|
+
totalCount: number;
|
|
209
|
+
};
|
|
210
|
+
}> | ErrorResponse;
|
|
211
|
+
export type RoundResponse = SuccessResponse<{
|
|
212
|
+
round: RoundType;
|
|
213
|
+
}> | ErrorResponse;
|
|
214
|
+
export type RoundsResponse = SuccessResponse<{
|
|
215
|
+
rounds: {
|
|
216
|
+
pageInfo: {
|
|
217
|
+
endCursor: string;
|
|
218
|
+
hasNextPage: boolean;
|
|
219
|
+
};
|
|
220
|
+
edges: {
|
|
221
|
+
cursor: string;
|
|
222
|
+
node: RoundType;
|
|
223
|
+
}[];
|
|
224
|
+
totalCount: number;
|
|
225
|
+
};
|
|
226
|
+
}> | ErrorResponse;
|
|
227
|
+
export type RoundGraphqlResponse = {
|
|
228
|
+
data: {
|
|
229
|
+
round: RoundType;
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
export type RoundsGraphqlResponse = {
|
|
233
|
+
data: {
|
|
234
|
+
rounds: {
|
|
235
|
+
pageInfo: {
|
|
236
|
+
endCursor: string;
|
|
237
|
+
hasNextPage: boolean;
|
|
238
|
+
};
|
|
239
|
+
edges: {
|
|
240
|
+
cursor: string;
|
|
241
|
+
node: RoundType;
|
|
242
|
+
}[];
|
|
243
|
+
totalCount: number;
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
export type ProofResponse = SuccessResponse<{
|
|
248
|
+
proofData: ProofType;
|
|
249
|
+
}> | ErrorResponse;
|
|
250
|
+
export type ProofGraphqlResponse = {
|
|
251
|
+
data: {
|
|
252
|
+
proofData: ProofType;
|
|
253
|
+
};
|
|
254
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isValidAddress(address: string): boolean;
|