Skip to main content

@vocdoni/sdk

Table of contents

Classes

Interfaces

Enumerations

Functions

Type Aliases

Variables

Functions

areEqualHexStrings

areEqualHexStrings(hex1?, hex2?): boolean

Compares two hex strings checking if they're the same. It ensures both have hex prefix and are lowercase.

Parameters

NameType
hex1?string
hex2?string

Returns

boolean

Defined in

util/common.ts:35


checkValidAccountMetadata

checkValidAccountMetadata(accountMetadata): AccountMetadata

Asserts that the given metadata is valid. Throws an exception if it is not.

Parameters

NameType
accountMetadataAccountMetadata

Returns

AccountMetadata

Defined in

types/metadata/account.ts:8


checkValidElectionMetadata

checkValidElectionMetadata(electionMetadata): ElectionMetadata

Asserts that the given metadata is valid. Throws an exception if it is not.

Parameters

NameType
electionMetadataElectionMetadata

Returns

ElectionMetadata

Defined in

types/metadata/election.ts:8


delay

delay(ms): Promise\<unknown>

Parameters

NameType
msany

Returns

Promise\<unknown>

Defined in

util/common.ts:6


dotobject

dotobject(obj, dot): any

Dot notation to object conversion. Takes any object as first argument and uses the string dot notation from the second argument (i.e. 'a.child.node') to access that given object value.

Parameters

NameTypeDescription
objanyObject to be accessed by dot notation
dotstringDot notation string to extract object data

Returns

any

Return the object data

Defined in

util/common.ts:60


ensure0x

ensure0x(value): string

Parameters

NameType
valuestring

Returns

string

Defined in

util/common.ts:12


formatUnits

formatUnits(value, decimals?): string

Returns a string representation of value formatted with decimals digits

Parameters

NameTypeDefault valueDescription
valueBigNumberishundefinedThe value in native BigInt
decimalsnumber18The number of decimals

Returns

string

The formatted string

Defined in

util/common.ts:48


getBytes

getBytes(count): Uint8Array

Parameters

NameType
countnumber

Returns

Uint8Array

Defined in

util/common.ts:16


getHex

getHex(): string

Generates a random seed and returns a 32 byte keccak256 hash of it (starting with "0x")

Returns

string

Defined in

util/common.ts:23


strip0x

strip0x(value): string

Parameters

NameType
valuestring

Returns

string

Defined in

util/common.ts:8

Type Aliases

AccountData

Ƭ AccountData: Object

Type declaration

NameType
accountAccount
addressstring
balancenumber
electionIndexnumber
infoURL?string
noncenumber
sik?string

Defined in

services/account.ts:25


AllElectionStatus

Ƭ AllElectionStatus: ElectionStatus | ElectionStatusReady

Defined in

types/election/published.ts:24


ArchivedAccountData

Ƭ ArchivedAccountData: Pick\<AccountData, "address" | "account">

Defined in

services/account.ts:35


Census3Census

Ƭ Census3Census: ICensus3CensusResponse

Defined in

census3.ts:31


Census3CreateStrategyToken

Ƭ Census3CreateStrategyToken: Omit\<Census3StrategyToken, "chainAddress">

Defined in

api/census3/strategy.ts:105


Census3Strategy

Ƭ Census3Strategy: Object

Type declaration

NameTypeDescription
IDnumberThe strategy identifier
aliasstringThe strategy alias
predicatestringThe strategy predicate
tokens{ [key: string]: Census3StrategyToken; }The list of tokens
uristringThe URI of the strategy

Defined in

api/census3/strategy.ts:46


Census3StrategyToken

Ƭ Census3StrategyToken: Object

Type declaration

NameTypeDescription
IDstringThe id (address) of the token.
chainAddressstringThe chain address of the token.
chainIDnumberThe chain id of the token.
externalID?stringThe external identifier of the token.
iconURI?stringThe token icon URI.
minBalance?stringThe minimum balance for the strategy.

Defined in

api/census3/strategy.ts:73


Census3SummaryToken

Ƭ Census3SummaryToken: Omit\<Census3Token, "status" | "size"> & { synced: boolean }

Defined in

api/census3/token.ts:12


Census3Token

Ƭ Census3Token: Object

Type declaration

