@vocdoni/davinci-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/LICENSE +661 -0
- package/README.md +635 -0
- package/dist/contracts.d.ts +512 -0
- package/dist/index.d.ts +1388 -0
- package/dist/index.js +2045 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2000 -0
- package/dist/index.mjs.map +1 -0
- package/dist/index.umd.js +2045 -0
- package/dist/sequencer.d.ts +538 -0
- package/package.json +103 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1388 @@
|
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { ContractTransactionResponse, ContractRunner, Signer, Wallet } from 'ethers';
|
|
3
|
+
import * as _vocdoni_davinci_contracts_dist_src_ProcessRegistry from '@vocdoni/davinci-contracts/dist/src/ProcessRegistry';
|
|
4
|
+
|
|
5
|
+
type AnyJson = boolean | number | string | null | JsonArray | JsonMap | any;
|
|
6
|
+
interface JsonMap {
|
|
7
|
+
[key: string]: AnyJson;
|
|
8
|
+
}
|
|
9
|
+
interface JsonArray extends Array<AnyJson> {
|
|
10
|
+
}
|
|
11
|
+
type CustomMeta = AnyJson | JsonArray | JsonMap;
|
|
12
|
+
type MultiLanguage<T> = {
|
|
13
|
+
default: T;
|
|
14
|
+
[lang: string]: T;
|
|
15
|
+
};
|
|
16
|
+
interface IChoice {
|
|
17
|
+
title: MultiLanguage<string>;
|
|
18
|
+
value: number;
|
|
19
|
+
meta?: CustomMeta;
|
|
20
|
+
results?: string;
|
|
21
|
+
answer?: number;
|
|
22
|
+
}
|
|
23
|
+
type Choice = Pick<IChoice, 'title' | 'value' | 'meta'>;
|
|
24
|
+
interface IQuestion {
|
|
25
|
+
title: MultiLanguage<string>;
|
|
26
|
+
description?: MultiLanguage<string>;
|
|
27
|
+
numAbstains?: string;
|
|
28
|
+
meta?: CustomMeta;
|
|
29
|
+
choices: Array<IChoice>;
|
|
30
|
+
}
|
|
31
|
+
type Question = Pick<IQuestion, 'title' | 'description' | 'choices' | 'meta'>;
|
|
32
|
+
declare enum ElectionResultsTypeNames {
|
|
33
|
+
SINGLE_CHOICE_MULTIQUESTION = "single-choice-multiquestion",
|
|
34
|
+
MULTIPLE_CHOICE = "multiple-choice",
|
|
35
|
+
BUDGET = "budget-based",
|
|
36
|
+
APPROVAL = "approval",
|
|
37
|
+
QUADRATIC = "quadratic"
|
|
38
|
+
}
|
|
39
|
+
interface AbstainProperties {
|
|
40
|
+
canAbstain: boolean;
|
|
41
|
+
abstainValues: Array<string>;
|
|
42
|
+
}
|
|
43
|
+
interface ChoiceProperties {
|
|
44
|
+
repeatChoice: boolean;
|
|
45
|
+
numChoices: {
|
|
46
|
+
min: number;
|
|
47
|
+
max: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
interface BudgetProperties {
|
|
51
|
+
useCensusWeightAsBudget: boolean;
|
|
52
|
+
maxBudget: number;
|
|
53
|
+
minStep: number;
|
|
54
|
+
forceFullBudget: boolean;
|
|
55
|
+
}
|
|
56
|
+
interface ApprovalProperties {
|
|
57
|
+
rejectValue: number;
|
|
58
|
+
acceptValue: number;
|
|
59
|
+
}
|
|
60
|
+
interface QuadraticProperties extends BudgetProperties {
|
|
61
|
+
quadraticCost: number;
|
|
62
|
+
}
|
|
63
|
+
type ElectionResultsType = {
|
|
64
|
+
name: ElectionResultsTypeNames.SINGLE_CHOICE_MULTIQUESTION;
|
|
65
|
+
properties: Record<string, never>;
|
|
66
|
+
} | {
|
|
67
|
+
name: ElectionResultsTypeNames.MULTIPLE_CHOICE;
|
|
68
|
+
properties: AbstainProperties & ChoiceProperties;
|
|
69
|
+
} | {
|
|
70
|
+
name: ElectionResultsTypeNames.BUDGET;
|
|
71
|
+
properties: BudgetProperties;
|
|
72
|
+
} | {
|
|
73
|
+
name: ElectionResultsTypeNames.APPROVAL;
|
|
74
|
+
properties: ApprovalProperties;
|
|
75
|
+
} | {
|
|
76
|
+
name: ElectionResultsTypeNames.QUADRATIC;
|
|
77
|
+
properties: QuadraticProperties;
|
|
78
|
+
};
|
|
79
|
+
type ProtocolVersion = '1.1' | '1.2';
|
|
80
|
+
interface ElectionMetadata {
|
|
81
|
+
version: ProtocolVersion;
|
|
82
|
+
title: MultiLanguage<string>;
|
|
83
|
+
description: MultiLanguage<string>;
|
|
84
|
+
media: {
|
|
85
|
+
header: string;
|
|
86
|
+
logo: string;
|
|
87
|
+
};
|
|
88
|
+
meta?: {
|
|
89
|
+
[key: string]: any;
|
|
90
|
+
};
|
|
91
|
+
questions: Array<IQuestion>;
|
|
92
|
+
type: ElectionResultsType;
|
|
93
|
+
}
|
|
94
|
+
declare const ElectionMetadataTemplate: ElectionMetadata;
|
|
95
|
+
declare const getElectionMetadataTemplate: () => ElectionMetadata;
|
|
96
|
+
|
|
97
|
+
interface ApiError {
|
|
98
|
+
error: string;
|
|
99
|
+
code: number;
|
|
100
|
+
}
|
|
101
|
+
declare class BaseService {
|
|
102
|
+
protected axios: AxiosInstance;
|
|
103
|
+
constructor(baseURL: string, config?: AxiosRequestConfig);
|
|
104
|
+
protected request<T>(config: AxiosRequestConfig): Promise<T>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Census origin types
|
|
109
|
+
*/
|
|
110
|
+
declare enum CensusOrigin {
|
|
111
|
+
/** Indicates that the census is derived from a Merkle Tree structure */
|
|
112
|
+
CensusOriginMerkleTree = 1,
|
|
113
|
+
/** Indicates that the census is provided by a Credential Service Provider (CSP) */
|
|
114
|
+
CensusOriginCSP = 2
|
|
115
|
+
}
|
|
116
|
+
interface CensusParticipant {
|
|
117
|
+
key: string;
|
|
118
|
+
weight?: string;
|
|
119
|
+
}
|
|
120
|
+
interface BaseCensusProof {
|
|
121
|
+
/** The Merkle root (hex-prefixed). */
|
|
122
|
+
root: string;
|
|
123
|
+
/** The voter's address (hex-prefixed). */
|
|
124
|
+
address: string;
|
|
125
|
+
/** The weight as a decimal string. */
|
|
126
|
+
weight: string;
|
|
127
|
+
/** Census origin type: CensusOriginMerkleTree for merkle proofs, CensusOriginCSP for csp proofs */
|
|
128
|
+
censusOrigin: CensusOrigin;
|
|
129
|
+
}
|
|
130
|
+
interface MerkleCensusProof extends BaseCensusProof {
|
|
131
|
+
censusOrigin: CensusOrigin.CensusOriginMerkleTree;
|
|
132
|
+
/** The leaf value (hex-prefixed weight). */
|
|
133
|
+
value: string;
|
|
134
|
+
/** The serialized sibling path (hex-prefixed). */
|
|
135
|
+
siblings: string;
|
|
136
|
+
}
|
|
137
|
+
interface CSPCensusProof extends BaseCensusProof {
|
|
138
|
+
censusOrigin: CensusOrigin.CensusOriginCSP;
|
|
139
|
+
/** The process id signed with the address (hex-prefixed). */
|
|
140
|
+
processId: string;
|
|
141
|
+
/** The public key of the csp (hex-prefixed). */
|
|
142
|
+
publicKey: string;
|
|
143
|
+
/** The signature that proves that the voter is in the census (hex-prefixed). */
|
|
144
|
+
signature: string;
|
|
145
|
+
}
|
|
146
|
+
type CensusProof = MerkleCensusProof | CSPCensusProof;
|
|
147
|
+
/**
|
|
148
|
+
* Provider function for Merkle census proofs
|
|
149
|
+
*/
|
|
150
|
+
type MerkleCensusProofProvider = (args: {
|
|
151
|
+
censusRoot: string;
|
|
152
|
+
address: string;
|
|
153
|
+
}) => Promise<MerkleCensusProof>;
|
|
154
|
+
/**
|
|
155
|
+
* Provider function for CSP census proofs
|
|
156
|
+
*/
|
|
157
|
+
type CSPCensusProofProvider = (args: {
|
|
158
|
+
processId: string;
|
|
159
|
+
address: string;
|
|
160
|
+
}) => Promise<CSPCensusProof>;
|
|
161
|
+
/**
|
|
162
|
+
* Configuration for census proof providers
|
|
163
|
+
*/
|
|
164
|
+
interface CensusProviders {
|
|
165
|
+
/** Optional override for Merkle census proof fetching */
|
|
166
|
+
merkle?: MerkleCensusProofProvider;
|
|
167
|
+
/** Required provider for CSP census proof generation */
|
|
168
|
+
csp?: CSPCensusProofProvider;
|
|
169
|
+
}
|
|
170
|
+
interface PublishCensusResponse {
|
|
171
|
+
/** The Merkle root of the published census (hex-prefixed). */
|
|
172
|
+
root: string;
|
|
173
|
+
/** The number of participants in the census. */
|
|
174
|
+
participantCount: number;
|
|
175
|
+
/** ISO timestamp when the working census was created. */
|
|
176
|
+
createdAt: string;
|
|
177
|
+
/** ISO timestamp when the census was published. */
|
|
178
|
+
publishedAt: string;
|
|
179
|
+
/** The constructed URI for accessing the census */
|
|
180
|
+
uri: string;
|
|
181
|
+
}
|
|
182
|
+
interface Snapshot {
|
|
183
|
+
/** ISO timestamp of the snapshot date. */
|
|
184
|
+
snapshotDate: string;
|
|
185
|
+
/** The Merkle root of the census (hex-prefixed). */
|
|
186
|
+
censusRoot: string;
|
|
187
|
+
/** The number of participants in the census. */
|
|
188
|
+
participantCount: number;
|
|
189
|
+
/** Minimum balance filter applied. */
|
|
190
|
+
minBalance: number;
|
|
191
|
+
/** User-defined query name. */
|
|
192
|
+
queryName: string;
|
|
193
|
+
/** ISO timestamp when the snapshot was created. */
|
|
194
|
+
createdAt: string;
|
|
195
|
+
/** Type of query executed (optional). */
|
|
196
|
+
queryType?: string;
|
|
197
|
+
/** Token decimals (optional). */
|
|
198
|
+
decimals?: number;
|
|
199
|
+
/** Query execution period (optional). */
|
|
200
|
+
period?: string;
|
|
201
|
+
/** Query parameters (optional). */
|
|
202
|
+
parameters?: Record<string, any>;
|
|
203
|
+
/** Weight configuration (optional). */
|
|
204
|
+
weightConfig?: {
|
|
205
|
+
strategy: string;
|
|
206
|
+
targetMinWeight: number;
|
|
207
|
+
maxWeight: number;
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
interface SnapshotsResponse {
|
|
211
|
+
/** Array of snapshots. */
|
|
212
|
+
snapshots: Snapshot[];
|
|
213
|
+
/** Total number of snapshots. */
|
|
214
|
+
total: number;
|
|
215
|
+
/** Current page number. */
|
|
216
|
+
page: number;
|
|
217
|
+
/** Number of items per page. */
|
|
218
|
+
pageSize: number;
|
|
219
|
+
/** Whether there is a next page. */
|
|
220
|
+
hasNext: boolean;
|
|
221
|
+
/** Whether there is a previous page. */
|
|
222
|
+
hasPrev: boolean;
|
|
223
|
+
}
|
|
224
|
+
interface SnapshotsQueryParams {
|
|
225
|
+
/** Page number (default: 1). */
|
|
226
|
+
page?: number;
|
|
227
|
+
/** Items per page (default: 20, max: 100). */
|
|
228
|
+
pageSize?: number;
|
|
229
|
+
/** Filter by minimum balance. */
|
|
230
|
+
minBalance?: number;
|
|
231
|
+
/** Filter by user-defined query name. */
|
|
232
|
+
queryName?: string;
|
|
233
|
+
}
|
|
234
|
+
interface HealthResponse {
|
|
235
|
+
/** Service status. */
|
|
236
|
+
status: string;
|
|
237
|
+
/** ISO timestamp of the health check. */
|
|
238
|
+
timestamp: string;
|
|
239
|
+
/** Service name. */
|
|
240
|
+
service: string;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
declare class VocdoniCensusService extends BaseService {
|
|
244
|
+
constructor(baseURL: string);
|
|
245
|
+
/**
|
|
246
|
+
* Constructs the URI for accessing a census by its root
|
|
247
|
+
* @param censusRoot - The census root (hex-prefixed)
|
|
248
|
+
* @returns The constructed URI for the census
|
|
249
|
+
*/
|
|
250
|
+
getCensusUri(censusRoot: string): string;
|
|
251
|
+
createCensus(): Promise<string>;
|
|
252
|
+
addParticipants(censusId: string, participants: CensusParticipant[]): Promise<void>;
|
|
253
|
+
getParticipants(censusId: string): Promise<CensusParticipant[]>;
|
|
254
|
+
getCensusRoot(censusId: string): Promise<string>;
|
|
255
|
+
getCensusSizeById(censusId: string): Promise<number>;
|
|
256
|
+
getCensusSizeByRoot(censusRoot: string): Promise<number>;
|
|
257
|
+
getCensusSize(censusIdOrRoot: string): Promise<number>;
|
|
258
|
+
deleteCensus(censusId: string): Promise<void>;
|
|
259
|
+
getCensusProof(censusRoot: string, key: string): Promise<CensusProof>;
|
|
260
|
+
publishCensus(censusId: string): Promise<PublishCensusResponse>;
|
|
261
|
+
getSnapshots(params?: SnapshotsQueryParams): Promise<SnapshotsResponse>;
|
|
262
|
+
getLatestSnapshot(): Promise<Snapshot>;
|
|
263
|
+
getHealth(): Promise<HealthResponse>;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
interface BallotMode {
|
|
267
|
+
numFields: number;
|
|
268
|
+
maxValue: string;
|
|
269
|
+
minValue: string;
|
|
270
|
+
uniqueValues: boolean;
|
|
271
|
+
costFromWeight: boolean;
|
|
272
|
+
costExponent: number;
|
|
273
|
+
maxValueSum: string;
|
|
274
|
+
minValueSum: string;
|
|
275
|
+
}
|
|
276
|
+
interface Census {
|
|
277
|
+
censusOrigin: CensusOrigin;
|
|
278
|
+
maxVotes: string;
|
|
279
|
+
censusRoot: string;
|
|
280
|
+
censusURI: string;
|
|
281
|
+
}
|
|
282
|
+
interface EncryptionKey {
|
|
283
|
+
x: string;
|
|
284
|
+
y: string;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
interface CreateProcessRequest {
|
|
288
|
+
processId: string;
|
|
289
|
+
censusRoot: string;
|
|
290
|
+
ballotMode: BallotMode;
|
|
291
|
+
signature: string;
|
|
292
|
+
/**
|
|
293
|
+
* The censusOrigin specifies the origin type of the census used in the request.
|
|
294
|
+
* This attribute allows the API to determine how the census data should be processed or verified.
|
|
295
|
+
*/
|
|
296
|
+
censusOrigin: CensusOrigin;
|
|
297
|
+
}
|
|
298
|
+
interface CreateProcessResponse {
|
|
299
|
+
processId: string;
|
|
300
|
+
encryptionPubKey: [string, string];
|
|
301
|
+
stateRoot: string;
|
|
302
|
+
ballotMode: BallotMode;
|
|
303
|
+
}
|
|
304
|
+
interface GetProcessResponse {
|
|
305
|
+
id: string;
|
|
306
|
+
status: number;
|
|
307
|
+
organizationId: string;
|
|
308
|
+
encryptionKey: EncryptionKey;
|
|
309
|
+
stateRoot: string;
|
|
310
|
+
result: string[];
|
|
311
|
+
startTime: number;
|
|
312
|
+
duration: number;
|
|
313
|
+
metadataURI: string;
|
|
314
|
+
ballotMode: BallotMode;
|
|
315
|
+
census: Census;
|
|
316
|
+
metadata: {
|
|
317
|
+
title: Record<string, string>;
|
|
318
|
+
description: Record<string, string>;
|
|
319
|
+
media: {
|
|
320
|
+
header: string;
|
|
321
|
+
logo: string;
|
|
322
|
+
};
|
|
323
|
+
questions: {
|
|
324
|
+
title: Record<string, string>;
|
|
325
|
+
description: Record<string, string>;
|
|
326
|
+
choices: {
|
|
327
|
+
title: Record<string, string>;
|
|
328
|
+
value: number;
|
|
329
|
+
meta: Record<string, string>;
|
|
330
|
+
}[];
|
|
331
|
+
meta: Record<string, string>;
|
|
332
|
+
}[];
|
|
333
|
+
processType: {
|
|
334
|
+
name: string;
|
|
335
|
+
properties: Record<string, string>;
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
voteCount: string;
|
|
339
|
+
voteOverwrittenCount: string;
|
|
340
|
+
isAcceptingVotes: boolean;
|
|
341
|
+
sequencerStats: {
|
|
342
|
+
stateTransitionCount: number;
|
|
343
|
+
lastStateTransitionDate: string;
|
|
344
|
+
settledStateTransitionCount: number;
|
|
345
|
+
aggregatedVotesCount: number;
|
|
346
|
+
verifiedVotesCount: number;
|
|
347
|
+
pendingVotesCount: number;
|
|
348
|
+
currentBatchSize: number;
|
|
349
|
+
lastBatchSize: number;
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
interface VoteCiphertext {
|
|
353
|
+
c1: [string, string];
|
|
354
|
+
c2: [string, string];
|
|
355
|
+
}
|
|
356
|
+
interface VoteBallot {
|
|
357
|
+
curveType: string;
|
|
358
|
+
ciphertexts: VoteCiphertext[];
|
|
359
|
+
}
|
|
360
|
+
interface VoteProof {
|
|
361
|
+
pi_a: [string, string, string];
|
|
362
|
+
pi_b: [[string, string], [string, string], [string, string]];
|
|
363
|
+
pi_c: [string, string, string];
|
|
364
|
+
protocol: string;
|
|
365
|
+
}
|
|
366
|
+
interface VoteRequest {
|
|
367
|
+
/** The `processId` you obtained when creating the process. */
|
|
368
|
+
processId: string;
|
|
369
|
+
/** Your Merkle‐proof that you're in the census. */
|
|
370
|
+
censusProof: CensusProof;
|
|
371
|
+
/** Your encrypted ballot. */
|
|
372
|
+
ballot: VoteBallot;
|
|
373
|
+
/** The zkSNARK proof that the ballot is well‐formed. */
|
|
374
|
+
ballotProof: VoteProof;
|
|
375
|
+
/** Hash of the ballot inputs (decimal string). */
|
|
376
|
+
ballotInputsHash: string;
|
|
377
|
+
/** Your Ethereum address (hex-prefixed). */
|
|
378
|
+
address: string;
|
|
379
|
+
/** Signature over the raw bytes of the voteId. */
|
|
380
|
+
signature: string;
|
|
381
|
+
/** The vote ID (hex-prefixed). */
|
|
382
|
+
voteId: string;
|
|
383
|
+
}
|
|
384
|
+
interface InfoResponse {
|
|
385
|
+
circuitUrl: string;
|
|
386
|
+
circuitHash: string;
|
|
387
|
+
provingKeyUrl: string;
|
|
388
|
+
provingKeyHash: string;
|
|
389
|
+
verificationKeyUrl: string;
|
|
390
|
+
verificationKeyHash: string;
|
|
391
|
+
ballotProofWasmHelperUrl: string;
|
|
392
|
+
ballotProofWasmHelperHash: string;
|
|
393
|
+
ballotProofWasmHelperExecJsUrl: string;
|
|
394
|
+
ballotProofWasmHelperExecJsHash: string;
|
|
395
|
+
contracts: {
|
|
396
|
+
process: string;
|
|
397
|
+
organization: string;
|
|
398
|
+
stateTransitionVerifier: string;
|
|
399
|
+
resultsVerifier: string;
|
|
400
|
+
};
|
|
401
|
+
network: {
|
|
402
|
+
[key: string]: number;
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
declare enum VoteStatus {
|
|
406
|
+
Pending = "pending",
|
|
407
|
+
Verified = "verified",
|
|
408
|
+
Aggregated = "aggregated",
|
|
409
|
+
Processed = "processed",
|
|
410
|
+
Settled = "settled",
|
|
411
|
+
Error = "error"
|
|
412
|
+
}
|
|
413
|
+
interface VoteStatusResponse {
|
|
414
|
+
status: VoteStatus;
|
|
415
|
+
}
|
|
416
|
+
interface ListProcessesResponse {
|
|
417
|
+
processes: string[];
|
|
418
|
+
}
|
|
419
|
+
interface SequencerStats {
|
|
420
|
+
activeProcesses: number;
|
|
421
|
+
pendingVotes: number;
|
|
422
|
+
verifiedVotes: number;
|
|
423
|
+
aggregatedVotes: number;
|
|
424
|
+
stateTransitions: number;
|
|
425
|
+
settledStateTransitions: number;
|
|
426
|
+
lastStateTransitionDate: string;
|
|
427
|
+
}
|
|
428
|
+
interface WorkerStats {
|
|
429
|
+
name: string;
|
|
430
|
+
successCount: number;
|
|
431
|
+
failedCount: number;
|
|
432
|
+
}
|
|
433
|
+
interface WorkersResponse {
|
|
434
|
+
workers: WorkerStats[];
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
declare class VocdoniSequencerService extends BaseService {
|
|
438
|
+
constructor(baseURL: string);
|
|
439
|
+
ping(): Promise<void>;
|
|
440
|
+
createProcess(body: CreateProcessRequest): Promise<CreateProcessResponse>;
|
|
441
|
+
getProcess(processId: string): Promise<GetProcessResponse>;
|
|
442
|
+
listProcesses(): Promise<string[]>;
|
|
443
|
+
submitVote(vote: VoteRequest): Promise<void>;
|
|
444
|
+
getVoteStatus(processId: string, voteId: string): Promise<VoteStatusResponse>;
|
|
445
|
+
hasAddressVoted(processId: string, address: string): Promise<boolean>;
|
|
446
|
+
getInfo(): Promise<InfoResponse>;
|
|
447
|
+
pushMetadata(metadata: ElectionMetadata): Promise<string>;
|
|
448
|
+
getMetadata(hashOrUrl: string): Promise<ElectionMetadata>;
|
|
449
|
+
getMetadataUrl(hash: string): string;
|
|
450
|
+
getStats(): Promise<SequencerStats>;
|
|
451
|
+
getWorkers(): Promise<WorkersResponse>;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
interface VocdoniApiServiceConfig {
|
|
455
|
+
sequencerURL: string;
|
|
456
|
+
censusURL: string;
|
|
457
|
+
}
|
|
458
|
+
declare class VocdoniApiService {
|
|
459
|
+
readonly census: VocdoniCensusService;
|
|
460
|
+
readonly sequencer: VocdoniSequencerService;
|
|
461
|
+
constructor(config: VocdoniApiServiceConfig);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Supported environment types
|
|
466
|
+
*/
|
|
467
|
+
type Environment = 'dev' | 'stg' | 'prod';
|
|
468
|
+
/**
|
|
469
|
+
* URL configuration for each service
|
|
470
|
+
*/
|
|
471
|
+
interface ServiceUrls {
|
|
472
|
+
/** Sequencer API URL */
|
|
473
|
+
sequencer: string;
|
|
474
|
+
/** Census API URL */
|
|
475
|
+
census: string;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Chain configuration for each environment
|
|
479
|
+
*/
|
|
480
|
+
interface ChainConfig {
|
|
481
|
+
/** Chain name/ID */
|
|
482
|
+
chain: 'sepolia' | 'mainnet';
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Environment-based URL configuration
|
|
486
|
+
*/
|
|
487
|
+
interface EnvironmentConfig {
|
|
488
|
+
dev: ServiceUrls & ChainConfig;
|
|
489
|
+
stg: ServiceUrls & ChainConfig;
|
|
490
|
+
prod: ServiceUrls & ChainConfig;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Configuration options for environment setup
|
|
494
|
+
*/
|
|
495
|
+
interface EnvironmentOptions {
|
|
496
|
+
/** Environment to use (defaults to 'prod') */
|
|
497
|
+
environment?: Environment;
|
|
498
|
+
/** Custom URLs to override defaults */
|
|
499
|
+
customUrls?: Partial<ServiceUrls>;
|
|
500
|
+
/** Custom chain to override default */
|
|
501
|
+
customChain?: ChainConfig['chain'];
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Default URL and chain configuration for all environments
|
|
506
|
+
*/
|
|
507
|
+
declare const DEFAULT_ENVIRONMENT_URLS: EnvironmentConfig;
|
|
508
|
+
/**
|
|
509
|
+
* Get URLs and chain configuration for a specific environment
|
|
510
|
+
*/
|
|
511
|
+
declare function getEnvironmentConfig(environment: Environment): ServiceUrls & ChainConfig;
|
|
512
|
+
/**
|
|
513
|
+
* Get only URLs for a specific environment
|
|
514
|
+
*/
|
|
515
|
+
declare function getEnvironmentUrls(environment: Environment): ServiceUrls;
|
|
516
|
+
/**
|
|
517
|
+
* Get chain configuration for a specific environment
|
|
518
|
+
*/
|
|
519
|
+
declare function getEnvironmentChain(environment: Environment): ChainConfig['chain'];
|
|
520
|
+
/**
|
|
521
|
+
* Resolve URLs and chain based on environment and custom overrides
|
|
522
|
+
*/
|
|
523
|
+
declare function resolveConfiguration(options?: EnvironmentOptions): ServiceUrls & ChainConfig;
|
|
524
|
+
/**
|
|
525
|
+
* Resolve only URLs based on environment and custom overrides
|
|
526
|
+
*/
|
|
527
|
+
declare function resolveUrls(options?: EnvironmentOptions): ServiceUrls;
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Interface defining the structure of deployed contract addresses across different networks.
|
|
531
|
+
* Each contract has addresses for both Sepolia testnet and Ethereum mainnet.
|
|
532
|
+
*/
|
|
533
|
+
interface DeployedAddresses {
|
|
534
|
+
/** Process Registry contract addresses */
|
|
535
|
+
processRegistry: {
|
|
536
|
+
/** Sepolia testnet address */
|
|
537
|
+
sepolia: string;
|
|
538
|
+
/** Ethereum mainnet address */
|
|
539
|
+
mainnet: string;
|
|
540
|
+
};
|
|
541
|
+
/** Organization Registry contract addresses */
|
|
542
|
+
organizationRegistry: {
|
|
543
|
+
/** Sepolia testnet address */
|
|
544
|
+
sepolia: string;
|
|
545
|
+
/** Ethereum mainnet address */
|
|
546
|
+
mainnet: string;
|
|
547
|
+
};
|
|
548
|
+
/** State Transition Verifier contract addresses */
|
|
549
|
+
stateTransitionVerifierGroth16: {
|
|
550
|
+
/** Sepolia testnet address */
|
|
551
|
+
sepolia: string;
|
|
552
|
+
/** Ethereum mainnet address */
|
|
553
|
+
mainnet: string;
|
|
554
|
+
};
|
|
555
|
+
/** Results Verifier contract addresses */
|
|
556
|
+
resultsVerifierGroth16: {
|
|
557
|
+
/** Sepolia testnet address */
|
|
558
|
+
sepolia: string;
|
|
559
|
+
/** Ethereum mainnet address */
|
|
560
|
+
mainnet: string;
|
|
561
|
+
};
|
|
562
|
+
/** Sequencer Registry contract addresses */
|
|
563
|
+
sequencerRegistry: {
|
|
564
|
+
/** Sepolia testnet address */
|
|
565
|
+
sepolia: string;
|
|
566
|
+
/** Ethereum mainnet address */
|
|
567
|
+
mainnet: string;
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Deployed contract addresses imported from @vocdoni/davinci-contracts package.
|
|
572
|
+
* These addresses are used to interact with the Vocdoni voting protocol contracts
|
|
573
|
+
* on different networks.
|
|
574
|
+
*/
|
|
575
|
+
declare const deployedAddresses: DeployedAddresses;
|
|
576
|
+
/**
|
|
577
|
+
* Enum representing the possible states of a transaction during its lifecycle.
|
|
578
|
+
* Used to track and report transaction status in the event stream.
|
|
579
|
+
*/
|
|
580
|
+
declare enum TxStatus {
|
|
581
|
+
/** Transaction has been submitted and is waiting to be mined */
|
|
582
|
+
Pending = "pending",
|
|
583
|
+
/** Transaction has been successfully mined and executed */
|
|
584
|
+
Completed = "completed",
|
|
585
|
+
/** Transaction was mined but reverted during execution */
|
|
586
|
+
Reverted = "reverted",
|
|
587
|
+
/** Transaction failed before or during submission */
|
|
588
|
+
Failed = "failed"
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Union type representing the different events that can occur during a transaction's lifecycle.
|
|
592
|
+
* Each event includes relevant data based on the transaction status.
|
|
593
|
+
*
|
|
594
|
+
* @template T - The type of the successful response data
|
|
595
|
+
*/
|
|
596
|
+
type TxStatusEvent<T = any> = {
|
|
597
|
+
status: TxStatus.Pending;
|
|
598
|
+
hash: string;
|
|
599
|
+
} | {
|
|
600
|
+
status: TxStatus.Completed;
|
|
601
|
+
response: T;
|
|
602
|
+
} | {
|
|
603
|
+
status: TxStatus.Reverted;
|
|
604
|
+
reason?: string;
|
|
605
|
+
} | {
|
|
606
|
+
status: TxStatus.Failed;
|
|
607
|
+
error: Error;
|
|
608
|
+
};
|
|
609
|
+
/**
|
|
610
|
+
* Abstract base class providing common functionality for smart contract interactions.
|
|
611
|
+
* Implements transaction handling, status monitoring, and event normalization.
|
|
612
|
+
*/
|
|
613
|
+
declare abstract class SmartContractService {
|
|
614
|
+
/**
|
|
615
|
+
* Sends a transaction and yields status events during its lifecycle.
|
|
616
|
+
* This method handles the complete transaction flow from submission to completion,
|
|
617
|
+
* including error handling and status updates.
|
|
618
|
+
*
|
|
619
|
+
* @template T - The type of the successful response data
|
|
620
|
+
* @param txPromise - Promise resolving to the transaction response
|
|
621
|
+
* @param responseHandler - Function to process the successful transaction result
|
|
622
|
+
* @returns AsyncGenerator yielding transaction status events
|
|
623
|
+
*
|
|
624
|
+
* @example
|
|
625
|
+
* ```typescript
|
|
626
|
+
* const txStream = await this.sendTx(
|
|
627
|
+
* contract.someMethod(),
|
|
628
|
+
* async () => await contract.getUpdatedValue()
|
|
629
|
+
* );
|
|
630
|
+
*
|
|
631
|
+
* for await (const event of txStream) {
|
|
632
|
+
* switch (event.status) {
|
|
633
|
+
* case TxStatus.Pending:
|
|
634
|
+
* console.log(`Transaction pending: ${event.hash}`);
|
|
635
|
+
* break;
|
|
636
|
+
* case TxStatus.Completed:
|
|
637
|
+
* console.log(`Transaction completed:`, event.response);
|
|
638
|
+
* break;
|
|
639
|
+
* }
|
|
640
|
+
* }
|
|
641
|
+
* ```
|
|
642
|
+
*/
|
|
643
|
+
protected sendTx<T>(txPromise: Promise<ContractTransactionResponse>, responseHandler: () => Promise<T>): AsyncGenerator<TxStatusEvent<T>, void, unknown>;
|
|
644
|
+
/**
|
|
645
|
+
* Executes a transaction stream and returns the result or throws an error.
|
|
646
|
+
* This is a convenience method that processes a transaction stream and either
|
|
647
|
+
* returns the successful result or throws an appropriate error.
|
|
648
|
+
*
|
|
649
|
+
* @template T - The type of the successful response data
|
|
650
|
+
* @param stream - AsyncGenerator of transaction status events
|
|
651
|
+
* @returns Promise resolving to the successful response data
|
|
652
|
+
* @throws Error if the transaction fails or reverts
|
|
653
|
+
*
|
|
654
|
+
* @example
|
|
655
|
+
* ```typescript
|
|
656
|
+
* try {
|
|
657
|
+
* const result = await SmartContractService.executeTx(
|
|
658
|
+
* contract.someMethod()
|
|
659
|
+
* );
|
|
660
|
+
* console.log('Transaction successful:', result);
|
|
661
|
+
* } catch (error) {
|
|
662
|
+
* console.error('Transaction failed:', error);
|
|
663
|
+
* }
|
|
664
|
+
* ```
|
|
665
|
+
*/
|
|
666
|
+
static executeTx<T>(stream: AsyncGenerator<TxStatusEvent<T>>): Promise<T>;
|
|
667
|
+
/**
|
|
668
|
+
* Normalizes event listener arguments between different ethers.js versions.
|
|
669
|
+
* This helper method ensures consistent event argument handling regardless of
|
|
670
|
+
* whether the event payload follows ethers v5 or v6 format.
|
|
671
|
+
*
|
|
672
|
+
* @template Args - Tuple type representing the expected event arguments
|
|
673
|
+
* @param callback - The event callback function to normalize
|
|
674
|
+
* @returns Normalized event listener function
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* ```typescript
|
|
678
|
+
* contract.on('Transfer', this.normalizeListener((from: string, to: string, amount: BigInt) => {
|
|
679
|
+
* console.log(`Transfer from ${from} to ${to}: ${amount}`);
|
|
680
|
+
* }));
|
|
681
|
+
* ```
|
|
682
|
+
*/
|
|
683
|
+
protected normalizeListener<Args extends any[]>(callback: (...args: Args) => void): (...listenerArgs: any[]) => void;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* @fileoverview Standardized types and interfaces for contract services
|
|
688
|
+
*
|
|
689
|
+
* This module provides consistent type definitions for callbacks, interfaces,
|
|
690
|
+
* and common data structures used across contract services.
|
|
691
|
+
*/
|
|
692
|
+
/**
|
|
693
|
+
* Generic callback type for contract events.
|
|
694
|
+
* @template T - Tuple type representing the event arguments
|
|
695
|
+
*/
|
|
696
|
+
type EntityCallback<T extends any[]> = (...args: T) => void;
|
|
697
|
+
/**
|
|
698
|
+
* Callback for when an organization is created.
|
|
699
|
+
* @param id - The organization ID
|
|
700
|
+
*/
|
|
701
|
+
type OrganizationCreatedCallback = EntityCallback<[string]>;
|
|
702
|
+
/**
|
|
703
|
+
* Callback for when an organization is updated.
|
|
704
|
+
* @param id - The organization ID
|
|
705
|
+
* @param updater - Address of the account that updated the organization
|
|
706
|
+
*/
|
|
707
|
+
type OrganizationUpdatedCallback = EntityCallback<[string, string]>;
|
|
708
|
+
/**
|
|
709
|
+
* Callback for when an administrator is added to an organization.
|
|
710
|
+
* @param id - The organization ID
|
|
711
|
+
* @param administrator - Address of the administrator that was added
|
|
712
|
+
*/
|
|
713
|
+
type OrganizationAdministratorAddedCallback = EntityCallback<[string, string]>;
|
|
714
|
+
/**
|
|
715
|
+
* Callback for when an administrator is removed from an organization.
|
|
716
|
+
* @param id - The organization ID
|
|
717
|
+
* @param administrator - Address of the administrator that was removed
|
|
718
|
+
* @param remover - Address of the account that removed the administrator
|
|
719
|
+
*/
|
|
720
|
+
type OrganizationAdministratorRemovedCallback = EntityCallback<[string, string, string]>;
|
|
721
|
+
/**
|
|
722
|
+
* Callback for when a process is created.
|
|
723
|
+
* @param processID - The process ID
|
|
724
|
+
* @param creator - Address of the account that created the process
|
|
725
|
+
*/
|
|
726
|
+
type ProcessCreatedCallback = EntityCallback<[string, string]>;
|
|
727
|
+
/**
|
|
728
|
+
* Callback for when a process status changes.
|
|
729
|
+
* @param processID - The process ID
|
|
730
|
+
* @param oldStatus - The previous status
|
|
731
|
+
* @param newStatus - The new status
|
|
732
|
+
*/
|
|
733
|
+
type ProcessStatusChangedCallback = EntityCallback<[string, bigint, bigint]>;
|
|
734
|
+
/**
|
|
735
|
+
* Callback for when a process census is updated.
|
|
736
|
+
* @param processID - The process ID
|
|
737
|
+
* @param root - The new census root
|
|
738
|
+
* @param uri - The new census URI
|
|
739
|
+
* @param maxVotes - The maximum number of votes
|
|
740
|
+
*/
|
|
741
|
+
type ProcessCensusUpdatedCallback = EntityCallback<[string, string, string, bigint]>;
|
|
742
|
+
/**
|
|
743
|
+
* Callback for when a process duration changes.
|
|
744
|
+
* @param processID - The process ID
|
|
745
|
+
* @param duration - The new duration
|
|
746
|
+
*/
|
|
747
|
+
type ProcessDurationChangedCallback = EntityCallback<[string, bigint]>;
|
|
748
|
+
/**
|
|
749
|
+
* Callback for when a process state root is updated.
|
|
750
|
+
* @param processID - The process ID
|
|
751
|
+
* @param sender - Address of the account that updated the state root
|
|
752
|
+
* @param newStateRoot - The new state root
|
|
753
|
+
*/
|
|
754
|
+
type ProcessStateRootUpdatedCallback = EntityCallback<[string, string, bigint]>;
|
|
755
|
+
/**
|
|
756
|
+
* Callback for when process results are set.
|
|
757
|
+
* @param processID - The process ID
|
|
758
|
+
* @param sender - Address of the account that set the results
|
|
759
|
+
* @param result - The results array
|
|
760
|
+
*/
|
|
761
|
+
type ProcessResultsSetCallback = EntityCallback<[string, string, bigint[]]>;
|
|
762
|
+
|
|
763
|
+
declare enum ProcessStatus {
|
|
764
|
+
READY = 0,
|
|
765
|
+
ENDED = 1,
|
|
766
|
+
CANCELED = 2,
|
|
767
|
+
PAUSED = 3,
|
|
768
|
+
RESULTS = 4
|
|
769
|
+
}
|
|
770
|
+
declare class ProcessRegistryService extends SmartContractService {
|
|
771
|
+
private contract;
|
|
772
|
+
constructor(contractAddress: string, runner: ContractRunner);
|
|
773
|
+
getProcess(processID: string): Promise<_vocdoni_davinci_contracts_dist_src_ProcessRegistry.IProcessRegistry.ProcessStructOutput>;
|
|
774
|
+
getProcessCount(): Promise<number>;
|
|
775
|
+
getChainID(): Promise<string>;
|
|
776
|
+
getNextProcessId(organizationId: string): Promise<string>;
|
|
777
|
+
getProcessEndTime(processID: string): Promise<bigint>;
|
|
778
|
+
getRVerifierVKeyHash(): Promise<string>;
|
|
779
|
+
getSTVerifierVKeyHash(): Promise<string>;
|
|
780
|
+
getMaxCensusOrigin(): Promise<bigint>;
|
|
781
|
+
getMaxStatus(): Promise<bigint>;
|
|
782
|
+
getProcessNonce(address: string): Promise<bigint>;
|
|
783
|
+
getProcessDirect(processID: string): Promise<[bigint, string, _vocdoni_davinci_contracts_dist_src_ProcessRegistry.IProcessRegistry.EncryptionKeyStructOutput, bigint, bigint, bigint, bigint, bigint, bigint, bigint, string, _vocdoni_davinci_contracts_dist_src_ProcessRegistry.IProcessRegistry.BallotModeStructOutput, _vocdoni_davinci_contracts_dist_src_ProcessRegistry.IProcessRegistry.CensusStructOutput] & {
|
|
784
|
+
status: bigint;
|
|
785
|
+
organizationId: string;
|
|
786
|
+
encryptionKey: _vocdoni_davinci_contracts_dist_src_ProcessRegistry.IProcessRegistry.EncryptionKeyStructOutput;
|
|
787
|
+
latestStateRoot: bigint;
|
|
788
|
+
startTime: bigint;
|
|
789
|
+
duration: bigint;
|
|
790
|
+
voteCount: bigint;
|
|
791
|
+
voteOverwriteCount: bigint;
|
|
792
|
+
creationBlock: bigint;
|
|
793
|
+
batchNumber: bigint;
|
|
794
|
+
metadataURI: string;
|
|
795
|
+
ballotMode: _vocdoni_davinci_contracts_dist_src_ProcessRegistry.IProcessRegistry.BallotModeStructOutput;
|
|
796
|
+
census: _vocdoni_davinci_contracts_dist_src_ProcessRegistry.IProcessRegistry.CensusStructOutput;
|
|
797
|
+
}>;
|
|
798
|
+
getRVerifier(): Promise<string>;
|
|
799
|
+
getSTVerifier(): Promise<string>;
|
|
800
|
+
newProcess(status: ProcessStatus, startTime: number, duration: number, ballotMode: BallotMode, census: Census, metadata: string, encryptionKey: EncryptionKey, initStateRoot: bigint): AsyncGenerator<TxStatusEvent<{
|
|
801
|
+
success: boolean;
|
|
802
|
+
}>, void, unknown>;
|
|
803
|
+
setProcessStatus(processID: string, newStatus: ProcessStatus): AsyncGenerator<TxStatusEvent<{
|
|
804
|
+
success: boolean;
|
|
805
|
+
}>, void, unknown>;
|
|
806
|
+
setProcessCensus(processID: string, census: Census): AsyncGenerator<TxStatusEvent<{
|
|
807
|
+
success: boolean;
|
|
808
|
+
}>, void, unknown>;
|
|
809
|
+
setProcessDuration(processID: string, duration: number): AsyncGenerator<TxStatusEvent<{
|
|
810
|
+
success: boolean;
|
|
811
|
+
}>, void, unknown>;
|
|
812
|
+
/**
|
|
813
|
+
* Matches the on-chain `submitStateTransition(processId, proof, input)`
|
|
814
|
+
*/
|
|
815
|
+
submitStateTransition(processID: string, proof: string, input: string): AsyncGenerator<TxStatusEvent<{
|
|
816
|
+
success: boolean;
|
|
817
|
+
}>, void, unknown>;
|
|
818
|
+
/**
|
|
819
|
+
* Sets the results for a voting process.
|
|
820
|
+
*
|
|
821
|
+
* @param processID - The ID of the process to set results for
|
|
822
|
+
* @param proof - Zero-knowledge proof validating the results
|
|
823
|
+
* @param input - Input data for the proof verification
|
|
824
|
+
* @returns A transaction stream that resolves to success status
|
|
825
|
+
*/
|
|
826
|
+
setProcessResults(processID: string, proof: string, input: string): AsyncGenerator<TxStatusEvent<{
|
|
827
|
+
success: boolean;
|
|
828
|
+
}>, void, unknown>;
|
|
829
|
+
onProcessCreated(cb: ProcessCreatedCallback): void;
|
|
830
|
+
onProcessStatusChanged(cb: ProcessStatusChangedCallback): void;
|
|
831
|
+
onCensusUpdated(cb: ProcessCensusUpdatedCallback): void;
|
|
832
|
+
onProcessDurationChanged(cb: ProcessDurationChangedCallback): void;
|
|
833
|
+
onStateRootUpdated(cb: ProcessStateRootUpdatedCallback): void;
|
|
834
|
+
onProcessResultsSet(cb: ProcessResultsSetCallback): void;
|
|
835
|
+
removeAllListeners(): void;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
interface OrganizationInfo {
|
|
839
|
+
name: string;
|
|
840
|
+
metadataURI: string;
|
|
841
|
+
}
|
|
842
|
+
declare class OrganizationRegistryService extends SmartContractService {
|
|
843
|
+
private contract;
|
|
844
|
+
constructor(contractAddress: string, runner: ContractRunner);
|
|
845
|
+
getOrganization(id: string): Promise<OrganizationInfo>;
|
|
846
|
+
existsOrganization(id: string): Promise<boolean>;
|
|
847
|
+
isAdministrator(id: string, address: string): Promise<boolean>;
|
|
848
|
+
getOrganizationCount(): Promise<number>;
|
|
849
|
+
createOrganization(name: string, metadataURI: string, administrators: string[]): AsyncGenerator<TxStatusEvent<{
|
|
850
|
+
success: boolean;
|
|
851
|
+
}>, void, unknown>;
|
|
852
|
+
updateOrganization(id: string, name: string, metadataURI: string): AsyncGenerator<TxStatusEvent<{
|
|
853
|
+
success: boolean;
|
|
854
|
+
}>, void, unknown>;
|
|
855
|
+
addAdministrator(id: string, administrator: string): AsyncGenerator<TxStatusEvent<{
|
|
856
|
+
success: boolean;
|
|
857
|
+
}>, void, unknown>;
|
|
858
|
+
removeAdministrator(id: string, administrator: string): AsyncGenerator<TxStatusEvent<{
|
|
859
|
+
success: boolean;
|
|
860
|
+
}>, void, unknown>;
|
|
861
|
+
deleteOrganization(id: string): AsyncGenerator<TxStatusEvent<{
|
|
862
|
+
success: boolean;
|
|
863
|
+
}>, void, unknown>;
|
|
864
|
+
onOrganizationCreated(cb: OrganizationCreatedCallback): void;
|
|
865
|
+
onOrganizationUpdated(cb: OrganizationUpdatedCallback): void;
|
|
866
|
+
onAdministratorAdded(cb: OrganizationAdministratorAddedCallback): void;
|
|
867
|
+
onAdministratorRemoved(cb: OrganizationAdministratorRemovedCallback): void;
|
|
868
|
+
removeAllListeners(): void;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
interface ProofInputs {
|
|
872
|
+
fields: string[];
|
|
873
|
+
num_fields: string;
|
|
874
|
+
unique_values: string;
|
|
875
|
+
max_value: string;
|
|
876
|
+
min_value: string;
|
|
877
|
+
max_value_sum: string;
|
|
878
|
+
min_value_sum: string;
|
|
879
|
+
cost_exponent: string;
|
|
880
|
+
cost_from_weight: string;
|
|
881
|
+
address: string;
|
|
882
|
+
weight: string;
|
|
883
|
+
process_id: string;
|
|
884
|
+
vote_id: string;
|
|
885
|
+
encryption_pubkey: [string, string];
|
|
886
|
+
k: string;
|
|
887
|
+
cipherfields: string[];
|
|
888
|
+
inputs_hash: string;
|
|
889
|
+
}
|
|
890
|
+
interface Groth16Proof {
|
|
891
|
+
pi_a: [string, string, string];
|
|
892
|
+
pi_b: [[string, string], [string, string], [string, string]];
|
|
893
|
+
pi_c: [string, string, string];
|
|
894
|
+
protocol: string;
|
|
895
|
+
curve: string;
|
|
896
|
+
}
|
|
897
|
+
interface CircomProofOptions {
|
|
898
|
+
wasmUrl?: string;
|
|
899
|
+
zkeyUrl?: string;
|
|
900
|
+
vkeyUrl?: string;
|
|
901
|
+
/** Optional SHA-256 hash to verify circuit WASM file integrity */
|
|
902
|
+
wasmHash?: string;
|
|
903
|
+
/** Optional SHA-256 hash to verify proving key file integrity */
|
|
904
|
+
zkeyHash?: string;
|
|
905
|
+
/** Optional SHA-256 hash to verify verification key file integrity */
|
|
906
|
+
vkeyHash?: string;
|
|
907
|
+
}
|
|
908
|
+
declare class CircomProof {
|
|
909
|
+
private readonly wasmUrl?;
|
|
910
|
+
private readonly zkeyUrl?;
|
|
911
|
+
private readonly vkeyUrl?;
|
|
912
|
+
private readonly wasmHash?;
|
|
913
|
+
private readonly zkeyHash?;
|
|
914
|
+
private readonly vkeyHash?;
|
|
915
|
+
private wasmCache;
|
|
916
|
+
private zkeyCache;
|
|
917
|
+
private vkeyCache;
|
|
918
|
+
constructor(opts?: CircomProofOptions);
|
|
919
|
+
/**
|
|
920
|
+
* Computes SHA-256 hash of the given data and compares it with the expected hash.
|
|
921
|
+
* @param data - The data to hash (string or ArrayBuffer or Uint8Array)
|
|
922
|
+
* @param expectedHash - The expected SHA-256 hash in hexadecimal format
|
|
923
|
+
* @param filename - The filename for error reporting
|
|
924
|
+
* @throws Error if the computed hash doesn't match the expected hash
|
|
925
|
+
*/
|
|
926
|
+
private verifyHash;
|
|
927
|
+
/**
|
|
928
|
+
* Generate a zk‐SNARK proof.
|
|
929
|
+
* If you didn't pass wasmUrl/zkeyUrl in the constructor you must supply them here.
|
|
930
|
+
*/
|
|
931
|
+
generate(inputs: ProofInputs, urls?: {
|
|
932
|
+
wasmUrl?: string;
|
|
933
|
+
zkeyUrl?: string;
|
|
934
|
+
}): Promise<{
|
|
935
|
+
proof: Groth16Proof;
|
|
936
|
+
publicSignals: string[];
|
|
937
|
+
}>;
|
|
938
|
+
verify(proof: Groth16Proof, publicSignals: string[], urlOverride?: string): Promise<boolean>;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
interface DavinciCryptoInputs {
|
|
942
|
+
address: string;
|
|
943
|
+
processID: string;
|
|
944
|
+
encryptionKey: [string, string];
|
|
945
|
+
k?: string;
|
|
946
|
+
weight: string;
|
|
947
|
+
fieldValues: string[];
|
|
948
|
+
ballotMode: BallotMode;
|
|
949
|
+
}
|
|
950
|
+
interface DavinciCryptoCiphertext {
|
|
951
|
+
c1: [string, string];
|
|
952
|
+
c2: [string, string];
|
|
953
|
+
}
|
|
954
|
+
interface DavinciCryptoOutput {
|
|
955
|
+
processId: string;
|
|
956
|
+
address: string;
|
|
957
|
+
ballot: {
|
|
958
|
+
curveType: string;
|
|
959
|
+
ciphertexts: DavinciCryptoCiphertext[];
|
|
960
|
+
};
|
|
961
|
+
ballotInputsHash: string;
|
|
962
|
+
voteId: string;
|
|
963
|
+
circomInputs: ProofInputs;
|
|
964
|
+
}
|
|
965
|
+
interface CSPSignOutput {
|
|
966
|
+
censusOrigin: CensusOrigin;
|
|
967
|
+
root: string;
|
|
968
|
+
address: string;
|
|
969
|
+
processId: string;
|
|
970
|
+
publicKey: string;
|
|
971
|
+
signature: string;
|
|
972
|
+
}
|
|
973
|
+
interface RawResult<T = any> {
|
|
974
|
+
error?: string;
|
|
975
|
+
data?: T;
|
|
976
|
+
}
|
|
977
|
+
interface GoDavinciCryptoWasm {
|
|
978
|
+
proofInputs(inputJson: string): RawResult<DavinciCryptoOutput>;
|
|
979
|
+
cspSign(censusOrigin: number, privKey: string, processId: string, address: string): RawResult<CSPSignOutput>;
|
|
980
|
+
cspVerify(cspProof: string): RawResult<boolean>;
|
|
981
|
+
cspCensusRoot(censusOrigin: number, privKey: string): RawResult<{
|
|
982
|
+
root: string;
|
|
983
|
+
}>;
|
|
984
|
+
}
|
|
985
|
+
declare global {
|
|
986
|
+
var Go: new () => {
|
|
987
|
+
importObject: Record<string, any>;
|
|
988
|
+
run(instance: WebAssembly.Instance): Promise<void>;
|
|
989
|
+
};
|
|
990
|
+
var DavinciCrypto: GoDavinciCryptoWasm;
|
|
991
|
+
}
|
|
992
|
+
interface DavinciCryptoOptions {
|
|
993
|
+
/** URL to wasm_exec.js */
|
|
994
|
+
wasmExecUrl: string;
|
|
995
|
+
/** URL to the compiled davinci_crypto.wasm */
|
|
996
|
+
wasmUrl: string;
|
|
997
|
+
/** How long (ms) to wait for the Go runtime to attach DavinciCrypto */
|
|
998
|
+
initTimeoutMs?: number;
|
|
999
|
+
/** Optional SHA-256 hash to verify wasm_exec.js integrity */
|
|
1000
|
+
wasmExecHash?: string;
|
|
1001
|
+
/** Optional SHA-256 hash to verify davinci_crypto.wasm integrity */
|
|
1002
|
+
wasmHash?: string;
|
|
1003
|
+
}
|
|
1004
|
+
declare class DavinciCrypto {
|
|
1005
|
+
private go;
|
|
1006
|
+
private initialized;
|
|
1007
|
+
private readonly wasmExecUrl;
|
|
1008
|
+
private readonly wasmUrl;
|
|
1009
|
+
private readonly initTimeoutMs;
|
|
1010
|
+
private readonly wasmExecHash?;
|
|
1011
|
+
private readonly wasmHash?;
|
|
1012
|
+
private static wasmExecCache;
|
|
1013
|
+
private static wasmBinaryCache;
|
|
1014
|
+
constructor(opts: DavinciCryptoOptions);
|
|
1015
|
+
/**
|
|
1016
|
+
* Computes SHA-256 hash of the given data and compares it with the expected hash.
|
|
1017
|
+
* @param data - The data to hash (string or ArrayBuffer)
|
|
1018
|
+
* @param expectedHash - The expected SHA-256 hash in hexadecimal format
|
|
1019
|
+
* @param filename - The filename for error reporting
|
|
1020
|
+
* @throws Error if the computed hash doesn't match the expected hash
|
|
1021
|
+
*/
|
|
1022
|
+
private verifyHash;
|
|
1023
|
+
/**
|
|
1024
|
+
* Must be awaited before calling `proofInputs()`.
|
|
1025
|
+
* Safe to call multiple times.
|
|
1026
|
+
*/
|
|
1027
|
+
init(): Promise<void>;
|
|
1028
|
+
/**
|
|
1029
|
+
* Convert your inputs into JSON, hand off to Go/WASM, then parse & return.
|
|
1030
|
+
* @throws if called before `await init()`, or if Go returns an error
|
|
1031
|
+
*/
|
|
1032
|
+
proofInputs(inputs: DavinciCryptoInputs): Promise<DavinciCryptoOutput>;
|
|
1033
|
+
/**
|
|
1034
|
+
* Generate a CSP (Credential Service Provider) signature for census proof.
|
|
1035
|
+
* @param censusOrigin - The census origin type (e.g., CensusOrigin.CensusOriginCSP)
|
|
1036
|
+
* @param privKey - The private key in hex format
|
|
1037
|
+
* @param processId - The process ID in hex format
|
|
1038
|
+
* @param address - The address in hex format
|
|
1039
|
+
* @returns The CSP proof as a parsed JSON object
|
|
1040
|
+
* @throws if called before `await init()`, or if Go returns an error
|
|
1041
|
+
*/
|
|
1042
|
+
cspSign(censusOrigin: CensusOrigin, privKey: string, processId: string, address: string): Promise<CSPSignOutput>;
|
|
1043
|
+
/**
|
|
1044
|
+
* Verify a CSP (Credential Service Provider) proof.
|
|
1045
|
+
* @param censusOrigin - The census origin type (e.g., CensusOrigin.CensusOriginCSP)
|
|
1046
|
+
* @param root - The census root
|
|
1047
|
+
* @param address - The address
|
|
1048
|
+
* @param processId - The process ID
|
|
1049
|
+
* @param publicKey - The public key
|
|
1050
|
+
* @param signature - The signature
|
|
1051
|
+
* @returns The verification result
|
|
1052
|
+
* @throws if called before `await init()`, or if Go returns an error
|
|
1053
|
+
*/
|
|
1054
|
+
cspVerify(censusOrigin: CensusOrigin, root: string, address: string, processId: string, publicKey: string, signature: string): Promise<boolean>;
|
|
1055
|
+
/**
|
|
1056
|
+
* Generate a CSP (Credential Service Provider) census root.
|
|
1057
|
+
* @param censusOrigin - The census origin type (e.g., CensusOrigin.CensusOriginCSP)
|
|
1058
|
+
* @param privKey - The private key in hex format
|
|
1059
|
+
* @returns The census root as a hexadecimal string
|
|
1060
|
+
* @throws if called before `await init()`, or if Go returns an error
|
|
1061
|
+
*/
|
|
1062
|
+
cspCensusRoot(censusOrigin: CensusOrigin, privKey: string): Promise<string>;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
/**
|
|
1066
|
+
* Base interface with shared fields between ProcessConfig and ProcessInfo
|
|
1067
|
+
*/
|
|
1068
|
+
interface BaseProcess {
|
|
1069
|
+
/** Process title */
|
|
1070
|
+
title: string;
|
|
1071
|
+
/** Process description (optional) */
|
|
1072
|
+
description?: string;
|
|
1073
|
+
/** Census configuration */
|
|
1074
|
+
census: {
|
|
1075
|
+
/** Census type - MerkleTree or CSP */
|
|
1076
|
+
type: CensusOrigin;
|
|
1077
|
+
/** Census root */
|
|
1078
|
+
root: string;
|
|
1079
|
+
/** Census size */
|
|
1080
|
+
size: number;
|
|
1081
|
+
/** Census URI */
|
|
1082
|
+
uri: string;
|
|
1083
|
+
};
|
|
1084
|
+
/** Ballot configuration */
|
|
1085
|
+
ballot: BallotMode;
|
|
1086
|
+
/** Election questions and choices (required) */
|
|
1087
|
+
questions: Array<{
|
|
1088
|
+
title: string;
|
|
1089
|
+
description?: string;
|
|
1090
|
+
choices: Array<{
|
|
1091
|
+
title: string;
|
|
1092
|
+
value: number;
|
|
1093
|
+
}>;
|
|
1094
|
+
}>;
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Configuration for creating a process
|
|
1098
|
+
*/
|
|
1099
|
+
interface ProcessConfig extends BaseProcess {
|
|
1100
|
+
/** Process timing - use either duration-based or date-based configuration */
|
|
1101
|
+
timing: {
|
|
1102
|
+
/** Start date/time (Date object, ISO string, or Unix timestamp, default: now + 60 seconds) */
|
|
1103
|
+
startDate?: Date | string | number;
|
|
1104
|
+
/** Duration in seconds (required if endDate is not provided) */
|
|
1105
|
+
duration?: number;
|
|
1106
|
+
/** End date/time (Date object, ISO string, or Unix timestamp, cannot be used with duration) */
|
|
1107
|
+
endDate?: Date | string | number;
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Result of process creation
|
|
1112
|
+
*/
|
|
1113
|
+
interface ProcessCreationResult {
|
|
1114
|
+
/** The created process ID */
|
|
1115
|
+
processId: string;
|
|
1116
|
+
/** Transaction hash of the on-chain process creation */
|
|
1117
|
+
transactionHash: string;
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
* User-friendly process information that extends the base process with additional runtime data
|
|
1121
|
+
*/
|
|
1122
|
+
interface ProcessInfo extends BaseProcess {
|
|
1123
|
+
/** The process ID */
|
|
1124
|
+
processId: string;
|
|
1125
|
+
/** Current process status */
|
|
1126
|
+
status: ProcessStatus;
|
|
1127
|
+
/** Process creator address */
|
|
1128
|
+
creator: string;
|
|
1129
|
+
/** Start date as Date object */
|
|
1130
|
+
startDate: Date;
|
|
1131
|
+
/** End date as Date object */
|
|
1132
|
+
endDate: Date;
|
|
1133
|
+
/** Duration in seconds */
|
|
1134
|
+
duration: number;
|
|
1135
|
+
/** Time remaining in seconds (0 if ended, negative if not started) */
|
|
1136
|
+
timeRemaining: number;
|
|
1137
|
+
/** Process results (array of BigInt values) */
|
|
1138
|
+
result: bigint[];
|
|
1139
|
+
/** Number of votes cast */
|
|
1140
|
+
voteCount: number;
|
|
1141
|
+
/** Number of vote overwrites */
|
|
1142
|
+
voteOverwriteCount: number;
|
|
1143
|
+
/** Metadata URI */
|
|
1144
|
+
metadataURI: string;
|
|
1145
|
+
/** Raw contract data (for advanced users) */
|
|
1146
|
+
raw?: any;
|
|
1147
|
+
}
|
|
1148
|
+
/**
|
|
1149
|
+
* Service that orchestrates the complete process creation workflow
|
|
1150
|
+
*/
|
|
1151
|
+
declare class ProcessOrchestrationService {
|
|
1152
|
+
private processRegistry;
|
|
1153
|
+
private apiService;
|
|
1154
|
+
private organizationRegistry;
|
|
1155
|
+
private getCrypto;
|
|
1156
|
+
private signer;
|
|
1157
|
+
constructor(processRegistry: ProcessRegistryService, apiService: VocdoniApiService, organizationRegistry: OrganizationRegistryService, getCrypto: () => Promise<DavinciCrypto>, signer: Signer);
|
|
1158
|
+
/**
|
|
1159
|
+
* Gets user-friendly process information by transforming raw contract data
|
|
1160
|
+
* @param processId - The process ID to fetch
|
|
1161
|
+
* @returns Promise resolving to the user-friendly process information
|
|
1162
|
+
*/
|
|
1163
|
+
getProcess(processId: string): Promise<ProcessInfo>;
|
|
1164
|
+
/**
|
|
1165
|
+
* Creates a complete voting process with minimal configuration
|
|
1166
|
+
* This method handles all the complex orchestration internally
|
|
1167
|
+
*/
|
|
1168
|
+
createProcess(config: ProcessConfig): Promise<ProcessCreationResult>;
|
|
1169
|
+
/**
|
|
1170
|
+
* Validates and calculates timing parameters
|
|
1171
|
+
*/
|
|
1172
|
+
private calculateTiming;
|
|
1173
|
+
/**
|
|
1174
|
+
* Converts various date formats to Unix timestamp
|
|
1175
|
+
*/
|
|
1176
|
+
private dateToUnixTimestamp;
|
|
1177
|
+
/**
|
|
1178
|
+
* Creates metadata from the simplified configuration
|
|
1179
|
+
*/
|
|
1180
|
+
private createMetadata;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* Simplified vote configuration interface for end users
|
|
1185
|
+
*/
|
|
1186
|
+
interface VoteConfig {
|
|
1187
|
+
/** The process ID to vote in */
|
|
1188
|
+
processId: string;
|
|
1189
|
+
/** The voter's choices - array of selected values for each question */
|
|
1190
|
+
choices: number[];
|
|
1191
|
+
/** Optional: Custom randomness for vote encryption (will be generated if not provided) */
|
|
1192
|
+
randomness?: string;
|
|
1193
|
+
}
|
|
1194
|
+
/**
|
|
1195
|
+
* Result of vote submission
|
|
1196
|
+
*/
|
|
1197
|
+
interface VoteResult {
|
|
1198
|
+
/** The unique vote ID */
|
|
1199
|
+
voteId: string;
|
|
1200
|
+
/** The transaction signature */
|
|
1201
|
+
signature: string;
|
|
1202
|
+
/** The voter's address */
|
|
1203
|
+
voterAddress: string;
|
|
1204
|
+
/** The process ID */
|
|
1205
|
+
processId: string;
|
|
1206
|
+
/** Current vote status */
|
|
1207
|
+
status: VoteStatus;
|
|
1208
|
+
}
|
|
1209
|
+
/**
|
|
1210
|
+
* Vote status information
|
|
1211
|
+
*/
|
|
1212
|
+
interface VoteStatusInfo {
|
|
1213
|
+
/** The vote ID */
|
|
1214
|
+
voteId: string;
|
|
1215
|
+
/** Current status of the vote */
|
|
1216
|
+
status: VoteStatus;
|
|
1217
|
+
/** The process ID */
|
|
1218
|
+
processId: string;
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Service that orchestrates the complete voting workflow
|
|
1222
|
+
* Handles all the complex cryptographic operations and API calls internally
|
|
1223
|
+
*/
|
|
1224
|
+
declare class VoteOrchestrationService {
|
|
1225
|
+
private apiService;
|
|
1226
|
+
private getCrypto;
|
|
1227
|
+
private signer;
|
|
1228
|
+
private censusProviders;
|
|
1229
|
+
constructor(apiService: VocdoniApiService, getCrypto: () => Promise<DavinciCrypto>, signer: Signer, censusProviders?: CensusProviders);
|
|
1230
|
+
/**
|
|
1231
|
+
* Submit a vote with simplified configuration
|
|
1232
|
+
* This method handles all the complex orchestration internally:
|
|
1233
|
+
* - Fetches process information and encryption keys
|
|
1234
|
+
* - Gets census proof (Merkle or CSP)
|
|
1235
|
+
* - Generates cryptographic proofs
|
|
1236
|
+
* - Signs and submits the vote
|
|
1237
|
+
*
|
|
1238
|
+
* @param config - Simplified vote configuration
|
|
1239
|
+
* @returns Promise resolving to vote submission result
|
|
1240
|
+
*/
|
|
1241
|
+
submitVote(config: VoteConfig): Promise<VoteResult>;
|
|
1242
|
+
/**
|
|
1243
|
+
* Get the status of a submitted vote
|
|
1244
|
+
*
|
|
1245
|
+
* @param processId - The process ID
|
|
1246
|
+
* @param voteId - The vote ID
|
|
1247
|
+
* @returns Promise resolving to vote status information
|
|
1248
|
+
*/
|
|
1249
|
+
getVoteStatus(processId: string, voteId: string): Promise<VoteStatusInfo>;
|
|
1250
|
+
/**
|
|
1251
|
+
* Check if an address has voted in a process
|
|
1252
|
+
*
|
|
1253
|
+
* @param processId - The process ID
|
|
1254
|
+
* @param address - The voter's address
|
|
1255
|
+
* @returns Promise resolving to boolean indicating if the address has voted
|
|
1256
|
+
*/
|
|
1257
|
+
hasAddressVoted(processId: string, address: string): Promise<boolean>;
|
|
1258
|
+
/**
|
|
1259
|
+
* Wait for a vote to reach a specific status
|
|
1260
|
+
*
|
|
1261
|
+
* @param processId - The process ID
|
|
1262
|
+
* @param voteId - The vote ID
|
|
1263
|
+
* @param targetStatus - The target status to wait for (default: "settled")
|
|
1264
|
+
* @param timeoutMs - Maximum time to wait in milliseconds (default: 300000 = 5 minutes)
|
|
1265
|
+
* @param pollIntervalMs - Polling interval in milliseconds (default: 5000 = 5 seconds)
|
|
1266
|
+
* @returns Promise resolving to final vote status
|
|
1267
|
+
*/
|
|
1268
|
+
waitForVoteStatus(processId: string, voteId: string, targetStatus?: VoteStatus, timeoutMs?: number, pollIntervalMs?: number): Promise<VoteStatusInfo>;
|
|
1269
|
+
/**
|
|
1270
|
+
* Get census proof based on census origin type
|
|
1271
|
+
*/
|
|
1272
|
+
private getCensusProof;
|
|
1273
|
+
/**
|
|
1274
|
+
* Generate vote proof inputs using DavinciCrypto
|
|
1275
|
+
*/
|
|
1276
|
+
private generateVoteProofInputs;
|
|
1277
|
+
/**
|
|
1278
|
+
* Validate user choices based on ballot mode
|
|
1279
|
+
*/
|
|
1280
|
+
private validateChoices;
|
|
1281
|
+
/**
|
|
1282
|
+
* Generate zk-SNARK proof using CircomProof
|
|
1283
|
+
*/
|
|
1284
|
+
private generateZkProof;
|
|
1285
|
+
private hexToBytes;
|
|
1286
|
+
/**
|
|
1287
|
+
* Sign the vote using the signer
|
|
1288
|
+
*/
|
|
1289
|
+
private signVote;
|
|
1290
|
+
/**
|
|
1291
|
+
* Submit the vote request to the sequencer
|
|
1292
|
+
*/
|
|
1293
|
+
private submitVoteRequest;
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
/**
|
|
1297
|
+
* @fileoverview Standardized error classes for contract services
|
|
1298
|
+
*
|
|
1299
|
+
* This module provides a consistent error hierarchy for all contract service operations.
|
|
1300
|
+
* All errors extend from ContractServiceError and include operation context for better debugging.
|
|
1301
|
+
*/
|
|
1302
|
+
/**
|
|
1303
|
+
* Abstract base class for all contract service errors.
|
|
1304
|
+
* Provides consistent error structure with operation context.
|
|
1305
|
+
*/
|
|
1306
|
+
declare abstract class ContractServiceError extends Error {
|
|
1307
|
+
readonly operation: string;
|
|
1308
|
+
/**
|
|
1309
|
+
* Creates a new ContractServiceError instance.
|
|
1310
|
+
*
|
|
1311
|
+
* @param message - The error message describing what went wrong
|
|
1312
|
+
* @param operation - The operation that was being performed when the error occurred
|
|
1313
|
+
*/
|
|
1314
|
+
constructor(message: string, operation: string);
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Error thrown when organization creation fails.
|
|
1318
|
+
*/
|
|
1319
|
+
declare class OrganizationCreateError extends ContractServiceError {
|
|
1320
|
+
}
|
|
1321
|
+
/**
|
|
1322
|
+
* Error thrown when organization update fails.
|
|
1323
|
+
*/
|
|
1324
|
+
declare class OrganizationUpdateError extends ContractServiceError {
|
|
1325
|
+
}
|
|
1326
|
+
/**
|
|
1327
|
+
* Error thrown when organization deletion fails.
|
|
1328
|
+
*/
|
|
1329
|
+
declare class OrganizationDeleteError extends ContractServiceError {
|
|
1330
|
+
}
|
|
1331
|
+
/**
|
|
1332
|
+
* Error thrown when administrator operations fail.
|
|
1333
|
+
*/
|
|
1334
|
+
declare class OrganizationAdministratorError extends ContractServiceError {
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* Error thrown when process creation fails.
|
|
1338
|
+
*/
|
|
1339
|
+
declare class ProcessCreateError extends ContractServiceError {
|
|
1340
|
+
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Error thrown when process status change fails.
|
|
1343
|
+
*/
|
|
1344
|
+
declare class ProcessStatusError extends ContractServiceError {
|
|
1345
|
+
}
|
|
1346
|
+
/**
|
|
1347
|
+
* Error thrown when process census update fails.
|
|
1348
|
+
*/
|
|
1349
|
+
declare class ProcessCensusError extends ContractServiceError {
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Error thrown when process duration change fails.
|
|
1353
|
+
*/
|
|
1354
|
+
declare class ProcessDurationError extends ContractServiceError {
|
|
1355
|
+
}
|
|
1356
|
+
/**
|
|
1357
|
+
* Error thrown when state transition submission fails.
|
|
1358
|
+
*/
|
|
1359
|
+
declare class ProcessStateTransitionError extends ContractServiceError {
|
|
1360
|
+
}
|
|
1361
|
+
/**
|
|
1362
|
+
* Error thrown when process result setting fails.
|
|
1363
|
+
*/
|
|
1364
|
+
declare class ProcessResultError extends ContractServiceError {
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
/**
|
|
1368
|
+
* Creates the signature message for process creation.
|
|
1369
|
+
* @param processId - The process ID (with or without 0x prefix)
|
|
1370
|
+
* @returns The message string to be signed
|
|
1371
|
+
*/
|
|
1372
|
+
declare function createProcessSignatureMessage(processId: string): string;
|
|
1373
|
+
/**
|
|
1374
|
+
* Signs the process creation message with the provided signer.
|
|
1375
|
+
* @param processId - The process ID (with or without 0x prefix)
|
|
1376
|
+
* @param signer - The signer (Wallet or Signer) to sign with
|
|
1377
|
+
* @returns Promise resolving to the signature string
|
|
1378
|
+
*/
|
|
1379
|
+
declare function signProcessCreation(processId: string, signer: Signer | Wallet): Promise<string>;
|
|
1380
|
+
/**
|
|
1381
|
+
* Validates that a process ID is a valid 64-character hex string (32 bytes).
|
|
1382
|
+
* @param processId - The process ID to validate
|
|
1383
|
+
* @returns True if valid, false otherwise
|
|
1384
|
+
*/
|
|
1385
|
+
declare function validateProcessId(processId: string): boolean;
|
|
1386
|
+
|
|
1387
|
+
export { BaseService, CircomProof, ContractServiceError, DEFAULT_ENVIRONMENT_URLS, DavinciCrypto, ElectionMetadataTemplate, ElectionResultsTypeNames, OrganizationAdministratorError, OrganizationCreateError, OrganizationDeleteError, OrganizationRegistryService, OrganizationUpdateError, ProcessCensusError, ProcessCreateError, ProcessDurationError, ProcessOrchestrationService, ProcessRegistryService, ProcessResultError, ProcessStateTransitionError, ProcessStatus, ProcessStatusError, SmartContractService, TxStatus, VocdoniApiService, VocdoniSequencerService, VoteOrchestrationService, VoteStatus, createProcessSignatureMessage, deployedAddresses, getElectionMetadataTemplate, getEnvironmentChain, getEnvironmentConfig, getEnvironmentUrls, resolveConfiguration, resolveUrls, signProcessCreation, validateProcessId };
|
|
1388
|
+
export type { AbstainProperties, AnyJson, ApiError, ApprovalProperties, BallotMode, BaseProcess, BudgetProperties, CSPSignOutput, Census, ChainConfig, Choice, ChoiceProperties, CircomProofOptions, CreateProcessRequest, CreateProcessResponse, CustomMeta, DavinciCryptoCiphertext, DavinciCryptoInputs, DavinciCryptoOptions, DavinciCryptoOutput, DeployedAddresses, ElectionMetadata, ElectionResultsType, EncryptionKey, EntityCallback, Environment, EnvironmentConfig, EnvironmentOptions, GetProcessResponse, Groth16Proof, IChoice, IQuestion, InfoResponse, JsonArray, JsonMap, ListProcessesResponse, MultiLanguage, OrganizationAdministratorAddedCallback, OrganizationAdministratorRemovedCallback, OrganizationCreatedCallback, OrganizationInfo, OrganizationUpdatedCallback, ProcessCensusUpdatedCallback, ProcessConfig, ProcessCreatedCallback, ProcessCreationResult, ProcessDurationChangedCallback, ProcessInfo, ProcessResultsSetCallback, ProcessStateRootUpdatedCallback, ProcessStatusChangedCallback, ProofInputs, ProtocolVersion, QuadraticProperties, Question, SequencerStats, ServiceUrls, TxStatusEvent, VocdoniApiServiceConfig, VoteBallot, VoteCiphertext, VoteConfig, VoteProof, VoteRequest, VoteResult, VoteStatusInfo, VoteStatusResponse, WorkerStats, WorkersResponse };
|