@vocdoni/davinci-sdk 0.0.6 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -193,18 +193,20 @@
193
193
  }
194
194
 
195
195
  var CensusOrigin = /* @__PURE__ */ ((CensusOrigin2) => {
196
- CensusOrigin2[CensusOrigin2["CensusOriginMerkleTree"] = 1] = "CensusOriginMerkleTree";
197
- CensusOrigin2[CensusOrigin2["CensusOriginCSP"] = 2] = "CensusOriginCSP";
196
+ CensusOrigin2[CensusOrigin2["OffchainStatic"] = 1] = "OffchainStatic";
197
+ CensusOrigin2[CensusOrigin2["OffchainDynamic"] = 2] = "OffchainDynamic";
198
+ CensusOrigin2[CensusOrigin2["Onchain"] = 3] = "Onchain";
199
+ CensusOrigin2[CensusOrigin2["CSP"] = 4] = "CSP";
198
200
  return CensusOrigin2;
199
201
  })(CensusOrigin || {});
200
202
  function isBaseCensusProof(proof) {
201
203
  return !!proof && typeof proof.root === "string" && typeof proof.address === "string" && typeof proof.censusOrigin === "number" && Object.values(CensusOrigin).includes(proof.censusOrigin);
202
204
  }
203
205
  function isMerkleCensusProof(proof) {
204
- return isBaseCensusProof(proof) && proof.censusOrigin === 1 /* CensusOriginMerkleTree */ && typeof proof.weight === "string" && typeof proof.value === "string" && typeof proof.siblings === "string";
206
+ return isBaseCensusProof(proof) && (proof.censusOrigin === 1 /* OffchainStatic */ || proof.censusOrigin === 2 /* OffchainDynamic */ || proof.censusOrigin === 3 /* Onchain */) && typeof proof.weight === "string" && typeof proof.value === "string" && typeof proof.siblings === "string";
205
207
  }
206
208
  function isCSPCensusProof(proof) {
207
- return isBaseCensusProof(proof) && proof.censusOrigin === 2 /* CensusOriginCSP */ && typeof proof.weight === "string" && typeof proof.processId === "string" && typeof proof.publicKey === "string" && typeof proof.signature === "string";
209
+ return isBaseCensusProof(proof) && proof.censusOrigin === 4 /* CSP */ && typeof proof.weight === "string" && typeof proof.processId === "string" && typeof proof.publicKey === "string" && typeof proof.signature === "string";
208
210
  }
209
211
  function assertMerkleCensusProof(proof) {
210
212
  if (!isMerkleCensusProof(proof)) {
@@ -217,19 +219,12 @@
217
219
  }
218
220
  }
219
221
 
