@vocdoni/davinci-sdk 0.0.5 → 0.0.7
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 +51 -3
- package/dist/contracts.d.ts +35 -12
- package/dist/index.d.ts +177 -22
- package/dist/index.js +229 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +229 -33
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +229 -32
- package/dist/sequencer.d.ts +12 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -321,7 +321,7 @@ For advanced use cases, you can still provide census data manually:
|
|
|
321
321
|
```typescript
|
|
322
322
|
const process = await sdk.createProcess({
|
|
323
323
|
census: {
|
|
324
|
-
type: CensusOrigin.
|
|
324
|
+
type: CensusOrigin.OffchainStatic,
|
|
325
325
|
root: "0xabc...",
|
|
326
326
|
size: 100,
|
|
327
327
|
uri: "ipfs://..."
|
|
@@ -406,7 +406,7 @@ const processResult = await sdk.createProcess({
|
|
|
406
406
|
|
|
407
407
|
// Census configuration
|
|
408
408
|
census: {
|
|
409
|
-
type: CensusOrigin.
|
|
409
|
+
type: CensusOrigin.OffchainStatic,
|
|
410
410
|
root: "0x...",
|
|
411
411
|
size: 1000,
|
|
412
412
|
uri: "ipfs://..."
|
|
@@ -431,6 +431,9 @@ const processResult = await sdk.createProcess({
|
|
|
431
431
|
minValueSum: "0"
|
|
432
432
|
},
|
|
433
433
|
|
|
434
|
+
// Maximum voters (optional, defaults to census size)
|
|
435
|
+
maxVoters: 500, // Limit the process to 500 voters
|
|
436
|
+
|
|
434
437
|
// Questions
|
|
435
438
|
questions: [{
|
|
436
439
|
title: "What is your preferred option?",
|
|
@@ -500,9 +503,54 @@ console.log('Title:', processInfo.title);
|
|
|
500
503
|
console.log('Status:', processInfo.status);
|
|
501
504
|
console.log('Start date:', processInfo.startDate);
|
|
502
505
|
console.log('End date:', processInfo.endDate);
|
|
506
|
+
console.log('Max voters:', processInfo.maxVoters);
|
|
507
|
+
console.log('Voters count:', processInfo.votersCount);
|
|
503
508
|
console.log('Questions:', processInfo.questions);
|
|
504
509
|
```
|
|
505
510
|
|
|
511
|
+
#### Managing Process MaxVoters
|
|
512
|
+
|
|
513
|
+
You can update the maximum number of voters allowed for a process after creation:
|
|
514
|
+
|
|
515
|
+
```typescript
|
|
516
|
+
// Update maxVoters limit
|
|
517
|
+
await sdk.setProcessMaxVoters(processId, 750);
|
|
518
|
+
|
|
519
|
+
console.log('MaxVoters updated to 750');
|
|
520
|
+
|
|
521
|
+
// Verify the change
|
|
522
|
+
const updatedProcess = await sdk.getProcess(processId);
|
|
523
|
+
console.log('New maxVoters:', updatedProcess.maxVoters);
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
For real-time transaction status updates, use the stream version:
|
|
527
|
+
|
|
528
|
+
```typescript
|
|
529
|
+
import { TxStatus } from '@vocdoni/davinci-sdk';
|
|
530
|
+
|
|
531
|
+
const stream = sdk.setProcessMaxVotersStream(processId, 750);
|
|
532
|
+
|
|
533
|
+
for await (const event of stream) {
|
|
534
|
+
switch (event.status) {
|
|
535
|
+
case TxStatus.Pending:
|
|
536
|
+
console.log("📝 Transaction submitted:", event.hash);
|
|
537
|
+
break;
|
|
538
|
+
|
|
539
|
+
case TxStatus.Completed:
|
|
540
|
+
console.log("✅ MaxVoters updated successfully");
|
|
541
|
+
break;
|
|
542
|
+
|
|
543
|
+
case TxStatus.Failed:
|
|
544
|
+
console.error("❌ Transaction failed:", event.error);
|
|
545
|
+
break;
|
|
546
|
+
|
|
547
|
+
case TxStatus.Reverted:
|
|
548
|
+
console.error("⚠️ Transaction reverted:", event.reason);
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
```
|
|
553
|
+
|
|
506
554
|
### Voting Operations
|
|
507
555
|
|
|
508
556
|
#### Submitting a Vote
|
|
@@ -614,7 +662,7 @@ async function completeVotingExample() {
|
|
|
614
662
|
title: "Community Budget Allocation",
|
|
615
663
|
description: "Decide how to allocate our community budget",
|
|
616
664
|
census: {
|
|
617
|
-
type: CensusOrigin.
|
|
665
|
+
type: CensusOrigin.OffchainStatic,
|
|
618
666
|
root: publishResult.root,
|
|
619
667
|
size: censusSize,
|
|
620
668
|
uri: publishResult.uri
|
package/dist/contracts.d.ts
CHANGED
|
@@ -224,6 +224,11 @@ declare class ProcessStatusError extends ContractServiceError {
|
|
|
224
224
|
*/
|
|
225
225
|
declare class ProcessCensusError extends ContractServiceError {
|
|
226
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Error thrown when the census origin does not allow to modify the census root or uri.
|
|
229
|
+
*/
|
|
230
|
+
declare class CensusNotUpdatable extends ContractServiceError {
|
|
231
|
+
}
|
|
227
232
|
/**
|
|
228
233
|
* Error thrown when process duration change fails.
|
|
229
234
|
*/
|
|
@@ -302,12 +307,15 @@ type ProcessCensusUpdatedCallback = EntityCallback<[string, string, string]>;
|
|
|
302
307
|
*/
|
|
303
308
|
type ProcessDurationChangedCallback = EntityCallback<[string, bigint]>;
|
|
304
309
|
/**
|
|
305
|
-
* Callback for when a process state
|
|
310
|
+
* Callback for when a process state transitions (valid state transition published).
|
|
306
311
|
* @param processID - The process ID
|
|
307
312
|
* @param sender - Address of the account that updated the state root
|
|
308
|
-
* @param
|
|
313
|
+
* @param oldStateRoot - The state root before the state transition
|
|
314
|
+
* @param newStateRoot - The new state root after the state transition
|
|
315
|
+
* @param newVotersCount - The number of single voters for the process updated after the state transition
|
|
316
|
+
* @param newOverwrittenVotesCount - The number of votes that has been overwritten updated after the state transition
|
|
309
317
|
*/
|
|
310
|
-
type
|
|
318
|
+
type ProcessStateTransitionedCallback = EntityCallback<[string, string, bigint, bigint, bigint, bigint]>;
|
|
311
319
|
/**
|
|
312
320
|
* Callback for when process results are set.
|
|
313
321
|
* @param processID - The process ID
|
|
@@ -315,6 +323,12 @@ type ProcessStateRootUpdatedCallback = EntityCallback<[string, string, bigint]>;
|
|
|
315
323
|
* @param result - The results array
|
|
316
324
|
*/
|
|
317
325
|
type ProcessResultsSetCallback = EntityCallback<[string, string, bigint[]]>;
|
|
326
|
+
/**
|
|
327
|
+
* Callback for when process maxVoters is changed.
|
|
328
|
+
* @param processID - The process ID
|
|
329
|
+
* @param maxVoters - The new maxVoters value
|
|
330
|
+
*/
|
|
331
|
+
type ProcessMaxVotersChangedCallback = EntityCallback<[string, bigint]>;
|
|
318
332
|
|
|
319
333
|
interface OrganizationInfo {
|
|
320
334
|
name: string;
|
|
@@ -353,10 +367,14 @@ declare class OrganizationRegistryService extends SmartContractService {
|
|
|
353
367
|
* Census origin types
|
|
354
368
|
*/
|
|
355
369
|
declare enum CensusOrigin {
|
|
356
|
-
/**
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
|
|
370
|
+
/** Offchain static Merkle Tree census */
|
|
371
|
+
OffchainStatic = 1,
|
|
372
|
+
/** Offchain dynamic Merkle Tree census */
|
|
373
|
+
OffchainDynamic = 2,
|
|
374
|
+
/** Onchain Merkle Tree census */
|
|
375
|
+
Onchain = 3,
|
|
376
|
+
/** Credential Service Provider (CSP) census using EdDSA BLS12-377 */
|
|
377
|
+
CSP = 4
|
|
360
378
|
}
|
|
361
379
|
|
|
362
380
|
interface BallotMode {
|
|
@@ -463,13 +481,14 @@ declare class ProcessRegistryService extends SmartContractService {
|
|
|
463
481
|
getMaxCensusOrigin(): Promise<bigint>;
|
|
464
482
|
getMaxStatus(): Promise<bigint>;
|
|
465
483
|
getProcessNonce(address: string): Promise<bigint>;
|
|
466
|
-
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] & {
|
|
484
|
+
getProcessDirect(processID: string): Promise<[bigint, string, _vocdoni_davinci_contracts_dist_src_ProcessRegistry.IProcessRegistry.EncryptionKeyStructOutput, bigint, bigint, bigint, bigint, bigint, bigint, bigint, bigint, string, _vocdoni_davinci_contracts_dist_src_ProcessRegistry.IProcessRegistry.BallotModeStructOutput, _vocdoni_davinci_contracts_dist_src_ProcessRegistry.IProcessRegistry.CensusStructOutput] & {
|
|
467
485
|
status: bigint;
|
|
468
486
|
organizationId: string;
|
|
469
487
|
encryptionKey: _vocdoni_davinci_contracts_dist_src_ProcessRegistry.IProcessRegistry.EncryptionKeyStructOutput;
|
|
470
488
|
latestStateRoot: bigint;
|
|
471
489
|
startTime: bigint;
|
|
472
490
|
duration: bigint;
|
|
491
|
+
maxVoters: bigint;
|
|
473
492
|
votersCount: bigint;
|
|
474
493
|
overwrittenVotesCount: bigint;
|
|
475
494
|
creationBlock: bigint;
|
|
@@ -480,7 +499,7 @@ declare class ProcessRegistryService extends SmartContractService {
|
|
|
480
499
|
}>;
|
|
481
500
|
getRVerifier(): Promise<string>;
|
|
482
501
|
getSTVerifier(): Promise<string>;
|
|
483
|
-
newProcess(status: ProcessStatus, startTime: number, duration: number, ballotMode: BallotMode, census: CensusData, metadata: string, encryptionKey: EncryptionKey, initStateRoot: bigint): AsyncGenerator<TxStatusEvent<{
|
|
502
|
+
newProcess(status: ProcessStatus, startTime: number, duration: number, maxVoters: number, ballotMode: BallotMode, census: CensusData, metadata: string, encryptionKey: EncryptionKey, initStateRoot: bigint): AsyncGenerator<TxStatusEvent<{
|
|
484
503
|
success: boolean;
|
|
485
504
|
}>, void, unknown>;
|
|
486
505
|
setProcessStatus(processID: string, newStatus: ProcessStatus): AsyncGenerator<TxStatusEvent<{
|
|
@@ -492,6 +511,9 @@ declare class ProcessRegistryService extends SmartContractService {
|
|
|
492
511
|
setProcessDuration(processID: string, duration: number): AsyncGenerator<TxStatusEvent<{
|
|
493
512
|
success: boolean;
|
|
494
513
|
}>, void, unknown>;
|
|
514
|
+
setProcessMaxVoters(processID: string, maxVoters: number): AsyncGenerator<TxStatusEvent<{
|
|
515
|
+
success: boolean;
|
|
516
|
+
}>, void, unknown>;
|
|
495
517
|
/**
|
|
496
518
|
* Matches the on-chain `submitStateTransition(processId, proof, input)`
|
|
497
519
|
*/
|
|
@@ -513,10 +535,11 @@ declare class ProcessRegistryService extends SmartContractService {
|
|
|
513
535
|
onProcessStatusChanged(cb: ProcessStatusChangedCallback): void;
|
|
514
536
|
onCensusUpdated(cb: ProcessCensusUpdatedCallback): void;
|
|
515
537
|
onProcessDurationChanged(cb: ProcessDurationChangedCallback): void;
|
|
516
|
-
|
|
538
|
+
onStateTransitioned(cb: ProcessStateTransitionedCallback): void;
|
|
517
539
|
onProcessResultsSet(cb: ProcessResultsSetCallback): void;
|
|
540
|
+
onProcessMaxVotersChanged(cb: ProcessMaxVotersChangedCallback): void;
|
|
518
541
|
removeAllListeners(): void;
|
|
519
542
|
}
|
|
520
543
|
|
|
521
|
-
export { ContractServiceError, OrganizationAdministratorError, OrganizationCreateError, OrganizationDeleteError, OrganizationRegistryService, OrganizationUpdateError, ProcessCensusError, ProcessCreateError, ProcessDurationError, ProcessRegistryService, ProcessResultError, ProcessStateTransitionError, ProcessStatus, ProcessStatusError, SmartContractService, TxStatus };
|
|
522
|
-
export type { EntityCallback, OrganizationAdministratorAddedCallback, OrganizationAdministratorRemovedCallback, OrganizationCreatedCallback, OrganizationInfo, OrganizationUpdatedCallback, ProcessCensusUpdatedCallback, ProcessCreatedCallback, ProcessDurationChangedCallback, ProcessResultsSetCallback,
|
|
544
|
+
export { CensusNotUpdatable, ContractServiceError, OrganizationAdministratorError, OrganizationCreateError, OrganizationDeleteError, OrganizationRegistryService, OrganizationUpdateError, ProcessCensusError, ProcessCreateError, ProcessDurationError, ProcessRegistryService, ProcessResultError, ProcessStateTransitionError, ProcessStatus, ProcessStatusError, SmartContractService, TxStatus };
|
|
545
|
+
export type { EntityCallback, OrganizationAdministratorAddedCallback, OrganizationAdministratorRemovedCallback, OrganizationCreatedCallback, OrganizationInfo, OrganizationUpdatedCallback, ProcessCensusUpdatedCallback, ProcessCreatedCallback, ProcessDurationChangedCallback, ProcessMaxVotersChangedCallback, ProcessResultsSetCallback, ProcessStateTransitionedCallback, ProcessStatusChangedCallback, TxStatusEvent };
|
package/dist/index.d.ts
CHANGED
|
@@ -108,10 +108,14 @@ declare class BaseService {
|
|
|
108
108
|
* Census origin types
|
|
109
109
|
*/
|
|
110
110
|
declare enum CensusOrigin {
|
|
111
|
-
/**
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
|
|
111
|
+
/** Offchain static Merkle Tree census */
|
|
112
|
+
OffchainStatic = 1,
|
|
113
|
+
/** Offchain dynamic Merkle Tree census */
|
|
114
|
+
OffchainDynamic = 2,
|
|
115
|
+
/** Onchain Merkle Tree census */
|
|
116
|
+
Onchain = 3,
|
|
117
|
+
/** Credential Service Provider (CSP) census using EdDSA BLS12-377 */
|
|
118
|
+
CSP = 4
|
|
115
119
|
}
|
|
116
120
|
interface CensusParticipant$1 {
|
|
117
121
|
key: string;
|
|
@@ -124,18 +128,18 @@ interface BaseCensusProof {
|
|
|
124
128
|
address: string;
|
|
125
129
|
/** The weight as a decimal string. */
|
|
126
130
|
weight: string;
|
|
127
|
-
/** Census origin type:
|
|
131
|
+
/** Census origin type: OffchainStatic/OffchainDynamic/Onchain for merkle proofs, CSP for csp proofs */
|
|
128
132
|
censusOrigin: CensusOrigin;
|
|
129
133
|
}
|
|
130
134
|
interface MerkleCensusProof extends BaseCensusProof {
|
|
131
|
-
censusOrigin: CensusOrigin.
|
|
135
|
+
censusOrigin: CensusOrigin.OffchainStatic | CensusOrigin.OffchainDynamic | CensusOrigin.Onchain;
|
|
132
136
|
/** The leaf value (hex-prefixed weight). */
|
|
133
137
|
value: string;
|
|
134
138
|
/** The serialized sibling path (hex-prefixed). */
|
|
135
139
|
siblings: string;
|
|
136
140
|
}
|
|
137
141
|
interface CSPCensusProof extends BaseCensusProof {
|
|
138
|
-
censusOrigin: CensusOrigin.
|
|
142
|
+
censusOrigin: CensusOrigin.CSP;
|
|
139
143
|
/** The process id signed with the address (hex-prefixed). */
|
|
140
144
|
processId: string;
|
|
141
145
|
/** The public key of the csp (hex-prefixed). */
|
|
@@ -308,8 +312,9 @@ declare abstract class Census {
|
|
|
308
312
|
protected _censusRoot: string | null;
|
|
309
313
|
protected _censusURI: string | null;
|
|
310
314
|
protected _type: CensusType;
|
|
315
|
+
protected _censusOrigin: CensusOrigin;
|
|
311
316
|
protected _size: number | null;
|
|
312
|
-
constructor(type: CensusType);
|
|
317
|
+
constructor(type: CensusType, censusOrigin?: CensusOrigin);
|
|
313
318
|
get censusId(): string | null;
|
|
314
319
|
get censusRoot(): string | null;
|
|
315
320
|
get censusURI(): string | null;
|
|
@@ -317,7 +322,7 @@ declare abstract class Census {
|
|
|
317
322
|
get size(): number | null;
|
|
318
323
|
get isPublished(): boolean;
|
|
319
324
|
/**
|
|
320
|
-
*
|
|
325
|
+
* Get the census origin (OffchainStatic, OffchainDynamic, Onchain, or CSP)
|
|
321
326
|
*/
|
|
322
327
|
get censusOrigin(): CensusOrigin;
|
|
323
328
|
}
|
|
@@ -328,7 +333,11 @@ declare abstract class Census {
|
|
|
328
333
|
*/
|
|
329
334
|
declare class PlainCensus extends Census {
|
|
330
335
|
private _participants;
|
|
331
|
-
|
|
336
|
+
/**
|
|
337
|
+
* Creates a new PlainCensus
|
|
338
|
+
* @param censusOrigin - The census origin (defaults to OffchainStatic for backward compatibility)
|
|
339
|
+
*/
|
|
340
|
+
constructor(censusOrigin?: CensusOrigin);
|
|
332
341
|
/**
|
|
333
342
|
* Add participant(s) with automatic weight=1
|
|
334
343
|
* @param addresses - Single address or array of addresses
|
|
@@ -369,7 +378,11 @@ interface WeightedParticipant {
|
|
|
369
378
|
*/
|
|
370
379
|
declare class WeightedCensus extends Census {
|
|
371
380
|
private _participants;
|
|
372
|
-
|
|
381
|
+
/**
|
|
382
|
+
* Creates a new WeightedCensus
|
|
383
|
+
* @param censusOrigin - The census origin (defaults to OffchainStatic for backward compatibility)
|
|
384
|
+
*/
|
|
385
|
+
constructor(censusOrigin?: CensusOrigin);
|
|
373
386
|
/**
|
|
374
387
|
* Add participant(s) with custom weights
|
|
375
388
|
* Weight can be provided as string, number, or bigint - will be converted to string internally
|
|
@@ -421,7 +434,15 @@ declare class CspCensus extends Census {
|
|
|
421
434
|
* Use this when you have the census root, URI, and size from a previous publication
|
|
422
435
|
*/
|
|
423
436
|
declare class PublishedCensus extends Census {
|
|
424
|
-
|
|
437
|
+
/**
|
|
438
|
+
* Creates a PublishedCensus from existing census data
|
|
439
|
+
* @param type - The census type (PLAIN, WEIGHTED, or CSP)
|
|
440
|
+
* @param root - The census root
|
|
441
|
+
* @param uri - The census URI
|
|
442
|
+
* @param size - The census size (number of participants)
|
|
443
|
+
* @param censusOrigin - The census origin (optional - defaults based on type if not provided)
|
|
444
|
+
*/
|
|
445
|
+
constructor(type: CensusType, root: string, uri: string, size: number, censusOrigin?: CensusOrigin);
|
|
425
446
|
}
|
|
426
447
|
|
|
427
448
|
/**
|
|
@@ -496,6 +517,7 @@ interface GetProcessResponse {
|
|
|
496
517
|
ballotMode: BallotMode;
|
|
497
518
|
census: CensusData;
|
|
498
519
|
votersCount: string;
|
|
520
|
+
maxVoters: string;
|
|
499
521
|
overwrittenVotesCount: string;
|
|
500
522
|
isAcceptingVotes: boolean;
|
|
501
523
|
sequencerStats: {
|
|
@@ -857,12 +879,15 @@ type ProcessCensusUpdatedCallback = EntityCallback<[string, string, string]>;
|
|
|
857
879
|
*/
|
|
858
880
|
type ProcessDurationChangedCallback = EntityCallback<[string, bigint]>;
|
|
859
881
|
/**
|
|
860
|
-
* Callback for when a process state
|
|
882
|
+
* Callback for when a process state transitions (valid state transition published).
|
|
861
883
|
* @param processID - The process ID
|
|
862
884
|
* @param sender - Address of the account that updated the state root
|
|
863
|
-
* @param
|
|
885
|
+
* @param oldStateRoot - The state root before the state transition
|
|
886
|
+
* @param newStateRoot - The new state root after the state transition
|
|
887
|
+
* @param newVotersCount - The number of single voters for the process updated after the state transition
|
|
888
|
+
* @param newOverwrittenVotesCount - The number of votes that has been overwritten updated after the state transition
|
|
864
889
|
*/
|
|
865
|
-
type
|
|
890
|
+
type ProcessStateTransitionedCallback = EntityCallback<[string, string, bigint, bigint, bigint, bigint]>;
|
|
866
891
|
/**
|
|
867
892
|
* Callback for when process results are set.
|
|
868
893
|
* @param processID - The process ID
|
|
@@ -870,6 +895,12 @@ type ProcessStateRootUpdatedCallback = EntityCallback<[string, string, bigint]>;
|
|
|
870
895
|
* @param result - The results array
|
|
871
896
|
*/
|
|
872
897
|
type ProcessResultsSetCallback = EntityCallback<[string, string, bigint[]]>;
|
|
898
|
+
/**
|
|
899
|
+
* Callback for when process maxVoters is changed.
|
|
900
|
+
* @param processID - The process ID
|
|
901
|
+
* @param maxVoters - The new maxVoters value
|
|
902
|
+
*/
|
|
903
|
+
type ProcessMaxVotersChangedCallback = EntityCallback<[string, bigint]>;
|
|
873
904
|
|
|
874
905
|
declare enum ProcessStatus {
|
|
875
906
|
READY = 0,
|
|
@@ -891,13 +922,14 @@ declare class ProcessRegistryService extends SmartContractService {
|
|
|
891
922
|
getMaxCensusOrigin(): Promise<bigint>;
|
|
892
923
|
getMaxStatus(): Promise<bigint>;
|
|
893
924
|
getProcessNonce(address: string): Promise<bigint>;
|
|
894
|
-
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] & {
|
|
925
|
+
getProcessDirect(processID: string): Promise<[bigint, string, _vocdoni_davinci_contracts_dist_src_ProcessRegistry.IProcessRegistry.EncryptionKeyStructOutput, bigint, bigint, bigint, bigint, bigint, bigint, bigint, bigint, string, _vocdoni_davinci_contracts_dist_src_ProcessRegistry.IProcessRegistry.BallotModeStructOutput, _vocdoni_davinci_contracts_dist_src_ProcessRegistry.IProcessRegistry.CensusStructOutput] & {
|
|
895
926
|
status: bigint;
|
|
896
927
|
organizationId: string;
|
|
897
928
|
encryptionKey: _vocdoni_davinci_contracts_dist_src_ProcessRegistry.IProcessRegistry.EncryptionKeyStructOutput;
|
|
898
929
|
latestStateRoot: bigint;
|
|
899
930
|
startTime: bigint;
|
|
900
931
|
duration: bigint;
|
|
932
|
+
maxVoters: bigint;
|
|
901
933
|
votersCount: bigint;
|
|
902
934
|
overwrittenVotesCount: bigint;
|
|
903
935
|
creationBlock: bigint;
|
|
@@ -908,7 +940,7 @@ declare class ProcessRegistryService extends SmartContractService {
|
|
|
908
940
|
}>;
|
|
909
941
|
getRVerifier(): Promise<string>;
|
|
910
942
|
getSTVerifier(): Promise<string>;
|
|
911
|
-
newProcess(status: ProcessStatus, startTime: number, duration: number, ballotMode: BallotMode, census: CensusData, metadata: string, encryptionKey: EncryptionKey, initStateRoot: bigint): AsyncGenerator<TxStatusEvent<{
|
|
943
|
+
newProcess(status: ProcessStatus, startTime: number, duration: number, maxVoters: number, ballotMode: BallotMode, census: CensusData, metadata: string, encryptionKey: EncryptionKey, initStateRoot: bigint): AsyncGenerator<TxStatusEvent<{
|
|
912
944
|
success: boolean;
|
|
913
945
|
}>, void, unknown>;
|
|
914
946
|
setProcessStatus(processID: string, newStatus: ProcessStatus): AsyncGenerator<TxStatusEvent<{
|
|
@@ -920,6 +952,9 @@ declare class ProcessRegistryService extends SmartContractService {
|
|
|
920
952
|
setProcessDuration(processID: string, duration: number): AsyncGenerator<TxStatusEvent<{
|
|
921
953
|
success: boolean;
|
|
922
954
|
}>, void, unknown>;
|
|
955
|
+
setProcessMaxVoters(processID: string, maxVoters: number): AsyncGenerator<TxStatusEvent<{
|
|
956
|
+
success: boolean;
|
|
957
|
+
}>, void, unknown>;
|
|
923
958
|
/**
|
|
924
959
|
* Matches the on-chain `submitStateTransition(processId, proof, input)`
|
|
925
960
|
*/
|
|
@@ -941,8 +976,9 @@ declare class ProcessRegistryService extends SmartContractService {
|
|
|
941
976
|
onProcessStatusChanged(cb: ProcessStatusChangedCallback): void;
|
|
942
977
|
onCensusUpdated(cb: ProcessCensusUpdatedCallback): void;
|
|
943
978
|
onProcessDurationChanged(cb: ProcessDurationChangedCallback): void;
|
|
944
|
-
|
|
979
|
+
onStateTransitioned(cb: ProcessStateTransitionedCallback): void;
|
|
945
980
|
onProcessResultsSet(cb: ProcessResultsSetCallback): void;
|
|
981
|
+
onProcessMaxVotersChanged(cb: ProcessMaxVotersChangedCallback): void;
|
|
946
982
|
removeAllListeners(): void;
|
|
947
983
|
}
|
|
948
984
|
|
|
@@ -1239,6 +1275,11 @@ interface BaseProcessConfig {
|
|
|
1239
1275
|
/** End date/time (Date object, ISO string, or Unix timestamp, cannot be used with duration) */
|
|
1240
1276
|
endDate?: Date | string | number;
|
|
1241
1277
|
};
|
|
1278
|
+
/**
|
|
1279
|
+
* Maximum number of voters allowed for this process (optional, defaults to census size)
|
|
1280
|
+
* This parameter limits how many votes can be cast in the process.
|
|
1281
|
+
*/
|
|
1282
|
+
maxVoters?: number;
|
|
1242
1283
|
}
|
|
1243
1284
|
/**
|
|
1244
1285
|
* Process configuration with metadata fields (title, description, questions)
|
|
@@ -1292,6 +1333,8 @@ interface ProcessInfo extends BaseProcess {
|
|
|
1292
1333
|
duration: number;
|
|
1293
1334
|
/** Time remaining in seconds (0 if ended, negative if not started) */
|
|
1294
1335
|
timeRemaining: number;
|
|
1336
|
+
/** Maximum number of voters allowed */
|
|
1337
|
+
maxVoters: number;
|
|
1295
1338
|
/** Process results (array of BigInt values) */
|
|
1296
1339
|
result: bigint[];
|
|
1297
1340
|
/** Number of votes cast */
|
|
@@ -1592,6 +1635,56 @@ declare class ProcessOrchestrationService {
|
|
|
1592
1635
|
* ```
|
|
1593
1636
|
*/
|
|
1594
1637
|
resumeProcess(processId: string): Promise<void>;
|
|
1638
|
+
/**
|
|
1639
|
+
* Sets the maximum number of voters for a process.
|
|
1640
|
+
* Returns an async generator that yields transaction status events.
|
|
1641
|
+
*
|
|
1642
|
+
* @param processId - The process ID
|
|
1643
|
+
* @param maxVoters - The new maximum number of voters
|
|
1644
|
+
* @returns AsyncGenerator yielding transaction status events
|
|
1645
|
+
*
|
|
1646
|
+
* @example
|
|
1647
|
+
* ```typescript
|
|
1648
|
+
* const stream = sdk.setProcessMaxVotersStream("0x1234567890abcdef...", 500);
|
|
1649
|
+
*
|
|
1650
|
+
* for await (const event of stream) {
|
|
1651
|
+
* switch (event.status) {
|
|
1652
|
+
* case "pending":
|
|
1653
|
+
* console.log("Transaction pending:", event.hash);
|
|
1654
|
+
* break;
|
|
1655
|
+
* case "completed":
|
|
1656
|
+
* console.log("MaxVoters updated successfully");
|
|
1657
|
+
* break;
|
|
1658
|
+
* case "failed":
|
|
1659
|
+
* console.error("Transaction failed:", event.error);
|
|
1660
|
+
* break;
|
|
1661
|
+
* case "reverted":
|
|
1662
|
+
* console.error("Transaction reverted:", event.reason);
|
|
1663
|
+
* break;
|
|
1664
|
+
* }
|
|
1665
|
+
* }
|
|
1666
|
+
* ```
|
|
1667
|
+
*/
|
|
1668
|
+
setProcessMaxVotersStream(processId: string, maxVoters: number): AsyncGenerator<TxStatusEvent<{
|
|
1669
|
+
success: boolean;
|
|
1670
|
+
}>>;
|
|
1671
|
+
/**
|
|
1672
|
+
* Sets the maximum number of voters for a process.
|
|
1673
|
+
* This is a simplified method that waits for transaction completion.
|
|
1674
|
+
*
|
|
1675
|
+
* For real-time transaction status updates, use setProcessMaxVotersStream() instead.
|
|
1676
|
+
*
|
|
1677
|
+
* @param processId - The process ID
|
|
1678
|
+
* @param maxVoters - The new maximum number of voters
|
|
1679
|
+
* @returns Promise resolving when the maxVoters is updated
|
|
1680
|
+
*
|
|
1681
|
+
* @example
|
|
1682
|
+
* ```typescript
|
|
1683
|
+
* await sdk.setProcessMaxVoters("0x1234567890abcdef...", 500);
|
|
1684
|
+
* console.log("MaxVoters updated successfully");
|
|
1685
|
+
* ```
|
|
1686
|
+
*/
|
|
1687
|
+
setProcessMaxVoters(processId: string, maxVoters: number): Promise<void>;
|
|
1595
1688
|
}
|
|
1596
1689
|
|
|
1597
1690
|
/**
|
|
@@ -1809,6 +1902,11 @@ declare class ProcessStatusError extends ContractServiceError {
|
|
|
1809
1902
|
*/
|
|
1810
1903
|
declare class ProcessCensusError extends ContractServiceError {
|
|
1811
1904
|
}
|
|
1905
|
+
/**
|
|
1906
|
+
* Error thrown when the census origin does not allow to modify the census root or uri.
|
|
1907
|
+
*/
|
|
1908
|
+
declare class CensusNotUpdatable extends ContractServiceError {
|
|
1909
|
+
}
|
|
1812
1910
|
/**
|
|
1813
1911
|
* Error thrown when process duration change fails.
|
|
1814
1912
|
*/
|
|
@@ -1996,7 +2094,7 @@ declare class DavinciSDK {
|
|
|
1996
2094
|
* title: "My Election",
|
|
1997
2095
|
* description: "A simple election",
|
|
1998
2096
|
* census: {
|
|
1999
|
-
* type: CensusOrigin.
|
|
2097
|
+
* type: CensusOrigin.OffchainStatic,
|
|
2000
2098
|
* root: "0x1234...",
|
|
2001
2099
|
* size: 100,
|
|
2002
2100
|
* uri: "ipfs://..."
|
|
@@ -2077,7 +2175,7 @@ declare class DavinciSDK {
|
|
|
2077
2175
|
* title: "My Election",
|
|
2078
2176
|
* description: "A simple election",
|
|
2079
2177
|
* census: {
|
|
2080
|
-
* type: CensusOrigin.
|
|
2178
|
+
* type: CensusOrigin.OffchainStatic,
|
|
2081
2179
|
* root: "0x1234...",
|
|
2082
2180
|
* size: 100,
|
|
2083
2181
|
* uri: "ipfs://your-census-uri"
|
|
@@ -2531,6 +2629,63 @@ declare class DavinciSDK {
|
|
|
2531
2629
|
* ```
|
|
2532
2630
|
*/
|
|
2533
2631
|
resumeProcess(processId: string): Promise<void>;
|
|
2632
|
+
/**
|
|
2633
|
+
* Sets the maximum number of voters for a process and returns an async generator
|
|
2634
|
+
* that yields transaction status events. This allows you to change the voter limit
|
|
2635
|
+
* after process creation.
|
|
2636
|
+
*
|
|
2637
|
+
* Requires a signer with a provider for blockchain interactions.
|
|
2638
|
+
*
|
|
2639
|
+
* @param processId - The process ID
|
|
2640
|
+
* @param maxVoters - The new maximum number of voters
|
|
2641
|
+
* @returns AsyncGenerator yielding transaction status events
|
|
2642
|
+
* @throws Error if signer does not have a provider
|
|
2643
|
+
*
|
|
2644
|
+
* @example
|
|
2645
|
+
* ```typescript
|
|
2646
|
+
* const stream = sdk.setProcessMaxVotersStream("0x1234567890abcdef...", 500);
|
|
2647
|
+
*
|
|
2648
|
+
* for await (const event of stream) {
|
|
2649
|
+
* switch (event.status) {
|
|
2650
|
+
* case TxStatus.Pending:
|
|
2651
|
+
* console.log("Transaction pending:", event.hash);
|
|
2652
|
+
* break;
|
|
2653
|
+
* case TxStatus.Completed:
|
|
2654
|
+
* console.log("MaxVoters updated successfully");
|
|
2655
|
+
* break;
|
|
2656
|
+
* case TxStatus.Failed:
|
|
2657
|
+
* console.error("Transaction failed:", event.error);
|
|
2658
|
+
* break;
|
|
2659
|
+
* case TxStatus.Reverted:
|
|
2660
|
+
* console.error("Transaction reverted:", event.reason);
|
|
2661
|
+
* break;
|
|
2662
|
+
* }
|
|
2663
|
+
* }
|
|
2664
|
+
* ```
|
|
2665
|
+
*/
|
|
2666
|
+
setProcessMaxVotersStream(processId: string, maxVoters: number): AsyncGenerator<TxStatusEvent<{
|
|
2667
|
+
success: boolean;
|
|
2668
|
+
}>, any, any>;
|
|
2669
|
+
/**
|
|
2670
|
+
* Sets the maximum number of voters for a process.
|
|
2671
|
+
* This is the simplified method that waits for transaction completion.
|
|
2672
|
+
*
|
|
2673
|
+
* For real-time transaction status updates, use setProcessMaxVotersStream() instead.
|
|
2674
|
+
*
|
|
2675
|
+
* Requires a signer with a provider for blockchain interactions.
|
|
2676
|
+
*
|
|
2677
|
+
* @param processId - The process ID
|
|
2678
|
+
* @param maxVoters - The new maximum number of voters
|
|
2679
|
+
* @returns Promise resolving when the maxVoters is updated
|
|
2680
|
+
* @throws Error if signer does not have a provider
|
|
2681
|
+
*
|
|
2682
|
+
* @example
|
|
2683
|
+
* ```typescript
|
|
2684
|
+
* await sdk.setProcessMaxVoters("0x1234567890abcdef...", 500);
|
|
2685
|
+
* console.log("MaxVoters updated successfully");
|
|
2686
|
+
* ```
|
|
2687
|
+
*/
|
|
2688
|
+
setProcessMaxVoters(processId: string, maxVoters: number): Promise<void>;
|
|
2534
2689
|
/**
|
|
2535
2690
|
* Resolve contract address based on configuration priority:
|
|
2536
2691
|
* 1. Custom addresses from user config (if provided)
|
|
@@ -2558,5 +2713,5 @@ declare class DavinciSDK {
|
|
|
2558
2713
|
private ensureProvider;
|
|
2559
2714
|
}
|
|
2560
2715
|
|
|
2561
|
-
export { BaseService, Census, CensusOrchestrator, CensusOrigin, CensusType, CircomProof, ContractServiceError, CspCensus, DavinciCrypto, DavinciSDK, ElectionMetadataTemplate, ElectionResultsTypeNames, OrganizationAdministratorError, OrganizationCreateError, OrganizationDeleteError, OrganizationRegistryService, OrganizationUpdateError, PlainCensus, ProcessCensusError, ProcessCreateError, ProcessDurationError, ProcessOrchestrationService, ProcessRegistryService, ProcessResultError, ProcessStateTransitionError, ProcessStatus, ProcessStatusError, PublishedCensus, SmartContractService, TxStatus, VocdoniApiService, VocdoniCensusService, VocdoniSequencerService, VoteOrchestrationService, VoteStatus, WeightedCensus, assertCSPCensusProof, assertMerkleCensusProof, createProcessSignatureMessage, getElectionMetadataTemplate, isCSPCensusProof, isMerkleCensusProof, signProcessCreation, validateProcessId };
|
|
2562
|
-
export type { AbstainProperties, AnyJson, ApiError, ApprovalProperties, BallotMode, BaseCensusProof, BaseProcess, BudgetProperties, CSPCensusProof, CSPCensusProofProvider, CSPSignOutput, CensusData, CensusParticipant$1 as CensusParticipant, CensusProof, CensusProviders, CensusSizeResponse, Choice, ChoiceProperties, CircomProofOptions, CreateProcessRequest, CreateProcessResponse, CustomMeta, DavinciCryptoCiphertext, DavinciCryptoInputs, DavinciCryptoOptions, DavinciCryptoOutput, DavinciSDKConfig, ElectionMetadata, ElectionResultsType, EncryptionKey, EntityCallback, GetProcessResponse, Groth16Proof, HealthResponse, IChoice, IQuestion, InfoResponse, JsonArray, JsonMap, ListProcessesResponse, MerkleCensusProof, MerkleCensusProofProvider, MultiLanguage, OrganizationAdministratorAddedCallback, OrganizationAdministratorRemovedCallback, OrganizationCreatedCallback, OrganizationInfo, OrganizationUpdatedCallback, ParticipantInfoResponse, ProcessCensusUpdatedCallback, ProcessConfig, ProcessConfigWithMetadata, ProcessConfigWithMetadataUri, ProcessCreatedCallback, ProcessCreationResult, ProcessDurationChangedCallback, ProcessInfo, ProcessQuestion, ProcessResultsSetCallback,
|
|
2716
|
+
export { BaseService, Census, CensusNotUpdatable, CensusOrchestrator, CensusOrigin, CensusType, CircomProof, ContractServiceError, CspCensus, DavinciCrypto, DavinciSDK, ElectionMetadataTemplate, ElectionResultsTypeNames, OrganizationAdministratorError, OrganizationCreateError, OrganizationDeleteError, OrganizationRegistryService, OrganizationUpdateError, PlainCensus, ProcessCensusError, ProcessCreateError, ProcessDurationError, ProcessOrchestrationService, ProcessRegistryService, ProcessResultError, ProcessStateTransitionError, ProcessStatus, ProcessStatusError, PublishedCensus, SmartContractService, TxStatus, VocdoniApiService, VocdoniCensusService, VocdoniSequencerService, VoteOrchestrationService, VoteStatus, WeightedCensus, assertCSPCensusProof, assertMerkleCensusProof, createProcessSignatureMessage, getElectionMetadataTemplate, isCSPCensusProof, isMerkleCensusProof, signProcessCreation, validateProcessId };
|
|
2717
|
+
export type { AbstainProperties, AnyJson, ApiError, ApprovalProperties, BallotMode, BaseCensusProof, BaseProcess, BudgetProperties, CSPCensusProof, CSPCensusProofProvider, CSPSignOutput, CensusData, CensusParticipant$1 as CensusParticipant, CensusProof, CensusProviders, CensusSizeResponse, Choice, ChoiceProperties, CircomProofOptions, CreateProcessRequest, CreateProcessResponse, CustomMeta, DavinciCryptoCiphertext, DavinciCryptoInputs, DavinciCryptoOptions, DavinciCryptoOutput, DavinciSDKConfig, ElectionMetadata, ElectionResultsType, EncryptionKey, EntityCallback, GetProcessResponse, Groth16Proof, HealthResponse, IChoice, IQuestion, InfoResponse, JsonArray, JsonMap, ListProcessesResponse, MerkleCensusProof, MerkleCensusProofProvider, MultiLanguage, OrganizationAdministratorAddedCallback, OrganizationAdministratorRemovedCallback, OrganizationCreatedCallback, OrganizationInfo, OrganizationUpdatedCallback, ParticipantInfoResponse, ProcessCensusUpdatedCallback, ProcessConfig, ProcessConfigWithMetadata, ProcessConfigWithMetadataUri, ProcessCreatedCallback, ProcessCreationResult, ProcessDurationChangedCallback, ProcessInfo, ProcessMaxVotersChangedCallback, ProcessQuestion, ProcessResultsSetCallback, ProcessStateTransitionedCallback, ProcessStatusChangedCallback, ProofInputs, ProtocolVersion, PublishCensusResponse, QuadraticProperties, Question, SequencerStats, Snapshot, SnapshotsQueryParams, SnapshotsResponse, TxStatusEvent, VocdoniApiServiceConfig, VoteBallot, VoteCiphertext, VoteConfig, VoteOrchestrationConfig, VoteProof, VoteRequest, VoteResult, VoteStatusInfo, VoteStatusResponse, WeightedParticipant, WorkerStats, WorkersResponse };
|