@vocdoni/davinci-sdk 0.0.7 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -28
- package/dist/contracts.d.ts +12 -0
- package/dist/index.d.ts +91 -88
- package/dist/index.js +142 -154
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +139 -152
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +142 -154
- package/dist/sequencer.d.ts +12 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ yarn add @vocdoni/davinci-sdk
|
|
|
20
20
|
### Basic Usage
|
|
21
21
|
|
|
22
22
|
```typescript
|
|
23
|
-
import { DavinciSDK,
|
|
23
|
+
import { DavinciSDK, OffchainCensus } from '@vocdoni/davinci-sdk';
|
|
24
24
|
import { Wallet } from 'ethers';
|
|
25
25
|
|
|
26
26
|
// Initialize the SDK
|
|
@@ -34,7 +34,7 @@ const sdk = new DavinciSDK({
|
|
|
34
34
|
await sdk.init();
|
|
35
35
|
|
|
36
36
|
// 1. Create a census with eligible voters
|
|
37
|
-
const census = new
|
|
37
|
+
const census = new OffchainCensus(); // Supports both plain and weighted voting
|
|
38
38
|
census.add([
|
|
39
39
|
'0x1234567890123456789012345678901234567890',
|
|
40
40
|
'0x2345678901234567890123456789012345678901',
|
|
@@ -152,14 +152,16 @@ The SDK provides simple-to-use census classes that make voter management easy. C
|
|
|
152
152
|
|
|
153
153
|
### Census Types
|
|
154
154
|
|
|
155
|
-
####
|
|
155
|
+
#### OffchainCensus - Static Merkle Tree Census
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
A flexible census that supports both plain addresses (equal voting power) and weighted participants.
|
|
158
|
+
|
|
159
|
+
**Plain addresses (everyone gets weight = 1):**
|
|
158
160
|
|
|
159
161
|
```typescript
|
|
160
|
-
import {
|
|
162
|
+
import { OffchainCensus } from '@vocdoni/davinci-sdk';
|
|
161
163
|
|
|
162
|
-
const census = new
|
|
164
|
+
const census = new OffchainCensus();
|
|
163
165
|
census.add([
|
|
164
166
|
'0x1234567890123456789012345678901234567890',
|
|
165
167
|
'0xabcdefabcdefabcdefabcdefabcdefabcdefabcd',
|
|
@@ -168,19 +170,19 @@ census.add([
|
|
|
168
170
|
|
|
169
171
|
// Use directly in process creation - SDK auto-publishes!
|
|
170
172
|
const process = await sdk.createProcess({
|
|
171
|
-
census: census, // ✨ Auto-published!
|
|
173
|
+
census: census, // ✨ Auto-published! maxVoters auto-calculated!
|
|
172
174
|
// ... rest of config
|
|
173
175
|
});
|
|
174
176
|
```
|
|
175
177
|
|
|
176
|
-
|
|
178
|
+
**Weighted participants (custom voting power):**
|
|
177
179
|
|
|
178
|
-
|
|
180
|
+
Supports flexible weight types: **string**, **number**, or **bigint**.
|
|
179
181
|
|
|
180
182
|
```typescript
|
|
181
|
-
import {
|
|
183
|
+
import { OffchainCensus } from '@vocdoni/davinci-sdk';
|
|
182
184
|
|
|
183
|
-
const census = new
|
|
185
|
+
const census = new OffchainCensus();
|
|
184
186
|
|
|
185
187
|
census.add([
|
|
186
188
|
{ key: '0x123...', weight: "1" }, // string
|
|
@@ -188,7 +190,27 @@ census.add([
|
|
|
188
190
|
{ key: '0x789...', weight: 100n }, // bigint
|
|
189
191
|
]);
|
|
190
192
|
|
|
191
|
-
// Auto-published when creating process
|
|
193
|
+
// Auto-published when creating process, maxVoters auto-set to participant count
|
|
194
|
+
const process = await sdk.createProcess({
|
|
195
|
+
census: census,
|
|
196
|
+
// ... rest of config
|
|
197
|
+
});
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### OffchainDynamicCensus - Updatable Merkle Tree Census
|
|
201
|
+
|
|
202
|
+
Similar to OffchainCensus but allows census updates after process creation.
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
import { OffchainDynamicCensus } from '@vocdoni/davinci-sdk';
|
|
206
|
+
|
|
207
|
+
const census = new OffchainDynamicCensus();
|
|
208
|
+
census.add([
|
|
209
|
+
{ key: '0x123...', weight: 10 },
|
|
210
|
+
{ key: '0x456...', weight: 20 }
|
|
211
|
+
]);
|
|
212
|
+
|
|
213
|
+
// Auto-published and updatable
|
|
192
214
|
const process = await sdk.createProcess({
|
|
193
215
|
census: census,
|
|
194
216
|
// ... rest of config
|
|
@@ -204,12 +226,12 @@ import { CspCensus } from '@vocdoni/davinci-sdk';
|
|
|
204
226
|
|
|
205
227
|
const census = new CspCensus(
|
|
206
228
|
"0x1234567890abcdef", // Root hash (public key)
|
|
207
|
-
"https://csp-server.com"
|
|
208
|
-
1000 // Expected number of voters
|
|
229
|
+
"https://csp-server.com" // CSP URL
|
|
209
230
|
);
|
|
210
231
|
|
|
211
232
|
const process = await sdk.createProcess({
|
|
212
233
|
census: census,
|
|
234
|
+
maxVoters: 1000, // Required for CSP census
|
|
213
235
|
// ... rest of config
|
|
214
236
|
});
|
|
215
237
|
```
|
|
@@ -219,27 +241,76 @@ const process = await sdk.createProcess({
|
|
|
219
241
|
For censuses already published to the network.
|
|
220
242
|
|
|
221
243
|
```typescript
|
|
222
|
-
import { PublishedCensus,
|
|
244
|
+
import { PublishedCensus, CensusOrigin } from '@vocdoni/davinci-sdk';
|
|
223
245
|
|
|
224
246
|
const census = new PublishedCensus(
|
|
225
|
-
|
|
247
|
+
CensusOrigin.OffchainStatic,
|
|
226
248
|
"0xroot...",
|
|
227
|
-
"ipfs://uri..."
|
|
228
|
-
100 // size
|
|
249
|
+
"ipfs://uri..."
|
|
229
250
|
);
|
|
230
251
|
|
|
231
252
|
const process = await sdk.createProcess({
|
|
232
253
|
census: census,
|
|
254
|
+
maxVoters: 100, // Required for pre-published census
|
|
233
255
|
// ... rest of config
|
|
234
256
|
});
|
|
235
257
|
```
|
|
236
258
|
|
|
259
|
+
#### OnchainCensus - Token-Based Voting
|
|
260
|
+
|
|
261
|
+
Use existing on-chain token contracts (ERC20, ERC721) for voting eligibility. Perfect for DAO governance where voting power comes from token holdings.
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
import { OnchainCensus } from '@vocdoni/davinci-sdk';
|
|
265
|
+
|
|
266
|
+
// Create census from token contract address with subgraph URI
|
|
267
|
+
const census = new OnchainCensus(
|
|
268
|
+
"0x1234567890123456789012345678901234567890", // Token contract address
|
|
269
|
+
"https://api.studio.thegraph.com/query/12345/token-holders/v1.0.0" // Subgraph endpoint
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
const process = await sdk.createProcess({
|
|
273
|
+
census: census,
|
|
274
|
+
maxVoters: 10000, // Required for onchain census
|
|
275
|
+
// ... rest of config
|
|
276
|
+
});
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**Key Features:**
|
|
280
|
+
- **No Publishing Required**: Uses existing on-chain data, no need to publish
|
|
281
|
+
- **Automatic Validation**: Contract address and URI validated on construction
|
|
282
|
+
- **Token Agnostic**: Works with any ERC20 or ERC721 contract
|
|
283
|
+
- **DAO Ready**: Perfect for token-based governance systems
|
|
284
|
+
- **Subgraph Integration**: URI should point to a subgraph or API endpoint for census data
|
|
285
|
+
|
|
286
|
+
**Technical Details:**
|
|
287
|
+
- `censusRoot` automatically set to 32-byte zero value (`0x0000...000`)
|
|
288
|
+
- `contractAddress` properly passed to smart contracts
|
|
289
|
+
- `uri` parameter is **required** and should point to a data source (e.g., subgraph)
|
|
290
|
+
- Census is immediately ready for process creation
|
|
291
|
+
|
|
292
|
+
**Example with different subgraph providers:**
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
// The Graph Studio
|
|
296
|
+
const census = new OnchainCensus(
|
|
297
|
+
"0xTokenAddress...",
|
|
298
|
+
"https://api.studio.thegraph.com/query/12345/my-token/v1.0.0"
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
// Custom subgraph deployment
|
|
302
|
+
const census = new OnchainCensus(
|
|
303
|
+
"0xTokenAddress...",
|
|
304
|
+
"https://subgraph.example.com/api/token-holders"
|
|
305
|
+
);
|
|
306
|
+
```
|
|
307
|
+
|
|
237
308
|
### Auto-Publishing Feature
|
|
238
309
|
|
|
239
310
|
The SDK automatically publishes unpublished censuses when creating a process:
|
|
240
311
|
|
|
241
312
|
```typescript
|
|
242
|
-
const census = new
|
|
313
|
+
const census = new OffchainCensus();
|
|
243
314
|
census.add(['0x123...', '0x456...']);
|
|
244
315
|
|
|
245
316
|
console.log(census.isPublished); // false
|
|
@@ -257,10 +328,10 @@ console.log(census.censusURI); // Published URI
|
|
|
257
328
|
|
|
258
329
|
### Flexible Weight Types
|
|
259
330
|
|
|
260
|
-
|
|
331
|
+
OffchainCensus accepts weights as strings, numbers, or bigints for maximum flexibility:
|
|
261
332
|
|
|
262
333
|
```typescript
|
|
263
|
-
const census = new
|
|
334
|
+
const census = new OffchainCensus();
|
|
264
335
|
|
|
265
336
|
// String weights (recommended for very large numbers)
|
|
266
337
|
census.add({ key: '0x123...', weight: "999999999999" });
|
|
@@ -282,7 +353,7 @@ census.add([
|
|
|
282
353
|
### Census Operations
|
|
283
354
|
|
|
284
355
|
```typescript
|
|
285
|
-
const census = new
|
|
356
|
+
const census = new OffchainCensus();
|
|
286
357
|
|
|
287
358
|
// Add single participant
|
|
288
359
|
census.add({ key: '0x123...', weight: 5 });
|
|
@@ -310,7 +381,6 @@ const participants = census.participants;
|
|
|
310
381
|
if (census.isPublished) {
|
|
311
382
|
console.log('Root:', census.censusRoot);
|
|
312
383
|
console.log('URI:', census.censusURI);
|
|
313
|
-
console.log('Size:', census.size);
|
|
314
384
|
}
|
|
315
385
|
```
|
|
316
386
|
|
|
@@ -323,9 +393,9 @@ const process = await sdk.createProcess({
|
|
|
323
393
|
census: {
|
|
324
394
|
type: CensusOrigin.OffchainStatic,
|
|
325
395
|
root: "0xabc...",
|
|
326
|
-
size: 100,
|
|
327
396
|
uri: "ipfs://..."
|
|
328
397
|
},
|
|
398
|
+
maxVoters: 100, // Required for manual census config
|
|
329
399
|
// ... rest of config
|
|
330
400
|
});
|
|
331
401
|
```
|
|
@@ -408,7 +478,6 @@ const processResult = await sdk.createProcess({
|
|
|
408
478
|
census: {
|
|
409
479
|
type: CensusOrigin.OffchainStatic,
|
|
410
480
|
root: "0x...",
|
|
411
|
-
size: 1000,
|
|
412
481
|
uri: "ipfs://..."
|
|
413
482
|
},
|
|
414
483
|
|
|
@@ -431,8 +500,8 @@ const processResult = await sdk.createProcess({
|
|
|
431
500
|
minValueSum: "0"
|
|
432
501
|
},
|
|
433
502
|
|
|
434
|
-
// Maximum voters (
|
|
435
|
-
maxVoters: 500,
|
|
503
|
+
// Maximum voters (required for manual census config)
|
|
504
|
+
maxVoters: 500,
|
|
436
505
|
|
|
437
506
|
// Questions
|
|
438
507
|
questions: [{
|
|
@@ -664,9 +733,9 @@ async function completeVotingExample() {
|
|
|
664
733
|
census: {
|
|
665
734
|
type: CensusOrigin.OffchainStatic,
|
|
666
735
|
root: publishResult.root,
|
|
667
|
-
size: censusSize,
|
|
668
736
|
uri: publishResult.uri
|
|
669
737
|
},
|
|
738
|
+
maxVoters: censusSize,
|
|
670
739
|
timing: {
|
|
671
740
|
startDate: new Date(Date.now() + 60000), // Start in 1 minute
|
|
672
741
|
duration: 3600 // 1 hour
|
package/dist/contracts.d.ts
CHANGED
|
@@ -390,7 +390,19 @@ interface BallotMode {
|
|
|
390
390
|
interface CensusData {
|
|
391
391
|
censusOrigin: CensusOrigin;
|
|
392
392
|
censusRoot: string;
|
|
393
|
+
/**
|
|
394
|
+
* Contract address for onchain censuses (ERC20/ERC721 token contract).
|
|
395
|
+
* For offchain censuses, defaults to zero address.
|
|
396
|
+
* @default "0x0000000000000000000000000000000000000000"
|
|
397
|
+
*/
|
|
398
|
+
contractAddress?: string;
|
|
393
399
|
censusURI: string;
|
|
400
|
+
/**
|
|
401
|
+
* For onchain censuses, allows any valid Merkle root from the onchain source.
|
|
402
|
+
* For other census types, set to false to require the specific censusRoot.
|
|
403
|
+
* @default false
|
|
404
|
+
*/
|
|
405
|
+
onchainAllowAnyValidRoot?: boolean;
|
|
394
406
|
}
|
|
395
407
|
interface EncryptionKey {
|
|
396
408
|
x: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -117,7 +117,7 @@ declare enum CensusOrigin {
|
|
|
117
117
|
/** Credential Service Provider (CSP) census using EdDSA BLS12-377 */
|
|
118
118
|
CSP = 4
|
|
119
119
|
}
|
|
120
|
-
interface CensusParticipant
|
|
120
|
+
interface CensusParticipant {
|
|
121
121
|
key: string;
|
|
122
122
|
weight?: string;
|
|
123
123
|
}
|
|
@@ -275,8 +275,8 @@ declare class VocdoniCensusService extends BaseService {
|
|
|
275
275
|
*/
|
|
276
276
|
getCensusUri(relativePath: string): string;
|
|
277
277
|
createCensus(): Promise<string>;
|
|
278
|
-
addParticipants(censusId: string, participants: CensusParticipant
|
|
279
|
-
getParticipants(censusId: string): Promise<CensusParticipant
|
|
278
|
+
addParticipants(censusId: string, participants: CensusParticipant[]): Promise<void>;
|
|
279
|
+
getParticipants(censusId: string): Promise<CensusParticipant[]>;
|
|
280
280
|
getCensusRoot(censusId: string): Promise<string>;
|
|
281
281
|
getCensusSizeById(censusId: string): Promise<number>;
|
|
282
282
|
getCensusSizeByRoot(censusRoot: string): Promise<number>;
|
|
@@ -289,21 +289,6 @@ declare class VocdoniCensusService extends BaseService {
|
|
|
289
289
|
getHealth(): Promise<HealthResponse>;
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
/**
|
|
293
|
-
* Census type enumeration
|
|
294
|
-
*/
|
|
295
|
-
declare enum CensusType {
|
|
296
|
-
PLAIN = "plain",
|
|
297
|
-
WEIGHTED = "weighted",
|
|
298
|
-
CSP = "csp"
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Re-export CensusParticipant from types for convenience
|
|
302
|
-
* Extended to make weight required (base type has optional weight)
|
|
303
|
-
*/
|
|
304
|
-
interface CensusParticipant extends CensusParticipant$1 {
|
|
305
|
-
weight: string;
|
|
306
|
-
}
|
|
307
292
|
/**
|
|
308
293
|
* Abstract base class for all census types
|
|
309
294
|
*/
|
|
@@ -311,84 +296,48 @@ declare abstract class Census {
|
|
|
311
296
|
protected _censusId: string | null;
|
|
312
297
|
protected _censusRoot: string | null;
|
|
313
298
|
protected _censusURI: string | null;
|
|
314
|
-
protected _type: CensusType;
|
|
315
299
|
protected _censusOrigin: CensusOrigin;
|
|
316
|
-
|
|
317
|
-
constructor(type: CensusType, censusOrigin?: CensusOrigin);
|
|
300
|
+
constructor(censusOrigin: CensusOrigin);
|
|
318
301
|
get censusId(): string | null;
|
|
319
302
|
get censusRoot(): string | null;
|
|
320
303
|
get censusURI(): string | null;
|
|
321
|
-
get type(): CensusType;
|
|
322
|
-
get size(): number | null;
|
|
323
304
|
get isPublished(): boolean;
|
|
324
305
|
/**
|
|
325
306
|
* Get the census origin (OffchainStatic, OffchainDynamic, Onchain, or CSP)
|
|
326
307
|
*/
|
|
327
308
|
get censusOrigin(): CensusOrigin;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Plain census where all participants have equal voting power (weight=1)
|
|
332
|
-
* Simpler API - just add addresses without specifying weights
|
|
333
|
-
*/
|
|
334
|
-
declare class PlainCensus extends Census {
|
|
335
|
-
private _participants;
|
|
336
309
|
/**
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
|
|
340
|
-
constructor(censusOrigin?: CensusOrigin);
|
|
341
|
-
/**
|
|
342
|
-
* Add participant(s) with automatic weight=1
|
|
343
|
-
* @param addresses - Single address or array of addresses
|
|
344
|
-
*/
|
|
345
|
-
add(addresses: string | string[]): void;
|
|
346
|
-
/**
|
|
347
|
-
* Remove participant by address
|
|
348
|
-
*/
|
|
349
|
-
remove(address: string): void;
|
|
350
|
-
/**
|
|
351
|
-
* Get all participants as CensusParticipant array (for API)
|
|
352
|
-
* All participants have weight="1"
|
|
353
|
-
*/
|
|
354
|
-
get participants(): CensusParticipant[];
|
|
355
|
-
/**
|
|
356
|
-
* Get addresses only
|
|
357
|
-
*/
|
|
358
|
-
get addresses(): string[];
|
|
359
|
-
private validateAddress;
|
|
360
|
-
/**
|
|
361
|
-
* Internal method called after publishing
|
|
362
|
-
* @internal
|
|
310
|
+
* Check if this census requires publishing via the Census API
|
|
311
|
+
* Merkle censuses (OffchainStatic, OffchainDynamic) need to be published
|
|
312
|
+
* Onchain and CSP censuses are ready immediately upon construction
|
|
363
313
|
*/
|
|
364
|
-
|
|
314
|
+
get requiresPublishing(): boolean;
|
|
365
315
|
}
|
|
366
316
|
|
|
367
317
|
/**
|
|
368
|
-
* Participant with flexible weight type for
|
|
318
|
+
* Participant with flexible weight type for MerkleCensus
|
|
369
319
|
* Weight can be string, number, or bigint - will be normalized to string internally
|
|
370
320
|
*/
|
|
371
|
-
interface
|
|
321
|
+
interface Participant {
|
|
372
322
|
key: string;
|
|
373
323
|
weight: string | number | bigint;
|
|
374
324
|
}
|
|
375
325
|
/**
|
|
376
|
-
*
|
|
377
|
-
*
|
|
326
|
+
* Abstract base class for Merkle Tree censuses
|
|
327
|
+
* Supports both plain addresses (weight=1) and weighted participants
|
|
378
328
|
*/
|
|
379
|
-
declare class
|
|
329
|
+
declare abstract class MerkleCensus extends Census {
|
|
380
330
|
private _participants;
|
|
331
|
+
constructor(censusOrigin: CensusOrigin);
|
|
381
332
|
/**
|
|
382
|
-
*
|
|
383
|
-
* @param
|
|
333
|
+
* Add participant(s) - supports both plain addresses and weighted participants
|
|
334
|
+
* @param data - Can be:
|
|
335
|
+
* - string: single address (weight=1)
|
|
336
|
+
* - string[]: array of addresses (weight=1 for all)
|
|
337
|
+
* - {key: string, weight: string|number|bigint}: single weighted participant
|
|
338
|
+
* - Array of weighted participants
|
|
384
339
|
*/
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Add participant(s) with custom weights
|
|
388
|
-
* Weight can be provided as string, number, or bigint - will be converted to string internally
|
|
389
|
-
* @param participant - Single participant or array of participants with custom weights
|
|
390
|
-
*/
|
|
391
|
-
add(participant: WeightedParticipant | WeightedParticipant[]): void;
|
|
340
|
+
add(data: string | string[] | Participant | Participant[]): void;
|
|
392
341
|
/**
|
|
393
342
|
* Remove participant by address
|
|
394
343
|
*/
|
|
@@ -405,16 +354,58 @@ declare class WeightedCensus extends Census {
|
|
|
405
354
|
* Get weight for specific address
|
|
406
355
|
*/
|
|
407
356
|
getWeight(address: string): string | undefined;
|
|
357
|
+
/**
|
|
358
|
+
* Internal method to add a plain address with a given weight
|
|
359
|
+
*/
|
|
360
|
+
private addAddress;
|
|
361
|
+
/**
|
|
362
|
+
* Internal method to add a weighted participant
|
|
363
|
+
*/
|
|
364
|
+
private addParticipant;
|
|
408
365
|
/**
|
|
409
366
|
* Normalizes weight from string, number, or bigint to string
|
|
410
367
|
*/
|
|
411
368
|
private normalizeWeight;
|
|
412
|
-
|
|
369
|
+
/**
|
|
370
|
+
* Validates Ethereum address format
|
|
371
|
+
*/
|
|
372
|
+
private validateAddress;
|
|
413
373
|
/**
|
|
414
374
|
* Internal method called after publishing
|
|
415
375
|
* @internal
|
|
416
376
|
*/
|
|
417
|
-
_setPublishedData(root: string, uri: string,
|
|
377
|
+
_setPublishedData(root: string, uri: string, censusId?: string): void;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Offchain static Merkle Tree census (most common)
|
|
382
|
+
* Supports both plain addresses (weight=1) and weighted participants
|
|
383
|
+
*/
|
|
384
|
+
declare class OffchainCensus extends MerkleCensus {
|
|
385
|
+
constructor();
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Offchain dynamic Merkle Tree census
|
|
390
|
+
* Supports both plain addresses (weight=1) and weighted participants
|
|
391
|
+
*/
|
|
392
|
+
declare class OffchainDynamicCensus extends MerkleCensus {
|
|
393
|
+
constructor();
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Onchain census that references a smart contract
|
|
398
|
+
* Does not require publishing as it references an existing on-chain contract
|
|
399
|
+
*/
|
|
400
|
+
declare class OnchainCensus extends Census {
|
|
401
|
+
private _contractAddress;
|
|
402
|
+
/**
|
|
403
|
+
* Creates an OnchainCensus
|
|
404
|
+
* @param contractAddress - The address of the smart contract (e.g., ERC20, ERC721)
|
|
405
|
+
* @param uri - The URI pointing to census data source (e.g., subgraph endpoint)
|
|
406
|
+
*/
|
|
407
|
+
constructor(contractAddress: string, uri: string);
|
|
408
|
+
get contractAddress(): string;
|
|
418
409
|
}
|
|
419
410
|
|
|
420
411
|
/**
|
|
@@ -424,25 +415,23 @@ declare class WeightedCensus extends Census {
|
|
|
424
415
|
declare class CspCensus extends Census {
|
|
425
416
|
private _publicKey;
|
|
426
417
|
private _cspURI;
|
|
427
|
-
constructor(publicKey: string, cspURI: string
|
|
418
|
+
constructor(publicKey: string, cspURI: string);
|
|
428
419
|
get publicKey(): string;
|
|
429
420
|
get cspURI(): string;
|
|
430
421
|
}
|
|
431
422
|
|
|
432
423
|
/**
|
|
433
424
|
* Published census - represents a census that has already been published
|
|
434
|
-
* Use this when you have the census root
|
|
425
|
+
* Use this when you have the census root and URI from a previous publication
|
|
435
426
|
*/
|
|
436
427
|
declare class PublishedCensus extends Census {
|
|
437
428
|
/**
|
|
438
429
|
* Creates a PublishedCensus from existing census data
|
|
439
|
-
* @param
|
|
430
|
+
* @param censusOrigin - The census origin (OffchainStatic, OffchainDynamic, Onchain, or CSP)
|
|
440
431
|
* @param root - The census root
|
|
441
432
|
* @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
433
|
*/
|
|
445
|
-
constructor(
|
|
434
|
+
constructor(censusOrigin: CensusOrigin, root: string, uri: string);
|
|
446
435
|
}
|
|
447
436
|
|
|
448
437
|
/**
|
|
@@ -452,19 +441,19 @@ declare class CensusOrchestrator {
|
|
|
452
441
|
private censusService;
|
|
453
442
|
constructor(censusService: VocdoniCensusService);
|
|
454
443
|
/**
|
|
455
|
-
* Publishes a
|
|
444
|
+
* Publishes a MerkleCensus (OffchainCensus, OffchainDynamicCensus, or OnchainCensus)
|
|
456
445
|
* Creates a working census, adds participants, and publishes it
|
|
457
446
|
*/
|
|
458
|
-
publish(census:
|
|
447
|
+
publish(census: MerkleCensus): Promise<void>;
|
|
459
448
|
/**
|
|
460
449
|
* Gets census data for process creation
|
|
461
|
-
* Throws if census is not published
|
|
450
|
+
* Throws if census is not ready (published for Merkle/CSP, or constructed for Onchain)
|
|
462
451
|
*/
|
|
463
452
|
getCensusData(census: Census): {
|
|
464
453
|
type: CensusOrigin;
|
|
465
454
|
root: string;
|
|
466
455
|
uri: string;
|
|
467
|
-
|
|
456
|
+
contractAddress?: string;
|
|
468
457
|
};
|
|
469
458
|
}
|
|
470
459
|
|
|
@@ -481,7 +470,19 @@ interface BallotMode {
|
|
|
481
470
|
interface CensusData {
|
|
482
471
|
censusOrigin: CensusOrigin;
|
|
483
472
|
censusRoot: string;
|
|
473
|
+
/**
|
|
474
|
+
* Contract address for onchain censuses (ERC20/ERC721 token contract).
|
|
475
|
+
* For offchain censuses, defaults to zero address.
|
|
476
|
+
* @default "0x0000000000000000000000000000000000000000"
|
|
477
|
+
*/
|
|
478
|
+
contractAddress?: string;
|
|
484
479
|
censusURI: string;
|
|
480
|
+
/**
|
|
481
|
+
* For onchain censuses, allows any valid Merkle root from the onchain source.
|
|
482
|
+
* For other census types, set to false to require the specific censusRoot.
|
|
483
|
+
* @default false
|
|
484
|
+
*/
|
|
485
|
+
onchainAllowAnyValidRoot?: boolean;
|
|
485
486
|
}
|
|
486
487
|
interface EncryptionKey {
|
|
487
488
|
x: string;
|
|
@@ -1276,8 +1277,10 @@ interface BaseProcessConfig {
|
|
|
1276
1277
|
endDate?: Date | string | number;
|
|
1277
1278
|
};
|
|
1278
1279
|
/**
|
|
1279
|
-
* Maximum number of voters allowed for this process
|
|
1280
|
-
*
|
|
1280
|
+
* Maximum number of voters allowed for this process
|
|
1281
|
+
* Optional only if census is a published MerkleCensus (OffchainCensus/OffchainDynamicCensus)
|
|
1282
|
+
* - defaults to participant count from the census
|
|
1283
|
+
* Required in all other cases (OnchainCensus, CspCensus, manual config, unpublished census)
|
|
1281
1284
|
*/
|
|
1282
1285
|
maxVoters?: number;
|
|
1283
1286
|
}
|
|
@@ -2713,5 +2716,5 @@ declare class DavinciSDK {
|
|
|
2713
2716
|
private ensureProvider;
|
|
2714
2717
|
}
|
|
2715
2718
|
|
|
2716
|
-
export { BaseService, Census, CensusNotUpdatable, CensusOrchestrator, CensusOrigin,
|
|
2717
|
-
export type { AbstainProperties, AnyJson, ApiError, ApprovalProperties, BallotMode, BaseCensusProof, BaseProcess, BudgetProperties, CSPCensusProof, CSPCensusProofProvider, CSPSignOutput, CensusData, CensusParticipant
|
|
2719
|
+
export { BaseService, Census, CensusNotUpdatable, CensusOrchestrator, CensusOrigin, CircomProof, ContractServiceError, CspCensus, DavinciCrypto, DavinciSDK, ElectionMetadataTemplate, ElectionResultsTypeNames, MerkleCensus, OffchainCensus, OffchainDynamicCensus, OnchainCensus, OrganizationAdministratorError, OrganizationCreateError, OrganizationDeleteError, OrganizationRegistryService, OrganizationUpdateError, ProcessCensusError, ProcessCreateError, ProcessDurationError, ProcessOrchestrationService, ProcessRegistryService, ProcessResultError, ProcessStateTransitionError, ProcessStatus, ProcessStatusError, PublishedCensus, SmartContractService, TxStatus, VocdoniApiService, VocdoniCensusService, VocdoniSequencerService, VoteOrchestrationService, VoteStatus, assertCSPCensusProof, assertMerkleCensusProof, createProcessSignatureMessage, getElectionMetadataTemplate, isCSPCensusProof, isMerkleCensusProof, signProcessCreation, validateProcessId };
|
|
2720
|
+
export type { AbstainProperties, AnyJson, ApiError, ApprovalProperties, BallotMode, BaseCensusProof, BaseProcess, BudgetProperties, CSPCensusProof, CSPCensusProofProvider, CSPSignOutput, CensusData, 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, Participant, 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, WorkerStats, WorkersResponse };
|