@dorafactory/maci-sdk 0.0.4 → 0.0.6
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 +22 -7
- package/dist/index.js +41 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -12
- package/dist/index.mjs.map +1 -1
- package/dist/libs/circom/circomlib.d.ts +39 -0
- package/dist/libs/circom/index.d.ts +3 -0
- package/dist/libs/circom/tree.d.ts +23 -0
- package/dist/libs/contract/contract.d.ts +4 -2
- package/dist/libs/contract/types.d.ts +2 -4
- package/dist/libs/contract/utils.d.ts +2 -2
- package/dist/libs/contract/vars.d.ts +14 -16
- package/dist/libs/oracle-certificate/index.d.ts +1 -0
- package/dist/libs/oracle-certificate/oracle-certificate.d.ts +27 -0
- package/dist/libs/oracle-certificate/types.d.ts +5 -0
- package/dist/maci.d.ts +3 -1
- package/dist/types/index.d.ts +4 -0
- package/package.json +2 -2
- package/src/libs/contract/contract.ts +8 -4
- package/src/libs/contract/types.ts +4 -4
- package/src/libs/contract/utils.ts +9 -2
- package/src/libs/contract/vars.ts +45 -18
- package/src/libs/oracle-certificate/index.ts +1 -0
- package/src/libs/oracle-certificate/oracle-certificate.ts +90 -0
- package/src/libs/oracle-certificate/types.ts +6 -0
- package/src/maci.ts +11 -0
- package/src/types/index.ts +4 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
type MixedData<T> = T | Array<MixedData<T>> | {
|
|
2
|
+
[key: string]: MixedData<T>;
|
|
3
|
+
};
|
|
4
|
+
export type PrivateKey = bigint;
|
|
5
|
+
export type PublicKey = [bigint, bigint];
|
|
6
|
+
export interface Account {
|
|
7
|
+
privKey: PrivateKey;
|
|
8
|
+
pubKey: PublicKey;
|
|
9
|
+
formatedPrivKey: PrivateKey;
|
|
10
|
+
}
|
|
11
|
+
export declare const stringizing: (o: MixedData<bigint>, path?: MixedData<bigint>[]) => MixedData<string>;
|
|
12
|
+
export declare const genKeypair: (pkey?: PrivateKey) => Account;
|
|
13
|
+
export declare const genEcdhSharedKey: (privKey: PrivateKey, pubKey: PublicKey) => PublicKey;
|
|
14
|
+
export declare const genMessageFactory: (stateIdx: number, signPriKey: PrivateKey, signPubKey: PublicKey, coordPubKey: PublicKey) => (encPriKey: PrivateKey, nonce: number, voIdx: number, newVotes: number, isLastCmd: boolean, salt?: bigint) => bigint[];
|
|
15
|
+
export declare const batchGenMessage: (stateIdx: number, account: Account, coordPubKey: PublicKey, plan: [number, number][]) => {
|
|
16
|
+
msg: bigint[];
|
|
17
|
+
encPubkeys: PublicKey;
|
|
18
|
+
}[];
|
|
19
|
+
export declare const privateKeyFromTxt: (txt: string) => Account | undefined;
|
|
20
|
+
export declare const genAddKeyProof: (depth: number, { coordPubKey, oldKey, deactivates, }: {
|
|
21
|
+
coordPubKey: PublicKey;
|
|
22
|
+
oldKey: Account;
|
|
23
|
+
deactivates: bigint[][];
|
|
24
|
+
}) => Promise<{
|
|
25
|
+
inputHash: bigint;
|
|
26
|
+
coordPubKey: PublicKey;
|
|
27
|
+
deactivateRoot: any;
|
|
28
|
+
deactivateIndex: number;
|
|
29
|
+
deactivateLeaf: any;
|
|
30
|
+
c1: bigint[];
|
|
31
|
+
c2: bigint[];
|
|
32
|
+
randomVal: bigint;
|
|
33
|
+
d1: bigint[];
|
|
34
|
+
d2: bigint[];
|
|
35
|
+
deactivateLeafPathElements: any;
|
|
36
|
+
nullifier: any;
|
|
37
|
+
oldPrivateKey: bigint;
|
|
38
|
+
} | null>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export = Tree;
|
|
2
|
+
declare class Tree {
|
|
3
|
+
constructor(degree: any, depth: any, zero: any);
|
|
4
|
+
DEPTH: any;
|
|
5
|
+
HEIGHT: any;
|
|
6
|
+
DEGREE: any;
|
|
7
|
+
LEAVES_COUNT: number;
|
|
8
|
+
LEAVES_IDX_0: number;
|
|
9
|
+
NODES_COUNT: number;
|
|
10
|
+
get root(): any;
|
|
11
|
+
initZero(zero: any): void;
|
|
12
|
+
zeros: any[] | undefined;
|
|
13
|
+
initNodes(): void;
|
|
14
|
+
nodes: any[] | undefined;
|
|
15
|
+
initLeaves(leaves: any): void;
|
|
16
|
+
leaf(leafIdx: any): any;
|
|
17
|
+
leaves(): any[];
|
|
18
|
+
updateLeaf(leafIdx: any, leaf: any): void;
|
|
19
|
+
pathIdxOf(leafIdx: any): number[];
|
|
20
|
+
pathElementOf(leafIdx: any): any[][];
|
|
21
|
+
subTree(length: any): Tree;
|
|
22
|
+
_update(nodeIdx: any): void;
|
|
23
|
+
}
|
|
@@ -10,10 +10,12 @@ export declare class Contract {
|
|
|
10
10
|
registryAddress: string;
|
|
11
11
|
maciCodeId: number;
|
|
12
12
|
oracleCodeId: number;
|
|
13
|
-
|
|
13
|
+
feegrantOperator: string;
|
|
14
|
+
whitelistBackendPubkey: string;
|
|
15
|
+
constructor({ rpcEndpoint, registryAddress, maciCodeId, oracleCodeId, feegrantOperator, whitelistBackendPubkey, }: ContractParams);
|
|
14
16
|
createAMaciRound({ signer, startVoting, endVoting, operator, whitelist, title, description, link, maxVoter, maxOption, voiceCreditAmount, circuitType, preDeactivateRoot, }: CreateAMaciRoundParams): Promise<string>;
|
|
15
17
|
createMaciRound({ signer, operatorPubkey, startVoting, endVoting, whitelist, title, description, link, maxVoter, maxOption, circuitType, certSystemType, }: CreateMaciRoundParams): Promise<import("@cosmjs/cosmwasm-stargate").InstantiateResult>;
|
|
16
|
-
createOracleMaciRound({ signer, operatorPubkey, startVoting, endVoting, title, description, link, maxVoter, maxOption, circuitType,
|
|
18
|
+
createOracleMaciRound({ signer, operatorPubkey, startVoting, endVoting, title, description, link, maxVoter, maxOption, circuitType, whitelistEcosystem, whitelistSnapshotHeight, whitelistVotingPowerArgs, }: CreateOracleMaciRoundParams): Promise<import("@cosmjs/cosmwasm-stargate").InstantiateResult>;
|
|
17
19
|
queryRoundInfo({ signer, roundAddress, }: {
|
|
18
20
|
signer: OfflineSigner;
|
|
19
21
|
roundAddress: string;
|
|
@@ -26,13 +26,11 @@ export type CreateMaciRoundParams = {
|
|
|
26
26
|
} & CreateRoundParams;
|
|
27
27
|
export type CreateOracleMaciRoundParams = {
|
|
28
28
|
operatorPubkey: string;
|
|
29
|
-
whitelistEcosystem:
|
|
29
|
+
whitelistEcosystem: 'cosmoshub' | 'doravota';
|
|
30
30
|
whitelistSnapshotHeight: string;
|
|
31
31
|
whitelistVotingPowerArgs: {
|
|
32
|
-
mode:
|
|
32
|
+
mode: 'slope' | 'threshold';
|
|
33
33
|
slope: string;
|
|
34
34
|
threshold: string;
|
|
35
35
|
};
|
|
36
|
-
whitelistBackendPubkey?: string;
|
|
37
|
-
feegrantOperator?: string;
|
|
38
36
|
} & CreateRoundParams;
|
|
@@ -17,7 +17,7 @@ export declare function getContractParams(type: MaciRoundType, circuitType: Maci
|
|
|
17
17
|
vk_delta_2: string;
|
|
18
18
|
vk_ic0: string;
|
|
19
19
|
vk_ic1: string;
|
|
20
|
-
} | null;
|
|
20
|
+
} | null | undefined;
|
|
21
21
|
groth16TallyVkey: {
|
|
22
22
|
vk_alpha1: string;
|
|
23
23
|
vk_beta_2: string;
|
|
@@ -25,7 +25,7 @@ export declare function getContractParams(type: MaciRoundType, circuitType: Maci
|
|
|
25
25
|
vk_delta_2: string;
|
|
26
26
|
vk_ic0: string;
|
|
27
27
|
vk_ic1: string;
|
|
28
|
-
} | null;
|
|
28
|
+
} | null | undefined;
|
|
29
29
|
plonkProcessVkey: {
|
|
30
30
|
n: number;
|
|
31
31
|
num_inputs: number;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
type Groth16VkeyType = {
|
|
2
|
+
vk_alpha1: string;
|
|
3
|
+
vk_beta_2: string;
|
|
4
|
+
vk_gamma_2: string;
|
|
5
|
+
vk_delta_2: string;
|
|
6
|
+
vk_ic0: string;
|
|
7
|
+
vk_ic1: string;
|
|
8
|
+
};
|
|
1
9
|
type CircuitInfoType = {
|
|
2
10
|
[key: string]: {
|
|
3
11
|
parameter: {
|
|
@@ -7,22 +15,12 @@ type CircuitInfoType = {
|
|
|
7
15
|
message_batch_size: string;
|
|
8
16
|
};
|
|
9
17
|
groth16: {
|
|
10
|
-
process_vkey
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
vk_ic1: string;
|
|
17
|
-
};
|
|
18
|
-
tally_vkey: {
|
|
19
|
-
vk_alpha1: string;
|
|
20
|
-
vk_beta_2: string;
|
|
21
|
-
vk_gamma_2: string;
|
|
22
|
-
vk_delta_2: string;
|
|
23
|
-
vk_ic0: string;
|
|
24
|
-
vk_ic1: string;
|
|
25
|
-
};
|
|
18
|
+
process_vkey?: Groth16VkeyType;
|
|
19
|
+
tally_vkey?: Groth16VkeyType;
|
|
20
|
+
process_1p1v_vkey?: Groth16VkeyType;
|
|
21
|
+
tally_1p1v_vkey?: Groth16VkeyType;
|
|
22
|
+
process_qv_vkey?: Groth16VkeyType;
|
|
23
|
+
tally_qv_vkey?: Groth16VkeyType;
|
|
26
24
|
};
|
|
27
25
|
plonk?: {
|
|
28
26
|
process_vkey: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { OracleCertificate } from './oracle-certificate';
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
}
|
|
22
|
+
export declare class OracleCertificate {
|
|
23
|
+
private certificateApiEndpoint;
|
|
24
|
+
private http;
|
|
25
|
+
constructor({ certificateApiEndpoint, http }: OracleCertificateParams);
|
|
26
|
+
sign(data: SignatureRequest): Promise<SignatureResponse>;
|
|
27
|
+
}
|
package/dist/maci.d.ts
CHANGED
|
@@ -16,11 +16,13 @@ export declare class MaciClient {
|
|
|
16
16
|
http: Http;
|
|
17
17
|
indexer: Indexer;
|
|
18
18
|
contract: Contract;
|
|
19
|
+
feegrantOperator: string;
|
|
20
|
+
whitelistBackendPubkey: string;
|
|
19
21
|
/**
|
|
20
22
|
* @constructor
|
|
21
23
|
* @param {ClientParams} params - The parameters for the Maci Client instance.
|
|
22
24
|
*/
|
|
23
|
-
constructor({ network, rpcEndpoint, restEndpoint, apiEndpoint, registryAddress, maciCodeId, oracleCodeId, customFetch, defaultOptions, }: ClientParams);
|
|
25
|
+
constructor({ network, rpcEndpoint, restEndpoint, apiEndpoint, registryAddress, maciCodeId, oracleCodeId, customFetch, defaultOptions, feegrantOperator, whitelistBackendPubkey, }: ClientParams);
|
|
24
26
|
oracleMaciClient({ signer, contractAddress, }: {
|
|
25
27
|
signer: OfflineSigner;
|
|
26
28
|
contractAddress: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -23,12 +23,16 @@ export type ClientParams = {
|
|
|
23
23
|
oracleCodeId?: number;
|
|
24
24
|
customFetch?: typeof fetch;
|
|
25
25
|
defaultOptions?: FetchOptions;
|
|
26
|
+
feegrantOperator?: string;
|
|
27
|
+
whitelistBackendPubkey?: string;
|
|
26
28
|
};
|
|
27
29
|
export type ContractParams = {
|
|
28
30
|
rpcEndpoint: string;
|
|
29
31
|
registryAddress: string;
|
|
30
32
|
maciCodeId: number;
|
|
31
33
|
oracleCodeId: number;
|
|
34
|
+
whitelistBackendPubkey: string;
|
|
35
|
+
feegrantOperator: string;
|
|
32
36
|
};
|
|
33
37
|
export type TransactionType = {
|
|
34
38
|
id: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dorafactory/maci-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "SDK for interacting with maci",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"maci",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@cosmjs/launchpad": "^0.27.1",
|
|
35
35
|
"@cosmjs/proto-signing": "^0.32.1",
|
|
36
36
|
"@cosmjs/stargate": "^0.32.1",
|
|
37
|
-
"
|
|
37
|
+
"ethers": "^6.13.4",
|
|
38
38
|
"assert": "^2.1.0",
|
|
39
39
|
"bech32": "1.1.4",
|
|
40
40
|
"superstruct": "^1.0.3",
|
|
@@ -39,17 +39,23 @@ export class Contract {
|
|
|
39
39
|
public registryAddress: string;
|
|
40
40
|
public maciCodeId: number;
|
|
41
41
|
public oracleCodeId: number;
|
|
42
|
+
public feegrantOperator: string;
|
|
43
|
+
public whitelistBackendPubkey: string;
|
|
42
44
|
|
|
43
45
|
constructor({
|
|
44
46
|
rpcEndpoint,
|
|
45
47
|
registryAddress,
|
|
46
48
|
maciCodeId,
|
|
47
49
|
oracleCodeId,
|
|
50
|
+
feegrantOperator,
|
|
51
|
+
whitelistBackendPubkey,
|
|
48
52
|
}: ContractParams) {
|
|
49
53
|
this.rpcEndpoint = rpcEndpoint;
|
|
50
54
|
this.registryAddress = registryAddress;
|
|
51
55
|
this.maciCodeId = maciCodeId;
|
|
52
56
|
this.oracleCodeId = oracleCodeId;
|
|
57
|
+
this.feegrantOperator = feegrantOperator;
|
|
58
|
+
this.whitelistBackendPubkey = whitelistBackendPubkey;
|
|
53
59
|
}
|
|
54
60
|
|
|
55
61
|
async createAMaciRound({
|
|
@@ -190,11 +196,9 @@ export class Contract {
|
|
|
190
196
|
maxVoter,
|
|
191
197
|
maxOption,
|
|
192
198
|
circuitType,
|
|
193
|
-
whitelistBackendPubkey,
|
|
194
199
|
whitelistEcosystem,
|
|
195
200
|
whitelistSnapshotHeight,
|
|
196
201
|
whitelistVotingPowerArgs,
|
|
197
|
-
feegrantOperator,
|
|
198
202
|
}: CreateOracleMaciRoundParams) {
|
|
199
203
|
const start_time = (startVoting.getTime() * 1_000_000).toString();
|
|
200
204
|
const end_time = (endVoting.getTime() * 1_000_000).toString();
|
|
@@ -236,14 +240,14 @@ export class Contract {
|
|
|
236
240
|
plonk_process_vkey: plonkProcessVkey,
|
|
237
241
|
plonk_tally_vkey: plonkTallyVkey,
|
|
238
242
|
max_vote_options: maxOption,
|
|
239
|
-
whitelist_backend_pubkey: whitelistBackendPubkey,
|
|
243
|
+
whitelist_backend_pubkey: this.whitelistBackendPubkey,
|
|
240
244
|
whitelist_ecosystem: whitelistEcosystem,
|
|
241
245
|
whitelist_snapshot_height: whitelistSnapshotHeight,
|
|
242
246
|
whitelist_voting_power_args: whitelistVotingPowerArgs,
|
|
243
247
|
circuit_type: maciVoteType,
|
|
244
248
|
certification_system: maciCertSystem,
|
|
245
249
|
qtr_lib: QTR_LIB,
|
|
246
|
-
feegrant_operator: feegrantOperator,
|
|
250
|
+
feegrant_operator: this.feegrantOperator,
|
|
247
251
|
},
|
|
248
252
|
'[Oracle MACI]' + title,
|
|
249
253
|
'auto'
|
|
@@ -30,13 +30,13 @@ export type CreateMaciRoundParams = {
|
|
|
30
30
|
|
|
31
31
|
export type CreateOracleMaciRoundParams = {
|
|
32
32
|
operatorPubkey: string;
|
|
33
|
-
whitelistEcosystem:
|
|
33
|
+
whitelistEcosystem: 'cosmoshub' | 'doravota';
|
|
34
34
|
whitelistSnapshotHeight: string;
|
|
35
35
|
whitelistVotingPowerArgs: {
|
|
36
|
-
mode:
|
|
36
|
+
mode: 'slope' | 'threshold';
|
|
37
37
|
slope: string;
|
|
38
38
|
threshold: string;
|
|
39
39
|
};
|
|
40
|
-
whitelistBackendPubkey?: string;
|
|
41
|
-
feegrantOperator?: string;
|
|
40
|
+
// whitelistBackendPubkey?: string;
|
|
41
|
+
// feegrantOperator?: string;
|
|
42
42
|
} & CreateRoundParams;
|
|
@@ -113,8 +113,15 @@ export function getContractParams(
|
|
|
113
113
|
// vote_option_tree_depth: 3
|
|
114
114
|
parameters = CIRCUIT_INFO['9-4-3-625'].parameter;
|
|
115
115
|
if (proofSystem === MaciCertSystemType.GROTH16) {
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
if (circuitType === MaciCircuitType.IP1V) {
|
|
117
|
+
groth16ProcessVkey =
|
|
118
|
+
CIRCUIT_INFO['9-4-3-625']['groth16'].process_1p1v_vkey;
|
|
119
|
+
groth16TallyVkey = CIRCUIT_INFO['9-4-3-625']['groth16'].tally_1p1v_vkey;
|
|
120
|
+
} else if (circuitType === MaciCircuitType.QV) {
|
|
121
|
+
groth16ProcessVkey =
|
|
122
|
+
CIRCUIT_INFO['9-4-3-625']['groth16'].process_qv_vkey;
|
|
123
|
+
groth16TallyVkey = CIRCUIT_INFO['9-4-3-625']['groth16'].tally_qv_vkey;
|
|
124
|
+
}
|
|
118
125
|
} else if (proofSystem === MaciCertSystemType.PLONK) {
|
|
119
126
|
throw new Error('PLONK is not supported for MACI-9');
|
|
120
127
|
}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { GasPrice } from '@cosmjs/stargate';
|
|
2
2
|
|
|
3
|
+
type Groth16VkeyType = {
|
|
4
|
+
vk_alpha1: string;
|
|
5
|
+
vk_beta_2: string;
|
|
6
|
+
vk_gamma_2: string;
|
|
7
|
+
vk_delta_2: string;
|
|
8
|
+
vk_ic0: string;
|
|
9
|
+
vk_ic1: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
3
12
|
type CircuitInfoType = {
|
|
4
13
|
[key: string]: {
|
|
5
14
|
parameter: {
|
|
@@ -9,22 +18,12 @@ type CircuitInfoType = {
|
|
|
9
18
|
message_batch_size: string;
|
|
10
19
|
};
|
|
11
20
|
groth16: {
|
|
12
|
-
process_vkey
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
vk_ic1: string;
|
|
19
|
-
};
|
|
20
|
-
tally_vkey: {
|
|
21
|
-
vk_alpha1: string;
|
|
22
|
-
vk_beta_2: string;
|
|
23
|
-
vk_gamma_2: string;
|
|
24
|
-
vk_delta_2: string;
|
|
25
|
-
vk_ic0: string;
|
|
26
|
-
vk_ic1: string;
|
|
27
|
-
};
|
|
21
|
+
process_vkey?: Groth16VkeyType;
|
|
22
|
+
tally_vkey?: Groth16VkeyType;
|
|
23
|
+
process_1p1v_vkey?: Groth16VkeyType;
|
|
24
|
+
tally_1p1v_vkey?: Groth16VkeyType;
|
|
25
|
+
process_qv_vkey?: Groth16VkeyType;
|
|
26
|
+
tally_qv_vkey?: Groth16VkeyType;
|
|
28
27
|
};
|
|
29
28
|
plonk?: {
|
|
30
29
|
process_vkey: {
|
|
@@ -358,7 +357,35 @@ export const CIRCUIT_INFO: CircuitInfoType = {
|
|
|
358
357
|
vote_option_tree_depth: '3',
|
|
359
358
|
},
|
|
360
359
|
groth16: {
|
|
361
|
-
|
|
360
|
+
process_1p1v_vkey: {
|
|
361
|
+
vk_alpha1:
|
|
362
|
+
'2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926',
|
|
363
|
+
vk_beta_2:
|
|
364
|
+
'0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8',
|
|
365
|
+
vk_gamma_2:
|
|
366
|
+
'198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa',
|
|
367
|
+
vk_delta_2:
|
|
368
|
+
'198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa',
|
|
369
|
+
vk_ic0:
|
|
370
|
+
'1195be678487bbc8c0ae726c0985a5caf6f75e3f8327926926c4f89e498ad733043e46e10b506d194b27275f402bc3fb208a2f5be69662e7c9898d1c0ece4f04',
|
|
371
|
+
vk_ic1:
|
|
372
|
+
'10c34362189a7ee44b1c5e57755d7e0d672dba552e614d5cd9a53081bee2333425879fa4e4a9e3fff287824cce35f94725ca0edb60a4ffcbf50becb2fd96cb0b',
|
|
373
|
+
},
|
|
374
|
+
tally_1p1v_vkey: {
|
|
375
|
+
vk_alpha1:
|
|
376
|
+
'2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926',
|
|
377
|
+
vk_beta_2:
|
|
378
|
+
'0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8',
|
|
379
|
+
vk_gamma_2:
|
|
380
|
+
'198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa',
|
|
381
|
+
vk_delta_2:
|
|
382
|
+
'198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa',
|
|
383
|
+
vk_ic0:
|
|
384
|
+
'2ec191d51bd4ac7cd65cb3dd2decfa4e56c4f167bbc40e2c9e1ca728f9bc5b0e2ed1c82319dc554aea5ff2ca05d6f4d4d61e8f059a8c05d4b4faabae5128a437',
|
|
385
|
+
vk_ic1:
|
|
386
|
+
'2f19db8f03b6b5896abc6989273371b14833356f45c12685e57bc292eccc53570cb629e551df179f73b9f3391946bad29739af8b808c80b0f057af45aea59849',
|
|
387
|
+
},
|
|
388
|
+
process_qv_vkey: {
|
|
362
389
|
vk_alpha1:
|
|
363
390
|
'2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926',
|
|
364
391
|
vk_beta_2:
|
|
@@ -372,7 +399,7 @@ export const CIRCUIT_INFO: CircuitInfoType = {
|
|
|
372
399
|
vk_ic1:
|
|
373
400
|
'0274a24117a799333754d646e35f37292e7ca9984fb8781211504b158d69d2c422aa99651ca207c77084988b16ef363664b9cf36071f7131dcc10b98ea27d7f6',
|
|
374
401
|
},
|
|
375
|
-
|
|
402
|
+
tally_qv_vkey: {
|
|
376
403
|
vk_alpha1:
|
|
377
404
|
'2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926',
|
|
378
405
|
vk_beta_2:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { OracleCertificate } from './oracle-certificate';
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BalanceResponse,
|
|
3
|
+
RoundResponse,
|
|
4
|
+
RoundsResponse,
|
|
5
|
+
OperatorResponse,
|
|
6
|
+
OperatorsResponse,
|
|
7
|
+
CircuitResponse,
|
|
8
|
+
TransactionResponse,
|
|
9
|
+
TransactionsResponse,
|
|
10
|
+
CircuitsResponse,
|
|
11
|
+
ProofResponse,
|
|
12
|
+
} from '../../types';
|
|
13
|
+
import { Http } from '../http';
|
|
14
|
+
import {
|
|
15
|
+
Round,
|
|
16
|
+
Account,
|
|
17
|
+
Circuit,
|
|
18
|
+
Operator,
|
|
19
|
+
Proof,
|
|
20
|
+
Transaction,
|
|
21
|
+
} from '../query';
|
|
22
|
+
import { handleError, ErrorType } from '../errors';
|
|
23
|
+
import { ERROR } from '../errors/types';
|
|
24
|
+
import { OracleCertificateParams } from './types';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @class Indexer
|
|
28
|
+
* @description This class is used to interact with Maci Indexer.
|
|
29
|
+
*/
|
|
30
|
+
export interface SignatureRequest {
|
|
31
|
+
address: string;
|
|
32
|
+
height: string;
|
|
33
|
+
contractAddress: string;
|
|
34
|
+
amount?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface SignatureResponse {
|
|
38
|
+
code: number;
|
|
39
|
+
data?: {
|
|
40
|
+
signature: string;
|
|
41
|
+
};
|
|
42
|
+
error?: {
|
|
43
|
+
message: string;
|
|
44
|
+
type: string;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class OracleCertificate {
|
|
49
|
+
private certificateApiEndpoint: string;
|
|
50
|
+
private http: Http;
|
|
51
|
+
|
|
52
|
+
constructor({ certificateApiEndpoint, http }: OracleCertificateParams) {
|
|
53
|
+
this.certificateApiEndpoint = certificateApiEndpoint;
|
|
54
|
+
this.http = http;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async sign(data: SignatureRequest): Promise<SignatureResponse> {
|
|
58
|
+
try {
|
|
59
|
+
const response = await fetch(
|
|
60
|
+
`${this.certificateApiEndpoint}/cosmoshub/sign`,
|
|
61
|
+
{
|
|
62
|
+
method: 'POST',
|
|
63
|
+
headers: {
|
|
64
|
+
'Content-Type': 'application/json',
|
|
65
|
+
},
|
|
66
|
+
body: JSON.stringify(data),
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
return {
|
|
72
|
+
code: response.status,
|
|
73
|
+
error: {
|
|
74
|
+
message: `Signature request failed: ${response.status} ${response.statusText}`,
|
|
75
|
+
type: 'error',
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const signatureData = await response.json();
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
code: 200,
|
|
84
|
+
data: signatureData,
|
|
85
|
+
};
|
|
86
|
+
} catch (error) {
|
|
87
|
+
return handleError(error as ErrorType);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
package/src/maci.ts
CHANGED
|
@@ -36,6 +36,9 @@ export class MaciClient {
|
|
|
36
36
|
public indexer: Indexer;
|
|
37
37
|
public contract: Contract;
|
|
38
38
|
|
|
39
|
+
public feegrantOperator: string;
|
|
40
|
+
public whitelistBackendPubkey: string;
|
|
41
|
+
|
|
39
42
|
/**
|
|
40
43
|
* @constructor
|
|
41
44
|
* @param {ClientParams} params - The parameters for the Maci Client instance.
|
|
@@ -50,6 +53,8 @@ export class MaciClient {
|
|
|
50
53
|
oracleCodeId,
|
|
51
54
|
customFetch,
|
|
52
55
|
defaultOptions,
|
|
56
|
+
feegrantOperator,
|
|
57
|
+
whitelistBackendPubkey,
|
|
53
58
|
}: ClientParams) {
|
|
54
59
|
const defaultParams = getDefaultParams(network);
|
|
55
60
|
|
|
@@ -59,6 +64,10 @@ export class MaciClient {
|
|
|
59
64
|
this.registryAddress = registryAddress || defaultParams.registryAddress;
|
|
60
65
|
this.maciCodeId = maciCodeId || defaultParams.maciCodeId;
|
|
61
66
|
this.oracleCodeId = oracleCodeId || defaultParams.oracleCodeId;
|
|
67
|
+
this.feegrantOperator =
|
|
68
|
+
feegrantOperator || defaultParams.oracleFeegrantOperator;
|
|
69
|
+
this.whitelistBackendPubkey =
|
|
70
|
+
whitelistBackendPubkey || defaultParams.oracleWhitelistBackendPubkey;
|
|
62
71
|
|
|
63
72
|
this.http = new Http(
|
|
64
73
|
this.apiEndpoint,
|
|
@@ -77,6 +86,8 @@ export class MaciClient {
|
|
|
77
86
|
registryAddress: this.registryAddress,
|
|
78
87
|
maciCodeId: this.maciCodeId,
|
|
79
88
|
oracleCodeId: this.oracleCodeId,
|
|
89
|
+
feegrantOperator: this.feegrantOperator,
|
|
90
|
+
whitelistBackendPubkey: this.whitelistBackendPubkey,
|
|
80
91
|
});
|
|
81
92
|
}
|
|
82
93
|
|
package/src/types/index.ts
CHANGED
|
@@ -27,6 +27,8 @@ export type ClientParams = {
|
|
|
27
27
|
oracleCodeId?: number;
|
|
28
28
|
customFetch?: typeof fetch;
|
|
29
29
|
defaultOptions?: FetchOptions;
|
|
30
|
+
feegrantOperator?: string;
|
|
31
|
+
whitelistBackendPubkey?: string;
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
export type ContractParams = {
|
|
@@ -34,6 +36,8 @@ export type ContractParams = {
|
|
|
34
36
|
registryAddress: string;
|
|
35
37
|
maciCodeId: number;
|
|
36
38
|
oracleCodeId: number;
|
|
39
|
+
whitelistBackendPubkey: string;
|
|
40
|
+
feegrantOperator: string;
|
|
37
41
|
};
|
|
38
42
|
|
|
39
43
|
export type TransactionType = {
|