@sage-protocol/sdk 0.2.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.mjs +18 -20
- package/dist/index.cjs +247 -740
- package/dist/index.mjs +247 -740
- package/dist/node/index.cjs +247 -740
- package/dist/node/index.mjs +247 -740
- package/package.json +1 -2
- package/types/index.d.ts +36 -11
package/dist/index.mjs
CHANGED
|
@@ -20,7 +20,7 @@ var require_package = __commonJS({
|
|
|
20
20
|
"package.json"(exports2, module2) {
|
|
21
21
|
module2.exports = {
|
|
22
22
|
name: "@sage-protocol/sdk",
|
|
23
|
-
version: "0.
|
|
23
|
+
version: "0.3.0",
|
|
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",
|
|
@@ -78,7 +78,6 @@ var require_package = __commonJS({
|
|
|
78
78
|
},
|
|
79
79
|
dependencies: {
|
|
80
80
|
"@merit-systems/echo-typescript-sdk": "^1.0.17",
|
|
81
|
-
"@whetstone-research/doppler-sdk": "^0.0.1-alpha.40",
|
|
82
81
|
ai: "^5.0.52",
|
|
83
82
|
axios: "^1.11.0",
|
|
84
83
|
ethers: "^6.15.0",
|
|
@@ -164,31 +163,36 @@ var require_abi = __commonJS({
|
|
|
164
163
|
];
|
|
165
164
|
var FactoryWrite = [
|
|
166
165
|
"function createSubDAO(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount) returns (address subDAO, address registry)",
|
|
166
|
+
// legacy compatibility
|
|
167
167
|
"function createSubDAOWithStable(string name, string description, uint8 accessModel, uint256 minStakeAmount, (uint256 value,uint256 deadline,uint8 v,bytes32 r,bytes32 s) permit) returns (address subDAO, address registry)",
|
|
168
168
|
"function createSubDAOWithParams(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount, uint256 votingDelay, uint256 votingPeriod, uint256 proposalThreshold, uint256 quorumPercentage, uint8 initialForkPolicy, uint8 initialMembershipPolicy, string profileCID, string manifestCID, string manifestVersion) returns (address subDAO, address registry)",
|
|
169
169
|
"function createSubDAOOperatorWithStable(string name, string description, uint8 accessModel, uint256 minStakeAmount, address operatorExecutor, address operatorAdmin, (uint256 value,uint256 deadline,uint8 v,bytes32 r,bytes32 s) permit) returns (address subDAO, address registry)",
|
|
170
170
|
"function createSubDAOOperatorWithStableAdvanced(string name, string description, uint8 accessModel, uint256 minStakeAmount, address operatorExecutor, address operatorAdmin, bool anyoneExec, bool governorProposer, (uint256 value,uint256 deadline,uint8 v,bytes32 r,bytes32 s) permit) returns (address subDAO, address registry)",
|
|
171
171
|
"function createSubDAOOperator(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount, address operatorExecutor, address operatorAdmin) returns (address subDAO, address registry)",
|
|
172
172
|
"function createSubDAOOperatorAdvanced(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount, address operatorExecutor, address operatorAdmin, bool anyoneExec, bool governorProposer) returns (address subDAO, address registry)",
|
|
173
|
+
// Forking (legacy overloads forward with maxForkFee=type(uint256).max)
|
|
173
174
|
"function createForkedSubDAO(string newName, string newDescription, string originalName, address originalSubDAO, address forker, bool copyLibrary) returns (address subDAO, address registry)",
|
|
174
|
-
|
|
175
|
+
// Forking (preferred: explicit maxForkFee slippage cap)
|
|
176
|
+
"function createForkedSubDAO(string newName, string newDescription, string originalName, address originalSubDAO, address forker, uint256 maxForkFee, bool copyLibrary) returns (address subDAO, address registry)",
|
|
177
|
+
// Stable-fee forking (legacy overloads forward with maxForkFee=type(uint256).max)
|
|
178
|
+
"function createForkedSubDAOWithStable(string newName, string newDescription, string originalName, address originalSubDAO, address forker, uint64 authorizationNonce, (uint256 value,uint256 deadline,uint8 v,bytes32 r,bytes32 s) permit, bool copyLibrary) returns (address subDAO, address registry)",
|
|
179
|
+
// Stable-fee forking (preferred: explicit maxForkFee slippage cap)
|
|
180
|
+
"function createForkedSubDAOWithStable(string newName, string newDescription, string originalName, address originalSubDAO, address forker, uint64 authorizationNonce, (uint256 value,uint256 deadline,uint8 v,bytes32 r,bytes32 s) permit, uint256 maxForkFee, bool copyLibrary) returns (address subDAO, address registry)"
|
|
175
181
|
];
|
|
176
182
|
var TemplateModule = [
|
|
177
183
|
"function getActiveTemplates() view returns (uint256[])",
|
|
178
|
-
"function getTemplateStruct(uint256) view returns (string,string,uint8,uint8,uint8,
|
|
184
|
+
"function getTemplateStruct(uint256) view returns (string,string,uint8,uint8,uint8,bool,bool,uint256,uint256,uint256,uint256,uint256,uint256,bool,bytes)",
|
|
179
185
|
"function getTemplateUsage(uint256) view returns (uint256)",
|
|
180
186
|
"function getTemplateUsageMeta(uint256) view returns (uint256 usage, uint256 cap)",
|
|
181
187
|
"function minCreationBurn() view returns (uint256)",
|
|
182
188
|
"function maxCreationBurn() view returns (uint256)"
|
|
183
189
|
];
|
|
184
190
|
var LibraryRegistry = [
|
|
185
|
-
"function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version,
|
|
191
|
+
"function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version, uint256 nonce)",
|
|
186
192
|
"function daoTimelock(address) view returns (address)",
|
|
187
|
-
"function getLibrary(address) view returns (tuple(string manifestCID, address lastUpdater, uint256 lastUpdated, string version,
|
|
193
|
+
"function getLibrary(address) view returns (tuple(string manifestCID, address lastUpdater, uint256 lastUpdated, string version, uint256 nonce))",
|
|
188
194
|
"function getLibraryIds(address dao) view returns (bytes32[] memory)",
|
|
189
|
-
"function getLibraryStream(address dao, string libraryId) view returns (tuple(string manifestCID, address lastUpdater, uint256 lastUpdated, string version,
|
|
190
|
-
"function getLibraryForkFee(address dao) view returns (uint256)",
|
|
191
|
-
"function setLibraryForkFee(address dao, uint256 fee)",
|
|
195
|
+
"function getLibraryStream(address dao, string libraryId) view returns (tuple(string manifestCID, address lastUpdater, uint256 lastUpdated, string version, uint256 nonce))",
|
|
192
196
|
"function updateLibrary(address dao, string manifestCID, string version)",
|
|
193
197
|
"function updateLibraryCAS(address dao, string manifestCID, string version, uint256 expectedNonce)",
|
|
194
198
|
"function updateLibraryStream(address dao, string libraryId, string manifestCID, string version)",
|
|
@@ -307,9 +311,6 @@ var require_abi = __commonJS({
|
|
|
307
311
|
"function getForkBurnDiscount(address) view returns (uint256)",
|
|
308
312
|
"function totalBurned() view returns (uint256)"
|
|
309
313
|
];
|
|
310
|
-
var PersonalLibraryFacet = [
|
|
311
|
-
"function createPersonalRegistry(uint8 policy) returns (address)"
|
|
312
|
-
];
|
|
313
314
|
var PersonalMarketplace = [
|
|
314
315
|
"function setPrice(bytes32 key, uint256 price)",
|
|
315
316
|
"function purchase(address creator, bytes32 key, uint256 expectedPrice, uint256 deadline)"
|
|
@@ -336,7 +337,7 @@ var require_abi = __commonJS({
|
|
|
336
337
|
"function setMerkleRoot(uint256 proposalId, bytes32 root)",
|
|
337
338
|
"function finalize(uint256 proposalId)",
|
|
338
339
|
"function claim(uint256 proposalId, address account, uint256 amount, bytes32[] proof)",
|
|
339
|
-
"function getBoost(uint256 proposalId) view returns (uint256 totalPool, uint256 totalClaimed, bytes32 merkleRoot, bool active, bool finalized, address creator)",
|
|
340
|
+
"function getBoost(uint256 proposalId) view returns (uint256 totalPool, uint256 totalClaimed, bytes32 merkleRoot, uint256 expiresAt, bool active, bool finalized, address creator)",
|
|
340
341
|
"function claimed(uint256 proposalId, address account) view returns (bool)",
|
|
341
342
|
"event BoostCreated(uint256 indexed proposalId, address indexed creator, uint256 totalPool)",
|
|
342
343
|
"event MerkleRootSet(uint256 indexed proposalId, bytes32 merkleRoot)",
|
|
@@ -434,7 +435,7 @@ var require_abi = __commonJS({
|
|
|
434
435
|
"function weth() view returns (address)",
|
|
435
436
|
"function timeBuffer() view returns (uint256)",
|
|
436
437
|
"function reservePrice() view returns (uint256)",
|
|
437
|
-
"function
|
|
438
|
+
"function minBidIncrementBps() view returns (uint256)",
|
|
438
439
|
"function duration() view returns (uint256)",
|
|
439
440
|
"function mintTierId() view returns (uint256)",
|
|
440
441
|
"function defaultTokenURI() view returns (string)",
|
|
@@ -444,7 +445,7 @@ var require_abi = __commonJS({
|
|
|
444
445
|
"function paused() view returns (bool)",
|
|
445
446
|
"function setTimeBuffer(uint256 _timeBuffer)",
|
|
446
447
|
"function setReservePrice(uint256 _reservePrice)",
|
|
447
|
-
"function
|
|
448
|
+
"function setMinBidIncrementBps(uint256 _minBidIncrementBps)",
|
|
448
449
|
"function setDuration(uint256 _duration)",
|
|
449
450
|
"function setMintTierId(uint256 _tierId)",
|
|
450
451
|
"function setDefaultTokenURI(string _uri)",
|
|
@@ -457,7 +458,7 @@ var require_abi = __commonJS({
|
|
|
457
458
|
"event AuctionSettled(uint256 indexed nftId, address winner, uint256 amount)",
|
|
458
459
|
"event AuctionTimeBufferUpdated(uint256 timeBuffer)",
|
|
459
460
|
"event AuctionReservePriceUpdated(uint256 reservePrice)",
|
|
460
|
-
"event
|
|
461
|
+
"event AuctionMinBidIncrementBpsUpdated(uint256 minBidIncrementBps)",
|
|
461
462
|
"event AuctionDurationUpdated(uint256 duration)"
|
|
462
463
|
];
|
|
463
464
|
var SimpleBountySystem = [
|
|
@@ -467,10 +468,8 @@ var require_abi = __commonJS({
|
|
|
467
468
|
// Bounty Creation
|
|
468
469
|
"function createBounty(string title, string description, string ipfsCID, uint256 reward, uint256 deadline) returns (uint256)",
|
|
469
470
|
"function createBountyAdvanced(string title, string description, string ipfsCID, uint256 reward, uint256 deadline, uint256 votingDuration, uint8 mode, uint8 libraryAction, address assignee, string libraryKey) returns (uint256)",
|
|
470
|
-
// Submission
|
|
471
|
-
"function claimBounty(uint256 bountyId)",
|
|
471
|
+
// Submission
|
|
472
472
|
"function submitEntry(uint256 bountyId, string promptIPFS, string deliverableIPFS) returns (uint256)",
|
|
473
|
-
"function completeBounty(uint256 bountyId, string deliverableIPFS)",
|
|
474
473
|
// Voting (COMPETITIVE mode)
|
|
475
474
|
"function startVoting(uint256 bountyId)",
|
|
476
475
|
"function vote(uint256 bountyId, uint256 submissionId)",
|
|
@@ -549,7 +548,6 @@ var require_abi = __commonJS({
|
|
|
549
548
|
Timelock,
|
|
550
549
|
ERC20Votes,
|
|
551
550
|
SXXX,
|
|
552
|
-
PersonalLibraryFacet,
|
|
553
551
|
PersonalMarketplace,
|
|
554
552
|
PersonalLicenseReceipt,
|
|
555
553
|
TreasuryWrapper,
|
|
@@ -1840,13 +1838,31 @@ var require_subdao = __commonJS({
|
|
|
1840
1838
|
Number(accessModel ?? 0),
|
|
1841
1839
|
0n,
|
|
1842
1840
|
// minStakeAmount deprecated
|
|
1843
|
-
BigInt(burnAmount ?? 0n)
|
|
1841
|
+
BigInt(burnAmount ?? 0n),
|
|
1842
|
+
1n,
|
|
1843
|
+
// votingDelay
|
|
1844
|
+
100n,
|
|
1845
|
+
// votingPeriod
|
|
1846
|
+
1n,
|
|
1847
|
+
// proposalThreshold
|
|
1848
|
+
500n * 10n ** 18n,
|
|
1849
|
+
// quorumVotes
|
|
1850
|
+
0,
|
|
1851
|
+
// initialForkPolicy
|
|
1852
|
+
0,
|
|
1853
|
+
// initialMembershipPolicy
|
|
1854
|
+
"",
|
|
1855
|
+
// profileCID
|
|
1856
|
+
"",
|
|
1857
|
+
// manifestCID
|
|
1858
|
+
""
|
|
1859
|
+
// manifestVersion
|
|
1844
1860
|
];
|
|
1845
1861
|
let tx;
|
|
1846
1862
|
try {
|
|
1847
|
-
tx = await fac.
|
|
1863
|
+
tx = await fac.createSubDAOWithParams(...args);
|
|
1848
1864
|
} catch (err) {
|
|
1849
|
-
tx = await fac.
|
|
1865
|
+
tx = await fac.createSubDAOWithParams(...args, { gasLimit: 8e6 });
|
|
1850
1866
|
}
|
|
1851
1867
|
const receipt = await tx.wait();
|
|
1852
1868
|
const iface = new Interface(ABI.Factory);
|
|
@@ -3857,6 +3873,43 @@ var require_library = __commonJS({
|
|
|
3857
3873
|
}
|
|
3858
3874
|
return raw;
|
|
3859
3875
|
}
|
|
3876
|
+
function mapLibraryInfo(info, libraryId = "default") {
|
|
3877
|
+
return {
|
|
3878
|
+
libraryId,
|
|
3879
|
+
manifestCID: info.manifestCID,
|
|
3880
|
+
previousCID: "",
|
|
3881
|
+
// Not tracked on-chain (history is in events/subgraph)
|
|
3882
|
+
timestamp: BigInt(info.lastUpdated.toString()),
|
|
3883
|
+
proposer: getAddress(info.lastUpdater),
|
|
3884
|
+
promptCount: 0,
|
|
3885
|
+
// Not tracked on-chain
|
|
3886
|
+
version: info.version,
|
|
3887
|
+
nonce: BigInt(info.nonce.toString()),
|
|
3888
|
+
forkedFromDAO: null,
|
|
3889
|
+
// Removed from on-chain struct; use events/subgraph
|
|
3890
|
+
sxxxForkFee: 0n
|
|
3891
|
+
// Removed from on-chain struct
|
|
3892
|
+
};
|
|
3893
|
+
}
|
|
3894
|
+
async function resolveLibraryInfo({ contract, dao, libraryId = "default" }) {
|
|
3895
|
+
const libId = normaliseLibraryId(libraryId);
|
|
3896
|
+
let streamError = null;
|
|
3897
|
+
try {
|
|
3898
|
+
const stream = await contract.getLibraryStream(dao, libId);
|
|
3899
|
+
const streamCid = typeof stream?.manifestCID === "string" ? stream.manifestCID.trim() : "";
|
|
3900
|
+
if (streamCid || libId !== "default") {
|
|
3901
|
+
return mapLibraryInfo(stream, libId);
|
|
3902
|
+
}
|
|
3903
|
+
} catch (err) {
|
|
3904
|
+
streamError = err;
|
|
3905
|
+
}
|
|
3906
|
+
if (libId === "default") {
|
|
3907
|
+
const legacy = await contract.getLibrary(dao);
|
|
3908
|
+
return mapLibraryInfo(legacy, libId);
|
|
3909
|
+
}
|
|
3910
|
+
if (streamError) throw streamError;
|
|
3911
|
+
throw new SageSDKError(CODES.NOT_FOUND, `library stream not found`, { dao, libraryId: libId });
|
|
3912
|
+
}
|
|
3860
3913
|
async function listManifests({ provider, registry, factoryAddress, offset = 0, limit = 50 }) {
|
|
3861
3914
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
3862
3915
|
if (!factoryAddress) throw new SageSDKError(CODES.INVALID_ARGS, "factoryAddress required for V4 listing");
|
|
@@ -3880,41 +3933,15 @@ var require_library = __commonJS({
|
|
|
3880
3933
|
const addr = normalise(registry, "registry");
|
|
3881
3934
|
const dao = normalise(subdao, "subdao");
|
|
3882
3935
|
const contract = new Contract(addr, ABI.LibraryRegistry, provider);
|
|
3883
|
-
|
|
3884
|
-
return {
|
|
3885
|
-
manifestCID: info.manifestCID,
|
|
3886
|
-
previousCID: "",
|
|
3887
|
-
// Not tracked on-chain in V4 (history is in events/subgraph)
|
|
3888
|
-
timestamp: BigInt(info.lastUpdated.toString()),
|
|
3889
|
-
proposer: getAddress(info.lastUpdater),
|
|
3890
|
-
promptCount: 0,
|
|
3891
|
-
// Not tracked on-chain in V4
|
|
3892
|
-
version: info.version,
|
|
3893
|
-
nonce: BigInt(info.nonce.toString()),
|
|
3894
|
-
forkedFromDAO: info.forkedFromDAO && info.forkedFromDAO !== "0x0000000000000000000000000000000000000000" ? getAddress(info.forkedFromDAO) : null,
|
|
3895
|
-
sxxxForkFee: BigInt(info.sxxxForkFee.toString())
|
|
3896
|
-
};
|
|
3936
|
+
return resolveLibraryInfo({ contract, dao, libraryId: "default" });
|
|
3897
3937
|
}
|
|
3898
3938
|
async function getLibraryStreamInfo({ provider, registry, subdao, libraryId = "default" }) {
|
|
3899
3939
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
3900
3940
|
if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
|
|
3901
3941
|
const addr = normalise(registry, "registry");
|
|
3902
3942
|
const dao = normalise(subdao, "subdao");
|
|
3903
|
-
const libId = normaliseLibraryId(libraryId);
|
|
3904
3943
|
const contract = new Contract(addr, ABI.LibraryRegistry, provider);
|
|
3905
|
-
|
|
3906
|
-
return {
|
|
3907
|
-
libraryId: libId,
|
|
3908
|
-
manifestCID: info.manifestCID,
|
|
3909
|
-
previousCID: "",
|
|
3910
|
-
timestamp: BigInt(info.lastUpdated.toString()),
|
|
3911
|
-
proposer: getAddress(info.lastUpdater),
|
|
3912
|
-
promptCount: 0,
|
|
3913
|
-
version: info.version,
|
|
3914
|
-
nonce: BigInt(info.nonce.toString()),
|
|
3915
|
-
forkedFromDAO: info.forkedFromDAO && info.forkedFromDAO !== "0x0000000000000000000000000000000000000000" ? getAddress(info.forkedFromDAO) : null,
|
|
3916
|
-
sxxxForkFee: BigInt(info.sxxxForkFee.toString())
|
|
3917
|
-
};
|
|
3944
|
+
return resolveLibraryInfo({ contract, dao, libraryId });
|
|
3918
3945
|
}
|
|
3919
3946
|
async function getLibraryIds({ provider, registry, subdao }) {
|
|
3920
3947
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
@@ -4569,8 +4596,8 @@ var require_governance = __commonJS({
|
|
|
4569
4596
|
const reg = new Contract(
|
|
4570
4597
|
targets[i],
|
|
4571
4598
|
[
|
|
4572
|
-
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4573
|
-
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4599
|
+
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))",
|
|
4600
|
+
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))"
|
|
4574
4601
|
],
|
|
4575
4602
|
provider
|
|
4576
4603
|
);
|
|
@@ -4604,8 +4631,8 @@ var require_governance = __commonJS({
|
|
|
4604
4631
|
const reg = new Contract(
|
|
4605
4632
|
targets[i],
|
|
4606
4633
|
[
|
|
4607
|
-
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4608
|
-
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4634
|
+
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))",
|
|
4635
|
+
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))"
|
|
4609
4636
|
],
|
|
4610
4637
|
provider
|
|
4611
4638
|
);
|
|
@@ -4639,8 +4666,8 @@ var require_governance = __commonJS({
|
|
|
4639
4666
|
const reg = new Contract(
|
|
4640
4667
|
targets[i],
|
|
4641
4668
|
[
|
|
4642
|
-
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4643
|
-
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4669
|
+
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))",
|
|
4670
|
+
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))"
|
|
4644
4671
|
],
|
|
4645
4672
|
provider
|
|
4646
4673
|
);
|
|
@@ -4681,8 +4708,8 @@ var require_governance = __commonJS({
|
|
|
4681
4708
|
const reg = new Contract(
|
|
4682
4709
|
targets[i],
|
|
4683
4710
|
[
|
|
4684
|
-
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4685
|
-
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4711
|
+
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))",
|
|
4712
|
+
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))"
|
|
4686
4713
|
],
|
|
4687
4714
|
provider
|
|
4688
4715
|
);
|
|
@@ -7049,16 +7076,16 @@ var require_factory = __commonJS({
|
|
|
7049
7076
|
accessModel: Number(template[2]),
|
|
7050
7077
|
forkPolicy: Number(template[3]),
|
|
7051
7078
|
membershipPolicy: Number(template[4]),
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7079
|
+
allowForkPolicyOverride: Boolean(template[5]),
|
|
7080
|
+
allowMembershipPolicyOverride: Boolean(template[6]),
|
|
7081
|
+
burnAmount: BigInt(template[7].toString()),
|
|
7082
|
+
votingDelay: BigInt(template[8].toString()),
|
|
7083
|
+
votingPeriod: BigInt(template[9].toString()),
|
|
7084
|
+
proposalThreshold: BigInt(template[10].toString()),
|
|
7085
|
+
// template[11] is quorumVotes (absolute token amount, e.g., 100e18 = 100 SXXX)
|
|
7086
|
+
quorumVotes: BigInt(template[11].toString()),
|
|
7087
|
+
quorumPercentage: Number(template[11]),
|
|
7060
7088
|
// deprecated alias
|
|
7061
|
-
// template[11] was proposalStakeRequired (deprecated)
|
|
7062
7089
|
proposalCooldownSeconds: BigInt(template[12].toString()),
|
|
7063
7090
|
isActive: Boolean(template[13])
|
|
7064
7091
|
});
|
|
@@ -7079,16 +7106,16 @@ var require_factory = __commonJS({
|
|
|
7079
7106
|
accessModel: Number(template[2]),
|
|
7080
7107
|
forkPolicy: Number(template[3]),
|
|
7081
7108
|
membershipPolicy: Number(template[4]),
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7109
|
+
allowForkPolicyOverride: Boolean(template[5]),
|
|
7110
|
+
allowMembershipPolicyOverride: Boolean(template[6]),
|
|
7111
|
+
burnAmount: BigInt(template[7].toString()),
|
|
7112
|
+
votingDelay: BigInt(template[8].toString()),
|
|
7113
|
+
votingPeriod: BigInt(template[9].toString()),
|
|
7114
|
+
proposalThreshold: BigInt(template[10].toString()),
|
|
7115
|
+
// template[11] is quorumVotes (absolute token amount, e.g., 100e18 = 100 SXXX)
|
|
7116
|
+
quorumVotes: BigInt(template[11].toString()),
|
|
7117
|
+
quorumPercentage: Number(template[11]),
|
|
7090
7118
|
// deprecated alias
|
|
7091
|
-
// template[11] was proposalStakeRequired (deprecated)
|
|
7092
7119
|
proposalCooldownSeconds: BigInt(template[12].toString()),
|
|
7093
7120
|
isActive: Boolean(template[13]),
|
|
7094
7121
|
usage: usage != null ? BigInt(usage.toString()) : null,
|
|
@@ -7096,15 +7123,40 @@ var require_factory = __commonJS({
|
|
|
7096
7123
|
};
|
|
7097
7124
|
}
|
|
7098
7125
|
var FactoryWriteInterface = new Interface(ABI.FactoryWrite);
|
|
7099
|
-
function buildCreateSubDAOTx({
|
|
7126
|
+
function buildCreateSubDAOTx({
|
|
7127
|
+
factory,
|
|
7128
|
+
name,
|
|
7129
|
+
description,
|
|
7130
|
+
accessModel,
|
|
7131
|
+
minStakeAmount,
|
|
7132
|
+
burnAmount,
|
|
7133
|
+
votingDelay = 1n,
|
|
7134
|
+
votingPeriod = 100n,
|
|
7135
|
+
proposalThreshold = 1n,
|
|
7136
|
+
quorumVotes = 500n * 10n ** 18n,
|
|
7137
|
+
initialForkPolicy = 0,
|
|
7138
|
+
initialMembershipPolicy = 0,
|
|
7139
|
+
profileCID = "",
|
|
7140
|
+
manifestCID = "",
|
|
7141
|
+
manifestVersion = ""
|
|
7142
|
+
}) {
|
|
7100
7143
|
const addr = normalise(factory, "factory");
|
|
7101
|
-
const payload = FactoryWriteInterface.encodeFunctionData("
|
|
7144
|
+
const payload = FactoryWriteInterface.encodeFunctionData("createSubDAOWithParams", [
|
|
7102
7145
|
String(name),
|
|
7103
7146
|
String(description),
|
|
7104
7147
|
Number(accessModel),
|
|
7105
|
-
0n,
|
|
7148
|
+
BigInt(minStakeAmount || 0n),
|
|
7106
7149
|
// minStakeAmount deprecated
|
|
7107
|
-
BigInt(burnAmount)
|
|
7150
|
+
BigInt(burnAmount),
|
|
7151
|
+
BigInt(votingDelay),
|
|
7152
|
+
BigInt(votingPeriod),
|
|
7153
|
+
BigInt(proposalThreshold),
|
|
7154
|
+
BigInt(quorumVotes),
|
|
7155
|
+
Number(initialForkPolicy),
|
|
7156
|
+
Number(initialMembershipPolicy),
|
|
7157
|
+
String(profileCID || ""),
|
|
7158
|
+
String(manifestCID || ""),
|
|
7159
|
+
String(manifestVersion || "")
|
|
7108
7160
|
]);
|
|
7109
7161
|
return { to: addr, data: payload, value: 0n };
|
|
7110
7162
|
}
|
|
@@ -7128,18 +7180,45 @@ var require_factory = __commonJS({
|
|
|
7128
7180
|
]);
|
|
7129
7181
|
return { to: addr, data: payload, value: 0n };
|
|
7130
7182
|
}
|
|
7131
|
-
function buildCreateForkedSubDAOTx({
|
|
7183
|
+
function buildCreateForkedSubDAOTx({
|
|
7184
|
+
factory,
|
|
7185
|
+
newName,
|
|
7186
|
+
newDescription,
|
|
7187
|
+
originalName,
|
|
7188
|
+
originalSubDAO,
|
|
7189
|
+
forker,
|
|
7190
|
+
copyLibrary = false,
|
|
7191
|
+
maxForkFee
|
|
7192
|
+
}) {
|
|
7132
7193
|
const addr = normalise(factory, "factory");
|
|
7133
|
-
const
|
|
7194
|
+
const argsBase = [
|
|
7134
7195
|
String(newName),
|
|
7135
7196
|
String(newDescription),
|
|
7136
7197
|
String(originalName),
|
|
7137
7198
|
normalise(originalSubDAO, "originalSubDAO"),
|
|
7138
7199
|
normalise(forker, "forker")
|
|
7139
|
-
]
|
|
7200
|
+
];
|
|
7201
|
+
const payload = maxForkFee === void 0 || maxForkFee === null ? FactoryWriteInterface.encodeFunctionData(
|
|
7202
|
+
"createForkedSubDAO(string,string,string,address,address,bool)",
|
|
7203
|
+
[...argsBase, Boolean(copyLibrary)]
|
|
7204
|
+
) : FactoryWriteInterface.encodeFunctionData(
|
|
7205
|
+
"createForkedSubDAO(string,string,string,address,address,uint256,bool)",
|
|
7206
|
+
[...argsBase, BigInt(maxForkFee), Boolean(copyLibrary)]
|
|
7207
|
+
);
|
|
7140
7208
|
return { to: addr, data: payload, value: 0n };
|
|
7141
7209
|
}
|
|
7142
|
-
function buildCreateForkedSubDAOWithStableTx({
|
|
7210
|
+
function buildCreateForkedSubDAOWithStableTx({
|
|
7211
|
+
factory,
|
|
7212
|
+
newName,
|
|
7213
|
+
newDescription,
|
|
7214
|
+
originalName,
|
|
7215
|
+
originalSubDAO,
|
|
7216
|
+
forker,
|
|
7217
|
+
authorizationNonce,
|
|
7218
|
+
permit,
|
|
7219
|
+
copyLibrary = false,
|
|
7220
|
+
maxForkFee
|
|
7221
|
+
}) {
|
|
7143
7222
|
const addr = normalise(factory, "factory");
|
|
7144
7223
|
if (!permit) throw new SageSDKError(CODES.INVALID_ARGS, "permit required for stable fork");
|
|
7145
7224
|
const tuple = [
|
|
@@ -7149,7 +7228,7 @@ var require_factory = __commonJS({
|
|
|
7149
7228
|
permit.r ?? "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
7150
7229
|
permit.s ?? "0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
7151
7230
|
];
|
|
7152
|
-
const
|
|
7231
|
+
const argsBase = [
|
|
7153
7232
|
String(newName),
|
|
7154
7233
|
String(newDescription),
|
|
7155
7234
|
String(originalName),
|
|
@@ -7157,7 +7236,14 @@ var require_factory = __commonJS({
|
|
|
7157
7236
|
normalise(forker, "forker"),
|
|
7158
7237
|
Number(authorizationNonce ?? 0),
|
|
7159
7238
|
tuple
|
|
7160
|
-
]
|
|
7239
|
+
];
|
|
7240
|
+
const payload = maxForkFee === void 0 || maxForkFee === null ? FactoryWriteInterface.encodeFunctionData(
|
|
7241
|
+
"createForkedSubDAOWithStable(string,string,string,address,address,uint64,(uint256,uint256,uint8,bytes32,bytes32),bool)",
|
|
7242
|
+
[...argsBase, Boolean(copyLibrary)]
|
|
7243
|
+
) : FactoryWriteInterface.encodeFunctionData(
|
|
7244
|
+
"createForkedSubDAOWithStable(string,string,string,address,address,uint64,(uint256,uint256,uint8,bytes32,bytes32),uint256,bool)",
|
|
7245
|
+
[...argsBase, BigInt(maxForkFee), Boolean(copyLibrary)]
|
|
7246
|
+
);
|
|
7161
7247
|
return { to: addr, data: payload, value: 0n };
|
|
7162
7248
|
}
|
|
7163
7249
|
function buildCreateSubDAOWithParamsTx({
|
|
@@ -7358,10 +7444,8 @@ var require_lineage = __commonJS({
|
|
|
7358
7444
|
var { Contract, getAddress } = __require("ethers");
|
|
7359
7445
|
var { SageSDKError, CODES } = require_errors();
|
|
7360
7446
|
var LINEAGE_ABI = [
|
|
7361
|
-
"function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version,
|
|
7362
|
-
"function getLibraryForkFee(address) view returns (uint256)"
|
|
7447
|
+
"function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version, uint256 nonce)"
|
|
7363
7448
|
];
|
|
7364
|
-
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
7365
7449
|
function normalise(address, label) {
|
|
7366
7450
|
if (!address) throw new SageSDKError(CODES.INVALID_ARGS, `${label} required`);
|
|
7367
7451
|
try {
|
|
@@ -7375,13 +7459,7 @@ var require_lineage = __commonJS({
|
|
|
7375
7459
|
if (!registry) throw new SageSDKError(CODES.INVALID_ARGS, "registry required");
|
|
7376
7460
|
if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
|
|
7377
7461
|
try {
|
|
7378
|
-
|
|
7379
|
-
const info = await contract.libraryByDAO(normalise(subdao, "subdao"));
|
|
7380
|
-
const parent = info.forkedFromDAO;
|
|
7381
|
-
if (!parent || parent === ZERO_ADDRESS) {
|
|
7382
|
-
return null;
|
|
7383
|
-
}
|
|
7384
|
-
return getAddress(parent).toLowerCase();
|
|
7462
|
+
return null;
|
|
7385
7463
|
} catch (err) {
|
|
7386
7464
|
throw new SageSDKError(CODES.CONTRACT_ERROR, "Failed to fetch parent library", { cause: err });
|
|
7387
7465
|
}
|
|
@@ -7391,25 +7469,11 @@ var require_lineage = __commonJS({
|
|
|
7391
7469
|
if (!registry) throw new SageSDKError(CODES.INVALID_ARGS, "registry required");
|
|
7392
7470
|
if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
|
|
7393
7471
|
try {
|
|
7394
|
-
const
|
|
7395
|
-
const chain = [];
|
|
7396
|
-
let current = normalise(subdao, "subdao");
|
|
7397
|
-
const MAX_DEPTH = 100;
|
|
7398
|
-
let iterations = 0;
|
|
7399
|
-
while (current && iterations < MAX_DEPTH) {
|
|
7400
|
-
chain.unshift(getAddress(current).toLowerCase());
|
|
7401
|
-
const info = await contract.libraryByDAO(current);
|
|
7402
|
-
const parent = info.forkedFromDAO;
|
|
7403
|
-
if (!parent || parent === ZERO_ADDRESS) {
|
|
7404
|
-
break;
|
|
7405
|
-
}
|
|
7406
|
-
current = parent;
|
|
7407
|
-
iterations++;
|
|
7408
|
-
}
|
|
7472
|
+
const addr = getAddress(normalise(subdao, "subdao")).toLowerCase();
|
|
7409
7473
|
return {
|
|
7410
|
-
chain,
|
|
7411
|
-
depth:
|
|
7412
|
-
root:
|
|
7474
|
+
chain: [addr],
|
|
7475
|
+
depth: 0,
|
|
7476
|
+
root: addr
|
|
7413
7477
|
};
|
|
7414
7478
|
} catch (err) {
|
|
7415
7479
|
throw new SageSDKError(CODES.CONTRACT_ERROR, "Failed to fetch lineage chain", { cause: err });
|
|
@@ -7420,16 +7484,7 @@ var require_lineage = __commonJS({
|
|
|
7420
7484
|
return parent !== null;
|
|
7421
7485
|
}
|
|
7422
7486
|
async function getLibraryForkFee({ provider, registry, subdao }) {
|
|
7423
|
-
|
|
7424
|
-
if (!registry) throw new SageSDKError(CODES.INVALID_ARGS, "registry required");
|
|
7425
|
-
if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
|
|
7426
|
-
try {
|
|
7427
|
-
const contract = new Contract(normalise(registry, "registry"), LINEAGE_ABI, provider);
|
|
7428
|
-
const fee = await contract.getLibraryForkFee(normalise(subdao, "subdao"));
|
|
7429
|
-
return BigInt(fee.toString());
|
|
7430
|
-
} catch (err) {
|
|
7431
|
-
throw new SageSDKError(CODES.CONTRACT_ERROR, "Failed to fetch library fork fee", { cause: err });
|
|
7432
|
-
}
|
|
7487
|
+
return 0n;
|
|
7433
7488
|
}
|
|
7434
7489
|
async function getLibraryInfo({ provider, registry, subdao }) {
|
|
7435
7490
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
@@ -7438,10 +7493,11 @@ var require_lineage = __commonJS({
|
|
|
7438
7493
|
try {
|
|
7439
7494
|
const contract = new Contract(normalise(registry, "registry"), LINEAGE_ABI, provider);
|
|
7440
7495
|
const info = await contract.libraryByDAO(normalise(subdao, "subdao"));
|
|
7441
|
-
const parent = info.forkedFromDAO;
|
|
7442
7496
|
return {
|
|
7443
|
-
parentDAO:
|
|
7444
|
-
|
|
7497
|
+
parentDAO: null,
|
|
7498
|
+
// Fork lineage removed from on-chain struct
|
|
7499
|
+
forkFee: 0n,
|
|
7500
|
+
// Fork fees removed from on-chain struct
|
|
7445
7501
|
manifestCID: info.manifestCID,
|
|
7446
7502
|
version: info.version
|
|
7447
7503
|
};
|
|
@@ -8637,12 +8693,6 @@ var require_personal = __commonJS({
|
|
|
8637
8693
|
var { Interface } = __require("ethers");
|
|
8638
8694
|
var ABI = require_abi();
|
|
8639
8695
|
var { normaliseAddress, toBytes32Key } = require_helpers();
|
|
8640
|
-
function buildCreatePersonalRegistryTx({ factory, policy }) {
|
|
8641
|
-
const to = normaliseAddress(factory, "factory");
|
|
8642
|
-
const iface = new Interface(ABI.PersonalLibraryFacet);
|
|
8643
|
-
const data = iface.encodeFunctionData("createPersonalRegistry", [policy >>> 0]);
|
|
8644
|
-
return { to, data, value: 0n };
|
|
8645
|
-
}
|
|
8646
8696
|
function buildSetPriceTx({ marketplace, key, price }) {
|
|
8647
8697
|
const to = normaliseAddress(marketplace, "marketplace");
|
|
8648
8698
|
const k = toBytes32Key(key);
|
|
@@ -8662,7 +8712,6 @@ var require_personal = __commonJS({
|
|
|
8662
8712
|
return { to, data, value: 0n };
|
|
8663
8713
|
}
|
|
8664
8714
|
module2.exports = {
|
|
8665
|
-
buildCreatePersonalRegistryTx,
|
|
8666
8715
|
buildSetPriceTx,
|
|
8667
8716
|
buildBuyTx,
|
|
8668
8717
|
...require_receipt(),
|
|
@@ -8671,300 +8720,6 @@ var require_personal = __commonJS({
|
|
|
8671
8720
|
}
|
|
8672
8721
|
});
|
|
8673
8722
|
|
|
8674
|
-
// src/premium/index.js
|
|
8675
|
-
var require_premium = __commonJS({
|
|
8676
|
-
"src/premium/index.js"(exports2, module2) {
|
|
8677
|
-
var axios = __require("axios");
|
|
8678
|
-
var { getAddress } = __require("ethers");
|
|
8679
|
-
function safeGetAddress(value) {
|
|
8680
|
-
try {
|
|
8681
|
-
return getAddress(value);
|
|
8682
|
-
} catch {
|
|
8683
|
-
return null;
|
|
8684
|
-
}
|
|
8685
|
-
}
|
|
8686
|
-
function mapSafe(list, mapper) {
|
|
8687
|
-
const out = [];
|
|
8688
|
-
for (const item of list || []) {
|
|
8689
|
-
try {
|
|
8690
|
-
const v = mapper(item);
|
|
8691
|
-
if (v != null) out.push(v);
|
|
8692
|
-
} catch {
|
|
8693
|
-
}
|
|
8694
|
-
}
|
|
8695
|
-
return out;
|
|
8696
|
-
}
|
|
8697
|
-
async function query(url, document, variables) {
|
|
8698
|
-
if (!url) throw new Error("subgraph url required");
|
|
8699
|
-
const resp = await axios.post(url, { query: document, variables }, { timeout: 1e4 });
|
|
8700
|
-
if (resp.data && resp.data.errors) {
|
|
8701
|
-
throw new Error(resp.data.errors.map((e) => e.message).join("; "));
|
|
8702
|
-
}
|
|
8703
|
-
return resp.data.data;
|
|
8704
|
-
}
|
|
8705
|
-
async function listPremiumPrompts({ url, subdao = null, first = 50, skip = 0, orderBy = "blockTimestamp", orderDirection = "desc" }) {
|
|
8706
|
-
const safeOrderBy = ["blockTimestamp", "price"].includes(orderBy) ? orderBy : "blockTimestamp";
|
|
8707
|
-
const safeOrderDirection = orderDirection === "asc" ? "asc" : "desc";
|
|
8708
|
-
let doc;
|
|
8709
|
-
const variables = {
|
|
8710
|
-
first: Math.min(Math.max(1, Number(first || 50)), 200),
|
|
8711
|
-
skip: Number(skip || 0)
|
|
8712
|
-
};
|
|
8713
|
-
if (subdao) {
|
|
8714
|
-
const addr = safeGetAddress(subdao);
|
|
8715
|
-
if (!addr) throw new Error("invalid subdao address");
|
|
8716
|
-
variables.subdao = addr.toLowerCase();
|
|
8717
|
-
doc = `
|
|
8718
|
-
query($subdao: Bytes!, $first: Int!, $skip: Int!) {
|
|
8719
|
-
premiumPrompts(
|
|
8720
|
-
where: { subdao: $subdao }
|
|
8721
|
-
first: $first
|
|
8722
|
-
skip: $skip
|
|
8723
|
-
orderBy: ${safeOrderBy}
|
|
8724
|
-
orderDirection: ${safeOrderDirection}
|
|
8725
|
-
) {
|
|
8726
|
-
id
|
|
8727
|
-
cidHash
|
|
8728
|
-
subdao
|
|
8729
|
-
price
|
|
8730
|
-
manifestCID
|
|
8731
|
-
blockNumber
|
|
8732
|
-
blockTimestamp
|
|
8733
|
-
transactionHash
|
|
8734
|
-
}
|
|
8735
|
-
}
|
|
8736
|
-
`;
|
|
8737
|
-
} else {
|
|
8738
|
-
doc = `
|
|
8739
|
-
query($first: Int!, $skip: Int!) {
|
|
8740
|
-
premiumPrompts(
|
|
8741
|
-
first: $first
|
|
8742
|
-
skip: $skip
|
|
8743
|
-
orderBy: ${safeOrderBy}
|
|
8744
|
-
orderDirection: ${safeOrderDirection}
|
|
8745
|
-
) {
|
|
8746
|
-
id
|
|
8747
|
-
cidHash
|
|
8748
|
-
subdao
|
|
8749
|
-
price
|
|
8750
|
-
manifestCID
|
|
8751
|
-
blockNumber
|
|
8752
|
-
blockTimestamp
|
|
8753
|
-
transactionHash
|
|
8754
|
-
}
|
|
8755
|
-
}
|
|
8756
|
-
`;
|
|
8757
|
-
}
|
|
8758
|
-
const data = await query(url, doc, variables);
|
|
8759
|
-
return mapSafe(data?.premiumPrompts, (p) => {
|
|
8760
|
-
const sub = safeGetAddress(p.subdao);
|
|
8761
|
-
if (!sub) return null;
|
|
8762
|
-
return {
|
|
8763
|
-
id: String(p.id),
|
|
8764
|
-
cidHash: String(p.cidHash),
|
|
8765
|
-
subdao: sub,
|
|
8766
|
-
price: BigInt(String(p.price || "0")),
|
|
8767
|
-
manifestCID: p.manifestCID || null,
|
|
8768
|
-
blockNumber: Number(p.blockNumber || 0),
|
|
8769
|
-
blockTimestamp: Number(p.blockTimestamp || 0),
|
|
8770
|
-
transactionHash: p.transactionHash || null
|
|
8771
|
-
};
|
|
8772
|
-
});
|
|
8773
|
-
}
|
|
8774
|
-
async function getPremiumPrompt({ url, cidHash }) {
|
|
8775
|
-
const id2 = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
|
|
8776
|
-
const doc = `
|
|
8777
|
-
query($id: ID!) {
|
|
8778
|
-
premiumPrompt(id: $id) {
|
|
8779
|
-
id
|
|
8780
|
-
cidHash
|
|
8781
|
-
subdao
|
|
8782
|
-
price
|
|
8783
|
-
manifestCID
|
|
8784
|
-
blockNumber
|
|
8785
|
-
blockTimestamp
|
|
8786
|
-
transactionHash
|
|
8787
|
-
}
|
|
8788
|
-
premiumPromptStats(id: $id) {
|
|
8789
|
-
totalRevenue
|
|
8790
|
-
purchaseCount
|
|
8791
|
-
uniqueBuyers
|
|
8792
|
-
currentHolders
|
|
8793
|
-
}
|
|
8794
|
-
}
|
|
8795
|
-
`;
|
|
8796
|
-
const data = await query(url, doc, { id: id2 });
|
|
8797
|
-
const p = data?.premiumPrompt;
|
|
8798
|
-
if (!p) return null;
|
|
8799
|
-
const sub = safeGetAddress(p.subdao);
|
|
8800
|
-
if (!sub) return null;
|
|
8801
|
-
const stats = data?.premiumPromptStats || {};
|
|
8802
|
-
return {
|
|
8803
|
-
id: String(p.id),
|
|
8804
|
-
cidHash: String(p.cidHash),
|
|
8805
|
-
subdao: sub,
|
|
8806
|
-
price: BigInt(String(p.price || "0")),
|
|
8807
|
-
manifestCID: p.manifestCID || null,
|
|
8808
|
-
blockNumber: Number(p.blockNumber || 0),
|
|
8809
|
-
blockTimestamp: Number(p.blockTimestamp || 0),
|
|
8810
|
-
transactionHash: p.transactionHash || null,
|
|
8811
|
-
// Stats
|
|
8812
|
-
totalRevenue: stats.totalRevenue ? BigInt(String(stats.totalRevenue)) : null,
|
|
8813
|
-
purchaseCount: stats.purchaseCount ? BigInt(String(stats.purchaseCount)) : null,
|
|
8814
|
-
uniqueBuyers: stats.uniqueBuyers ? BigInt(String(stats.uniqueBuyers)) : null,
|
|
8815
|
-
currentHolders: stats.currentHolders ? BigInt(String(stats.currentHolders)) : null
|
|
8816
|
-
};
|
|
8817
|
-
}
|
|
8818
|
-
async function listPremiumPurchases({ url, cidHash, first = 50, skip = 0 }) {
|
|
8819
|
-
const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
|
|
8820
|
-
const doc = `
|
|
8821
|
-
query($cidHash: Bytes!, $first: Int!, $skip: Int!) {
|
|
8822
|
-
premiumPurchases(
|
|
8823
|
-
where: { cidHash: $cidHash }
|
|
8824
|
-
first: $first
|
|
8825
|
-
skip: $skip
|
|
8826
|
-
orderBy: blockTimestamp
|
|
8827
|
-
orderDirection: desc
|
|
8828
|
-
) {
|
|
8829
|
-
id
|
|
8830
|
-
cidHash
|
|
8831
|
-
buyer
|
|
8832
|
-
price
|
|
8833
|
-
treasury
|
|
8834
|
-
blockNumber
|
|
8835
|
-
blockTimestamp
|
|
8836
|
-
transactionHash
|
|
8837
|
-
}
|
|
8838
|
-
}
|
|
8839
|
-
`;
|
|
8840
|
-
const data = await query(url, doc, {
|
|
8841
|
-
cidHash: normalizedCidHash,
|
|
8842
|
-
first: Math.min(Math.max(1, Number(first || 50)), 200),
|
|
8843
|
-
skip: Number(skip || 0)
|
|
8844
|
-
});
|
|
8845
|
-
return mapSafe(data?.premiumPurchases, (p) => {
|
|
8846
|
-
const buyer = safeGetAddress(p.buyer);
|
|
8847
|
-
const treasury = safeGetAddress(p.treasury);
|
|
8848
|
-
if (!buyer || !treasury) return null;
|
|
8849
|
-
return {
|
|
8850
|
-
id: String(p.id),
|
|
8851
|
-
cidHash: String(p.cidHash),
|
|
8852
|
-
buyer,
|
|
8853
|
-
price: BigInt(String(p.price || "0")),
|
|
8854
|
-
treasury,
|
|
8855
|
-
blockNumber: Number(p.blockNumber || 0),
|
|
8856
|
-
blockTimestamp: Number(p.blockTimestamp || 0),
|
|
8857
|
-
transactionHash: p.transactionHash || null
|
|
8858
|
-
};
|
|
8859
|
-
});
|
|
8860
|
-
}
|
|
8861
|
-
async function hasPurchased({ url, cidHash, holder }) {
|
|
8862
|
-
const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
|
|
8863
|
-
const normalizedHolder = holder.toLowerCase();
|
|
8864
|
-
const id2 = `${normalizedCidHash}-${normalizedHolder}`;
|
|
8865
|
-
const doc = `
|
|
8866
|
-
query($id: ID!) {
|
|
8867
|
-
premiumHolderBalance(id: $id) {
|
|
8868
|
-
balance
|
|
8869
|
-
}
|
|
8870
|
-
}
|
|
8871
|
-
`;
|
|
8872
|
-
const data = await query(url, doc, { id: id2 });
|
|
8873
|
-
const balance = data?.premiumHolderBalance?.balance;
|
|
8874
|
-
return balance ? BigInt(String(balance)) > 0n : false;
|
|
8875
|
-
}
|
|
8876
|
-
async function getHolderBalance({ url, cidHash, holder }) {
|
|
8877
|
-
const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
|
|
8878
|
-
const normalizedHolder = holder.toLowerCase();
|
|
8879
|
-
const id2 = `${normalizedCidHash}-${normalizedHolder}`;
|
|
8880
|
-
const doc = `
|
|
8881
|
-
query($id: ID!) {
|
|
8882
|
-
premiumHolderBalance(id: $id) {
|
|
8883
|
-
balance
|
|
8884
|
-
updatedAt
|
|
8885
|
-
}
|
|
8886
|
-
}
|
|
8887
|
-
`;
|
|
8888
|
-
const data = await query(url, doc, { id: id2 });
|
|
8889
|
-
const row = data?.premiumHolderBalance;
|
|
8890
|
-
if (!row) return 0n;
|
|
8891
|
-
return BigInt(String(row.balance || "0"));
|
|
8892
|
-
}
|
|
8893
|
-
async function listHolders({ url, cidHash, first = 100, skip = 0 }) {
|
|
8894
|
-
const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
|
|
8895
|
-
const doc = `
|
|
8896
|
-
query($cidHash: Bytes!, $first: Int!, $skip: Int!) {
|
|
8897
|
-
premiumHolderBalances(
|
|
8898
|
-
where: { cidHash: $cidHash, balance_gt: "0" }
|
|
8899
|
-
first: $first
|
|
8900
|
-
skip: $skip
|
|
8901
|
-
orderBy: balance
|
|
8902
|
-
orderDirection: desc
|
|
8903
|
-
) {
|
|
8904
|
-
id
|
|
8905
|
-
cidHash
|
|
8906
|
-
holder
|
|
8907
|
-
balance
|
|
8908
|
-
updatedAt
|
|
8909
|
-
}
|
|
8910
|
-
}
|
|
8911
|
-
`;
|
|
8912
|
-
const data = await query(url, doc, {
|
|
8913
|
-
cidHash: normalizedCidHash,
|
|
8914
|
-
first: Math.min(Math.max(1, Number(first || 100)), 500),
|
|
8915
|
-
skip: Number(skip || 0)
|
|
8916
|
-
});
|
|
8917
|
-
return mapSafe(data?.premiumHolderBalances, (h) => {
|
|
8918
|
-
const holder = safeGetAddress(h.holder);
|
|
8919
|
-
if (!holder) return null;
|
|
8920
|
-
return {
|
|
8921
|
-
id: String(h.id),
|
|
8922
|
-
cidHash: String(h.cidHash),
|
|
8923
|
-
holder,
|
|
8924
|
-
balance: BigInt(String(h.balance || "0")),
|
|
8925
|
-
updatedAt: Number(h.updatedAt || 0)
|
|
8926
|
-
};
|
|
8927
|
-
});
|
|
8928
|
-
}
|
|
8929
|
-
async function getRevSplit({ url, subdao }) {
|
|
8930
|
-
const addr = safeGetAddress(subdao);
|
|
8931
|
-
if (!addr) throw new Error("invalid subdao address");
|
|
8932
|
-
const doc = `
|
|
8933
|
-
query($id: ID!) {
|
|
8934
|
-
premiumRevSplit(id: $id) {
|
|
8935
|
-
id
|
|
8936
|
-
subdao
|
|
8937
|
-
treasuryBps
|
|
8938
|
-
protocolBps
|
|
8939
|
-
creatorBps
|
|
8940
|
-
updatedAt
|
|
8941
|
-
}
|
|
8942
|
-
}
|
|
8943
|
-
`;
|
|
8944
|
-
const data = await query(url, doc, { id: addr.toLowerCase() });
|
|
8945
|
-
const split = data?.premiumRevSplit;
|
|
8946
|
-
if (!split) return null;
|
|
8947
|
-
return {
|
|
8948
|
-
id: String(split.id),
|
|
8949
|
-
subdao: safeGetAddress(split.subdao) || addr,
|
|
8950
|
-
treasuryBps: Number(split.treasuryBps || 0),
|
|
8951
|
-
protocolBps: Number(split.protocolBps || 0),
|
|
8952
|
-
creatorBps: Number(split.creatorBps || 0),
|
|
8953
|
-
updatedAt: Number(split.updatedAt || 0)
|
|
8954
|
-
};
|
|
8955
|
-
}
|
|
8956
|
-
module2.exports = {
|
|
8957
|
-
listPremiumPrompts,
|
|
8958
|
-
getPremiumPrompt,
|
|
8959
|
-
listPremiumPurchases,
|
|
8960
|
-
hasPurchased,
|
|
8961
|
-
getHolderBalance,
|
|
8962
|
-
listHolders,
|
|
8963
|
-
getRevSplit
|
|
8964
|
-
};
|
|
8965
|
-
}
|
|
8966
|
-
});
|
|
8967
|
-
|
|
8968
8723
|
// src/utils/privateTx.js
|
|
8969
8724
|
var require_privateTx = __commonJS({
|
|
8970
8725
|
"src/utils/privateTx.js"(exports2, module2) {
|
|
@@ -9484,7 +9239,7 @@ var require_boost = __commonJS({
|
|
|
9484
9239
|
const contract = new Contract(addr, ABI.GovernanceBoostMerkle, provider);
|
|
9485
9240
|
const result = await contract.getBoost(proposalId).catch(() => null);
|
|
9486
9241
|
if (!result) return null;
|
|
9487
|
-
const [totalPool, totalClaimed, merkleRoot, active, finalized, creator] = result;
|
|
9242
|
+
const [totalPool, totalClaimed, merkleRoot, expiresAt, active, finalized, creator] = result;
|
|
9488
9243
|
const creatorAddr = creator ? getAddress(creator) : ZERO_ADDRESS;
|
|
9489
9244
|
const pool = toBigInt(totalPool);
|
|
9490
9245
|
if (!active && !finalized && pool === 0n && creatorAddr === ZERO_ADDRESS) return null;
|
|
@@ -9494,6 +9249,7 @@ var require_boost = __commonJS({
|
|
|
9494
9249
|
totalPool: pool,
|
|
9495
9250
|
totalClaimed: toBigInt(totalClaimed),
|
|
9496
9251
|
merkleRoot,
|
|
9252
|
+
expiresAt: toBigInt(expiresAt),
|
|
9497
9253
|
active: Boolean(active),
|
|
9498
9254
|
finalized: Boolean(finalized),
|
|
9499
9255
|
creator: creatorAddr
|
|
@@ -10762,13 +10518,13 @@ var require_auction = __commonJS({
|
|
|
10762
10518
|
}
|
|
10763
10519
|
async function getConfig({ provider, auctionHouse }) {
|
|
10764
10520
|
const c = getAuctionContract(provider, auctionHouse);
|
|
10765
|
-
const [nft, treasury, weth, timeBuffer, reservePrice,
|
|
10521
|
+
const [nft, treasury, weth, timeBuffer, reservePrice, minBidIncrementBps, duration, mintTierId, defaultTokenURI, paused, owner] = await Promise.all([
|
|
10766
10522
|
c.nft(),
|
|
10767
10523
|
c.treasury(),
|
|
10768
10524
|
c.weth(),
|
|
10769
10525
|
c.timeBuffer(),
|
|
10770
10526
|
c.reservePrice(),
|
|
10771
|
-
c.
|
|
10527
|
+
c.minBidIncrementBps(),
|
|
10772
10528
|
c.duration(),
|
|
10773
10529
|
c.mintTierId(),
|
|
10774
10530
|
c.defaultTokenURI(),
|
|
@@ -10781,7 +10537,7 @@ var require_auction = __commonJS({
|
|
|
10781
10537
|
weth: getAddress(weth),
|
|
10782
10538
|
timeBuffer: BigInt(timeBuffer.toString()),
|
|
10783
10539
|
reservePrice: BigInt(reservePrice.toString()),
|
|
10784
|
-
|
|
10540
|
+
minBidIncrementBps: BigInt(minBidIncrementBps.toString()),
|
|
10785
10541
|
duration: BigInt(duration.toString()),
|
|
10786
10542
|
mintTierId: BigInt(mintTierId.toString()),
|
|
10787
10543
|
defaultTokenURI: String(defaultTokenURI),
|
|
@@ -10837,10 +10593,10 @@ var require_auction = __commonJS({
|
|
|
10837
10593
|
const data = iface.encodeFunctionData("setReservePrice", [toBigInt(reservePrice, "reservePrice")]);
|
|
10838
10594
|
return { to: addr, data, value: 0n };
|
|
10839
10595
|
}
|
|
10840
|
-
function buildSetMinBidIncrementTx({ auctionHouse,
|
|
10596
|
+
function buildSetMinBidIncrementTx({ auctionHouse, bps }) {
|
|
10841
10597
|
const addr = normaliseAddress(auctionHouse, "auctionHouse");
|
|
10842
10598
|
const iface = new Interface(ABI.SageAuctionHouse);
|
|
10843
|
-
const data = iface.encodeFunctionData("
|
|
10599
|
+
const data = iface.encodeFunctionData("setMinBidIncrementBps", [toBigInt(bps, "bps")]);
|
|
10844
10600
|
return { to: addr, data, value: 0n };
|
|
10845
10601
|
}
|
|
10846
10602
|
function buildSetDurationTx({ auctionHouse, duration }) {
|
|
@@ -11861,6 +11617,43 @@ ${error}` : ""}`;
|
|
|
11861
11617
|
signature: "createSubDAOFromTemplate(uint256,string,string)",
|
|
11862
11618
|
args: [templateId, `"${name}"`, `"${description}"`]
|
|
11863
11619
|
};
|
|
11620
|
+
} else if (data.startsWith(__require("ethers").id("createSubDAOWithParams(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256,uint8,uint8,string,string,string)").slice(0, 10))) {
|
|
11621
|
+
const { ethers: ethers2 } = __require("ethers");
|
|
11622
|
+
const iface = new ethers2.Interface(["function createSubDAOWithParams(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256,uint8,uint8,string,string,string)"]);
|
|
11623
|
+
const decoded = iface.decodeFunctionData("createSubDAOWithParams", data);
|
|
11624
|
+
const name = decoded[0];
|
|
11625
|
+
const description = decoded[1];
|
|
11626
|
+
const accessModel = decoded[2].toString();
|
|
11627
|
+
const minStakeAmount = decoded[3].toString();
|
|
11628
|
+
const burnAmount = decoded[4].toString();
|
|
11629
|
+
const votingDelay = decoded[5].toString();
|
|
11630
|
+
const votingPeriod = decoded[6].toString();
|
|
11631
|
+
const proposalThreshold = decoded[7].toString();
|
|
11632
|
+
const quorumVotes = decoded[8].toString();
|
|
11633
|
+
const initialForkPolicy = decoded[9].toString();
|
|
11634
|
+
const initialMembershipPolicy = decoded[10].toString();
|
|
11635
|
+
const profileCID = decoded[11];
|
|
11636
|
+
const manifestCID = decoded[12];
|
|
11637
|
+
const manifestVersion = decoded[13];
|
|
11638
|
+
return {
|
|
11639
|
+
signature: "createSubDAOWithParams(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256,uint8,uint8,string,string,string)",
|
|
11640
|
+
args: [
|
|
11641
|
+
`"${name}"`,
|
|
11642
|
+
`"${description}"`,
|
|
11643
|
+
accessModel,
|
|
11644
|
+
minStakeAmount,
|
|
11645
|
+
burnAmount,
|
|
11646
|
+
votingDelay,
|
|
11647
|
+
votingPeriod,
|
|
11648
|
+
proposalThreshold,
|
|
11649
|
+
quorumVotes,
|
|
11650
|
+
initialForkPolicy,
|
|
11651
|
+
initialMembershipPolicy,
|
|
11652
|
+
`"${profileCID}"`,
|
|
11653
|
+
`"${manifestCID}"`,
|
|
11654
|
+
`"${manifestVersion}"`
|
|
11655
|
+
]
|
|
11656
|
+
};
|
|
11864
11657
|
} else if (data.startsWith(__require("ethers").id("createSubDAO(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256)").slice(0, 10))) {
|
|
11865
11658
|
const { ethers: ethers2 } = __require("ethers");
|
|
11866
11659
|
const iface = new ethers2.Interface(["function createSubDAO(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256)"]);
|
|
@@ -12036,6 +11829,24 @@ ${error}` : ""}`;
|
|
|
12036
11829
|
} else if (data.startsWith(__require("ethers").id("authorizeBurner(address)").slice(0, 10))) {
|
|
12037
11830
|
const burner = this.extractAddressFromData(data, 0);
|
|
12038
11831
|
return { signature: "authorizeBurner(address)", args: [burner] };
|
|
11832
|
+
} else if (data.startsWith(__require("ethers").id("createBoost((address,uint256,uint256,uint256,uint8,address,uint96,uint8,uint8,uint256,uint256))").slice(0, 10))) {
|
|
11833
|
+
const { ethers: ethers2 } = __require("ethers");
|
|
11834
|
+
const sig = "createBoost((address,uint256,uint256,uint256,uint8,address,uint96,uint8,uint8,uint256,uint256))";
|
|
11835
|
+
const iface = new ethers2.Interface([`function ${sig}`]);
|
|
11836
|
+
const d = iface.decodeFunctionData("createBoost", data);
|
|
11837
|
+
const params = d?.[0] ?? d;
|
|
11838
|
+
const governor = String(params?.governor ?? params?.[0]);
|
|
11839
|
+
const proposalId = (params?.proposalId ?? params?.[1])?.toString();
|
|
11840
|
+
const perVoter = (params?.perVoter ?? params?.[2])?.toString();
|
|
11841
|
+
const maxVoters = (params?.maxVoters ?? params?.[3])?.toString();
|
|
11842
|
+
const kind = (params?.kind ?? params?.[4])?.toString();
|
|
11843
|
+
const policy = String(params?.policy ?? params?.[5]);
|
|
11844
|
+
const minVotes = (params?.minVotes ?? params?.[6])?.toString();
|
|
11845
|
+
const payoutMode = (params?.payoutMode ?? params?.[7])?.toString();
|
|
11846
|
+
const support = (params?.support ?? params?.[8])?.toString();
|
|
11847
|
+
const startAt = (params?.startAt ?? params?.[9])?.toString();
|
|
11848
|
+
const expiresAt = (params?.expiresAt ?? params?.[10])?.toString();
|
|
11849
|
+
return { signature: sig, args: [governor, proposalId, perVoter, maxVoters, kind, policy, minVotes, payoutMode, support, startAt, expiresAt] };
|
|
12039
11850
|
} else if (data.startsWith(__require("ethers").id("createBoost(address,uint256,uint256,uint256,uint8,address,uint96,uint8,uint8,uint256,uint256)").slice(0, 10))) {
|
|
12040
11851
|
const { ethers: ethers2 } = __require("ethers");
|
|
12041
11852
|
const sig = "createBoost(address,uint256,uint256,uint256,uint8,address,uint96,uint8,uint8,uint256,uint256)";
|
|
@@ -12106,25 +11917,6 @@ ${error}` : ""}`;
|
|
|
12106
11917
|
const d = iface.decodeFunctionData("forkPromptWithStable", data);
|
|
12107
11918
|
const args = [`"${String(d[0])}"`, `"${String(d[1])}"`, `"${String(d[2])}"`, `"${String(d[3])}"`, "[permit]"];
|
|
12108
11919
|
return { signature: sig, args };
|
|
12109
|
-
} else if (data.startsWith(__require("ethers").id("createPremiumPrompt(bytes32,address,uint256)").slice(0, 10))) {
|
|
12110
|
-
const { ethers: ethers2 } = __require("ethers");
|
|
12111
|
-
const sig = "createPremiumPrompt(bytes32,address,uint256)";
|
|
12112
|
-
const iface = new ethers2.Interface([`function ${sig}`]);
|
|
12113
|
-
const d = iface.decodeFunctionData("createPremiumPrompt", data);
|
|
12114
|
-
const hash = d[0];
|
|
12115
|
-
const subdao = d[1];
|
|
12116
|
-
const price = d[2].toString();
|
|
12117
|
-
return { signature: sig, args: [hash, subdao, price] };
|
|
12118
|
-
} else if (data.startsWith(__require("ethers").id("createPremiumPromptWithManifest(bytes32,address,uint256,string)").slice(0, 10))) {
|
|
12119
|
-
const { ethers: ethers2 } = __require("ethers");
|
|
12120
|
-
const sig = "createPremiumPromptWithManifest(bytes32,address,uint256,string)";
|
|
12121
|
-
const iface = new ethers2.Interface([`function ${sig}`]);
|
|
12122
|
-
const d = iface.decodeFunctionData("createPremiumPromptWithManifest", data);
|
|
12123
|
-
const hash = d[0];
|
|
12124
|
-
const subdao = d[1];
|
|
12125
|
-
const price = d[2].toString();
|
|
12126
|
-
const manifest = d[3];
|
|
12127
|
-
return { signature: sig, args: [hash, subdao, price, `"${manifest}"`] };
|
|
12128
11920
|
} else if (data.startsWith(__require("ethers").id("claim(uint256,address,uint256,bytes32[])").slice(0, 10))) {
|
|
12129
11921
|
const { ethers: ethers2 } = __require("ethers");
|
|
12130
11922
|
const sig = "claim(uint256,address,uint256,bytes32[])";
|
|
@@ -12136,18 +11928,6 @@ ${error}` : ""}`;
|
|
|
12136
11928
|
const proofArray = (d[3] || []).map((x) => String(x));
|
|
12137
11929
|
const formattedProof = `[${proofArray.join(",")}]`;
|
|
12138
11930
|
return { signature: sig, args: [proposalId, account, amount, formattedProof] };
|
|
12139
|
-
} else if (data.startsWith(__require("ethers").id("purchaseAccess(bytes32)").slice(0, 10))) {
|
|
12140
|
-
const { ethers: ethers2 } = __require("ethers");
|
|
12141
|
-
const iface = new ethers2.Interface(["function purchaseAccess(bytes32)"]);
|
|
12142
|
-
const d = iface.decodeFunctionData("purchaseAccess", data);
|
|
12143
|
-
return { signature: "purchaseAccess(bytes32)", args: [d[0]] };
|
|
12144
|
-
} else if (data.startsWith(__require("ethers").id("setProtocolRake(uint96,address)").slice(0, 10))) {
|
|
12145
|
-
const { ethers: ethers2 } = __require("ethers");
|
|
12146
|
-
const iface = new ethers2.Interface(["function setProtocolRake(uint96,address)"]);
|
|
12147
|
-
const decoded = iface.decodeFunctionData("setProtocolRake", data);
|
|
12148
|
-
const bps = decoded[0].toString();
|
|
12149
|
-
const treas = decoded[1];
|
|
12150
|
-
return { signature: "setProtocolRake(uint96,address)", args: [bps, treas] };
|
|
12151
11931
|
} else if (data.startsWith(__require("ethers").id("revokeBurner(address)").slice(0, 10))) {
|
|
12152
11932
|
const burner = this.extractAddressFromData(data, 0);
|
|
12153
11933
|
return { signature: "revokeBurner(address)", args: [burner] };
|
|
@@ -12597,276 +12377,6 @@ var require_typed = __commonJS({
|
|
|
12597
12377
|
}
|
|
12598
12378
|
});
|
|
12599
12379
|
|
|
12600
|
-
// src/doppler/index.js
|
|
12601
|
-
var require_doppler = __commonJS({
|
|
12602
|
-
"src/doppler/index.js"(exports2, module2) {
|
|
12603
|
-
var { createPublicClient, createWalletClient, http } = __require("viem");
|
|
12604
|
-
var { privateKeyToAccount } = __require("viem/accounts");
|
|
12605
|
-
var { erc20Abi } = __require("viem");
|
|
12606
|
-
var { base, baseSepolia } = __require("viem/chains");
|
|
12607
|
-
var dopplerLib = __require("@whetstone-research/doppler-sdk");
|
|
12608
|
-
function getChainById(chainId) {
|
|
12609
|
-
if (Number(chainId) === baseSepolia.id) return baseSepolia;
|
|
12610
|
-
if (Number(chainId) === base.id) return base;
|
|
12611
|
-
return { id: Number(chainId), name: `chain-${chainId}` };
|
|
12612
|
-
}
|
|
12613
|
-
function initDoppler(opts) {
|
|
12614
|
-
const chain = getChainById(opts.chainId);
|
|
12615
|
-
const publicClient = createPublicClient({ chain, transport: http(opts.rpcUrl) });
|
|
12616
|
-
let walletClient;
|
|
12617
|
-
if (opts.privateKey) {
|
|
12618
|
-
const pk = opts.privateKey.startsWith("0x") ? opts.privateKey : `0x${opts.privateKey}`;
|
|
12619
|
-
const account = privateKeyToAccount(pk);
|
|
12620
|
-
walletClient = createWalletClient({ chain, transport: http(opts.rpcUrl), account });
|
|
12621
|
-
} else if (opts.account) {
|
|
12622
|
-
walletClient = createWalletClient({ chain, transport: http(opts.rpcUrl), account: opts.account });
|
|
12623
|
-
}
|
|
12624
|
-
const DopplerSDK = dopplerLib.DopplerSDK || dopplerLib.default?.DopplerSDK || dopplerLib;
|
|
12625
|
-
const sdk = new DopplerSDK({ publicClient, walletClient, chainId: chain.id });
|
|
12626
|
-
return sdk;
|
|
12627
|
-
}
|
|
12628
|
-
async function deployDynamicAuction(sdk, user, p) {
|
|
12629
|
-
const DynamicAuctionBuilder = dopplerLib.DynamicAuctionBuilder || dopplerLib.default?.DynamicAuctionBuilder;
|
|
12630
|
-
if (!DynamicAuctionBuilder) throw new Error("DynamicAuctionBuilder missing from doppler-sdk");
|
|
12631
|
-
const builder = new DynamicAuctionBuilder().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 }).poolConfig({ fee: p.pool.fee, tickSpacing: p.pool.tickSpacing }).withUserAddress(user);
|
|
12632
|
-
if (p.auction && p.auction.startPrice && p.auction.endPrice && typeof builder.auctionByPriceRange === "function") {
|
|
12633
|
-
builder.auctionByPriceRange({
|
|
12634
|
-
priceRange: { startPrice: p.auction.startPrice, endPrice: p.auction.endPrice },
|
|
12635
|
-
minProceeds: p.auction.minProceeds || 0n,
|
|
12636
|
-
maxProceeds: p.auction.maxProceeds || 0n,
|
|
12637
|
-
durationDays: p.auction.durationDays,
|
|
12638
|
-
epochLength: p.auction.epochLength,
|
|
12639
|
-
numPdSlugs: p.auction.numPdSlugs || 5
|
|
12640
|
-
});
|
|
12641
|
-
} else if (typeof builder.auctionByTicks === "function") {
|
|
12642
|
-
throw new Error("auctionByPriceRange not supported by current doppler-sdk version; please provide tick params instead");
|
|
12643
|
-
} else {
|
|
12644
|
-
throw new Error("No supported auction configuration method on doppler-sdk builder");
|
|
12645
|
-
}
|
|
12646
|
-
builder.withMigration({
|
|
12647
|
-
type: p.migration.type || "uniswapV4",
|
|
12648
|
-
fee: p.migration.fee,
|
|
12649
|
-
tickSpacing: p.migration.tickSpacing,
|
|
12650
|
-
lpRecipient: p.migration.lpRecipient
|
|
12651
|
-
});
|
|
12652
|
-
if (p.governance && typeof builder.withGovernance === "function") {
|
|
12653
|
-
builder.withGovernance(p.governance);
|
|
12654
|
-
}
|
|
12655
|
-
if (p.overrides?.airlock && typeof builder.withAirlock === "function") builder.withAirlock(p.overrides.airlock);
|
|
12656
|
-
if (p.overrides?.dopplerDeployer && typeof builder.withDopplerDeployer === "function") builder.withDopplerDeployer(p.overrides.dopplerDeployer);
|
|
12657
|
-
if (p.overrides?.governanceFactory && typeof builder.withGovernanceFactory === "function") builder.withGovernanceFactory(p.overrides.governanceFactory);
|
|
12658
|
-
if (p.overrides?.v4Initializer && typeof builder.withV4Initializer === "function") builder.withV4Initializer(p.overrides.v4Initializer);
|
|
12659
|
-
const params = builder.build();
|
|
12660
|
-
const result = await sdk.factory.createDynamicAuction(params);
|
|
12661
|
-
return result;
|
|
12662
|
-
}
|
|
12663
|
-
async function getAuctionStatus(sdk, auctionAddress) {
|
|
12664
|
-
const lens = sdk.lens;
|
|
12665
|
-
if (lens && typeof lens.getAuctionStatus === "function") {
|
|
12666
|
-
return await lens.getAuctionStatus({ auctionAddress });
|
|
12667
|
-
}
|
|
12668
|
-
return { auctionAddress, note: "Lens API not available in this doppler-sdk version" };
|
|
12669
|
-
}
|
|
12670
|
-
async function listAuctions(sdk, { limit = 10, cursor } = {}) {
|
|
12671
|
-
const lens = sdk.lens;
|
|
12672
|
-
if (lens) {
|
|
12673
|
-
if (typeof lens.listAuctions === "function") {
|
|
12674
|
-
try {
|
|
12675
|
-
return await lens.listAuctions({ limit, cursor });
|
|
12676
|
-
} catch (e) {
|
|
12677
|
-
}
|
|
12678
|
-
}
|
|
12679
|
-
if (typeof lens.getAuctions === "function") {
|
|
12680
|
-
try {
|
|
12681
|
-
return await lens.getAuctions({ limit, cursor });
|
|
12682
|
-
} catch (e) {
|
|
12683
|
-
}
|
|
12684
|
-
}
|
|
12685
|
-
}
|
|
12686
|
-
const fac = sdk.factory;
|
|
12687
|
-
if (fac && typeof fac.listAuctions === "function") {
|
|
12688
|
-
try {
|
|
12689
|
-
return await fac.listAuctions({ limit, cursor });
|
|
12690
|
-
} catch (e) {
|
|
12691
|
-
}
|
|
12692
|
-
}
|
|
12693
|
-
return { ok: false, error: "LIST_UNSUPPORTED", message: "Listing auctions not supported by this doppler-sdk version" };
|
|
12694
|
-
}
|
|
12695
|
-
async function buyTokens(sdk, { auctionAddress, numeraireAmount }) {
|
|
12696
|
-
const trade = sdk.trade || sdk.swap || sdk.auction;
|
|
12697
|
-
if (trade && typeof trade.buy === "function") {
|
|
12698
|
-
try {
|
|
12699
|
-
return await trade.buy({ auctionAddress, numeraireAmount });
|
|
12700
|
-
} catch (e) {
|
|
12701
|
-
}
|
|
12702
|
-
}
|
|
12703
|
-
return { ok: false, error: "BUY_UNSUPPORTED", message: "Buy not supported by this doppler-sdk version. Use executeV3BuyExactIn/urExecute helpers or upgrade doppler-sdk." };
|
|
12704
|
-
}
|
|
12705
|
-
async function migrate(sdk, asset) {
|
|
12706
|
-
if (sdk.airlock && typeof sdk.airlock.migrate === "function") {
|
|
12707
|
-
return await sdk.airlock.migrate({ asset });
|
|
12708
|
-
}
|
|
12709
|
-
throw new Error("Migrate is not supported by the current doppler-sdk version");
|
|
12710
|
-
}
|
|
12711
|
-
module2.exports = {
|
|
12712
|
-
initDoppler,
|
|
12713
|
-
deployDynamicAuction,
|
|
12714
|
-
getAuctionStatus,
|
|
12715
|
-
listAuctions,
|
|
12716
|
-
buyTokens,
|
|
12717
|
-
migrate
|
|
12718
|
-
};
|
|
12719
|
-
module2.exports.deployStaticAuction = async function deployStaticAuction(sdk, user, p) {
|
|
12720
|
-
const StaticAuctionBuilder = dopplerLib.StaticAuctionBuilder || dopplerLib.default?.StaticAuctionBuilder;
|
|
12721
|
-
if (!StaticAuctionBuilder) throw new Error("StaticAuctionBuilder missing from doppler-sdk");
|
|
12722
|
-
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);
|
|
12723
|
-
if (p.governance?.noOp) builder.withGovernance({ noOp: true });
|
|
12724
|
-
if (p.migration) builder.withMigration(p.migration);
|
|
12725
|
-
if (p.modules?.airlock && typeof builder.withAirlock === "function") builder.withAirlock(p.modules.airlock);
|
|
12726
|
-
if (p.modules?.v3Initializer && typeof builder.withV3Initializer === "function") builder.withV3Initializer(p.modules.v3Initializer);
|
|
12727
|
-
const params = builder.build();
|
|
12728
|
-
const res = await sdk.factory.createStaticAuction(params);
|
|
12729
|
-
return res;
|
|
12730
|
-
};
|
|
12731
|
-
module2.exports.getStaticPoolInfo = async function getStaticPoolInfo(sdk, poolAddress) {
|
|
12732
|
-
const auction = await sdk.getStaticAuction(poolAddress);
|
|
12733
|
-
return auction.getPoolInfo();
|
|
12734
|
-
};
|
|
12735
|
-
module2.exports.quoteV3ExactIn = async function quoteV3ExactIn(sdk, { tokenIn, tokenOut, amountIn, fee, sqrtPriceLimitX96 = 0n }) {
|
|
12736
|
-
return sdk.quoter.quoteExactInputV3({ tokenIn, tokenOut, amountIn, fee, sqrtPriceLimitX96 });
|
|
12737
|
-
};
|
|
12738
|
-
var WETH_ABI = [
|
|
12739
|
-
{ type: "function", name: "deposit", stateMutability: "payable", inputs: [], outputs: [] },
|
|
12740
|
-
{ type: "function", name: "withdraw", stateMutability: "nonpayable", inputs: [{ name: "wad", type: "uint256" }], outputs: [] },
|
|
12741
|
-
{ type: "function", name: "balanceOf", stateMutability: "view", inputs: [{ name: "a", type: "address" }], outputs: [{ type: "uint256" }] }
|
|
12742
|
-
];
|
|
12743
|
-
module2.exports.wrapEthToWethIfNeeded = async function wrapEthToWethIfNeeded({ rpcUrl, chainId, privateKey, weth, owner, minAmount }) {
|
|
12744
|
-
const chain = getChainById(chainId);
|
|
12745
|
-
const accountObj = privateKeyToAccount(privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`);
|
|
12746
|
-
const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
|
|
12747
|
-
const walletClient = createWalletClient({ chain, transport: http(rpcUrl), account: accountObj });
|
|
12748
|
-
const bal = await publicClient.readContract({ address: weth, abi: WETH_ABI, functionName: "balanceOf", args: [owner] });
|
|
12749
|
-
if (bal >= minAmount) return { deposited: 0n };
|
|
12750
|
-
const needed = minAmount - bal;
|
|
12751
|
-
const hash = await walletClient.writeContract({ address: weth, abi: WETH_ABI, functionName: "deposit", args: [], value: needed });
|
|
12752
|
-
await publicClient.waitForTransactionReceipt({ hash });
|
|
12753
|
-
return { deposited: needed, hash };
|
|
12754
|
-
};
|
|
12755
|
-
module2.exports.getDynamicHookInfo = async function getDynamicHookInfo(sdk, hookAddress) {
|
|
12756
|
-
const auction = await sdk.getDynamicAuction(hookAddress);
|
|
12757
|
-
return auction.getHookInfo();
|
|
12758
|
-
};
|
|
12759
|
-
module2.exports.quoteV4ExactIn = async function quoteV4ExactIn(sdk, { poolKey, zeroForOne, exactAmount, hookData }) {
|
|
12760
|
-
return sdk.quoter.quoteExactInputV4({ poolKey, zeroForOne, exactAmount, hookData });
|
|
12761
|
-
};
|
|
12762
|
-
var UR_ABI = [
|
|
12763
|
-
{ name: "execute", type: "function", stateMutability: "payable", inputs: [{ name: "commands", type: "bytes" }, { name: "inputs", type: "bytes[]" }], outputs: [] }
|
|
12764
|
-
];
|
|
12765
|
-
module2.exports.urExecute = async function urExecute({ rpcUrl, chainId, privateKey, universalRouter, commands, inputs, value }) {
|
|
12766
|
-
const chain = getChainById(chainId);
|
|
12767
|
-
const accountObj = privateKeyToAccount(privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`);
|
|
12768
|
-
const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
|
|
12769
|
-
const walletClient = createWalletClient({ chain, transport: http(rpcUrl), account: accountObj });
|
|
12770
|
-
const hash = await walletClient.writeContract({ address: universalRouter, abi: UR_ABI, functionName: "execute", args: [commands, inputs], value: value || 0n });
|
|
12771
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
12772
|
-
return { hash, receipt };
|
|
12773
|
-
};
|
|
12774
|
-
module2.exports.simulateCreateStaticAuction = async function simulateCreateStaticAuction(sdk, builderParams) {
|
|
12775
|
-
const StaticAuctionBuilder = dopplerLib.StaticAuctionBuilder || dopplerLib.default?.StaticAuctionBuilder;
|
|
12776
|
-
if (!StaticAuctionBuilder) throw new Error("StaticAuctionBuilder missing from doppler-sdk");
|
|
12777
|
-
const builder = new StaticAuctionBuilder().tokenConfig(builderParams.token).saleConfig(builderParams.sale).poolByTicks(builderParams.pool).withUserAddress(builderParams.userAddress);
|
|
12778
|
-
if (builderParams.governance) builder.withGovernance(builderParams.governance);
|
|
12779
|
-
if (builderParams.migration) builder.withMigration(builderParams.migration);
|
|
12780
|
-
if (builderParams.modules?.v3Initializer && typeof builder.withV3Initializer === "function") builder.withV3Initializer(builderParams.modules.v3Initializer);
|
|
12781
|
-
if (builderParams.modules?.airlock && typeof builder.withAirlock === "function") builder.withAirlock(builderParams.modules.airlock);
|
|
12782
|
-
const params = builder.build();
|
|
12783
|
-
return sdk.factory.simulateCreateStaticAuction(params);
|
|
12784
|
-
};
|
|
12785
|
-
module2.exports.simulateBundleExactOut = async function simulateBundleExactOut(sdk, createParams, { tokenIn, tokenOut, amount, fee, sqrtPriceLimitX96 = 0n }) {
|
|
12786
|
-
return sdk.factory.simulateBundleExactOutput(createParams, { tokenIn, tokenOut, amount, fee, sqrtPriceLimitX96 });
|
|
12787
|
-
};
|
|
12788
|
-
module2.exports.factoryBundle = async function factoryBundle(sdk, createParams, { commands, inputs, value }) {
|
|
12789
|
-
return sdk.factory.bundle(createParams, commands, inputs, { value });
|
|
12790
|
-
};
|
|
12791
|
-
var V3_SWAP_ROUTER_ABI = [
|
|
12792
|
-
{
|
|
12793
|
-
name: "exactInputSingle",
|
|
12794
|
-
type: "function",
|
|
12795
|
-
stateMutability: "payable",
|
|
12796
|
-
inputs: [
|
|
12797
|
-
{
|
|
12798
|
-
name: "params",
|
|
12799
|
-
type: "tuple",
|
|
12800
|
-
components: [
|
|
12801
|
-
{ name: "tokenIn", type: "address" },
|
|
12802
|
-
{ name: "tokenOut", type: "address" },
|
|
12803
|
-
{ name: "fee", type: "uint24" },
|
|
12804
|
-
{ name: "recipient", type: "address" },
|
|
12805
|
-
{ name: "deadline", type: "uint256" },
|
|
12806
|
-
{ name: "amountIn", type: "uint256" },
|
|
12807
|
-
{ name: "amountOutMinimum", type: "uint256" },
|
|
12808
|
-
{ name: "sqrtPriceLimitX96", type: "uint160" }
|
|
12809
|
-
]
|
|
12810
|
-
}
|
|
12811
|
-
],
|
|
12812
|
-
outputs: [{ name: "amountOut", type: "uint256" }]
|
|
12813
|
-
}
|
|
12814
|
-
];
|
|
12815
|
-
module2.exports.executeV3BuyExactIn = async function executeV3BuyExactIn({
|
|
12816
|
-
rpcUrl,
|
|
12817
|
-
chainId,
|
|
12818
|
-
privateKey,
|
|
12819
|
-
router,
|
|
12820
|
-
tokenIn,
|
|
12821
|
-
tokenOut,
|
|
12822
|
-
fee,
|
|
12823
|
-
amountIn,
|
|
12824
|
-
amountOutMinimum,
|
|
12825
|
-
recipient,
|
|
12826
|
-
deadline
|
|
12827
|
-
}) {
|
|
12828
|
-
const chain = getChainById(chainId);
|
|
12829
|
-
const accountObj = privateKeyToAccount(privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`);
|
|
12830
|
-
const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
|
|
12831
|
-
const walletClient = createWalletClient({ chain, transport: http(rpcUrl), account: accountObj });
|
|
12832
|
-
const allowance = await publicClient.readContract({
|
|
12833
|
-
address: tokenIn,
|
|
12834
|
-
abi: erc20Abi,
|
|
12835
|
-
functionName: "allowance",
|
|
12836
|
-
args: [accountObj.address, router]
|
|
12837
|
-
});
|
|
12838
|
-
if (allowance < amountIn) {
|
|
12839
|
-
await walletClient.writeContract({
|
|
12840
|
-
address: tokenIn,
|
|
12841
|
-
abi: erc20Abi,
|
|
12842
|
-
functionName: "approve",
|
|
12843
|
-
args: [router, amountIn]
|
|
12844
|
-
});
|
|
12845
|
-
}
|
|
12846
|
-
const hash = await walletClient.writeContract({
|
|
12847
|
-
address: router,
|
|
12848
|
-
abi: V3_SWAP_ROUTER_ABI,
|
|
12849
|
-
functionName: "exactInputSingle",
|
|
12850
|
-
args: [
|
|
12851
|
-
{
|
|
12852
|
-
tokenIn,
|
|
12853
|
-
tokenOut,
|
|
12854
|
-
fee,
|
|
12855
|
-
recipient,
|
|
12856
|
-
deadline,
|
|
12857
|
-
amountIn,
|
|
12858
|
-
amountOutMinimum,
|
|
12859
|
-
sqrtPriceLimitX96: 0n
|
|
12860
|
-
}
|
|
12861
|
-
],
|
|
12862
|
-
value: 0n
|
|
12863
|
-
});
|
|
12864
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
12865
|
-
return { hash, receipt };
|
|
12866
|
-
};
|
|
12867
|
-
}
|
|
12868
|
-
});
|
|
12869
|
-
|
|
12870
12380
|
// src/points.js
|
|
12871
12381
|
var require_points = __commonJS({
|
|
12872
12382
|
"src/points.js"(exports2, module2) {
|
|
@@ -14939,7 +14449,6 @@ var require_src = __commonJS({
|
|
|
14939
14449
|
var ipns = require_ipns();
|
|
14940
14450
|
var token = require_token();
|
|
14941
14451
|
var personal = require_personal();
|
|
14942
|
-
var premium = require_premium();
|
|
14943
14452
|
var subgraph = require_subgraph();
|
|
14944
14453
|
var privateTx = require_privateTx();
|
|
14945
14454
|
var safe = require_safe();
|
|
@@ -14958,7 +14467,6 @@ var require_src = __commonJS({
|
|
|
14958
14467
|
var walletTyped = require_typed();
|
|
14959
14468
|
var utils = require_provider();
|
|
14960
14469
|
var errors = require_errors();
|
|
14961
|
-
var doppler = require_doppler();
|
|
14962
14470
|
var adapters = {
|
|
14963
14471
|
transports: require_transports(),
|
|
14964
14472
|
governance: {
|
|
@@ -14994,7 +14502,7 @@ var require_src = __commonJS({
|
|
|
14994
14502
|
SageEchoExecutor,
|
|
14995
14503
|
token,
|
|
14996
14504
|
personal,
|
|
14997
|
-
premium
|
|
14505
|
+
// premium: removed — PremiumPrompts deprecated
|
|
14998
14506
|
treasury,
|
|
14999
14507
|
boost,
|
|
15000
14508
|
// bond module removed; bonds deprecated in CLI/SDK
|
|
@@ -15011,7 +14519,6 @@ var require_src = __commonJS({
|
|
|
15011
14519
|
}),
|
|
15012
14520
|
walletTyped,
|
|
15013
14521
|
errors,
|
|
15014
|
-
doppler,
|
|
15015
14522
|
adapters,
|
|
15016
14523
|
// Season points helpers (airdrops/testnet)
|
|
15017
14524
|
points,
|