@vocdoni/davinci-sdk 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -0
- package/dist/contracts.d.ts +16 -5
- package/dist/index.d.ts +163 -40
- package/dist/index.js +230 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +230 -14
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +230 -14
- package/dist/sequencer.d.ts +6 -27
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -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
|
package/dist/contracts.d.ts
CHANGED
|
@@ -315,6 +315,12 @@ type ProcessStateRootUpdatedCallback = EntityCallback<[string, string, bigint]>;
|
|
|
315
315
|
* @param result - The results array
|
|
316
316
|
*/
|
|
317
317
|
type ProcessResultsSetCallback = EntityCallback<[string, string, bigint[]]>;
|
|
318
|
+
/**
|
|
319
|
+
* Callback for when process maxVoters is changed.
|
|
320
|
+
* @param processID - The process ID
|
|
321
|
+
* @param maxVoters - The new maxVoters value
|
|
322
|
+
*/
|
|
323
|
+
type ProcessMaxVotersChangedCallback = EntityCallback<[string, bigint]>;
|
|
318
324
|
|
|
319
325
|
interface OrganizationInfo {
|
|
320
326
|
name: string;
|
|
@@ -463,15 +469,16 @@ declare class ProcessRegistryService extends SmartContractService {
|
|
|
463
469
|
getMaxCensusOrigin(): Promise<bigint>;
|
|
464
470
|
getMaxStatus(): Promise<bigint>;
|
|
465
471
|
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] & {
|
|
472
|
+
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
473
|
status: bigint;
|
|
468
474
|
organizationId: string;
|
|
469
475
|
encryptionKey: _vocdoni_davinci_contracts_dist_src_ProcessRegistry.IProcessRegistry.EncryptionKeyStructOutput;
|
|
470
476
|
latestStateRoot: bigint;
|
|
471
477
|
startTime: bigint;
|
|
472
478
|
duration: bigint;
|
|
473
|
-
|
|
474
|
-
|
|
479
|
+
maxVoters: bigint;
|
|
480
|
+
votersCount: bigint;
|
|
481
|
+
overwrittenVotesCount: bigint;
|
|
475
482
|
creationBlock: bigint;
|
|
476
483
|
batchNumber: bigint;
|
|
477
484
|
metadataURI: string;
|
|
@@ -480,7 +487,7 @@ declare class ProcessRegistryService extends SmartContractService {
|
|
|
480
487
|
}>;
|
|
481
488
|
getRVerifier(): Promise<string>;
|
|
482
489
|
getSTVerifier(): Promise<string>;
|
|
483
|
-
newProcess(status: ProcessStatus, startTime: number, duration: number, ballotMode: BallotMode, census: CensusData, metadata: string, encryptionKey: EncryptionKey, initStateRoot: bigint): AsyncGenerator<TxStatusEvent<{
|
|
490
|
+
newProcess(status: ProcessStatus, startTime: number, duration: number, maxVoters: number, ballotMode: BallotMode, census: CensusData, metadata: string, encryptionKey: EncryptionKey, initStateRoot: bigint): AsyncGenerator<TxStatusEvent<{
|
|
484
491
|
success: boolean;
|
|
485
492
|
}>, void, unknown>;
|
|
486
493
|
setProcessStatus(processID: string, newStatus: ProcessStatus): AsyncGenerator<TxStatusEvent<{
|
|
@@ -492,6 +499,9 @@ declare class ProcessRegistryService extends SmartContractService {
|
|
|
492
499
|
setProcessDuration(processID: string, duration: number): AsyncGenerator<TxStatusEvent<{
|
|
493
500
|
success: boolean;
|
|
494
501
|
}>, void, unknown>;
|
|
502
|
+
setProcessMaxVoters(processID: string, maxVoters: number): AsyncGenerator<TxStatusEvent<{
|
|
503
|
+
success: boolean;
|
|
504
|
+
}>, void, unknown>;
|
|
495
505
|
/**
|
|
496
506
|
* Matches the on-chain `submitStateTransition(processId, proof, input)`
|
|
497
507
|
*/
|
|
@@ -515,8 +525,9 @@ declare class ProcessRegistryService extends SmartContractService {
|
|
|
515
525
|
onProcessDurationChanged(cb: ProcessDurationChangedCallback): void;
|
|
516
526
|
onStateRootUpdated(cb: ProcessStateRootUpdatedCallback): void;
|
|
517
527
|
onProcessResultsSet(cb: ProcessResultsSetCallback): void;
|
|
528
|
+
onProcessMaxVotersChanged(cb: ProcessMaxVotersChangedCallback): void;
|
|
518
529
|
removeAllListeners(): void;
|
|
519
530
|
}
|
|
520
531
|
|
|
521
532
|
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, ProcessStateRootUpdatedCallback, ProcessStatusChangedCallback, TxStatusEvent };
|
|
533
|
+
export type { EntityCallback, OrganizationAdministratorAddedCallback, OrganizationAdministratorRemovedCallback, OrganizationCreatedCallback, OrganizationInfo, OrganizationUpdatedCallback, ProcessCensusUpdatedCallback, ProcessCreatedCallback, ProcessDurationChangedCallback, ProcessMaxVotersChangedCallback, ProcessResultsSetCallback, ProcessStateRootUpdatedCallback, ProcessStatusChangedCallback, TxStatusEvent };
|
package/dist/index.d.ts
CHANGED
|
@@ -489,36 +489,14 @@ interface GetProcessResponse {
|
|
|
489
489
|
organizationId: string;
|
|
490
490
|
encryptionKey: EncryptionKey;
|
|
491
491
|
stateRoot: string;
|
|
492
|
-
result: string[];
|
|
493
|
-
startTime:
|
|
492
|
+
result: string[] | null;
|
|
493
|
+
startTime: string;
|
|
494
494
|
duration: number;
|
|
495
495
|
metadataURI: string;
|
|
496
496
|
ballotMode: BallotMode;
|
|
497
497
|
census: CensusData;
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
description: Record<string, string>;
|
|
501
|
-
media: {
|
|
502
|
-
header: string;
|
|
503
|
-
logo: string;
|
|
504
|
-
};
|
|
505
|
-
questions: {
|
|
506
|
-
title: Record<string, string>;
|
|
507
|
-
description: Record<string, string>;
|
|
508
|
-
choices: {
|
|
509
|
-
title: Record<string, string>;
|
|
510
|
-
value: number;
|
|
511
|
-
meta: Record<string, string>;
|
|
512
|
-
}[];
|
|
513
|
-
meta: Record<string, string>;
|
|
514
|
-
}[];
|
|
515
|
-
processType: {
|
|
516
|
-
name: string;
|
|
517
|
-
properties: Record<string, string>;
|
|
518
|
-
};
|
|
519
|
-
};
|
|
520
|
-
voteCount: string;
|
|
521
|
-
voteOverwrittenCount: string;
|
|
498
|
+
votersCount: string;
|
|
499
|
+
overwrittenVotesCount: string;
|
|
522
500
|
isAcceptingVotes: boolean;
|
|
523
501
|
sequencerStats: {
|
|
524
502
|
stateTransitionCount: number;
|
|
@@ -629,7 +607,8 @@ declare class VocdoniSequencerService extends BaseService {
|
|
|
629
607
|
submitVote(vote: VoteRequest): Promise<void>;
|
|
630
608
|
getVoteStatus(processId: string, voteId: string): Promise<VoteStatusResponse>;
|
|
631
609
|
hasAddressVoted(processId: string, address: string): Promise<boolean>;
|
|
632
|
-
|
|
610
|
+
getAddressWeight(processId: string, address: string): Promise<string>;
|
|
611
|
+
isAddressAbleToVote(processId: string, address: string): Promise<boolean>;
|
|
633
612
|
getInfo(): Promise<InfoResponse>;
|
|
634
613
|
pushMetadata(metadata: ElectionMetadata): Promise<string>;
|
|
635
614
|
getMetadata(hashOrUrl: string): Promise<ElectionMetadata>;
|
|
@@ -891,6 +870,12 @@ type ProcessStateRootUpdatedCallback = EntityCallback<[string, string, bigint]>;
|
|
|
891
870
|
* @param result - The results array
|
|
892
871
|
*/
|
|
893
872
|
type ProcessResultsSetCallback = EntityCallback<[string, string, bigint[]]>;
|
|
873
|
+
/**
|
|
874
|
+
* Callback for when process maxVoters is changed.
|
|
875
|
+
* @param processID - The process ID
|
|
876
|
+
* @param maxVoters - The new maxVoters value
|
|
877
|
+
*/
|
|
878
|
+
type ProcessMaxVotersChangedCallback = EntityCallback<[string, bigint]>;
|
|
894
879
|
|
|
895
880
|
declare enum ProcessStatus {
|
|
896
881
|
READY = 0,
|
|
@@ -912,15 +897,16 @@ declare class ProcessRegistryService extends SmartContractService {
|
|
|
912
897
|
getMaxCensusOrigin(): Promise<bigint>;
|
|
913
898
|
getMaxStatus(): Promise<bigint>;
|
|
914
899
|
getProcessNonce(address: string): Promise<bigint>;
|
|
915
|
-
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] & {
|
|
900
|
+
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] & {
|
|
916
901
|
status: bigint;
|
|
917
902
|
organizationId: string;
|
|
918
903
|
encryptionKey: _vocdoni_davinci_contracts_dist_src_ProcessRegistry.IProcessRegistry.EncryptionKeyStructOutput;
|
|
919
904
|
latestStateRoot: bigint;
|
|
920
905
|
startTime: bigint;
|
|
921
906
|
duration: bigint;
|
|
922
|
-
|
|
923
|
-
|
|
907
|
+
maxVoters: bigint;
|
|
908
|
+
votersCount: bigint;
|
|
909
|
+
overwrittenVotesCount: bigint;
|
|
924
910
|
creationBlock: bigint;
|
|
925
911
|
batchNumber: bigint;
|
|
926
912
|
metadataURI: string;
|
|
@@ -929,7 +915,7 @@ declare class ProcessRegistryService extends SmartContractService {
|
|
|
929
915
|
}>;
|
|
930
916
|
getRVerifier(): Promise<string>;
|
|
931
917
|
getSTVerifier(): Promise<string>;
|
|
932
|
-
newProcess(status: ProcessStatus, startTime: number, duration: number, ballotMode: BallotMode, census: CensusData, metadata: string, encryptionKey: EncryptionKey, initStateRoot: bigint): AsyncGenerator<TxStatusEvent<{
|
|
918
|
+
newProcess(status: ProcessStatus, startTime: number, duration: number, maxVoters: number, ballotMode: BallotMode, census: CensusData, metadata: string, encryptionKey: EncryptionKey, initStateRoot: bigint): AsyncGenerator<TxStatusEvent<{
|
|
933
919
|
success: boolean;
|
|
934
920
|
}>, void, unknown>;
|
|
935
921
|
setProcessStatus(processID: string, newStatus: ProcessStatus): AsyncGenerator<TxStatusEvent<{
|
|
@@ -941,6 +927,9 @@ declare class ProcessRegistryService extends SmartContractService {
|
|
|
941
927
|
setProcessDuration(processID: string, duration: number): AsyncGenerator<TxStatusEvent<{
|
|
942
928
|
success: boolean;
|
|
943
929
|
}>, void, unknown>;
|
|
930
|
+
setProcessMaxVoters(processID: string, maxVoters: number): AsyncGenerator<TxStatusEvent<{
|
|
931
|
+
success: boolean;
|
|
932
|
+
}>, void, unknown>;
|
|
944
933
|
/**
|
|
945
934
|
* Matches the on-chain `submitStateTransition(processId, proof, input)`
|
|
946
935
|
*/
|
|
@@ -964,6 +953,7 @@ declare class ProcessRegistryService extends SmartContractService {
|
|
|
964
953
|
onProcessDurationChanged(cb: ProcessDurationChangedCallback): void;
|
|
965
954
|
onStateRootUpdated(cb: ProcessStateRootUpdatedCallback): void;
|
|
966
955
|
onProcessResultsSet(cb: ProcessResultsSetCallback): void;
|
|
956
|
+
onProcessMaxVotersChanged(cb: ProcessMaxVotersChangedCallback): void;
|
|
967
957
|
removeAllListeners(): void;
|
|
968
958
|
}
|
|
969
959
|
|
|
@@ -1260,6 +1250,11 @@ interface BaseProcessConfig {
|
|
|
1260
1250
|
/** End date/time (Date object, ISO string, or Unix timestamp, cannot be used with duration) */
|
|
1261
1251
|
endDate?: Date | string | number;
|
|
1262
1252
|
};
|
|
1253
|
+
/**
|
|
1254
|
+
* Maximum number of voters allowed for this process (optional, defaults to census size)
|
|
1255
|
+
* This parameter limits how many votes can be cast in the process.
|
|
1256
|
+
*/
|
|
1257
|
+
maxVoters?: number;
|
|
1263
1258
|
}
|
|
1264
1259
|
/**
|
|
1265
1260
|
* Process configuration with metadata fields (title, description, questions)
|
|
@@ -1313,12 +1308,14 @@ interface ProcessInfo extends BaseProcess {
|
|
|
1313
1308
|
duration: number;
|
|
1314
1309
|
/** Time remaining in seconds (0 if ended, negative if not started) */
|
|
1315
1310
|
timeRemaining: number;
|
|
1311
|
+
/** Maximum number of voters allowed */
|
|
1312
|
+
maxVoters: number;
|
|
1316
1313
|
/** Process results (array of BigInt values) */
|
|
1317
1314
|
result: bigint[];
|
|
1318
1315
|
/** Number of votes cast */
|
|
1319
|
-
|
|
1316
|
+
votersCount: number;
|
|
1320
1317
|
/** Number of vote overwrites */
|
|
1321
|
-
|
|
1318
|
+
overwrittenVotesCount: number;
|
|
1322
1319
|
/** Metadata URI */
|
|
1323
1320
|
metadataURI: string;
|
|
1324
1321
|
/** Raw contract data (for advanced users) */
|
|
@@ -1613,6 +1610,56 @@ declare class ProcessOrchestrationService {
|
|
|
1613
1610
|
* ```
|
|
1614
1611
|
*/
|
|
1615
1612
|
resumeProcess(processId: string): Promise<void>;
|
|
1613
|
+
/**
|
|
1614
|
+
* Sets the maximum number of voters for a process.
|
|
1615
|
+
* Returns an async generator that yields transaction status events.
|
|
1616
|
+
*
|
|
1617
|
+
* @param processId - The process ID
|
|
1618
|
+
* @param maxVoters - The new maximum number of voters
|
|
1619
|
+
* @returns AsyncGenerator yielding transaction status events
|
|
1620
|
+
*
|
|
1621
|
+
* @example
|
|
1622
|
+
* ```typescript
|
|
1623
|
+
* const stream = sdk.setProcessMaxVotersStream("0x1234567890abcdef...", 500);
|
|
1624
|
+
*
|
|
1625
|
+
* for await (const event of stream) {
|
|
1626
|
+
* switch (event.status) {
|
|
1627
|
+
* case "pending":
|
|
1628
|
+
* console.log("Transaction pending:", event.hash);
|
|
1629
|
+
* break;
|
|
1630
|
+
* case "completed":
|
|
1631
|
+
* console.log("MaxVoters updated successfully");
|
|
1632
|
+
* break;
|
|
1633
|
+
* case "failed":
|
|
1634
|
+
* console.error("Transaction failed:", event.error);
|
|
1635
|
+
* break;
|
|
1636
|
+
* case "reverted":
|
|
1637
|
+
* console.error("Transaction reverted:", event.reason);
|
|
1638
|
+
* break;
|
|
1639
|
+
* }
|
|
1640
|
+
* }
|
|
1641
|
+
* ```
|
|
1642
|
+
*/
|
|
1643
|
+
setProcessMaxVotersStream(processId: string, maxVoters: number): AsyncGenerator<TxStatusEvent<{
|
|
1644
|
+
success: boolean;
|
|
1645
|
+
}>>;
|
|
1646
|
+
/**
|
|
1647
|
+
* Sets the maximum number of voters for a process.
|
|
1648
|
+
* This is a simplified method that waits for transaction completion.
|
|
1649
|
+
*
|
|
1650
|
+
* For real-time transaction status updates, use setProcessMaxVotersStream() instead.
|
|
1651
|
+
*
|
|
1652
|
+
* @param processId - The process ID
|
|
1653
|
+
* @param maxVoters - The new maximum number of voters
|
|
1654
|
+
* @returns Promise resolving when the maxVoters is updated
|
|
1655
|
+
*
|
|
1656
|
+
* @example
|
|
1657
|
+
* ```typescript
|
|
1658
|
+
* await sdk.setProcessMaxVoters("0x1234567890abcdef...", 500);
|
|
1659
|
+
* console.log("MaxVoters updated successfully");
|
|
1660
|
+
* ```
|
|
1661
|
+
*/
|
|
1662
|
+
setProcessMaxVoters(processId: string, maxVoters: number): Promise<void>;
|
|
1616
1663
|
}
|
|
1617
1664
|
|
|
1618
1665
|
/**
|
|
@@ -2216,22 +2263,41 @@ declare class DavinciSDK {
|
|
|
2216
2263
|
*/
|
|
2217
2264
|
hasAddressVoted(processId: string, address: string): Promise<boolean>;
|
|
2218
2265
|
/**
|
|
2219
|
-
* Check if an address is able to vote in a process
|
|
2266
|
+
* Check if an address is able to vote in a process (i.e., is in the census).
|
|
2220
2267
|
*
|
|
2221
2268
|
* Does NOT require a provider - uses API calls only.
|
|
2222
2269
|
*
|
|
2223
2270
|
* @param processId - The process ID
|
|
2224
2271
|
* @param address - The voter's address
|
|
2225
|
-
* @returns Promise resolving to
|
|
2272
|
+
* @returns Promise resolving to boolean indicating if the address can vote
|
|
2226
2273
|
*
|
|
2227
2274
|
* @example
|
|
2228
2275
|
* ```typescript
|
|
2229
|
-
* const
|
|
2230
|
-
*
|
|
2231
|
-
*
|
|
2276
|
+
* const canVote = await sdk.isAddressAbleToVote(processId, "0x1234567890abcdef...");
|
|
2277
|
+
* if (canVote) {
|
|
2278
|
+
* console.log("This address can vote");
|
|
2279
|
+
* } else {
|
|
2280
|
+
* console.log("This address is not in the census");
|
|
2281
|
+
* }
|
|
2232
2282
|
* ```
|
|
2233
2283
|
*/
|
|
2234
|
-
isAddressAbleToVote(processId: string, address: string): Promise<
|
|
2284
|
+
isAddressAbleToVote(processId: string, address: string): Promise<boolean>;
|
|
2285
|
+
/**
|
|
2286
|
+
* Get the voting weight for an address in a process.
|
|
2287
|
+
*
|
|
2288
|
+
* Does NOT require a provider - uses API calls only.
|
|
2289
|
+
*
|
|
2290
|
+
* @param processId - The process ID
|
|
2291
|
+
* @param address - The voter's address
|
|
2292
|
+
* @returns Promise resolving to the address weight as a string
|
|
2293
|
+
*
|
|
2294
|
+
* @example
|
|
2295
|
+
* ```typescript
|
|
2296
|
+
* const weight = await sdk.getAddressWeight(processId, "0x1234567890abcdef...");
|
|
2297
|
+
* console.log("Address weight:", weight);
|
|
2298
|
+
* ```
|
|
2299
|
+
*/
|
|
2300
|
+
getAddressWeight(processId: string, address: string): Promise<string>;
|
|
2235
2301
|
/**
|
|
2236
2302
|
* Watch vote status changes in real-time using an async generator.
|
|
2237
2303
|
* This method yields each status change as it happens, perfect for showing
|
|
@@ -2533,6 +2599,63 @@ declare class DavinciSDK {
|
|
|
2533
2599
|
* ```
|
|
2534
2600
|
*/
|
|
2535
2601
|
resumeProcess(processId: string): Promise<void>;
|
|
2602
|
+
/**
|
|
2603
|
+
* Sets the maximum number of voters for a process and returns an async generator
|
|
2604
|
+
* that yields transaction status events. This allows you to change the voter limit
|
|
2605
|
+
* after process creation.
|
|
2606
|
+
*
|
|
2607
|
+
* Requires a signer with a provider for blockchain interactions.
|
|
2608
|
+
*
|
|
2609
|
+
* @param processId - The process ID
|
|
2610
|
+
* @param maxVoters - The new maximum number of voters
|
|
2611
|
+
* @returns AsyncGenerator yielding transaction status events
|
|
2612
|
+
* @throws Error if signer does not have a provider
|
|
2613
|
+
*
|
|
2614
|
+
* @example
|
|
2615
|
+
* ```typescript
|
|
2616
|
+
* const stream = sdk.setProcessMaxVotersStream("0x1234567890abcdef...", 500);
|
|
2617
|
+
*
|
|
2618
|
+
* for await (const event of stream) {
|
|
2619
|
+
* switch (event.status) {
|
|
2620
|
+
* case TxStatus.Pending:
|
|
2621
|
+
* console.log("Transaction pending:", event.hash);
|
|
2622
|
+
* break;
|
|
2623
|
+
* case TxStatus.Completed:
|
|
2624
|
+
* console.log("MaxVoters updated successfully");
|
|
2625
|
+
* break;
|
|
2626
|
+
* case TxStatus.Failed:
|
|
2627
|
+
* console.error("Transaction failed:", event.error);
|
|
2628
|
+
* break;
|
|
2629
|
+
* case TxStatus.Reverted:
|
|
2630
|
+
* console.error("Transaction reverted:", event.reason);
|
|
2631
|
+
* break;
|
|
2632
|
+
* }
|
|
2633
|
+
* }
|
|
2634
|
+
* ```
|
|
2635
|
+
*/
|
|
2636
|
+
setProcessMaxVotersStream(processId: string, maxVoters: number): AsyncGenerator<TxStatusEvent<{
|
|
2637
|
+
success: boolean;
|
|
2638
|
+
}>, any, any>;
|
|
2639
|
+
/**
|
|
2640
|
+
* Sets the maximum number of voters for a process.
|
|
2641
|
+
* This is the simplified method that waits for transaction completion.
|
|
2642
|
+
*
|
|
2643
|
+
* For real-time transaction status updates, use setProcessMaxVotersStream() instead.
|
|
2644
|
+
*
|
|
2645
|
+
* Requires a signer with a provider for blockchain interactions.
|
|
2646
|
+
*
|
|
2647
|
+
* @param processId - The process ID
|
|
2648
|
+
* @param maxVoters - The new maximum number of voters
|
|
2649
|
+
* @returns Promise resolving when the maxVoters is updated
|
|
2650
|
+
* @throws Error if signer does not have a provider
|
|
2651
|
+
*
|
|
2652
|
+
* @example
|
|
2653
|
+
* ```typescript
|
|
2654
|
+
* await sdk.setProcessMaxVoters("0x1234567890abcdef...", 500);
|
|
2655
|
+
* console.log("MaxVoters updated successfully");
|
|
2656
|
+
* ```
|
|
2657
|
+
*/
|
|
2658
|
+
setProcessMaxVoters(processId: string, maxVoters: number): Promise<void>;
|
|
2536
2659
|
/**
|
|
2537
2660
|
* Resolve contract address based on configuration priority:
|
|
2538
2661
|
* 1. Custom addresses from user config (if provided)
|
|
@@ -2561,4 +2684,4 @@ declare class DavinciSDK {
|
|
|
2561
2684
|
}
|
|
2562
2685
|
|
|
2563
2686
|
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 };
|
|
2564
|
-
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, ProcessStateRootUpdatedCallback, ProcessStatusChangedCallback, ProofInputs, ProtocolVersion, PublishCensusResponse, QuadraticProperties, Question, SequencerStats, Snapshot, SnapshotsQueryParams, SnapshotsResponse, TxStatusEvent, VocdoniApiServiceConfig, VoteBallot, VoteCiphertext, VoteConfig, VoteOrchestrationConfig, VoteProof, VoteRequest, VoteResult, VoteStatusInfo, VoteStatusResponse, WeightedParticipant, WorkerStats, WorkersResponse };
|
|
2687
|
+
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, ProcessStateRootUpdatedCallback, ProcessStatusChangedCallback, ProofInputs, ProtocolVersion, PublishCensusResponse, QuadraticProperties, Question, SequencerStats, Snapshot, SnapshotsQueryParams, SnapshotsResponse, TxStatusEvent, VocdoniApiServiceConfig, VoteBallot, VoteCiphertext, VoteConfig, VoteOrchestrationConfig, VoteProof, VoteRequest, VoteResult, VoteStatusInfo, VoteStatusResponse, WeightedParticipant, WorkerStats, WorkersResponse };
|