@sage-protocol/sdk 0.1.2 → 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/dist/browser/index.mjs +156 -47
- package/dist/index.cjs +384 -431
- package/dist/index.mjs +477 -524
- package/dist/node/index.cjs +384 -431
- package/dist/node/index.mjs +479 -526
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -17,10 +17,10 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
17
17
|
|
|
18
18
|
// package.json
|
|
19
19
|
var require_package = __commonJS({
|
|
20
|
-
"package.json"(
|
|
21
|
-
|
|
20
|
+
"package.json"(exports2, module2) {
|
|
21
|
+
module2.exports = {
|
|
22
22
|
name: "@sage-protocol/sdk",
|
|
23
|
-
version: "0.1.
|
|
23
|
+
version: "0.1.6",
|
|
24
24
|
description: "Backend-agnostic SDK for interacting with the Sage Protocol (governance, SubDAOs, tokens).",
|
|
25
25
|
main: "dist/index.cjs",
|
|
26
26
|
module: "dist/index.mjs",
|
|
@@ -95,7 +95,7 @@ var require_package = __commonJS({
|
|
|
95
95
|
|
|
96
96
|
// src/abi/index.js
|
|
97
97
|
var require_abi = __commonJS({
|
|
98
|
-
"src/abi/index.js"(
|
|
98
|
+
"src/abi/index.js"(exports2, module2) {
|
|
99
99
|
var SubDAO = [
|
|
100
100
|
"function governor() view returns (address)",
|
|
101
101
|
"function timelock() view returns (address)",
|
|
@@ -250,20 +250,19 @@ var require_abi = __commonJS({
|
|
|
250
250
|
var PersonalLicenseReceipt = [
|
|
251
251
|
"function balanceOf(address account, uint256 id) view returns (uint256)"
|
|
252
252
|
];
|
|
253
|
-
var
|
|
254
|
-
"function
|
|
255
|
-
"function
|
|
256
|
-
"function
|
|
257
|
-
"function
|
|
258
|
-
"function
|
|
259
|
-
"function
|
|
260
|
-
"
|
|
261
|
-
"
|
|
262
|
-
"
|
|
263
|
-
"
|
|
264
|
-
"
|
|
265
|
-
"
|
|
266
|
-
"function lpContributions(address,address) view returns (uint256)"
|
|
253
|
+
var TreasuryWrapper = [
|
|
254
|
+
"function execute(address,uint256,bytes,bytes32) returns (bool)",
|
|
255
|
+
"function allowedTargets(address) view returns (bool)",
|
|
256
|
+
"function allowedSelectors(bytes4) view returns (bool)",
|
|
257
|
+
"function owners(address) view returns (bool)",
|
|
258
|
+
"function ownerCount() view returns (uint256)",
|
|
259
|
+
"function registry() view returns (address)",
|
|
260
|
+
"event TreasuryAction(address indexed caller, address indexed target, uint256 value, bytes data, bytes32 refId)",
|
|
261
|
+
"event AllowedTargetUpdated(address indexed target, bool allowed)",
|
|
262
|
+
"event AllowedSelectorUpdated(bytes4 indexed selector, bool allowed)",
|
|
263
|
+
"event OwnerAdded(address indexed owner)",
|
|
264
|
+
"event OwnerRemoved(address indexed owner)",
|
|
265
|
+
"event TokensSwept(address indexed token, address indexed to, uint256 amount)"
|
|
267
266
|
];
|
|
268
267
|
var GovernanceBoostMerkle = [
|
|
269
268
|
"function getProposalConfig(uint256) view returns (tuple(uint256 proposalId,address token,uint256 totalAmount,uint64 startTime,uint64 endTime,uint256 merkleRoot))",
|
|
@@ -275,33 +274,10 @@ var require_abi = __commonJS({
|
|
|
275
274
|
"function create(uint256 proposalId, address token, uint256 perVoter, uint256 maxVoters)",
|
|
276
275
|
"function fund(uint256 proposalId, uint256 amount)"
|
|
277
276
|
];
|
|
278
|
-
var BondDepository = [
|
|
279
|
-
// Core getters
|
|
280
|
-
"function payoutToken() view returns (address)",
|
|
281
|
-
"function principalToken() view returns (address)",
|
|
282
|
-
"function treasury() view returns (address)",
|
|
283
|
-
// Terms
|
|
284
|
-
"function terms() view returns (tuple(uint256 controlVariable,uint256 minimumPrice,uint256 maxPayout,uint256 maxDebt,uint256 vestingTerm,uint256 fee))",
|
|
285
|
-
"function totalDebt(address) view returns (uint256)",
|
|
286
|
-
// Pricing
|
|
287
|
-
"function bondPrice() view returns (uint256)",
|
|
288
|
-
"function bondPrice(address) view returns (uint256)",
|
|
289
|
-
"function bondPriceInUSD() view returns (uint256)",
|
|
290
|
-
"function currentDebt() view returns (uint256)",
|
|
291
|
-
"function debtRatio() view returns (uint256)",
|
|
292
|
-
"function standardizedDebtRatio() view returns (uint256)",
|
|
293
|
-
// User views
|
|
294
|
-
"function bondInfo(address) view returns (tuple(uint256 payout,uint256 vesting,uint256 lastBlock,uint256 pricePaid))",
|
|
295
|
-
"function pendingPayout(address) view returns (uint256)",
|
|
296
|
-
"function percentVestedFor(address) view returns (uint256)",
|
|
297
|
-
// Actions
|
|
298
|
-
"function deposit(uint256 _amount, uint256 _maxPrice) returns (uint256 payout_)",
|
|
299
|
-
"function redeem(address _recipient, bool _stake) returns (uint256)"
|
|
300
|
-
];
|
|
301
277
|
var Events = {
|
|
302
278
|
ProposalCreated: "event ProposalCreated(uint256 id, address proposer, address[] targets, uint256[] values, string[] signatures, bytes[] calldatas, uint256 startBlock, uint256 endBlock, string description)"
|
|
303
279
|
};
|
|
304
|
-
|
|
280
|
+
module2.exports = {
|
|
305
281
|
SubDAO,
|
|
306
282
|
Factory,
|
|
307
283
|
FactoryRead,
|
|
@@ -316,10 +292,10 @@ var require_abi = __commonJS({
|
|
|
316
292
|
PersonalLibraryFacet,
|
|
317
293
|
PersonalMarketplace,
|
|
318
294
|
PersonalLicenseReceipt,
|
|
319
|
-
|
|
295
|
+
TreasuryWrapper,
|
|
296
|
+
// Protocol treasury (replaces SageTreasury)
|
|
320
297
|
GovernanceBoostMerkle,
|
|
321
298
|
GovernanceBoostDirect,
|
|
322
|
-
BondDepository,
|
|
323
299
|
Events
|
|
324
300
|
};
|
|
325
301
|
}
|
|
@@ -327,9 +303,9 @@ var require_abi = __commonJS({
|
|
|
327
303
|
|
|
328
304
|
// src/types.js
|
|
329
305
|
var require_types = __commonJS({
|
|
330
|
-
"src/types.js"(
|
|
306
|
+
"src/types.js"(exports2, module2) {
|
|
331
307
|
var BigIntZero = 0n;
|
|
332
|
-
|
|
308
|
+
module2.exports = {
|
|
333
309
|
BigIntZero
|
|
334
310
|
};
|
|
335
311
|
}
|
|
@@ -337,7 +313,7 @@ var require_types = __commonJS({
|
|
|
337
313
|
|
|
338
314
|
// src/utils/errors.js
|
|
339
315
|
var require_errors = __commonJS({
|
|
340
|
-
"src/utils/errors.js"(
|
|
316
|
+
"src/utils/errors.js"(exports2, module2) {
|
|
341
317
|
var SageSDKError = class extends Error {
|
|
342
318
|
constructor(code, message, details) {
|
|
343
319
|
super(message);
|
|
@@ -354,7 +330,7 @@ var require_errors = __commonJS({
|
|
|
354
330
|
MISSING_DEPENDENCY: "ERR_MISSING_DEPENDENCY",
|
|
355
331
|
API_REQUEST_FAILED: "ERR_API_REQUEST_FAILED"
|
|
356
332
|
};
|
|
357
|
-
|
|
333
|
+
module2.exports = {
|
|
358
334
|
SageSDKError,
|
|
359
335
|
CODES
|
|
360
336
|
};
|
|
@@ -363,7 +339,7 @@ var require_errors = __commonJS({
|
|
|
363
339
|
|
|
364
340
|
// src/utils/description.js
|
|
365
341
|
var require_description = __commonJS({
|
|
366
|
-
"src/utils/description.js"(
|
|
342
|
+
"src/utils/description.js"(exports2, module2) {
|
|
367
343
|
var { randomBytes, hexlify } = __require("ethers");
|
|
368
344
|
var SALT_RE = /\n\n\[SALT:0x[0-9a-fA-F]{64}\]$/;
|
|
369
345
|
function generateSaltHex() {
|
|
@@ -394,7 +370,7 @@ var require_description = __commonJS({
|
|
|
394
370
|
return String(desc || "");
|
|
395
371
|
}
|
|
396
372
|
}
|
|
397
|
-
|
|
373
|
+
module2.exports = {
|
|
398
374
|
makeProposalDescription,
|
|
399
375
|
stripProposalSalt
|
|
400
376
|
};
|
|
@@ -403,7 +379,7 @@ var require_description = __commonJS({
|
|
|
403
379
|
|
|
404
380
|
// src/subgraph/index.js
|
|
405
381
|
var require_subgraph = __commonJS({
|
|
406
|
-
"src/subgraph/index.js"(
|
|
382
|
+
"src/subgraph/index.js"(exports2, module2) {
|
|
407
383
|
var axios = __require("axios");
|
|
408
384
|
var { getAddress } = __require("ethers");
|
|
409
385
|
var { keccak256, toUtf8Bytes } = __require("ethers");
|
|
@@ -526,7 +502,7 @@ var require_subgraph = __commonJS({
|
|
|
526
502
|
createdAt: Number(lib.createdAt || 0)
|
|
527
503
|
}));
|
|
528
504
|
}
|
|
529
|
-
|
|
505
|
+
module2.exports = {
|
|
530
506
|
query,
|
|
531
507
|
listProposals,
|
|
532
508
|
listProposalsFiltered,
|
|
@@ -535,9 +511,9 @@ var require_subgraph = __commonJS({
|
|
|
535
511
|
* Canonical proposal timeline. Tries common fields first, then event-style fallbacks.
|
|
536
512
|
* Returns { id, createdAt, queuedAt, executedAt, canceledAt, eta, state } (numbers/strings may be null when unavailable).
|
|
537
513
|
*/
|
|
538
|
-
async getProposalTimeline({ url, id }) {
|
|
514
|
+
async getProposalTimeline({ url, id: id2 }) {
|
|
539
515
|
if (!url) throw new Error("subgraph url required");
|
|
540
|
-
const pid = typeof
|
|
516
|
+
const pid = typeof id2 === "bigint" ? id2.toString() : String(id2);
|
|
541
517
|
try {
|
|
542
518
|
const data = await query(url, `
|
|
543
519
|
query($id: ID!) {
|
|
@@ -725,10 +701,10 @@ var require_subgraph = __commonJS({
|
|
|
725
701
|
updatedAt: Number(p.updatedAt || 0)
|
|
726
702
|
} : null;
|
|
727
703
|
},
|
|
728
|
-
async getProposalById({ url, id }) {
|
|
704
|
+
async getProposalById({ url, id: id2 }) {
|
|
729
705
|
if (!url) throw new Error("subgraph url required");
|
|
730
706
|
const doc = `query($id: ID!){ proposal(id:$id){ id proposer description createdAt updatedAt state eta targets values calldatas } }`;
|
|
731
|
-
const data = await query(url, doc, { id: String(
|
|
707
|
+
const data = await query(url, doc, { id: String(id2) });
|
|
732
708
|
const p = data?.proposal;
|
|
733
709
|
if (!p) return null;
|
|
734
710
|
return {
|
|
@@ -750,7 +726,7 @@ var require_subgraph = __commonJS({
|
|
|
750
726
|
|
|
751
727
|
// src/adapters/transports.js
|
|
752
728
|
var require_transports = __commonJS({
|
|
753
|
-
"src/adapters/transports.js"(
|
|
729
|
+
"src/adapters/transports.js"(exports2, module2) {
|
|
754
730
|
function createTransports({ provider, signer = null, subgraph = null }) {
|
|
755
731
|
return function resolve(kind) {
|
|
756
732
|
switch (kind) {
|
|
@@ -765,7 +741,7 @@ var require_transports = __commonJS({
|
|
|
765
741
|
}
|
|
766
742
|
};
|
|
767
743
|
}
|
|
768
|
-
|
|
744
|
+
module2.exports = {
|
|
769
745
|
createTransports
|
|
770
746
|
};
|
|
771
747
|
}
|
|
@@ -773,10 +749,10 @@ var require_transports = __commonJS({
|
|
|
773
749
|
|
|
774
750
|
// src/ipfs/index.js
|
|
775
751
|
var require_ipfs = __commonJS({
|
|
776
|
-
"src/ipfs/index.js"(
|
|
752
|
+
"src/ipfs/index.js"(exports2, module2) {
|
|
777
753
|
var axiosDefault = __require("axios");
|
|
778
754
|
var FormData = __require("form-data");
|
|
779
|
-
var { ethers } = __require("ethers");
|
|
755
|
+
var { ethers: ethers2 } = __require("ethers");
|
|
780
756
|
var DEFAULT_GATEWAY = "https://ipfs.dev.sageprotocol.io/ipfs";
|
|
781
757
|
function toLowerSafe(value, fallback = "") {
|
|
782
758
|
if (value == null) return fallback;
|
|
@@ -831,14 +807,14 @@ var require_ipfs = __commonJS({
|
|
|
831
807
|
}
|
|
832
808
|
return Array.from(urls);
|
|
833
809
|
}
|
|
834
|
-
function ensureLeadingSlash(
|
|
835
|
-
const value =
|
|
810
|
+
function ensureLeadingSlash(path2, fallback = "") {
|
|
811
|
+
const value = path2 || fallback;
|
|
836
812
|
if (!value) return fallback;
|
|
837
813
|
return value.startsWith("/") ? value : `/${value}`;
|
|
838
814
|
}
|
|
839
815
|
function generateDeterministicCid(payload) {
|
|
840
816
|
const content = Buffer.isBuffer(payload) ? payload : typeof payload === "string" ? Buffer.from(payload) : Buffer.from(JSON.stringify(payload));
|
|
841
|
-
const hash =
|
|
817
|
+
const hash = ethers2.keccak256(content);
|
|
842
818
|
const hashStr = hash.slice(2);
|
|
843
819
|
const cidSuffix = (hashStr + hashStr).slice(0, 44);
|
|
844
820
|
return `Qm${cidSuffix}`;
|
|
@@ -910,7 +886,7 @@ var require_ipfs = __commonJS({
|
|
|
910
886
|
}
|
|
911
887
|
function workerUrl(kind, cid) {
|
|
912
888
|
const base = workerBaseUrl();
|
|
913
|
-
const ensure = (
|
|
889
|
+
const ensure = (path2) => path2.startsWith("/") ? path2 : `/${path2}`;
|
|
914
890
|
if (base) {
|
|
915
891
|
if (kind === "challenge") return `${base}${ensure(config.worker.challengePath || "/auth/challenge")}`;
|
|
916
892
|
if (kind === "upload") return `${base}${ensure(config.worker.uploadPath || "/ipfs/upload")}`;
|
|
@@ -1232,18 +1208,18 @@ var require_ipfs = __commonJS({
|
|
|
1232
1208
|
return postWorkerJson("discoveryEventsPath", "/discover/events", payload);
|
|
1233
1209
|
}
|
|
1234
1210
|
async function recordMcpUsageEvent({ promptId, metadata, address } = {}) {
|
|
1235
|
-
const
|
|
1236
|
-
if (!
|
|
1237
|
-
const payload = { promptId:
|
|
1211
|
+
const id2 = typeof promptId === "string" ? promptId.trim() : "";
|
|
1212
|
+
if (!id2) throw new Error("promptId required");
|
|
1213
|
+
const payload = { promptId: id2 };
|
|
1238
1214
|
if (metadata && typeof metadata === "object") payload.metadata = metadata;
|
|
1239
1215
|
const actor = address || config.worker.address;
|
|
1240
1216
|
if (actor) payload.address = actor;
|
|
1241
1217
|
return postWorkerJson("discoveryMcpPath", "/discover/mcp", payload);
|
|
1242
1218
|
}
|
|
1243
1219
|
async function recordLaunchEvent({ promptId, metadata, address } = {}) {
|
|
1244
|
-
const
|
|
1245
|
-
if (!
|
|
1246
|
-
const payload = { promptId:
|
|
1220
|
+
const id2 = typeof promptId === "string" ? promptId.trim() : "";
|
|
1221
|
+
if (!id2) throw new Error("promptId required");
|
|
1222
|
+
const payload = { promptId: id2 };
|
|
1247
1223
|
if (metadata && typeof metadata === "object") payload.metadata = metadata;
|
|
1248
1224
|
const actor = address || config.worker.address;
|
|
1249
1225
|
if (actor) payload.address = actor;
|
|
@@ -1273,11 +1249,11 @@ var require_ipfs = __commonJS({
|
|
|
1273
1249
|
}
|
|
1274
1250
|
async function reviewGovernanceReport(payload = {}) {
|
|
1275
1251
|
if (!payload || typeof payload !== "object") throw new Error("payload required");
|
|
1276
|
-
const
|
|
1277
|
-
if (!
|
|
1252
|
+
const id2 = typeof payload.id === "string" ? payload.id.trim() : "";
|
|
1253
|
+
if (!id2) throw new Error("report id required");
|
|
1278
1254
|
const status = typeof payload.status === "string" ? payload.status.trim() : "";
|
|
1279
1255
|
if (!status) throw new Error("status required");
|
|
1280
|
-
const body = { id, status };
|
|
1256
|
+
const body = { id: id2, status };
|
|
1281
1257
|
if (typeof payload.note === "string") body.note = payload.note;
|
|
1282
1258
|
if (typeof payload.action === "string") body.action = payload.action;
|
|
1283
1259
|
return postWorkerJson("governanceReviewPath", "/governance/report/review", body);
|
|
@@ -1393,7 +1369,7 @@ var require_ipfs = __commonJS({
|
|
|
1393
1369
|
verified
|
|
1394
1370
|
};
|
|
1395
1371
|
}
|
|
1396
|
-
|
|
1372
|
+
module2.exports = {
|
|
1397
1373
|
DEFAULT_GATEWAY,
|
|
1398
1374
|
createClient,
|
|
1399
1375
|
buildGatewayUrls,
|
|
@@ -1405,7 +1381,7 @@ var require_ipfs = __commonJS({
|
|
|
1405
1381
|
|
|
1406
1382
|
// src/library/search.js
|
|
1407
1383
|
var require_search = __commonJS({
|
|
1408
|
-
"src/library/search.js"(
|
|
1384
|
+
"src/library/search.js"(exports2, module2) {
|
|
1409
1385
|
var { Contract, getAddress } = __require("ethers");
|
|
1410
1386
|
var ABI = require_abi();
|
|
1411
1387
|
var { SageSDKError, CODES } = require_errors();
|
|
@@ -1576,7 +1552,7 @@ var require_search = __commonJS({
|
|
|
1576
1552
|
}
|
|
1577
1553
|
};
|
|
1578
1554
|
}
|
|
1579
|
-
|
|
1555
|
+
module2.exports = {
|
|
1580
1556
|
searchRegistry
|
|
1581
1557
|
};
|
|
1582
1558
|
}
|
|
@@ -1584,7 +1560,7 @@ var require_search = __commonJS({
|
|
|
1584
1560
|
|
|
1585
1561
|
// src/library/validation.js
|
|
1586
1562
|
var require_validation = __commonJS({
|
|
1587
|
-
"src/library/validation.js"(
|
|
1563
|
+
"src/library/validation.js"(exports2, module2) {
|
|
1588
1564
|
var fsDefault = __require("fs");
|
|
1589
1565
|
var pathDefault = __require("path");
|
|
1590
1566
|
function defaultAjvFactory() {
|
|
@@ -1603,18 +1579,18 @@ var require_validation = __commonJS({
|
|
|
1603
1579
|
} catch (_) {
|
|
1604
1580
|
}
|
|
1605
1581
|
}
|
|
1606
|
-
function normaliseSchemaPaths(schemaPaths, { path }) {
|
|
1582
|
+
function normaliseSchemaPaths(schemaPaths, { path: path2 }) {
|
|
1607
1583
|
if (Array.isArray(schemaPaths) && schemaPaths.length) {
|
|
1608
1584
|
return schemaPaths;
|
|
1609
1585
|
}
|
|
1610
1586
|
return [
|
|
1611
|
-
|
|
1612
|
-
|
|
1587
|
+
path2.join(process.cwd(), "docs", "schemas", "manifest.schema.json"),
|
|
1588
|
+
path2.join(__dirname, "..", "..", "docs", "schemas", "manifest.schema.json")
|
|
1613
1589
|
];
|
|
1614
1590
|
}
|
|
1615
|
-
function safeJsonParse(
|
|
1591
|
+
function safeJsonParse(fs2, file) {
|
|
1616
1592
|
try {
|
|
1617
|
-
const raw =
|
|
1593
|
+
const raw = fs2.readFileSync(file, "utf8");
|
|
1618
1594
|
return JSON.parse(raw);
|
|
1619
1595
|
} catch (_) {
|
|
1620
1596
|
return null;
|
|
@@ -1640,17 +1616,17 @@ var require_validation = __commonJS({
|
|
|
1640
1616
|
}
|
|
1641
1617
|
function createManifestValidator(options = {}) {
|
|
1642
1618
|
const {
|
|
1643
|
-
fs = fsDefault,
|
|
1644
|
-
path = pathDefault,
|
|
1619
|
+
fs: fs2 = fsDefault,
|
|
1620
|
+
path: path2 = pathDefault,
|
|
1645
1621
|
ajvFactory = defaultAjvFactory,
|
|
1646
1622
|
addFormats = defaultAddFormats,
|
|
1647
1623
|
schemaPaths
|
|
1648
1624
|
} = options;
|
|
1649
|
-
const searchPaths = normaliseSchemaPaths(schemaPaths, { path });
|
|
1625
|
+
const searchPaths = normaliseSchemaPaths(schemaPaths, { path: path2 });
|
|
1650
1626
|
function loadSchema() {
|
|
1651
1627
|
for (const schemaPath of searchPaths) {
|
|
1652
|
-
if (!
|
|
1653
|
-
const schema = safeJsonParse(
|
|
1628
|
+
if (!fs2.existsSync(schemaPath)) continue;
|
|
1629
|
+
const schema = safeJsonParse(fs2, schemaPath);
|
|
1654
1630
|
if (schema) return { schema, schemaPath };
|
|
1655
1631
|
}
|
|
1656
1632
|
return { schema: null, schemaPath: null };
|
|
@@ -1723,7 +1699,7 @@ var require_validation = __commonJS({
|
|
|
1723
1699
|
if (!manifestPath) {
|
|
1724
1700
|
throw new Error("manifestPath required");
|
|
1725
1701
|
}
|
|
1726
|
-
const data = safeJsonParse(
|
|
1702
|
+
const data = safeJsonParse(fs2, manifestPath);
|
|
1727
1703
|
if (!data) {
|
|
1728
1704
|
return {
|
|
1729
1705
|
ok: false,
|
|
@@ -1756,8 +1732,8 @@ var require_validation = __commonJS({
|
|
|
1756
1732
|
seenKeys.add(key);
|
|
1757
1733
|
const files = Array.isArray(prompt.files) ? prompt.files : [];
|
|
1758
1734
|
for (const file of files) {
|
|
1759
|
-
const resolved =
|
|
1760
|
-
if (!
|
|
1735
|
+
const resolved = path2.isAbsolute(file) ? file : manifestPath ? path2.join(path2.dirname(manifestPath), file) : file;
|
|
1736
|
+
if (!fs2.existsSync(resolved)) {
|
|
1761
1737
|
issues.push({
|
|
1762
1738
|
type: "missing_file",
|
|
1763
1739
|
message: `File not found: ${file}`,
|
|
@@ -1780,7 +1756,7 @@ var require_validation = __commonJS({
|
|
|
1780
1756
|
}
|
|
1781
1757
|
function bestPracticeCheckFile(manifestPath, options2 = {}) {
|
|
1782
1758
|
if (!manifestPath) throw new Error("manifestPath required");
|
|
1783
|
-
const data = safeJsonParse(
|
|
1759
|
+
const data = safeJsonParse(fs2, manifestPath);
|
|
1784
1760
|
if (!data) {
|
|
1785
1761
|
return [{ type: "parse_error", message: `Failed to parse JSON at ${manifestPath}`, manifestPath }];
|
|
1786
1762
|
}
|
|
@@ -1794,7 +1770,7 @@ var require_validation = __commonJS({
|
|
|
1794
1770
|
bestPracticeCheckFile
|
|
1795
1771
|
};
|
|
1796
1772
|
}
|
|
1797
|
-
|
|
1773
|
+
module2.exports = {
|
|
1798
1774
|
createManifestValidator
|
|
1799
1775
|
};
|
|
1800
1776
|
}
|
|
@@ -1802,8 +1778,8 @@ var require_validation = __commonJS({
|
|
|
1802
1778
|
|
|
1803
1779
|
// src/library/index.js
|
|
1804
1780
|
var require_library = __commonJS({
|
|
1805
|
-
"src/library/index.js"(
|
|
1806
|
-
var { Contract, getAddress, keccak256, toUtf8Bytes } = __require("ethers");
|
|
1781
|
+
"src/library/index.js"(exports2, module2) {
|
|
1782
|
+
var { Contract, getAddress, keccak256, toUtf8Bytes, AbiCoder } = __require("ethers");
|
|
1807
1783
|
var { Interface } = __require("ethers");
|
|
1808
1784
|
var ABI = require_abi();
|
|
1809
1785
|
var { SageSDKError, CODES } = require_errors();
|
|
@@ -1842,17 +1818,31 @@ var require_library = __commonJS({
|
|
|
1842
1818
|
promptCount: Number(promptCount)
|
|
1843
1819
|
};
|
|
1844
1820
|
}
|
|
1821
|
+
function _computeLibraryKey(subdao, libraryId) {
|
|
1822
|
+
const coder = AbiCoder.defaultAbiCoder ? AbiCoder.defaultAbiCoder() : new AbiCoder();
|
|
1823
|
+
const encoded = coder.encode(["address", "string"], [getAddress(subdao), String(libraryId)]);
|
|
1824
|
+
return keccak256(encoded);
|
|
1825
|
+
}
|
|
1845
1826
|
async function getLatestLibrary({ provider, registry, subdao, libraryId = "main" }) {
|
|
1846
1827
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
1847
1828
|
const addr = normalise(registry, "registry");
|
|
1848
1829
|
const sub = normalise(subdao, "subdao");
|
|
1849
1830
|
const contract = new Contract(addr, ABI.LibraryRegistry, provider);
|
|
1850
|
-
const key =
|
|
1831
|
+
const key = _computeLibraryKey(sub, libraryId);
|
|
1851
1832
|
const latestCID = await contract.subdaoLibraryLatest(key).catch(() => "");
|
|
1852
1833
|
if (!latestCID || latestCID.length === 0) return null;
|
|
1853
1834
|
const info = await getManifestInfo({ provider, registry: addr, manifestCID: latestCID });
|
|
1854
1835
|
return info;
|
|
1855
1836
|
}
|
|
1837
|
+
async function getBeforeAfterForUpdate({ provider, registry, subdao, libraryId = "main", newCid }) {
|
|
1838
|
+
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
1839
|
+
const addr = normalise(registry, "registry");
|
|
1840
|
+
const sub = normalise(subdao, "subdao");
|
|
1841
|
+
const contract = new Contract(addr, ABI.LibraryRegistry, provider);
|
|
1842
|
+
const key = _computeLibraryKey(sub, libraryId);
|
|
1843
|
+
const prev = await contract.subdaoLibraryLatest(key).catch(() => "");
|
|
1844
|
+
return { previousCID: prev || null, newCID: String(newCid), libraryId: String(libraryId) };
|
|
1845
|
+
}
|
|
1856
1846
|
async function hasScopedOwnership({ provider, registry, subdao, manifestCID }) {
|
|
1857
1847
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
1858
1848
|
const addr = normalise(registry, "registry");
|
|
@@ -1872,12 +1862,14 @@ var require_library = __commonJS({
|
|
|
1872
1862
|
]);
|
|
1873
1863
|
return { to, data, value: 0n };
|
|
1874
1864
|
}
|
|
1875
|
-
|
|
1865
|
+
module2.exports = {
|
|
1876
1866
|
listManifests,
|
|
1877
1867
|
getManifestInfo,
|
|
1878
1868
|
getLatestLibrary,
|
|
1879
1869
|
hasScopedOwnership,
|
|
1880
1870
|
buildUpdateLibraryForSubDAOTx,
|
|
1871
|
+
_computeLibraryKey,
|
|
1872
|
+
getBeforeAfterForUpdate,
|
|
1881
1873
|
/** Build an authorizeTimelock(timelock, subdao) call for a LibraryRegistry. */
|
|
1882
1874
|
buildAuthorizeTimelockTx: function buildAuthorizeTimelockTx({ registry, timelock, subdao }) {
|
|
1883
1875
|
const to = normalise(registry, "registry");
|
|
@@ -1914,7 +1906,7 @@ var require_library = __commonJS({
|
|
|
1914
1906
|
|
|
1915
1907
|
// src/governance/index.js
|
|
1916
1908
|
var require_governance = __commonJS({
|
|
1917
|
-
"src/governance/index.js"(
|
|
1909
|
+
"src/governance/index.js"(exports2, module2) {
|
|
1918
1910
|
var { Contract, Interface, AbiCoder, getAddress, hexlify, keccak256, toUtf8Bytes } = __require("ethers");
|
|
1919
1911
|
var ABI = require_abi();
|
|
1920
1912
|
var { BigIntZero } = require_types();
|
|
@@ -1964,11 +1956,11 @@ var require_governance = __commonJS({
|
|
|
1964
1956
|
stakeAmount
|
|
1965
1957
|
};
|
|
1966
1958
|
}
|
|
1967
|
-
async function getProposal({ provider, governor, id }) {
|
|
1959
|
+
async function getProposal({ provider, governor, id: id2 }) {
|
|
1968
1960
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
1969
1961
|
const addr = normaliseGovernor(governor);
|
|
1970
1962
|
const g = new Contract(addr, ABI.Governor, provider);
|
|
1971
|
-
const pid = typeof
|
|
1963
|
+
const pid = typeof id2 === "bigint" ? id2 : String(id2).startsWith("0x") ? BigInt(id2) : BigInt(String(id2));
|
|
1972
1964
|
const [state, snapshot, deadline, votes] = await Promise.all([
|
|
1973
1965
|
g.state(pid),
|
|
1974
1966
|
g.proposalSnapshot(pid),
|
|
@@ -2022,12 +2014,12 @@ var require_governance = __commonJS({
|
|
|
2022
2014
|
}
|
|
2023
2015
|
return proposals;
|
|
2024
2016
|
}
|
|
2025
|
-
async function getProposalMetadata({ provider, governor, id, fromBlock = 0, toBlock = "latest" }) {
|
|
2017
|
+
async function getProposalMetadata({ provider, governor, id: id2, fromBlock = 0, toBlock = "latest" }) {
|
|
2026
2018
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
2027
2019
|
const addr = normaliseGovernor(governor);
|
|
2028
2020
|
const iface = new Interface([ABI.Events.ProposalCreated]);
|
|
2029
2021
|
const topic = iface.getEvent("ProposalCreated").topicHash;
|
|
2030
|
-
const pid = typeof
|
|
2022
|
+
const pid = typeof id2 === "bigint" ? id2 : String(id2).startsWith("0x") ? BigInt(id2) : BigInt(String(id2));
|
|
2031
2023
|
const logs = await provider.getLogs({ address: addr, fromBlock, toBlock, topics: [topic] });
|
|
2032
2024
|
for (const log of logs) {
|
|
2033
2025
|
try {
|
|
@@ -2088,10 +2080,10 @@ var require_governance = __commonJS({
|
|
|
2088
2080
|
function buildCastVoteTx({ governor, proposalId, support, reason }) {
|
|
2089
2081
|
const addr = normaliseGovernor(governor);
|
|
2090
2082
|
const iface = new Interface(ABI.Governor);
|
|
2091
|
-
const
|
|
2083
|
+
const id2 = typeof proposalId === "bigint" ? proposalId : String(proposalId).startsWith("0x") ? BigInt(proposalId) : BigInt(String(proposalId));
|
|
2092
2084
|
const s = Number(support);
|
|
2093
2085
|
const hasReason = reason && String(reason).length > 0;
|
|
2094
|
-
const data = hasReason ? iface.encodeFunctionData("castVoteWithReason(uint256,uint8,string)", [
|
|
2086
|
+
const data = hasReason ? iface.encodeFunctionData("castVoteWithReason(uint256,uint8,string)", [id2, s, String(reason)]) : iface.encodeFunctionData("castVote(uint256,uint8)", [id2, s]);
|
|
2095
2087
|
return { to: addr, data, value: BigIntZero };
|
|
2096
2088
|
}
|
|
2097
2089
|
function cueTx(fn, { governor, targets = [], values = [], calldatas = [], descriptionOrHash = "" }) {
|
|
@@ -2112,17 +2104,73 @@ var require_governance = __commonJS({
|
|
|
2112
2104
|
function buildQueueByIdTx({ governor, proposalId }) {
|
|
2113
2105
|
const addr = normaliseGovernor(governor);
|
|
2114
2106
|
const iface = new Interface(ABI.Governor);
|
|
2115
|
-
const
|
|
2116
|
-
const data = iface.encodeFunctionData("queue(uint256)", [
|
|
2107
|
+
const id2 = typeof proposalId === "bigint" ? proposalId : String(proposalId).startsWith("0x") ? BigInt(proposalId) : BigInt(String(proposalId));
|
|
2108
|
+
const data = iface.encodeFunctionData("queue(uint256)", [id2]);
|
|
2117
2109
|
return { to: addr, data, value: BigIntZero };
|
|
2118
2110
|
}
|
|
2119
2111
|
function buildExecuteByIdTx({ governor, proposalId }) {
|
|
2120
2112
|
const addr = normaliseGovernor(governor);
|
|
2121
2113
|
const iface = new Interface(ABI.Governor);
|
|
2122
|
-
const
|
|
2123
|
-
const data = iface.encodeFunctionData("execute(uint256)", [
|
|
2114
|
+
const id2 = typeof proposalId === "bigint" ? proposalId : String(proposalId).startsWith("0x") ? BigInt(proposalId) : BigInt(String(proposalId));
|
|
2115
|
+
const data = iface.encodeFunctionData("execute(uint256)", [id2]);
|
|
2124
2116
|
return { to: addr, data, value: BigIntZero };
|
|
2125
2117
|
}
|
|
2118
|
+
async function decodeProposalEffects({ provider, governor, proposalId, fromBlock = 0, toBlock = "latest" }) {
|
|
2119
|
+
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
2120
|
+
const govAddr = normaliseGovernor(governor);
|
|
2121
|
+
const iface = new Interface([ABI.Events.ProposalCreated]);
|
|
2122
|
+
const topic = iface.getEvent("ProposalCreated").topicHash;
|
|
2123
|
+
const id2 = typeof proposalId === "bigint" ? proposalId : String(proposalId).startsWith("0x") ? BigInt(proposalId) : BigInt(String(proposalId));
|
|
2124
|
+
let parsed = null;
|
|
2125
|
+
let logTxHash = null;
|
|
2126
|
+
const logs = await provider.getLogs({ address: govAddr, fromBlock, toBlock, topics: [topic] });
|
|
2127
|
+
for (const log of logs) {
|
|
2128
|
+
try {
|
|
2129
|
+
const p = iface.parseLog(log);
|
|
2130
|
+
if (BigInt(p.args.id.toString()) === id2) {
|
|
2131
|
+
parsed = p;
|
|
2132
|
+
logTxHash = log.transactionHash;
|
|
2133
|
+
break;
|
|
2134
|
+
}
|
|
2135
|
+
} catch (_) {
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
if (!parsed) throw new Error("ProposalCreated event not found");
|
|
2139
|
+
const targets = parsed.args.targets.map(getAddress);
|
|
2140
|
+
const calldatas = parsed.args.calldatas.map((d) => typeof d === "string" ? d : "0x" + Buffer.from(d).toString("hex"));
|
|
2141
|
+
const LibraryIface = new Interface(["function updateLibraryForSubDAO(address,string,string,uint256)", "function subdaoLibraryLatest(bytes32) view returns (string)"]);
|
|
2142
|
+
const PromptIface = new Interface(["function updatePromptByGovernance(string,string)"]);
|
|
2143
|
+
const coder = AbiCoder.defaultAbiCoder ? AbiCoder.defaultAbiCoder() : new AbiCoder();
|
|
2144
|
+
const effects = [];
|
|
2145
|
+
for (let i = 0; i < calldatas.length; i++) {
|
|
2146
|
+
const data = calldatas[i];
|
|
2147
|
+
const sel = data.slice(0, 10);
|
|
2148
|
+
try {
|
|
2149
|
+
const decoded = LibraryIface.decodeFunctionData("updateLibraryForSubDAO", data);
|
|
2150
|
+
const [subdao, libraryId, newCid, promptCount] = decoded;
|
|
2151
|
+
let previousCID = null;
|
|
2152
|
+
try {
|
|
2153
|
+
const reg = new Contract(targets[i], ["function subdaoLibraryLatest(bytes32) view returns (string)"], provider);
|
|
2154
|
+
const key = keccak256(coder.encode(["address", "string"], [getAddress(subdao), String(libraryId)]));
|
|
2155
|
+
const prev = await reg.subdaoLibraryLatest(key).catch(() => "");
|
|
2156
|
+
previousCID = prev && prev.length ? String(prev) : null;
|
|
2157
|
+
} catch (_) {
|
|
2158
|
+
}
|
|
2159
|
+
effects.push({ type: "libraryUpdate", index: i, target: targets[i], subdao: getAddress(subdao), libraryId: String(libraryId), previousCid: previousCID, newCid: String(newCid), promptCount: Number(promptCount) });
|
|
2160
|
+
continue;
|
|
2161
|
+
} catch (_) {
|
|
2162
|
+
}
|
|
2163
|
+
try {
|
|
2164
|
+
const decodedP = PromptIface.decodeFunctionData("updatePromptByGovernance", data);
|
|
2165
|
+
const [key, newCid] = decodedP;
|
|
2166
|
+
effects.push({ type: "promptUpdate", index: i, target: targets[i], key: String(key), newCid: String(newCid) });
|
|
2167
|
+
continue;
|
|
2168
|
+
} catch (_) {
|
|
2169
|
+
}
|
|
2170
|
+
effects.push({ type: "unknown", index: i, target: targets[i], selector: sel });
|
|
2171
|
+
}
|
|
2172
|
+
return { governor: govAddr, proposalId: id2, tx: logTxHash, actions: { count: calldatas.length }, effects };
|
|
2173
|
+
}
|
|
2126
2174
|
async function getQuorumAt({ provider, governor, blockTag }) {
|
|
2127
2175
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
2128
2176
|
const addr = normaliseGovernor(governor);
|
|
@@ -2240,7 +2288,7 @@ var require_governance = __commonJS({
|
|
|
2240
2288
|
const token = await g.sxxxToken();
|
|
2241
2289
|
return buildDelegateTx({ token, delegatee: account });
|
|
2242
2290
|
}
|
|
2243
|
-
|
|
2291
|
+
module2.exports = {
|
|
2244
2292
|
getGovernorInfo,
|
|
2245
2293
|
getProposal,
|
|
2246
2294
|
listProposals,
|
|
@@ -2252,6 +2300,7 @@ var require_governance = __commonJS({
|
|
|
2252
2300
|
buildExecuteTx,
|
|
2253
2301
|
buildQueueByIdTx,
|
|
2254
2302
|
buildExecuteByIdTx,
|
|
2303
|
+
decodeProposalEffects,
|
|
2255
2304
|
makeProposalDescription,
|
|
2256
2305
|
stripProposalSalt,
|
|
2257
2306
|
getQuorumAt,
|
|
@@ -2509,7 +2558,7 @@ var require_governance = __commonJS({
|
|
|
2509
2558
|
|
|
2510
2559
|
// src/governance/intents.js
|
|
2511
2560
|
var require_intents = __commonJS({
|
|
2512
|
-
"src/governance/intents.js"(
|
|
2561
|
+
"src/governance/intents.js"(exports2, module2) {
|
|
2513
2562
|
var { Interface, getAddress } = __require("ethers");
|
|
2514
2563
|
var { SageSDKError, CODES } = require_errors();
|
|
2515
2564
|
function normalise(addr, label) {
|
|
@@ -2533,7 +2582,7 @@ var require_intents = __commonJS({
|
|
|
2533
2582
|
"function setPremiumRevSplit(address,uint16,uint16,uint16)",
|
|
2534
2583
|
"function setCreatorStakeBps(address,uint256)"
|
|
2535
2584
|
]);
|
|
2536
|
-
|
|
2585
|
+
module2.exports = {
|
|
2537
2586
|
// Governor targets
|
|
2538
2587
|
buildUpdateQuorumTx: ({ governor, quorumPercent }) => ({ to: normalise(governor, "governor"), data: GovIface.encodeFunctionData("updateQuorumNumerator", [Number(quorumPercent)]), value: 0n }),
|
|
2539
2588
|
buildSetVotingPeriodTx: ({ governor, blocks }) => ({ to: normalise(governor, "governor"), data: GovIface.encodeFunctionData("setVotingPeriodBlocks", [Number(blocks)]), value: 0n }),
|
|
@@ -2551,7 +2600,7 @@ var require_intents = __commonJS({
|
|
|
2551
2600
|
|
|
2552
2601
|
// src/utils/logs.js
|
|
2553
2602
|
var require_logs = __commonJS({
|
|
2554
|
-
"src/utils/logs.js"(
|
|
2603
|
+
"src/utils/logs.js"(exports2, module2) {
|
|
2555
2604
|
async function fetchLogsChunked({ provider, address, topics = [], fromBlock = 0, toBlock = "latest", chunkSize = 5e4 }) {
|
|
2556
2605
|
if (!provider) throw new Error("provider required");
|
|
2557
2606
|
const latest = toBlock === "latest" ? await provider.getBlockNumber() : Number(toBlock);
|
|
@@ -2565,7 +2614,7 @@ var require_logs = __commonJS({
|
|
|
2565
2614
|
}
|
|
2566
2615
|
return logs;
|
|
2567
2616
|
}
|
|
2568
|
-
|
|
2617
|
+
module2.exports = {
|
|
2569
2618
|
fetchLogsChunked
|
|
2570
2619
|
};
|
|
2571
2620
|
}
|
|
@@ -2573,7 +2622,7 @@ var require_logs = __commonJS({
|
|
|
2573
2622
|
|
|
2574
2623
|
// src/subdao/index.js
|
|
2575
2624
|
var require_subdao = __commonJS({
|
|
2576
|
-
"src/subdao/index.js"(
|
|
2625
|
+
"src/subdao/index.js"(exports2, module2) {
|
|
2577
2626
|
var { Contract, Interface, getAddress } = __require("ethers");
|
|
2578
2627
|
var ABI = require_abi();
|
|
2579
2628
|
var { fetchLogsChunked } = require_logs();
|
|
@@ -2671,7 +2720,7 @@ var require_subdao = __commonJS({
|
|
|
2671
2720
|
const data = SubDAOInterface.encodeFunctionData("unstake", [BigInt(amount)]);
|
|
2672
2721
|
return { to: addr, data, value: 0n };
|
|
2673
2722
|
}
|
|
2674
|
-
|
|
2723
|
+
module2.exports = {
|
|
2675
2724
|
discoverSubDAOs,
|
|
2676
2725
|
getSubDAOInfo,
|
|
2677
2726
|
getSubDAOUserStats,
|
|
@@ -2784,16 +2833,16 @@ var require_subdao = __commonJS({
|
|
|
2784
2833
|
const op = await makeOperator({ signer, subdao: created.subdao, operator, grantAdmin });
|
|
2785
2834
|
return { ...created, operatorResult: op };
|
|
2786
2835
|
}
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2836
|
+
module2.exports.ensureSxxxBurnAllowance = ensureSxxxBurnAllowance;
|
|
2837
|
+
module2.exports.createSubDAO = createSubDAO;
|
|
2838
|
+
module2.exports.makeOperator = makeOperator;
|
|
2839
|
+
module2.exports.createOperatorSubDAO = createOperatorSubDAO;
|
|
2791
2840
|
}
|
|
2792
2841
|
});
|
|
2793
2842
|
|
|
2794
2843
|
// src/governance/templates.js
|
|
2795
2844
|
var require_templates = __commonJS({
|
|
2796
|
-
"src/governance/templates.js"(
|
|
2845
|
+
"src/governance/templates.js"(exports2, module2) {
|
|
2797
2846
|
var { Contract, ZeroAddress, getAddress, isAddress } = __require("ethers");
|
|
2798
2847
|
var subdao = require_subdao();
|
|
2799
2848
|
var abi = require_abi();
|
|
@@ -2903,7 +2952,7 @@ var require_templates = __commonJS({
|
|
|
2903
2952
|
const receipts = await executeSequence(actions);
|
|
2904
2953
|
return { governor, timelock, receipts };
|
|
2905
2954
|
}
|
|
2906
|
-
|
|
2955
|
+
module2.exports = {
|
|
2907
2956
|
communityDraftsBoardExec,
|
|
2908
2957
|
tokenDemocracy
|
|
2909
2958
|
};
|
|
@@ -2912,7 +2961,7 @@ var require_templates = __commonJS({
|
|
|
2912
2961
|
|
|
2913
2962
|
// src/adapters/governance/openzeppelin.js
|
|
2914
2963
|
var require_openzeppelin = __commonJS({
|
|
2915
|
-
"src/adapters/governance/openzeppelin.js"(
|
|
2964
|
+
"src/adapters/governance/openzeppelin.js"(exports2, module2) {
|
|
2916
2965
|
var { Contract, Interface, getAddress } = __require("ethers");
|
|
2917
2966
|
var axios = __require("axios");
|
|
2918
2967
|
var ABI = require_abi();
|
|
@@ -2958,7 +3007,7 @@ var require_openzeppelin = __commonJS({
|
|
|
2958
3007
|
for (const log of logs) {
|
|
2959
3008
|
try {
|
|
2960
3009
|
const parsed = iface.parseLog(log);
|
|
2961
|
-
const
|
|
3010
|
+
const id2 = BigInt(parsed.args.id.toString());
|
|
2962
3011
|
const proposer = getAddress(parsed.args.proposer);
|
|
2963
3012
|
const targets = parsed.args.targets.map(getAddress);
|
|
2964
3013
|
const values = parsed.args.values.map((v) => BigInt(v.toString()));
|
|
@@ -2968,7 +3017,7 @@ var require_openzeppelin = __commonJS({
|
|
|
2968
3017
|
const block = await provider.getBlock(log.blockNumber).catch(() => ({ timestamp: 0 }));
|
|
2969
3018
|
const quorum = await governance.getQuorumAt({ provider, governor: addr, blockTag: BigInt(endBlock || log.blockNumber) }).catch(() => null);
|
|
2970
3019
|
const signatures = await getSignatureList({ provider, targets, calldatas, abiResolver, selectorResolver, chainId: resolvedChainId });
|
|
2971
|
-
items.push({ id, proposer, createdAt: Number(block.timestamp || 0), startBlock, endBlock, quorum, txHash: log.transactionHash, targets, values, calldatas, signatures });
|
|
3020
|
+
items.push({ id: id2, proposer, createdAt: Number(block.timestamp || 0), startBlock, endBlock, quorum, txHash: log.transactionHash, targets, values, calldatas, signatures });
|
|
2972
3021
|
} catch (_) {
|
|
2973
3022
|
}
|
|
2974
3023
|
}
|
|
@@ -2976,10 +3025,10 @@ var require_openzeppelin = __commonJS({
|
|
|
2976
3025
|
}
|
|
2977
3026
|
return { items, nextCursor: null };
|
|
2978
3027
|
}
|
|
2979
|
-
async function getTimelineOnchain({ provider, governor, id, fromBlock = 0, toBlock = "latest" }) {
|
|
3028
|
+
async function getTimelineOnchain({ provider, governor, id: id2, fromBlock = 0, toBlock = "latest" }) {
|
|
2980
3029
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
2981
3030
|
const addr = normaliseGovernor(governor);
|
|
2982
|
-
const pid = typeof
|
|
3031
|
+
const pid = typeof id2 === "bigint" ? id2 : String(id2).startsWith("0x") ? BigInt(id2) : BigInt(String(id2));
|
|
2983
3032
|
const iface = new Interface([Events.ProposalQueued, Events.ProposalExecuted, Events.ProposalCanceled]);
|
|
2984
3033
|
const topics = [
|
|
2985
3034
|
iface.getEvent("ProposalQueued").topicHash,
|
|
@@ -3144,7 +3193,7 @@ var require_openzeppelin = __commonJS({
|
|
|
3144
3193
|
}
|
|
3145
3194
|
return out;
|
|
3146
3195
|
}
|
|
3147
|
-
|
|
3196
|
+
module2.exports = {
|
|
3148
3197
|
getProposals,
|
|
3149
3198
|
getTimelineOnchain,
|
|
3150
3199
|
getSignatureList,
|
|
@@ -3199,7 +3248,7 @@ var require_openzeppelin = __commonJS({
|
|
|
3199
3248
|
|
|
3200
3249
|
// src/governance/operations.js
|
|
3201
3250
|
var require_operations = __commonJS({
|
|
3202
|
-
"src/governance/operations.js"(
|
|
3251
|
+
"src/governance/operations.js"(exports2, module2) {
|
|
3203
3252
|
var { Contract, getAddress, Interface, ZeroAddress, ZeroHash, keccak256, toUtf8Bytes, formatEther } = __require("ethers");
|
|
3204
3253
|
var governance = require_governance();
|
|
3205
3254
|
var ABI = require_abi();
|
|
@@ -3212,9 +3261,9 @@ var require_operations = __commonJS({
|
|
|
3212
3261
|
throw new SageSDKError(CODES.INVALID_ARGS, "invalid governor address", { cause: error });
|
|
3213
3262
|
}
|
|
3214
3263
|
}
|
|
3215
|
-
function normaliseProposalId(
|
|
3216
|
-
if (typeof
|
|
3217
|
-
const value = String(
|
|
3264
|
+
function normaliseProposalId(id2) {
|
|
3265
|
+
if (typeof id2 === "bigint") return id2;
|
|
3266
|
+
const value = String(id2);
|
|
3218
3267
|
try {
|
|
3219
3268
|
return value.startsWith("0x") ? BigInt(value) : BigInt(value);
|
|
3220
3269
|
} catch (error) {
|
|
@@ -3236,7 +3285,7 @@ var require_operations = __commonJS({
|
|
|
3236
3285
|
if (!load || !save) return null;
|
|
3237
3286
|
return { load, save };
|
|
3238
3287
|
}
|
|
3239
|
-
function normaliseTuple(governor,
|
|
3288
|
+
function normaliseTuple(governor, id2, metadata) {
|
|
3240
3289
|
const targets = Array.isArray(metadata.targets) ? metadata.targets.map((t) => getAddress(t)) : [];
|
|
3241
3290
|
let values = Array.isArray(metadata.values) ? metadata.values.map((v) => BigInt(v)) : new Array(targets.length).fill(BigIntZero);
|
|
3242
3291
|
const calldatas = Array.isArray(metadata.calldatas) ? metadata.calldatas.map(String) : [];
|
|
@@ -3246,7 +3295,7 @@ var require_operations = __commonJS({
|
|
|
3246
3295
|
const description = metadata.description || metadata.body || "";
|
|
3247
3296
|
const descriptionHash = metadata.descriptionHash || (typeof metadata.hashDescription === "function" ? metadata.hashDescription(description) : keccak256(toUtf8Bytes(String(description || ""))));
|
|
3248
3297
|
return {
|
|
3249
|
-
id,
|
|
3298
|
+
id: id2,
|
|
3250
3299
|
governor,
|
|
3251
3300
|
targets,
|
|
3252
3301
|
values,
|
|
@@ -3271,10 +3320,10 @@ var require_operations = __commonJS({
|
|
|
3271
3320
|
}) {
|
|
3272
3321
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
3273
3322
|
const govAddr = normaliseGovernor(governor);
|
|
3274
|
-
const
|
|
3323
|
+
const id2 = normaliseProposalId(proposalId);
|
|
3275
3324
|
const cacheAdapter = wrapCache(cache);
|
|
3276
3325
|
if (!refresh && cacheAdapter) {
|
|
3277
|
-
const cached = await cacheAdapter.load(govAddr,
|
|
3326
|
+
const cached = await cacheAdapter.load(govAddr, id2);
|
|
3278
3327
|
if (cached) return cached;
|
|
3279
3328
|
}
|
|
3280
3329
|
if (helperAddress) {
|
|
@@ -3283,10 +3332,10 @@ var require_operations = __commonJS({
|
|
|
3283
3332
|
"function getProposalTuple(uint256) view returns (address[] targets,uint256[] values,bytes[] calldatas,bytes32 descriptionHash,bool exists)"
|
|
3284
3333
|
];
|
|
3285
3334
|
const helper = new Contract(helperAddress, helperAbi, provider);
|
|
3286
|
-
const res = await helper.getProposalTuple(
|
|
3335
|
+
const res = await helper.getProposalTuple(id2);
|
|
3287
3336
|
if (res && res.exists) {
|
|
3288
3337
|
const tuple2 = {
|
|
3289
|
-
id,
|
|
3338
|
+
id: id2,
|
|
3290
3339
|
governor: normaliseGovernor(governor),
|
|
3291
3340
|
targets: res.targets || [],
|
|
3292
3341
|
values: (res.values || []).map((v) => BigInt(v)),
|
|
@@ -3295,7 +3344,7 @@ var require_operations = __commonJS({
|
|
|
3295
3344
|
descriptionHash: res.descriptionHash || null,
|
|
3296
3345
|
createdBlock: null
|
|
3297
3346
|
};
|
|
3298
|
-
if (cacheAdapter) await cacheAdapter.save(governor,
|
|
3347
|
+
if (cacheAdapter) await cacheAdapter.save(governor, id2, tuple2);
|
|
3299
3348
|
return tuple2;
|
|
3300
3349
|
}
|
|
3301
3350
|
} catch (_) {
|
|
@@ -3303,7 +3352,7 @@ var require_operations = __commonJS({
|
|
|
3303
3352
|
}
|
|
3304
3353
|
let metadata = null;
|
|
3305
3354
|
try {
|
|
3306
|
-
metadata = await governance.getProposalMetadata({ provider, governor: govAddr, id });
|
|
3355
|
+
metadata = await governance.getProposalMetadata({ provider, governor: govAddr, id: id2 });
|
|
3307
3356
|
} catch (_) {
|
|
3308
3357
|
metadata = null;
|
|
3309
3358
|
}
|
|
@@ -3312,7 +3361,7 @@ var require_operations = __commonJS({
|
|
|
3312
3361
|
try {
|
|
3313
3362
|
const govAbi = new Interface(ABI.Governor);
|
|
3314
3363
|
const govC = new Contract(govAddr, govAbi, provider);
|
|
3315
|
-
const snapshot = hints.snapshot ?? await govC.proposalSnapshot(
|
|
3364
|
+
const snapshot = hints.snapshot ?? await govC.proposalSnapshot(id2).catch(() => null);
|
|
3316
3365
|
const votingDelay = hints.votingDelay ?? await govC.votingDelay().catch(() => null);
|
|
3317
3366
|
if (snapshot !== null && votingDelay !== null) {
|
|
3318
3367
|
const approxCreation = Number(snapshot) - Number(votingDelay);
|
|
@@ -3335,9 +3384,9 @@ var require_operations = __commonJS({
|
|
|
3335
3384
|
try {
|
|
3336
3385
|
const parsed = govC.interface.parseLog(log);
|
|
3337
3386
|
const pid = normaliseProposalId(parsed.args.proposalId);
|
|
3338
|
-
if (pid ===
|
|
3387
|
+
if (pid === id2) {
|
|
3339
3388
|
metadata = {
|
|
3340
|
-
id,
|
|
3389
|
+
id: id2,
|
|
3341
3390
|
governor: govAddr,
|
|
3342
3391
|
targets: Array.from(parsed.args.targets || [], String),
|
|
3343
3392
|
values: Array.from(parsed.args.values || [], (v) => BigInt(v.toString())),
|
|
@@ -3362,7 +3411,7 @@ var require_operations = __commonJS({
|
|
|
3362
3411
|
const page = await governance.listProposals({ provider, governor: govAddr, fromBlock, toBlock: "latest" });
|
|
3363
3412
|
metadata = page.find((entry) => {
|
|
3364
3413
|
try {
|
|
3365
|
-
return normaliseProposalId(entry.id || entry.proposalId) ===
|
|
3414
|
+
return normaliseProposalId(entry.id || entry.proposalId) === id2;
|
|
3366
3415
|
} catch (_) {
|
|
3367
3416
|
return false;
|
|
3368
3417
|
}
|
|
@@ -3372,9 +3421,9 @@ var require_operations = __commonJS({
|
|
|
3372
3421
|
if (!metadata) {
|
|
3373
3422
|
throw new SageSDKError(CODES.NOT_FOUND, "proposal tuple not found");
|
|
3374
3423
|
}
|
|
3375
|
-
const tuple = normaliseTuple(govAddr,
|
|
3424
|
+
const tuple = normaliseTuple(govAddr, id2, metadata);
|
|
3376
3425
|
if (cacheAdapter) {
|
|
3377
|
-
await cacheAdapter.save(govAddr,
|
|
3426
|
+
await cacheAdapter.save(govAddr, id2, tuple);
|
|
3378
3427
|
}
|
|
3379
3428
|
return tuple;
|
|
3380
3429
|
}
|
|
@@ -3659,7 +3708,7 @@ var require_operations = __commonJS({
|
|
|
3659
3708
|
}
|
|
3660
3709
|
return results;
|
|
3661
3710
|
}
|
|
3662
|
-
|
|
3711
|
+
module2.exports = {
|
|
3663
3712
|
resolveProposalTuple,
|
|
3664
3713
|
queueProposal,
|
|
3665
3714
|
executeProposal,
|
|
@@ -3670,9 +3719,94 @@ var require_operations = __commonJS({
|
|
|
3670
3719
|
}
|
|
3671
3720
|
});
|
|
3672
3721
|
|
|
3722
|
+
// src/governance/grants.js
|
|
3723
|
+
var require_grants = __commonJS({
|
|
3724
|
+
"src/governance/grants.js"(exports2, module2) {
|
|
3725
|
+
var { Interface, getAddress, isAddress, parseUnits } = __require("ethers");
|
|
3726
|
+
var { SageSDKError, CODES } = require_errors();
|
|
3727
|
+
function normalizeAddress(label, value) {
|
|
3728
|
+
if (!value) throw new SageSDKError(CODES.INVALID_ARGS, `${label} required`);
|
|
3729
|
+
if (!isAddress(value)) throw new SageSDKError(CODES.INVALID_ARGS, `${label} invalid`);
|
|
3730
|
+
return getAddress(value);
|
|
3731
|
+
}
|
|
3732
|
+
async function buildGrantProposal({ provider = null, vault, token, recipient, amount, decimals = null, raw = false, description = null }) {
|
|
3733
|
+
const vaultAddr = normalizeAddress("vault", vault);
|
|
3734
|
+
const tokenAddr = normalizeAddress("token", token);
|
|
3735
|
+
const rcptAddr = normalizeAddress("recipient", recipient);
|
|
3736
|
+
if (amount == null) throw new SageSDKError(CODES.INVALID_ARGS, "amount required");
|
|
3737
|
+
let resolvedDecimals = decimals != null ? Number(decimals) : null;
|
|
3738
|
+
let symbol = null;
|
|
3739
|
+
if (provider && resolvedDecimals == null) {
|
|
3740
|
+
try {
|
|
3741
|
+
const erc20 = new (__require("ethers")).Contract(tokenAddr, ["function decimals() view returns (uint8)", "function symbol() view returns (string)"], provider);
|
|
3742
|
+
resolvedDecimals = Number(await erc20.decimals());
|
|
3743
|
+
symbol = await erc20.symbol().catch(() => null);
|
|
3744
|
+
} catch (_) {
|
|
3745
|
+
}
|
|
3746
|
+
}
|
|
3747
|
+
if (resolvedDecimals == null) resolvedDecimals = 18;
|
|
3748
|
+
let amtWei;
|
|
3749
|
+
if (raw) {
|
|
3750
|
+
amtWei = BigInt(String(amount));
|
|
3751
|
+
} else {
|
|
3752
|
+
amtWei = parseUnits(String(amount), resolvedDecimals);
|
|
3753
|
+
}
|
|
3754
|
+
const iface = new Interface(["function withdraw(address token,uint256 amount,address recipient)"]);
|
|
3755
|
+
const data = iface.encodeFunctionData("withdraw", [tokenAddr, amtWei, rcptAddr]);
|
|
3756
|
+
const targets = [vaultAddr];
|
|
3757
|
+
const values = [0n];
|
|
3758
|
+
const calldatas = [data];
|
|
3759
|
+
const desc = description && description.length ? description : `Grant ${String(amount)}${symbol ? " " + symbol : ""} to ${rcptAddr}`;
|
|
3760
|
+
return { targets, values, calldatas, description: desc };
|
|
3761
|
+
}
|
|
3762
|
+
module2.exports = {
|
|
3763
|
+
buildGrantProposal,
|
|
3764
|
+
/**
|
|
3765
|
+
* Build a batched proposal for multiple grants. Each item can specify its own vault
|
|
3766
|
+
* or inherit from defaultVault. Decimals are resolved per-token when provider is present.
|
|
3767
|
+
* items: Array<{ vault?, token, recipient, amount, decimals?, raw? }>
|
|
3768
|
+
*/
|
|
3769
|
+
buildBatchGrantProposal: async function buildBatchGrantProposal({ provider = null, items = [], defaultVault = null, description = null }) {
|
|
3770
|
+
if (!Array.isArray(items) || items.length === 0) {
|
|
3771
|
+
throw new SageSDKError(CODES.INVALID_ARGS, "items required");
|
|
3772
|
+
}
|
|
3773
|
+
const targets = [];
|
|
3774
|
+
const values = [];
|
|
3775
|
+
const calldatas = [];
|
|
3776
|
+
const iface = new Interface(["function withdraw(address token,uint256 amount,address recipient)"]);
|
|
3777
|
+
for (const [i, it] of items.entries()) {
|
|
3778
|
+
const vault = it.vault || defaultVault;
|
|
3779
|
+
if (!vault) throw new SageSDKError(CODES.INVALID_ARGS, `item[${i}]: vault missing and no defaultVault provided`);
|
|
3780
|
+
const vaultAddr = normalizeAddress("vault", vault);
|
|
3781
|
+
const tokenAddr = normalizeAddress("token", it.token);
|
|
3782
|
+
const rcptAddr = normalizeAddress("recipient", it.recipient);
|
|
3783
|
+
let resolvedDecimals = it.decimals != null ? Number(it.decimals) : null;
|
|
3784
|
+
if (provider && resolvedDecimals == null && !it.raw) {
|
|
3785
|
+
try {
|
|
3786
|
+
const erc20 = new (__require("ethers")).Contract(tokenAddr, ["function decimals() view returns (uint8)"], provider);
|
|
3787
|
+
resolvedDecimals = Number(await erc20.decimals());
|
|
3788
|
+
} catch (_) {
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3791
|
+
if (resolvedDecimals == null) resolvedDecimals = 18;
|
|
3792
|
+
let amtWei;
|
|
3793
|
+
if (it.raw) amtWei = BigInt(String(it.amount));
|
|
3794
|
+
else amtWei = parseUnits(String(it.amount), resolvedDecimals);
|
|
3795
|
+
const data = iface.encodeFunctionData("withdraw", [tokenAddr, amtWei, rcptAddr]);
|
|
3796
|
+
targets.push(vaultAddr);
|
|
3797
|
+
values.push(0n);
|
|
3798
|
+
calldatas.push(data);
|
|
3799
|
+
}
|
|
3800
|
+
const desc = description && description.length ? description : `Batch Grants: ${items.length} transfer(s)`;
|
|
3801
|
+
return { targets, values, calldatas, description: desc };
|
|
3802
|
+
}
|
|
3803
|
+
};
|
|
3804
|
+
}
|
|
3805
|
+
});
|
|
3806
|
+
|
|
3673
3807
|
// src/timelock/index.js
|
|
3674
3808
|
var require_timelock = __commonJS({
|
|
3675
|
-
"src/timelock/index.js"(
|
|
3809
|
+
"src/timelock/index.js"(exports2, module2) {
|
|
3676
3810
|
var { Contract, Interface, getAddress } = __require("ethers");
|
|
3677
3811
|
var { SageSDKError, CODES } = require_errors();
|
|
3678
3812
|
var TimelockABI = [
|
|
@@ -3732,8 +3866,8 @@ var require_timelock = __commonJS({
|
|
|
3732
3866
|
for (const log of logs) {
|
|
3733
3867
|
try {
|
|
3734
3868
|
const parsed = iface.parseLog(log);
|
|
3735
|
-
const
|
|
3736
|
-
const op = operations.get(
|
|
3869
|
+
const id2 = parsed.args.id;
|
|
3870
|
+
const op = operations.get(id2) || { id: id2, scheduled: [], executed: [], cancelled: false };
|
|
3737
3871
|
if (parsed.name === "CallScheduled") {
|
|
3738
3872
|
op.scheduled.push({
|
|
3739
3873
|
index: Number(parsed.args.index),
|
|
@@ -3755,14 +3889,14 @@ var require_timelock = __commonJS({
|
|
|
3755
3889
|
} else if (parsed.name === "Cancelled") {
|
|
3756
3890
|
op.cancelled = true;
|
|
3757
3891
|
}
|
|
3758
|
-
operations.set(
|
|
3892
|
+
operations.set(id2, op);
|
|
3759
3893
|
} catch (err) {
|
|
3760
3894
|
continue;
|
|
3761
3895
|
}
|
|
3762
3896
|
}
|
|
3763
3897
|
return Array.from(operations.values());
|
|
3764
3898
|
}
|
|
3765
|
-
|
|
3899
|
+
module2.exports = {
|
|
3766
3900
|
getTimelockInfo,
|
|
3767
3901
|
listQueuedOperations,
|
|
3768
3902
|
buildScheduleTx: ({ timelock, target, value = 0n, data = "0x", predecessor = "0x0000000000000000000000000000000000000000000000000000000000000000", salt = "0x0000000000000000000000000000000000000000000000000000000000000000", delay = 0n }) => {
|
|
@@ -3778,10 +3912,10 @@ var require_timelock = __commonJS({
|
|
|
3778
3912
|
]);
|
|
3779
3913
|
return { to, data: payload, value: 0n };
|
|
3780
3914
|
},
|
|
3781
|
-
buildCancelTx: ({ timelock, id }) => {
|
|
3782
|
-
if (!
|
|
3915
|
+
buildCancelTx: ({ timelock, id: id2 }) => {
|
|
3916
|
+
if (!id2) throw new SageSDKError(CODES.INVALID_ARGS, "operation id required");
|
|
3783
3917
|
const addr = normalise(timelock, "timelock");
|
|
3784
|
-
const payload = TimelockInterface.encodeFunctionData("cancel", [
|
|
3918
|
+
const payload = TimelockInterface.encodeFunctionData("cancel", [id2]);
|
|
3785
3919
|
return { to: addr, data: payload, value: 0n };
|
|
3786
3920
|
},
|
|
3787
3921
|
buildExecuteTx: ({ timelock, target, value = 0n, data = "0x", predecessor = "0x0000000000000000000000000000000000000000000000000000000000000000", salt = "0x0000000000000000000000000000000000000000000000000000000000000000" }) => {
|
|
@@ -3801,7 +3935,7 @@ var require_timelock = __commonJS({
|
|
|
3801
3935
|
|
|
3802
3936
|
// src/factory/index.js
|
|
3803
3937
|
var require_factory = __commonJS({
|
|
3804
|
-
"src/factory/index.js"(
|
|
3938
|
+
"src/factory/index.js"(exports2, module2) {
|
|
3805
3939
|
var { Contract, Interface, getAddress } = __require("ethers");
|
|
3806
3940
|
var ABI = require_abi();
|
|
3807
3941
|
var { SageSDKError, CODES } = require_errors();
|
|
@@ -3890,10 +4024,10 @@ var require_factory = __commonJS({
|
|
|
3890
4024
|
const moduleContract = new Contract(templateAddr, ABI.TemplateModule, provider);
|
|
3891
4025
|
const ids = await moduleContract.getActiveTemplates().catch(() => []);
|
|
3892
4026
|
const templates = [];
|
|
3893
|
-
for (const
|
|
3894
|
-
const template = await moduleContract.getTemplateStruct(
|
|
4027
|
+
for (const id2 of ids) {
|
|
4028
|
+
const template = await moduleContract.getTemplateStruct(id2);
|
|
3895
4029
|
templates.push({
|
|
3896
|
-
id: Number(
|
|
4030
|
+
id: Number(id2),
|
|
3897
4031
|
name: template[0],
|
|
3898
4032
|
description: template[1],
|
|
3899
4033
|
accessModel: Number(template[2]),
|
|
@@ -4072,7 +4206,7 @@ var require_factory = __commonJS({
|
|
|
4072
4206
|
return null;
|
|
4073
4207
|
}
|
|
4074
4208
|
}
|
|
4075
|
-
|
|
4209
|
+
module2.exports = {
|
|
4076
4210
|
getFactoryConfig,
|
|
4077
4211
|
getFactoryStats,
|
|
4078
4212
|
listSubDAOs,
|
|
@@ -4090,7 +4224,7 @@ var require_factory = __commonJS({
|
|
|
4090
4224
|
|
|
4091
4225
|
// src/prompt/execute.js
|
|
4092
4226
|
var require_execute = __commonJS({
|
|
4093
|
-
"src/prompt/execute.js"(
|
|
4227
|
+
"src/prompt/execute.js"(exports2, module2) {
|
|
4094
4228
|
var axios = __require("axios");
|
|
4095
4229
|
var { createEchoOpenAI } = __require("@merit-systems/echo-typescript-sdk");
|
|
4096
4230
|
var { generateText } = __require("ai");
|
|
@@ -4280,13 +4414,13 @@ ${JSON.stringify(residual, null, 2)}`
|
|
|
4280
4414
|
forkDepth: Number(data.forkDepth || 0)
|
|
4281
4415
|
};
|
|
4282
4416
|
};
|
|
4283
|
-
|
|
4417
|
+
module2.exports = { SageEchoExecutor };
|
|
4284
4418
|
}
|
|
4285
4419
|
});
|
|
4286
4420
|
|
|
4287
4421
|
// src/prompt/index.js
|
|
4288
4422
|
var require_prompt = __commonJS({
|
|
4289
|
-
"src/prompt/index.js"(
|
|
4423
|
+
"src/prompt/index.js"(exports2, module2) {
|
|
4290
4424
|
var { Contract, getAddress } = __require("ethers");
|
|
4291
4425
|
var ABI = require_abi();
|
|
4292
4426
|
var { SageSDKError, CODES } = require_errors();
|
|
@@ -4348,8 +4482,8 @@ var require_prompt = __commonJS({
|
|
|
4348
4482
|
for (let i = 1; i <= upto; i++) ids.push(i);
|
|
4349
4483
|
}
|
|
4350
4484
|
const results = [];
|
|
4351
|
-
for (const
|
|
4352
|
-
const key = await contract.getPromptKey(
|
|
4485
|
+
for (const id2 of ids) {
|
|
4486
|
+
const key = await contract.getPromptKey(id2).catch(() => null);
|
|
4353
4487
|
if (!key) continue;
|
|
4354
4488
|
results.push(await getPromptData({ provider, registry: addr, key }));
|
|
4355
4489
|
}
|
|
@@ -4361,8 +4495,8 @@ var require_prompt = __commonJS({
|
|
|
4361
4495
|
const contract = new Contract(addr, ABI.PromptRegistry, provider);
|
|
4362
4496
|
const ids = await contract.getByTagPage(tagHash, BigInt(offset), BigInt(Math.min(Number(limit), 100)));
|
|
4363
4497
|
const out = [];
|
|
4364
|
-
for (const
|
|
4365
|
-
const key = await contract.getPromptKey(
|
|
4498
|
+
for (const id2 of ids) {
|
|
4499
|
+
const key = await contract.getPromptKey(id2).catch(() => null);
|
|
4366
4500
|
if (!key) continue;
|
|
4367
4501
|
out.push(await getPromptData({ provider, registry: addr, key }));
|
|
4368
4502
|
}
|
|
@@ -4374,8 +4508,8 @@ var require_prompt = __commonJS({
|
|
|
4374
4508
|
const contract = new Contract(addr, ABI.PromptRegistry, provider);
|
|
4375
4509
|
const ids = await contract.getByCreatorPage(getAddress(creator), BigInt(offset), BigInt(Math.min(Number(limit), 100)));
|
|
4376
4510
|
const out = [];
|
|
4377
|
-
for (const
|
|
4378
|
-
const key = await contract.getPromptKey(
|
|
4511
|
+
for (const id2 of ids) {
|
|
4512
|
+
const key = await contract.getPromptKey(id2).catch(() => null);
|
|
4379
4513
|
if (!key) continue;
|
|
4380
4514
|
out.push(await getPromptData({ provider, registry: addr, key }));
|
|
4381
4515
|
}
|
|
@@ -4387,8 +4521,8 @@ var require_prompt = __commonJS({
|
|
|
4387
4521
|
const contract = new Contract(addr, ABI.PromptRegistry, provider);
|
|
4388
4522
|
const ids = await contract.getByCategoryPage(Number(category), BigInt(offset), BigInt(Math.min(Number(limit), 100)));
|
|
4389
4523
|
const out = [];
|
|
4390
|
-
for (const
|
|
4391
|
-
const key = await contract.getPromptKey(
|
|
4524
|
+
for (const id2 of ids) {
|
|
4525
|
+
const key = await contract.getPromptKey(id2).catch(() => null);
|
|
4392
4526
|
if (!key) continue;
|
|
4393
4527
|
out.push(await getPromptData({ provider, registry: addr, key }));
|
|
4394
4528
|
}
|
|
@@ -4412,7 +4546,7 @@ var require_prompt = __commonJS({
|
|
|
4412
4546
|
const contract = new Contract(addr, ABI.PromptRegistry, provider);
|
|
4413
4547
|
return contract.usageCount(key).catch(() => 0);
|
|
4414
4548
|
}
|
|
4415
|
-
|
|
4549
|
+
module2.exports = {
|
|
4416
4550
|
getPromptData,
|
|
4417
4551
|
listPrompts,
|
|
4418
4552
|
listByTagPage,
|
|
@@ -4461,7 +4595,7 @@ var require_prompt = __commonJS({
|
|
|
4461
4595
|
|
|
4462
4596
|
// src/ipns/index.js
|
|
4463
4597
|
var require_ipns = __commonJS({
|
|
4464
|
-
"src/ipns/index.js"(
|
|
4598
|
+
"src/ipns/index.js"(exports2, module2) {
|
|
4465
4599
|
var axiosDefault = __require("axios");
|
|
4466
4600
|
var contentHashLib = null;
|
|
4467
4601
|
try {
|
|
@@ -4478,9 +4612,9 @@ var require_ipns = __commonJS({
|
|
|
4478
4612
|
function removeTrailingSlash(str) {
|
|
4479
4613
|
return str ? str.replace(/\/$/, "") : str;
|
|
4480
4614
|
}
|
|
4481
|
-
function ensureLeadingSlash(
|
|
4482
|
-
if (!
|
|
4483
|
-
return
|
|
4615
|
+
function ensureLeadingSlash(path2) {
|
|
4616
|
+
if (!path2) return "/";
|
|
4617
|
+
return path2.startsWith("/") ? path2 : `/${path2}`;
|
|
4484
4618
|
}
|
|
4485
4619
|
function dedupe(list = []) {
|
|
4486
4620
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -4575,10 +4709,10 @@ var require_ipns = __commonJS({
|
|
|
4575
4709
|
}
|
|
4576
4710
|
return null;
|
|
4577
4711
|
}
|
|
4578
|
-
async function fetchWithGateways(
|
|
4712
|
+
async function fetchWithGateways(path2, axiosInstance, gateways, { timeout, attempts = 3, baseDelay = 500, jitterMs = 250 } = {}) {
|
|
4579
4713
|
const errors = [];
|
|
4580
4714
|
const unique = dedupe(gateways);
|
|
4581
|
-
const suffix =
|
|
4715
|
+
const suffix = path2.replace(/^\/+/, "");
|
|
4582
4716
|
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
|
4583
4717
|
const delayMs = attempt === 0 ? 0 : jitter(baseDelay * attempt, jitterMs);
|
|
4584
4718
|
if (delayMs) await delay(delayMs);
|
|
@@ -4600,7 +4734,7 @@ var require_ipns = __commonJS({
|
|
|
4600
4734
|
}
|
|
4601
4735
|
}
|
|
4602
4736
|
}
|
|
4603
|
-
const failure = new Error(`Failed to fetch ${
|
|
4737
|
+
const failure = new Error(`Failed to fetch ${path2} from gateways`);
|
|
4604
4738
|
failure.attempts = errors;
|
|
4605
4739
|
throw failure;
|
|
4606
4740
|
}
|
|
@@ -4843,7 +4977,7 @@ var require_ipns = __commonJS({
|
|
|
4843
4977
|
}
|
|
4844
4978
|
};
|
|
4845
4979
|
}
|
|
4846
|
-
|
|
4980
|
+
module2.exports = {
|
|
4847
4981
|
createClient,
|
|
4848
4982
|
normalizeIpnsName,
|
|
4849
4983
|
normalizeCid,
|
|
@@ -4854,7 +4988,7 @@ var require_ipns = __commonJS({
|
|
|
4854
4988
|
|
|
4855
4989
|
// src/token/index.js
|
|
4856
4990
|
var require_token = __commonJS({
|
|
4857
|
-
"src/token/index.js"(
|
|
4991
|
+
"src/token/index.js"(exports2, module2) {
|
|
4858
4992
|
var { Contract, Interface, getAddress } = __require("ethers");
|
|
4859
4993
|
var ABI = require_abi();
|
|
4860
4994
|
var { SageSDKError, CODES } = require_errors();
|
|
@@ -5006,7 +5140,7 @@ var require_token = __commonJS({
|
|
|
5006
5140
|
function getBurnConstants() {
|
|
5007
5141
|
return { ...BURN_CONSTANTS };
|
|
5008
5142
|
}
|
|
5009
|
-
|
|
5143
|
+
module2.exports = {
|
|
5010
5144
|
getBalance,
|
|
5011
5145
|
getVotes,
|
|
5012
5146
|
getTotalSupply,
|
|
@@ -5026,8 +5160,8 @@ var require_token = __commonJS({
|
|
|
5026
5160
|
|
|
5027
5161
|
// src/personal/helpers.js
|
|
5028
5162
|
var require_helpers = __commonJS({
|
|
5029
|
-
"src/personal/helpers.js"(
|
|
5030
|
-
var { getAddress, ZeroAddress, id } = __require("ethers");
|
|
5163
|
+
"src/personal/helpers.js"(exports2, module2) {
|
|
5164
|
+
var { getAddress, ZeroAddress, id: id2 } = __require("ethers");
|
|
5031
5165
|
function normaliseAddress(addr, label) {
|
|
5032
5166
|
if (!addr) throw new Error(`[personal] missing ${label}`);
|
|
5033
5167
|
const value = addr.toString();
|
|
@@ -5038,9 +5172,9 @@ var require_helpers = __commonJS({
|
|
|
5038
5172
|
if (typeof key === "string" && key.startsWith("0x") && key.length === 66) {
|
|
5039
5173
|
return key;
|
|
5040
5174
|
}
|
|
5041
|
-
return
|
|
5175
|
+
return id2(key);
|
|
5042
5176
|
}
|
|
5043
|
-
|
|
5177
|
+
module2.exports = {
|
|
5044
5178
|
normaliseAddress,
|
|
5045
5179
|
toBytes32Key
|
|
5046
5180
|
};
|
|
@@ -5049,7 +5183,7 @@ var require_helpers = __commonJS({
|
|
|
5049
5183
|
|
|
5050
5184
|
// src/personal/receipt.js
|
|
5051
5185
|
var require_receipt = __commonJS({
|
|
5052
|
-
"src/personal/receipt.js"(
|
|
5186
|
+
"src/personal/receipt.js"(exports2, module2) {
|
|
5053
5187
|
var { Contract, getAddress, solidityPackedKeccak256 } = __require("ethers");
|
|
5054
5188
|
var ABI = require_abi();
|
|
5055
5189
|
var { normaliseAddress, toBytes32Key } = require_helpers();
|
|
@@ -5067,11 +5201,11 @@ var require_receipt = __commonJS({
|
|
|
5067
5201
|
const receiptAddress = normaliseAddress(receipt, "receipt");
|
|
5068
5202
|
const holderAddress = normaliseAddress(holder, "holder");
|
|
5069
5203
|
const contract = new Contract(receiptAddress, ABI.PersonalLicenseReceipt, provider);
|
|
5070
|
-
const
|
|
5071
|
-
const balance = await contract.balanceOf(holderAddress,
|
|
5204
|
+
const id2 = typeof receiptId === "bigint" ? receiptId : BigInt(receiptId);
|
|
5205
|
+
const balance = await contract.balanceOf(holderAddress, id2);
|
|
5072
5206
|
return typeof balance === "bigint" ? balance : BigInt(balance.toString());
|
|
5073
5207
|
}
|
|
5074
|
-
|
|
5208
|
+
module2.exports = {
|
|
5075
5209
|
computeReceiptId,
|
|
5076
5210
|
getReceiptBalance
|
|
5077
5211
|
};
|
|
@@ -5080,7 +5214,7 @@ var require_receipt = __commonJS({
|
|
|
5080
5214
|
|
|
5081
5215
|
// src/personal/access.js
|
|
5082
5216
|
var require_access = __commonJS({
|
|
5083
|
-
"src/personal/access.js"(
|
|
5217
|
+
"src/personal/access.js"(exports2, module2) {
|
|
5084
5218
|
var { uint8arrayToString } = __require("@lit-protocol/uint8arrays");
|
|
5085
5219
|
var subgraph = require_subgraph();
|
|
5086
5220
|
var { normaliseAddress, toBytes32Key } = require_helpers();
|
|
@@ -5255,7 +5389,7 @@ var require_access = __commonJS({
|
|
|
5255
5389
|
}
|
|
5256
5390
|
return uint8arrayToString(response.decryptedData, "utf8");
|
|
5257
5391
|
}
|
|
5258
|
-
|
|
5392
|
+
module2.exports = {
|
|
5259
5393
|
resolveEncryptedResource,
|
|
5260
5394
|
decryptWithLit
|
|
5261
5395
|
};
|
|
@@ -5264,7 +5398,7 @@ var require_access = __commonJS({
|
|
|
5264
5398
|
|
|
5265
5399
|
// src/personal/index.js
|
|
5266
5400
|
var require_personal = __commonJS({
|
|
5267
|
-
"src/personal/index.js"(
|
|
5401
|
+
"src/personal/index.js"(exports2, module2) {
|
|
5268
5402
|
var { Interface } = __require("ethers");
|
|
5269
5403
|
var ABI = require_abi();
|
|
5270
5404
|
var { normaliseAddress, toBytes32Key } = require_helpers();
|
|
@@ -5292,7 +5426,7 @@ var require_personal = __commonJS({
|
|
|
5292
5426
|
]);
|
|
5293
5427
|
return { to, data, value: 0n };
|
|
5294
5428
|
}
|
|
5295
|
-
|
|
5429
|
+
module2.exports = {
|
|
5296
5430
|
buildCreatePersonalRegistryTx,
|
|
5297
5431
|
buildSetPriceTx,
|
|
5298
5432
|
buildBuyTx,
|
|
@@ -5304,7 +5438,7 @@ var require_personal = __commonJS({
|
|
|
5304
5438
|
|
|
5305
5439
|
// src/utils/privateTx.js
|
|
5306
5440
|
var require_privateTx = __commonJS({
|
|
5307
|
-
"src/utils/privateTx.js"(
|
|
5441
|
+
"src/utils/privateTx.js"(exports2, module2) {
|
|
5308
5442
|
var axios = __require("axios");
|
|
5309
5443
|
async function sendPrivateRaw({ privateRpcUrl, signedTx, preferences = {} }) {
|
|
5310
5444
|
const body = {
|
|
@@ -5336,7 +5470,7 @@ var require_privateTx = __commonJS({
|
|
|
5336
5470
|
const sent = await signer.sendTransaction(tx);
|
|
5337
5471
|
return { hash: sent.hash, tx: sent };
|
|
5338
5472
|
}
|
|
5339
|
-
|
|
5473
|
+
module2.exports = {
|
|
5340
5474
|
sendTransaction
|
|
5341
5475
|
};
|
|
5342
5476
|
}
|
|
@@ -5344,7 +5478,7 @@ var require_privateTx = __commonJS({
|
|
|
5344
5478
|
|
|
5345
5479
|
// src/utils/safe.js
|
|
5346
5480
|
var require_safe = __commonJS({
|
|
5347
|
-
"src/utils/safe.js"(
|
|
5481
|
+
"src/utils/safe.js"(exports2, module2) {
|
|
5348
5482
|
function toSafeTx(tx, opts = {}) {
|
|
5349
5483
|
const op = Number(opts.operation ?? 0);
|
|
5350
5484
|
return {
|
|
@@ -5360,13 +5494,13 @@ var require_safe = __commonJS({
|
|
|
5360
5494
|
function toSafeTxList(txs, opts = {}) {
|
|
5361
5495
|
return txs.map((t, i) => toSafeTx(t, { ...opts, nonce: opts.nonce != null ? Number(opts.nonce) + i : void 0 }));
|
|
5362
5496
|
}
|
|
5363
|
-
|
|
5497
|
+
module2.exports = { toSafeTx, toSafeTxList };
|
|
5364
5498
|
}
|
|
5365
5499
|
});
|
|
5366
5500
|
|
|
5367
5501
|
// src/treasury/index.js
|
|
5368
5502
|
var require_treasury = __commonJS({
|
|
5369
|
-
"src/treasury/index.js"(
|
|
5503
|
+
"src/treasury/index.js"(exports2, module2) {
|
|
5370
5504
|
var { Contract, Interface, getAddress } = __require("ethers");
|
|
5371
5505
|
var ABI = require_abi();
|
|
5372
5506
|
var { SageSDKError, CODES } = require_errors();
|
|
@@ -5447,12 +5581,12 @@ var require_treasury = __commonJS({
|
|
|
5447
5581
|
idList = Array.from({ length: total - start }, (_, i) => start + i);
|
|
5448
5582
|
}
|
|
5449
5583
|
const withdrawals = [];
|
|
5450
|
-
for (const
|
|
5451
|
-
const entry = await contract.pendingWithdrawals(
|
|
5584
|
+
for (const id2 of idList) {
|
|
5585
|
+
const entry = await contract.pendingWithdrawals(id2).catch(() => null);
|
|
5452
5586
|
if (!entry || !entry.exists) continue;
|
|
5453
5587
|
const [token, recipient, amount, value, requester, balanceBefore, recipientBalanceBefore, depositSnapshot, isLP, isEmergency] = entry;
|
|
5454
5588
|
withdrawals.push({
|
|
5455
|
-
id: Number(
|
|
5589
|
+
id: Number(id2),
|
|
5456
5590
|
token: token && token !== ZERO_ADDRESS ? getAddress(token) : null,
|
|
5457
5591
|
recipient: recipient && recipient !== ZERO_ADDRESS ? getAddress(recipient) : null,
|
|
5458
5592
|
amount: toBigInt(amount),
|
|
@@ -5627,17 +5761,17 @@ var require_treasury = __commonJS({
|
|
|
5627
5761
|
id: parsed?.id != null ? Number(parsed.id) : null
|
|
5628
5762
|
};
|
|
5629
5763
|
}
|
|
5630
|
-
async function confirmWithdrawal({ signer, treasury, id, waitMs }) {
|
|
5764
|
+
async function confirmWithdrawal({ signer, treasury, id: id2, waitMs }) {
|
|
5631
5765
|
const contract = createWriteContract({ signer, treasury });
|
|
5632
|
-
const tx = await contract.confirmWithdrawal(Number(
|
|
5766
|
+
const tx = await contract.confirmWithdrawal(Number(id2));
|
|
5633
5767
|
const receipt = await waitForReceipt({ signer, tx, waitMs });
|
|
5634
|
-
return { transaction: tx, receipt, id: Number(
|
|
5768
|
+
return { transaction: tx, receipt, id: Number(id2) };
|
|
5635
5769
|
}
|
|
5636
|
-
async function cancelWithdrawal({ signer, treasury, id, waitMs }) {
|
|
5770
|
+
async function cancelWithdrawal({ signer, treasury, id: id2, waitMs }) {
|
|
5637
5771
|
const contract = createWriteContract({ signer, treasury });
|
|
5638
|
-
const tx = await contract.cancelWithdrawal(Number(
|
|
5772
|
+
const tx = await contract.cancelWithdrawal(Number(id2));
|
|
5639
5773
|
const receipt = await waitForReceipt({ signer, tx, waitMs });
|
|
5640
|
-
return { transaction: tx, receipt, id: Number(
|
|
5774
|
+
return { transaction: tx, receipt, id: Number(id2) };
|
|
5641
5775
|
}
|
|
5642
5776
|
async function setPriceOverride({ signer, treasury, token, price, ttlSeconds, waitMs }) {
|
|
5643
5777
|
const contract = createWriteContract({ signer, treasury });
|
|
@@ -5679,7 +5813,7 @@ var require_treasury = __commonJS({
|
|
|
5679
5813
|
}
|
|
5680
5814
|
return null;
|
|
5681
5815
|
}
|
|
5682
|
-
|
|
5816
|
+
module2.exports = {
|
|
5683
5817
|
getTreasuryInfo,
|
|
5684
5818
|
getPendingWithdrawals,
|
|
5685
5819
|
getCanonicalLiquidityPlans,
|
|
@@ -5691,14 +5825,30 @@ var require_treasury = __commonJS({
|
|
|
5691
5825
|
confirmWithdrawal,
|
|
5692
5826
|
cancelWithdrawal,
|
|
5693
5827
|
setPriceOverride,
|
|
5694
|
-
clearPriceOverride
|
|
5828
|
+
clearPriceOverride,
|
|
5829
|
+
// TX builders for app usage
|
|
5830
|
+
buildApproveTx: ({ token, spender, amount, decimals = 18 }) => {
|
|
5831
|
+
if (!token || !spender) throw new SageSDKError(CODES.INVALID_ARGS, "token and spender required");
|
|
5832
|
+
const iface = new Interface(["function approve(address,uint256)"]);
|
|
5833
|
+
return { to: getAddress(token), data: iface.encodeFunctionData("approve", [getAddress(spender), BigInt(amount.toString ? amount.toString() : amount)]), value: 0n };
|
|
5834
|
+
},
|
|
5835
|
+
buildTransferTx: ({ token, to, amount, decimals = 18 }) => {
|
|
5836
|
+
if (!token || !to) throw new SageSDKError(CODES.INVALID_ARGS, "token and to required");
|
|
5837
|
+
const iface = new Interface(["function transfer(address,uint256)"]);
|
|
5838
|
+
return { to: getAddress(token), data: iface.encodeFunctionData("transfer", [getAddress(to), BigInt(amount.toString ? amount.toString() : amount)]), value: 0n };
|
|
5839
|
+
},
|
|
5840
|
+
buildWrapEthTx: ({ weth, amountWei }) => {
|
|
5841
|
+
if (!weth) throw new SageSDKError(CODES.INVALID_ARGS, "weth required");
|
|
5842
|
+
const iface = new Interface(["function deposit() payable"]);
|
|
5843
|
+
return { to: getAddress(weth), data: iface.encodeFunctionData("deposit", []), value: BigInt(amountWei.toString ? amountWei.toString() : amountWei) };
|
|
5844
|
+
}
|
|
5695
5845
|
};
|
|
5696
5846
|
}
|
|
5697
5847
|
});
|
|
5698
5848
|
|
|
5699
5849
|
// src/boost/index.js
|
|
5700
5850
|
var require_boost = __commonJS({
|
|
5701
|
-
"src/boost/index.js"(
|
|
5851
|
+
"src/boost/index.js"(exports2, module2) {
|
|
5702
5852
|
var { Contract, Interface, getAddress } = __require("ethers");
|
|
5703
5853
|
var ABI = require_abi();
|
|
5704
5854
|
var { SageSDKError, CODES } = require_errors();
|
|
@@ -5777,7 +5927,7 @@ var require_boost = __commonJS({
|
|
|
5777
5927
|
const data = DirectInterface.encodeFunctionData("fund", [Number(proposalId), BigInt(amount ?? 0n)]);
|
|
5778
5928
|
return { to: addr, data, value: 0n };
|
|
5779
5929
|
}
|
|
5780
|
-
|
|
5930
|
+
module2.exports = {
|
|
5781
5931
|
getMerkleConfig,
|
|
5782
5932
|
buildMerkleFundTx,
|
|
5783
5933
|
buildMerkleSetRootTx,
|
|
@@ -5790,7 +5940,7 @@ var require_boost = __commonJS({
|
|
|
5790
5940
|
|
|
5791
5941
|
// src/bounty/index.js
|
|
5792
5942
|
var require_bounty = __commonJS({
|
|
5793
|
-
"src/bounty/index.js"(
|
|
5943
|
+
"src/bounty/index.js"(exports2, module2) {
|
|
5794
5944
|
var { Contract, Interface, getAddress, isAddress } = __require("ethers");
|
|
5795
5945
|
var subdao = require_subdao();
|
|
5796
5946
|
var governance = require_governance();
|
|
@@ -5903,8 +6053,8 @@ var require_bounty = __commonJS({
|
|
|
5903
6053
|
["function approveBountyCompletion(uint256,string)"],
|
|
5904
6054
|
signer
|
|
5905
6055
|
);
|
|
5906
|
-
const
|
|
5907
|
-
const tx = await bountyContract.approveBountyCompletion(
|
|
6056
|
+
const id2 = BigInt(bountyId);
|
|
6057
|
+
const tx = await bountyContract.approveBountyCompletion(id2, String(deliverable));
|
|
5908
6058
|
return tx.wait();
|
|
5909
6059
|
}
|
|
5910
6060
|
async function proposeApproveWinner({
|
|
@@ -5922,18 +6072,18 @@ var require_bounty = __commonJS({
|
|
|
5922
6072
|
const context = await subdao.getSubDAOInfo({ provider, subdao: subdaoAddress });
|
|
5923
6073
|
const governor = normaliseAddress("governor", context.governor);
|
|
5924
6074
|
const iface = new Interface(["function approveBountyCompletion(uint256,string)"]);
|
|
5925
|
-
const
|
|
5926
|
-
const data = iface.encodeFunctionData("approveBountyCompletion", [
|
|
6075
|
+
const id2 = BigInt(bountyId);
|
|
6076
|
+
const data = iface.encodeFunctionData("approveBountyCompletion", [id2, String(deliverable)]);
|
|
5927
6077
|
const proposalCall = governance.buildProposeTx({
|
|
5928
6078
|
governor,
|
|
5929
6079
|
targets: [bountySystemAddress],
|
|
5930
6080
|
values: [0n],
|
|
5931
6081
|
calldatas: [data],
|
|
5932
|
-
description: `Approve bounty completion for id=${
|
|
6082
|
+
description: `Approve bounty completion for id=${id2}`
|
|
5933
6083
|
});
|
|
5934
6084
|
return { governor, proposalCall };
|
|
5935
6085
|
}
|
|
5936
|
-
|
|
6086
|
+
module2.exports = {
|
|
5937
6087
|
configureWinnerMode,
|
|
5938
6088
|
fundFromTreasury,
|
|
5939
6089
|
approveWinner,
|
|
@@ -5942,251 +6092,9 @@ var require_bounty = __commonJS({
|
|
|
5942
6092
|
}
|
|
5943
6093
|
});
|
|
5944
6094
|
|
|
5945
|
-
// src/bond/index.js
|
|
5946
|
-
var require_bond = __commonJS({
|
|
5947
|
-
"src/bond/index.js"(exports, module) {
|
|
5948
|
-
var {
|
|
5949
|
-
Contract,
|
|
5950
|
-
Interface,
|
|
5951
|
-
MaxUint256,
|
|
5952
|
-
WeiPerEther,
|
|
5953
|
-
formatUnits,
|
|
5954
|
-
getAddress,
|
|
5955
|
-
parseUnits
|
|
5956
|
-
} = __require("ethers");
|
|
5957
|
-
var ABI = require_abi();
|
|
5958
|
-
var { SageSDKError, CODES } = require_errors();
|
|
5959
|
-
function normalise(address, label) {
|
|
5960
|
-
if (!address) throw new SageSDKError(CODES.INVALID_ARGS, `${label} required`);
|
|
5961
|
-
try {
|
|
5962
|
-
return getAddress(address);
|
|
5963
|
-
} catch (err) {
|
|
5964
|
-
throw new SageSDKError(CODES.INVALID_ARGS, `invalid ${label}`, { cause: err });
|
|
5965
|
-
}
|
|
5966
|
-
}
|
|
5967
|
-
var ERC20 = [
|
|
5968
|
-
"function decimals() view returns (uint8)",
|
|
5969
|
-
"function allowance(address owner, address spender) view returns (uint256)",
|
|
5970
|
-
"function approve(address spender, uint256 value) returns (bool)",
|
|
5971
|
-
"function balanceOf(address) view returns (uint256)"
|
|
5972
|
-
];
|
|
5973
|
-
var BondInterface = new Interface(ABI.BondDepository);
|
|
5974
|
-
async function getInfo({ provider, bond }) {
|
|
5975
|
-
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
5976
|
-
const addr = normalise(bond, "bond");
|
|
5977
|
-
const c = new Contract(addr, ABI.BondDepository, provider);
|
|
5978
|
-
const [terms, price, priceUsd, totalDebt, payoutToken, principalToken, treasury] = await Promise.all([
|
|
5979
|
-
c.terms(),
|
|
5980
|
-
c.bondPrice(),
|
|
5981
|
-
c.bondPriceInUSD().catch(() => 0n),
|
|
5982
|
-
// totalDebt is keyed by payout token in this implementation
|
|
5983
|
-
c.payoutToken().then((pt) => c.totalDebt(pt)).catch(() => 0n),
|
|
5984
|
-
c.payoutToken(),
|
|
5985
|
-
c.principalToken(),
|
|
5986
|
-
c.treasury()
|
|
5987
|
-
]);
|
|
5988
|
-
return {
|
|
5989
|
-
bond: addr,
|
|
5990
|
-
payoutToken,
|
|
5991
|
-
principalToken,
|
|
5992
|
-
treasury,
|
|
5993
|
-
terms: {
|
|
5994
|
-
controlVariable: BigInt(terms.controlVariable?.toString?.() || terms[0]?.toString?.() || "0"),
|
|
5995
|
-
minimumPrice: BigInt(terms.minimumPrice?.toString?.() || terms[1]?.toString?.() || "0"),
|
|
5996
|
-
maxPayoutBps: BigInt(terms.maxPayout?.toString?.() || terms[2]?.toString?.() || "0"),
|
|
5997
|
-
maxDebt: BigInt(terms.maxDebt?.toString?.() || terms[3]?.toString?.() || "0"),
|
|
5998
|
-
vestingTerm: BigInt(terms.vestingTerm?.toString?.() || terms[4]?.toString?.() || "0"),
|
|
5999
|
-
feeBps: BigInt(terms.fee?.toString?.() || terms[5]?.toString?.() || "0")
|
|
6000
|
-
},
|
|
6001
|
-
price: BigInt(price.toString()),
|
|
6002
|
-
priceUSD: BigInt(priceUsd.toString()),
|
|
6003
|
-
totalDebt: BigInt(totalDebt.toString())
|
|
6004
|
-
};
|
|
6005
|
-
}
|
|
6006
|
-
async function getPrice({ provider, bond }) {
|
|
6007
|
-
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
6008
|
-
const c = new Contract(normalise(bond, "bond"), ABI.BondDepository, provider);
|
|
6009
|
-
return c.bondPrice();
|
|
6010
|
-
}
|
|
6011
|
-
async function getUserStatus({ provider, bond, user }) {
|
|
6012
|
-
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
6013
|
-
const addr = normalise(bond, "bond");
|
|
6014
|
-
const who = normalise(user, "user");
|
|
6015
|
-
const c = new Contract(addr, ABI.BondDepository, provider);
|
|
6016
|
-
const [info, pending, vested] = await Promise.all([
|
|
6017
|
-
c.bondInfo(who),
|
|
6018
|
-
c.pendingPayout(who),
|
|
6019
|
-
c.percentVestedFor(who).catch(() => 0n)
|
|
6020
|
-
]);
|
|
6021
|
-
return {
|
|
6022
|
-
address: who,
|
|
6023
|
-
bond: addr,
|
|
6024
|
-
payoutRemaining: BigInt(info?.payout?.toString?.() || info[0]?.toString?.() || "0"),
|
|
6025
|
-
vestingBlocks: BigInt(info?.vesting?.toString?.() || info[1]?.toString?.() || "0"),
|
|
6026
|
-
lastInteractionBlock: BigInt(info?.lastBlock?.toString?.() || info[2]?.toString?.() || "0"),
|
|
6027
|
-
pricePaid: BigInt(info?.pricePaid?.toString?.() || info[3]?.toString?.() || "0"),
|
|
6028
|
-
pendingPayout: BigInt(pending.toString()),
|
|
6029
|
-
percentVestedBps: BigInt(vested.toString())
|
|
6030
|
-
};
|
|
6031
|
-
}
|
|
6032
|
-
function buildDepositTx({ bond, amount, maxPrice }) {
|
|
6033
|
-
const to = normalise(bond, "bond");
|
|
6034
|
-
const iface = new Interface(ABI.BondDepository);
|
|
6035
|
-
const data = iface.encodeFunctionData("deposit", [
|
|
6036
|
-
BigInt(amount ?? 0n),
|
|
6037
|
-
// principal amount in token units
|
|
6038
|
-
BigInt(maxPrice ?? 0n)
|
|
6039
|
-
// scaled by 1e18
|
|
6040
|
-
]);
|
|
6041
|
-
return { to, data, value: 0n };
|
|
6042
|
-
}
|
|
6043
|
-
function buildRedeemTx({ bond, recipient, stake = false }) {
|
|
6044
|
-
const to = normalise(bond, "bond");
|
|
6045
|
-
const iface = new Interface(ABI.BondDepository);
|
|
6046
|
-
const data = iface.encodeFunctionData("redeem", [normalise(recipient, "recipient"), !!stake]);
|
|
6047
|
-
return { to, data, value: 0n };
|
|
6048
|
-
}
|
|
6049
|
-
async function getTokenDecimals({ provider, token }) {
|
|
6050
|
-
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
6051
|
-
const c = new Contract(normalise(token, "token"), ERC20, provider);
|
|
6052
|
-
const d = await c.decimals().catch(() => 18);
|
|
6053
|
-
return Number(d);
|
|
6054
|
-
}
|
|
6055
|
-
async function getPrincipalAndPayout({ provider, bond }) {
|
|
6056
|
-
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
6057
|
-
const c = new Contract(normalise(bond, "bond"), ABI.BondDepository, provider);
|
|
6058
|
-
const [payoutToken, principalToken] = await Promise.all([
|
|
6059
|
-
c.payoutToken(),
|
|
6060
|
-
c.principalToken()
|
|
6061
|
-
]);
|
|
6062
|
-
return { payoutToken, principalToken };
|
|
6063
|
-
}
|
|
6064
|
-
async function estimatePayout({ provider, bond, amount, principalDecimals, payoutDecimals }) {
|
|
6065
|
-
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
6066
|
-
if (amount == null) throw new SageSDKError(CODES.INVALID_ARGS, "amount required");
|
|
6067
|
-
const { principalToken, payoutToken } = await getPrincipalAndPayout({ provider, bond });
|
|
6068
|
-
const principalDec = principalDecimals ?? await getTokenDecimals({ provider, token: principalToken });
|
|
6069
|
-
const payoutDec = payoutDecimals ?? await getTokenDecimals({ provider, token: payoutToken });
|
|
6070
|
-
const amountUnits = parseUnits(String(amount), principalDec);
|
|
6071
|
-
const price = await getPrice({ provider, bond });
|
|
6072
|
-
if (price === 0n) {
|
|
6073
|
-
throw new SageSDKError(CODES.RPC_ERROR, "bond price returned zero");
|
|
6074
|
-
}
|
|
6075
|
-
const payoutUnits = amountUnits * WeiPerEther / price;
|
|
6076
|
-
return {
|
|
6077
|
-
inputAmount: String(amount),
|
|
6078
|
-
expectedPayout: formatUnits(payoutUnits, payoutDec),
|
|
6079
|
-
bondPrice: formatUnits(price, 18),
|
|
6080
|
-
principalToken,
|
|
6081
|
-
payoutToken,
|
|
6082
|
-
principalDecimals: principalDec,
|
|
6083
|
-
payoutDecimals: payoutDec
|
|
6084
|
-
};
|
|
6085
|
-
}
|
|
6086
|
-
async function ensurePrincipalAllowance({ signer, bond, amount, principalToken }) {
|
|
6087
|
-
if (!signer) throw new SageSDKError(CODES.INVALID_ARGS, "signer required");
|
|
6088
|
-
const owner = await signer.getAddress();
|
|
6089
|
-
const provider = signer.provider;
|
|
6090
|
-
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "signer requires provider");
|
|
6091
|
-
const bondAddress = normalise(bond, "bond");
|
|
6092
|
-
const tokenAddress = principalToken ? normalise(principalToken, "principalToken") : (await getPrincipalAndPayout({ provider, bond: bondAddress })).principalToken;
|
|
6093
|
-
const principal = new Contract(tokenAddress, ERC20, signer);
|
|
6094
|
-
const allowance = await principal.allowance(owner, bondAddress);
|
|
6095
|
-
if (allowance >= amount) {
|
|
6096
|
-
return { approved: false, transactionHash: null };
|
|
6097
|
-
}
|
|
6098
|
-
const approvalTx = await principal.approve(bondAddress, MaxUint256);
|
|
6099
|
-
const receipt = await approvalTx.wait();
|
|
6100
|
-
return {
|
|
6101
|
-
approved: true,
|
|
6102
|
-
transactionHash: receipt.hash ?? approvalTx.hash ?? null
|
|
6103
|
-
};
|
|
6104
|
-
}
|
|
6105
|
-
async function purchase({ signer, bond, amount, maxPrice }) {
|
|
6106
|
-
if (!signer) throw new SageSDKError(CODES.INVALID_ARGS, "signer required");
|
|
6107
|
-
if (amount == null) throw new SageSDKError(CODES.INVALID_ARGS, "amount required");
|
|
6108
|
-
if (maxPrice == null) throw new SageSDKError(CODES.INVALID_ARGS, "maxPrice required");
|
|
6109
|
-
const provider = signer.provider;
|
|
6110
|
-
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "signer requires provider");
|
|
6111
|
-
const bondAddress = normalise(bond, "bond");
|
|
6112
|
-
const bondContract = new Contract(bondAddress, ABI.BondDepository, signer);
|
|
6113
|
-
const { principalToken, payoutToken } = await getPrincipalAndPayout({ provider, bond: bondAddress });
|
|
6114
|
-
const principalDec = await getTokenDecimals({ provider, token: principalToken });
|
|
6115
|
-
const payoutDec = await getTokenDecimals({ provider, token: payoutToken });
|
|
6116
|
-
const amountUnits = parseUnits(String(amount), principalDec);
|
|
6117
|
-
const maxPriceUnits = parseUnits(String(maxPrice), 18);
|
|
6118
|
-
const currentPrice = await getPrice({ provider, bond: bondAddress });
|
|
6119
|
-
if (currentPrice > maxPriceUnits) {
|
|
6120
|
-
throw new SageSDKError(CODES.INVALID_ARGS, "current bond price exceeds max price", {
|
|
6121
|
-
currentPrice: formatUnits(currentPrice, 18),
|
|
6122
|
-
maxPrice: String(maxPrice)
|
|
6123
|
-
});
|
|
6124
|
-
}
|
|
6125
|
-
await ensurePrincipalAllowance({ signer, bond: bondAddress, amount: amountUnits, principalToken });
|
|
6126
|
-
const tx = await bondContract.deposit(amountUnits, maxPriceUnits);
|
|
6127
|
-
const receipt = await tx.wait();
|
|
6128
|
-
let depositEvent = null;
|
|
6129
|
-
for (const log of receipt.logs || []) {
|
|
6130
|
-
try {
|
|
6131
|
-
const parsed = BondInterface.parseLog(log);
|
|
6132
|
-
if (parsed?.name === "BondCreated") {
|
|
6133
|
-
depositEvent = parsed.args;
|
|
6134
|
-
break;
|
|
6135
|
-
}
|
|
6136
|
-
} catch (_) {
|
|
6137
|
-
}
|
|
6138
|
-
}
|
|
6139
|
-
return {
|
|
6140
|
-
transactionHash: receipt.hash ?? tx.hash ?? null,
|
|
6141
|
-
deposit: formatUnits(depositEvent?.deposit ?? amountUnits, principalDec),
|
|
6142
|
-
payout: depositEvent?.payout != null ? formatUnits(depositEvent.payout, payoutDec) : null,
|
|
6143
|
-
expires: depositEvent?.expires ?? null,
|
|
6144
|
-
price: formatUnits(currentPrice, 18)
|
|
6145
|
-
};
|
|
6146
|
-
}
|
|
6147
|
-
async function redeem({ signer, bond, recipient, stake = false }) {
|
|
6148
|
-
if (!signer) throw new SageSDKError(CODES.INVALID_ARGS, "signer required");
|
|
6149
|
-
const provider = signer.provider;
|
|
6150
|
-
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "signer requires provider");
|
|
6151
|
-
const bondAddress = normalise(bond, "bond");
|
|
6152
|
-
const user = normalise(recipient || await signer.getAddress(), "recipient");
|
|
6153
|
-
const bondContract = new Contract(bondAddress, ABI.BondDepository, signer);
|
|
6154
|
-
const { payoutToken } = await getPrincipalAndPayout({ provider, bond: bondAddress });
|
|
6155
|
-
const payoutDec = await getTokenDecimals({ provider, token: payoutToken });
|
|
6156
|
-
const pending = await bondContract.pendingPayout(user);
|
|
6157
|
-
if (pending === 0n) {
|
|
6158
|
-
return {
|
|
6159
|
-
transactionHash: null,
|
|
6160
|
-
redeemed: "0",
|
|
6161
|
-
message: "No bonds available for redemption"
|
|
6162
|
-
};
|
|
6163
|
-
}
|
|
6164
|
-
const tx = await bondContract.redeem(user, !!stake);
|
|
6165
|
-
const receipt = await tx.wait();
|
|
6166
|
-
return {
|
|
6167
|
-
transactionHash: receipt.hash ?? tx.hash ?? null,
|
|
6168
|
-
redeemed: formatUnits(pending, payoutDec)
|
|
6169
|
-
};
|
|
6170
|
-
}
|
|
6171
|
-
module.exports = {
|
|
6172
|
-
getInfo,
|
|
6173
|
-
getPrice,
|
|
6174
|
-
getUserStatus,
|
|
6175
|
-
buildDepositTx,
|
|
6176
|
-
buildRedeemTx,
|
|
6177
|
-
getTokenDecimals,
|
|
6178
|
-
getPrincipalAndPayout,
|
|
6179
|
-
estimatePayout,
|
|
6180
|
-
ensurePrincipalAllowance,
|
|
6181
|
-
purchase,
|
|
6182
|
-
redeem
|
|
6183
|
-
};
|
|
6184
|
-
}
|
|
6185
|
-
});
|
|
6186
|
-
|
|
6187
6095
|
// src/utils/provider.js
|
|
6188
6096
|
var require_provider = __commonJS({
|
|
6189
|
-
"src/utils/provider.js"(
|
|
6097
|
+
"src/utils/provider.js"(exports2, module2) {
|
|
6190
6098
|
var { JsonRpcProvider } = __require("ethers");
|
|
6191
6099
|
function assertString(value, name) {
|
|
6192
6100
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
@@ -6197,7 +6105,7 @@ var require_provider = __commonJS({
|
|
|
6197
6105
|
assertString(rpcUrl, "rpcUrl");
|
|
6198
6106
|
return new JsonRpcProvider(rpcUrl);
|
|
6199
6107
|
}
|
|
6200
|
-
|
|
6108
|
+
module2.exports = {
|
|
6201
6109
|
getProvider,
|
|
6202
6110
|
assertString
|
|
6203
6111
|
};
|
|
@@ -6206,8 +6114,8 @@ var require_provider = __commonJS({
|
|
|
6206
6114
|
|
|
6207
6115
|
// src/wallet/index.js
|
|
6208
6116
|
var require_wallet = __commonJS({
|
|
6209
|
-
"src/wallet/index.js"(
|
|
6210
|
-
var { ethers } = __require("ethers");
|
|
6117
|
+
"src/wallet/index.js"(exports2, module2) {
|
|
6118
|
+
var { ethers: ethers2 } = __require("ethers");
|
|
6211
6119
|
var { SageSDKError, CODES } = require_errors();
|
|
6212
6120
|
var { getProvider } = require_provider();
|
|
6213
6121
|
function isBrowser() {
|
|
@@ -6234,7 +6142,7 @@ var require_wallet = __commonJS({
|
|
|
6234
6142
|
const rpcUrl = src.rpcUrl || getDefaultRpc();
|
|
6235
6143
|
const provider = getProvider({ rpcUrl });
|
|
6236
6144
|
const pk = src.privateKey.startsWith("0x") ? src.privateKey : "0x" + src.privateKey;
|
|
6237
|
-
const signer = new
|
|
6145
|
+
const signer = new ethers2.Wallet(pk, provider);
|
|
6238
6146
|
return { signer, provider };
|
|
6239
6147
|
}
|
|
6240
6148
|
case "pkEnv": {
|
|
@@ -6243,7 +6151,7 @@ var require_wallet = __commonJS({
|
|
|
6243
6151
|
if (!pk) throw new SageSDKError(CODES.INVALID_ARGS, `${envName} not set`);
|
|
6244
6152
|
const rpcUrl = src.rpcUrl || getDefaultRpc();
|
|
6245
6153
|
const provider = getProvider({ rpcUrl });
|
|
6246
|
-
const signer = new
|
|
6154
|
+
const signer = new ethers2.Wallet(pk.startsWith("0x") ? pk : "0x" + pk, provider);
|
|
6247
6155
|
return { signer, provider };
|
|
6248
6156
|
}
|
|
6249
6157
|
case "rpc": {
|
|
@@ -6254,7 +6162,7 @@ var require_wallet = __commonJS({
|
|
|
6254
6162
|
case "injected": {
|
|
6255
6163
|
if (!isBrowser()) throw new SageSDKError(CODES.MISSING_DEPENDENCY, "Injected provider only available in browser");
|
|
6256
6164
|
try {
|
|
6257
|
-
const provider = new
|
|
6165
|
+
const provider = new ethers2.BrowserProvider(window.ethereum);
|
|
6258
6166
|
const signer = await provider.getSigner();
|
|
6259
6167
|
return { signer, provider };
|
|
6260
6168
|
} catch (e) {
|
|
@@ -6282,7 +6190,7 @@ var require_wallet = __commonJS({
|
|
|
6282
6190
|
return process.env.RPC_URL || process.env.BASE_SEPOLIA_RPC_URL || process.env.BASE_SEPOLIA_RPC || "https://base-sepolia.publicnode.com";
|
|
6283
6191
|
}
|
|
6284
6192
|
function create() {
|
|
6285
|
-
const wallet =
|
|
6193
|
+
const wallet = ethers2.Wallet.createRandom();
|
|
6286
6194
|
return {
|
|
6287
6195
|
address: wallet.address,
|
|
6288
6196
|
// Intentionally do not expose privateKey by default to avoid accidental leaks
|
|
@@ -6295,7 +6203,7 @@ var require_wallet = __commonJS({
|
|
|
6295
6203
|
throw new SageSDKError(CODES.INVALID_ARGS, "secret required to import wallet");
|
|
6296
6204
|
}
|
|
6297
6205
|
const pk = secret.startsWith("0x") ? secret : "0x" + secret;
|
|
6298
|
-
const wallet = new
|
|
6206
|
+
const wallet = new ethers2.Wallet(pk);
|
|
6299
6207
|
return { address: wallet.address, _wallet: wallet };
|
|
6300
6208
|
}
|
|
6301
6209
|
function exportWallet(w) {
|
|
@@ -6314,7 +6222,7 @@ var require_wallet = __commonJS({
|
|
|
6314
6222
|
async function connectInjected() {
|
|
6315
6223
|
return loadSigner("injected");
|
|
6316
6224
|
}
|
|
6317
|
-
|
|
6225
|
+
module2.exports = {
|
|
6318
6226
|
listProviders,
|
|
6319
6227
|
loadSigner,
|
|
6320
6228
|
connectInjected,
|
|
@@ -6330,7 +6238,7 @@ var require_wallet = __commonJS({
|
|
|
6330
6238
|
} catch (_) {
|
|
6331
6239
|
if (!opts || !opts.mnemonic || !opts.rpcUrl) throw new SageSDKError(CODES.INVALID_ARGS, "mnemonic and rpcUrl required");
|
|
6332
6240
|
const provider = getProvider({ rpcUrl: opts.rpcUrl });
|
|
6333
|
-
const wallet =
|
|
6241
|
+
const wallet = ethers2.HDNodeWallet.fromPhrase(opts.mnemonic, opts.path);
|
|
6334
6242
|
const signer = wallet.connect(provider);
|
|
6335
6243
|
return { signer, provider };
|
|
6336
6244
|
}
|
|
@@ -6342,7 +6250,7 @@ var require_wallet = __commonJS({
|
|
|
6342
6250
|
} catch (_) {
|
|
6343
6251
|
if (!opts || !opts.json || !opts.password || !opts.rpcUrl) throw new SageSDKError(CODES.INVALID_ARGS, "json, password, rpcUrl required");
|
|
6344
6252
|
const provider = getProvider({ rpcUrl: opts.rpcUrl });
|
|
6345
|
-
const signer = await
|
|
6253
|
+
const signer = await ethers2.Wallet.fromEncryptedJson(opts.json, opts.password);
|
|
6346
6254
|
return { signer: signer.connect(provider), provider };
|
|
6347
6255
|
}
|
|
6348
6256
|
},
|
|
@@ -6388,7 +6296,7 @@ var require_wallet = __commonJS({
|
|
|
6388
6296
|
|
|
6389
6297
|
// src/wallet/session.js
|
|
6390
6298
|
var require_session = __commonJS({
|
|
6391
|
-
"src/wallet/session.js"(
|
|
6299
|
+
"src/wallet/session.js"(exports2, module2) {
|
|
6392
6300
|
var DEFAULT_WALLET_TYPE = "cast";
|
|
6393
6301
|
function resolveWalletType({ config, env = process.env } = {}) {
|
|
6394
6302
|
const envType = String(env.WALLET_TYPE || "").trim();
|
|
@@ -6416,7 +6324,7 @@ var require_session = __commonJS({
|
|
|
6416
6324
|
return false;
|
|
6417
6325
|
}
|
|
6418
6326
|
}
|
|
6419
|
-
|
|
6327
|
+
module2.exports = {
|
|
6420
6328
|
DEFAULT_WALLET_TYPE,
|
|
6421
6329
|
resolveWalletType,
|
|
6422
6330
|
shouldAllowInsecurePrivateKey,
|
|
@@ -6444,6 +6352,32 @@ var require_cast_manager = __commonJS({
|
|
|
6444
6352
|
blue: (text) => `\x1B[34m${text}\x1B[0m`,
|
|
6445
6353
|
cyan: (text) => `\x1B[36m${text}\x1B[0m`
|
|
6446
6354
|
};
|
|
6355
|
+
function optionalRequire(id) {
|
|
6356
|
+
try {
|
|
6357
|
+
const req = typeof __non_webpack_require__ === "function" ? __non_webpack_require__ : eval("require");
|
|
6358
|
+
return req(id);
|
|
6359
|
+
} catch (_) {
|
|
6360
|
+
return null;
|
|
6361
|
+
}
|
|
6362
|
+
}
|
|
6363
|
+
function loadConfigBridge() {
|
|
6364
|
+
const shared = optionalRequire("@sage-protocol/shared");
|
|
6365
|
+
if (shared) {
|
|
6366
|
+
if (shared.ConfigManager) return shared.ConfigManager;
|
|
6367
|
+
if (typeof shared.getProjectDir === "function" || typeof shared.readProfiles === "function") {
|
|
6368
|
+
return shared;
|
|
6369
|
+
}
|
|
6370
|
+
}
|
|
6371
|
+
const local = optionalRequire("./config");
|
|
6372
|
+
if (local) {
|
|
6373
|
+
if (local.ConfigManager) return local.ConfigManager;
|
|
6374
|
+
return local;
|
|
6375
|
+
}
|
|
6376
|
+
return {
|
|
6377
|
+
getProjectDir: () => process.cwd(),
|
|
6378
|
+
readProfiles: () => ({ profiles: {}, activeProfile: "default" })
|
|
6379
|
+
};
|
|
6380
|
+
}
|
|
6447
6381
|
var CastSigner = class extends ethers.VoidSigner {
|
|
6448
6382
|
constructor(address, provider, castWalletManager) {
|
|
6449
6383
|
super(address, provider);
|
|
@@ -6578,13 +6512,8 @@ var require_cast_manager = __commonJS({
|
|
|
6578
6512
|
if (!address) return;
|
|
6579
6513
|
try {
|
|
6580
6514
|
const normalized = ethers.getAddress(address);
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
({ ConfigManager: cfgModule } = __require("@sage-protocol/shared"));
|
|
6584
|
-
} catch (_) {
|
|
6585
|
-
cfgModule = __require("./config");
|
|
6586
|
-
}
|
|
6587
|
-
const projectDir = cfgModule.getProjectDir ? cfgModule.getProjectDir() : process.cwd();
|
|
6515
|
+
const cfgModule = loadConfigBridge();
|
|
6516
|
+
const projectDir = typeof cfgModule.getProjectDir === "function" ? cfgModule.getProjectDir() : process.cwd();
|
|
6588
6517
|
const cfgPath = path.join(projectDir, ".sage", "config.json");
|
|
6589
6518
|
const current = fs.existsSync(cfgPath) ? JSON.parse(fs.readFileSync(cfgPath, "utf8") || "{}") : {};
|
|
6590
6519
|
const active = current.activeProfile || "default";
|
|
@@ -6670,14 +6599,9 @@ var require_cast_manager = __commonJS({
|
|
|
6670
6599
|
console.log(colors.blue("\u{1F517} Connecting wallet using Cast keystore..."));
|
|
6671
6600
|
this.ensureKeystoreDir();
|
|
6672
6601
|
try {
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
} catch (_) {
|
|
6677
|
-
cliConfig = __require("./config");
|
|
6678
|
-
}
|
|
6679
|
-
const profiles = cliConfig.readProfiles();
|
|
6680
|
-
const active = profiles.activeProfile || "default";
|
|
6602
|
+
const cliConfig = loadConfigBridge();
|
|
6603
|
+
const profiles = typeof cliConfig.readProfiles === "function" ? cliConfig.readProfiles() : { profiles: {}, activeProfile: "default" };
|
|
6604
|
+
const active = profiles?.activeProfile || "default";
|
|
6681
6605
|
const wanted = profiles?.profiles?.[active]?.wallet?.defaultAccount;
|
|
6682
6606
|
if (wanted && this.keystoreDir && fs.existsSync(this.keystoreDir)) {
|
|
6683
6607
|
const files = fs.readdirSync(this.keystoreDir);
|
|
@@ -6713,7 +6637,7 @@ var require_cast_manager = __commonJS({
|
|
|
6713
6637
|
this.ensureAccountSynced(walletData.address, walletData.keystorePath, { silent: true });
|
|
6714
6638
|
}
|
|
6715
6639
|
try {
|
|
6716
|
-
const { checkRpcHealth } =
|
|
6640
|
+
const { checkRpcHealth } = optionalRequire("./utils/rpc-health") || {};
|
|
6717
6641
|
const candidates = [
|
|
6718
6642
|
this.rpcUrl,
|
|
6719
6643
|
process.env.BASE_SEPOLIA_RPC,
|
|
@@ -7675,10 +7599,10 @@ ${error}` : ""}`;
|
|
|
7675
7599
|
|
|
7676
7600
|
// src/wallet/cdp-manager.js
|
|
7677
7601
|
var require_cdp_manager = __commonJS({
|
|
7678
|
-
"src/wallet/cdp-manager.js"(
|
|
7679
|
-
var
|
|
7680
|
-
var
|
|
7681
|
-
var { ethers } = __require("ethers");
|
|
7602
|
+
"src/wallet/cdp-manager.js"(exports2, module2) {
|
|
7603
|
+
var fs2 = __require("fs");
|
|
7604
|
+
var path2 = __require("path");
|
|
7605
|
+
var { ethers: ethers2 } = __require("ethers");
|
|
7682
7606
|
var MinimalCdpSigner = class {
|
|
7683
7607
|
constructor(manager, provider) {
|
|
7684
7608
|
this._mgr = manager;
|
|
@@ -7707,7 +7631,7 @@ var require_cdp_manager = __commonJS({
|
|
|
7707
7631
|
this.provider = null;
|
|
7708
7632
|
this.signer = null;
|
|
7709
7633
|
this.connected = false;
|
|
7710
|
-
this._profilePath =
|
|
7634
|
+
this._profilePath = path2.join(process.cwd(), ".cdp-wallet.json");
|
|
7711
7635
|
this._client = null;
|
|
7712
7636
|
this._userId = null;
|
|
7713
7637
|
this._walletId = null;
|
|
@@ -7730,9 +7654,9 @@ var require_cdp_manager = __commonJS({
|
|
|
7730
7654
|
}
|
|
7731
7655
|
}
|
|
7732
7656
|
_loadProfile() {
|
|
7733
|
-
if (
|
|
7657
|
+
if (fs2.existsSync(this._profilePath)) {
|
|
7734
7658
|
try {
|
|
7735
|
-
const x = JSON.parse(
|
|
7659
|
+
const x = JSON.parse(fs2.readFileSync(this._profilePath, "utf8"));
|
|
7736
7660
|
this._userId = x.userId || null;
|
|
7737
7661
|
this._walletId = x.walletId || null;
|
|
7738
7662
|
this.account = x.address || null;
|
|
@@ -7742,14 +7666,14 @@ var require_cdp_manager = __commonJS({
|
|
|
7742
7666
|
}
|
|
7743
7667
|
_saveProfile() {
|
|
7744
7668
|
const payload = { userId: this._userId, walletId: this._walletId, address: this.account };
|
|
7745
|
-
|
|
7669
|
+
fs2.writeFileSync(this._profilePath, JSON.stringify(payload, null, 2));
|
|
7746
7670
|
}
|
|
7747
7671
|
async connect() {
|
|
7748
7672
|
if (!process.env.CDP_API_KEY_ID || !process.env.CDP_API_KEY_SECRET) {
|
|
7749
7673
|
throw new Error("Missing CDP_API_KEY_ID/CDP_API_KEY_SECRET in env");
|
|
7750
7674
|
}
|
|
7751
7675
|
const rpc = process.env.RPC_URL || "https://base-sepolia.publicnode.com";
|
|
7752
|
-
this.provider = new
|
|
7676
|
+
this.provider = new ethers2.JsonRpcProvider(rpc);
|
|
7753
7677
|
this._loadProfile();
|
|
7754
7678
|
let client;
|
|
7755
7679
|
try {
|
|
@@ -7761,7 +7685,7 @@ var require_cdp_manager = __commonJS({
|
|
|
7761
7685
|
const email = process.env.CDP_USER_EMAIL || await this._promptEmail();
|
|
7762
7686
|
const fakeUserId = `user_${Buffer.from(email).toString("hex").slice(0, 8)}`;
|
|
7763
7687
|
const fakeWalletId = `w_${Date.now()}`;
|
|
7764
|
-
const fakeAddress = this.account ||
|
|
7688
|
+
const fakeAddress = this.account || ethers2.Wallet.createRandom().address;
|
|
7765
7689
|
this._userId = fakeUserId;
|
|
7766
7690
|
this._walletId = fakeWalletId;
|
|
7767
7691
|
this.account = fakeAddress;
|
|
@@ -7775,7 +7699,7 @@ var require_cdp_manager = __commonJS({
|
|
|
7775
7699
|
console.log("\u{1F4CD} Address:", this.account);
|
|
7776
7700
|
try {
|
|
7777
7701
|
const bal = await this.getBalance();
|
|
7778
|
-
console.log("\u{1F4B0} Balance:",
|
|
7702
|
+
console.log("\u{1F4B0} Balance:", ethers2.formatEther(bal), "ETH");
|
|
7779
7703
|
} catch (_) {
|
|
7780
7704
|
}
|
|
7781
7705
|
}
|
|
@@ -7800,7 +7724,7 @@ var require_cdp_manager = __commonJS({
|
|
|
7800
7724
|
if (!process.env.SAGE_QUIET_JSON) {
|
|
7801
7725
|
console.log("\u{1F4DD} Transaction Details:");
|
|
7802
7726
|
console.log("To:", to);
|
|
7803
|
-
console.log("Value:",
|
|
7727
|
+
console.log("Value:", ethers2.formatEther(value));
|
|
7804
7728
|
console.log("Data:", data);
|
|
7805
7729
|
console.log("\u{1F4E8} Check your email/app to approve the transaction...");
|
|
7806
7730
|
}
|
|
@@ -7845,14 +7769,14 @@ var require_cdp_manager = __commonJS({
|
|
|
7845
7769
|
if (!process.env.SAGE_QUIET_JSON) console.log("\u2705 CDP wallet disconnected");
|
|
7846
7770
|
}
|
|
7847
7771
|
};
|
|
7848
|
-
|
|
7772
|
+
module2.exports = CDPWalletManager;
|
|
7849
7773
|
}
|
|
7850
7774
|
});
|
|
7851
7775
|
|
|
7852
7776
|
// src/wallet/typed.js
|
|
7853
7777
|
var require_typed = __commonJS({
|
|
7854
|
-
"src/wallet/typed.js"(
|
|
7855
|
-
var { ethers } = __require("ethers");
|
|
7778
|
+
"src/wallet/typed.js"(exports2, module2) {
|
|
7779
|
+
var { ethers: ethers2 } = __require("ethers");
|
|
7856
7780
|
function buildGovernorDomain({ name, chainId, verifyingContract }) {
|
|
7857
7781
|
if (!name || !chainId || !verifyingContract) throw new Error("name, chainId, verifyingContract required");
|
|
7858
7782
|
return { name, version: "1", chainId: Number(chainId), verifyingContract };
|
|
@@ -7888,7 +7812,7 @@ var require_typed = __commonJS({
|
|
|
7888
7812
|
const typed = { owner, spender, value, nonce, deadline };
|
|
7889
7813
|
return await signer.signTypedData(domain, PermitTypes, typed);
|
|
7890
7814
|
}
|
|
7891
|
-
|
|
7815
|
+
module2.exports = {
|
|
7892
7816
|
buildGovernorDomain,
|
|
7893
7817
|
BallotTypes,
|
|
7894
7818
|
signVoteBySig,
|
|
@@ -7901,7 +7825,7 @@ var require_typed = __commonJS({
|
|
|
7901
7825
|
|
|
7902
7826
|
// src/doppler/index.js
|
|
7903
7827
|
var require_doppler = __commonJS({
|
|
7904
|
-
"src/doppler/index.js"(
|
|
7828
|
+
"src/doppler/index.js"(exports2, module2) {
|
|
7905
7829
|
var { createPublicClient, createWalletClient, http } = __require("viem");
|
|
7906
7830
|
var { privateKeyToAccount } = __require("viem/accounts");
|
|
7907
7831
|
var { erc20Abi } = __require("viem");
|
|
@@ -7969,12 +7893,40 @@ var require_doppler = __commonJS({
|
|
|
7969
7893
|
}
|
|
7970
7894
|
return { auctionAddress, note: "Lens API not available in this doppler-sdk version" };
|
|
7971
7895
|
}
|
|
7896
|
+
async function listAuctions(sdk, { limit = 10, cursor } = {}) {
|
|
7897
|
+
const lens = sdk.lens;
|
|
7898
|
+
if (lens) {
|
|
7899
|
+
if (typeof lens.listAuctions === "function") {
|
|
7900
|
+
try {
|
|
7901
|
+
return await lens.listAuctions({ limit, cursor });
|
|
7902
|
+
} catch (e) {
|
|
7903
|
+
}
|
|
7904
|
+
}
|
|
7905
|
+
if (typeof lens.getAuctions === "function") {
|
|
7906
|
+
try {
|
|
7907
|
+
return await lens.getAuctions({ limit, cursor });
|
|
7908
|
+
} catch (e) {
|
|
7909
|
+
}
|
|
7910
|
+
}
|
|
7911
|
+
}
|
|
7912
|
+
const fac = sdk.factory;
|
|
7913
|
+
if (fac && typeof fac.listAuctions === "function") {
|
|
7914
|
+
try {
|
|
7915
|
+
return await fac.listAuctions({ limit, cursor });
|
|
7916
|
+
} catch (e) {
|
|
7917
|
+
}
|
|
7918
|
+
}
|
|
7919
|
+
return { ok: false, error: "LIST_UNSUPPORTED", message: "Listing auctions not supported by this doppler-sdk version" };
|
|
7920
|
+
}
|
|
7972
7921
|
async function buyTokens(sdk, { auctionAddress, numeraireAmount }) {
|
|
7973
7922
|
const trade = sdk.trade || sdk.swap || sdk.auction;
|
|
7974
7923
|
if (trade && typeof trade.buy === "function") {
|
|
7975
|
-
|
|
7924
|
+
try {
|
|
7925
|
+
return await trade.buy({ auctionAddress, numeraireAmount });
|
|
7926
|
+
} catch (e) {
|
|
7927
|
+
}
|
|
7976
7928
|
}
|
|
7977
|
-
|
|
7929
|
+
return { ok: false, error: "BUY_UNSUPPORTED", message: "Buy not supported by this doppler-sdk version. Use executeV3BuyExactIn/urExecute helpers or upgrade doppler-sdk." };
|
|
7978
7930
|
}
|
|
7979
7931
|
async function migrate(sdk, asset) {
|
|
7980
7932
|
if (sdk.airlock && typeof sdk.airlock.migrate === "function") {
|
|
@@ -7982,14 +7934,15 @@ var require_doppler = __commonJS({
|
|
|
7982
7934
|
}
|
|
7983
7935
|
throw new Error("Migrate is not supported by the current doppler-sdk version");
|
|
7984
7936
|
}
|
|
7985
|
-
|
|
7937
|
+
module2.exports = {
|
|
7986
7938
|
initDoppler,
|
|
7987
7939
|
deployDynamicAuction,
|
|
7988
7940
|
getAuctionStatus,
|
|
7941
|
+
listAuctions,
|
|
7989
7942
|
buyTokens,
|
|
7990
7943
|
migrate
|
|
7991
7944
|
};
|
|
7992
|
-
|
|
7945
|
+
module2.exports.deployStaticAuction = async function deployStaticAuction(sdk, user, p) {
|
|
7993
7946
|
const StaticAuctionBuilder = dopplerLib.StaticAuctionBuilder || dopplerLib.default?.StaticAuctionBuilder;
|
|
7994
7947
|
if (!StaticAuctionBuilder) throw new Error("StaticAuctionBuilder missing from doppler-sdk");
|
|
7995
7948
|
const builder = new StaticAuctionBuilder().tokenConfig({ name: p.token.name, symbol: p.token.symbol, tokenURI: p.token.tokenURI }).saleConfig({ initialSupply: p.sale.initialSupply, numTokensToSell: p.sale.numTokensToSell, numeraire: p.sale.numeraire }).poolByTicks({ startTick: p.pool.startTick, endTick: p.pool.endTick, fee: p.pool.fee, numPositions: p.pool.numPositions || 15 }).withUserAddress(user);
|
|
@@ -8001,11 +7954,11 @@ var require_doppler = __commonJS({
|
|
|
8001
7954
|
const res = await sdk.factory.createStaticAuction(params);
|
|
8002
7955
|
return res;
|
|
8003
7956
|
};
|
|
8004
|
-
|
|
7957
|
+
module2.exports.getStaticPoolInfo = async function getStaticPoolInfo(sdk, poolAddress) {
|
|
8005
7958
|
const auction = await sdk.getStaticAuction(poolAddress);
|
|
8006
7959
|
return auction.getPoolInfo();
|
|
8007
7960
|
};
|
|
8008
|
-
|
|
7961
|
+
module2.exports.quoteV3ExactIn = async function quoteV3ExactIn(sdk, { tokenIn, tokenOut, amountIn, fee, sqrtPriceLimitX96 = 0n }) {
|
|
8009
7962
|
return sdk.quoter.quoteExactInputV3({ tokenIn, tokenOut, amountIn, fee, sqrtPriceLimitX96 });
|
|
8010
7963
|
};
|
|
8011
7964
|
var WETH_ABI = [
|
|
@@ -8013,7 +7966,7 @@ var require_doppler = __commonJS({
|
|
|
8013
7966
|
{ type: "function", name: "withdraw", stateMutability: "nonpayable", inputs: [{ name: "wad", type: "uint256" }], outputs: [] },
|
|
8014
7967
|
{ type: "function", name: "balanceOf", stateMutability: "view", inputs: [{ name: "a", type: "address" }], outputs: [{ type: "uint256" }] }
|
|
8015
7968
|
];
|
|
8016
|
-
|
|
7969
|
+
module2.exports.wrapEthToWethIfNeeded = async function wrapEthToWethIfNeeded({ rpcUrl, chainId, privateKey, weth, owner, minAmount }) {
|
|
8017
7970
|
const chain = getChainById(chainId);
|
|
8018
7971
|
const accountObj = privateKeyToAccount(privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`);
|
|
8019
7972
|
const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
|
|
@@ -8025,17 +7978,17 @@ var require_doppler = __commonJS({
|
|
|
8025
7978
|
await publicClient.waitForTransactionReceipt({ hash });
|
|
8026
7979
|
return { deposited: needed, hash };
|
|
8027
7980
|
};
|
|
8028
|
-
|
|
7981
|
+
module2.exports.getDynamicHookInfo = async function getDynamicHookInfo(sdk, hookAddress) {
|
|
8029
7982
|
const auction = await sdk.getDynamicAuction(hookAddress);
|
|
8030
7983
|
return auction.getHookInfo();
|
|
8031
7984
|
};
|
|
8032
|
-
|
|
7985
|
+
module2.exports.quoteV4ExactIn = async function quoteV4ExactIn(sdk, { poolKey, zeroForOne, exactAmount, hookData }) {
|
|
8033
7986
|
return sdk.quoter.quoteExactInputV4({ poolKey, zeroForOne, exactAmount, hookData });
|
|
8034
7987
|
};
|
|
8035
7988
|
var UR_ABI = [
|
|
8036
7989
|
{ name: "execute", type: "function", stateMutability: "payable", inputs: [{ name: "commands", type: "bytes" }, { name: "inputs", type: "bytes[]" }], outputs: [] }
|
|
8037
7990
|
];
|
|
8038
|
-
|
|
7991
|
+
module2.exports.urExecute = async function urExecute({ rpcUrl, chainId, privateKey, universalRouter, commands, inputs, value }) {
|
|
8039
7992
|
const chain = getChainById(chainId);
|
|
8040
7993
|
const accountObj = privateKeyToAccount(privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`);
|
|
8041
7994
|
const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
|
|
@@ -8044,7 +7997,7 @@ var require_doppler = __commonJS({
|
|
|
8044
7997
|
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
8045
7998
|
return { hash, receipt };
|
|
8046
7999
|
};
|
|
8047
|
-
|
|
8000
|
+
module2.exports.simulateCreateStaticAuction = async function simulateCreateStaticAuction(sdk, builderParams) {
|
|
8048
8001
|
const StaticAuctionBuilder = dopplerLib.StaticAuctionBuilder || dopplerLib.default?.StaticAuctionBuilder;
|
|
8049
8002
|
if (!StaticAuctionBuilder) throw new Error("StaticAuctionBuilder missing from doppler-sdk");
|
|
8050
8003
|
const builder = new StaticAuctionBuilder().tokenConfig(builderParams.token).saleConfig(builderParams.sale).poolByTicks(builderParams.pool).withUserAddress(builderParams.userAddress);
|
|
@@ -8055,10 +8008,10 @@ var require_doppler = __commonJS({
|
|
|
8055
8008
|
const params = builder.build();
|
|
8056
8009
|
return sdk.factory.simulateCreateStaticAuction(params);
|
|
8057
8010
|
};
|
|
8058
|
-
|
|
8011
|
+
module2.exports.simulateBundleExactOut = async function simulateBundleExactOut(sdk, createParams, { tokenIn, tokenOut, amount, fee, sqrtPriceLimitX96 = 0n }) {
|
|
8059
8012
|
return sdk.factory.simulateBundleExactOutput(createParams, { tokenIn, tokenOut, amount, fee, sqrtPriceLimitX96 });
|
|
8060
8013
|
};
|
|
8061
|
-
|
|
8014
|
+
module2.exports.factoryBundle = async function factoryBundle(sdk, createParams, { commands, inputs, value }) {
|
|
8062
8015
|
return sdk.factory.bundle(createParams, commands, inputs, { value });
|
|
8063
8016
|
};
|
|
8064
8017
|
var V3_SWAP_ROUTER_ABI = [
|
|
@@ -8085,7 +8038,7 @@ var require_doppler = __commonJS({
|
|
|
8085
8038
|
outputs: [{ name: "amountOut", type: "uint256" }]
|
|
8086
8039
|
}
|
|
8087
8040
|
];
|
|
8088
|
-
|
|
8041
|
+
module2.exports.executeV3BuyExactIn = async function executeV3BuyExactIn({
|
|
8089
8042
|
rpcUrl,
|
|
8090
8043
|
chainId,
|
|
8091
8044
|
privateKey,
|
|
@@ -8142,13 +8095,14 @@ var require_doppler = __commonJS({
|
|
|
8142
8095
|
|
|
8143
8096
|
// src/index.js
|
|
8144
8097
|
var require_src = __commonJS({
|
|
8145
|
-
"src/index.js"(
|
|
8098
|
+
"src/index.js"(exports2, module2) {
|
|
8146
8099
|
var pkg = require_package();
|
|
8147
8100
|
var abi = require_abi();
|
|
8148
8101
|
var governance = require_governance();
|
|
8149
8102
|
governance.intents = require_intents();
|
|
8150
8103
|
var governanceTemplates = require_templates();
|
|
8151
8104
|
governance.operations = require_operations();
|
|
8105
|
+
governance.grants = require_grants();
|
|
8152
8106
|
var subdao = require_subdao();
|
|
8153
8107
|
var timelock = require_timelock();
|
|
8154
8108
|
var factory = require_factory();
|
|
@@ -8165,7 +8119,6 @@ var require_src = __commonJS({
|
|
|
8165
8119
|
var treasury = require_treasury();
|
|
8166
8120
|
var boost = require_boost();
|
|
8167
8121
|
var bounty = require_bounty();
|
|
8168
|
-
var bond = require_bond();
|
|
8169
8122
|
var wallet = require_wallet();
|
|
8170
8123
|
wallet.session = require_session();
|
|
8171
8124
|
var walletCastManager = require_cast_manager();
|
|
@@ -8180,7 +8133,7 @@ var require_src = __commonJS({
|
|
|
8180
8133
|
openzeppelin: require_openzeppelin()
|
|
8181
8134
|
}
|
|
8182
8135
|
};
|
|
8183
|
-
|
|
8136
|
+
module2.exports = {
|
|
8184
8137
|
version: pkg.version,
|
|
8185
8138
|
getProvider: utils.getProvider,
|
|
8186
8139
|
abi,
|
|
@@ -8198,7 +8151,7 @@ var require_src = __commonJS({
|
|
|
8198
8151
|
personal,
|
|
8199
8152
|
treasury,
|
|
8200
8153
|
boost,
|
|
8201
|
-
bond
|
|
8154
|
+
// bond module removed; bonds deprecated in CLI/SDK
|
|
8202
8155
|
subgraph,
|
|
8203
8156
|
utils: { ...utils, privateTx, safe },
|
|
8204
8157
|
bounty,
|
|
@@ -8244,8 +8197,8 @@ var require_src = __commonJS({
|
|
|
8244
8197
|
|
|
8245
8198
|
// src/node.js
|
|
8246
8199
|
var require_node = __commonJS({
|
|
8247
|
-
"src/node.js"(
|
|
8248
|
-
|
|
8200
|
+
"src/node.js"(exports2, module2) {
|
|
8201
|
+
module2.exports = require_src();
|
|
8249
8202
|
}
|
|
8250
8203
|
});
|
|
8251
8204
|
export default require_node();
|