NameTypeDescription
IDstringThe id (address) of the token.
chainAddressstringThe chain address of the token.
chainIDnumberThe chain id of the token.
decimalsnumberThe decimals of the token
defaultStrategynumberThe default strategy assigned.
externalID?stringThe external identifier of the token.
iconURI?stringThe icon URI of the token.
namestringThe name of the token.
sizenumberThe size (token holders) of the token.
startBlocknumberThe creation block.
status{ atBlock: number ; progress: number ; synced: boolean }The census3 status of the token.
status.atBlocknumberAt which number of block the token is synced
status.progressnumberThe progress percentage of the sync
status.syncedbooleanIf the token is already synced or not.
symbolstringThe symbol of the token.
tags?stringThe tags of the token.
totalSupplystringThe total supply of the token.
typestringThe type of the token.

Defined in

api/census3/token.ts:14


CensusImportExport

Ƭ CensusImportExport: Object

Type declaration

NameType
datastring
maxLevelsnumber
rootHashstring
typenumber

Defined in

services/census.ts:42


CensusProof

Ƭ CensusProof: Object

Type declaration

NameType
proofstring
rootstring
siblings?string[]
typeCensusType
valuestring
weightstring

Defined in

services/census.ts:26


ChainCircuits

Ƭ ChainCircuits: Object

Type declaration

NameType
vKeyDataUint8Array
vKeyHashstring
vKeyURIstring
wasmDataUint8Array
wasmHashstring
wasmURIstring
zKeyDataUint8Array
zKeyHashstring
zKeyURIstring

Defined in

services/anonymous.ts:51


ChainCosts

Ƭ ChainCosts: IChainGetCostsResponse

Defined in

services/chain.ts:14


ChainData

Ƭ ChainData: Object

Type declaration

NameType
blockTimenumber[]
blockTimestampnumber
chainIdstring
heightnumber
maxCensusSizenumber

Defined in

services/chain.ts:29


ChainTx

Ƭ ChainTx: IChainTxReference

Defined in

services/chain.ts:15


ClientOptions

Ƭ ClientOptions: Object

Optional VocdoniSDKClient arguments

Type declaration

NameType
api_url?string
electionId?string
envEnvOptions
faucet?Partial\<FaucetOptions>
tx_wait?TxWaitOptions
wallet?Wallet | Signer

Defined in

client.ts:86


CspCensusProof

Ƭ CspCensusProof: Object

Type declaration

NameType
addressstring
proof_type?CspProofType
signaturestring
type?number
weight?bigint

Defined in

services/census.ts:56


ElectionCreatedInformation

Ƭ ElectionCreatedInformation: IElectionCreateResponse

Defined in

services/election.ts:37


ElectionCreationStepValue

Ƭ ElectionCreationStepValue: { key: GET_CHAIN_DATA } | { key: CENSUS_CREATED } | { key: GET_ACCOUNT_DATA } | { key: GET_DATA_PIN } | { key: GENERATE_TX } | { key: SIGN_TX } | { key: CREATING ; txHash: string } | { electionId: string ; key: DONE }

Defined in

services/election.ts:50


ElectionIdOption

Ƭ ElectionIdOption: Object

Type declaration

NameType
electionIdstring

Defined in

types/client/account.ts:5


ElectionKeys

Ƭ ElectionKeys: IElectionKeysResponse

Defined in

services/election.ts:36


ElectionMeta

Ƭ ElectionMeta: AnyJson | JsonArray | JsonMap

Defined in

types/election/election.ts:101


ElectionResultsType

Ƭ ElectionResultsType: { name: SINGLE_CHOICE_MULTIQUESTION ; properties: {} } | { name: MULTIPLE_CHOICE ; properties: { abstainValues: string[] ; canAbstain: boolean ; repeatChoice: boolean } } | { name: BUDGET ; properties: { forceFullBudget: boolean ; maxBudget: number ; minStep: number ; useCensusWeightAsBudget: boolean } } | { name: APPROVAL ; properties: { acceptValue: number ; rejectValue: number } }

Defined in

types/metadata/election.ts:44


FaucetOptions

Ƭ FaucetOptions: FaucetServiceParameters

Defined in

services/faucet.ts:28


FaucetPackage

Ƭ FaucetPackage: Object

Type declaration

NameType
payloadstring
signaturestring

Defined in

services/faucet.ts:23


HasAlreadyVotedOptions

