@sage-protocol/sdk 0.0.6 → 0.0.8
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 +68 -0
- package/dist/index.cjs +3263 -2848
- package/dist/index.mjs +3263 -2848
- package/package.json +1 -1
- package/types/index.d.ts +2 -0
package/README.md
CHANGED
|
@@ -77,6 +77,44 @@ Next Phases
|
|
|
77
77
|
-----------
|
|
78
78
|
Phase 6 focuses on integration polish and packaging. Track progress in the [SDK Improvement Specification](../../docs/SDK_Improvement_Specification.md).
|
|
79
79
|
|
|
80
|
+
New governance/factory/library helpers (2025‑10)
|
|
81
|
+
-----------------------------------------------
|
|
82
|
+
|
|
83
|
+
Proposal ID and preflight
|
|
84
|
+
```js
|
|
85
|
+
import sdk from '@sage-protocol/sdk';
|
|
86
|
+
const idHex = sdk.governance.computeProposalIdHex({ targets, values, calldatas, description });
|
|
87
|
+
const pre = await sdk.governance.simulatePropose({ provider, governor, targets, values, calldatas, description, sender });
|
|
88
|
+
if (!pre.ok) throw new Error(`preflight failed: ${pre.error?.message}`);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Votes at latest‑1 (ERC20Votes)
|
|
92
|
+
```js
|
|
93
|
+
// Token path
|
|
94
|
+
const votes1 = await sdk.governance.getVotesLatestMinusOne({ provider, token: sxxxToken, account: user });
|
|
95
|
+
// Governor path (auto‑resolves token)
|
|
96
|
+
const votes2 = await sdk.governance.getVotesLatestMinusOne({ provider, governor, account: user });
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Factory‑mapped registry
|
|
100
|
+
```js
|
|
101
|
+
const mapped = await sdk.factory.getSubDAORegistry({ provider, factory, subdao });
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Registry preflight as timelock
|
|
105
|
+
```js
|
|
106
|
+
const { to, data } = sdk.library.buildUpdateLibraryForSubDAOTx({ registry, subdao, manifestCID, promptCount, libraryId: 'main' });
|
|
107
|
+
const sim = await sdk.library.simulateAsTimelock({ provider, registry, to, data, timelock });
|
|
108
|
+
if (!sim.ok) throw new Error(`registry preflight failed: ${sim.error?.message}`);
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Propose by hash (arrays + bytes32)
|
|
112
|
+
```js
|
|
113
|
+
// For governors that prefer descriptionHash (or deterministic IDs)
|
|
114
|
+
const dh = sdk.governance.hashDescription(description);
|
|
115
|
+
const tx = sdk.governance.buildProposeTxByHash({ governor, targets, values, calldatas, descriptionHash: dh });
|
|
116
|
+
```
|
|
117
|
+
|
|
80
118
|
API Notes and Examples
|
|
81
119
|
----------------------
|
|
82
120
|
|
|
@@ -174,6 +212,36 @@ const tx = await sdk.governance.buildDelegateSelfTx({ provider, governor, accoun
|
|
|
174
212
|
// send via userOp (CDP) or EOA
|
|
175
213
|
```
|
|
176
214
|
|
|
215
|
+
Votes token resolution and gates
|
|
216
|
+
```js
|
|
217
|
+
// Resolve the IVotes token used for proposals
|
|
218
|
+
const votesToken = await sdk.governance.resolveVotesToken({ provider, governor });
|
|
219
|
+
|
|
220
|
+
// Build preferred self-delegate using resolved token
|
|
221
|
+
const del = await sdk.governance.buildDelegateSelfPreferred({ provider, governor, account: user });
|
|
222
|
+
|
|
223
|
+
// Delegate and verify votes (no throw)
|
|
224
|
+
const res = await sdk.governance.delegateSelfAndVerify({ provider, governor, account: user, signer, minVotes: 1n });
|
|
225
|
+
// → { txHash, ok, votes, payload }
|
|
226
|
+
|
|
227
|
+
// Readiness to propose (preflight)
|
|
228
|
+
const gates = await sdk.governance.ensureProposeGates({ provider, governor, proposer: user });
|
|
229
|
+
// Optionally include execution check (registry update as timelock)
|
|
230
|
+
const ready = await sdk.governance.readinessToPropose({
|
|
231
|
+
provider,
|
|
232
|
+
governor,
|
|
233
|
+
proposer: user,
|
|
234
|
+
execution: { registry, timelock, subdao, libraryId: 'main', manifestCID, promptCount: 12 },
|
|
235
|
+
});
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Subgraph normalization
|
|
239
|
+
```js
|
|
240
|
+
// listProposalsFiltered now returns both state (string) and stateNum (0–7)
|
|
241
|
+
const items = await sdk.subgraph.listProposalsFiltered({ url: SUBGRAPH_URL, governor });
|
|
242
|
+
// item.state → 'PENDING' | 'ACTIVE' | ... ; item.stateNum → 0..7 or null when unknown
|
|
243
|
+
```
|
|
244
|
+
|
|
177
245
|
Proposal timeline (subgraph)
|
|
178
246
|
```js
|
|
179
247
|
const t = await sdk.subgraph.getProposalTimeline({ url: SUBGRAPH_URL, id: idHexOrDecimal });
|