@sage-protocol/sdk 0.1.21 → 0.1.23

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 CHANGED
@@ -405,7 +405,7 @@ const mapped = await sdk.factory.getSubDAORegistry({ provider, factory, subdao }
405
405
 
406
406
  Registry preflight as timelock
407
407
  ```js
408
- const { to, data } = sdk.library.buildUpdateLibraryForSubDAOTx({ registry, subdao, manifestCID, promptCount, libraryId: 'main' });
408
+ const { to, data } = sdk.library.buildUpdateLibraryTx({ registry, subdao, manifestCID, version: '1.0.0' });
409
409
  const sim = await sdk.library.simulateAsTimelock({ provider, registry, to, data, timelock });
410
410
  if (!sim.ok) throw new Error(`registry preflight failed: ${sim.error?.message}`);
411
411
  ```
@@ -14,7 +14,7 @@ var require_package = __commonJS({
14
14
  "package.json"(exports, module) {
15
15
  module.exports = {
16
16
  name: "@sage-protocol/sdk",
17
- version: "0.1.21",
17
+ version: "0.1.23",
18
18
  description: "Backend-agnostic SDK for interacting with the Sage Protocol (governance, SubDAOs, tokens).",
19
19
  main: "dist/index.cjs",
20
20
  module: "dist/index.mjs",
@@ -119,7 +119,12 @@ var require_abi = __commonJS({
119
119
  "function userForkCount(address) view returns (uint256)",
120
120
  "function forkCount(string) view returns (uint256)",
121
121
  "function stake(uint256)",
122
- "function unstake(uint256)"
122
+ "function unstake(uint256)",
123
+ // Fork functions
124
+ "function forkSubDAO(string,string)",
125
+ "function forkSubDAO(string,string,bool)",
126
+ "function forkSubDAOWithStable(string,string,(uint256,uint256,uint8,bytes32,bytes32))",
127
+ "function forkSubDAOWithStable(string,string,(uint256,uint256,uint8,bytes32,bytes32),bool)"
123
128
  ];
124
129
  var Factory = [
125
130
  "event SubDAOGovernanceDeployed(address indexed subDAO, address indexed governor, address timelock, address treasury)"
@@ -159,8 +164,8 @@ var require_abi = __commonJS({
159
164
  "function createSubDAOOperatorWithStableAdvanced(string name, string description, uint8 accessModel, uint256 minStakeAmount, address operatorExecutor, address operatorAdmin, bool anyoneExec, bool governorProposer, (uint256 value,uint256 deadline,uint8 v,bytes32 r,bytes32 s) permit) returns (address subDAO, address registry)",
160
165
  "function createSubDAOOperator(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount, address operatorExecutor, address operatorAdmin) returns (address subDAO, address registry)",
161
166
  "function createSubDAOOperatorAdvanced(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount, address operatorExecutor, address operatorAdmin, bool anyoneExec, bool governorProposer) returns (address subDAO, address registry)",
162
- "function createForkedSubDAO(string newName, string newDescription, string originalName, address originalSubDAO, address forker) returns (address subDAO, address registry)",
163
- "function createForkedSubDAOWithStable(string newName, string newDescription, string originalName, address originalSubDAO, address forker, uint64 authorizationNonce, (uint256 value,uint256 deadline,uint8 v,bytes32 r,bytes32 s) permit) returns (address subDAO, address registry)"
167
+ "function createForkedSubDAO(string newName, string newDescription, string originalName, address originalSubDAO, address forker, bool copyLibrary) returns (address subDAO, address registry)",
168
+ "function createForkedSubDAOWithStable(string newName, string newDescription, string originalName, address originalSubDAO, address forker, uint64 authorizationNonce, (uint256 value,uint256 deadline,uint8 v,bytes32 r,bytes32 s) permit, bool copyLibrary) returns (address subDAO, address registry)"
164
169
  ];
165
170
  var TemplateModule = [
166
171
  "function getActiveTemplates() view returns (uint256[])",
@@ -179,9 +184,10 @@ var require_abi = __commonJS({
179
184
  "function updateLibrary(address dao, string manifestCID, string version)",
180
185
  "function registerDAO(address dao, address timelock)",
181
186
  "function registerForkedDAO(address childDAO, address childTimelock, address parentDAO, string manifestCID, string version)",
187
+ "function initializeLibraryFromFork(address sourceDao, address forkedDao)",
182
188
  "event LibraryUpdated(address indexed dao, string manifestCID, address indexed timelock, string version)",
183
189
  "event DAORegistered(address indexed dao, address indexed timelock)",
184
- "event LibraryForked(address indexed parentDAO, address indexed childDAO)",
190
+ "event LibraryForked(address indexed sourceDao, address indexed forkedDao, string manifestCID)",
185
191
  "event LibraryForkFeeUpdated(address indexed dao, uint256 fee)"
186
192
  ];
187
193
  var PromptRegistry = [
@@ -1107,19 +1113,37 @@ var require_subgraph = __commonJS({
1107
1113
  updatedAt: Number(p.updatedAt || 0)
1108
1114
  };
1109
1115
  },
1110
- async getProposalById({ url, id }) {
1116
+ async getProposalById({ url, id, governor }) {
1111
1117
  if (!url) throw new Error("subgraph url required");
1112
- const doc = `query($id: ID!){ proposal(id:$id){ id proposer description createdAt updatedAt state eta targets values calldatas } }`;
1113
- const data = await query(url, doc, { id: String(id) });
1114
- const p = data?.proposal;
1118
+ let p = null;
1119
+ if (governor) {
1120
+ const govLower = String(governor).toLowerCase();
1121
+ const compositeId = `${govLower}-${String(id)}`;
1122
+ const doc = `query($id: ID!){ proposal(id:$id){ id proposer description createdAt updatedAt state eta targets values calldatas } }`;
1123
+ const data = await query(url, doc, { id: compositeId });
1124
+ p = data?.proposal;
1125
+ }
1126
+ if (!p && governor) {
1127
+ const govLower = String(governor).toLowerCase();
1128
+ const doc = `query($gov: Bytes!, $first: Int!){ proposals(where:{governor:$gov}, first:$first, orderBy:createdAt, orderDirection:desc){ id proposer description createdAt updatedAt state eta targets values calldatas } }`;
1129
+ const data = await query(url, doc, { gov: govLower, first: 100 });
1130
+ const proposals = data?.proposals || [];
1131
+ p = proposals.find((prop) => {
1132
+ const parts = String(prop.id || "").split("-");
1133
+ const propId = parts.length > 1 ? parts[parts.length - 1] : prop.id;
1134
+ return String(propId) === String(id) || propId && String(BigInt(propId)) === String(BigInt(id));
1135
+ });
1136
+ }
1115
1137
  if (!p) return null;
1116
1138
  try {
1117
1139
  const proposer = safeGetAddress(p.proposer);
1118
1140
  if (!proposer) return null;
1119
1141
  const targets = (p.targets || []).map((t) => safeGetAddress(t)).filter(Boolean);
1120
1142
  if (!targets.length && (p.targets || []).length) return null;
1143
+ const idParts = String(p.id || "").split("-");
1144
+ const actualId = idParts.length > 1 ? idParts[idParts.length - 1] : p.id;
1121
1145
  return {
1122
- id: BigInt(p.id),
1146
+ id: BigInt(actualId),
1123
1147
  proposer,
1124
1148
  description: p.description || "",
1125
1149
  createdAt: Number(p.createdAt || 0),