diff --git a/docs/sdk/AccountService.mdx b/docs/sdk/AccountService.mdx
new file mode 100644
index 000000000..6ce9dab0d
--- /dev/null
+++ b/docs/sdk/AccountService.mdx
@@ -0,0 +1,64 @@
+---
+custom_edit_url: null
+---
+
+```ts
+class AccountService
+```
+
+
+
+Instantiate the election service.
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|params|Partial<AccountServiceParameters>|||The service parameters|
+
+## Methods
+
+### fetchAccountInfo {#fetchAccountInfo}
+
+
+
+Fetches account information.
+
+**Returns**: Promise<[AccountData](AccountData)>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|address|string|||The account address to fetch the information|
+
+### setInfo {#setInfo}
+
+
+
+Updates an account with information
+
+**Returns**: Promise<string>
+- The transaction hash
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|tx|string|||The transaction for setting the account|
+|metadata|string|||The account metadata|
+
diff --git a/docs/sdk/AnonymousService.mdx b/docs/sdk/AnonymousService.mdx
new file mode 100644
index 000000000..6867050ce
--- /dev/null
+++ b/docs/sdk/AnonymousService.mdx
@@ -0,0 +1,73 @@
+---
+custom_edit_url: null
+---
+
+```ts
+class AnonymousService
+```
+
+
+
+Instantiate the anonymous service.
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|params|Partial<AnonymousServiceParameters>|||The service parameters|
+
+## Methods
+
+### checkCircuitsHashes {#checkCircuitsHashes}
+
+
+
+Checks circuit hashes
+
+**Returns**: ChainCircuits
+- The checked circuit parameters
+
+### fetchCircuits {#fetchCircuits}
+
+
+
+Fetches circuits for anonymous voting
+
+**Returns**: Promise<ChainCircuits>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|circuits|Omit<ChainCircuits, ('zKeyData'\|'vKeyData'\|'wasmData')>|✔️||Additional options for custom circuits|
+
+### setCircuits {#setCircuits}
+
+
+
+Sets circuits for anonymous voting
+
+**Returns**: Promise<ChainCircuits>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|circuits|ChainCircuits|||Custom circuits|
+
diff --git a/docs/sdk/AnonymousVote.mdx b/docs/sdk/AnonymousVote.mdx
new file mode 100644
index 000000000..753667aaf
--- /dev/null
+++ b/docs/sdk/AnonymousVote.mdx
@@ -0,0 +1,29 @@
+---
+custom_edit_url: null
+---
+
+```ts
+class AnonymousVote
+```
+
+
+
+## constructor
+```ts
+new AnonymousVote(votes, signature, password)
+```
+
+
+
+Constructs a csp vote
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|votes|Array<number \| TSBigIntKeyword>|||The list of votes values|
+|signature|string|✔️||The signature of the payload|
+|password|string|✔️|"0"|The password of the anonymous vote|
+
diff --git a/docs/sdk/ArchivedCensus.mdx b/docs/sdk/ArchivedCensus.mdx
new file mode 100644
index 000000000..6c7fcc8f5
--- /dev/null
+++ b/docs/sdk/ArchivedCensus.mdx
@@ -0,0 +1,33 @@
+---
+custom_edit_url: null
+---
+
+```ts
+class ArchivedCensus
+```
+
+
+
+Represents an archived census
+
+## constructor
+```ts
+new ArchivedCensus(censusId, censusURI, type, size, weight)
+```
+
+
+
+Constructs an archived census
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|censusId|string|||The id of the census|
+|censusURI|string|✔️||The URI of the census|
+|type|CensusType|✔️||The type of the census|
+|size|number|✔️||The size of the census|
+|weight|TSBigIntKeyword|✔️||The weight of the census|
+
diff --git a/docs/sdk/ArchivedElection.mdx b/docs/sdk/ArchivedElection.mdx
new file mode 100644
index 000000000..63fe58396
--- /dev/null
+++ b/docs/sdk/ArchivedElection.mdx
@@ -0,0 +1,29 @@
+---
+custom_edit_url: null
+---
+
+```ts
+class ArchivedElection
+```
+
+
+
+Represents a published election
+
+## constructor
+```ts
+new ArchivedElection(params)
+```
+
+
+
+Constructs an archived election
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|params|IPublishedElectionParameters|||Election parameters|
+
diff --git a/docs/sdk/Census3CensusAPI.mdx b/docs/sdk/Census3CensusAPI.mdx
index e06a572bc..d8875176d 100644
--- a/docs/sdk/Census3CensusAPI.mdx
+++ b/docs/sdk/Census3CensusAPI.mdx
@@ -12,7 +12,7 @@ class Census3CensusAPI
## constructor
@@ -57,20 +57,35 @@ Returns the information of the census
|url|string|||API endpoint URL|
|id|number|||The identifier of the census|
+### queue {#queue}
+
+
+
+Returns the information of the census queue
+
+**Returns**: Promise<ICensus3CensusQueueResponse>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|url|string|||API endpoint URL|
+|id|string|||The identifier of the census queue|
+
### create {#create}
-Requests the creation of a new census with the strategy provided for the blockNumber.
+Requests the creation of a new census with the strategy provided.
-**Returns**: Promise<ICensus3CensusCreateResponse>
-- promised ICensus3CensusCreateResponse
+**Returns**: Promise<ICensus3QueueResponse>
+- The queue identifier
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
|url|string|||API endpoint URL|
|strategyId|number|||The strategy identifier|
-|blockNumber|number|✔️||The number of the block|
+|anonymous|boolean|✔️|false|If the census has to be anonymous|
diff --git a/docs/sdk/Census3ServiceAPI.mdx b/docs/sdk/Census3ServiceAPI.mdx
new file mode 100644
index 000000000..75ed43f57
--- /dev/null
+++ b/docs/sdk/Census3ServiceAPI.mdx
@@ -0,0 +1,43 @@
+---
+custom_edit_url: null
+---
+
+```ts
+class Census3ServiceAPI
+```
+
+
+
+Fetches supported chains from the service
+
+**Returns**: Promise<ICensus3ServiceInfoResponse>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|url|string|||API endpoint URL|
+
diff --git a/docs/sdk/Census3StrategyAPI.mdx b/docs/sdk/Census3StrategyAPI.mdx
index 32e24fedf..cfc17c483 100644
--- a/docs/sdk/Census3StrategyAPI.mdx
+++ b/docs/sdk/Census3StrategyAPI.mdx
@@ -12,7 +12,7 @@ class Census3StrategyAPI
## constructor
@@ -35,13 +35,29 @@ Cannot be constructed.
Fetches list of strategies
+**Returns**: Promise<ICensus3StrategiesListResponsePaginated>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|url|string|||API endpoint URL|
+|pagination|Census3Pagination|✔️||Pagination options|
+
+### listByToken {#listByToken}
+
+
+
+Fetches list of strategies based on given token
+
**Returns**: Promise<ICensus3StrategiesListResponse>
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
|url|string|||API endpoint URL|
-|page|number|✔️|0|The page number|
-|token|string|✔️||The token id or address|
+|tokenId|string|||The identifier of the token|
+|chainId|number|||The chain identifier of the token|
+|externalId|string|✔️||The identifier used by external provider|
### strategy {#strategy}
@@ -51,13 +67,77 @@ Fetches list of strategies
Returns the information of the strategy
-**Returns**: Promise<ICensus3StrategyResponse>
+**Returns**: Promise<Census3Strategy>
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
|url|string|||API endpoint URL|
|id|number|||The identifier of the strategy|
+### estimation {#estimation}
+
+
+
+Returns the estimation of size and time (in milliseconds) to create the census generated for the provided strategy
+
+**Returns**: Promise<ICensus3QueueResponse>
+- The queue identifier
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|url|string|||API endpoint URL|
+|id|number|||The identifier of the strategy|
+|anonymous|boolean|✔️|false|If the estimation should be done for anonymous census|
+
+### estimationQueue {#estimationQueue}
+
+
+
+Returns the information of the strategy estimation queue
+
+**Returns**: Promise<ICensus3StrategyEstimationQueueResponse>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|url|string|||API endpoint URL|
+|strategyId|number|||The identifier of the strategy|
+|queueId|string|||The identifier of the strategy estimation queue|
+
+### importQueue {#importQueue}
+
+
+
+Returns the information of the strategy import queue
+
+**Returns**: Promise<ICensus3StrategyImportQueueResponse>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|url|string|||API endpoint URL|
+|queueId|string|||The identifier of the strategy import queue|
+
+### import {#import}
+
+
+
+Imports a strategy from IPFS from the given cid.
+
+**Returns**: Promise<ICensus3QueueResponse>
+- The queue identifier
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|url|string|||API endpoint URL|
+|cid|string|||The cid of the IPFS where the strategy is stored|
+
### create {#create}
-Triggers a new scan for the provided token, starting from the defined block.
+Triggers a new scan for the provided token.
**Returns**: Promise<IFileCIDResponse>
- promised IFileCIDResponse
@@ -86,6 +108,7 @@ Triggers a new scan for the provided token, starting from the defined block.
|url|string|||API endpoint URL|
|id|string|||The token address|
|type|string|||The type of the token|
-|startBlock|number|||The start block|
-|tag|Array<string>|✔️||The tags assigned for the token|
+|chainId|number|||The chain id of the token|
+|tags|Array<string>|✔️||The tags assigned for the token|
+|externalId|string|✔️||The identifier used by external provider|
diff --git a/docs/sdk/CensusAPI.mdx b/docs/sdk/CensusAPI.mdx
index 21dcfb205..e57548651 100644
--- a/docs/sdk/CensusAPI.mdx
+++ b/docs/sdk/CensusAPI.mdx
@@ -12,7 +12,7 @@ class CensusAPI
## constructor
@@ -94,6 +94,60 @@ Checks if the specified address is in the specified census
|censusId|string|||The census ID of which we want the proof from|
|key|string|||The address to be checked|
+### export {#export}
+
+
+
+Exports the given census identifier
+
+**Returns**: Promise<ICensusExportResponse>
+- on success
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|url|string|||API endpoint URL|
+|authToken|string|||Authentication token|
+|censusId|string|||The census ID we want to export|
+
+### import {#import}
+
+
+
+Imports data into the given census identifier
+
+**Returns**: Promise<void>
+- on success
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|url|string|||API endpoint URL|
+|authToken|string|||Authentication token|
+|censusId|string|||The census ID we want to export|
+|type|number|||The type of the census|
+|rootHash|string|||The root hash of the census|
+|data|string|||The census data to be imported|
+
+### delete {#delete}
+
+
+
+Deletes the given census
+
+**Returns**: Promise<void>
+- on success
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|url|string|||API endpoint URL|
+|authToken|string|||Authentication token|
+|censusId|string|||The census ID we want to export|
+
### size {#size}
@@ -107,7 +161,7 @@ Returns the size of a given census
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
|url|string|||API endpoint URL|
-|censusId|string|||The census ID of which we want the proof from|
+|censusId|string|||The census ID|
### weight {#weight}
@@ -122,5 +176,20 @@ Returns the weight of a given census
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
|url|string|||API endpoint URL|
-|censusId|string|||The census ID of which we want the proof from|
+|censusId|string|||The census ID|
+
+### type {#type}
+
+
+ static
+
+
+Returns the type of given census
+
+**Returns**: Promise<ICensusTypeResponse>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|url|string|||API endpoint URL|
+|censusId|string|||The census ID|
diff --git a/docs/sdk/CensusImportExport.mdx b/docs/sdk/CensusImportExport.mdx
new file mode 100644
index 000000000..44d961f26
--- /dev/null
+++ b/docs/sdk/CensusImportExport.mdx
@@ -0,0 +1,15 @@
+---
+custom_edit_url: null
+---
+
+
+
+
+
+|PROPERTY|TYPE|DESCRIPTION|
+|:---:|:---:|:---:|
+|type|number||
+|rootHash|string||
+|data|string||
+|maxLevels|number||
+
diff --git a/docs/sdk/OffchainCensusProof.mdx b/docs/sdk/CensusProof.mdx
similarity index 85%
rename from docs/sdk/OffchainCensusProof.mdx
rename to docs/sdk/CensusProof.mdx
index 5e4263e22..420823f9c 100644
--- a/docs/sdk/OffchainCensusProof.mdx
+++ b/docs/sdk/CensusProof.mdx
@@ -11,5 +11,4 @@ custom_edit_url: null
|weight|string||
|proof|string||
|value|string||
-|type|CensusProofType||
diff --git a/docs/sdk/CensusService.mdx b/docs/sdk/CensusService.mdx
new file mode 100644
index 000000000..447ff87b0
--- /dev/null
+++ b/docs/sdk/CensusService.mdx
@@ -0,0 +1,158 @@
+---
+custom_edit_url: null
+---
+
+```ts
+class CensusService
+```
+
+
+
+
+
+
+
+## constructor
+```ts
+new CensusService(params)
+```
+
+
+
+
+
+Instantiate the census service.
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|params|Partial<CensusServiceParameters>|||The service parameters|
+
+## Methods
+
+### get {#get}
+
+
+
+
+
+Fetches the information of a given census.
+
+**Returns**: Promise<{size: number, weight: bigint, type: CensusType}>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|censusId|string||||
+
+### delete {#delete}
+
+
+
+
+
+Deletes the given census.
+
+**Returns**: Promise<void>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|censusId|string||||
+
+### fetchProof {#fetchProof}
+
+
+ async
+
+
+Fetches proof that an address is part of the specified census.
+
+**Returns**: Promise<[CensusProof](CensusProof)>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|censusId|string|||Census we want to check the address against|
+|key|string|||The address to be found|
+
+### publish {#publish}
+
+
+
+
+
+Publishes the given census identifier.
+
+**Returns**: Promise<ICensusPublishResponse>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|censusId|string|||The census identifier|
+
+### export {#export}
+
+
+
+
+
+Exports the given census identifier.
+
+**Returns**: Promise<[CensusImportExport](CensusImportExport)>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|censusId|string|||The census identifier|
+
+### import {#import}
+
+
+
+
+
+Imports data into the given census identifier.
+
+**Returns**: Promise<ICensusImportResponse>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|censusId|string|||The census identifier|
+|data|[CensusImportExport](CensusImportExport)|||The census data|
+
+### createCensus {#createCensus}
+
+
+
+
+
+Publishes the given census.
+
+**Returns**: Promise<void>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|census|[PlainCensus](PlainCensus) \| [WeightedCensus](WeightedCensus)|||The census to be published.|
+
+### createCensusParallel {#createCensusParallel}
+
+
+
+
+
+Publishes the given census.
+
+**Returns**: Promise<void>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|census|[PlainCensus](PlainCensus) \| [WeightedCensus](WeightedCensus)|||The census to be published.|
+
+### fetchAccountToken {#fetchAccountToken}
+
+
+
+
+
+Fetches the specific account token auth and sets it to the current instance.
+
+**Returns**: Promise<void>
+
diff --git a/docs/sdk/ChainService.mdx b/docs/sdk/ChainService.mdx
new file mode 100644
index 000000000..7799e21c4
--- /dev/null
+++ b/docs/sdk/ChainService.mdx
@@ -0,0 +1,115 @@
+---
+custom_edit_url: null
+---
+
+```ts
+class ChainService
+```
+
+
+
+
+
+
+
+## constructor
+```ts
+new ChainService(params)
+```
+
+
+
+
+
+Instantiate the chain service.
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|params|Partial<ChainServiceParameters>|||The service parameters|
+
+## Methods
+
+### fetchChainData {#fetchChainData}
+
+
+
+
+
+Fetches blockchain information if needed.
+
+**Returns**: Promise<ChainData>
+
+### fetchChainCosts {#fetchChainCosts}
+
+
+
+
+
+Fetches blockchain costs information if needed.
+
+**Returns**: Promise<ChainCosts>
+
+### submitTx {#submitTx}
+
+
+
+
+
+Submits a transaction to the blockchain
+
+**Returns**: Promise<string>
+- The transaction hash
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|payload|string|||The transaction data payload|
+
+### txInfo {#txInfo}
+
+
+
+
+
+Fetches information about a transaction from the blockchain.
+
+**Returns**: Promise<ChainTx>
+- The chain transaction
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|txHash|string|||The transaction hash which we want to retrieve the info from|
+
+### dateToBlock {#dateToBlock}
+
+
+
+
+
+Returns the block number for a given date.
+
+**Returns**: Promise<number>
+- The block number
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|date|Date|||The date which we want to retrieve the block number from|
+
+### waitForTransaction {#waitForTransaction}
+
+
+
+
+
+A convenience method to wait for a transaction to be executed. It will
loop trying to get the transaction information, and will retry every time
it fails.
+
+**Returns**: Promise<void>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|tx|string|||Transaction to wait for|
+|wait|number|✔️||The delay in milliseconds between tries|
+|attempts|attempts|✔️||The attempts to try before failing|
+
diff --git a/docs/sdk/CspService.mdx b/docs/sdk/CspService.mdx
new file mode 100644
index 000000000..4b7e46540
--- /dev/null
+++ b/docs/sdk/CspService.mdx
@@ -0,0 +1,27 @@
+---
+custom_edit_url: null
+---
+
+```ts
+class CspService
+```
+
+
+
+
+
+## constructor
+```ts
+new CspService(params)
+```
+
+
+
+
+
+Instantiate the CSP service.
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|params|Partial<CspServiceParameters>|||The service parameters|
+
diff --git a/docs/sdk/ElectionAPI.mdx b/docs/sdk/ElectionAPI.mdx
index 8b28e723e..4f4f67017 100644
--- a/docs/sdk/ElectionAPI.mdx
+++ b/docs/sdk/ElectionAPI.mdx
@@ -12,7 +12,7 @@ class ElectionAPI
## constructor
@@ -73,6 +73,23 @@ Creates a new election.
|payload|string|||The set information info raw payload to be submitted to the chain|
|metadata|string|||The base64 encoded metadata JSON object|
+### nextElectionId {#nextElectionId}
+
+
+ static
+
+
+Returns the next election id.
+
+**Returns**: Promise<IElectionNextIdResponse>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|url|string|||API endpoint URL|
+|organizationId|string|||The identifier of the organization|
+|censusOrigin|number|||The census origin|
+|envelopeType|IVoteMode|✔️||The envelope type|
+
### votesCount {#votesCount}
diff --git a/docs/sdk/ElectionService.mdx b/docs/sdk/ElectionService.mdx
new file mode 100644
index 000000000..8c2e1bcef
--- /dev/null
+++ b/docs/sdk/ElectionService.mdx
@@ -0,0 +1,155 @@
+---
+custom_edit_url: null
+---
+
+```ts
+class ElectionService
+```
+
+
+
+
+
+
+
+## constructor
+```ts
+new ElectionService(params)
+```
+
+
+
+
+
+Instantiate the election service.
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|params|Partial<ElectionServiceParameters>|||The service parameters|
+
+## Methods
+
+### fetchElection {#fetchElection}
+
+
+ async
+
+
+Fetches info about an election.
+
+**Returns**: Promise<[UnpublishedElection](UnpublishedElection)>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|electionId|string|||The id of the election|
+
+### create {#create}
+
+
+
+
+
+Creates a new election.
+
+**Returns**: Promise<ElectionCreatedInformation>
+- The created election information
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|payload|string|||The set information info raw payload to be submitted to the chain|
+|metadata|string|||The base64 encoded metadata JSON object|
+
+### nextElectionId {#nextElectionId}
+
+
+
+
+
+Returns the next election id.
+
+**Returns**: Promise<string>
+- The next election identifier
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|address|string|||The address of the account|
+|election|[UnpublishedElection](UnpublishedElection)|||The unpublished election|
+
+### getElectionSalt {#getElectionSalt}
+
+
+
+
+
+Returns an election salt for address
+
+**Returns**: Promise<string>
+- The election salt
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|address|string|||The address of the account|
+|electionCount|number|||The election count|
+
+### getNumericElectionId {#getNumericElectionId}
+
+
+
+
+
+Returns a numeric election identifier
+
+**Returns**: number
+- The numeric identifier
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|electionId|string|||The identifier of the election|
+
+### keys {#keys}
+
+
+
+
+
+Fetches the encryption keys from the specified process.
+
+**Returns**: Promise<ElectionKeys>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|electionId|string|||The identifier of the election|
+
+### estimateElectionCost {#estimateElectionCost}
+
+
+
+
+
+Estimates the election cost
+
+**Returns**: Promise<number>
+- The cost in tokens.
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|election|[UnpublishedElection](UnpublishedElection)||||
+
+### calculateElectionCost {#calculateElectionCost}
+
+
+
+
+
+Calculate the election cost
+
+**Returns**: Promise<number>
+- The cost in tokens.
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|election|[UnpublishedElection](UnpublishedElection)||||
+
diff --git a/docs/sdk/FaucetAPI.mdx b/docs/sdk/FaucetAPI.mdx
index fa81c3364..ec45a99d7 100644
--- a/docs/sdk/FaucetAPI.mdx
+++ b/docs/sdk/FaucetAPI.mdx
@@ -33,13 +33,12 @@ Cannot be constructed.
static
-Calls the collect tokens method. Only works under development.
+Calls the collect tokens method.
**Returns**: Promise<IFaucetCollectResponse>
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
|url|string|||API endpoint URL|
-|authToken|string|||Authentication token|
|address|string|||Address to send the tokens to|
diff --git a/docs/sdk/FaucetOptions.mdx b/docs/sdk/FaucetOptions.mdx
index 13392ab58..a0ea7933d 100644
--- a/docs/sdk/FaucetOptions.mdx
+++ b/docs/sdk/FaucetOptions.mdx
@@ -10,7 +10,5 @@ Specify custom Faucet.
|PROPERTY|TYPE|DESCRIPTION|
|:---:|:---:|:---:|
-|url|string||
-|auth_token|string \| null||
-|token_limit|number \| null||
+|token_limit|number||
diff --git a/docs/sdk/FaucetService.mdx b/docs/sdk/FaucetService.mdx
new file mode 100644
index 000000000..7cb42aadd
--- /dev/null
+++ b/docs/sdk/FaucetService.mdx
@@ -0,0 +1,63 @@
+---
+custom_edit_url: null
+---
+
+```ts
+class FaucetService
+```
+
+
+
+
+
+
+
+## constructor
+```ts
+new FaucetService(params)
+```
+
+
+
+
+
+Instantiate the chain service.
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|params|Partial<FaucetServiceParameters>|||The service parameters|
+
+## Methods
+
+### fetchPayload {#fetchPayload}
+
+
+
+
+
+Fetches a faucet payload. Only for development.
+
+**Returns**: Promise<{string}>
+- The encoded faucet package
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|address|string|||The address where to send the tokens|
+
+### parseFaucetPackage {#parseFaucetPackage}
+
+
+
+
+
+Parses a faucet package.
+
+**Returns**: [FaucetPackage](FaucetPackage)
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|faucetPackage|string||||
+
diff --git a/docs/sdk/FileService.mdx b/docs/sdk/FileService.mdx
new file mode 100644
index 000000000..f502ee26b
--- /dev/null
+++ b/docs/sdk/FileService.mdx
@@ -0,0 +1,49 @@
+---
+custom_edit_url: null
+---
+
+```ts
+class FileService
+```
+
+
+
+
+
+
+
+## constructor
+```ts
+new FileService(params)
+```
+
+
+
+
+
+Instantiate the election service.
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|params|Partial<FileServiceParameters>|||The service parameters|
+
+## Methods
+
+### calculateCID {#calculateCID}
+
+
+
+
+
+Fetches the CID expected for the specified data content.
+
+**Returns**: Promise<string>
+- Resulting CID
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|data|string|||The data of which we want the CID of|
+
diff --git a/docs/sdk/Service.mdx b/docs/sdk/Service.mdx
new file mode 100644
index 000000000..7fc3c80fe
--- /dev/null
+++ b/docs/sdk/Service.mdx
@@ -0,0 +1,23 @@
+---
+custom_edit_url: null
+---
+
+```ts
+class Service
+```
+
+
+
+
+
+## constructor
+```ts
+new Service()
+```
+
+
+
+
+
+Cannot be constructed.
+
diff --git a/docs/sdk/Signing.mdx b/docs/sdk/Signing.mdx
index 225c2f1f8..e077f774a 100644
--- a/docs/sdk/Signing.mdx
+++ b/docs/sdk/Signing.mdx
@@ -39,8 +39,7 @@ Prefix and Sign a binary payload using the given Ethers wallet or signer.
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
-|messageBytes|Uint8Array||||
-|chainId|string|||The ID of the Vocdoni blockchain deployment for which the message is intended to|
+|message|string||||
|walletOrSigner|Wallet \| Signer||||
### signRaw {#signRaw}
diff --git a/docs/sdk/TokenCensus.mdx b/docs/sdk/TokenCensus.mdx
index 6ba0bc2a7..9c6018605 100644
--- a/docs/sdk/TokenCensus.mdx
+++ b/docs/sdk/TokenCensus.mdx
@@ -14,7 +14,7 @@ Represents a census3 census
## constructor
```ts
-new TokenCensus(censusId, censusURI, token, size, weight)
+new TokenCensus(censusId, censusURI, anonymous, token, size, weight)
```
@@ -27,6 +27,7 @@ Constructs a census3 census
|:---:|:---:|:---:|:---:|:---:|
|censusId|string|||The id of the census|
|censusURI|string|||The URI of the census|
+|anonymous|boolean|||If the census is anonymous|
|token|Token|||The token of the census|
|size|number|✔️||The size of the census|
|weight|TSBigIntKeyword|✔️||The weight of the census|
diff --git a/docs/sdk/TxWaitOptions.mdx b/docs/sdk/TxWaitOptions.mdx
index d878df5b1..135ac1d26 100644
--- a/docs/sdk/TxWaitOptions.mdx
+++ b/docs/sdk/TxWaitOptions.mdx
@@ -10,6 +10,6 @@ Specify custom retry times and attempts when waiting for a transaction.
|PROPERTY|TYPE|DESCRIPTION|
|:---:|:---:|:---:|
-|retry_time|number \| null||
-|attempts|number \| null||
+|retryTime|number||
+|attempts|number||
diff --git a/docs/sdk/VocdoniCensus3Client.mdx b/docs/sdk/VocdoniCensus3Client.mdx
index 2c963c2ec..0f69fc1ec 100644
--- a/docs/sdk/VocdoniCensus3Client.mdx
+++ b/docs/sdk/VocdoniCensus3Client.mdx
@@ -12,7 +12,7 @@ class VocdoniCensus3Client
## constructor
@@ -38,11 +38,22 @@ Instantiate new VocdoniCensus3 client.
To instantiate the client just
-Returns a list of summarized tokens supported by the service
+Returns a list of summary tokens supported by the service
**Returns**: Promise<Array<TokenSummary>>
- Token summary list
+### getSupportedChains {#getSupportedChains}
+
+
+
+
+
+Returns a list of supported chain identifiers
+
+**Returns**: Promise<Array<SupportedChain>>
+- Supported chain list
+
### getSupportedTypes {#getSupportedTypes}
@@ -54,6 +65,17 @@ Returns a list of supported tokens type
**Returns**: Promise<Array<string>>
- Supported tokens type list
+### getSupportedOperators {#getSupportedOperators}
+
+
+
+
+
+Returns a list of supported strategies operators
+
+**Returns**: Promise<Array<SupportedOperator>>
+- Supported strategies operators list
+
### getToken {#getToken}
@@ -68,6 +90,26 @@ Returns the full token information based on the id (address)
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
|id|string|||The id (address) of the token|
+|chainId|number|||The id of the chain|
+|externalId|string|✔️||The identifier used by external provider|
+
+### isHolderInToken {#isHolderInToken}
+
+
+
+
+
+Returns if the holder ID is already registered in the database as a holder of the token.
+
+**Returns**: Promise<Token>
+- The token information
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|tokenId|string|||The id (address) of the token|
+|chainId|number|||The id of the chain|
+|holderId|string|||The identifier of the holder|
+|externalId|string|✔️||The identifier used by external provider|
### createToken {#createToken}
@@ -83,38 +125,37 @@ Creates a new token to be tracked in the service
|:---:|:---:|:---:|:---:|:---:|
|address|string|||The address of the token|
|type|string|||The type of the token|
+|chainId|number|✔️|1|The chain id of the token|
+|externalId|string|✔️|""|The identifier used by external provider|
|tags|string|✔️|[]|The tag list to associate the token with|
-|startBlock|string|✔️|0|The start block where to start scanning|
-### getStrategiesList {#getStrategiesList}
+### getStrategies {#getStrategies}
-Returns the strategies identifiers list
+Returns the strategies
-**Returns**: Promise<Array<number>>
-- The list of strategies identifiers
-
-|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
-|:---:|:---:|:---:|:---:|:---:|
-|options|{page?: number, token?: string}|✔️|||
+**Returns**: Promise<Array<Census3Strategy>>
+- The list of strategies
-### getStrategies {#getStrategies}
+### getStrategiesByToken {#getStrategiesByToken}
-Returns the strategies list
+Returns the strategies from the given token
-**Returns**: Promise<Array<Strategy>>
+**Returns**: Promise<Array<Census3Strategy>>
- The list of strategies
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
-|options|{page?: number, token?: string}|✔️|||
+|id|string|||The id (address) of the token|
+|chainId|number|||The id of the chain|
+|externalId|string|✔️||The identifier used by external provider|
### getStrategy {#getStrategy}
@@ -131,6 +172,22 @@ Returns the information of the strategy based on the id
|:---:|:---:|:---:|:---:|:---:|
|id|number|||The id of the strategy|
+### getStrategyEstimation {#getStrategyEstimation}
+
+
+
+
+
+Returns the estimation of size and time (in milliseconds) to create the census generated for the provided strategy
+
+**Returns**: Promise<Strategy>
+- The strategy estimation
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|id|number|||The id of the strategy|
+|anonymous|boolean|✔️|false|If the estimation should be done for anonymous census|
+
### createStrategy {#createStrategy}
@@ -144,23 +201,39 @@ Creates a new strategy based on the given tokens and predicate
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
-|tokens|Array<{id: string, name: string, minBalance: string, method: string}>||||
-|strategy|string|||The strategy predicate|
+|alias|string|||The alias of the strategy|
+|predicate|string|||The predicate of the strategy|
+|tokens|{[key: string]: StrategyToken}|||The token list for the strategy|
-### getCensusesList {#getCensusesList}
+### importStrategy {#importStrategy}
-Returns the census3 censuses identifiers list
+Imports a strategy from IPFS from the given cid.
-**Returns**: Promise<Array<number>>
-- The list of census3 censuses identifiers
+**Returns**: Promise<Strategy>
+- The strategy information
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
-|options|{strategyId?: number}|✔️|||
+|cid|number|||The IPFS cid of the strategy to import|
+
+### validatePredicate {#validatePredicate}
+
+
+
+
+
+Validates a predicate
+
+**Returns**: Promise<ParsedPredicate>
+- The parsed predicate
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|predicate|string|||The predicate of the strategy|
### getCensuses {#getCensuses}
@@ -168,14 +241,14 @@ Returns the census3 censuses identifiers list
-Returns the census3 censuses list
+Returns the census3 censuses
-**Returns**: Promise<Array<Census3Census>>
+**Returns**: Promise<Array<number>>
- The list of census3 censuses
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
-|options|{strategyId?: number}|✔️|||
+|strategyId|string|||The strategy identifier|
### getCensus {#getCensus}
@@ -200,13 +273,13 @@ Returns the census3 census based on the given identifier
Creates the census based on the given strategy
-**Returns**: Promise<number>
-- The id of the census
+**Returns**: Promise<Census3Census>
+- The census information
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
|strategyId|number|||The id of the strategy|
-|blockNumber|number|✔️||The block number|
+|anonymous|boolean|✔️|false|If the census has to be anonymous|
### createTokenCensus {#createTokenCensus}
@@ -214,7 +287,7 @@ Creates the census based on the given strategy
async
-Returns the actual census based on the given token
+Returns the actual census based on the given token using the default strategy set
**Returns**: Promise<[TokenCensus](TokenCensus)>
- The token census
@@ -222,4 +295,7 @@ Returns the actual census based on the given token
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
|address|string|||The address of the token|
+|chainId|number|||The id of the chain|
+|anonymous|boolean|✔️|false|If the census has to be anonymous|
+|externalId|string|✔️||The identifier used by external provider|
diff --git a/docs/sdk/VocdoniSDKClient.mdx b/docs/sdk/VocdoniSDKClient.mdx
index 9c698d349..5ad56e3cb 100644
--- a/docs/sdk/VocdoniSDKClient.mdx
+++ b/docs/sdk/VocdoniSDKClient.mdx
@@ -14,7 +14,7 @@ Main Vocdoni client object. It's a wrapper for all the methods in api, core
-
+
## constructor
@@ -60,65 +60,6 @@ Sets an election id. Required by other methods like submitVote or createElection
|:---:|:---:|:---:|:---:|:---:|
|electionId|string|||Election id string|
-### fetchChainId {#fetchChainId}
-
-
-
-
-
-Fetches blockchain information if needed and returns the chain id.
-
-**Returns**: Promise<string>
-
-### fetchChainCosts {#fetchChainCosts}
-
-
-
-
-
-Fetches blockchain costs information if needed.
-
-**Returns**: Promise<ChainCosts>
-
-### checkCircuitsHashes {#checkCircuitsHashes}
-
-
-
-
-
-Checks circuit hashes
-
-**Returns**: ChainCircuits
-- The checked circuit parameters
-
-### setCircuits {#setCircuits}
-
-
-
-
-
-Sets circuits for anonymous voting
-
-**Returns**: Promise<ChainCircuits>
-
-|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
-|:---:|:---:|:---:|:---:|:---:|
-|circuits|ChainCircuits|||Custom circuits|
-
-### fetchCircuits {#fetchCircuits}
-
-
-
-
-
-Fetches circuits for anonymous voting
-
-**Returns**: Promise<ChainCircuits>
-
-|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
-|:---:|:---:|:---:|:---:|:---:|
-|circuits|Omit<ChainCircuits, ('zKeyData'\|'vKeyData'\|'wasmData')>|✔️||Additional options for custom circuits|
-
### fetchAccountInfo {#fetchAccountInfo}
@@ -127,60 +68,25 @@ Fetches circuits for anonymous voting
Fetches account information.
-**Returns**: Promise<[AccountData](AccountData)>
+**Returns**: Promise<(AccountData\|ArchivedAccountData)>
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
|address|string|✔️||The account address to fetch the information|
-### calculateCID {#calculateCID}
-
-
-
-
-
-Fetches the CID expected for the specified data content.
-
-**Returns**: Promise<string>
-- Resulting CID
-
-|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
-|:---:|:---:|:---:|:---:|:---:|
-|data|string|||The data of which we want the CID of|
-
-### fetchFaucetPayload {#fetchFaucetPayload}
-
-
-
-
-
-Fetches a faucet payload. Only for development.
-
-**Returns**: Promise<{string}>
-
-### parseFaucetPackage {#parseFaucetPackage}
+### fetchAccount {#fetchAccount}
-
+ async
-Parses a faucet package.
+Fetches account.
-**Returns**: [FaucetPackage](FaucetPackage)
+**Returns**: Promise<[AccountData](AccountData)>
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
-|faucetPackage|string||||
-
-### fetchAccountToken {#fetchAccountToken}
-
-
-
-
-
-Fetches the specific account token auth and sets it to the current instance.
-
-**Returns**: Promise<void>
+|address|string|✔️||The account address to fetch the information|
### fetchElection {#fetchElection}
@@ -190,58 +96,43 @@ Fetches the specific account token auth and sets it to the current instance.
Fetches info about an election.
-**Returns**: Promise<[UnpublishedElection](UnpublishedElection)>
+**Returns**: Promise<(PublishedElection\|ArchivedElection)>
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
|electionId|string|✔️||The id of the election|
-### waitForTransaction {#waitForTransaction}
+### fetchProofForWallet {#fetchProofForWallet}
-A convenience method to wait for a transaction to be executed. It will
loop trying to get the transaction information, and will retry every time
it fails.
-
-**Returns**: Promise<void>
-
-|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
-|:---:|:---:|:---:|:---:|:---:|
-|tx|string|||Transaction to wait for|
-|wait|number|✔️||The delay in milliseconds between tries|
-|attempts|attempts|✔️||The attempts to try before failing|
-
-### fetchProof {#fetchProof}
-
-
- async
-
-
Fetches proof that an address is part of the specified census.
-**Returns**: Promise<[OffchainCensusProof](OffchainCensusProof)>
+**Returns**: Promise<[CensusProof](CensusProof)>
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
-|censusId|string|||Census we want to check the address against|
-|key|string|||The address to be found|
-|type|CensusProofType|||Type of census|
+|censusId|string||||
+|wallet|Wallet \| Signer||||
-### fetchProofForWallet {#fetchProofForWallet}
+### calcZKProofForWallet {#calcZKProofForWallet}
-
+ async
-Fetches proof that an address is part of the specified census.
+Calculates ZK proof from given wallet.
-**Returns**: Promise<[OffchainCensusProof](OffchainCensusProof)>
+**Returns**: Promise<ZkProof>
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
|election|[PublishedElection](PublishedElection)||||
|wallet|Wallet \| Signer||||
+|signature|string||||
+|password|string|✔️|"0"||
### createAccountInfo {#createAccountInfo}
@@ -283,7 +174,7 @@ Updates an account with information
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
-|promAccountData|Promise<{tx: Uint8Array, metadata: string}>||||
+|promAccountData|Promise<{tx: Uint8Array, metadata: string, message: string}>||||
### createAccount {#createAccount}
@@ -299,55 +190,60 @@ Registers an account against vochain, so it can create new elections.
|:---:|:---:|:---:|:---:|:---:|
|options|Object|✔️||Additional
options, like extra information of the account, or the faucet package string|
-### collectFaucetTokens {#collectFaucetTokens}
+### sendTokens {#sendTokens}
-Calls the faucet to get new tokens. Only under development.
+Send tokens from one account to another.
-**Returns**: Promise<[AccountData](AccountData)>
-- Account data information updated with new balance
+**Returns**: Promise<void>
-### createCensus {#createCensus}
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|options|SendTokensOptions|||Options for send tokens|
+
+### collectFaucetTokens {#collectFaucetTokens}
-Publishes the given census.
+Calls the faucet to get new tokens. Only under development.
-**Returns**: Promise<void>
+**Returns**: Promise<[AccountData](AccountData)>
+- Account data information updated with new balance
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
-|census|[PlainCensus](PlainCensus) \| [WeightedCensus](WeightedCensus)|||The census to be published.|
+|faucetPackage|string|✔️||The faucet package|
-### fetchCensusInfo {#fetchCensusInfo}
+### createElection {#createElection}
-
+ async
-Fetches the information of a given census.
+Creates a new voting election.
-**Returns**: Promise<{size: number, weight: bigint}>
+**Returns**: Promise<string>
+- Resulting election id.
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
-|censusId|string||||
+|election|[UnpublishedElection](UnpublishedElection)|||The election object to be created.|
-### createElection {#createElection}
+### createElectionSteps {#createElectionSteps}
async
-Creates a new voting election.
+Creates a new voting election by steps with async returns.
-**Returns**: Promise<string>
-- Resulting election id.
+**Returns**: AsyncGenerator<ElectionCreationStepValue>
+- The async step returns.
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
@@ -452,13 +348,12 @@ Checks if the user is in census.
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
-|electionId|string|✔️||The id of the election|
-|key|Object|✔️||The key in the census to check|
+|options|HasAlreadyVotedOptions|✔️||Options for is in census|
### hasAlreadyVoted {#hasAlreadyVoted}
-
+ async
Checks if the user has already voted
@@ -468,7 +363,7 @@ Checks if the user has already voted
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
-|electionId|string|✔️||The id of the election|
+|options|HasAlreadyVotedOptions|✔️||Options for has already voted|
### isAbleToVote {#isAbleToVote}
@@ -482,7 +377,7 @@ Checks if the user is able to vote
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
-|electionId|string|✔️||The id of the election|
+|options|IsAbleToVoteOptions|✔️||Options for is able to vote|
### votesLeftCount {#votesLeftCount}
@@ -496,7 +391,7 @@ Checks how many times a user can submit their vote
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
-|electionId|string|✔️||The id of the election|
+|options|VotesLeftCountOptions|✔️||Options for votes left count|
### submitVote {#submitVote}
@@ -511,7 +406,7 @@ Submits a vote to the current instance election id.
|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
|:---:|:---:|:---:|:---:|:---:|
-|vote|[Vote](Vote) \| [CspVote](CspVote)|||The vote (or votes) to be sent.|
+|vote|[Vote](Vote) \| [CspVote](CspVote) \| [AnonymousVote](AnonymousVote)|||The vote (or votes) to be sent.|
### generateRandomWallet {#generateRandomWallet}
@@ -524,6 +419,97 @@ Assigns a random Wallet to the client and returns its private key.
**Returns**: string
- The private key.
+### fetchProof {#fetchProof}
+
+
+ async
+
+
+Fetches proof that an address is part of the specified census.
+
+**Returns**: Promise<[CensusProof](CensusProof)>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|censusId|string|||Census we want to check the address against|
+|key|string|||The address to be found|
+
+### createCensus {#createCensus}
+
+
+
+
+
+Publishes the given census.
+
+**Returns**: Promise<void>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|census|[PlainCensus](PlainCensus) \| [WeightedCensus](WeightedCensus)|||The census to be published.|
+
+### fetchCensusInfo {#fetchCensusInfo}
+
+
+
+
+
+Fetches the information of a given census.
+
+**Returns**: Promise<{size: number, weight: bigint}>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|censusId|string||||
+
+### fetchCircuits {#fetchCircuits}
+
+
+
+
+
+Fetches circuits for anonymous voting
+
+**Returns**: Promise<ChainCircuits>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|circuits|Omit<ChainCircuits, ('zKeyData'\|'vKeyData'\|'wasmData')>|✔️||Additional options for custom circuits|
+
+### setCircuits {#setCircuits}
+
+
+
+
+
+Sets circuits for anonymous voting
+
+**Returns**: Promise<ChainCircuits>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|circuits|ChainCircuits|||Custom circuits|
+
+### fetchChainCosts {#fetchChainCosts}
+
+
+
+
+
+Fetches blockchain costs information if needed.
+
+**Returns**: Promise<ChainCosts>
+
+### fetchChainId {#fetchChainId}
+
+
+
+
+
+Fetches blockchain information if needed and returns the chain id.
+
+**Returns**: Promise<string>
+
### estimateElectionCost {#estimateElectionCost}
@@ -554,3 +540,58 @@ Calculate the election cost
|:---:|:---:|:---:|:---:|:---:|
|election|[UnpublishedElection](UnpublishedElection)||||
+### calculateCID {#calculateCID}
+
+
+
+
+
+Fetches the CID expected for the specified data content.
+
+**Returns**: Promise<string>
+- Resulting CID
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|data|string|||The data of which we want the CID of|
+
+### fetchFaucetPayload {#fetchFaucetPayload}
+
+
+
+
+
+Fetches a faucet payload. Only for development.
+
+**Returns**: Promise<{string}>
+
+### parseFaucetPackage {#parseFaucetPackage}
+
+
+
+
+
+Parses a faucet package.
+
+**Returns**: [FaucetPackage](FaucetPackage)
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|faucetPackage|string|||The encoded faucet package|
+
+### waitForTransaction {#waitForTransaction}
+
+
+
+
+
+A convenience method to wait for a transaction to be executed. It will
loop trying to get the transaction information, and will retry every time
it fails.
+
+**Returns**: Promise<void>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|tx|string|||Transaction to wait for|
+|wait|number|✔️||The delay in milliseconds between tries|
+|attempts|attempts|✔️||The attempts to try before failing|
+
diff --git a/docs/sdk/VoteCore.mdx b/docs/sdk/VoteCore.mdx
index 5f3c26914..67839f578 100644
--- a/docs/sdk/VoteCore.mdx
+++ b/docs/sdk/VoteCore.mdx
@@ -41,5 +41,5 @@ Packages the given parameters into a proof that can be submitted to the Vochain
|:---:|:---:|:---:|:---:|:---:|
|electionId|string||||
|type|CensusType||||
-|censusProof|[OffchainCensusProof](OffchainCensusProof) \| [CspCensusProof](CspCensusProof)||||
+|censusProof|[CensusProof](CensusProof) \| [CspCensusProof](CspCensusProof) \| ZkProof||||
diff --git a/docs/sdk/VoteService.mdx b/docs/sdk/VoteService.mdx
new file mode 100644
index 000000000..534147c89
--- /dev/null
+++ b/docs/sdk/VoteService.mdx
@@ -0,0 +1,62 @@
+---
+custom_edit_url: null
+---
+
+```ts
+class VoteService
+```
+
+
+
+
+
+
+
+## constructor
+```ts
+new VoteService(params)
+```
+
+
+
+
+
+Instantiate the election service.
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|params|Partial<VoteServiceParameters>|||The service parameters|
+
+## Methods
+
+### info {#info}
+
+
+
+
+
+Get the vote information
+
+**Returns**: Promise<VoteInfo>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|voteId|string|||The identifier of the vote|
+
+### vote {#vote}
+
+
+
+
+
+Submit the vote to the chain
+
+**Returns**: Promise<VoteSubmit>
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|payload|string|||The base64 encoded vote transaction|
+
diff --git a/docs/sdk/ZkAPI.mdx b/docs/sdk/ZkAPI.mdx
new file mode 100644
index 000000000..5bb9037aa
--- /dev/null
+++ b/docs/sdk/ZkAPI.mdx
@@ -0,0 +1,61 @@
+---
+custom_edit_url: null
+---
+
+```ts
+class ZkAPI
+```
+
+
+
+
+
+
+
+## constructor
+```ts
+new ZkAPI()
+```
+
+
+
+
+
+Cannot be constructed.
+
+## Methods
+### proof {#proof}
+
+
+ static
+
+
+Returns the ZK proof on given address
+
+**Returns**: Promise<IZkProofResponse>
+- The ZK proof
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|url|string|||API endpoint URL|
+|key|string|||The address to be checked|
+
+### sik {#sik}
+
+
+ static
+
+
+Returns the SIK on given address
+
+**Returns**: Promise<IZkSIKResponse>
+- The ZK proof
+
+|PARAMETER|TYPE|OPTIONAL|DEFAULT|DESCRIPTION|
+|:---:|:---:|:---:|:---:|:---:|
+|url|string|||API endpoint URL|
+|key|string|||The address to be checked|
+
diff --git a/docs/sdk/changelog.md b/docs/sdk/changelog.md
index ee827758b..85f43bc83 100644
--- a/docs/sdk/changelog.md
+++ b/docs/sdk/changelog.md
@@ -7,6 +7,184 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Changed
+
+- Supported tokens from Census3 using `getSupportedTokens()` returns now a token summary.
+- Census3 `getStrategyEstimation` accepts `anonymous` flag and returns `accuracy` for anonymous censuses.
+
+### Fixed
+
+- Removed `nullifier` from vote package.
+
+### Added
+
+- Added `ArchivedAccountData` for dealing with archived accounts and new `fetchAccount` function in client.
+
+## [0.7.0] - 2023-12-13
+
+### Changed
+
+- Changed sha256 library from `@ethersproject/sha2` to `js-sha256` for web workers.
+- Using API endpoint for estimating blocks from dates when creating an election.
+- [**BREAKING**] Census3 `getStrategySize` function changed to `getStrategyEstimation` giving estimated time and size for the given strategy.
+
+## [0.6.1] - 2023-11-29
+
+### Added
+
+- New anonymous function `hasRegisteredSIK` for checking if a user has registered a SIK.
+
+### Fixed
+
+- Removed outliers from block times for avoiding block estimation issues.
+
+## [0.6.0] - 2023-11-28
+
+### Added
+
+- New election service functions `nextElectionId` and `getElectionSalt`.
+
+### Changed
+
+- [**BREAKING**] Refactored options for `isInCensus`, `hasAlreadyVoted`, `isAbleToVote` and `votesLeftCount`.
+- [**BREAKING**] New options for `AnonymousVote` which enable to add the user's signature.
+- [**BREAKING**] New internal anonymous flow when signature is given by the consumer.
+
+## [0.5.3] - 2023-11-28
+
+### Added
+
+- New account methods supported for listing, counting and checking account transfers in `AccountAPI`.
+
+### Fixed
+
+- Archived elections without census URI are now accepted.
+
+### Changed
+
+- Faucet options don't require `token_limit` anymore.
+
+## [0.5.2] - 2023-11-16
+
+### Fixed
+
+- Anonymous vote packages are no longer signed.
+
+## [0.5.1] - 2023-11-15
+
+### Fixed
+
+- Missing exported election type `ArchivedElection`.
+- Faucet errors correctly shown with message.
+
+## [0.5.0] - 2023-11-14
+
+### Changed
+
+- [**BREAKING**] New full integration for Census3 v2, using tokens, strategies and censuses.
+
+## [0.4.3] - 2023-11-09
+
+### Added
+
+- Support for archived elections with new election type `ArchivedElection` and with new census with type `ArchivedCensus`.
+
+## [0.4.2] - 2023-11-06
+
+### Changed
+
+- Removed faucet path from default URLs.
+- Updated `@vocdoni/proto` dependency to `1.15.4`.
+
+### Added
+
+- Import, export and delete census functionality in census service.
+- Added new election parameter `temporarySecretIdentity` for deleting temporary SIKs once election is finished.
+
+### Fixed
+
+- Fixed `ffjavascript` dependency to `0.2.59`.
+
+## [0.4.1] - 2023-10-24
+
+### Changed
+
+- Modified `dev`, `stg` and `prod` default URLs for all services.
+- Upgraded to new faucet.
+
+## [0.4.0] - 2023-10-10
+
+### Changed
+
+- [**BREAKING**] New signatures for chain transactions.
+
+## [0.3.2] - 2023-10-10
+
+### Added
+
+- Added support for uploading big censuses in chunks.
+
+### Fixed
+
+- Added `assert` as embedded in rollup configuration.
+
+## [0.3.1] - 2023-09-20
+
+### Added
+
+- New `createElectionSteps` function in client for using async generators and control creation flow.
+- New `sendTokens` function in client for transferring tokens between accounts.
+
+### Changed
+
+- New user-friendly text for SIK payload signing.
+
+### Fixed
+
+- Added `ethers` as embedded in rollup configuration for `circomlibjs` dependencies.
+
+## [0.3.0] - 2023-09-13
+
+### Fixed
+
+- Ensuring proof `value` handled as hex for anonymous circuits inputs.
+
+### Changed
+
+- [**BREAKING**] Removed some (probably not used) client properties for future refactor.
+- Added services as mid-layer between pure SDK client and API wrappers.
+
+### Added
+
+- Census3 supported chains information.
+
+## [0.2.0] - 2023-09-04
+
+### Fixed
+
+- `dotobject` helper returns null when key is not found.
+
+### Changed
+
+- `collectFaucetTokens` function accepts raw faucet package payload.
+
+### Added
+
+- Census3 error typings.
+- [**BREAKING**] Census3 anonymous censuses.
+
+## [0.1.1] - 2023-08-14
+
+### Fixed
+
+- Added missing dependency `readable-stream`.
+
+## [0.1.0] - 2023-08-11
+
+### Added
+
+- [**BREAKING**] Anonymous integration
+
### Fixed
- Added missing `maxCensusSize` and `manuallyEnded` in `fetchElection`.
@@ -227,6 +405,23 @@ which extend from the abstract `Election` class.
- First unstable version of the SDK for testing purposes
+[0.7.0]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.7.0
+[0.6.1]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.6.1
+[0.6.0]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.6.0
+[0.5.3]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.5.3
+[0.5.2]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.5.2
+[0.5.1]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.5.1
+[0.5.0]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.5.0
+[0.4.3]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.4.3
+[0.4.2]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.4.2
+[0.4.1]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.4.1
+[0.4.0]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.4.0
+[0.3.2]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.3.2
+[0.3.1]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.3.1
+[0.3.0]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.3.0
+[0.2.0]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.2.0
+[0.1.1]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.1.1
+[0.1.0]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.1.0
[0.0.18]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.0.18
[0.0.17]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.0.17
[0.0.16]: https://github.com/vocdoni/vocdoni-sdk/releases/tag/v0.0.16
diff --git a/docs/sdk/sdk.md b/docs/sdk/sdk.md
index 3769240c6..8428db166 100644
--- a/docs/sdk/sdk.md
+++ b/docs/sdk/sdk.md
@@ -1,3 +1,18 @@
+
+
+
+
+
+
+![npm](https://img.shields.io/npm/v/%40vocdoni%2Fsdk)
+![GitHub commit activity (main)](https://img.shields.io/github/commit-activity/m/vocdoni/vocdoni-sdk)
+[![Example workflow](https://github.com/vocdoni/vocdoni-sdk/actions/workflows/examples.yml/badge.svg)](https://vocdoni.github.io/vocdoni-sdk/)
+![Main workflow](https://github.com/vocdoni/vocdoni-sdk/actions/workflows/main.yml/badge.svg)
+[![Join Discord](https://img.shields.io/badge/discord-join%20chat-blue.svg)](https://discord.gg/xFTh8Np2ga)
+[![Twitter Follow](https://img.shields.io/twitter/follow/vocdoni.svg?style=social&label=Follow)](https://twitter.com/vocdoni)
+
+
+
# Vocdoni SDK
The Vocdoni SDK is a convenient way to interact with the Vocdoni Protocol
@@ -547,9 +562,421 @@ const vote = client.cspVote(new Vote([index % 2]), signature);
const voteId = await client.submitVote(vote);
~~~
+## Census3
+
+### What is Census3?
+
+Census3 is an API service to create censuses for elections with holders of a single token or a combination of them.
+The service creates a list of holder addresses and balances and keeps it updated in real time, for every registered token.
+Then, it allows creating a merkle tree census (compatible with [Vocdoni](https://vocdoni.io/)) with those holders, using their balances as vote weights.
+
+More information about Census3 can be found [here](https://github.com/vocdoni/census3).
+
+### Using Census3
+
+The SDK comes with an implementation of the [Census3 API](https://github.com/vocdoni/census3/blob/main/api/README.md).
+
+#### Creating a Census3 client
+
+~~~ts
+const client = new VocdoniCensus3Client({
+ env: EnvOptions.DEV // dev environment
+})
+~~~
+
+#### Getting basic service information
+
+~~~ts
+// Get the supported chains
+const supportedChains = await client.getSupportedChains();
+// [
+// {
+// "chainID": 1,
+// "shortName": "eth",
+// "name": "Ethereum Mainnet"
+// },
+// {
+// "chainID": 5,
+// "shortName": "gor",
+// "name": "Goerli"
+// },
+// {
+// "chainID": 137,
+// "shortName": "matic",
+// "name": "Polygon Mainnet"
+// },
+// {
+// "chainID": 80001,
+// "shortName": "maticmum",
+// "name": "Mumbai"
+// }
+// ]
+~~~
+
+~~~ts
+// Get the supported token types
+const supportedTypes = await client.getSupportedTypes();
+// ["erc20", "erc777", "poap", "unknown", "erc721burned", "erc1155", "nation3", "want", "erc721"]
+~~~
+
+#### Getting tokens information and creating them
+
+~~~ts
+// Get the supported tokens
+const supportedTokens = await client.getSupportedTokens();
+// [
+// {
+// "ID": "0x0AaCfbeC6a24756c20D41914F2caba817C0d8521",
+// "type": "erc20",
+// "decimals": 18,
+// "startBlock": 10886913,
+// "symbol": "YAM",
+// "totalSupply": "",
+// "name": "YAM",
+// "status": {
+// "atBlock": 18565762,
+// "synced": true,
+// "progress": 100
+// },
+// "size": 14999,
+// "defaultStrategy": 19,
+// "chainID": 1,
+// "chainAddress": "eth:0x0AaCfbeC6a24756c20D41914F2caba817C0d8521"
+// },
+// {
+// "ID": "0x0b38210ea11411557c13457D4dA7dC6ea731B88a",
+// "type": "erc20",
+// "decimals": 18,
+// "startBlock": 11203771,
+// "symbol": "API3",
+// "totalSupply": "",
+// "name": "API3",
+// "status": {
+// "atBlock": 18565763,
+// "synced": true,
+// "progress": 100
+// },
+// "size": 51178,
+// "defaultStrategy": 8,
+// "chainID": 1,
+// "chainAddress": "eth:0x0b38210ea11411557c13457D4dA7dC6ea731B88a"
+// },
+// ...
+// ]
+~~~
+
+~~~ts
+// Get a token by its ID (address) and chain identifier
+const token = await client.getToken('0x0AaCfbeC6a24756c20D41914F2caba817C0d8521', 1);
+// {
+// "ID": "0x0AaCfbeC6a24756c20D41914F2caba817C0d8521",
+// "type": "erc20",
+// "decimals": 18,
+// "startBlock": 10886913,
+// "symbol": "YAM",
+// "totalSupply": "15164231312592159866595366",
+// "name": "YAM",
+// "status": {
+// "atBlock": 18565783,
+// "synced": true,
+// "progress": 100
+// },
+// "size": 14999,
+// "defaultStrategy": 19,
+// "chainID": 1,
+// "chainAddress": "eth:0x0AaCfbeC6a24756c20D41914F2caba817C0d8521",
+// "tags": []
+// }
+~~~
+
+~~~ts
+// Check if a holder is registered for a given token
+const token = await client.isHolderInToken(
+ '0x0AaCfbeC6a24756c20D41914F2caba817C0d8521',
+ 1,
+ '0x111000000000000000000000000000000000dEaD'
+);
+// false
+~~~
+
+~~~ts
+// Creates a new token by passing the address, the type and the chain identifier
+const token = await client.createToken('0xa117000000f279d81a1d3cc75430faa017fa5a2e', 'erc20', 1);
+~~~
+
+#### Getting strategies information and creating them
+
+~~~ts
+// Get the supported strategies
+const supportedStrategies = await client.getStrategies();
+// [
+// {
+// "ID": 1,
+// "alias": "Default strategy for token CRV",
+// "predicate": "CRV",
+// "uri": "ipfs://bafybeicjqjklqpumewpaue6weg47byz6fwmbg6ozief3w2pgqx7zlwl5ea",
+// "tokens": {
+// "CRV": {
+// "ID": "0xD533a949740bb3306d119CC777fa900bA034cd52",
+// "chainID": 1,
+// "minBalance": "0",
+// "chainAddress": "eth:0xD533a949740bb3306d119CC777fa900bA034cd52"
+// }
+// }
+// },
+// {
+// "ID": 2,
+// "alias": "Default strategy for token UNI",
+// "predicate": "UNI",
+// "uri": "ipfs://bafybeiesxbsbvp2agcuolezec6hvimntqdg3w43xs62mecdj2fyeh5anxu",
+// "tokens": {
+// "UNI": {
+// "ID": "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984",
+// "chainID": 1,
+// "minBalance": "0",
+// "chainAddress": "eth:0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"
+// }
+// }
+// },
+// ...
+// ]
+~~~
+
+~~~ts
+// Get the supported strategies by token and chain identifier
+const supportedStrategiesByToken = await client.getStrategiesByToken('0x0AaCfbeC6a24756c20D41914F2caba817C0d8521', 1);
+// [
+// {
+// "ID": 19,
+// "alias": "Default strategy for token YAM",
+// "predicate": "YAM",
+// "uri": "ipfs://bafybeicddxfktpcmbkvrflifbod6eeaizfab7l5ijggswnn5jwu3uhv4i4",
+// "tokens": {
+// "YAM": {
+// "ID": "0x0AaCfbeC6a24756c20D41914F2caba817C0d8521",
+// "chainID": 1,
+// "minBalance": "0",
+// "chainAddress": "eth:0x0AaCfbeC6a24756c20D41914F2caba817C0d8521"
+// }
+// }
+// },
+// {
+// "ID": 37,
+// "alias": "testStrategy_1699887257144",
+// "predicate": "(YAM OR API3) AND 1INCH",
+// "uri": "ipfs://bafybeic2gw6nb75ledp3jbz46rmdrnti33hgtlm5icfluxn5ol4enqps7i",
+// "tokens": {
+// "1INCH": {
+// "ID": "0x111111111117dC0aa78b770fA6A738034120C302",
+// "chainID": 1,
+// "minBalance": "50",
+// "chainAddress": "eth:0x111111111117dC0aa78b770fA6A738034120C302"
+// },
+// "API3": {
+// "ID": "0x0b38210ea11411557c13457D4dA7dC6ea731B88a",
+// "chainID": 1,
+// "minBalance": "0",
+// "chainAddress": "eth:0x0b38210ea11411557c13457D4dA7dC6ea731B88a"
+// },
+// "YAM": {
+// "ID": "0x0AaCfbeC6a24756c20D41914F2caba817C0d8521",
+// "chainID": 1,
+// "minBalance": "10000",
+// "chainAddress": "eth:0x0AaCfbeC6a24756c20D41914F2caba817C0d8521"
+// }
+// }
+// },
+// ...
+// ]
+~~~
+
+~~~ts
+// Get a strategy on a given identifier
+const strategy = await client.getStrategy(1);
+// {
+// "ID": 1,
+// "alias": "Default strategy for token CRV",
+// "predicate": "CRV",
+// "uri": "ipfs://bafybeicjqjklqpumewpaue6weg47byz6fwmbg6ozief3w2pgqx7zlwl5ea",
+// "tokens": {
+// "CRV": {
+// "ID": "0xD533a949740bb3306d119CC777fa900bA034cd52",
+// "chainID": 1,
+// "minBalance": "0",
+// "chainAddress": "eth:0xD533a949740bb3306d119CC777fa900bA034cd52"
+// }
+// }
+// }
+~~~
+
+~~~ts
+// Get strategy estimation information for creating census
+const size = await client.getStrategyEstimation(1);
+// {
+// "size": 5516,
+// "timeToCreateCensus": 3296,
+// "accuracy": 100
+// }
+~~~
+
+~~~ts
+// Creates a new strategy by passing the alias, the predicate and the tokens information
+const strategyId = await client.createStrategy('test_strategy', '(wANT OR ANT) AND USDC', {
+ "wANT": {
+ "ID": "0x1324",
+ "chainID": 1,
+ "minBalance": "10000"
+ },
+ "ANT": {
+ "ID": "0x1324",
+ "chainID": 5,
+ },
+ "USDC": {
+ "ID": "0x1324",
+ "chainID": 1,
+ "minBalance": "50"
+ },
+});
+console.log(strategyId) // strategy identifier
+~~~
+
+~~~ts
+// Imports a strategy from IPFS by the given cid
+const strategy = await client.importStrategy('bafybeicjqjklqpumewpaue6weg47byz6fwmbg6ozief3w2pgqx7zlwl5ea');
+// {
+// "ID": 1,
+// "alias": "Default strategy for token CRV",
+// "predicate": "CRV",
+// "uri": "ipfs://bafybeicjqjklqpumewpaue6weg47byz6fwmbg6ozief3w2pgqx7zlwl5ea",
+// "tokens": {
+// "CRV": {
+// "ID": "0xD533a949740bb3306d119CC777fa900bA034cd52",
+// "chainID": 1,
+// "minBalance": "0",
+// "chainAddress": "eth:0xD533a949740bb3306d119CC777fa900bA034cd52"
+// }
+// }
+// }
+~~~
+
+~~~ts
+// Validates a predicate for a strategy and returns the parsed predicate in JSON
+const validatePredicate = await client.validatePredicate('1INCH AND (YAM OR API3)');
+// {
+// "result": {
+// "childs": {
+// "operator": "AND",
+// "tokens": [
+// {
+// "childs": {
+// "operator": "OR",
+// "tokens": [
+// {
+// "literal": "YAM"
+// },
+// {
+// "literal": "API3"
+// }
+// ]
+// }
+// },
+// {
+// "literal": "1INCH"
+// }
+// ]
+// }
+// }
+// }
+~~~
+
+~~~ts
+// Gets the supported predicate operators
+const operators = await client.getSupportedOperators();
+// [
+// {
+// "description": "AND logical operator that returns the common token holders between symbols with fixed balance to 1",
+// "tag": "AND"
+// },
+// {
+// "description": "AND:sum logical operator that returns the common token holders between symbols with the sum of their balances on both tokens",
+// "tag": "AND:sum"
+// },
+// {
+// "description": "AND:mul logical operator that returns the common token holders between symbols with the multiplication of their balances on both tokens",
+// "tag": "AND:mul"
+// },
+// ...
+// ]
+~~~
+
+#### Getting censuses information and creating them
+
+~~~ts
+// Get the supported censuses by strategy identifier
+const strategyID = 18;
+const censusesByStrategy = await client.getCensuses(strategyID);
+// [
+// {
+// "ID": 18569955180,
+// "strategyID": 18,
+// "merkleRoot": "9b1ac0ed374a66b781a22ec5e1b1382324adc0759662e1e6f85fc87f5a23407e",
+// "uri": "ipfs://bafybeihwz2mbkkphgs2ni5laymgtfokaskujg2qfqcvoxhkccbdqp6k7ly",
+// "size": 14999,
+// "weight": "81637958624197446065983341792",
+// "anonymous": false
+// },
+// {
+// "ID": 18569991180,
+// "strategyID": 18,
+// "merkleRoot": "ab1c003b923c4fec0b24f84893ddda8835fd3990904dc64f06c1fc0eadef402f",
+// "uri": "ipfs://bafybeig5jrzw7ayxb442evan4pwa4rfksznh3smyt4exyjkubet2u5ldjm",
+// "size": 14999,
+// "weight": "653103668993579568527866734336",
+// "anonymous": false
+// },
+// ...
+// ]
+~~~
+
+~~~ts
+// Get a census on a given identifier
+const census = await client.getCensus(18569955180);
+// {
+// "ID": 18569955180,
+// "strategyID": 18,
+// "merkleRoot": "9b1ac0ed374a66b781a22ec5e1b1382324adc0759662e1e6f85fc87f5a23407e",
+// "uri": "ipfs://bafybeihwz2mbkkphgs2ni5laymgtfokaskujg2qfqcvoxhkccbdqp6k7ly",
+// "size": 14999,
+// "weight": "1514939612264202552941935398517220938016694806267744586724593217517874",
+// "anonymous": false
+// }
+~~~
+
+~~~ts
+// Creates a new census by passing the strategy identifier
+const strategyID = 18;
+const census = await client.createCensus(strategyID);
+// {
+// "ID": 18570184180,
+// "strategyID": 18,
+// "merkleRoot": "542166dd4757904449e71d5c21058597ab4179f040ee1f9e7dd29eec622ca5ed",
+// "uri": "ipfs://bafybeifbhmytl6olebkdoas6uftj3ae5akutmji4io6k37ilzu5uli2nle",
+// "size": 14999,
+// "weight": "42801802051163230603042274301444096",
+// "anonymous": false
+// }
+~~~
+
+~~~ts
+// Creates a new census by passing the token address, using the default strategy and returns
+// an instance of `TokenCensus` which can be directly used as a census in the Vocdoni chain
+const census = await client.createTokenCensus('0x0AaCfbeC6a24756c20D41914F2caba817C0d8521', 1);
+console.log(typeof census); // TokenCensus
+~~~
+
## Examples
-You can find a [full featured CRA][example-cra] application with all the previous
+You can find a [full featured vite][example-vite] application with all the previous
steps in the [examples] folder. In that folder you'll also find a
[es modules example][example-esm], creating and voting an election process.
@@ -589,7 +1016,7 @@ This SDK is licensed under the [GNU Affero General Public License v3.0][license]
[election-lifecycle-states]: https://developer.vocdoni.io/get-started/intro#election-lifecycle-states
[election params interface]: https://github.com/vocdoni/vocdoni-sdk/blob/main/src/types/election/election.ts#23
[examples]: https://github.com/vocdoni/vocdoni-sdk/blob/main/examples
-[example-cra]: https://github.com/vocdoni/vocdoni-sdk/blob/main/examples/cra
+[example-vite]: https://github.com/vocdoni/vocdoni-sdk/blob/main/examples/vite-react-app
[example-esm]: https://github.com/vocdoni/vocdoni-sdk/blob/main/examples/esm
[quadratic voting example]: https://github.com/vocdoni/vocdoni-sdk/blob/main/examples/typescript/src/quadratic.ts
[quadratic voting documentation]: https://developer.vocdoni.io/protocol/ballot#quadratic-voting
diff --git a/docs/sdk/sidebars-api.js b/docs/sdk/sidebars-api.js
index 3f7de8ea3..ed542fa5c 100644
--- a/docs/sdk/sidebars-api.js
+++ b/docs/sdk/sidebars-api.js
@@ -9,6 +9,7 @@ module.exports = {
"sdk/CensusAPI",
"sdk/Census3API",
"sdk/Census3CensusAPI",
+ "sdk/Census3ServiceAPI",
"sdk/Census3StrategyAPI",
"sdk/Census3TokenAPI",
"sdk/ChainAPI",
@@ -18,13 +19,25 @@ module.exports = {
"sdk/FileAPI",
"sdk/VoteAPI",
"sdk/WalletAPI",
+ "sdk/ZkAPI",
"sdk/VocdoniCensus3Client",
"sdk/VocdoniSDKClient",
"sdk/AccountCore",
"sdk/ElectionCore",
"sdk/TransactionCore",
"sdk/VoteCore",
+ "sdk/AccountService",
+ "sdk/AnonymousService",
+ "sdk/CensusService",
+ "sdk/ChainService",
+ "sdk/CspService",
+ "sdk/ElectionService",
+ "sdk/FaucetService",
+ "sdk/FileService",
+ "sdk/Service",
+ "sdk/VoteService",
"sdk/Account",
+ "sdk/ArchivedCensus",
"sdk/Census",
"sdk/TokenCensus",
"sdk/CspCensus",
@@ -32,10 +45,12 @@ module.exports = {
"sdk/PlainCensus",
"sdk/PublishedCensus",
"sdk/WeightedCensus",
+ "sdk/ArchivedElection",
"sdk/Election",
"sdk/InvalidElection",
"sdk/PublishedElection",
"sdk/UnpublishedElection",
+ "sdk/AnonymousVote",
"sdk/CspVote",
"sdk/Vote",
"sdk/Asymmetric",
@@ -53,13 +68,14 @@ module.exports = {
"type": "category",
"label": "Typedef",
"items": [
+ "sdk/TxWaitOptions",
+ "sdk/ClientOptions",
"sdk/AccountData",
- "sdk/OffchainCensusProof",
+ "sdk/CensusProof",
+ "sdk/CensusImportExport",
"sdk/CspCensusProof",
- "sdk/FaucetPackage",
"sdk/FaucetOptions",
- "sdk/TxWaitOptions",
- "sdk/ClientOptions"
+ "sdk/FaucetPackage"
]
},
{