Ƭ HasAlreadyVotedOptions: Partial\<WalletOption & ElectionIdOption & VoteIdOption>

Defined in

types/client/account.ts:10


IAccountSummary

Ƭ IAccountSummary: Pick\<IAccountInfoResponse, "address" | "balance" | "nonce">

Defined in

api/account.ts:17


IBudgetElectionParameters

Ƭ IBudgetElectionParameters: IBudgetElectionParametersWithCensusWeight | IBudgetElectionParametersWithBudget

Defined in

types/election/budget.ts:21


IsAbleToVoteOptions

Ƭ IsAbleToVoteOptions: Partial\<WalletOption & ElectionIdOption & VoteIdOption>

Defined in

types/client/account.ts:12


IsInCensusOptions

Ƭ IsInCensusOptions: Partial\<WalletOption & ElectionIdOption>

Defined in

types/client/account.ts:9


ParsedPredicate

Ƭ ParsedPredicate: ICensus3ValidatePredicateResponse

Defined in

census3.ts:34


SendTokensOptions

Ƭ SendTokensOptions: Partial\<WalletOption> & { amount: number ; to: string }

Defined in

types/client/account.ts:8


Strategy

Ƭ Strategy: Census3Strategy

Defined in

census3.ts:27


StrategyHolder

Ƭ StrategyHolder: Object

Type declaration

NameType
holderstring
weightbigint

Defined in

census3.ts:28


StrategyHolders

Ƭ StrategyHolders: Object

Type declaration

NameType
holdersStrategyHolder[]
paginationCensus3Pagination

Defined in

census3.ts:29


StrategyToken

Ƭ StrategyToken: Census3CreateStrategyToken

Defined in

census3.ts:30


SupportedChain

Ƭ SupportedChain: ICensus3SupportedChain

Defined in

census3.ts:32


SupportedOperator

Ƭ SupportedOperator: ICensus3StrategiesOperator

Defined in

census3.ts:33


Token

Ƭ Token: Omit\<Census3Token, "tags"> & { tags: string[] }

Defined in

census3.ts:25


TokenSummary

Ƭ TokenSummary: Omit\<Census3SummaryToken, "tags"> & { tags: string[] }

Defined in

census3.ts:26


TxWaitOptions

Ƭ TxWaitOptions: Object

Specify custom retry times and attempts when waiting for a transaction.

Type declaration

NameType
attemptsnumber
retryTimenumber

Defined in

services/chain.ts:24


VoteIdOption

Ƭ VoteIdOption: Object

Type declaration

NameType
voteIdstring

Defined in

types/client/account.ts:6


VoteInfo

Ƭ VoteInfo: IVoteInfoResponse

Defined in

services/vote.ts:15


VoteStepValue

Ƭ VoteStepValue: { electionId: string ; key: GET_ELECTION } | { key: GET_PROOF } | { key: GET_SIGNATURE ; signature: string } | { key: CALC_ZK_PROOF } | { key: GENERATE_TX } | { key: SIGN_TX } | { key: DONE ; voteId: string }

Defined in

services/vote.ts:28


VoteSubmit

Ƭ VoteSubmit: IVoteSubmitResponse

Defined in

services/vote.ts:16


VotesLeftCountOptions

Ƭ VotesLeftCountOptions: Partial\<WalletOption & ElectionIdOption & VoteIdOption>

Defined in

types/client/account.ts:11


WalletOption

Ƭ WalletOption: Object

Type declaration

NameType
walletWallet | Signer

Defined in

types/client/account.ts:4


ZkProof

Ƭ ZkProof: Object

Type declaration

NameType
proof{ curve: string ; pi_a: string[] ; pi_b: string[][] ; pi_c: string[] ; protocol: string }
proof.curvestring
proof.pi_astring[]
proof.pi_bstring[][]
proof.pi_cstring[]
proof.protocolstring
publicSignalsstring[]

Defined in

services/anonymous.ts:23

Variables

AccountMetadataTemplate

Const AccountMetadataTemplate: AccountMetadata

Defined in

types/metadata/account.ts:67


ElectionMetadataTemplate

Const ElectionMetadataTemplate: ElectionMetadata

Defined in

types/metadata/election.ts:140

Resources

Guides
Soon

Tutorials
Soon

Copyright © 2024 Vocdoni, Inc. All rights reserved.