@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,204 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TransactionsResponse,
|
|
3
|
+
TransactionResponse,
|
|
4
|
+
TransactionGraphqlResponse,
|
|
5
|
+
TransactionsGraphqlResponse,
|
|
6
|
+
} from '../../types';
|
|
7
|
+
import { Http } from '../../libs';
|
|
8
|
+
import { isValidAddress } from '../../utils';
|
|
9
|
+
import { handleError, ErrorType } from '../errors';
|
|
10
|
+
import { ERROR } from '../errors/types';
|
|
11
|
+
|
|
12
|
+
export class Transaction {
|
|
13
|
+
public http: Http;
|
|
14
|
+
|
|
15
|
+
constructor(http: Http) {
|
|
16
|
+
this.http = http;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async getTransactionByHash(txHash: string): Promise<TransactionResponse> {
|
|
20
|
+
try {
|
|
21
|
+
const TRANSACTION_QUERY = `query {
|
|
22
|
+
transaction(id: "${txHash}") {
|
|
23
|
+
id
|
|
24
|
+
blockHeight
|
|
25
|
+
txHash
|
|
26
|
+
timestamp
|
|
27
|
+
type
|
|
28
|
+
status
|
|
29
|
+
circuitName
|
|
30
|
+
fee
|
|
31
|
+
gasUsed
|
|
32
|
+
gasWanted
|
|
33
|
+
caller
|
|
34
|
+
contractAddress
|
|
35
|
+
}
|
|
36
|
+
}`;
|
|
37
|
+
|
|
38
|
+
const response = await this.http.fetchGraphql<TransactionGraphqlResponse>(
|
|
39
|
+
TRANSACTION_QUERY,
|
|
40
|
+
''
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
if (!response || !response.data || !response.data.transaction) {
|
|
44
|
+
return {
|
|
45
|
+
code: 404,
|
|
46
|
+
error: {
|
|
47
|
+
message: `No transaction found for txHash ${txHash}`,
|
|
48
|
+
type: ERROR.ERROR_TRANSACTION_NOT_FOUND,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
code: 200,
|
|
55
|
+
data: response.data,
|
|
56
|
+
};
|
|
57
|
+
} catch (error: any) {
|
|
58
|
+
return handleError(error as ErrorType);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async getTransactions(
|
|
63
|
+
after: string,
|
|
64
|
+
limit?: number
|
|
65
|
+
): Promise<TransactionsResponse> {
|
|
66
|
+
try {
|
|
67
|
+
const TRANSACTION_HISTORY_QUERY = `query transactions($limit: Int, $after: Cursor) {
|
|
68
|
+
transactions(first: $limit, after: $after, orderBy: [TIMESTAMP_DESC]
|
|
69
|
+
){
|
|
70
|
+
pageInfo {
|
|
71
|
+
endCursor
|
|
72
|
+
hasNextPage
|
|
73
|
+
}
|
|
74
|
+
totalCount
|
|
75
|
+
edges {
|
|
76
|
+
cursor
|
|
77
|
+
node {
|
|
78
|
+
id
|
|
79
|
+
blockHeight
|
|
80
|
+
txHash
|
|
81
|
+
timestamp
|
|
82
|
+
type
|
|
83
|
+
status
|
|
84
|
+
circuitName
|
|
85
|
+
fee
|
|
86
|
+
gasUsed
|
|
87
|
+
gasWanted
|
|
88
|
+
caller
|
|
89
|
+
contractAddress
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}`;
|
|
94
|
+
|
|
95
|
+
const response =
|
|
96
|
+
await this.http.fetchGraphql<TransactionsGraphqlResponse>(
|
|
97
|
+
TRANSACTION_HISTORY_QUERY,
|
|
98
|
+
after,
|
|
99
|
+
limit
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
if (
|
|
103
|
+
!response ||
|
|
104
|
+
!response.data ||
|
|
105
|
+
!response.data.transactions ||
|
|
106
|
+
!response.data.transactions.edges
|
|
107
|
+
) {
|
|
108
|
+
return {
|
|
109
|
+
code: 404,
|
|
110
|
+
error: {
|
|
111
|
+
message: 'No transactions data found',
|
|
112
|
+
type: ERROR.ERROR_TRANSACTIONS_NOT_FOUND,
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
code: 200,
|
|
119
|
+
data: response.data,
|
|
120
|
+
};
|
|
121
|
+
} catch (error) {
|
|
122
|
+
return handleError(error as ErrorType);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async getTransactionsByContractAddress(
|
|
127
|
+
address: string,
|
|
128
|
+
after: string,
|
|
129
|
+
limit?: number
|
|
130
|
+
): Promise<TransactionsResponse> {
|
|
131
|
+
try {
|
|
132
|
+
if (!isValidAddress(address)) {
|
|
133
|
+
return {
|
|
134
|
+
code: 400,
|
|
135
|
+
error: {
|
|
136
|
+
message: 'Invalid round address format',
|
|
137
|
+
type: ERROR.ERROR_ROUND_INVALID_ADDRESS,
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const TRANSACTION_HISTORY_QUERY = `query transactions($limit: Int!, $after: Cursor) {
|
|
143
|
+
transactions(first: $limit, after: $after, filter:{
|
|
144
|
+
contractAddress:{
|
|
145
|
+
equalTo: "${address}"
|
|
146
|
+
}
|
|
147
|
+
}, orderBy: [TIMESTAMP_DESC]
|
|
148
|
+
){
|
|
149
|
+
pageInfo {
|
|
150
|
+
endCursor
|
|
151
|
+
hasNextPage
|
|
152
|
+
}
|
|
153
|
+
totalCount
|
|
154
|
+
edges {
|
|
155
|
+
cursor
|
|
156
|
+
node {
|
|
157
|
+
id
|
|
158
|
+
blockHeight
|
|
159
|
+
txHash
|
|
160
|
+
timestamp
|
|
161
|
+
type
|
|
162
|
+
status
|
|
163
|
+
circuitName
|
|
164
|
+
fee
|
|
165
|
+
gasUsed
|
|
166
|
+
gasWanted
|
|
167
|
+
caller
|
|
168
|
+
contractAddress
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}`;
|
|
173
|
+
|
|
174
|
+
const response =
|
|
175
|
+
await this.http.fetchGraphql<TransactionsGraphqlResponse>(
|
|
176
|
+
TRANSACTION_HISTORY_QUERY,
|
|
177
|
+
after,
|
|
178
|
+
limit
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
if (
|
|
182
|
+
!response ||
|
|
183
|
+
!response.data ||
|
|
184
|
+
!response.data.transactions ||
|
|
185
|
+
!response.data.transactions.edges
|
|
186
|
+
) {
|
|
187
|
+
return {
|
|
188
|
+
code: 404,
|
|
189
|
+
error: {
|
|
190
|
+
message: 'No transactions data found',
|
|
191
|
+
type: ERROR.ERROR_TRANSACTIONS_NOT_FOUND,
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return {
|
|
197
|
+
code: 200,
|
|
198
|
+
data: response.data,
|
|
199
|
+
};
|
|
200
|
+
} catch (error) {
|
|
201
|
+
return handleError(error as ErrorType);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
package/src/maci.ts
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BalanceResponse,
|
|
3
|
+
ClientParams,
|
|
4
|
+
RoundResponse,
|
|
5
|
+
RoundsResponse,
|
|
6
|
+
OperatorResponse,
|
|
7
|
+
OperatorsResponse,
|
|
8
|
+
CircuitResponse,
|
|
9
|
+
TransactionResponse,
|
|
10
|
+
TransactionsResponse,
|
|
11
|
+
CircuitsResponse,
|
|
12
|
+
ProofResponse,
|
|
13
|
+
} from './types';
|
|
14
|
+
import { Http, Indexer, Contract } from './libs';
|
|
15
|
+
import { getDefaultParams } from './libs/const';
|
|
16
|
+
import {
|
|
17
|
+
CreateAMaciRoundParams,
|
|
18
|
+
CreateMaciRoundParams,
|
|
19
|
+
CreateOracleMaciRoundParams,
|
|
20
|
+
} from './libs/contract/types';
|
|
21
|
+
import { OfflineSigner } from '@cosmjs/proto-signing';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @class MaciClient
|
|
25
|
+
* @description This class is used to interact with Maci Client.
|
|
26
|
+
*/
|
|
27
|
+
export class MaciClient {
|
|
28
|
+
public rpcEndpoint: string;
|
|
29
|
+
public restEndpoint: string;
|
|
30
|
+
public apiEndpoint: string;
|
|
31
|
+
public registryAddress: string;
|
|
32
|
+
public maciCodeId: number;
|
|
33
|
+
public oracleCodeId: number;
|
|
34
|
+
|
|
35
|
+
public http: Http;
|
|
36
|
+
public indexer: Indexer;
|
|
37
|
+
public contract: Contract;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @constructor
|
|
41
|
+
* @param {ClientParams} params - The parameters for the Maci Client instance.
|
|
42
|
+
*/
|
|
43
|
+
constructor({
|
|
44
|
+
network,
|
|
45
|
+
rpcEndpoint,
|
|
46
|
+
restEndpoint,
|
|
47
|
+
apiEndpoint,
|
|
48
|
+
registryAddress,
|
|
49
|
+
maciCodeId,
|
|
50
|
+
oracleCodeId,
|
|
51
|
+
customFetch,
|
|
52
|
+
defaultOptions,
|
|
53
|
+
}: ClientParams) {
|
|
54
|
+
const defaultParams = getDefaultParams(network);
|
|
55
|
+
|
|
56
|
+
this.rpcEndpoint = rpcEndpoint || defaultParams.rpcEndpoint;
|
|
57
|
+
this.restEndpoint = restEndpoint || defaultParams.restEndpoint;
|
|
58
|
+
this.apiEndpoint = apiEndpoint || defaultParams.apiEndpoint;
|
|
59
|
+
this.registryAddress = registryAddress || defaultParams.registryAddress;
|
|
60
|
+
this.maciCodeId = maciCodeId || defaultParams.maciCodeId;
|
|
61
|
+
this.oracleCodeId = oracleCodeId || defaultParams.oracleCodeId;
|
|
62
|
+
|
|
63
|
+
this.http = new Http(
|
|
64
|
+
this.apiEndpoint,
|
|
65
|
+
this.restEndpoint,
|
|
66
|
+
customFetch,
|
|
67
|
+
defaultOptions
|
|
68
|
+
);
|
|
69
|
+
this.indexer = new Indexer({
|
|
70
|
+
restEndpoint: this.restEndpoint,
|
|
71
|
+
apiEndpoint: this.apiEndpoint,
|
|
72
|
+
registryAddress: this.registryAddress,
|
|
73
|
+
http: this.http,
|
|
74
|
+
});
|
|
75
|
+
this.contract = new Contract({
|
|
76
|
+
rpcEndpoint: this.rpcEndpoint,
|
|
77
|
+
registryAddress: this.registryAddress,
|
|
78
|
+
maciCodeId: this.maciCodeId,
|
|
79
|
+
oracleCodeId: this.oracleCodeId,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async oracleMaciClient({
|
|
84
|
+
signer,
|
|
85
|
+
contractAddress,
|
|
86
|
+
}: {
|
|
87
|
+
signer: OfflineSigner;
|
|
88
|
+
contractAddress: string;
|
|
89
|
+
}) {
|
|
90
|
+
return await this.contract.oracleMaciClient({
|
|
91
|
+
signer,
|
|
92
|
+
contractAddress,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async registryClient({
|
|
97
|
+
signer,
|
|
98
|
+
contractAddress,
|
|
99
|
+
}: {
|
|
100
|
+
signer: OfflineSigner;
|
|
101
|
+
contractAddress: string;
|
|
102
|
+
}) {
|
|
103
|
+
return await this.contract.registryClient({ signer, contractAddress });
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async maciClient({
|
|
107
|
+
signer,
|
|
108
|
+
contractAddress,
|
|
109
|
+
}: {
|
|
110
|
+
signer: OfflineSigner;
|
|
111
|
+
contractAddress: string;
|
|
112
|
+
}) {
|
|
113
|
+
return await this.contract.maciClient({ signer, contractAddress });
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async amaciClient({
|
|
117
|
+
signer,
|
|
118
|
+
contractAddress,
|
|
119
|
+
}: {
|
|
120
|
+
signer: OfflineSigner;
|
|
121
|
+
contractAddress: string;
|
|
122
|
+
}) {
|
|
123
|
+
return await this.contract.amaciClient({ signer, contractAddress });
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async createAMaciRound(params: CreateAMaciRoundParams) {
|
|
127
|
+
return await this.contract.createAMaciRound(params);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async createMaciRound(params: CreateMaciRoundParams) {
|
|
131
|
+
return await this.contract.createMaciRound(params);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async createOracleMaciRound(params: CreateOracleMaciRoundParams) {
|
|
135
|
+
return await this.contract.createOracleMaciRound(params);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @method balanceOf
|
|
140
|
+
* @description Get the balance of a specific address.
|
|
141
|
+
* @param {string} address - The address to check the balance for.
|
|
142
|
+
* @returns {Promise<BalanceResponse>} The balance response.
|
|
143
|
+
*/
|
|
144
|
+
async balanceOf(address: string): Promise<BalanceResponse> {
|
|
145
|
+
return await this.indexer.account.balanceOf(address);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @method getRoundById
|
|
150
|
+
* @description Get a round by its ID.
|
|
151
|
+
* @param {string} id - The ID of the round.
|
|
152
|
+
* @returns {Promise<RoundResponse>} The round response.
|
|
153
|
+
*/
|
|
154
|
+
async getRoundById(id: string): Promise<RoundResponse> {
|
|
155
|
+
return await this.indexer.round.getRoundById(id);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @method getRounds
|
|
160
|
+
* @description Get multiple rounds.
|
|
161
|
+
* @param {string} after - The cursor to start after.
|
|
162
|
+
* @param {number} [limit] - The number of rounds to retrieve.
|
|
163
|
+
* @returns {Promise<RoundsResponse>} The rounds response.
|
|
164
|
+
*/
|
|
165
|
+
async getRounds(after: string, limit?: number): Promise<RoundsResponse> {
|
|
166
|
+
return await this.indexer.round.getRounds(after, limit);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @method getRoundsByStatus
|
|
171
|
+
* @description Get rounds by their status.
|
|
172
|
+
* @param {string} status - The status of the rounds to retrieve.
|
|
173
|
+
* @param {string} after - The cursor to start after.
|
|
174
|
+
* @param {number} [limit] - The number of rounds to retrieve.
|
|
175
|
+
* @returns {Promise<RoundsResponse>} The rounds response.
|
|
176
|
+
*/
|
|
177
|
+
async getRoundsByStatus(
|
|
178
|
+
status: string,
|
|
179
|
+
after: string,
|
|
180
|
+
limit?: number
|
|
181
|
+
): Promise<RoundsResponse> {
|
|
182
|
+
return await this.indexer.round.getRoundsByStatus(status, after, limit);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* @method getRoundsByCircuitName
|
|
187
|
+
* @description Get rounds by their circuit name.
|
|
188
|
+
* @param {string} name - The name of the circuit.
|
|
189
|
+
* @param {string} after - The cursor to start after.
|
|
190
|
+
* @param {number} [limit] - The number of rounds to retrieve.
|
|
191
|
+
* @returns {Promise<RoundsResponse>} The rounds response.
|
|
192
|
+
*/
|
|
193
|
+
async getRoundsByCircuitName(
|
|
194
|
+
name: string,
|
|
195
|
+
after: string,
|
|
196
|
+
limit?: number
|
|
197
|
+
): Promise<RoundsResponse> {
|
|
198
|
+
return await this.indexer.round.getRoundsByCircuitName(name, after, limit);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @method getRoundsByOperator
|
|
203
|
+
* @description Get rounds by their operator address.
|
|
204
|
+
* @param {string} address - The address of the operator.
|
|
205
|
+
* @param {string} after - The cursor to start after.
|
|
206
|
+
* @param {number} [limit] - The number of rounds to retrieve.
|
|
207
|
+
* @returns {Promise<RoundsResponse>} The rounds response.
|
|
208
|
+
*/
|
|
209
|
+
async getRoundsByOperator(
|
|
210
|
+
address: string,
|
|
211
|
+
after: string,
|
|
212
|
+
limit?: number
|
|
213
|
+
): Promise<RoundsResponse> {
|
|
214
|
+
return await this.indexer.round.getRoundsByOperator(address, after, limit);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* @method getOperatorByAddress
|
|
219
|
+
* @description Get an operator by their address.
|
|
220
|
+
* @param {string} address - The address of the operator.
|
|
221
|
+
* @returns {Promise<OperatorResponse>} The operator response.
|
|
222
|
+
*/
|
|
223
|
+
async getOperatorByAddress(address: string): Promise<OperatorResponse> {
|
|
224
|
+
return await this.indexer.operator.getOperatorByAddress(address);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* @method getOperators
|
|
229
|
+
* @description Get multiple operators.
|
|
230
|
+
* @param {string} after - The cursor to start after.
|
|
231
|
+
* @param {number} [limit] - The number of operators to retrieve.
|
|
232
|
+
* @returns {Promise<OperatorsResponse>} The operators response.
|
|
233
|
+
*/
|
|
234
|
+
async getOperators(
|
|
235
|
+
after: string,
|
|
236
|
+
limit?: number
|
|
237
|
+
): Promise<OperatorsResponse> {
|
|
238
|
+
return await this.indexer.operator.getOperators(after, limit);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* @method getCircuitByName
|
|
243
|
+
* @description Get a circuit by its name.
|
|
244
|
+
* @param {string} name - The name of the circuit.
|
|
245
|
+
* @returns {Promise<CircuitResponse>} The circuit response.
|
|
246
|
+
*/
|
|
247
|
+
async getCircuitByName(name: string): Promise<CircuitResponse> {
|
|
248
|
+
return await this.indexer.circuit.getCircuitByName(name);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* @method getCircuits
|
|
253
|
+
* @description Get all available circuits.
|
|
254
|
+
* @returns {Promise<CircuitsResponse>} The circuits response.
|
|
255
|
+
*/
|
|
256
|
+
async getCircuits(): Promise<CircuitsResponse> {
|
|
257
|
+
return await this.indexer.circuit.getCircuits();
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* @method getTransactionByHash
|
|
262
|
+
* @description Get a transaction by its hash.
|
|
263
|
+
* @param {string} hash - The hash of the transaction.
|
|
264
|
+
* @returns {Promise<TransactionResponse>} The transaction response.
|
|
265
|
+
*/
|
|
266
|
+
async getTransactionByHash(hash: string): Promise<TransactionResponse> {
|
|
267
|
+
return await this.indexer.transaction.getTransactionByHash(hash);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* @method getTransactions
|
|
272
|
+
* @description Get multiple transactions.
|
|
273
|
+
* @param {string} after - The cursor to start after.
|
|
274
|
+
* @param {number} [limit] - The number of transactions to retrieve.
|
|
275
|
+
* @returns {Promise<TransactionsResponse>} The transactions response.
|
|
276
|
+
*/
|
|
277
|
+
async getTransactions(
|
|
278
|
+
after: string,
|
|
279
|
+
limit?: number
|
|
280
|
+
): Promise<TransactionsResponse> {
|
|
281
|
+
return await this.indexer.transaction.getTransactions(after, limit);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* @method getTransactionsByContractAddress
|
|
286
|
+
* @description Get transactions by contract address.
|
|
287
|
+
* @param {string} address - The contract address.
|
|
288
|
+
* @param {string} after - The cursor to start after.
|
|
289
|
+
* @param {number} [limit] - The number of transactions to retrieve.
|
|
290
|
+
* @returns {Promise<TransactionsResponse>} The transactions response.
|
|
291
|
+
*/
|
|
292
|
+
async getTransactionsByContractAddress(
|
|
293
|
+
address: string,
|
|
294
|
+
after: string,
|
|
295
|
+
limit?: number
|
|
296
|
+
): Promise<TransactionsResponse> {
|
|
297
|
+
return await this.indexer.transaction.getTransactionsByContractAddress(
|
|
298
|
+
address,
|
|
299
|
+
after,
|
|
300
|
+
limit
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* @method getProofByContractAddress
|
|
306
|
+
* @description Get proof data by contract address.
|
|
307
|
+
* @param {string} address - The contract address.
|
|
308
|
+
* @returns {Promise<ProofResponse>} The proof response.
|
|
309
|
+
*/
|
|
310
|
+
async getProofByContractAddress(address: string): Promise<ProofResponse> {
|
|
311
|
+
return await this.indexer.proof.getProofByContractAddress(address);
|
|
312
|
+
}
|
|
313
|
+
}
|