Problem
The JavaScript SDK currently has no high-level client for interacting with AnonVote. Although the project is structured around reusable packages, developers have no unified entry point for creating elections, casting votes, or verifying results.
Without a client abstraction, every application integrating AnonVote will need to manually wire together cryptographic primitives, request validation, payload serialization, and future network interactions. This duplicates logic across projects and increases the likelihood of inconsistent implementations.
A well-defined SDK should expose a small, intuitive API while hiding internal implementation details. It should become the primary interface developers use when building applications on top of AnonVote.
Solution
Implement an AnonVoteClient class that provides the public SDK interface.
The client should expose the following methods:
createElection()
Creates a new election object.
Accepts:
- title
- description
- available voting options
- start time
- end time
Returns a strongly typed election object.
castVote()
Accepts a ballot ID, vote option, and encryption key.
The client should:
- validate the vote
- encrypt the vote using
@anonvote/crypto
- return the encrypted payload ready for submission
verifyVote()
Accepts an encrypted payload and verifies it can be successfully decrypted and validated.
Returns a boolean indicating whether the payload is valid.
serialize()
Converts SDK objects into JSON-safe payloads suitable for APIs or blockchain transactions.
deserialize()
Reconstructs SDK objects from serialized payloads.
TypeScript Types
Implement and export:
Election
Ballot
VoteReceipt
ClientConfig
All public APIs must be fully typed with no implicit any values.
Tests
Add comprehensive unit tests covering:
- Election creation
- Invalid election data
- Vote casting
- Vote serialization
- Vote deserialization
- Successful verification
- Failed verification
- Type exports
- Public API exports
Target high test coverage for all client methods.
Acceptance Criteria
AnonVoteClient implemented
- All methods exported from the package entry point
- Fully typed public API
- Integrates with
@anonvote/crypto
- Complete unit test coverage
- Package builds successfully using TypeScript
- Public API documented with JSDoc comments
Note for contributors
This client is intended to be the primary developer interface for the AnonVote ecosystem. Keep the API minimal, consistent, and framework-agnostic. Avoid introducing runtime dependencies unless absolutely necessary.
Problem
The JavaScript SDK currently has no high-level client for interacting with AnonVote. Although the project is structured around reusable packages, developers have no unified entry point for creating elections, casting votes, or verifying results.
Without a client abstraction, every application integrating AnonVote will need to manually wire together cryptographic primitives, request validation, payload serialization, and future network interactions. This duplicates logic across projects and increases the likelihood of inconsistent implementations.
A well-defined SDK should expose a small, intuitive API while hiding internal implementation details. It should become the primary interface developers use when building applications on top of AnonVote.
Solution
Implement an
AnonVoteClientclass that provides the public SDK interface.The client should expose the following methods:
createElection()
Creates a new election object.
Accepts:
Returns a strongly typed election object.
castVote()
Accepts a ballot ID, vote option, and encryption key.
The client should:
@anonvote/cryptoverifyVote()
Accepts an encrypted payload and verifies it can be successfully decrypted and validated.
Returns a boolean indicating whether the payload is valid.
serialize()
Converts SDK objects into JSON-safe payloads suitable for APIs or blockchain transactions.
deserialize()
Reconstructs SDK objects from serialized payloads.
TypeScript Types
Implement and export:
ElectionBallotVoteReceiptClientConfigAll public APIs must be fully typed with no implicit
anyvalues.Tests
Add comprehensive unit tests covering:
Target high test coverage for all client methods.
Acceptance Criteria
AnonVoteClientimplemented@anonvote/cryptoNote for contributors
This client is intended to be the primary developer interface for the AnonVote ecosystem. Keep the API minimal, consistent, and framework-agnostic. Avoid introducing runtime dependencies unless absolutely necessary.