@vocdoni/davinci-sdk 0.0.2 → 0.0.3
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 +251 -42
- package/dist/contracts.d.ts +10 -54
- package/dist/index.d.ts +232 -151
- package/dist/index.js +558 -326
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +552 -320
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +3140 -2908
- package/dist/sequencer.d.ts +2 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -113,7 +113,7 @@ declare enum CensusOrigin {
|
|
|
113
113
|
/** Indicates that the census is provided by a Credential Service Provider (CSP) */
|
|
114
114
|
CensusOriginCSP = 2
|
|
115
115
|
}
|
|
116
|
-
interface CensusParticipant {
|
|
116
|
+
interface CensusParticipant$1 {
|
|
117
117
|
key: string;
|
|
118
118
|
weight?: string;
|
|
119
119
|
}
|
|
@@ -269,8 +269,8 @@ declare class VocdoniCensusService extends BaseService {
|
|
|
269
269
|
*/
|
|
270
270
|
getCensusUri(censusRoot: string): string;
|
|
271
271
|
createCensus(): Promise<string>;
|
|
272
|
-
addParticipants(censusId: string, participants: CensusParticipant[]): Promise<void>;
|
|
273
|
-
getParticipants(censusId: string): Promise<CensusParticipant[]>;
|
|
272
|
+
addParticipants(censusId: string, participants: CensusParticipant$1[]): Promise<void>;
|
|
273
|
+
getParticipants(censusId: string): Promise<CensusParticipant$1[]>;
|
|
274
274
|
getCensusRoot(censusId: string): Promise<string>;
|
|
275
275
|
getCensusSizeById(censusId: string): Promise<number>;
|
|
276
276
|
getCensusSizeByRoot(censusRoot: string): Promise<number>;
|
|
@@ -283,6 +283,168 @@ declare class VocdoniCensusService extends BaseService {
|
|
|
283
283
|
getHealth(): Promise<HealthResponse>;
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
+
/**
|
|
287
|
+
* Census type enumeration
|
|
288
|
+
*/
|
|
289
|
+
declare enum CensusType {
|
|
290
|
+
PLAIN = "plain",
|
|
291
|
+
WEIGHTED = "weighted",
|
|
292
|
+
CSP = "csp"
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Re-export CensusParticipant from types for convenience
|
|
296
|
+
* Extended to make weight required (base type has optional weight)
|
|
297
|
+
*/
|
|
298
|
+
interface CensusParticipant extends CensusParticipant$1 {
|
|
299
|
+
weight: string;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Abstract base class for all census types
|
|
303
|
+
*/
|
|
304
|
+
declare abstract class Census {
|
|
305
|
+
protected _censusId: string | null;
|
|
306
|
+
protected _censusRoot: string | null;
|
|
307
|
+
protected _censusURI: string | null;
|
|
308
|
+
protected _type: CensusType;
|
|
309
|
+
protected _size: number | null;
|
|
310
|
+
constructor(type: CensusType);
|
|
311
|
+
get censusId(): string | null;
|
|
312
|
+
get censusRoot(): string | null;
|
|
313
|
+
get censusURI(): string | null;
|
|
314
|
+
get type(): CensusType;
|
|
315
|
+
get size(): number | null;
|
|
316
|
+
get isPublished(): boolean;
|
|
317
|
+
/**
|
|
318
|
+
* Convert CensusType to CensusOrigin enum for API compatibility
|
|
319
|
+
*/
|
|
320
|
+
get censusOrigin(): CensusOrigin;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Plain census where all participants have equal voting power (weight=1)
|
|
325
|
+
* Simpler API - just add addresses without specifying weights
|
|
326
|
+
*/
|
|
327
|
+
declare class PlainCensus extends Census {
|
|
328
|
+
private _participants;
|
|
329
|
+
constructor();
|
|
330
|
+
/**
|
|
331
|
+
* Add participant(s) with automatic weight=1
|
|
332
|
+
* @param addresses - Single address or array of addresses
|
|
333
|
+
*/
|
|
334
|
+
add(addresses: string | string[]): void;
|
|
335
|
+
/**
|
|
336
|
+
* Remove participant by address
|
|
337
|
+
*/
|
|
338
|
+
remove(address: string): void;
|
|
339
|
+
/**
|
|
340
|
+
* Get all participants as CensusParticipant array (for API)
|
|
341
|
+
* All participants have weight="1"
|
|
342
|
+
*/
|
|
343
|
+
get participants(): CensusParticipant[];
|
|
344
|
+
/**
|
|
345
|
+
* Get addresses only
|
|
346
|
+
*/
|
|
347
|
+
get addresses(): string[];
|
|
348
|
+
private validateAddress;
|
|
349
|
+
/**
|
|
350
|
+
* Internal method called after publishing
|
|
351
|
+
* @internal
|
|
352
|
+
*/
|
|
353
|
+
_setPublishedData(root: string, uri: string, size: number, censusId?: string): void;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Participant with flexible weight type for WeightedCensus
|
|
358
|
+
* Weight can be string, number, or bigint - will be normalized to string internally
|
|
359
|
+
*/
|
|
360
|
+
interface WeightedParticipant {
|
|
361
|
+
key: string;
|
|
362
|
+
weight: string | number | bigint;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Weighted census where participants can have different voting power
|
|
366
|
+
* Requires specifying weight for each participant
|
|
367
|
+
*/
|
|
368
|
+
declare class WeightedCensus extends Census {
|
|
369
|
+
private _participants;
|
|
370
|
+
constructor();
|
|
371
|
+
/**
|
|
372
|
+
* Add participant(s) with custom weights
|
|
373
|
+
* Weight can be provided as string, number, or bigint - will be converted to string internally
|
|
374
|
+
* @param participant - Single participant or array of participants with custom weights
|
|
375
|
+
*/
|
|
376
|
+
add(participant: WeightedParticipant | WeightedParticipant[]): void;
|
|
377
|
+
/**
|
|
378
|
+
* Remove participant by address
|
|
379
|
+
*/
|
|
380
|
+
remove(address: string): void;
|
|
381
|
+
/**
|
|
382
|
+
* Get all participants as CensusParticipant array
|
|
383
|
+
*/
|
|
384
|
+
get participants(): CensusParticipant[];
|
|
385
|
+
/**
|
|
386
|
+
* Get participant addresses
|
|
387
|
+
*/
|
|
388
|
+
get addresses(): string[];
|
|
389
|
+
/**
|
|
390
|
+
* Get weight for specific address
|
|
391
|
+
*/
|
|
392
|
+
getWeight(address: string): string | undefined;
|
|
393
|
+
/**
|
|
394
|
+
* Normalizes weight from string, number, or bigint to string
|
|
395
|
+
*/
|
|
396
|
+
private normalizeWeight;
|
|
397
|
+
private validateParticipant;
|
|
398
|
+
/**
|
|
399
|
+
* Internal method called after publishing
|
|
400
|
+
* @internal
|
|
401
|
+
*/
|
|
402
|
+
_setPublishedData(root: string, uri: string, size: number, censusId?: string): void;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* CSP (Certificate Service Provider) census
|
|
407
|
+
* Uses a public key and CSP server URI instead of a participant list
|
|
408
|
+
*/
|
|
409
|
+
declare class CspCensus extends Census {
|
|
410
|
+
private _publicKey;
|
|
411
|
+
private _cspURI;
|
|
412
|
+
constructor(publicKey: string, cspURI: string, size: number);
|
|
413
|
+
get publicKey(): string;
|
|
414
|
+
get cspURI(): string;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Published census - represents a census that has already been published
|
|
419
|
+
* Use this when you have the census root, URI, and size from a previous publication
|
|
420
|
+
*/
|
|
421
|
+
declare class PublishedCensus extends Census {
|
|
422
|
+
constructor(type: CensusType, root: string, uri: string, size: number);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Orchestrates census creation and publishing
|
|
427
|
+
*/
|
|
428
|
+
declare class CensusOrchestrator {
|
|
429
|
+
private censusService;
|
|
430
|
+
constructor(censusService: VocdoniCensusService);
|
|
431
|
+
/**
|
|
432
|
+
* Publishes a PlainCensus or WeightedCensus
|
|
433
|
+
* Creates a working census, adds participants, and publishes it
|
|
434
|
+
*/
|
|
435
|
+
publish(census: PlainCensus | WeightedCensus): Promise<void>;
|
|
436
|
+
/**
|
|
437
|
+
* Gets census data for process creation
|
|
438
|
+
* Throws if census is not published
|
|
439
|
+
*/
|
|
440
|
+
getCensusData(census: Census): {
|
|
441
|
+
type: CensusOrigin;
|
|
442
|
+
root: string;
|
|
443
|
+
uri: string;
|
|
444
|
+
size: number;
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
|
|
286
448
|
interface BallotMode {
|
|
287
449
|
numFields: number;
|
|
288
450
|
maxValue: string;
|
|
@@ -293,7 +455,7 @@ interface BallotMode {
|
|
|
293
455
|
maxValueSum: string;
|
|
294
456
|
minValueSum: string;
|
|
295
457
|
}
|
|
296
|
-
interface
|
|
458
|
+
interface CensusData {
|
|
297
459
|
censusOrigin: CensusOrigin;
|
|
298
460
|
maxVotes: string;
|
|
299
461
|
censusRoot: string;
|
|
@@ -332,7 +494,7 @@ interface GetProcessResponse {
|
|
|
332
494
|
duration: number;
|
|
333
495
|
metadataURI: string;
|
|
334
496
|
ballotMode: BallotMode;
|
|
335
|
-
census:
|
|
497
|
+
census: CensusData;
|
|
336
498
|
metadata: {
|
|
337
499
|
title: Record<string, string>;
|
|
338
500
|
description: Record<string, string>;
|
|
@@ -481,118 +643,6 @@ declare class VocdoniApiService {
|
|
|
481
643
|
constructor(config: VocdoniApiServiceConfig);
|
|
482
644
|
}
|
|
483
645
|
|
|
484
|
-
/**
|
|
485
|
-
* Supported environment types
|
|
486
|
-
*/
|
|
487
|
-
type Environment = 'dev' | 'stg' | 'prod';
|
|
488
|
-
/**
|
|
489
|
-
* URL configuration for each service
|
|
490
|
-
*/
|
|
491
|
-
interface ServiceUrls {
|
|
492
|
-
/** Sequencer API URL */
|
|
493
|
-
sequencer: string;
|
|
494
|
-
/** Census API URL */
|
|
495
|
-
census: string;
|
|
496
|
-
}
|
|
497
|
-
/**
|
|
498
|
-
* Chain configuration for each environment
|
|
499
|
-
*/
|
|
500
|
-
interface ChainConfig {
|
|
501
|
-
/** Chain name/ID */
|
|
502
|
-
chain: 'sepolia' | 'mainnet';
|
|
503
|
-
}
|
|
504
|
-
/**
|
|
505
|
-
* Environment-based URL configuration
|
|
506
|
-
*/
|
|
507
|
-
interface EnvironmentConfig {
|
|
508
|
-
dev: ServiceUrls & ChainConfig;
|
|
509
|
-
stg: ServiceUrls & ChainConfig;
|
|
510
|
-
prod: ServiceUrls & ChainConfig;
|
|
511
|
-
}
|
|
512
|
-
/**
|
|
513
|
-
* Configuration options for environment setup
|
|
514
|
-
*/
|
|
515
|
-
interface EnvironmentOptions {
|
|
516
|
-
/** Environment to use (defaults to 'prod') */
|
|
517
|
-
environment?: Environment;
|
|
518
|
-
/** Custom URLs to override defaults */
|
|
519
|
-
customUrls?: Partial<ServiceUrls>;
|
|
520
|
-
/** Custom chain to override default */
|
|
521
|
-
customChain?: ChainConfig['chain'];
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
/**
|
|
525
|
-
* Default URL and chain configuration for all environments
|
|
526
|
-
*/
|
|
527
|
-
declare const DEFAULT_ENVIRONMENT_URLS: EnvironmentConfig;
|
|
528
|
-
/**
|
|
529
|
-
* Get URLs and chain configuration for a specific environment
|
|
530
|
-
*/
|
|
531
|
-
declare function getEnvironmentConfig(environment: Environment): ServiceUrls & ChainConfig;
|
|
532
|
-
/**
|
|
533
|
-
* Get only URLs for a specific environment
|
|
534
|
-
*/
|
|
535
|
-
declare function getEnvironmentUrls(environment: Environment): ServiceUrls;
|
|
536
|
-
/**
|
|
537
|
-
* Get chain configuration for a specific environment
|
|
538
|
-
*/
|
|
539
|
-
declare function getEnvironmentChain(environment: Environment): ChainConfig['chain'];
|
|
540
|
-
/**
|
|
541
|
-
* Resolve URLs and chain based on environment and custom overrides
|
|
542
|
-
*/
|
|
543
|
-
declare function resolveConfiguration(options?: EnvironmentOptions): ServiceUrls & ChainConfig;
|
|
544
|
-
/**
|
|
545
|
-
* Resolve only URLs based on environment and custom overrides
|
|
546
|
-
*/
|
|
547
|
-
declare function resolveUrls(options?: EnvironmentOptions): ServiceUrls;
|
|
548
|
-
|
|
549
|
-
/**
|
|
550
|
-
* Interface defining the structure of deployed contract addresses across different networks.
|
|
551
|
-
* Each contract has addresses for both Sepolia testnet and Ethereum mainnet.
|
|
552
|
-
*/
|
|
553
|
-
interface DeployedAddresses {
|
|
554
|
-
/** Process Registry contract addresses */
|
|
555
|
-
processRegistry: {
|
|
556
|
-
/** Sepolia testnet address */
|
|
557
|
-
sepolia: string;
|
|
558
|
-
/** Ethereum mainnet address */
|
|
559
|
-
mainnet: string;
|
|
560
|
-
};
|
|
561
|
-
/** Organization Registry contract addresses */
|
|
562
|
-
organizationRegistry: {
|
|
563
|
-
/** Sepolia testnet address */
|
|
564
|
-
sepolia: string;
|
|
565
|
-
/** Ethereum mainnet address */
|
|
566
|
-
mainnet: string;
|
|
567
|
-
};
|
|
568
|
-
/** State Transition Verifier contract addresses */
|
|
569
|
-
stateTransitionVerifierGroth16: {
|
|
570
|
-
/** Sepolia testnet address */
|
|
571
|
-
sepolia: string;
|
|
572
|
-
/** Ethereum mainnet address */
|
|
573
|
-
mainnet: string;
|
|
574
|
-
};
|
|
575
|
-
/** Results Verifier contract addresses */
|
|
576
|
-
resultsVerifierGroth16: {
|
|
577
|
-
/** Sepolia testnet address */
|
|
578
|
-
sepolia: string;
|
|
579
|
-
/** Ethereum mainnet address */
|
|
580
|
-
mainnet: string;
|
|
581
|
-
};
|
|
582
|
-
/** Sequencer Registry contract addresses */
|
|
583
|
-
sequencerRegistry: {
|
|
584
|
-
/** Sepolia testnet address */
|
|
585
|
-
sepolia: string;
|
|
586
|
-
/** Ethereum mainnet address */
|
|
587
|
-
mainnet: string;
|
|
588
|
-
};
|
|
589
|
-
}
|
|
590
|
-
/**
|
|
591
|
-
* Deployed contract addresses imported from @vocdoni/davinci-contracts package.
|
|
592
|
-
* These addresses are used to interact with the Vocdoni voting protocol contracts
|
|
593
|
-
* on different networks.
|
|
594
|
-
*/
|
|
595
|
-
declare const deployedAddresses: DeployedAddresses;
|
|
596
646
|
/**
|
|
597
647
|
* Enum representing the possible states of a transaction during its lifecycle.
|
|
598
648
|
* Used to track and report transaction status in the event stream.
|
|
@@ -729,10 +779,13 @@ declare abstract class SmartContractService {
|
|
|
729
779
|
*/
|
|
730
780
|
protected setupEventListener<Args extends any[]>(contract: BaseContract, eventFilter: ContractEventName | EventFilter, callback: (...args: Args) => void): Promise<void>;
|
|
731
781
|
/**
|
|
732
|
-
* Checks if an error indicates that the RPC method is unsupported
|
|
782
|
+
* Checks if an error indicates that the RPC method is unsupported or filter operations are not working.
|
|
783
|
+
* This includes:
|
|
784
|
+
* - Method not found (-32601): RPC doesn't support eth_newFilter
|
|
785
|
+
* - Filter not found (-32000): RPC doesn't properly maintain filters
|
|
733
786
|
*
|
|
734
787
|
* @param error - The error to check
|
|
735
|
-
* @returns true if the error indicates unsupported
|
|
788
|
+
* @returns true if the error indicates unsupported or broken filter functionality
|
|
736
789
|
*/
|
|
737
790
|
private isUnsupportedMethodError;
|
|
738
791
|
/**
|
|
@@ -872,13 +925,13 @@ declare class ProcessRegistryService extends SmartContractService {
|
|
|
872
925
|
}>;
|
|
873
926
|
getRVerifier(): Promise<string>;
|
|
874
927
|
getSTVerifier(): Promise<string>;
|
|
875
|
-
newProcess(status: ProcessStatus, startTime: number, duration: number, ballotMode: BallotMode, census:
|
|
928
|
+
newProcess(status: ProcessStatus, startTime: number, duration: number, ballotMode: BallotMode, census: CensusData, metadata: string, encryptionKey: EncryptionKey, initStateRoot: bigint): AsyncGenerator<TxStatusEvent<{
|
|
876
929
|
success: boolean;
|
|
877
930
|
}>, void, unknown>;
|
|
878
931
|
setProcessStatus(processID: string, newStatus: ProcessStatus): AsyncGenerator<TxStatusEvent<{
|
|
879
932
|
success: boolean;
|
|
880
933
|
}>, void, unknown>;
|
|
881
|
-
setProcessCensus(processID: string, census:
|
|
934
|
+
setProcessCensus(processID: string, census: CensusData): AsyncGenerator<TxStatusEvent<{
|
|
882
935
|
success: boolean;
|
|
883
936
|
}>, void, unknown>;
|
|
884
937
|
setProcessDuration(processID: string, duration: number): AsyncGenerator<TxStatusEvent<{
|
|
@@ -1171,7 +1224,22 @@ interface BaseProcess {
|
|
|
1171
1224
|
/**
|
|
1172
1225
|
* Configuration for creating a process
|
|
1173
1226
|
*/
|
|
1174
|
-
interface ProcessConfig extends BaseProcess {
|
|
1227
|
+
interface ProcessConfig extends Omit<BaseProcess, 'census'> {
|
|
1228
|
+
/**
|
|
1229
|
+
* Census - either a Census object (PlainCensus, WeightedCensus, CspCensus, PublishedCensus)
|
|
1230
|
+
* or manual configuration. If a Census object is provided and not published, it will be
|
|
1231
|
+
* automatically published.
|
|
1232
|
+
*/
|
|
1233
|
+
census: Census | {
|
|
1234
|
+
/** Census type - MerkleTree or CSP */
|
|
1235
|
+
type: CensusOrigin;
|
|
1236
|
+
/** Census root */
|
|
1237
|
+
root: string;
|
|
1238
|
+
/** Census size */
|
|
1239
|
+
size: number;
|
|
1240
|
+
/** Census URI */
|
|
1241
|
+
uri: string;
|
|
1242
|
+
};
|
|
1175
1243
|
/** Process timing - use either duration-based or date-based configuration */
|
|
1176
1244
|
timing: {
|
|
1177
1245
|
/** Start date/time (Date object, ISO string, or Unix timestamp, default: now + 60 seconds) */
|
|
@@ -1229,7 +1297,13 @@ declare class ProcessOrchestrationService {
|
|
|
1229
1297
|
private organizationRegistry;
|
|
1230
1298
|
private getCrypto;
|
|
1231
1299
|
private signer;
|
|
1300
|
+
private censusOrchestrator;
|
|
1232
1301
|
constructor(processRegistry: ProcessRegistryService, apiService: VocdoniApiService, organizationRegistry: OrganizationRegistryService, getCrypto: () => Promise<DavinciCrypto>, signer: Signer);
|
|
1302
|
+
/**
|
|
1303
|
+
* Handles census - auto-publishes if needed and returns census config
|
|
1304
|
+
* @private
|
|
1305
|
+
*/
|
|
1306
|
+
private handleCensus;
|
|
1233
1307
|
/**
|
|
1234
1308
|
* Gets user-friendly process information by transforming raw contract data
|
|
1235
1309
|
* @param processId - The process ID to fetch
|
|
@@ -1541,6 +1615,15 @@ interface VoteStatusInfo {
|
|
|
1541
1615
|
/** The process ID */
|
|
1542
1616
|
processId: string;
|
|
1543
1617
|
}
|
|
1618
|
+
/**
|
|
1619
|
+
* Configuration options for VoteOrchestrationService
|
|
1620
|
+
*/
|
|
1621
|
+
interface VoteOrchestrationConfig {
|
|
1622
|
+
/** Whether to verify downloaded circuit files match expected hashes (default: true) */
|
|
1623
|
+
verifyCircuitFiles?: boolean;
|
|
1624
|
+
/** Whether to verify the generated proof is valid before submission (default: true) */
|
|
1625
|
+
verifyProof?: boolean;
|
|
1626
|
+
}
|
|
1544
1627
|
/**
|
|
1545
1628
|
* Service that orchestrates the complete voting workflow
|
|
1546
1629
|
* Handles all the complex cryptographic operations and API calls internally
|
|
@@ -1550,7 +1633,9 @@ declare class VoteOrchestrationService {
|
|
|
1550
1633
|
private getCrypto;
|
|
1551
1634
|
private signer;
|
|
1552
1635
|
private censusProviders;
|
|
1553
|
-
|
|
1636
|
+
private readonly verifyCircuitFiles;
|
|
1637
|
+
private readonly verifyProof;
|
|
1638
|
+
constructor(apiService: VocdoniApiService, getCrypto: () => Promise<DavinciCrypto>, signer: Signer, censusProviders?: CensusProviders, config?: VoteOrchestrationConfig);
|
|
1554
1639
|
/**
|
|
1555
1640
|
* Submit a vote with simplified configuration
|
|
1556
1641
|
* This method handles all the complex orchestration internally:
|
|
@@ -1754,43 +1839,42 @@ interface DavinciSDKConfig {
|
|
|
1754
1839
|
* - For process/organization operations: Must be connected to a provider
|
|
1755
1840
|
*/
|
|
1756
1841
|
signer: Signer;
|
|
1757
|
-
/**
|
|
1758
|
-
|
|
1759
|
-
/**
|
|
1760
|
-
sequencerUrl?: string;
|
|
1761
|
-
/** Census API URL for census management (optional, defaults based on environment) */
|
|
1842
|
+
/** Sequencer API URL for Vocdoni services (required) */
|
|
1843
|
+
sequencerUrl: string;
|
|
1844
|
+
/** Census API URL for census management (optional, only needed when creating censuses from scratch) */
|
|
1762
1845
|
censusUrl?: string;
|
|
1763
|
-
/**
|
|
1764
|
-
|
|
1765
|
-
/** Custom contract addresses (optional, uses defaults if not provided) */
|
|
1766
|
-
contractAddresses?: {
|
|
1846
|
+
/** Custom contract addresses (optional, fetched from sequencer if not provided) */
|
|
1847
|
+
addresses?: {
|
|
1767
1848
|
processRegistry?: string;
|
|
1768
1849
|
organizationRegistry?: string;
|
|
1769
1850
|
stateTransitionVerifier?: string;
|
|
1770
1851
|
resultsVerifier?: string;
|
|
1771
1852
|
sequencerRegistry?: string;
|
|
1772
1853
|
};
|
|
1773
|
-
/** Whether to force using contract addresses from sequencer info (optional, defaults to false) */
|
|
1774
|
-
useSequencerAddresses?: boolean;
|
|
1775
1854
|
/** Custom census proof providers (optional) */
|
|
1776
1855
|
censusProviders?: CensusProviders;
|
|
1856
|
+
/** Whether to verify downloaded circuit files match expected hashes (optional, defaults to true) */
|
|
1857
|
+
verifyCircuitFiles?: boolean;
|
|
1858
|
+
/** Whether to verify the generated proof is valid before submission (optional, defaults to true) */
|
|
1859
|
+
verifyProof?: boolean;
|
|
1777
1860
|
}
|
|
1778
1861
|
/**
|
|
1779
|
-
* Internal configuration interface
|
|
1862
|
+
* Internal configuration interface
|
|
1780
1863
|
*/
|
|
1781
1864
|
interface InternalDavinciSDKConfig {
|
|
1782
1865
|
signer: Signer;
|
|
1783
1866
|
sequencerUrl: string;
|
|
1784
|
-
censusUrl
|
|
1785
|
-
|
|
1786
|
-
contractAddresses: {
|
|
1867
|
+
censusUrl?: string;
|
|
1868
|
+
customAddresses: {
|
|
1787
1869
|
processRegistry?: string;
|
|
1788
1870
|
organizationRegistry?: string;
|
|
1789
1871
|
stateTransitionVerifier?: string;
|
|
1790
1872
|
resultsVerifier?: string;
|
|
1791
1873
|
sequencerRegistry?: string;
|
|
1792
1874
|
};
|
|
1793
|
-
|
|
1875
|
+
fetchAddressesFromSequencer: boolean;
|
|
1876
|
+
verifyCircuitFiles: boolean;
|
|
1877
|
+
verifyProof: boolean;
|
|
1794
1878
|
}
|
|
1795
1879
|
/**
|
|
1796
1880
|
* Simplified SDK class that encapsulates all Vocdoni DaVinci functionality
|
|
@@ -2023,6 +2107,7 @@ declare class DavinciSDK {
|
|
|
2023
2107
|
* This is the ultra-easy method for end users that handles all the complex voting workflow internally.
|
|
2024
2108
|
*
|
|
2025
2109
|
* Does NOT require a provider - can be used with a bare Wallet for signing only.
|
|
2110
|
+
* IMPORTANT: Requires censusUrl to be configured in the SDK for fetching census proofs (unless using custom census providers).
|
|
2026
2111
|
*
|
|
2027
2112
|
* The method automatically:
|
|
2028
2113
|
* - Fetches process information and validates voting is allowed
|
|
@@ -2032,6 +2117,7 @@ declare class DavinciSDK {
|
|
|
2032
2117
|
*
|
|
2033
2118
|
* @param config - Simplified vote configuration
|
|
2034
2119
|
* @returns Promise resolving to vote submission result
|
|
2120
|
+
* @throws Error if censusUrl is not configured (unless using custom census providers)
|
|
2035
2121
|
*
|
|
2036
2122
|
* @example
|
|
2037
2123
|
* ```typescript
|
|
@@ -2395,20 +2481,15 @@ declare class DavinciSDK {
|
|
|
2395
2481
|
resumeProcess(processId: string): Promise<void>;
|
|
2396
2482
|
/**
|
|
2397
2483
|
* Resolve contract address based on configuration priority:
|
|
2398
|
-
* 1.
|
|
2399
|
-
* 2.
|
|
2400
|
-
* 3. Default deployed addresses from npm package
|
|
2484
|
+
* 1. Custom addresses from user config (if provided)
|
|
2485
|
+
* 2. Addresses from sequencer (fetched during init if no custom addresses provided)
|
|
2401
2486
|
*/
|
|
2402
2487
|
private resolveContractAddress;
|
|
2403
2488
|
/**
|
|
2404
|
-
*
|
|
2405
|
-
|
|
2406
|
-
private getDefaultContractAddress;
|
|
2407
|
-
/**
|
|
2408
|
-
* Update contract addresses from sequencer info if useSequencerAddresses is enabled
|
|
2409
|
-
* Sequencer addresses have priority over user-provided addresses
|
|
2489
|
+
* Fetch contract addresses from sequencer info
|
|
2490
|
+
* This is called during init() if custom addresses are not provided
|
|
2410
2491
|
*/
|
|
2411
|
-
private
|
|
2492
|
+
private fetchContractAddressesFromSequencer;
|
|
2412
2493
|
/**
|
|
2413
2494
|
* Get the current configuration
|
|
2414
2495
|
*/
|
|
@@ -2425,5 +2506,5 @@ declare class DavinciSDK {
|
|
|
2425
2506
|
private ensureProvider;
|
|
2426
2507
|
}
|
|
2427
2508
|
|
|
2428
|
-
export { BaseService, CensusOrigin, CircomProof, ContractServiceError,
|
|
2429
|
-
export type { AbstainProperties, AnyJson, ApiError, ApprovalProperties, BallotMode, BaseCensusProof, BaseProcess, BudgetProperties, CSPCensusProof, CSPCensusProofProvider, CSPSignOutput,
|
|
2509
|
+
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 };
|
|
2510
|
+
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, ProcessCensusUpdatedCallback, ProcessConfig, ProcessCreatedCallback, ProcessCreationResult, ProcessDurationChangedCallback, ProcessInfo, 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 };
|