@bitsocial/pubsub-voting 0.4.0 → 0.4.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 +6 -2
- package/dist/client/voter.d.ts +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,6 +28,10 @@ This library does not start its own node. It consumes the host's running Helia n
|
|
|
28
28
|
|
|
29
29
|
See [DESIGN.md](./DESIGN.md) for the full rationale, including how this resists vote-dropping and how criteria upgrades fork cleanly.
|
|
30
30
|
|
|
31
|
+
## Research
|
|
32
|
+
|
|
33
|
+
- [Token-gated ephemeral boards](./docs/research/token-gated-ephemeral-boards.md) explores an adjacent, ownerless discussion protocol derived from on-chain assets. It is research rather than part of this library's roadmap or wire format.
|
|
34
|
+
|
|
31
35
|
## Usage
|
|
32
36
|
|
|
33
37
|
The library never starts a node and never takes a host SDK (there is no `pkc` argument). A host passes its own running Helia node in directly and injects its seams into a single `PubsubVoter`:
|
|
@@ -76,7 +80,7 @@ Construction throws `MissingPubsubError`, `MissingBlockstoreError`, or `MissingF
|
|
|
76
80
|
|
|
77
81
|
### Read a tally reactively (no signer needed)
|
|
78
82
|
|
|
79
|
-
`createContest` mints a per-contest read object; `update()` starts syncing and it emits `update` (carrying a fresh `tally`) and `error`, just like a
|
|
83
|
+
`createContest` mints a per-contest read object; `update()` starts syncing and it emits `update` (carrying a fresh `tally`) and `error`, just like a pkc-js `community`:
|
|
80
84
|
|
|
81
85
|
```ts
|
|
82
86
|
const contest = await voter.createContest({ criteria }); // criteria: the contest's full document (strictly validated here)
|
|
@@ -136,7 +140,7 @@ Repeated `createContest` calls with byte-identical criteria return the same `Con
|
|
|
136
140
|
|
|
137
141
|
### Publish or withdraw a vote (needs a signer)
|
|
138
142
|
|
|
139
|
-
`createContestVote` mints a publishable ballot; `publish()` signs and broadcasts it once and emits `publishingstatechange`, like a
|
|
143
|
+
`createContestVote` mints a publishable ballot; `publish()` signs and broadcasts it once and emits `publishingstatechange`, like a pkc-js publication:
|
|
140
144
|
|
|
141
145
|
```ts
|
|
142
146
|
const vote = await voter.createContestVote({ criteria, votes: [{ community: { publicKey: "12D3KooW..." }, vote: 1 }] });
|
package/dist/client/voter.d.ts
CHANGED
|
@@ -21,16 +21,16 @@ import type { VoteSigner } from "../signer/types.js";
|
|
|
21
21
|
*/
|
|
22
22
|
export declare function republishIntervalBuckets(criteria: Criteria): number;
|
|
23
23
|
/**
|
|
24
|
-
* Public facade — three objects, mirroring pkc-js
|
|
24
|
+
* Public facade — three objects, mirroring pkc-js:
|
|
25
25
|
* - {@link PubsubVoter} (`VoteClient`): the factory. Holds the host-injected dependencies once
|
|
26
26
|
* and owns one engine per contest, keyed by topic. A contest is addressed by its full criteria
|
|
27
27
|
* document — `createContest({ criteria })` validates it and derives the topic — so a directory
|
|
28
28
|
* host like 5chan authors its 63 documents however it likes (e.g. merged from a local
|
|
29
29
|
* manifest) and creates each contest, without wiring dependencies 63 times.
|
|
30
30
|
* - {@link Contest} (`createContest`): one contest's reactive **read** view. `update()` starts
|
|
31
|
-
* syncing and emits `update` (carrying a fresh `tally`) / `error`, like `
|
|
31
|
+
* syncing and emits `update` (carrying a fresh `tally`) / `error`, like `community.update()`.
|
|
32
32
|
* - {@link ContestVote} (`createContestVote`): one publishable **ballot**. `publish()` signs and
|
|
33
|
-
* broadcasts it once, emitting `publishingstatechange` / `error`, like a
|
|
33
|
+
* broadcasts it once, emitting `publishingstatechange` / `error`, like a pkc publication.
|
|
34
34
|
*
|
|
35
35
|
* The injected seams (helia, chains, signer, nameResolvers) are the ONLY host contact surface, so
|
|
36
36
|
* the same core runs under pkc-js, plebbit, or a raw node. The host passes its running Helia node
|