@dorafactory/maci-sdk 0.1.2 → 0.1.3-pre.2
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/dist/index.js +2083 -1037
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2083 -1037
- package/dist/index.mjs.map +1 -1
- package/dist/libs/const.d.ts +1 -2
- package/dist/libs/contract/config.d.ts +12 -0
- package/dist/libs/contract/contract.d.ts +53 -2
- package/dist/libs/contract/ts/ApiMaci.client.d.ts +170 -0
- package/dist/libs/contract/ts/ApiMaci.types.d.ts +187 -0
- package/dist/libs/contract/ts/ApiSaas.client.d.ts +122 -0
- package/dist/libs/contract/ts/ApiSaas.types.d.ts +102 -0
- package/dist/libs/maci/maci.d.ts +24 -0
- package/dist/maci.d.ts +26 -2
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/libs/const.ts +5 -6
- package/src/libs/contract/config.ts +36 -0
- package/src/libs/contract/contract.ts +477 -3
- package/src/libs/contract/ts/ApiMaci.client.ts +459 -0
- package/src/libs/contract/ts/ApiMaci.types.ts +188 -0
- package/src/libs/contract/ts/ApiSaas.client.ts +307 -0
- package/src/libs/contract/ts/ApiSaas.types.ts +103 -0
- package/src/libs/maci/maci.ts +153 -0
- package/src/maci.ts +66 -4
- package/src/types/index.ts +2 -2
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by @cosmwasm/ts-codegen@1.11.1.
|
|
3
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
4
|
+
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
|
|
5
|
+
*/
|
|
6
|
+
export type Addr = string;
|
|
7
|
+
export interface InstantiateMsg {
|
|
8
|
+
admin: Addr;
|
|
9
|
+
denom: string;
|
|
10
|
+
maci_code_id: number;
|
|
11
|
+
registry_contract: Addr;
|
|
12
|
+
treasury_manager: Addr;
|
|
13
|
+
}
|
|
14
|
+
export type ExecuteMsg = {
|
|
15
|
+
update_config: {
|
|
16
|
+
admin?: Addr | null;
|
|
17
|
+
denom?: string | null;
|
|
18
|
+
};
|
|
19
|
+
} | {
|
|
20
|
+
update_maci_code_id: {
|
|
21
|
+
code_id: number;
|
|
22
|
+
};
|
|
23
|
+
} | {
|
|
24
|
+
update_amaci_registry_contract: {
|
|
25
|
+
registry_contract: Addr;
|
|
26
|
+
};
|
|
27
|
+
} | {
|
|
28
|
+
add_operator: {
|
|
29
|
+
operator: Addr;
|
|
30
|
+
};
|
|
31
|
+
} | {
|
|
32
|
+
remove_operator: {
|
|
33
|
+
operator: Addr;
|
|
34
|
+
};
|
|
35
|
+
} | {
|
|
36
|
+
deposit: {};
|
|
37
|
+
} | {
|
|
38
|
+
withdraw: {
|
|
39
|
+
amount: Uint128;
|
|
40
|
+
recipient?: Addr | null;
|
|
41
|
+
};
|
|
42
|
+
} | {
|
|
43
|
+
create_api_maci_round: {
|
|
44
|
+
certification_system: Uint256;
|
|
45
|
+
circuit_type: Uint256;
|
|
46
|
+
coordinator: PubKey;
|
|
47
|
+
end_time: Timestamp;
|
|
48
|
+
max_voters: number;
|
|
49
|
+
round_info: RoundInfo;
|
|
50
|
+
start_time: Timestamp;
|
|
51
|
+
vote_option_map: string[];
|
|
52
|
+
whitelist_backend_pubkey: string;
|
|
53
|
+
};
|
|
54
|
+
} | {
|
|
55
|
+
set_round_info: {
|
|
56
|
+
contract_addr: string;
|
|
57
|
+
round_info: RoundInfo;
|
|
58
|
+
};
|
|
59
|
+
} | {
|
|
60
|
+
set_vote_options_map: {
|
|
61
|
+
contract_addr: string;
|
|
62
|
+
vote_option_map: string[];
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export type Uint128 = string;
|
|
66
|
+
export type Uint256 = string;
|
|
67
|
+
export type Timestamp = Uint64;
|
|
68
|
+
export type Uint64 = string;
|
|
69
|
+
export interface PubKey {
|
|
70
|
+
x: Uint256;
|
|
71
|
+
y: Uint256;
|
|
72
|
+
}
|
|
73
|
+
export interface RoundInfo {
|
|
74
|
+
description: string;
|
|
75
|
+
link: string;
|
|
76
|
+
title: string;
|
|
77
|
+
}
|
|
78
|
+
export type QueryMsg = {
|
|
79
|
+
config: {};
|
|
80
|
+
} | {
|
|
81
|
+
operators: {};
|
|
82
|
+
} | {
|
|
83
|
+
is_operator: {
|
|
84
|
+
address: Addr;
|
|
85
|
+
};
|
|
86
|
+
} | {
|
|
87
|
+
balance: {};
|
|
88
|
+
} | {
|
|
89
|
+
maci_code_id: {};
|
|
90
|
+
} | {
|
|
91
|
+
treasury_manager: {};
|
|
92
|
+
};
|
|
93
|
+
export interface Config {
|
|
94
|
+
admin: Addr;
|
|
95
|
+
denom: string;
|
|
96
|
+
}
|
|
97
|
+
export type Boolean = boolean;
|
|
98
|
+
export type ArrayOfOperatorInfo = OperatorInfo[];
|
|
99
|
+
export interface OperatorInfo {
|
|
100
|
+
added_at: Timestamp;
|
|
101
|
+
address: Addr;
|
|
102
|
+
}
|
package/dist/libs/maci/maci.d.ts
CHANGED
|
@@ -109,6 +109,18 @@ export declare class MACI {
|
|
|
109
109
|
gasStation?: boolean;
|
|
110
110
|
fee?: StdFee | 'auto' | number;
|
|
111
111
|
}): Promise<import("@cosmjs/cosmwasm-stargate").ExecuteResult>;
|
|
112
|
+
rawSignup({ signer, address, contractAddress, pubKey, oracleCertificate, gasStation, fee, }: {
|
|
113
|
+
signer: OfflineSigner;
|
|
114
|
+
address?: string;
|
|
115
|
+
contractAddress: string;
|
|
116
|
+
pubKey: PubKey;
|
|
117
|
+
oracleCertificate?: {
|
|
118
|
+
amount: string;
|
|
119
|
+
signature: string;
|
|
120
|
+
};
|
|
121
|
+
gasStation?: boolean;
|
|
122
|
+
fee?: StdFee | 'auto' | number;
|
|
123
|
+
}): Promise<import("@cosmjs/cosmwasm-stargate").ExecuteResult>;
|
|
112
124
|
private processVoteOptions;
|
|
113
125
|
vote({ signer, address, contractAddress, selectedOptions, operatorCoordPubKey, maciKeypair, gasStation, fee, }: {
|
|
114
126
|
signer: OfflineSigner;
|
|
@@ -123,6 +135,18 @@ export declare class MACI {
|
|
|
123
135
|
gasStation?: boolean;
|
|
124
136
|
fee?: StdFee | 'auto' | number;
|
|
125
137
|
}): Promise<import("@cosmjs/cosmwasm-stargate").DeliverTxResponse>;
|
|
138
|
+
rawVote({ signer, address, contractAddress, pubKey, payload, gasStation, fee, }: {
|
|
139
|
+
signer: OfflineSigner;
|
|
140
|
+
address?: string;
|
|
141
|
+
contractAddress: string;
|
|
142
|
+
pubKey: PubKey;
|
|
143
|
+
payload: {
|
|
144
|
+
msg: bigint[];
|
|
145
|
+
encPubkeys: PubKey;
|
|
146
|
+
}[];
|
|
147
|
+
gasStation?: boolean;
|
|
148
|
+
fee?: StdFee | 'auto' | number;
|
|
149
|
+
}): Promise<import("@cosmjs/cosmwasm-stargate").DeliverTxResponse>;
|
|
126
150
|
publishMessage({ client, address, payload, contractAddress, gasStation, fee, }: {
|
|
127
151
|
client: SigningCosmWasmClient;
|
|
128
152
|
address: string;
|
package/dist/maci.d.ts
CHANGED
|
@@ -19,9 +19,9 @@ export declare class MaciClient {
|
|
|
19
19
|
certificateApiEndpoint: string;
|
|
20
20
|
registryAddress: string;
|
|
21
21
|
saasAddress: string;
|
|
22
|
+
apiSaasAddress: string;
|
|
22
23
|
maciCodeId: number;
|
|
23
24
|
oracleCodeId: number;
|
|
24
|
-
saasOracleCodeId: number;
|
|
25
25
|
feegrantOperator: string;
|
|
26
26
|
whitelistBackendPubkey: string;
|
|
27
27
|
http: Http;
|
|
@@ -35,7 +35,7 @@ export declare class MaciClient {
|
|
|
35
35
|
* @constructor
|
|
36
36
|
* @param {ClientParams} params - The parameters for the Maci Client instance.
|
|
37
37
|
*/
|
|
38
|
-
constructor({ signer, network, rpcEndpoint, restEndpoint, apiEndpoint, registryAddress, saasAddress, maciCodeId, oracleCodeId,
|
|
38
|
+
constructor({ signer, network, rpcEndpoint, restEndpoint, apiEndpoint, registryAddress, saasAddress, apiSaasAddress, maciCodeId, oracleCodeId, customFetch, defaultOptions, feegrantOperator, whitelistBackendPubkey, certificateApiEndpoint, maciKeypair, }: ClientParams);
|
|
39
39
|
getSigner(signer?: OfflineSigner): OfflineSigner;
|
|
40
40
|
getMaciKeypair(): Keypair;
|
|
41
41
|
getMaciPubkey(): bigint;
|
|
@@ -251,4 +251,28 @@ export declare class MaciClient {
|
|
|
251
251
|
address?: string;
|
|
252
252
|
fee?: number | StdFee | 'auto';
|
|
253
253
|
}): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
254
|
+
rawSignup({ signer, address, contractAddress, pubKey, oracleCertificate, gasStation, fee, }: {
|
|
255
|
+
signer?: OfflineSigner;
|
|
256
|
+
address?: string;
|
|
257
|
+
contractAddress: string;
|
|
258
|
+
pubKey: PubKey;
|
|
259
|
+
oracleCertificate?: {
|
|
260
|
+
amount: string;
|
|
261
|
+
signature: string;
|
|
262
|
+
};
|
|
263
|
+
gasStation?: boolean;
|
|
264
|
+
fee?: StdFee;
|
|
265
|
+
}): Promise<import("@cosmjs/cosmwasm-stargate").ExecuteResult>;
|
|
266
|
+
rawVote({ signer, address, contractAddress, pubKey, payload, gasStation, fee, }: {
|
|
267
|
+
signer?: OfflineSigner;
|
|
268
|
+
address?: string;
|
|
269
|
+
contractAddress: string;
|
|
270
|
+
pubKey: PubKey;
|
|
271
|
+
payload: {
|
|
272
|
+
msg: bigint[];
|
|
273
|
+
encPubkeys: PubKey;
|
|
274
|
+
}[];
|
|
275
|
+
gasStation?: boolean;
|
|
276
|
+
fee?: StdFee | 'auto' | number;
|
|
277
|
+
}): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
254
278
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -26,9 +26,9 @@ export type ClientParams = {
|
|
|
26
26
|
certificateApiEndpoint?: string;
|
|
27
27
|
registryAddress?: string;
|
|
28
28
|
saasAddress?: string;
|
|
29
|
+
apiSaasAddress?: string;
|
|
29
30
|
maciCodeId?: number;
|
|
30
31
|
oracleCodeId?: number;
|
|
31
|
-
saasOracleCodeId?: number;
|
|
32
32
|
customFetch?: typeof fetch;
|
|
33
33
|
defaultOptions?: FetchOptions;
|
|
34
34
|
feegrantOperator?: string;
|
|
@@ -42,9 +42,9 @@ export type ContractParams = {
|
|
|
42
42
|
rpcEndpoint: string;
|
|
43
43
|
registryAddress: string;
|
|
44
44
|
saasAddress: string;
|
|
45
|
+
apiSaasAddress: string;
|
|
45
46
|
maciCodeId: number;
|
|
46
47
|
oracleCodeId: number;
|
|
47
|
-
saasOracleCodeId: number;
|
|
48
48
|
whitelistBackendPubkey: string;
|
|
49
49
|
feegrantOperator: string;
|
|
50
50
|
};
|
package/package.json
CHANGED
package/src/libs/const.ts
CHANGED
|
@@ -150,13 +150,12 @@ export interface NetworkConfig {
|
|
|
150
150
|
certificateApiEndpoint: string;
|
|
151
151
|
registryAddress: string;
|
|
152
152
|
saasAddress: string;
|
|
153
|
+
apiSaasAddress: string;
|
|
153
154
|
maciCodeId: number;
|
|
154
155
|
oracleCodeId: number;
|
|
155
|
-
saasCodeId: number;
|
|
156
156
|
oracleWhitelistBackendPubkey: string;
|
|
157
157
|
oracleFeegrantOperator: string;
|
|
158
158
|
oracleCodeIds: string[];
|
|
159
|
-
saasCodeIds: string[];
|
|
160
159
|
}
|
|
161
160
|
|
|
162
161
|
export function getDefaultParams(
|
|
@@ -176,15 +175,15 @@ export function getDefaultParams(
|
|
|
176
175
|
'dora1smg5qp5trjdkcekdjssqpjehdjf6n4cjss0clyvqcud3t3u3948s8rmgg4',
|
|
177
176
|
saasAddress:
|
|
178
177
|
'dora1ksxvvve2nsw5uyvg7y6lnnxcqxadjepc78z0qa8enm5zhayxaqgqpsewf8',
|
|
178
|
+
apiSaasAddress:
|
|
179
|
+
'dora1ksxvvve2nsw5uyvg7y6lnnxcqxadjepc78z0qa8enm5zhayxaqgqpsewf8',
|
|
179
180
|
maciCodeId: 106,
|
|
180
181
|
// oracleCodeId: 116,// 9-4-3-625
|
|
181
182
|
oracleCodeId: 119, // 6-3-3-125
|
|
182
|
-
saasCodeId: 124,
|
|
183
183
|
oracleWhitelistBackendPubkey:
|
|
184
184
|
'A61YtCv2ibMZmDeM02nEElil8wlHx1tLKogBk5dPgf/Q',
|
|
185
185
|
oracleFeegrantOperator: 'dora16s9tljk8dy9ae335yvyzlm8gvkypx9228q8pq8',
|
|
186
186
|
oracleCodeIds: ['101', '116', '117', '119'],
|
|
187
|
-
saasCodeIds: ['124'],
|
|
188
187
|
};
|
|
189
188
|
case 'testnet':
|
|
190
189
|
return {
|
|
@@ -199,15 +198,15 @@ export function getDefaultParams(
|
|
|
199
198
|
'dora13c8aecstyxrhax9znvvh5zey89edrmd2k5va57pxvpe3fxtfsfeqlhsjnd',
|
|
200
199
|
saasAddress:
|
|
201
200
|
'dora1dgnszrwnwxgr5djprrr6w4q45z8s3ghsew869g6tlp4ruqah39nqnemjya',
|
|
201
|
+
apiSaasAddress:
|
|
202
|
+
'dora16xj2yrh3snq8f2qvma9uzjd5m2qgvzaqjcqmeuweh73t29c4rhusxm9hq6',
|
|
202
203
|
maciCodeId: 134,
|
|
203
204
|
// oracleCodeId: 113, // 9-4-3-625
|
|
204
205
|
oracleCodeId: 123, // 6-3-3-125
|
|
205
|
-
saasCodeId: 152,
|
|
206
206
|
oracleWhitelistBackendPubkey:
|
|
207
207
|
'AoYo/zENN/JquagPdG0/NMbWBBYxOM8BVN677mBXJKJQ',
|
|
208
208
|
oracleFeegrantOperator: 'dora1xp0twdzsdeq4qg3c64v66552deax8zmvq4zw78',
|
|
209
209
|
oracleCodeIds: ['102', '105', '108', '110', '113', '115', '123'],
|
|
210
|
-
saasCodeIds: ['152'],
|
|
211
210
|
};
|
|
212
211
|
}
|
|
213
212
|
}
|
|
@@ -11,6 +11,8 @@ import { AMaciClient } from './ts/AMaci.client';
|
|
|
11
11
|
import { RegistryClient } from './ts/Registry.client';
|
|
12
12
|
import { OracleMaciClient } from './ts/OracleMaci.client';
|
|
13
13
|
import { SaasClient } from './ts/Saas.client';
|
|
14
|
+
import { ApiMaciClient } from './ts/ApiMaci.client';
|
|
15
|
+
import { ApiSaasClient } from './ts/ApiSaas.client';
|
|
14
16
|
|
|
15
17
|
const defaultSigningClientOptions: SigningStargateClientOptions = {
|
|
16
18
|
broadcastPollIntervalMs: 8_000,
|
|
@@ -52,6 +54,23 @@ export async function createAMaciClientBy({
|
|
|
52
54
|
return new AMaciClient(signingCosmWasmClient, address, contractAddress);
|
|
53
55
|
}
|
|
54
56
|
|
|
57
|
+
export async function createApiMaciClientBy({
|
|
58
|
+
rpcEndpoint,
|
|
59
|
+
wallet,
|
|
60
|
+
contractAddress,
|
|
61
|
+
}: {
|
|
62
|
+
rpcEndpoint: string;
|
|
63
|
+
wallet: OfflineSigner;
|
|
64
|
+
contractAddress: string;
|
|
65
|
+
}) {
|
|
66
|
+
const signingCosmWasmClient = await createContractClientByWallet(
|
|
67
|
+
rpcEndpoint,
|
|
68
|
+
wallet
|
|
69
|
+
);
|
|
70
|
+
const [{ address }] = await wallet.getAccounts();
|
|
71
|
+
return new ApiMaciClient(signingCosmWasmClient, address, contractAddress);
|
|
72
|
+
}
|
|
73
|
+
|
|
55
74
|
export async function createRegistryClientBy({
|
|
56
75
|
rpcEndpoint,
|
|
57
76
|
wallet,
|
|
@@ -86,6 +105,23 @@ export async function createSaasClientBy({
|
|
|
86
105
|
return new SaasClient(signingCosmWasmClient, address, contractAddress);
|
|
87
106
|
}
|
|
88
107
|
|
|
108
|
+
export async function createApiSaasClientBy({
|
|
109
|
+
rpcEndpoint,
|
|
110
|
+
wallet,
|
|
111
|
+
contractAddress,
|
|
112
|
+
}: {
|
|
113
|
+
rpcEndpoint: string;
|
|
114
|
+
wallet: OfflineSigner;
|
|
115
|
+
contractAddress: string;
|
|
116
|
+
}) {
|
|
117
|
+
const signingCosmWasmClient = await createContractClientByWallet(
|
|
118
|
+
rpcEndpoint,
|
|
119
|
+
wallet
|
|
120
|
+
);
|
|
121
|
+
const [{ address }] = await wallet.getAccounts();
|
|
122
|
+
return new ApiSaasClient(signingCosmWasmClient, address, contractAddress);
|
|
123
|
+
}
|
|
124
|
+
|
|
89
125
|
export async function createOracleMaciClientBy({
|
|
90
126
|
rpcEndpoint,
|
|
91
127
|
wallet,
|