@sage-protocol/sdk 0.0.8 → 0.1.6
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 +79 -0
- package/dist/browser/index.mjs +6464 -0
- package/dist/index.cjs +599 -428
- package/dist/index.mjs +694 -523
- package/dist/node/index.cjs +8193 -0
- package/dist/node/index.mjs +8204 -0
- package/package.json +21 -3
- package/types/index.d.ts +20 -0
package/README.md
CHANGED
|
@@ -42,6 +42,15 @@ const info = await sdk.governance.getGovernorInfo({ provider, governor: subdaos[
|
|
|
42
42
|
const sdk = require('@sage-protocol/sdk');
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
+
What’s New in 0.0.8
|
|
46
|
+
--------------------
|
|
47
|
+
- 0.0.8 Highlights
|
|
48
|
+
- Governance helpers (additive): resolveVotesToken, buildDelegateSelfPreferred, delegateSelfAndVerify, ensureProposeGates, readinessToPropose, listActiveProposals
|
|
49
|
+
- Library helpers (additive): buildAuthorizeTimelockTx, executionReadiness
|
|
50
|
+
- Subgraph normalization: listProposalsFiltered returns state (string) and stateNum (0–7)
|
|
51
|
+
- Backward compatible: no removed/renamed exports; all additions are optional
|
|
52
|
+
- IPFS worker helpers: discovery signal APIs (`recordMcpUsage`, `recordLaunchEvent`, `recordDiscoveryEvent`) and governance queue actions (`submitGovernanceReport`, `listGovernanceReports`, `reviewGovernanceReport`, `batchGovernanceReports`)
|
|
53
|
+
|
|
45
54
|
Module Overview
|
|
46
55
|
---------------
|
|
47
56
|
|
|
@@ -53,6 +62,7 @@ Module Overview
|
|
|
53
62
|
| `factory` | Config reads, template enumeration, SubDAO create/fork builders | Launch tooling, analytics |
|
|
54
63
|
| `library` | Manifest listings & scoped ownership checks | Prompt library browsers |
|
|
55
64
|
| `prompt` | Prompt metadata, fork counts, usage counters | UI prompt catalogues, agent prompt selection |
|
|
65
|
+
| `ipfs` | Upload helpers + discovery/governance worker APIs | CLI sandbox, dashboards, worker automation |
|
|
56
66
|
| `subdao` | Discovery, staking helpers, per-user stats | SubDAO directories, onboarding |
|
|
57
67
|
| `token` | SXXX balances/allowances, burner discovery, tx builders | Wallet gating, burner dashboards |
|
|
58
68
|
| `treasury` | Reserve/POL snapshot, pending withdrawals, liquidity plans | Treasury analytics, Safe operators |
|
|
@@ -242,12 +252,81 @@ const items = await sdk.subgraph.listProposalsFiltered({ url: SUBGRAPH_URL, gove
|
|
|
242
252
|
// item.state → 'PENDING' | 'ACTIVE' | ... ; item.stateNum → 0..7 or null when unknown
|
|
243
253
|
```
|
|
244
254
|
|
|
255
|
+
Subgraph State Normalization
|
|
256
|
+
----------------------------
|
|
257
|
+
- State Mapping
|
|
258
|
+
- PENDING → 0
|
|
259
|
+
- ACTIVE → 1
|
|
260
|
+
- CANCELED/CANCELLED → 2
|
|
261
|
+
- DEFEATED → 3
|
|
262
|
+
- SUCCEEDED → 4
|
|
263
|
+
- QUEUED → 5
|
|
264
|
+
- EXPIRED → 6
|
|
265
|
+
- EXECUTED → 7
|
|
266
|
+
- Example
|
|
267
|
+
```js
|
|
268
|
+
const items = await sdk.subgraph.listProposalsFiltered({ url: SUBGRAPH_URL, governor });
|
|
269
|
+
console.log(items[0].state); // 'PENDING'
|
|
270
|
+
console.log(items[0].stateNum); // 0
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
New Helper Examples
|
|
274
|
+
-------------------
|
|
275
|
+
|
|
276
|
+
- Votes token + self‑delegate
|
|
277
|
+
```js
|
|
278
|
+
const votesToken = await sdk.governance.resolveVotesToken({ provider, governor });
|
|
279
|
+
const tx = await sdk.governance.buildDelegateSelfPreferred({ provider, governor, account: user });
|
|
280
|
+
const res = await sdk.governance.delegateSelfAndVerify({ provider, governor, account: user, signer, minVotes: 1n });
|
|
281
|
+
console.log(res.ok, res.votes, res.txHash);
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
- Propose gates and execution readiness (one‑shot)
|
|
285
|
+
```js
|
|
286
|
+
const gates = await sdk.governance.ensureProposeGates({ provider, governor, proposer: user });
|
|
287
|
+
const ready = await sdk.governance.readinessToPropose({
|
|
288
|
+
provider, governor, proposer: user,
|
|
289
|
+
execution: { registry, timelock, subdao, libraryId: 'main', manifestCID, promptCount: 12 }
|
|
290
|
+
});
|
|
291
|
+
console.log({ threshold: gates.threshold, votesOk: gates.votesOk, execReady: ready.executionReady });
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
- List active proposals (subgraph)
|
|
295
|
+
```js
|
|
296
|
+
const active = await sdk.governance.listActiveProposals({ url: SUBGRAPH_URL, governor });
|
|
297
|
+
// active[i].state (string), active[i].stateNum (0–7)
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
- Library authorize + readiness
|
|
301
|
+
```js
|
|
302
|
+
const auth = sdk.library.buildAuthorizeTimelockTx({ registry, timelock, subdao });
|
|
303
|
+
const exec = await sdk.library.executionReadiness({ provider, registry, timelock, subdao, libraryId: 'main', manifestCID, promptCount });
|
|
304
|
+
console.log(exec.ok, exec.error);
|
|
305
|
+
```
|
|
306
|
+
|
|
245
307
|
Proposal timeline (subgraph)
|
|
246
308
|
```js
|
|
247
309
|
const t = await sdk.subgraph.getProposalTimeline({ url: SUBGRAPH_URL, id: idHexOrDecimal });
|
|
248
310
|
// { id, createdAt, queuedAt, executedAt, canceledAt, eta, state }
|
|
249
311
|
```
|
|
250
312
|
|
|
313
|
+
Compatibility
|
|
314
|
+
-------------
|
|
315
|
+
- 0.0.8 Compatibility
|
|
316
|
+
- All changes are additive; no removed or renamed exports. Existing callers can continue to rely on string state. stateNum is optional.
|
|
317
|
+
|
|
318
|
+
Troubleshooting
|
|
319
|
+
---------------
|
|
320
|
+
- JSON + BigInt
|
|
321
|
+
- Use a replacer when printing SDK results:
|
|
322
|
+
```js
|
|
323
|
+
JSON.stringify(obj, (_, v) => (typeof v === 'bigint' ? v.toString() : v));
|
|
324
|
+
```
|
|
325
|
+
- Governor filter casing
|
|
326
|
+
- The SDK normalizes governor for Bytes filters; if you issue manual GraphQL, use lowercase governor addresses to avoid case sensitivity pitfalls.
|
|
327
|
+
- Votes snapshot timing
|
|
328
|
+
- getVotesLatestMinusOne reads at latest‑1 to avoid same‑block edge cases on ERC20Votes.
|
|
329
|
+
|
|
251
330
|
Prompt pagination helpers
|
|
252
331
|
```js
|
|
253
332
|
const totalByTag = await sdk.prompt.getByTagCount({ provider, registry, tagHash });
|