@inversealtruism/cairn-sdk 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 InverseAltruism
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,108 @@
1
+ # @inversealtruism/cairn-sdk
2
+
3
+ The **Compute Substrate dApp kit** — one cohesive toolkit for building apps on CSD. It composes everything in the Cairn ecosystem behind a single `Cairn` object:
4
+
5
+ | | |
6
+ |---|---|
7
+ | `cairn.wallet` | Connect the **Cairn Wallet**, sign things (clear-signed approvals). The key never leaves the extension. |
8
+ | `cairn.chain` | Node RPC + transaction builders + a verifying **light client** (re-exports the `csd-*` primitives). |
9
+ | `cairn.board` | The signal **board** + work graph. Reads are public; writes are wallet-signed. |
10
+ | `cairn.index` | The L2 **explorer/indexer**: REST + merkle proofs + live SSE/WS feeds. |
11
+ | `cairn.content` | **Self-certifying content** — publish via the board, fetch with client-side verification. |
12
+ | `cairn.registry` | L3 **peer / gateway / identity** resolution. |
13
+
14
+ ```bash
15
+ npm i @inversealtruism/cairn-sdk
16
+ ```
17
+
18
+ ## Quick start
19
+
20
+ ```ts
21
+ import { Cairn } from "@inversealtruism/cairn-sdk";
22
+
23
+ const cairn = new Cairn({ network: "mainnet" }); // defaults to cairn-substrate.com
24
+
25
+ // reads need no wallet
26
+ const top = await cairn.board.top({ domain: "csd:apps" });
27
+ const tip = await cairn.chain.tip();
28
+
29
+ // connect the user's wallet (browser) — prompts once, then "connected"
30
+ await cairn.connect();
31
+
32
+ // publish a board item, signed by the user's wallet (clear-signed approval)
33
+ const { txid } = await cairn.board.propose({
34
+ domain: "csd:apps",
35
+ title: "My dApp",
36
+ body: "Built with the Cairn SDK",
37
+ });
38
+
39
+ // watch it land, live
40
+ cairn.index.streamAll({ onProposal: (e) => console.log("new proposal", e) });
41
+ ```
42
+
43
+ ## How wallet connection works (and why it's safe)
44
+
45
+ The SDK follows the exact model MetaMask uses — there is **no allowlist you maintain**:
46
+
47
+ - **`connect()` / `getAddress()`** grant *address visibility*. The first time a site connects, the user approves once; after that the wallet answers silently (the site shows up under **Settings → Connected sites**, revocable anytime). This is the only "silent" call.
48
+ - **Every signing / fund-moving call** — `send`, `propose`, `attest`, `signIn`, `sealClaim`, `revealClaim` — **always** opens the wallet's clear-signing approval window, **every time**, no matter what. Being "connected" never pre-approves a signature. A connected site cannot move a satoshi without an explicit, fully-disclosed approval click.
49
+
50
+ ```ts
51
+ import { connect, UserRejectedError, NotInstalledError } from "@inversealtruism/cairn-sdk";
52
+
53
+ try {
54
+ const { wallet, address } = await connect();
55
+ await wallet.send({ to: "0x…", amount: 100_000_000 }); // 1 CSD — still prompts
56
+ } catch (e) {
57
+ if (e instanceof NotInstalledError) { /* tell the user to install the wallet */ }
58
+ if (e instanceof UserRejectedError) { /* they declined */ }
59
+ }
60
+ ```
61
+
62
+ ## API by namespace
63
+
64
+ **`cairn.board`** — `top()/board({domain,window})`, `item(id)`, `domains()`, `quests()/quest(id)`, `profile(addr)`, `leaderboard()`, `network()/networkSeries()/miner(addr)`, `activity()`, `wall()`; writes `propose({domain,title,body,links?,fee?})`, `support(id,{score?,confidence?,fee?})`.
65
+
66
+ **`cairn.index`** — `tipHeight()`, `block()/blockTxids()`, `tx()/txStatus()/txMerkleProof()`, `address()/addressTxs()/addressUtxo()`, `proposal()/attestations()`, `reputation()`, `registryPeers()/registryGateways()/identity()`, **`verifyInclusion(txid)`** (trust-minimized), `streamAll()/streamBlocks()/streamDomain()` (SSE), `subscribe()` (WS).
67
+
68
+ **`cairn.content`** — `prepare(obj)`/`put(obj)` → `{ payloadHash, canonical, bytes }`; `get(hash)` / `getBytes(hash)` (fetch **and verify** `sha256(bytes) === hash`, throws `ContentVerificationError` on tamper); `hash(obj)`.
69
+
70
+ **`cairn.chain`** — `tip()`, `utxos(addr)`, `submit(nodeJsonTx)`, `.client` (full `CsdClient`), `.light()` (verifying light client). The package also re-exports the primitives under the `/chain` subpath: `buildSend/buildPropose/buildAttest`, `signTx`, `keygen`, `payloadHash`, `verifyMerkleProof`, `LightClient`, etc.
71
+
72
+ **`cairn.registry`** — `gateways()`, `peers()`, `resolveName(handle)`, `reverseName(addr)`, `.fromRecords` (deterministic local resolvers).
73
+
74
+ Subpath imports are available for tree-shaking: `@inversealtruism/cairn-sdk/{connect,board,indexer,content,registry,chain}`.
75
+
76
+ ## Examples
77
+
78
+ - **`examples/read-only.mjs`** — runs today against live mainnet, no wallet, no build: `npm run test:live`. Demonstrates chain/board/indexer/registry reads + verified merkle inclusion + verified content fetch.
79
+ - **`examples/hello-csd/`** — a no-framework browser dApp (connect → read board → publish → live feed). Build the bundle with `npm run build:example`, then serve the folder from **localhost** (the wallet injects there) with the Cairn Wallet installed.
80
+
81
+ ## Trust model & honest limits
82
+
83
+ - **Content is always verified client-side.** `cairn.content.get()` rejects bytes that don't hash to the requested `payloadHash` — an untrusted gateway can't serve tampered content.
84
+ - **Merkle inclusion is trust-minimized.** `verifyInclusion()` folds the proof and cross-checks the root against the on-chain header merkle → `trustLevel: "verified-inclusion"`. Without that cross-check it reports `"proof-consistent"` (indexer trusted).
85
+ - **Balances are RPC-trusted.** Headers don't commit to the UTXO set; balance reads trust the node/proxy (same as every light client).
86
+ - **Indexer/swarm run behind the cairn proxy.** By default `cairn.index` and content resolution use the cairn server's hardened, read-only, rate-limited `/explorer/api` reverse proxy (no separate public indexer needed). **SSE works through it; `subscribe()` (WebSocket) needs a direct indexer endpoint** — set `baseUrls.indexer` to a private/localhost indexer for WS.
87
+ - **Today the wallet injects only on `cairn-substrate.com` + localhost.** Connecting from an arbitrary third-party origin requires the wallet's "connect anywhere" release (broadened injection), which ships after the per-origin consent layer is proven.
88
+
89
+ ## Configuration
90
+
91
+ ```ts
92
+ new Cairn({
93
+ network: "mainnet",
94
+ baseUrls: {
95
+ cairn: "https://cairn-substrate.com", // board + /api/rpc proxy + /content origin
96
+ rpc: "https://cairn-substrate.com/api/rpc", // node RPC (proxy)
97
+ indexer: "https://cairn-substrate.com/explorer/api",
98
+ swarm: undefined, // optional direct swarm gateway
99
+ },
100
+ fetch, // custom fetch (Node <18, tests)
101
+ timeoutMs: 15000,
102
+ WebSocketImpl, // for index.subscribe() in environments without global WebSocket
103
+ });
104
+ ```
105
+
106
+ ## License
107
+
108
+ MIT
package/dist/board.cjs ADDED
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/board.ts
21
+ var board_exports = {};
22
+ __export(board_exports, {
23
+ BoardClient: () => BoardClient
24
+ });
25
+ module.exports = __toCommonJS(board_exports);
26
+ var import_csd_codec = require("@inversealtruism/csd-codec");
27
+ var import_csd_codec2 = require("@inversealtruism/csd-codec");
28
+
29
+ // src/errors.ts
30
+ var CairnError = class extends Error {
31
+ constructor(message) {
32
+ super(message);
33
+ this.name = new.target.name;
34
+ }
35
+ };
36
+
37
+ // src/board.ts
38
+ var BoardClient = class {
39
+ http;
40
+ wallet;
41
+ constructor(http, wallet) {
42
+ this.http = http;
43
+ this.wallet = wallet;
44
+ }
45
+ requireWallet() {
46
+ if (!this.wallet) {
47
+ throw new CairnError("This action needs a connected wallet. Construct Cairn with a wallet, or call cairn.connect() first.");
48
+ }
49
+ return this.wallet;
50
+ }
51
+ // ---- reads (public) ----------------------------------------------------
52
+ /** Ranked board for a domain + time window. */
53
+ board(opts = {}) {
54
+ return this.http.getJson("/api/board", { domain: opts.domain ?? "all", window: opts.window ?? "all" });
55
+ }
56
+ /** Alias for `board()` — the top items. */
57
+ top(opts = {}) {
58
+ return this.board(opts);
59
+ }
60
+ /** A single item with its supports + pledges + integrity flag. */
61
+ item(id) {
62
+ return this.http.getJson(`/api/item/${encodeURIComponent(id)}`);
63
+ }
64
+ /** Known + discovered domains. */
65
+ domains() {
66
+ return this.http.getJson("/api/domains");
67
+ }
68
+ /** All quests (work-graph items). */
69
+ quests() {
70
+ return this.http.getJson("/api/quests");
71
+ }
72
+ /** A single quest with claims/submissions/payouts. */
73
+ quest(id) {
74
+ return this.http.getJson(`/api/quest/${encodeURIComponent(id)}`);
75
+ }
76
+ /** An address's on-chain-derived profile + identity + reputation. */
77
+ profile(addr, opts = {}) {
78
+ return this.http.getJson(`/api/profile/${encodeURIComponent(addr)}`, opts.live ? { live: 1 } : void 0);
79
+ }
80
+ /** Reputation leaderboard (top 50). */
81
+ leaderboard() {
82
+ return this.http.getJson("/api/leaderboard");
83
+ }
84
+ /** Network dashboard snapshot. */
85
+ network() {
86
+ return this.http.getJson("/api/network");
87
+ }
88
+ /** Network time-series for charts. */
89
+ networkSeries(range = "24h") {
90
+ return this.http.getJson("/api/network/series", { range });
91
+ }
92
+ /** Recent blocks with miner/reward. */
93
+ networkBlocks(limit = 15) {
94
+ return this.http.getJson("/api/network/blocks", { limit });
95
+ }
96
+ /** Per-miner hashrate estimate. */
97
+ miner(addr) {
98
+ return this.http.getJson(`/api/miner/${encodeURIComponent(addr)}`);
99
+ }
100
+ /** Recent activity feed. */
101
+ activity() {
102
+ return this.http.getJson("/api/activity");
103
+ }
104
+ /** The gamified cairn wall. */
105
+ wall() {
106
+ return this.http.getJson("/api/wall");
107
+ }
108
+ /** Server health + chain reachability. */
109
+ health() {
110
+ return this.http.getJson("/api/health");
111
+ }
112
+ // ---- writes (wallet-signed) -------------------------------------------
113
+ /**
114
+ * Publish a board item: compute the canonical payload hash, have the WALLET
115
+ * build/sign/submit the Propose (clear-signed approval), then register the
116
+ * off-chain content. The payload hash is byte-identical to what the cairn
117
+ * server verifies (csd-codec.payloadHash over { v:1, domain, title, body, links }).
118
+ */
119
+ async propose(input) {
120
+ const wallet = this.requireWallet();
121
+ const content = {
122
+ v: 1,
123
+ domain: input.domain,
124
+ title: input.title,
125
+ body: input.body ?? "",
126
+ links: input.links ?? []
127
+ };
128
+ const ph = (0, import_csd_codec.payloadHash)(content);
129
+ const uri = `cairn:v1:${ph.slice(2, 14)}`;
130
+ const lifetime = input.lifetimeEpochs ?? 720;
131
+ const height = await this.tipHeight();
132
+ const expiresEpoch = Math.floor(height / import_csd_codec2.EPOCH_LEN) + lifetime;
133
+ const fee = input.fee ?? import_csd_codec2.MIN_FEE_PROPOSE;
134
+ const r = await wallet.propose({ domain: content.domain, payloadHash: ph, uri, expiresEpoch, fee });
135
+ const txid = String(r.txid ?? "");
136
+ if (!txid) throw new CairnError("Propose submitted but no txid was returned by the wallet.");
137
+ const reg = await this.tryRegister(content, txid);
138
+ return { txid, payloadHash: ph, content, registered: reg.ok, registerError: reg.error };
139
+ }
140
+ /**
141
+ * Register off-chain content for an already-submitted proposal txid. Idempotent.
142
+ * Returns { ok } — the cairn server verifies sha256(canonical) == on-chain payload_hash.
143
+ */
144
+ async registerContent(content, txid) {
145
+ try {
146
+ const res = await this.http.postJson("/api/content", {
147
+ domain: content.domain,
148
+ title: content.title,
149
+ body: content.body,
150
+ links: content.links,
151
+ txid
152
+ });
153
+ return { ok: !!res.ok, error: res.ok ? void 0 : res.error };
154
+ } catch (e) {
155
+ return { ok: false, error: e instanceof Error ? e.message : String(e) };
156
+ }
157
+ }
158
+ /** Support/attest a proposal (wallet-signed; always clear-signed). */
159
+ async support(proposalId, opts = {}) {
160
+ const wallet = this.requireWallet();
161
+ return wallet.attest({
162
+ proposalId,
163
+ score: opts.score ?? 80,
164
+ confidence: opts.confidence ?? 70,
165
+ fee: opts.fee ?? import_csd_codec2.MIN_FEE_ATTEST
166
+ });
167
+ }
168
+ // ---- internal ----------------------------------------------------------
169
+ async tipHeight() {
170
+ const tip = await this.http.getJson("/api/rpc/tip");
171
+ const h = Number(tip?.height);
172
+ if (!Number.isFinite(h)) throw new CairnError("Could not read chain tip height for expiry computation.");
173
+ return h;
174
+ }
175
+ async tryRegister(content, txid) {
176
+ const delays = [0, 1500, 3e3, 5e3];
177
+ let last = { ok: false, error: "not attempted" };
178
+ for (const d of delays) {
179
+ if (d) await sleep(d);
180
+ last = await this.registerContent(content, txid);
181
+ if (last.ok) return last;
182
+ if (!/not found yet|not found/i.test(last.error ?? "")) return last;
183
+ }
184
+ return last;
185
+ }
186
+ };
187
+ function sleep(ms) {
188
+ return new Promise((r) => setTimeout(r, ms));
189
+ }
190
+ // Annotate the CommonJS export names for ESM import in node:
191
+ 0 && (module.exports = {
192
+ BoardClient
193
+ });
@@ -0,0 +1,151 @@
1
+ import { H as Http } from './http-D2CzfOsm.cjs';
2
+ import { WalletConnection, TxResult } from './connect.cjs';
3
+
4
+ type BoardWindow = "24h" | "7d" | "30d" | "all";
5
+ /** A ranked board item (loose — the server returns a rich object). */
6
+ interface RankedItem {
7
+ id: string;
8
+ title: string;
9
+ body: string;
10
+ domain: string;
11
+ proposer: string;
12
+ score: number;
13
+ totalWeight: number;
14
+ [k: string]: unknown;
15
+ }
16
+ interface BoardItemContent {
17
+ v: 1;
18
+ domain: string;
19
+ title: string;
20
+ body: string;
21
+ links: string[];
22
+ }
23
+ interface ProposeInput {
24
+ domain: string;
25
+ title: string;
26
+ body?: string;
27
+ links?: string[];
28
+ /** Fee in base units (default MIN_FEE_PROPOSE = 0.25 CSD). */
29
+ fee?: number;
30
+ /** Lifetime in epochs before expiry (default 720 ≈ 30 days, matching cairn). */
31
+ lifetimeEpochs?: number;
32
+ }
33
+ interface ProposeResult {
34
+ txid: string;
35
+ payloadHash: string;
36
+ content: BoardItemContent;
37
+ /** Whether the off-chain content was registered with the cairn origin yet. */
38
+ registered: boolean;
39
+ /** If registration is still pending, call `registerContent(content, txid)` again later. */
40
+ registerError?: string;
41
+ }
42
+ interface SupportInput {
43
+ /** 0–100 quality score (default 80). */
44
+ score?: number;
45
+ /** 0–100 confidence (default 70). */
46
+ confidence?: number;
47
+ /** Fee in base units (default MIN_FEE_ATTEST = 0.05 CSD). */
48
+ fee?: number;
49
+ }
50
+ declare class BoardClient {
51
+ private readonly http;
52
+ private readonly wallet?;
53
+ constructor(http: Http, wallet?: WalletConnection);
54
+ private requireWallet;
55
+ /** Ranked board for a domain + time window. */
56
+ board(opts?: {
57
+ domain?: string;
58
+ window?: BoardWindow;
59
+ }): Promise<{
60
+ window: string;
61
+ domain: string;
62
+ count: number;
63
+ items: RankedItem[];
64
+ }>;
65
+ /** Alias for `board()` — the top items. */
66
+ top(opts?: {
67
+ domain?: string;
68
+ window?: BoardWindow;
69
+ }): Promise<{
70
+ window: string;
71
+ domain: string;
72
+ count: number;
73
+ items: RankedItem[];
74
+ }>;
75
+ /** A single item with its supports + pledges + integrity flag. */
76
+ item(id: string): Promise<{
77
+ ok: boolean;
78
+ item: RankedItem;
79
+ supports: unknown[];
80
+ pledges: unknown[];
81
+ integrityOk: boolean;
82
+ }>;
83
+ /** Known + discovered domains. */
84
+ domains(): Promise<{
85
+ prefix: string;
86
+ total: number;
87
+ domains: unknown[];
88
+ discovered: unknown[];
89
+ }>;
90
+ /** All quests (work-graph items). */
91
+ quests(): Promise<{
92
+ count: number;
93
+ quests: unknown[];
94
+ }>;
95
+ /** A single quest with claims/submissions/payouts. */
96
+ quest(id: string): Promise<{
97
+ ok: boolean;
98
+ quest: unknown;
99
+ }>;
100
+ /** An address's on-chain-derived profile + identity + reputation. */
101
+ profile(addr: string, opts?: {
102
+ live?: boolean;
103
+ }): Promise<{
104
+ ok: boolean;
105
+ profile: unknown;
106
+ identity: unknown;
107
+ reputation: unknown;
108
+ }>;
109
+ /** Reputation leaderboard (top 50). */
110
+ leaderboard(): Promise<{
111
+ count: number;
112
+ leaderboard: unknown[];
113
+ }>;
114
+ /** Network dashboard snapshot. */
115
+ network(): Promise<unknown>;
116
+ /** Network time-series for charts. */
117
+ networkSeries(range?: "24h" | "1w" | "1m" | "all"): Promise<unknown>;
118
+ /** Recent blocks with miner/reward. */
119
+ networkBlocks(limit?: number): Promise<unknown>;
120
+ /** Per-miner hashrate estimate. */
121
+ miner(addr: string): Promise<unknown>;
122
+ /** Recent activity feed. */
123
+ activity(): Promise<{
124
+ activity: unknown[];
125
+ }>;
126
+ /** The gamified cairn wall. */
127
+ wall(): Promise<unknown>;
128
+ /** Server health + chain reachability. */
129
+ health(): Promise<unknown>;
130
+ /**
131
+ * Publish a board item: compute the canonical payload hash, have the WALLET
132
+ * build/sign/submit the Propose (clear-signed approval), then register the
133
+ * off-chain content. The payload hash is byte-identical to what the cairn
134
+ * server verifies (csd-codec.payloadHash over { v:1, domain, title, body, links }).
135
+ */
136
+ propose(input: ProposeInput): Promise<ProposeResult>;
137
+ /**
138
+ * Register off-chain content for an already-submitted proposal txid. Idempotent.
139
+ * Returns { ok } — the cairn server verifies sha256(canonical) == on-chain payload_hash.
140
+ */
141
+ registerContent(content: BoardItemContent, txid: string): Promise<{
142
+ ok: boolean;
143
+ error?: string;
144
+ }>;
145
+ /** Support/attest a proposal (wallet-signed; always clear-signed). */
146
+ support(proposalId: string, opts?: SupportInput): Promise<TxResult>;
147
+ private tipHeight;
148
+ private tryRegister;
149
+ }
150
+
151
+ export { BoardClient, type BoardItemContent, type BoardWindow, type ProposeInput, type ProposeResult, type RankedItem, type SupportInput };
@@ -0,0 +1,151 @@
1
+ import { H as Http } from './http-D2CzfOsm.js';
2
+ import { WalletConnection, TxResult } from './connect.js';
3
+
4
+ type BoardWindow = "24h" | "7d" | "30d" | "all";
5
+ /** A ranked board item (loose — the server returns a rich object). */
6
+ interface RankedItem {
7
+ id: string;
8
+ title: string;
9
+ body: string;
10
+ domain: string;
11
+ proposer: string;
12
+ score: number;
13
+ totalWeight: number;
14
+ [k: string]: unknown;
15
+ }
16
+ interface BoardItemContent {
17
+ v: 1;
18
+ domain: string;
19
+ title: string;
20
+ body: string;
21
+ links: string[];
22
+ }
23
+ interface ProposeInput {
24
+ domain: string;
25
+ title: string;
26
+ body?: string;
27
+ links?: string[];
28
+ /** Fee in base units (default MIN_FEE_PROPOSE = 0.25 CSD). */
29
+ fee?: number;
30
+ /** Lifetime in epochs before expiry (default 720 ≈ 30 days, matching cairn). */
31
+ lifetimeEpochs?: number;
32
+ }
33
+ interface ProposeResult {
34
+ txid: string;
35
+ payloadHash: string;
36
+ content: BoardItemContent;
37
+ /** Whether the off-chain content was registered with the cairn origin yet. */
38
+ registered: boolean;
39
+ /** If registration is still pending, call `registerContent(content, txid)` again later. */
40
+ registerError?: string;
41
+ }
42
+ interface SupportInput {
43
+ /** 0–100 quality score (default 80). */
44
+ score?: number;
45
+ /** 0–100 confidence (default 70). */
46
+ confidence?: number;
47
+ /** Fee in base units (default MIN_FEE_ATTEST = 0.05 CSD). */
48
+ fee?: number;
49
+ }
50
+ declare class BoardClient {
51
+ private readonly http;
52
+ private readonly wallet?;
53
+ constructor(http: Http, wallet?: WalletConnection);
54
+ private requireWallet;
55
+ /** Ranked board for a domain + time window. */
56
+ board(opts?: {
57
+ domain?: string;
58
+ window?: BoardWindow;
59
+ }): Promise<{
60
+ window: string;
61
+ domain: string;
62
+ count: number;
63
+ items: RankedItem[];
64
+ }>;
65
+ /** Alias for `board()` — the top items. */
66
+ top(opts?: {
67
+ domain?: string;
68
+ window?: BoardWindow;
69
+ }): Promise<{
70
+ window: string;
71
+ domain: string;
72
+ count: number;
73
+ items: RankedItem[];
74
+ }>;
75
+ /** A single item with its supports + pledges + integrity flag. */
76
+ item(id: string): Promise<{
77
+ ok: boolean;
78
+ item: RankedItem;
79
+ supports: unknown[];
80
+ pledges: unknown[];
81
+ integrityOk: boolean;
82
+ }>;
83
+ /** Known + discovered domains. */
84
+ domains(): Promise<{
85
+ prefix: string;
86
+ total: number;
87
+ domains: unknown[];
88
+ discovered: unknown[];
89
+ }>;
90
+ /** All quests (work-graph items). */
91
+ quests(): Promise<{
92
+ count: number;
93
+ quests: unknown[];
94
+ }>;
95
+ /** A single quest with claims/submissions/payouts. */
96
+ quest(id: string): Promise<{
97
+ ok: boolean;
98
+ quest: unknown;
99
+ }>;
100
+ /** An address's on-chain-derived profile + identity + reputation. */
101
+ profile(addr: string, opts?: {
102
+ live?: boolean;
103
+ }): Promise<{
104
+ ok: boolean;
105
+ profile: unknown;
106
+ identity: unknown;
107
+ reputation: unknown;
108
+ }>;
109
+ /** Reputation leaderboard (top 50). */
110
+ leaderboard(): Promise<{
111
+ count: number;
112
+ leaderboard: unknown[];
113
+ }>;
114
+ /** Network dashboard snapshot. */
115
+ network(): Promise<unknown>;
116
+ /** Network time-series for charts. */
117
+ networkSeries(range?: "24h" | "1w" | "1m" | "all"): Promise<unknown>;
118
+ /** Recent blocks with miner/reward. */
119
+ networkBlocks(limit?: number): Promise<unknown>;
120
+ /** Per-miner hashrate estimate. */
121
+ miner(addr: string): Promise<unknown>;
122
+ /** Recent activity feed. */
123
+ activity(): Promise<{
124
+ activity: unknown[];
125
+ }>;
126
+ /** The gamified cairn wall. */
127
+ wall(): Promise<unknown>;
128
+ /** Server health + chain reachability. */
129
+ health(): Promise<unknown>;
130
+ /**
131
+ * Publish a board item: compute the canonical payload hash, have the WALLET
132
+ * build/sign/submit the Propose (clear-signed approval), then register the
133
+ * off-chain content. The payload hash is byte-identical to what the cairn
134
+ * server verifies (csd-codec.payloadHash over { v:1, domain, title, body, links }).
135
+ */
136
+ propose(input: ProposeInput): Promise<ProposeResult>;
137
+ /**
138
+ * Register off-chain content for an already-submitted proposal txid. Idempotent.
139
+ * Returns { ok } — the cairn server verifies sha256(canonical) == on-chain payload_hash.
140
+ */
141
+ registerContent(content: BoardItemContent, txid: string): Promise<{
142
+ ok: boolean;
143
+ error?: string;
144
+ }>;
145
+ /** Support/attest a proposal (wallet-signed; always clear-signed). */
146
+ support(proposalId: string, opts?: SupportInput): Promise<TxResult>;
147
+ private tipHeight;
148
+ private tryRegister;
149
+ }
150
+
151
+ export { BoardClient, type BoardItemContent, type BoardWindow, type ProposeInput, type ProposeResult, type RankedItem, type SupportInput };
package/dist/board.js ADDED
@@ -0,0 +1,7 @@
1
+ import {
2
+ BoardClient
3
+ } from "./chunk-OGP2W7DL.js";
4
+ import "./chunk-PHMU3CG5.js";
5
+ export {
6
+ BoardClient
7
+ };