220
- var CensusType = /* @__PURE__ */ ((CensusType2) => {
221
- CensusType2["PLAIN"] = "plain";
222
- CensusType2["WEIGHTED"] = "weighted";
223
- CensusType2["CSP"] = "csp";
224
- return CensusType2;
225
- })(CensusType || {});
226
222
  class Census {
227
- constructor(type) {
223
+ constructor(censusOrigin) {
228
224
  this._censusId = null;
229
225
  this._censusRoot = null;
230
226
  this._censusURI = null;
231
- this._size = null;
232
- this._type = type;
227
+ this._censusOrigin = censusOrigin;
233
228
  }
234
229
  get censusId() {
235
230
  return this._censusId;
@@ -240,106 +235,50 @@
240
235
  get censusURI() {
241
236
  return this._censusURI;
242
237
  }
243
- get type() {
244
- return this._type;
245
- }
246
- get size() {
247
- return this._size;
248
- }
249
238
  get isPublished() {
250
239
  return this._censusRoot !== null && this._censusURI !== null;
251
240
  }
252
241
  /**
253
- * Convert CensusType to CensusOrigin enum for API compatibility
242
+ * Get the census origin (OffchainStatic, OffchainDynamic, Onchain, or CSP)
254
243
  */
255
244
  get censusOrigin() {
256
- switch (this._type) {
257
- case "plain" /* PLAIN */:
258
- case "weighted" /* WEIGHTED */:
259
- return CensusOrigin.CensusOriginMerkleTree;
260
- case "csp" /* CSP */:
261
- return CensusOrigin.CensusOriginCSP;
262
- default:
263
- throw new Error(`Unknown census type: ${this._type}`);
264
- }
265
- }
266
- }
267
-
268
- class PlainCensus extends Census {
269
- constructor() {
270
- super(CensusType.PLAIN);
271
- this._participants = /* @__PURE__ */ new Set();
272
- }
273
- /**
274
- * Add participant(s) with automatic weight=1
275
- * @param addresses - Single address or array of addresses
276
- */
277
- add(addresses) {
278
- const toAdd = Array.isArray(addresses) ? addresses : [addresses];
279
- for (const address of toAdd) {
280
- this.validateAddress(address);
281
- this._participants.add(address.toLowerCase());
282
- }
283
- }
284
- /**
285
- * Remove participant by address
286
- */
287
- remove(address) {
288
- this._participants.delete(address.toLowerCase());
289
- }
290
- /**
291
- * Get all participants as CensusParticipant array (for API)
292
- * All participants have weight="1"
293
- */
294
- get participants() {
295
- return Array.from(this._participants).map((key) => ({
296
- key,
297
- weight: "1"
298
- // Everyone has weight=1 in plain census
299
- }));
245
+ return this._censusOrigin;
300
246
  }
301
247
  /**
302
- * Get addresses only
248
+ * Check if this census requires publishing via the Census API
249
+ * Merkle censuses (OffchainStatic, OffchainDynamic) need to be published
250
+ * Onchain and CSP censuses are ready immediately upon construction
303
251
  */
304
- get addresses() {
305
- return Array.from(this._participants);
306
- }
307
- validateAddress(address) {
308
- if (!address || typeof address !== "string") {
309
- throw new Error("Address is required and must be a string");
310
- }
311
- if (!/^(0x)?[0-9a-fA-F]{40}$/i.test(address)) {
312
- throw new Error(`Invalid Ethereum address format: ${address}`);
313
- }
314
- }
315
- /**
316
- * Internal method called after publishing
317
- * @internal
318
- */
319
- _setPublishedData(root, uri, size, censusId) {
320
- this._censusRoot = root;
321
- this._censusURI = uri;
322
- this._size = size;
323
- if (censusId) this._censusId = censusId;
252
+ get requiresPublishing() {
253
+ return this._censusOrigin === CensusOrigin.OffchainStatic || this._censusOrigin === CensusOrigin.OffchainDynamic;
324
254
  }
325
255
  }
326
256
 
327
- class WeightedCensus extends Census {
328
- constructor() {
329
- super(CensusType.WEIGHTED);
257
+ class MerkleCensus extends Census {
258
+ constructor(censusOrigin) {
259
+ super(censusOrigin);
330
260
  this._participants = /* @__PURE__ */ new Map();
331
261
  }
332
262
  /**
333
- * Add participant(s) with custom weights
334
- * Weight can be provided as string, number, or bigint - will be converted to string internally
335
- * @param participant - Single participant or array of participants with custom weights
263
+ * Add participant(s) - supports both plain addresses and weighted participants
264
+ * @param data - Can be:
265
+ * - string: single address (weight=1)
266
+ * - string[]: array of addresses (weight=1 for all)
267
+ * - {key: string, weight: string|number|bigint}: single weighted participant
268
+ * - Array of weighted participants
336
269
  */
337
- add(participant) {
338
- const toAdd = Array.isArray(participant) ? participant : [participant];
339
- for (const p of toAdd) {
340
- this.validateParticipant(p);
341
- const weightString = this.normalizeWeight(p.weight);
342
- this._participants.set(p.key.toLowerCase(), weightString);
270
+ add(data) {
271
+ if (typeof data === "string") {
272
+ this.addAddress(data, "1");
273
+ } else if (Array.isArray(data)) {
274
+ if (data.length === 0) return;
275
+ if (typeof data[0] === "string") {
276
+ data.forEach((addr) => this.addAddress(addr, "1"));
277
+ } else {
278
+ data.forEach((p) => this.addParticipant(p));
279
+ }
280
+ } else {
281
+ this.addParticipant(data);
343
282
  }
344
283
  }
345
284
  /**
@@ -369,6 +308,21 @@
369
308
  getWeight(address) {
370
309
  return this._participants.get(address.toLowerCase());
371
310
  }
311
+ /**
312
+ * Internal method to add a plain address with a given weight
313
+ */
314
+ addAddress(address, weight) {
315
+ this.validateAddress(address);
316
+ this._participants.set(address.toLowerCase(), weight);
317
+ }
318
+ /**
319
+ * Internal method to add a weighted participant
320
+ */
321
+ addParticipant(participant) {
322
+ this.validateAddress(participant.key);
323
+ const weight = this.normalizeWeight(participant.weight);
324
+ this._participants.set(participant.key.toLowerCase(), weight);
325
+ }
372
326
  /**
373
327
  * Normalizes weight from string, number, or bigint to string
374
328
  */
@@ -393,32 +347,63 @@
393
347
  }
394
348
  throw new Error(`Invalid weight type. Must be string, number, or bigint.`);
395
349
  }
396
- validateParticipant(participant) {
397
- if (!participant.key || typeof participant.key !== "string") {
398
- throw new Error("Participant key (address) is required");
399
- }
400
- if (!/^(0x)?[0-9a-fA-F]{40}$/i.test(participant.key)) {
401
- throw new Error(`Invalid Ethereum address format: ${participant.key}`);
350
+ /**
351
+ * Validates Ethereum address format
352
+ */
353
+ validateAddress(address) {
354
+ if (!address || typeof address !== "string") {
355
+ throw new Error("Address is required and must be a string");
402
356
  }
403
- if (participant.weight === void 0 || participant.weight === null) {
404
- throw new Error("Participant weight is required");
357
+ if (!/^(0x)?[0-9a-fA-F]{40}$/i.test(address)) {
358
+ throw new Error(`Invalid Ethereum address format: ${address}`);
405
359
  }
406
360
  }
407
361
  /**
408
362
  * Internal method called after publishing
409
363
  * @internal
410
364
  */
411
- _setPublishedData(root, uri, size, censusId) {
365
+ _setPublishedData(root, uri, censusId) {
412
366
  this._censusRoot = root;
413
367
  this._censusURI = uri;
414
- this._size = size;
415
368
  if (censusId) this._censusId = censusId;
416
369
  }
417
370
  }
418
371
 
372
+ class OffchainCensus extends MerkleCensus {
373
+ constructor() {
374
+ super(CensusOrigin.OffchainStatic);
375
+ }
376
+ }
377
+
378
+ class OffchainDynamicCensus extends MerkleCensus {
379
+ constructor() {
380
+ super(CensusOrigin.OffchainDynamic);
381
+ }
382
+ }
383
+
384
+ class OnchainCensus extends Census {
385
+ /**
386
+ * Creates an OnchainCensus
387
+ * @param contractAddress - The address of the smart contract (e.g., ERC20, ERC721)
388
+ * @param uri - Optional URI with census information
389
+ */
390
+ constructor(contractAddress, uri) {
391
+ super(CensusOrigin.Onchain);
392
+ if (!/^(0x)?[0-9a-fA-F]{40}$/i.test(contractAddress)) {
393
+ throw new Error("Contract address is missing or invalid");
394
+ }
395
+ this._contractAddress = contractAddress;
396
+ this._censusRoot = contractAddress;
397
+ this._censusURI = uri || `contract://${contractAddress}`;
398
+ }
399
+ get contractAddress() {
400
+ return this._contractAddress;
401
+ }
402
+ }
403
+
419
404
  class CspCensus extends Census {
420
- constructor(publicKey, cspURI, size) {
421
- super(CensusType.CSP);
405
+ constructor(publicKey, cspURI) {
406
+ super(CensusOrigin.CSP);
422
407
  if (!/^(0x)?[0-9a-fA-F]+$/.test(publicKey)) {
423
408
  throw new Error("Public key is missing or invalid");
424
409
  }
@@ -431,7 +416,6 @@
431
416
  this._cspURI = cspURI;
432
417
  this._censusRoot = publicKey;
433
418
  this._censusURI = cspURI;
434
- this._size = size;
435
419
  }
436
420
  get publicKey() {
437
421
  return this._publicKey;
@@ -442,11 +426,16 @@
442
426
  }
443
427
 
444
428
  class PublishedCensus extends Census {
445
- constructor(type, root, uri, size) {
446
- super(type);
429
+ /**
430
+ * Creates a PublishedCensus from existing census data
431
+ * @param censusOrigin - The census origin (OffchainStatic, OffchainDynamic, Onchain, or CSP)
432
+ * @param root - The census root
433
+ * @param uri - The census URI
434
+ */
435
+ constructor(censusOrigin, root, uri) {
436
+ super(censusOrigin);
447
437
  this._censusRoot = root;
448
438
  this._censusURI = uri;
449
- this._size = size;
450
439
  }
451
440
  }
452
441
 
@@ -455,7 +444,7 @@
455
444
  this.censusService = censusService;
456
445
  }
457
446
  /**
458
- * Publishes a PlainCensus or WeightedCensus
447
+ * Publishes a MerkleCensus (OffchainCensus, OffchainDynamicCensus, or OnchainCensus)
459
448
  * Creates a working census, adds participants, and publishes it
460
449
  */
461
450
  async publish(census) {
@@ -471,23 +460,24 @@
471
460
  census._setPublishedData(
472
461
  publishResponse.root,
473
462
  publishResponse.uri,
474
- publishResponse.participantCount,
475
463
  censusId
476
464
  );
477
465
  }
478
466
  /**
479
467
  * Gets census data for process creation
480
- * Throws if census is not published
468
+ * Throws if census is not ready (published for Merkle/CSP, or constructed for Onchain)
481
469
  */
482
470
  getCensusData(census) {
483
- if (!census.isPublished) {
484
- throw new Error("Census must be published before creating a process");
471
+ if (census.requiresPublishing && !census.isPublished) {
472
+ throw new Error("Merkle census must be published before creating a process");
473
+ }
474
+ if (!census.censusRoot || !census.censusURI) {
475
+ throw new Error("Census data is incomplete");
485
476
  }
486
477
  return {
487
478
  type: census.censusOrigin,
488
479
  root: census.censusRoot,
489
- uri: census.censusURI,
490
- size: census.size
480
+ uri: census.censusURI
491
481
  };
492
482
  }
493
483
  }
@@ -942,6 +932,8 @@
942
932
  }
943
933
  class ProcessCensusError extends ContractServiceError {
944
934
  }
935
+ class CensusNotUpdatable extends ContractServiceError {
936
+ }
945
937
  class ProcessDurationError extends ContractServiceError {
946
938
  }
947
939
  class ProcessStateTransitionError extends ContractServiceError {
@@ -1121,12 +1113,12 @@
1121
1113
  cb
1122
1114
  ).catch((err) => console.error("Error setting up ProcessDurationChanged listener:", err));
1123
1115
  }
1124
- onStateRootUpdated(cb) {
1116
+ onStateTransitioned(cb) {
1125
1117
  this.setupEventListener(
1126
1118
  this.contract,
1127
- this.contract.filters.ProcessStateRootUpdated(),
1119
+ this.contract.filters.ProcessStateTransitioned(),
1128
1120
  cb
1129
- ).catch((err) => console.error("Error setting up StateRootUpdated listener:", err));
1121
+ ).catch((err) => console.error("Error setting up ProcessStateTransitioned listener:", err));
1130
1122
  }
1131
1123
  onProcessResultsSet(cb) {
1132
1124
  this.setupEventListener(
@@ -1163,26 +1155,24 @@
1163
1155
  */
1164
1156
  async handleCensus(census) {
1165
1157
  if ("isPublished" in census) {
1166
- if (census instanceof PlainCensus || census instanceof WeightedCensus) {
1167
- if (!census.isPublished) {
1168
- const censusBaseURL = this.apiService.census?.["axios"]?.defaults?.baseURL;
1169
- if (!censusBaseURL || censusBaseURL === "" || censusBaseURL === "undefined") {
1170
- throw new Error(
1171
- 'Census API URL is required to publish PlainCensus or WeightedCensus. Please provide "censusUrl" when initializing DavinciSDK, or use a pre-published census.'
1172
- );
1173
- }
1174
- await this.censusOrchestrator.publish(census);
1158
+ if (census.requiresPublishing && !census.isPublished) {
1159
+ const censusBaseURL = this.apiService.census?.["axios"]?.defaults?.baseURL;
1160
+ if (!censusBaseURL || censusBaseURL === "" || censusBaseURL === "undefined") {
1161
+ throw new Error(
1162
+ 'Census API URL is required to publish Merkle censuses (OffchainCensus, OffchainDynamicCensus). Please provide "censusUrl" when initializing DavinciSDK, or use a pre-published census.'
1163
+ );
1175
1164
  }
1165
+ await this.censusOrchestrator.publish(census);
1176
1166
  }
1177
1167
  const censusData = this.censusOrchestrator.getCensusData(census);
1178
1168
  return {
1179
1169
  type: censusData.type,
1180
1170
  root: censusData.root,
1181
- size: censusData.size,
1182
1171
  uri: censusData.uri
1183
1172
  };
1184
1173
  }
1185
- return census;
1174
+ const { size, ...censusWithoutSize } = census;
1175
+ return censusWithoutSize;
1186
1176
  }
1187
1177
  /**
1188
1178
  * Gets user-friendly process information by transforming raw contract data
@@ -1390,7 +1380,22 @@
1390
1380
  ballotMode,
1391
1381
  signature
1392
1382
  });
1393
- const maxVoters = config.maxVoters ?? censusConfig.size;
1383
+ let maxVoters;
1384
+ if (config.maxVoters !== void 0) {
1385
+ maxVoters = config.maxVoters;
1386
+ } else if ("isPublished" in config.census && config.census.isPublished) {
1387
+ if ("participants" in config.census) {
1388
+ maxVoters = config.census.participants.length;
1389
+ } else {
1390
+ throw new Error(
1391
+ "maxVoters is required when using OnchainCensus, CspCensus, or PublishedCensus. It can only be auto-calculated for published MerkleCensus (OffchainCensus/OffchainDynamicCensus)."
1392
+ );
1393
+ }
1394
+ } else {
1395
+ throw new Error(
1396
+ "maxVoters is required. It can only be omitted when using a published MerkleCensus (OffchainCensus/OffchainDynamicCensus), in which case it defaults to the participant count."
1397
+ );
1398
+ }
1394
1399
  const census = {
1395
1400
  censusOrigin: censusConfig.type,
1396
1401
  censusRoot,
@@ -2020,7 +2025,7 @@
2020
2025
  signature,
2021
2026
  voteId
2022
2027
  };
2023
- if (process.census.censusOrigin === CensusOrigin.CensusOriginCSP) {
2028
+ if (process.census.censusOrigin === CensusOrigin.CSP) {
2024
2029
  voteRequest.censusProof = censusProof;
2025
2030
  }
2026
2031
  await this.submitVoteRequest(voteRequest);
@@ -2136,7 +2141,7 @@
2136
2141
  * Get census proof based on census origin type
2137
2142
  */
2138
2143
  async getCensusProof(censusOrigin, censusRoot, voterAddress, processId) {
2139
- if (censusOrigin === CensusOrigin.CensusOriginMerkleTree) {
2144
+ if (censusOrigin === CensusOrigin.OffchainStatic || censusOrigin === CensusOrigin.OffchainDynamic || censusOrigin === CensusOrigin.Onchain) {
2140
2145
  if (this.censusProviders.merkle) {
2141
2146
  const proof = await this.censusProviders.merkle({
2142
2147
  censusRoot,
@@ -2150,13 +2155,13 @@
2150
2155
  root: censusRoot,
2151
2156
  address: voterAddress,
2152
2157
  weight,
2153
- censusOrigin: CensusOrigin.CensusOriginMerkleTree,
2158
+ censusOrigin,
2154
2159
  value: "",
2155
2160
  siblings: ""
2156
2161
  };
2157
2162
  }
2158
2163
  }
2159
- if (censusOrigin === CensusOrigin.CensusOriginCSP) {
2164
+ if (censusOrigin === CensusOrigin.CSP) {
2160
2165
  if (!this.censusProviders.csp) {
2161
2166
  throw new Error(
2162
2167
  "CSP voting requires a CSP census proof provider. Pass one via VoteOrchestrationService(..., { csp: yourFn })."
@@ -2730,7 +2735,7 @@
2730
2735
  * title: "My Election",
2731
2736
  * description: "A simple election",
2732
2737
  * census: {
2733
- * type: CensusOrigin.CensusOriginMerkleTree,
2738
+ * type: CensusOrigin.OffchainStatic,
2734
2739
  * root: "0x1234...",
2735
2740
  * size: 100,
2736
2741
  * uri: "ipfs://..."
@@ -2817,7 +2822,7 @@
2817
2822
  * title: "My Election",
2818
2823
  * description: "A simple election",
2819
2824
  * census: {
2820
- * type: CensusOrigin.CensusOriginMerkleTree,
2825
+ * type: CensusOrigin.OffchainStatic,
2821
2826
  * root: "0x1234...",
2822
2827
  * size: 100,
2823
2828
  * uri: "ipfs://your-census-uri"
@@ -3516,9 +3521,9 @@
3516
3521
 
3517
3522
  exports.BaseService = BaseService;
3518
3523
  exports.Census = Census;
3524
+ exports.CensusNotUpdatable = CensusNotUpdatable;
3519
3525
  exports.CensusOrchestrator = CensusOrchestrator;
3520
3526
  exports.CensusOrigin = CensusOrigin;
3521
- exports.CensusType = CensusType;
3522
3527
  exports.CircomProof = CircomProof;
3523
3528
  exports.ContractServiceError = ContractServiceError;
3524
3529
  exports.CspCensus = CspCensus;
@@ -3526,12 +3531,15 @@
3526
3531
  exports.DavinciSDK = DavinciSDK;
3527
3532
  exports.ElectionMetadataTemplate = ElectionMetadataTemplate;
3528
3533
  exports.ElectionResultsTypeNames = ElectionResultsTypeNames;
3534
+ exports.MerkleCensus = MerkleCensus;
3535
+ exports.OffchainCensus = OffchainCensus;
3536
+ exports.OffchainDynamicCensus = OffchainDynamicCensus;
3537
+ exports.OnchainCensus = OnchainCensus;
3529
3538
  exports.OrganizationAdministratorError = OrganizationAdministratorError;
3530
3539
  exports.OrganizationCreateError = OrganizationCreateError;
3531
3540
  exports.OrganizationDeleteError = OrganizationDeleteError;
3532
3541
  exports.OrganizationRegistryService = OrganizationRegistryService;
3533
3542
  exports.OrganizationUpdateError = OrganizationUpdateError;
3534
- exports.PlainCensus = PlainCensus;
3535
3543
  exports.ProcessCensusError = ProcessCensusError;
3536
3544
  exports.ProcessCreateError = ProcessCreateError;
3537
3545
  exports.ProcessDurationError = ProcessDurationError;
@@ -3549,7 +3557,6 @@
3549
3557
  exports.VocdoniSequencerService = VocdoniSequencerService;
3550
3558
  exports.VoteOrchestrationService = VoteOrchestrationService;
3551
3559
  exports.VoteStatus = VoteStatus;
3552
- exports.WeightedCensus = WeightedCensus;
3553
3560
  exports.assertCSPCensusProof = assertCSPCensusProof;
3554
3561
  exports.assertMerkleCensusProof = assertMerkleCensusProof;
3555
3562
  exports.createProcessSignatureMessage = createProcessSignatureMessage;
@@ -99,10 +99,14 @@ declare class BaseService {
99
99
  * Census origin types
100
100
  */
101
101
  declare enum CensusOrigin {
102
- /** Indicates that the census is derived from a Merkle Tree structure */
103
- CensusOriginMerkleTree = 1,
104
- /** Indicates that the census is provided by a Credential Service Provider (CSP) */
105
- CensusOriginCSP = 2
102
+ /** Offchain static Merkle Tree census */
103
+ OffchainStatic = 1,
104
+ /** Offchain dynamic Merkle Tree census */
105
+ OffchainDynamic = 2,
106
+ /** Onchain Merkle Tree census */
107
+ Onchain = 3,
108
+ /** Credential Service Provider (CSP) census using EdDSA BLS12-377 */
109
+ CSP = 4
106
110
  }
107
111
  interface BaseCensusProof {
108
112
  /** The Merkle root (hex-prefixed). */
@@ -111,18 +115,18 @@ interface BaseCensusProof {
111
115
  address: string;
112
116
  /** The weight as a decimal string. */
113
117
  weight: string;
114
- /** Census origin type: CensusOriginMerkleTree for merkle proofs, CensusOriginCSP for csp proofs */
118
+ /** Census origin type: OffchainStatic/OffchainDynamic/Onchain for merkle proofs, CSP for csp proofs */
115
119
  censusOrigin: CensusOrigin;
116
120
  }
117
121
  interface MerkleCensusProof extends BaseCensusProof {
118
- censusOrigin: CensusOrigin.CensusOriginMerkleTree;
122
+ censusOrigin: CensusOrigin.OffchainStatic | CensusOrigin.OffchainDynamic | CensusOrigin.Onchain;
119
123
  /** The leaf value (hex-prefixed weight). */
120
124
  value: string;
121
125
  /** The serialized sibling path (hex-prefixed). */
122
126
  siblings: string;
123
127
  }
124
128
  interface CSPCensusProof extends BaseCensusProof {
125
- censusOrigin: CensusOrigin.CensusOriginCSP;
129
+ censusOrigin: CensusOrigin.CSP;
126
130
  /** The process id signed with the address (hex-prefixed). */
127
131
  processId: string;
128
132
  /** The public key of the csp (hex-prefixed). */
@@ -181,6 +185,7 @@ interface GetProcessResponse {
181
185
  ballotMode: BallotMode;
182
186
  census: CensusData;
183
187
  votersCount: string;
188
+ maxVoters: string;
184
189
  overwrittenVotesCount: string;
185
190
  isAcceptingVotes: boolean;
186
191
  sequencerStats: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vocdoni/davinci-sdk",
3
- "version": "0.0.6",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -72,7 +72,7 @@
72
72
  },
73
73
  "dependencies": {
74
74
  "@ethereumjs/common": "^4.4.0",
75
- "@vocdoni/davinci-contracts": "0.0.29",
75
+ "@vocdoni/davinci-contracts": "0.0.31",
76
76
  "axios": "^1.8.4",
77
77
  "ethers": "^6.7.1",
78
78
  "snarkjs": "^0.7.5"