@dorafactory/maci-sdk 0.0.7 → 0.0.9
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 +27 -7
- package/dist/index.js +751 -187
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +748 -187
- package/dist/index.mjs.map +1 -1
- package/dist/libs/circom/tree.d.ts +20 -20
- package/dist/libs/contract/ts/AMaci.client.d.ts +1 -1
- package/dist/libs/contract/ts/Maci.client.d.ts +21 -47
- package/dist/libs/contract/ts/Maci.types.d.ts +40 -31
- package/dist/libs/contract/ts/OracleMaci.client.d.ts +52 -52
- package/dist/libs/contract/ts/OracleMaci.types.d.ts +17 -7
- package/dist/libs/contract/ts/Registry.client.d.ts +2 -2
- package/dist/libs/contract/types.d.ts +2 -2
- package/dist/libs/errors/types.d.ts +1 -0
- package/dist/libs/http/http.d.ts +1 -1
- package/dist/libs/index.d.ts +3 -0
- package/dist/libs/indexer/indexer.d.ts +11 -2
- package/dist/libs/maci/index.d.ts +1 -0
- package/dist/libs/maci/maci.d.ts +64 -5
- package/dist/libs/oracle-certificate/oracle-certificate.d.ts +1 -21
- package/dist/libs/oracle-certificate/types.d.ts +12 -0
- package/dist/libs/query/event.d.ts +7 -0
- package/dist/libs/query/index.d.ts +1 -0
- package/dist/maci.d.ts +7 -5
- package/dist/types/index.d.ts +22 -0
- package/package.json +1 -1
- package/src/libs/const.ts +3 -2
- package/src/libs/contract/contract.ts +2 -6
- package/src/libs/contract/ts/AMaci.client.ts +868 -874
- package/src/libs/contract/ts/AMaci.types.ts +216 -216
- package/src/libs/contract/ts/Maci.client.ts +748 -888
- package/src/libs/contract/ts/Maci.types.ts +229 -224
- package/src/libs/contract/ts/OracleMaci.client.ts +623 -348
- package/src/libs/contract/ts/OracleMaci.types.ts +191 -138
- package/src/libs/contract/ts/Registry.client.ts +438 -446
- package/src/libs/contract/ts/Registry.types.ts +97 -97
- package/src/libs/contract/types.ts +6 -2
- package/src/libs/contract/utils.ts +9 -0
- package/src/libs/errors/types.ts +1 -0
- package/src/libs/http/http.ts +3 -7
- package/src/libs/index.ts +3 -0
- package/src/libs/indexer/indexer.ts +18 -0
- package/src/libs/maci/index.ts +1 -0
- package/src/libs/maci/maci.ts +302 -10
- package/src/libs/oracle-certificate/oracle-certificate.ts +19 -73
- package/src/libs/oracle-certificate/types.ts +15 -1
- package/src/libs/query/event.ts +78 -0
- package/src/libs/query/index.ts +1 -0
- package/src/maci.ts +27 -5
- package/src/types/index.ts +28 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { BalanceResponse, RoundResponse, RoundsResponse, OperatorResponse, OperatorsResponse, CircuitResponse, TransactionResponse, TransactionsResponse, CircuitsResponse, ProofResponse } from '../../types';
|
|
1
|
+
import { BalanceResponse, RoundResponse, RoundsResponse, OperatorResponse, OperatorsResponse, CircuitResponse, TransactionResponse, TransactionsResponse, CircuitsResponse, ProofResponse, SignUpEventsResponse } from '../../types';
|
|
2
2
|
import { IndexerParams } from './types';
|
|
3
3
|
import { Http } from '../http';
|
|
4
|
-
import { Round, UserAccount, Circuit, Operator, Proof, Transaction } from '../query';
|
|
4
|
+
import { Round, UserAccount, Circuit, Operator, Proof, Transaction, Event } from '../query';
|
|
5
5
|
/**
|
|
6
6
|
* @class Indexer
|
|
7
7
|
* @description This class is used to interact with Maci Indexer.
|
|
@@ -17,6 +17,7 @@ export declare class Indexer {
|
|
|
17
17
|
operator: Operator;
|
|
18
18
|
proof: Proof;
|
|
19
19
|
transaction: Transaction;
|
|
20
|
+
event: Event;
|
|
20
21
|
/**
|
|
21
22
|
* @constructor
|
|
22
23
|
* @param {IndexerParams} params - The parameters for the Maci Indexer instance.
|
|
@@ -130,4 +131,12 @@ export declare class Indexer {
|
|
|
130
131
|
* @returns {Promise<ProofResponse>} The proof response.
|
|
131
132
|
*/
|
|
132
133
|
getProofByContractAddress(address: string): Promise<ProofResponse>;
|
|
134
|
+
/**
|
|
135
|
+
* @method getStateIdxByPubKey
|
|
136
|
+
* @description Get the state index of a specific public key.
|
|
137
|
+
* @param {string} contractAddress - The contract address.
|
|
138
|
+
* @param {bigint[]} pubKey - The public key.
|
|
139
|
+
* @returns {Promise<SignUpEventsResponse>} The sign up events response.
|
|
140
|
+
*/
|
|
141
|
+
getSignUpEventByPubKey(contractAddress: string, pubKey: bigint[]): Promise<SignUpEventsResponse>;
|
|
133
142
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MACI } from './maci';
|
package/dist/libs/maci/maci.d.ts
CHANGED
|
@@ -1,14 +1,72 @@
|
|
|
1
1
|
import { OfflineSigner } from '@cosmjs/proto-signing';
|
|
2
2
|
import { Circom, PublicKey } from '../circom';
|
|
3
3
|
import { Contract } from '../contract';
|
|
4
|
+
import { Indexer } from '../indexer';
|
|
5
|
+
import { OracleCertificate } from '../oracle-certificate';
|
|
4
6
|
import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate';
|
|
7
|
+
import { CertificateEcosystem, ErrorResponse } from '../../types';
|
|
8
|
+
import { SignatureResponse } from '../oracle-certificate/types';
|
|
9
|
+
import { OracleWhitelistConfig } from '../contract/ts/OracleMaci.types';
|
|
10
|
+
export declare function isErrorResponse(response: unknown): response is ErrorResponse;
|
|
5
11
|
export declare class MACI {
|
|
6
12
|
circom: Circom;
|
|
7
13
|
contract: Contract;
|
|
8
|
-
|
|
14
|
+
indexer: Indexer;
|
|
15
|
+
oracleCertificate: OracleCertificate;
|
|
16
|
+
constructor({ circom, contract, indexer, oracleCertificate, }: {
|
|
9
17
|
circom: Circom;
|
|
10
18
|
contract: Contract;
|
|
19
|
+
indexer: Indexer;
|
|
20
|
+
oracleCertificate: OracleCertificate;
|
|
11
21
|
});
|
|
22
|
+
getStateIdxInc({ signer, address, contractAddress, }: {
|
|
23
|
+
signer: OfflineSigner;
|
|
24
|
+
address: string;
|
|
25
|
+
contractAddress: string;
|
|
26
|
+
}): Promise<string>;
|
|
27
|
+
getVoiceCreditBalance({ signer, stateIdx, contractAddress, }: {
|
|
28
|
+
signer: OfflineSigner;
|
|
29
|
+
stateIdx: number;
|
|
30
|
+
contractAddress: string;
|
|
31
|
+
}): Promise<string>;
|
|
32
|
+
getStateIdxByPubKey({ contractAddress, pubKey, }: {
|
|
33
|
+
contractAddress: string;
|
|
34
|
+
pubKey: bigint[];
|
|
35
|
+
}): Promise<number>;
|
|
36
|
+
queryWhitelistBalanceOf({ signer, address, contractAddress, certificate, mode, }: {
|
|
37
|
+
signer: OfflineSigner;
|
|
38
|
+
address: string;
|
|
39
|
+
contractAddress: string;
|
|
40
|
+
certificate?: string;
|
|
41
|
+
mode?: 'maci' | 'amaci';
|
|
42
|
+
}): Promise<string>;
|
|
43
|
+
isWhitelisted({ signer, address, contractAddress, }: {
|
|
44
|
+
signer: OfflineSigner;
|
|
45
|
+
address: string;
|
|
46
|
+
contractAddress: string;
|
|
47
|
+
}): Promise<boolean>;
|
|
48
|
+
getOracleWhitelistConfig({ signer, contractAddress, }: {
|
|
49
|
+
signer: OfflineSigner;
|
|
50
|
+
contractAddress: string;
|
|
51
|
+
}): Promise<OracleWhitelistConfig>;
|
|
52
|
+
getRoundInfo({ contractAddress }: {
|
|
53
|
+
contractAddress: string;
|
|
54
|
+
}): Promise<import("../../types").RoundType>;
|
|
55
|
+
getRoundCircuitType({ contractAddress }: {
|
|
56
|
+
contractAddress: string;
|
|
57
|
+
}): Promise<string>;
|
|
58
|
+
queryRoundIsQv({ contractAddress }: {
|
|
59
|
+
contractAddress: string;
|
|
60
|
+
}): Promise<boolean>;
|
|
61
|
+
queryRoundGasStation({ contractAddress }: {
|
|
62
|
+
contractAddress: string;
|
|
63
|
+
}): Promise<boolean>;
|
|
64
|
+
requestOracleCertificate({ signer, ecosystem, address, contractAddress, }: {
|
|
65
|
+
signer: OfflineSigner;
|
|
66
|
+
ecosystem: CertificateEcosystem;
|
|
67
|
+
address: string;
|
|
68
|
+
contractAddress: string;
|
|
69
|
+
}): Promise<SignatureResponse>;
|
|
12
70
|
signup({ signer, address, contractAddress, oracleCertificate, gasStation, }: {
|
|
13
71
|
signer: OfflineSigner;
|
|
14
72
|
address: string;
|
|
@@ -18,8 +76,9 @@ export declare class MACI {
|
|
|
18
76
|
signature: string;
|
|
19
77
|
};
|
|
20
78
|
gasStation?: boolean;
|
|
21
|
-
}): Promise<
|
|
22
|
-
|
|
79
|
+
}): Promise<import("@cosmjs/cosmwasm-stargate").ExecuteResult>;
|
|
80
|
+
private processVoteOptions;
|
|
81
|
+
vote({ signer, address, stateIdx, contractAddress, selectedOptions, operatorCoordPubKey, gasStation, }: {
|
|
23
82
|
signer: OfflineSigner;
|
|
24
83
|
address: string;
|
|
25
84
|
stateIdx: number;
|
|
@@ -30,8 +89,8 @@ export declare class MACI {
|
|
|
30
89
|
}[];
|
|
31
90
|
operatorCoordPubKey: PublicKey;
|
|
32
91
|
gasStation?: boolean;
|
|
33
|
-
})
|
|
34
|
-
|
|
92
|
+
}): Promise<import("@cosmjs/cosmwasm-stargate").DeliverTxResponse>;
|
|
93
|
+
publishMessage({ client, address, payload, contractAddress, gasStation, }: {
|
|
35
94
|
client: SigningCosmWasmClient;
|
|
36
95
|
address: string;
|
|
37
96
|
payload: {
|
|
@@ -1,24 +1,4 @@
|
|
|
1
|
-
import { OracleCertificateParams } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* @class Indexer
|
|
4
|
-
* @description This class is used to interact with Maci Indexer.
|
|
5
|
-
*/
|
|
6
|
-
export interface SignatureRequest {
|
|
7
|
-
address: string;
|
|
8
|
-
height: string;
|
|
9
|
-
contractAddress: string;
|
|
10
|
-
amount?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface SignatureResponse {
|
|
13
|
-
code: number;
|
|
14
|
-
data?: {
|
|
15
|
-
signature: string;
|
|
16
|
-
};
|
|
17
|
-
error?: {
|
|
18
|
-
message: string;
|
|
19
|
-
type: string;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
1
|
+
import { OracleCertificateParams, SignatureRequest, SignatureResponse } from './types';
|
|
22
2
|
export declare class OracleCertificate {
|
|
23
3
|
private certificateApiEndpoint;
|
|
24
4
|
private http;
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
+
import { CertificateEcosystem } from '../../types';
|
|
1
2
|
import { Http } from '../http/http';
|
|
2
3
|
export type OracleCertificateParams = {
|
|
3
4
|
certificateApiEndpoint: string;
|
|
4
5
|
http: Http;
|
|
5
6
|
};
|
|
7
|
+
export type SignatureRequest = {
|
|
8
|
+
ecosystem: CertificateEcosystem;
|
|
9
|
+
address: string;
|
|
10
|
+
height: string;
|
|
11
|
+
contractAddress: string;
|
|
12
|
+
};
|
|
13
|
+
export type SignatureResponse = {
|
|
14
|
+
signature: string;
|
|
15
|
+
amount: string;
|
|
16
|
+
snapshotHeight: string;
|
|
17
|
+
};
|
package/dist/maci.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { BalanceResponse, ClientParams, RoundResponse, RoundsResponse, OperatorResponse, OperatorsResponse, CircuitResponse, TransactionResponse, TransactionsResponse, CircuitsResponse, ProofResponse } from './types';
|
|
2
|
-
import { Http, Indexer, Contract } from './libs';
|
|
2
|
+
import { Http, Indexer, Contract, OracleCertificate, Circom, MACI } from './libs';
|
|
3
3
|
import { CreateAMaciRoundParams, CreateMaciRoundParams, CreateOracleMaciRoundParams } from './libs/contract/types';
|
|
4
4
|
import { OfflineSigner } from '@cosmjs/proto-signing';
|
|
5
|
-
import { Circom } from './libs/circom';
|
|
6
5
|
/**
|
|
7
6
|
* @class MaciClient
|
|
8
7
|
* @description This class is used to interact with Maci Client.
|
|
@@ -11,20 +10,23 @@ export declare class MaciClient {
|
|
|
11
10
|
rpcEndpoint: string;
|
|
12
11
|
restEndpoint: string;
|
|
13
12
|
apiEndpoint: string;
|
|
13
|
+
certificateApiEndpoint: string;
|
|
14
14
|
registryAddress: string;
|
|
15
15
|
maciCodeId: number;
|
|
16
16
|
oracleCodeId: number;
|
|
17
|
+
feegrantOperator: string;
|
|
18
|
+
whitelistBackendPubkey: string;
|
|
17
19
|
http: Http;
|
|
18
20
|
indexer: Indexer;
|
|
19
21
|
contract: Contract;
|
|
20
22
|
circom: Circom;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
oracleCertificate: OracleCertificate;
|
|
24
|
+
maci: MACI;
|
|
23
25
|
/**
|
|
24
26
|
* @constructor
|
|
25
27
|
* @param {ClientParams} params - The parameters for the Maci Client instance.
|
|
26
28
|
*/
|
|
27
|
-
constructor({ network, rpcEndpoint, restEndpoint, apiEndpoint, registryAddress, maciCodeId, oracleCodeId, customFetch, defaultOptions, feegrantOperator, whitelistBackendPubkey, }: ClientParams);
|
|
29
|
+
constructor({ network, rpcEndpoint, restEndpoint, apiEndpoint, registryAddress, maciCodeId, oracleCodeId, customFetch, defaultOptions, feegrantOperator, whitelistBackendPubkey, certificateApiEndpoint, }: ClientParams);
|
|
28
30
|
oracleMaciClient({ signer, contractAddress, }: {
|
|
29
31
|
signer: OfflineSigner;
|
|
30
32
|
contractAddress: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -13,11 +13,13 @@ export declare enum MaciRoundType {
|
|
|
13
13
|
AMACI = "1",
|
|
14
14
|
ORACLE_MACI = "2"
|
|
15
15
|
}
|
|
16
|
+
export type CertificateEcosystem = 'cosmoshub' | 'doravota';
|
|
16
17
|
export type ClientParams = {
|
|
17
18
|
network: 'mainnet' | 'testnet';
|
|
18
19
|
rpcEndpoint?: string;
|
|
19
20
|
restEndpoint?: string;
|
|
20
21
|
apiEndpoint?: string;
|
|
22
|
+
certificateApiEndpoint?: string;
|
|
21
23
|
registryAddress?: string;
|
|
22
24
|
maciCodeId?: number;
|
|
23
25
|
oracleCodeId?: number;
|
|
@@ -122,6 +124,16 @@ export type CircuitType = {
|
|
|
122
124
|
zipUrl: string;
|
|
123
125
|
roundCount?: number;
|
|
124
126
|
};
|
|
127
|
+
export type SignUpEventType = {
|
|
128
|
+
id: string;
|
|
129
|
+
blockHeight: string;
|
|
130
|
+
txHash: string;
|
|
131
|
+
contractAddress: string;
|
|
132
|
+
timestamp: string;
|
|
133
|
+
pubKey: string;
|
|
134
|
+
stateIdx: number;
|
|
135
|
+
balance: string;
|
|
136
|
+
};
|
|
125
137
|
export type CircuitsCountGraphqlResponse = {
|
|
126
138
|
data: {
|
|
127
139
|
rounds: {
|
|
@@ -270,3 +282,13 @@ export type ProofGraphqlResponse = {
|
|
|
270
282
|
proofData: ProofType;
|
|
271
283
|
};
|
|
272
284
|
};
|
|
285
|
+
export type SignUpEventsResponse = SuccessResponse<{
|
|
286
|
+
signUpEvents: SignUpEventType[];
|
|
287
|
+
}> | ErrorResponse;
|
|
288
|
+
export type SignUpEventsGraphqlResponse = {
|
|
289
|
+
data: {
|
|
290
|
+
signUpEvents: {
|
|
291
|
+
nodes: SignUpEventType[];
|
|
292
|
+
};
|
|
293
|
+
};
|
|
294
|
+
};
|
package/package.json
CHANGED
package/src/libs/const.ts
CHANGED
|
@@ -166,7 +166,8 @@ export function getDefaultParams(
|
|
|
166
166
|
rpcEndpoint: 'https://vota-rpc.dorafactory.org',
|
|
167
167
|
restEndpoint: 'https://vota-rest.dorafactory.org',
|
|
168
168
|
apiEndpoint: 'https://vota-api.dorafactory.org',
|
|
169
|
-
certificateApiEndpoint:
|
|
169
|
+
certificateApiEndpoint:
|
|
170
|
+
'https://vota-certificate-api.dorafactory.org/api/v1',
|
|
170
171
|
registryAddress:
|
|
171
172
|
'dora1smg5qp5trjdkcekdjssqpjehdjf6n4cjss0clyvqcud3t3u3948s8rmgg4',
|
|
172
173
|
maciCodeId: 106,
|
|
@@ -183,7 +184,7 @@ export function getDefaultParams(
|
|
|
183
184
|
restEndpoint: 'https://vota-testnet-rest.dorafactory.org',
|
|
184
185
|
apiEndpoint: 'https://vota-testnet-api.dorafactory.org',
|
|
185
186
|
certificateApiEndpoint:
|
|
186
|
-
'https://vota-testnet-certificate-api.dorafactory.org',
|
|
187
|
+
'https://vota-testnet-certificate-api.dorafactory.org/api/v1',
|
|
187
188
|
registryAddress:
|
|
188
189
|
'dora13c8aecstyxrhax9znvvh5zey89edrmd2k5va57pxvpe3fxtfsfeqlhsjnd',
|
|
189
190
|
maciCodeId: 107,
|
|
@@ -115,7 +115,6 @@ export class Contract {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
|
-
console.log(`Deploy tx: ${res.transactionHash} - ${contractAddress}`);
|
|
119
118
|
return contractAddress;
|
|
120
119
|
}
|
|
121
120
|
|
|
@@ -178,7 +177,7 @@ export class Contract {
|
|
|
178
177
|
certification_system: maciCertSystem,
|
|
179
178
|
qtr_lib: QTR_LIB,
|
|
180
179
|
},
|
|
181
|
-
|
|
180
|
+
`[MACI] ${title}`,
|
|
182
181
|
'auto'
|
|
183
182
|
);
|
|
184
183
|
|
|
@@ -249,13 +248,10 @@ export class Contract {
|
|
|
249
248
|
qtr_lib: QTR_LIB,
|
|
250
249
|
feegrant_operator: this.feegrantOperator,
|
|
251
250
|
},
|
|
252
|
-
|
|
251
|
+
`[Oracle MACI] ${title}`,
|
|
253
252
|
'auto'
|
|
254
253
|
);
|
|
255
254
|
|
|
256
|
-
// console.log(
|
|
257
|
-
// `Deploy tx: ${instantiateResponse.transactionHash} - ${instantiateResponse.contractAddress} `
|
|
258
|
-
// );
|
|
259
255
|
return instantiateResponse;
|
|
260
256
|
}
|
|
261
257
|
|