@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/node/index.cjs
CHANGED
|
@@ -14,7 +14,7 @@ var require_package = __commonJS({
|
|
|
14
14
|
"package.json"(exports2, module2) {
|
|
15
15
|
module2.exports = {
|
|
16
16
|
name: "@sage-protocol/sdk",
|
|
17
|
-
version: "0.
|
|
17
|
+
version: "0.3.0",
|
|
18
18
|
description: "Backend-agnostic SDK for interacting with the Sage Protocol (governance, SubDAOs, tokens).",
|
|
19
19
|
main: "dist/index.cjs",
|
|
20
20
|
module: "dist/index.mjs",
|
|
@@ -72,7 +72,6 @@ var require_package = __commonJS({
|
|
|
72
72
|
},
|
|
73
73
|
dependencies: {
|
|
74
74
|
"@merit-systems/echo-typescript-sdk": "^1.0.17",
|
|
75
|
-
"@whetstone-research/doppler-sdk": "^0.0.1-alpha.40",
|
|
76
75
|
ai: "^5.0.52",
|
|
77
76
|
axios: "^1.11.0",
|
|
78
77
|
ethers: "^6.15.0",
|
|
@@ -158,31 +157,36 @@ var require_abi = __commonJS({
|
|
|
158
157
|
];
|
|
159
158
|
var FactoryWrite = [
|
|
160
159
|
"function createSubDAO(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount) returns (address subDAO, address registry)",
|
|
160
|
+
// legacy compatibility
|
|
161
161
|
"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)",
|
|
162
162
|
"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)",
|
|
163
163
|
"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)",
|
|
164
164
|
"function createSubDAOOperatorWithStableAdvanced(string name, string description, uint8 accessModel, uint256 minStakeAmount, address operatorExecutor, address operatorAdmin, bool anyoneExec, bool governorProposer, (uint256 value,uint256 deadline,uint8 v,bytes32 r,bytes32 s) permit) returns (address subDAO, address registry)",
|
|
165
165
|
"function createSubDAOOperator(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount, address operatorExecutor, address operatorAdmin) returns (address subDAO, address registry)",
|
|
166
166
|
"function createSubDAOOperatorAdvanced(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount, address operatorExecutor, address operatorAdmin, bool anyoneExec, bool governorProposer) returns (address subDAO, address registry)",
|
|
167
|
+
// Forking (legacy overloads forward with maxForkFee=type(uint256).max)
|
|
167
168
|
"function createForkedSubDAO(string newName, string newDescription, string originalName, address originalSubDAO, address forker, bool copyLibrary) returns (address subDAO, address registry)",
|
|
168
|
-
|
|
169
|
+
// Forking (preferred: explicit maxForkFee slippage cap)
|
|
170
|
+
"function createForkedSubDAO(string newName, string newDescription, string originalName, address originalSubDAO, address forker, uint256 maxForkFee, bool copyLibrary) returns (address subDAO, address registry)",
|
|
171
|
+
// Stable-fee forking (legacy overloads forward with maxForkFee=type(uint256).max)
|
|
172
|
+
"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)",
|
|
173
|
+
// Stable-fee forking (preferred: explicit maxForkFee slippage cap)
|
|
174
|
+
"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)"
|
|
169
175
|
];
|
|
170
176
|
var TemplateModule = [
|
|
171
177
|
"function getActiveTemplates() view returns (uint256[])",
|
|
172
|
-
"function getTemplateStruct(uint256) view returns (string,string,uint8,uint8,uint8,
|
|
178
|
+
"function getTemplateStruct(uint256) view returns (string,string,uint8,uint8,uint8,bool,bool,uint256,uint256,uint256,uint256,uint256,uint256,bool,bytes)",
|
|
173
179
|
"function getTemplateUsage(uint256) view returns (uint256)",
|
|
174
180
|
"function getTemplateUsageMeta(uint256) view returns (uint256 usage, uint256 cap)",
|
|
175
181
|
"function minCreationBurn() view returns (uint256)",
|
|
176
182
|
"function maxCreationBurn() view returns (uint256)"
|
|
177
183
|
];
|
|
178
184
|
var LibraryRegistry = [
|
|
179
|
-
"function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version,
|
|
185
|
+
"function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version, uint256 nonce)",
|
|
180
186
|
"function daoTimelock(address) view returns (address)",
|
|
181
|
-
"function getLibrary(address) view returns (tuple(string manifestCID, address lastUpdater, uint256 lastUpdated, string version,
|
|
187
|
+
"function getLibrary(address) view returns (tuple(string manifestCID, address lastUpdater, uint256 lastUpdated, string version, uint256 nonce))",
|
|
182
188
|
"function getLibraryIds(address dao) view returns (bytes32[] memory)",
|
|
183
|
-
"function getLibraryStream(address dao, string libraryId) view returns (tuple(string manifestCID, address lastUpdater, uint256 lastUpdated, string version,
|
|
184
|
-
"function getLibraryForkFee(address dao) view returns (uint256)",
|
|
185
|
-
"function setLibraryForkFee(address dao, uint256 fee)",
|
|
189
|
+
"function getLibraryStream(address dao, string libraryId) view returns (tuple(string manifestCID, address lastUpdater, uint256 lastUpdated, string version, uint256 nonce))",
|
|
186
190
|
"function updateLibrary(address dao, string manifestCID, string version)",
|
|
187
191
|
"function updateLibraryCAS(address dao, string manifestCID, string version, uint256 expectedNonce)",
|
|
188
192
|
"function updateLibraryStream(address dao, string libraryId, string manifestCID, string version)",
|
|
@@ -301,9 +305,6 @@ var require_abi = __commonJS({
|
|
|
301
305
|
"function getForkBurnDiscount(address) view returns (uint256)",
|
|
302
306
|
"function totalBurned() view returns (uint256)"
|
|
303
307
|
];
|
|
304
|
-
var PersonalLibraryFacet = [
|
|
305
|
-
"function createPersonalRegistry(uint8 policy) returns (address)"
|
|
306
|
-
];
|
|
307
308
|
var PersonalMarketplace = [
|
|
308
309
|
"function setPrice(bytes32 key, uint256 price)",
|
|
309
310
|
"function purchase(address creator, bytes32 key, uint256 expectedPrice, uint256 deadline)"
|
|
@@ -330,7 +331,7 @@ var require_abi = __commonJS({
|
|
|
330
331
|
"function setMerkleRoot(uint256 proposalId, bytes32 root)",
|
|
331
332
|
"function finalize(uint256 proposalId)",
|
|
332
333
|
"function claim(uint256 proposalId, address account, uint256 amount, bytes32[] proof)",
|
|
333
|
-
"function getBoost(uint256 proposalId) view returns (uint256 totalPool, uint256 totalClaimed, bytes32 merkleRoot, bool active, bool finalized, address creator)",
|
|
334
|
+
"function getBoost(uint256 proposalId) view returns (uint256 totalPool, uint256 totalClaimed, bytes32 merkleRoot, uint256 expiresAt, bool active, bool finalized, address creator)",
|
|
334
335
|
"function claimed(uint256 proposalId, address account) view returns (bool)",
|
|
335
336
|
"event BoostCreated(uint256 indexed proposalId, address indexed creator, uint256 totalPool)",
|
|
336
337
|
"event MerkleRootSet(uint256 indexed proposalId, bytes32 merkleRoot)",
|
|
@@ -428,7 +429,7 @@ var require_abi = __commonJS({
|
|
|
428
429
|
"function weth() view returns (address)",
|
|
429
430
|
"function timeBuffer() view returns (uint256)",
|
|
430
431
|
"function reservePrice() view returns (uint256)",
|
|
431
|
-
"function
|
|
432
|
+
"function minBidIncrementBps() view returns (uint256)",
|
|
432
433
|
"function duration() view returns (uint256)",
|
|
433
434
|
"function mintTierId() view returns (uint256)",
|
|
434
435
|
"function defaultTokenURI() view returns (string)",
|
|
@@ -438,7 +439,7 @@ var require_abi = __commonJS({
|
|
|
438
439
|
"function paused() view returns (bool)",
|
|
439
440
|
"function setTimeBuffer(uint256 _timeBuffer)",
|
|
440
441
|
"function setReservePrice(uint256 _reservePrice)",
|
|
441
|
-
"function
|
|
442
|
+
"function setMinBidIncrementBps(uint256 _minBidIncrementBps)",
|
|
442
443
|
"function setDuration(uint256 _duration)",
|
|
443
444
|
"function setMintTierId(uint256 _tierId)",
|
|
444
445
|
"function setDefaultTokenURI(string _uri)",
|
|
@@ -451,7 +452,7 @@ var require_abi = __commonJS({
|
|
|
451
452
|
"event AuctionSettled(uint256 indexed nftId, address winner, uint256 amount)",
|
|
452
453
|
"event AuctionTimeBufferUpdated(uint256 timeBuffer)",
|
|
453
454
|
"event AuctionReservePriceUpdated(uint256 reservePrice)",
|
|
454
|
-
"event
|
|
455
|
+
"event AuctionMinBidIncrementBpsUpdated(uint256 minBidIncrementBps)",
|
|
455
456
|
"event AuctionDurationUpdated(uint256 duration)"
|
|
456
457
|
];
|
|
457
458
|
var SimpleBountySystem = [
|
|
@@ -461,10 +462,8 @@ var require_abi = __commonJS({
|
|
|
461
462
|
// Bounty Creation
|
|
462
463
|
"function createBounty(string title, string description, string ipfsCID, uint256 reward, uint256 deadline) returns (uint256)",
|
|
463
464
|
"function createBountyAdvanced(string title, string description, string ipfsCID, uint256 reward, uint256 deadline, uint256 votingDuration, uint8 mode, uint8 libraryAction, address assignee, string libraryKey) returns (uint256)",
|
|
464
|
-
// Submission
|
|
465
|
-
"function claimBounty(uint256 bountyId)",
|
|
465
|
+
// Submission
|
|
466
466
|
"function submitEntry(uint256 bountyId, string promptIPFS, string deliverableIPFS) returns (uint256)",
|
|
467
|
-
"function completeBounty(uint256 bountyId, string deliverableIPFS)",
|
|
468
467
|
// Voting (COMPETITIVE mode)
|
|
469
468
|
"function startVoting(uint256 bountyId)",
|
|
470
469
|
"function vote(uint256 bountyId, uint256 submissionId)",
|
|
@@ -543,7 +542,6 @@ var require_abi = __commonJS({
|
|
|
543
542
|
Timelock,
|
|
544
543
|
ERC20Votes,
|
|
545
544
|
SXXX,
|
|
546
|
-
PersonalLibraryFacet,
|
|
547
545
|
PersonalMarketplace,
|
|
548
546
|
PersonalLicenseReceipt,
|
|
549
547
|
TreasuryWrapper,
|
|
@@ -1834,13 +1832,31 @@ var require_subdao = __commonJS({
|
|
|
1834
1832
|
Number(accessModel ?? 0),
|
|
1835
1833
|
0n,
|
|
1836
1834
|
// minStakeAmount deprecated
|
|
1837
|
-
BigInt(burnAmount ?? 0n)
|
|
1835
|
+
BigInt(burnAmount ?? 0n),
|
|
1836
|
+
1n,
|
|
1837
|
+
// votingDelay
|
|
1838
|
+
100n,
|
|
1839
|
+
// votingPeriod
|
|
1840
|
+
1n,
|
|
1841
|
+
// proposalThreshold
|
|
1842
|
+
500n * 10n ** 18n,
|
|
1843
|
+
// quorumVotes
|
|
1844
|
+
0,
|
|
1845
|
+
// initialForkPolicy
|
|
1846
|
+
0,
|
|
1847
|
+
// initialMembershipPolicy
|
|
1848
|
+
"",
|
|
1849
|
+
// profileCID
|
|
1850
|
+
"",
|
|
1851
|
+
// manifestCID
|
|
1852
|
+
""
|
|
1853
|
+
// manifestVersion
|
|
1838
1854
|
];
|
|
1839
1855
|
let tx;
|
|
1840
1856
|
try {
|
|
1841
|
-
tx = await fac.
|
|
1857
|
+
tx = await fac.createSubDAOWithParams(...args);
|
|
1842
1858
|
} catch (err) {
|
|
1843
|
-
tx = await fac.
|
|
1859
|
+
tx = await fac.createSubDAOWithParams(...args, { gasLimit: 8e6 });
|
|
1844
1860
|
}
|
|
1845
1861
|
const receipt = await tx.wait();
|
|
1846
1862
|
const iface = new Interface(ABI.Factory);
|
|
@@ -3851,6 +3867,43 @@ var require_library = __commonJS({
|
|
|
3851
3867
|
}
|
|
3852
3868
|
return raw;
|
|
3853
3869
|
}
|
|
3870
|
+
function mapLibraryInfo(info, libraryId = "default") {
|
|
3871
|
+
return {
|
|
3872
|
+
libraryId,
|
|
3873
|
+
manifestCID: info.manifestCID,
|
|
3874
|
+
previousCID: "",
|
|
3875
|
+
// Not tracked on-chain (history is in events/subgraph)
|
|
3876
|
+
timestamp: BigInt(info.lastUpdated.toString()),
|
|
3877
|
+
proposer: getAddress(info.lastUpdater),
|
|
3878
|
+
promptCount: 0,
|
|
3879
|
+
// Not tracked on-chain
|
|
3880
|
+
version: info.version,
|
|
3881
|
+
nonce: BigInt(info.nonce.toString()),
|
|
3882
|
+
forkedFromDAO: null,
|
|
3883
|
+
// Removed from on-chain struct; use events/subgraph
|
|
3884
|
+
sxxxForkFee: 0n
|
|
3885
|
+
// Removed from on-chain struct
|
|
3886
|
+
};
|
|
3887
|
+
}
|
|
3888
|
+
async function resolveLibraryInfo({ contract, dao, libraryId = "default" }) {
|
|
3889
|
+
const libId = normaliseLibraryId(libraryId);
|
|
3890
|
+
let streamError = null;
|
|
3891
|
+
try {
|
|
3892
|
+
const stream = await contract.getLibraryStream(dao, libId);
|
|
3893
|
+
const streamCid = typeof stream?.manifestCID === "string" ? stream.manifestCID.trim() : "";
|
|
3894
|
+
if (streamCid || libId !== "default") {
|
|
3895
|
+
return mapLibraryInfo(stream, libId);
|
|
3896
|
+
}
|
|
3897
|
+
} catch (err) {
|
|
3898
|
+
streamError = err;
|
|
3899
|
+
}
|
|
3900
|
+
if (libId === "default") {
|
|
3901
|
+
const legacy = await contract.getLibrary(dao);
|
|
3902
|
+
return mapLibraryInfo(legacy, libId);
|
|
3903
|
+
}
|
|
3904
|
+
if (streamError) throw streamError;
|
|
3905
|
+
throw new SageSDKError(CODES.NOT_FOUND, `library stream not found`, { dao, libraryId: libId });
|
|
3906
|
+
}
|
|
3854
3907
|
async function listManifests({ provider, registry, factoryAddress, offset = 0, limit = 50 }) {
|
|
3855
3908
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
3856
3909
|
if (!factoryAddress) throw new SageSDKError(CODES.INVALID_ARGS, "factoryAddress required for V4 listing");
|
|
@@ -3874,41 +3927,15 @@ var require_library = __commonJS({
|
|
|
3874
3927
|
const addr = normalise(registry, "registry");
|
|
3875
3928
|
const dao = normalise(subdao, "subdao");
|
|
3876
3929
|
const contract = new Contract(addr, ABI.LibraryRegistry, provider);
|
|
3877
|
-
|
|
3878
|
-
return {
|
|
3879
|
-
manifestCID: info.manifestCID,
|
|
3880
|
-
previousCID: "",
|
|
3881
|
-
// Not tracked on-chain in V4 (history is in events/subgraph)
|
|
3882
|
-
timestamp: BigInt(info.lastUpdated.toString()),
|
|
3883
|
-
proposer: getAddress(info.lastUpdater),
|
|
3884
|
-
promptCount: 0,
|
|
3885
|
-
// Not tracked on-chain in V4
|
|
3886
|
-
version: info.version,
|
|
3887
|
-
nonce: BigInt(info.nonce.toString()),
|
|
3888
|
-
forkedFromDAO: info.forkedFromDAO && info.forkedFromDAO !== "0x0000000000000000000000000000000000000000" ? getAddress(info.forkedFromDAO) : null,
|
|
3889
|
-
sxxxForkFee: BigInt(info.sxxxForkFee.toString())
|
|
3890
|
-
};
|
|
3930
|
+
return resolveLibraryInfo({ contract, dao, libraryId: "default" });
|
|
3891
3931
|
}
|
|
3892
3932
|
async function getLibraryStreamInfo({ provider, registry, subdao, libraryId = "default" }) {
|
|
3893
3933
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
3894
3934
|
if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
|
|
3895
3935
|
const addr = normalise(registry, "registry");
|
|
3896
3936
|
const dao = normalise(subdao, "subdao");
|
|
3897
|
-
const libId = normaliseLibraryId(libraryId);
|
|
3898
3937
|
const contract = new Contract(addr, ABI.LibraryRegistry, provider);
|
|
3899
|
-
|
|
3900
|
-
return {
|
|
3901
|
-
libraryId: libId,
|
|
3902
|
-
manifestCID: info.manifestCID,
|
|
3903
|
-
previousCID: "",
|
|
3904
|
-
timestamp: BigInt(info.lastUpdated.toString()),
|
|
3905
|
-
proposer: getAddress(info.lastUpdater),
|
|
3906
|
-
promptCount: 0,
|
|
3907
|
-
version: info.version,
|
|
3908
|
-
nonce: BigInt(info.nonce.toString()),
|
|
3909
|
-
forkedFromDAO: info.forkedFromDAO && info.forkedFromDAO !== "0x0000000000000000000000000000000000000000" ? getAddress(info.forkedFromDAO) : null,
|
|
3910
|
-
sxxxForkFee: BigInt(info.sxxxForkFee.toString())
|
|
3911
|
-
};
|
|
3938
|
+
return resolveLibraryInfo({ contract, dao, libraryId });
|
|
3912
3939
|
}
|
|
3913
3940
|
async function getLibraryIds({ provider, registry, subdao }) {
|
|
3914
3941
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
@@ -4563,8 +4590,8 @@ var require_governance = __commonJS({
|
|
|
4563
4590
|
const reg = new Contract(
|
|
4564
4591
|
targets[i],
|
|
4565
4592
|
[
|
|
4566
|
-
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4567
|
-
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4593
|
+
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))",
|
|
4594
|
+
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))"
|
|
4568
4595
|
],
|
|
4569
4596
|
provider
|
|
4570
4597
|
);
|
|
@@ -4598,8 +4625,8 @@ var require_governance = __commonJS({
|
|
|
4598
4625
|
const reg = new Contract(
|
|
4599
4626
|
targets[i],
|
|
4600
4627
|
[
|
|
4601
|
-
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4602
|
-
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4628
|
+
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))",
|
|
4629
|
+
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))"
|
|
4603
4630
|
],
|
|
4604
4631
|
provider
|
|
4605
4632
|
);
|
|
@@ -4633,8 +4660,8 @@ var require_governance = __commonJS({
|
|
|
4633
4660
|
const reg = new Contract(
|
|
4634
4661
|
targets[i],
|
|
4635
4662
|
[
|
|
4636
|
-
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4637
|
-
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4663
|
+
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))",
|
|
4664
|
+
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))"
|
|
4638
4665
|
],
|
|
4639
4666
|
provider
|
|
4640
4667
|
);
|
|
@@ -4675,8 +4702,8 @@ var require_governance = __commonJS({
|
|
|
4675
4702
|
const reg = new Contract(
|
|
4676
4703
|
targets[i],
|
|
4677
4704
|
[
|
|
4678
|
-
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4679
|
-
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4705
|
+
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))",
|
|
4706
|
+
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))"
|
|
4680
4707
|
],
|
|
4681
4708
|
provider
|
|
4682
4709
|
);
|
|
@@ -7043,16 +7070,16 @@ var require_factory = __commonJS({
|
|
|
7043
7070
|
accessModel: Number(template[2]),
|
|
7044
7071
|
forkPolicy: Number(template[3]),
|
|
7045
7072
|
membershipPolicy: Number(template[4]),
|
|
7046
|
-
|
|
7047
|
-
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7073
|
+
allowForkPolicyOverride: Boolean(template[5]),
|
|
7074
|
+
allowMembershipPolicyOverride: Boolean(template[6]),
|
|
7075
|
+
burnAmount: BigInt(template[7].toString()),
|
|
7076
|
+
votingDelay: BigInt(template[8].toString()),
|
|
7077
|
+
votingPeriod: BigInt(template[9].toString()),
|
|
7078
|
+
proposalThreshold: BigInt(template[10].toString()),
|
|
7079
|
+
// template[11] is quorumVotes (absolute token amount, e.g., 100e18 = 100 SXXX)
|
|
7080
|
+
quorumVotes: BigInt(template[11].toString()),
|
|
7081
|
+
quorumPercentage: Number(template[11]),
|
|
7054
7082
|
// deprecated alias
|
|
7055
|
-
// template[11] was proposalStakeRequired (deprecated)
|
|
7056
7083
|
proposalCooldownSeconds: BigInt(template[12].toString()),
|
|
7057
7084
|
isActive: Boolean(template[13])
|
|
7058
7085
|
});
|
|
@@ -7073,16 +7100,16 @@ var require_factory = __commonJS({
|
|
|
7073
7100
|
accessModel: Number(template[2]),
|
|
7074
7101
|
forkPolicy: Number(template[3]),
|
|
7075
7102
|
membershipPolicy: Number(template[4]),
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7103
|
+
allowForkPolicyOverride: Boolean(template[5]),
|
|
7104
|
+
allowMembershipPolicyOverride: Boolean(template[6]),
|
|
7105
|
+
burnAmount: BigInt(template[7].toString()),
|
|
7106
|
+
votingDelay: BigInt(template[8].toString()),
|
|
7107
|
+
votingPeriod: BigInt(template[9].toString()),
|
|
7108
|
+
proposalThreshold: BigInt(template[10].toString()),
|
|
7109
|
+
// template[11] is quorumVotes (absolute token amount, e.g., 100e18 = 100 SXXX)
|
|
7110
|
+
quorumVotes: BigInt(template[11].toString()),
|
|
7111
|
+
quorumPercentage: Number(template[11]),
|
|
7084
7112
|
// deprecated alias
|
|
7085
|
-
// template[11] was proposalStakeRequired (deprecated)
|
|
7086
7113
|
proposalCooldownSeconds: BigInt(template[12].toString()),
|
|
7087
7114
|
isActive: Boolean(template[13]),
|
|
7088
7115
|
usage: usage != null ? BigInt(usage.toString()) : null,
|
|
@@ -7090,15 +7117,40 @@ var require_factory = __commonJS({
|
|
|
7090
7117
|
};
|
|
7091
7118
|
}
|
|
7092
7119
|
var FactoryWriteInterface = new Interface(ABI.FactoryWrite);
|
|
7093
|
-
function buildCreateSubDAOTx({
|
|
7120
|
+
function buildCreateSubDAOTx({
|
|
7121
|
+
factory,
|
|
7122
|
+
name,
|
|
7123
|
+
description,
|
|
7124
|
+
accessModel,
|
|
7125
|
+
minStakeAmount,
|
|
7126
|
+
burnAmount,
|
|
7127
|
+
votingDelay = 1n,
|
|
7128
|
+
votingPeriod = 100n,
|
|
7129
|
+
proposalThreshold = 1n,
|
|
7130
|
+
quorumVotes = 500n * 10n ** 18n,
|
|
7131
|
+
initialForkPolicy = 0,
|
|
7132
|
+
initialMembershipPolicy = 0,
|
|
7133
|
+
profileCID = "",
|
|
7134
|
+
manifestCID = "",
|
|
7135
|
+
manifestVersion = ""
|
|
7136
|
+
}) {
|
|
7094
7137
|
const addr = normalise(factory, "factory");
|
|
7095
|
-
const payload = FactoryWriteInterface.encodeFunctionData("
|
|
7138
|
+
const payload = FactoryWriteInterface.encodeFunctionData("createSubDAOWithParams", [
|
|
7096
7139
|
String(name),
|
|
7097
7140
|
String(description),
|
|
7098
7141
|
Number(accessModel),
|
|
7099
|
-
0n,
|
|
7142
|
+
BigInt(minStakeAmount || 0n),
|
|
7100
7143
|
// minStakeAmount deprecated
|
|
7101
|
-
BigInt(burnAmount)
|
|
7144
|
+
BigInt(burnAmount),
|
|
7145
|
+
BigInt(votingDelay),
|
|
7146
|
+
BigInt(votingPeriod),
|
|
7147
|
+
BigInt(proposalThreshold),
|
|
7148
|
+
BigInt(quorumVotes),
|
|
7149
|
+
Number(initialForkPolicy),
|
|
7150
|
+
Number(initialMembershipPolicy),
|
|
7151
|
+
String(profileCID || ""),
|
|
7152
|
+
String(manifestCID || ""),
|
|
7153
|
+
String(manifestVersion || "")
|
|
7102
7154
|
]);
|
|
7103
7155
|
return { to: addr, data: payload, value: 0n };
|
|
7104
7156
|
}
|
|
@@ -7122,18 +7174,45 @@ var require_factory = __commonJS({
|
|
|
7122
7174
|
]);
|
|
7123
7175
|
return { to: addr, data: payload, value: 0n };
|
|
7124
7176
|
}
|
|
7125
|
-
function buildCreateForkedSubDAOTx({
|
|
7177
|
+
function buildCreateForkedSubDAOTx({
|
|
7178
|
+
factory,
|
|
7179
|
+
newName,
|
|
7180
|
+
newDescription,
|
|
7181
|
+
originalName,
|
|
7182
|
+
originalSubDAO,
|
|
7183
|
+
forker,
|
|
7184
|
+
copyLibrary = false,
|
|
7185
|
+
maxForkFee
|
|
7186
|
+
}) {
|
|
7126
7187
|
const addr = normalise(factory, "factory");
|
|
7127
|
-
const
|
|
7188
|
+
const argsBase = [
|
|
7128
7189
|
String(newName),
|
|
7129
7190
|
String(newDescription),
|
|
7130
7191
|
String(originalName),
|
|
7131
7192
|
normalise(originalSubDAO, "originalSubDAO"),
|
|
7132
7193
|
normalise(forker, "forker")
|
|
7133
|
-
]
|
|
7194
|
+
];
|
|
7195
|
+
const payload = maxForkFee === void 0 || maxForkFee === null ? FactoryWriteInterface.encodeFunctionData(
|
|
7196
|
+
"createForkedSubDAO(string,string,string,address,address,bool)",
|
|
7197
|
+
[...argsBase, Boolean(copyLibrary)]
|
|
7198
|
+
) : FactoryWriteInterface.encodeFunctionData(
|
|
7199
|
+
"createForkedSubDAO(string,string,string,address,address,uint256,bool)",
|
|
7200
|
+
[...argsBase, BigInt(maxForkFee), Boolean(copyLibrary)]
|
|
7201
|
+
);
|
|
7134
7202
|
return { to: addr, data: payload, value: 0n };
|
|
7135
7203
|
}
|
|
7136
|
-
function buildCreateForkedSubDAOWithStableTx({
|
|
7204
|
+
function buildCreateForkedSubDAOWithStableTx({
|
|
7205
|
+
factory,
|
|
7206
|
+
newName,
|
|
7207
|
+
newDescription,
|
|
7208
|
+
originalName,
|
|
7209
|
+
originalSubDAO,
|
|
7210
|
+
forker,
|
|
7211
|
+
authorizationNonce,
|
|
7212
|
+
permit,
|
|
7213
|
+
copyLibrary = false,
|
|
7214
|
+
maxForkFee
|
|
7215
|
+
}) {
|
|
7137
7216
|
const addr = normalise(factory, "factory");
|
|
7138
7217
|
if (!permit) throw new SageSDKError(CODES.INVALID_ARGS, "permit required for stable fork");
|
|
7139
7218
|
const tuple = [
|
|
@@ -7143,7 +7222,7 @@ var require_factory = __commonJS({
|
|
|
7143
7222
|
permit.r ?? "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
7144
7223
|
permit.s ?? "0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
7145
7224
|
];
|
|
7146
|
-
const
|
|
7225
|
+
const argsBase = [
|
|
7147
7226
|
String(newName),
|
|
7148
7227
|
String(newDescription),
|
|
7149
7228
|
String(originalName),
|
|
@@ -7151,7 +7230,14 @@ var require_factory = __commonJS({
|
|
|
7151
7230
|
normalise(forker, "forker"),
|
|
7152
7231
|
Number(authorizationNonce ?? 0),
|
|
7153
7232
|
tuple
|
|
7154
|
-
]
|
|
7233
|
+
];
|
|
7234
|
+
const payload = maxForkFee === void 0 || maxForkFee === null ? FactoryWriteInterface.encodeFunctionData(
|
|
7235
|
+
"createForkedSubDAOWithStable(string,string,string,address,address,uint64,(uint256,uint256,uint8,bytes32,bytes32),bool)",
|
|
7236
|
+
[...argsBase, Boolean(copyLibrary)]
|
|
7237
|
+
) : FactoryWriteInterface.encodeFunctionData(
|
|
7238
|
+
"createForkedSubDAOWithStable(string,string,string,address,address,uint64,(uint256,uint256,uint8,bytes32,bytes32),uint256,bool)",
|
|
7239
|
+
[...argsBase, BigInt(maxForkFee), Boolean(copyLibrary)]
|
|
7240
|
+
);
|
|
7155
7241
|
return { to: addr, data: payload, value: 0n };
|
|
7156
7242
|
}
|
|
7157
7243
|
function buildCreateSubDAOWithParamsTx({
|
|
@@ -7352,10 +7438,8 @@ var require_lineage = __commonJS({
|
|
|
7352
7438
|
var { Contract, getAddress } = require("ethers");
|
|
7353
7439
|
var { SageSDKError, CODES } = require_errors();
|
|
7354
7440
|
var LINEAGE_ABI = [
|
|
7355
|
-
"function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version,
|
|
7356
|
-
"function getLibraryForkFee(address) view returns (uint256)"
|
|
7441
|
+
"function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version, uint256 nonce)"
|
|
7357
7442
|
];
|
|
7358
|
-
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
7359
7443
|
function normalise(address, label) {
|
|
7360
7444
|
if (!address) throw new SageSDKError(CODES.INVALID_ARGS, `${label} required`);
|
|
7361
7445
|
try {
|
|
@@ -7369,13 +7453,7 @@ var require_lineage = __commonJS({
|
|
|
7369
7453
|
if (!registry) throw new SageSDKError(CODES.INVALID_ARGS, "registry required");
|
|
7370
7454
|
if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
|
|
7371
7455
|
try {
|
|
7372
|
-
|
|
7373
|
-
const info = await contract.libraryByDAO(normalise(subdao, "subdao"));
|
|
7374
|
-
const parent = info.forkedFromDAO;
|
|
7375
|
-
if (!parent || parent === ZERO_ADDRESS) {
|
|
7376
|
-
return null;
|
|
7377
|
-
}
|
|
7378
|
-
return getAddress(parent).toLowerCase();
|
|
7456
|
+
return null;
|
|
7379
7457
|
} catch (err) {
|
|
7380
7458
|
throw new SageSDKError(CODES.CONTRACT_ERROR, "Failed to fetch parent library", { cause: err });
|
|
7381
7459
|
}
|
|
@@ -7385,25 +7463,11 @@ var require_lineage = __commonJS({
|
|
|
7385
7463
|
if (!registry) throw new SageSDKError(CODES.INVALID_ARGS, "registry required");
|
|
7386
7464
|
if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
|
|
7387
7465
|
try {
|
|
7388
|
-
const
|
|
7389
|
-
const chain = [];
|
|
7390
|
-
let current = normalise(subdao, "subdao");
|
|
7391
|
-
const MAX_DEPTH = 100;
|
|
7392
|
-
let iterations = 0;
|
|
7393
|
-
while (current && iterations < MAX_DEPTH) {
|
|
7394
|
-
chain.unshift(getAddress(current).toLowerCase());
|
|
7395
|
-
const info = await contract.libraryByDAO(current);
|
|
7396
|
-
const parent = info.forkedFromDAO;
|
|
7397
|
-
if (!parent || parent === ZERO_ADDRESS) {
|
|
7398
|
-
break;
|
|
7399
|
-
}
|
|
7400
|
-
current = parent;
|
|
7401
|
-
iterations++;
|
|
7402
|
-
}
|
|
7466
|
+
const addr = getAddress(normalise(subdao, "subdao")).toLowerCase();
|
|
7403
7467
|
return {
|
|
7404
|
-
chain,
|
|
7405
|
-
depth:
|
|
7406
|
-
root:
|
|
7468
|
+
chain: [addr],
|
|
7469
|
+
depth: 0,
|
|
7470
|
+
root: addr
|
|
7407
7471
|
};
|
|
7408
7472
|
} catch (err) {
|
|
7409
7473
|
throw new SageSDKError(CODES.CONTRACT_ERROR, "Failed to fetch lineage chain", { cause: err });
|
|
@@ -7414,16 +7478,7 @@ var require_lineage = __commonJS({
|
|
|
7414
7478
|
return parent !== null;
|
|
7415
7479
|
}
|
|
7416
7480
|
async function getLibraryForkFee({ provider, registry, subdao }) {
|
|
7417
|
-
|
|
7418
|
-
if (!registry) throw new SageSDKError(CODES.INVALID_ARGS, "registry required");
|
|
7419
|
-
if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
|
|
7420
|
-
try {
|
|
7421
|
-
const contract = new Contract(normalise(registry, "registry"), LINEAGE_ABI, provider);
|
|
7422
|
-
const fee = await contract.getLibraryForkFee(normalise(subdao, "subdao"));
|
|
7423
|
-
return BigInt(fee.toString());
|
|
7424
|
-
} catch (err) {
|
|
7425
|
-
throw new SageSDKError(CODES.CONTRACT_ERROR, "Failed to fetch library fork fee", { cause: err });
|
|
7426
|
-
}
|
|
7481
|
+
return 0n;
|
|
7427
7482
|
}
|
|
7428
7483
|
async function getLibraryInfo({ provider, registry, subdao }) {
|
|
7429
7484
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
@@ -7432,10 +7487,11 @@ var require_lineage = __commonJS({
|
|
|
7432
7487
|
try {
|
|
7433
7488
|
const contract = new Contract(normalise(registry, "registry"), LINEAGE_ABI, provider);
|
|
7434
7489
|
const info = await contract.libraryByDAO(normalise(subdao, "subdao"));
|
|
7435
|
-
const parent = info.forkedFromDAO;
|
|
7436
7490
|
return {
|
|
7437
|
-
parentDAO:
|
|
7438
|
-
|
|
7491
|
+
parentDAO: null,
|
|
7492
|
+
// Fork lineage removed from on-chain struct
|
|
7493
|
+
forkFee: 0n,
|
|
7494
|
+
// Fork fees removed from on-chain struct
|
|
7439
7495
|
manifestCID: info.manifestCID,
|
|
7440
7496
|
version: info.version
|
|
7441
7497
|
};
|
|
@@ -8631,12 +8687,6 @@ var require_personal = __commonJS({
|
|
|
8631
8687
|
var { Interface } = require("ethers");
|
|
8632
8688
|
var ABI = require_abi();
|
|
8633
8689
|
var { normaliseAddress, toBytes32Key } = require_helpers();
|
|
8634
|
-
function buildCreatePersonalRegistryTx({ factory, policy }) {
|
|
8635
|
-
const to = normaliseAddress(factory, "factory");
|
|
8636
|
-
const iface = new Interface(ABI.PersonalLibraryFacet);
|
|
8637
|
-
const data = iface.encodeFunctionData("createPersonalRegistry", [policy >>> 0]);
|
|
8638
|
-
return { to, data, value: 0n };
|
|
8639
|
-
}
|
|
8640
8690
|
function buildSetPriceTx({ marketplace, key, price }) {
|
|
8641
8691
|
const to = normaliseAddress(marketplace, "marketplace");
|
|
8642
8692
|
const k = toBytes32Key(key);
|
|
@@ -8656,7 +8706,6 @@ var require_personal = __commonJS({
|
|
|
8656
8706
|
return { to, data, value: 0n };
|
|
8657
8707
|
}
|
|
8658
8708
|
module2.exports = {
|
|
8659
|
-
buildCreatePersonalRegistryTx,
|
|
8660
8709
|
buildSetPriceTx,
|
|
8661
8710
|
buildBuyTx,
|
|
8662
8711
|
...require_receipt(),
|
|
@@ -8665,300 +8714,6 @@ var require_personal = __commonJS({
|
|
|
8665
8714
|
}
|
|
8666
8715
|
});
|
|
8667
8716
|
|
|
8668
|
-
// src/premium/index.js
|
|
8669
|
-
var require_premium = __commonJS({
|
|
8670
|
-
"src/premium/index.js"(exports2, module2) {
|
|
8671
|
-
var axios = require("axios");
|
|
8672
|
-
var { getAddress } = require("ethers");
|
|
8673
|
-
function safeGetAddress(value) {
|
|
8674
|
-
try {
|
|
8675
|
-
return getAddress(value);
|
|
8676
|
-
} catch {
|
|
8677
|
-
return null;
|
|
8678
|
-
}
|
|
8679
|
-
}
|
|
8680
|
-
function mapSafe(list, mapper) {
|
|
8681
|
-
const out = [];
|
|
8682
|
-
for (const item of list || []) {
|
|
8683
|
-
try {
|
|
8684
|
-
const v = mapper(item);
|
|
8685
|
-
if (v != null) out.push(v);
|
|
8686
|
-
} catch {
|
|
8687
|
-
}
|
|
8688
|
-
}
|
|
8689
|
-
return out;
|
|
8690
|
-
}
|
|
8691
|
-
async function query(url, document, variables) {
|
|
8692
|
-
if (!url) throw new Error("subgraph url required");
|
|
8693
|
-
const resp = await axios.post(url, { query: document, variables }, { timeout: 1e4 });
|
|
8694
|
-
if (resp.data && resp.data.errors) {
|
|
8695
|
-
throw new Error(resp.data.errors.map((e) => e.message).join("; "));
|
|
8696
|
-
}
|
|
8697
|
-
return resp.data.data;
|
|
8698
|
-
}
|
|
8699
|
-
async function listPremiumPrompts({ url, subdao = null, first = 50, skip = 0, orderBy = "blockTimestamp", orderDirection = "desc" }) {
|
|
8700
|
-
const safeOrderBy = ["blockTimestamp", "price"].includes(orderBy) ? orderBy : "blockTimestamp";
|
|
8701
|
-
const safeOrderDirection = orderDirection === "asc" ? "asc" : "desc";
|
|
8702
|
-
let doc;
|
|
8703
|
-
const variables = {
|
|
8704
|
-
first: Math.min(Math.max(1, Number(first || 50)), 200),
|
|
8705
|
-
skip: Number(skip || 0)
|
|
8706
|
-
};
|
|
8707
|
-
if (subdao) {
|
|
8708
|
-
const addr = safeGetAddress(subdao);
|
|
8709
|
-
if (!addr) throw new Error("invalid subdao address");
|
|
8710
|
-
variables.subdao = addr.toLowerCase();
|
|
8711
|
-
doc = `
|
|
8712
|
-
query($subdao: Bytes!, $first: Int!, $skip: Int!) {
|
|
8713
|
-
premiumPrompts(
|
|
8714
|
-
where: { subdao: $subdao }
|
|
8715
|
-
first: $first
|
|
8716
|
-
skip: $skip
|
|
8717
|
-
orderBy: ${safeOrderBy}
|
|
8718
|
-
orderDirection: ${safeOrderDirection}
|
|
8719
|
-
) {
|
|
8720
|
-
id
|
|
8721
|
-
cidHash
|
|
8722
|
-
subdao
|
|
8723
|
-
price
|
|
8724
|
-
manifestCID
|
|
8725
|
-
blockNumber
|
|
8726
|
-
blockTimestamp
|
|
8727
|
-
transactionHash
|
|
8728
|
-
}
|
|
8729
|
-
}
|
|
8730
|
-
`;
|
|
8731
|
-
} else {
|
|
8732
|
-
doc = `
|
|
8733
|
-
query($first: Int!, $skip: Int!) {
|
|
8734
|
-
premiumPrompts(
|
|
8735
|
-
first: $first
|
|
8736
|
-
skip: $skip
|
|
8737
|
-
orderBy: ${safeOrderBy}
|
|
8738
|
-
orderDirection: ${safeOrderDirection}
|
|
8739
|
-
) {
|
|
8740
|
-
id
|
|
8741
|
-
cidHash
|
|
8742
|
-
subdao
|
|
8743
|
-
price
|
|
8744
|
-
manifestCID
|
|
8745
|
-
blockNumber
|
|
8746
|
-
blockTimestamp
|
|
8747
|
-
transactionHash
|
|
8748
|
-
}
|
|
8749
|
-
}
|
|
8750
|
-
`;
|
|
8751
|
-
}
|
|
8752
|
-
const data = await query(url, doc, variables);
|
|
8753
|
-
return mapSafe(data?.premiumPrompts, (p) => {
|
|
8754
|
-
const sub = safeGetAddress(p.subdao);
|
|
8755
|
-
if (!sub) return null;
|
|
8756
|
-
return {
|
|
8757
|
-
id: String(p.id),
|
|
8758
|
-
cidHash: String(p.cidHash),
|
|
8759
|
-
subdao: sub,
|
|
8760
|
-
price: BigInt(String(p.price || "0")),
|
|
8761
|
-
manifestCID: p.manifestCID || null,
|
|
8762
|
-
blockNumber: Number(p.blockNumber || 0),
|
|
8763
|
-
blockTimestamp: Number(p.blockTimestamp || 0),
|
|
8764
|
-
transactionHash: p.transactionHash || null
|
|
8765
|
-
};
|
|
8766
|
-
});
|
|
8767
|
-
}
|
|
8768
|
-
async function getPremiumPrompt({ url, cidHash }) {
|
|
8769
|
-
const id2 = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
|
|
8770
|
-
const doc = `
|
|
8771
|
-
query($id: ID!) {
|
|
8772
|
-
premiumPrompt(id: $id) {
|
|
8773
|
-
id
|
|
8774
|
-
cidHash
|
|
8775
|
-
subdao
|
|
8776
|
-
price
|
|
8777
|
-
manifestCID
|
|
8778
|
-
blockNumber
|
|
8779
|
-
blockTimestamp
|
|
8780
|
-
transactionHash
|
|
8781
|
-
}
|
|
8782
|
-
premiumPromptStats(id: $id) {
|
|
8783
|
-
totalRevenue
|
|
8784
|
-
purchaseCount
|
|
8785
|
-
uniqueBuyers
|
|
8786
|
-
currentHolders
|
|
8787
|
-
}
|
|
8788
|
-
}
|
|
8789
|
-
`;
|
|
8790
|
-
const data = await query(url, doc, { id: id2 });
|
|
8791
|
-
const p = data?.premiumPrompt;
|
|
8792
|
-
if (!p) return null;
|
|
8793
|
-
const sub = safeGetAddress(p.subdao);
|
|
8794
|
-
if (!sub) return null;
|
|
8795
|
-
const stats = data?.premiumPromptStats || {};
|
|
8796
|
-
return {
|
|
8797
|
-
id: String(p.id),
|
|
8798
|
-
cidHash: String(p.cidHash),
|
|
8799
|
-
subdao: sub,
|
|
8800
|
-
price: BigInt(String(p.price || "0")),
|
|
8801
|
-
manifestCID: p.manifestCID || null,
|
|
8802
|
-
blockNumber: Number(p.blockNumber || 0),
|
|
8803
|
-
blockTimestamp: Number(p.blockTimestamp || 0),
|
|
8804
|
-
transactionHash: p.transactionHash || null,
|
|
8805
|
-
// Stats
|
|
8806
|
-
totalRevenue: stats.totalRevenue ? BigInt(String(stats.totalRevenue)) : null,
|
|
8807
|
-
purchaseCount: stats.purchaseCount ? BigInt(String(stats.purchaseCount)) : null,
|
|
8808
|
-
uniqueBuyers: stats.uniqueBuyers ? BigInt(String(stats.uniqueBuyers)) : null,
|
|
8809
|
-
currentHolders: stats.currentHolders ? BigInt(String(stats.currentHolders)) : null
|
|
8810
|
-
};
|
|
8811
|
-
}
|
|
8812
|
-
async function listPremiumPurchases({ url, cidHash, first = 50, skip = 0 }) {
|
|
8813
|
-
const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
|
|
8814
|
-
const doc = `
|
|
8815
|
-
query($cidHash: Bytes!, $first: Int!, $skip: Int!) {
|
|
8816
|
-
premiumPurchases(
|
|
8817
|
-
where: { cidHash: $cidHash }
|
|
8818
|
-
first: $first
|
|
8819
|
-
skip: $skip
|
|
8820
|
-
orderBy: blockTimestamp
|
|
8821
|
-
orderDirection: desc
|
|
8822
|
-
) {
|
|
8823
|
-
id
|
|
8824
|
-
cidHash
|
|
8825
|
-
buyer
|
|
8826
|
-
price
|
|
8827
|
-
treasury
|
|
8828
|
-
blockNumber
|
|
8829
|
-
blockTimestamp
|
|
8830
|
-
transactionHash
|
|
8831
|
-
}
|
|
8832
|
-
}
|
|
8833
|
-
`;
|
|
8834
|
-
const data = await query(url, doc, {
|
|
8835
|
-
cidHash: normalizedCidHash,
|
|
8836
|
-
first: Math.min(Math.max(1, Number(first || 50)), 200),
|
|
8837
|
-
skip: Number(skip || 0)
|
|
8838
|
-
});
|
|
8839
|
-
return mapSafe(data?.premiumPurchases, (p) => {
|
|
8840
|
-
const buyer = safeGetAddress(p.buyer);
|
|
8841
|
-
const treasury = safeGetAddress(p.treasury);
|
|
8842
|
-
if (!buyer || !treasury) return null;
|
|
8843
|
-
return {
|
|
8844
|
-
id: String(p.id),
|
|
8845
|
-
cidHash: String(p.cidHash),
|
|
8846
|
-
buyer,
|
|
8847
|
-
price: BigInt(String(p.price || "0")),
|
|
8848
|
-
treasury,
|
|
8849
|
-
blockNumber: Number(p.blockNumber || 0),
|
|
8850
|
-
blockTimestamp: Number(p.blockTimestamp || 0),
|
|
8851
|
-
transactionHash: p.transactionHash || null
|
|
8852
|
-
};
|
|
8853
|
-
});
|
|
8854
|
-
}
|
|
8855
|
-
async function hasPurchased({ url, cidHash, holder }) {
|
|
8856
|
-
const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
|
|
8857
|
-
const normalizedHolder = holder.toLowerCase();
|
|
8858
|
-
const id2 = `${normalizedCidHash}-${normalizedHolder}`;
|
|
8859
|
-
const doc = `
|
|
8860
|
-
query($id: ID!) {
|
|
8861
|
-
premiumHolderBalance(id: $id) {
|
|
8862
|
-
balance
|
|
8863
|
-
}
|
|
8864
|
-
}
|
|
8865
|
-
`;
|
|
8866
|
-
const data = await query(url, doc, { id: id2 });
|
|
8867
|
-
const balance = data?.premiumHolderBalance?.balance;
|
|
8868
|
-
return balance ? BigInt(String(balance)) > 0n : false;
|
|
8869
|
-
}
|
|
8870
|
-
async function getHolderBalance({ url, cidHash, holder }) {
|
|
8871
|
-
const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
|
|
8872
|
-
const normalizedHolder = holder.toLowerCase();
|
|
8873
|
-
const id2 = `${normalizedCidHash}-${normalizedHolder}`;
|
|
8874
|
-
const doc = `
|
|
8875
|
-
query($id: ID!) {
|
|
8876
|
-
premiumHolderBalance(id: $id) {
|
|
8877
|
-
balance
|
|
8878
|
-
updatedAt
|
|
8879
|
-
}
|
|
8880
|
-
}
|
|
8881
|
-
`;
|
|
8882
|
-
const data = await query(url, doc, { id: id2 });
|
|
8883
|
-
const row = data?.premiumHolderBalance;
|
|
8884
|
-
if (!row) return 0n;
|
|
8885
|
-
return BigInt(String(row.balance || "0"));
|
|
8886
|
-
}
|
|
8887
|
-
async function listHolders({ url, cidHash, first = 100, skip = 0 }) {
|
|
8888
|
-
const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
|
|
8889
|
-
const doc = `
|
|
8890
|
-
query($cidHash: Bytes!, $first: Int!, $skip: Int!) {
|
|
8891
|
-
premiumHolderBalances(
|
|
8892
|
-
where: { cidHash: $cidHash, balance_gt: "0" }
|
|
8893
|
-
first: $first
|
|
8894
|
-
skip: $skip
|
|
8895
|
-
orderBy: balance
|
|
8896
|
-
orderDirection: desc
|
|
8897
|
-
) {
|
|
8898
|
-
id
|
|
8899
|
-
cidHash
|
|
8900
|
-
holder
|
|
8901
|
-
balance
|
|
8902
|
-
updatedAt
|
|
8903
|
-
}
|
|
8904
|
-
}
|
|
8905
|
-
`;
|
|
8906
|
-
const data = await query(url, doc, {
|
|
8907
|
-
cidHash: normalizedCidHash,
|
|
8908
|
-
first: Math.min(Math.max(1, Number(first || 100)), 500),
|
|
8909
|
-
skip: Number(skip || 0)
|
|
8910
|
-
});
|
|
8911
|
-
return mapSafe(data?.premiumHolderBalances, (h) => {
|
|
8912
|
-
const holder = safeGetAddress(h.holder);
|
|
8913
|
-
if (!holder) return null;
|
|
8914
|
-
return {
|
|
8915
|
-
id: String(h.id),
|
|
8916
|
-
cidHash: String(h.cidHash),
|
|
8917
|
-
holder,
|
|
8918
|
-
balance: BigInt(String(h.balance || "0")),
|
|
8919
|
-
updatedAt: Number(h.updatedAt || 0)
|
|
8920
|
-
};
|
|
8921
|
-
});
|
|
8922
|
-
}
|
|
8923
|
-
async function getRevSplit({ url, subdao }) {
|
|
8924
|
-
const addr = safeGetAddress(subdao);
|
|
8925
|
-
if (!addr) throw new Error("invalid subdao address");
|
|
8926
|
-
const doc = `
|
|
8927
|
-
query($id: ID!) {
|
|
8928
|
-
premiumRevSplit(id: $id) {
|
|
8929
|
-
id
|
|
8930
|
-
subdao
|
|
8931
|
-
treasuryBps
|
|
8932
|
-
protocolBps
|
|
8933
|
-
creatorBps
|
|
8934
|
-
updatedAt
|
|
8935
|
-
}
|
|
8936
|
-
}
|
|
8937
|
-
`;
|
|
8938
|
-
const data = await query(url, doc, { id: addr.toLowerCase() });
|
|
8939
|
-
const split = data?.premiumRevSplit;
|
|
8940
|
-
if (!split) return null;
|
|
8941
|
-
return {
|
|
8942
|
-
id: String(split.id),
|
|
8943
|
-
subdao: safeGetAddress(split.subdao) || addr,
|
|
8944
|
-
treasuryBps: Number(split.treasuryBps || 0),
|
|
8945
|
-
protocolBps: Number(split.protocolBps || 0),
|
|
8946
|
-
creatorBps: Number(split.creatorBps || 0),
|
|
8947
|
-
updatedAt: Number(split.updatedAt || 0)
|
|
8948
|
-
};
|
|
8949
|
-
}
|
|
8950
|
-
module2.exports = {
|
|
8951
|
-
listPremiumPrompts,
|
|
8952
|
-
getPremiumPrompt,
|
|
8953
|
-
listPremiumPurchases,
|
|
8954
|
-
hasPurchased,
|
|
8955
|
-
getHolderBalance,
|
|
8956
|
-
listHolders,
|
|
8957
|
-
getRevSplit
|
|
8958
|
-
};
|
|
8959
|
-
}
|
|
8960
|
-
});
|
|
8961
|
-
|
|
8962
8717
|
// src/utils/privateTx.js
|
|
8963
8718
|
var require_privateTx = __commonJS({
|
|
8964
8719
|
"src/utils/privateTx.js"(exports2, module2) {
|
|
@@ -9478,7 +9233,7 @@ var require_boost = __commonJS({
|
|
|
9478
9233
|
const contract = new Contract(addr, ABI.GovernanceBoostMerkle, provider);
|
|
9479
9234
|
const result = await contract.getBoost(proposalId).catch(() => null);
|
|
9480
9235
|
if (!result) return null;
|
|
9481
|
-
const [totalPool, totalClaimed, merkleRoot, active, finalized, creator] = result;
|
|
9236
|
+
const [totalPool, totalClaimed, merkleRoot, expiresAt, active, finalized, creator] = result;
|
|
9482
9237
|
const creatorAddr = creator ? getAddress(creator) : ZERO_ADDRESS;
|
|
9483
9238
|
const pool = toBigInt(totalPool);
|
|
9484
9239
|
if (!active && !finalized && pool === 0n && creatorAddr === ZERO_ADDRESS) return null;
|
|
@@ -9488,6 +9243,7 @@ var require_boost = __commonJS({
|
|
|
9488
9243
|
totalPool: pool,
|
|
9489
9244
|
totalClaimed: toBigInt(totalClaimed),
|
|
9490
9245
|
merkleRoot,
|
|
9246
|
+
expiresAt: toBigInt(expiresAt),
|
|
9491
9247
|
active: Boolean(active),
|
|
9492
9248
|
finalized: Boolean(finalized),
|
|
9493
9249
|
creator: creatorAddr
|
|
@@ -10756,13 +10512,13 @@ var require_auction = __commonJS({
|
|
|
10756
10512
|
}
|
|
10757
10513
|
async function getConfig({ provider, auctionHouse }) {
|
|
10758
10514
|
const c = getAuctionContract(provider, auctionHouse);
|
|
10759
|
-
const [nft, treasury, weth, timeBuffer, reservePrice,
|
|
10515
|
+
const [nft, treasury, weth, timeBuffer, reservePrice, minBidIncrementBps, duration, mintTierId, defaultTokenURI, paused, owner] = await Promise.all([
|
|
10760
10516
|
c.nft(),
|
|
10761
10517
|
c.treasury(),
|
|
10762
10518
|
c.weth(),
|
|
10763
10519
|
c.timeBuffer(),
|
|
10764
10520
|
c.reservePrice(),
|
|
10765
|
-
c.
|
|
10521
|
+
c.minBidIncrementBps(),
|
|
10766
10522
|
c.duration(),
|
|
10767
10523
|
c.mintTierId(),
|
|
10768
10524
|
c.defaultTokenURI(),
|
|
@@ -10775,7 +10531,7 @@ var require_auction = __commonJS({
|
|
|
10775
10531
|
weth: getAddress(weth),
|
|
10776
10532
|
timeBuffer: BigInt(timeBuffer.toString()),
|
|
10777
10533
|
reservePrice: BigInt(reservePrice.toString()),
|
|
10778
|
-
|
|
10534
|
+
minBidIncrementBps: BigInt(minBidIncrementBps.toString()),
|
|
10779
10535
|
duration: BigInt(duration.toString()),
|
|
10780
10536
|
mintTierId: BigInt(mintTierId.toString()),
|
|
10781
10537
|
defaultTokenURI: String(defaultTokenURI),
|
|
@@ -10831,10 +10587,10 @@ var require_auction = __commonJS({
|
|
|
10831
10587
|
const data = iface.encodeFunctionData("setReservePrice", [toBigInt(reservePrice, "reservePrice")]);
|
|
10832
10588
|
return { to: addr, data, value: 0n };
|
|
10833
10589
|
}
|
|
10834
|
-
function buildSetMinBidIncrementTx({ auctionHouse,
|
|
10590
|
+
function buildSetMinBidIncrementTx({ auctionHouse, bps }) {
|
|
10835
10591
|
const addr = normaliseAddress(auctionHouse, "auctionHouse");
|
|
10836
10592
|
const iface = new Interface(ABI.SageAuctionHouse);
|
|
10837
|
-
const data = iface.encodeFunctionData("
|
|
10593
|
+
const data = iface.encodeFunctionData("setMinBidIncrementBps", [toBigInt(bps, "bps")]);
|
|
10838
10594
|
return { to: addr, data, value: 0n };
|
|
10839
10595
|
}
|
|
10840
10596
|
function buildSetDurationTx({ auctionHouse, duration }) {
|
|
@@ -11855,6 +11611,43 @@ ${error}` : ""}`;
|
|
|
11855
11611
|
signature: "createSubDAOFromTemplate(uint256,string,string)",
|
|
11856
11612
|
args: [templateId, `"${name}"`, `"${description}"`]
|
|
11857
11613
|
};
|
|
11614
|
+
} 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))) {
|
|
11615
|
+
const { ethers: ethers2 } = require("ethers");
|
|
11616
|
+
const iface = new ethers2.Interface(["function createSubDAOWithParams(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256,uint8,uint8,string,string,string)"]);
|
|
11617
|
+
const decoded = iface.decodeFunctionData("createSubDAOWithParams", data);
|
|
11618
|
+
const name = decoded[0];
|
|
11619
|
+
const description = decoded[1];
|
|
11620
|
+
const accessModel = decoded[2].toString();
|
|
11621
|
+
const minStakeAmount = decoded[3].toString();
|
|
11622
|
+
const burnAmount = decoded[4].toString();
|
|
11623
|
+
const votingDelay = decoded[5].toString();
|
|
11624
|
+
const votingPeriod = decoded[6].toString();
|
|
11625
|
+
const proposalThreshold = decoded[7].toString();
|
|
11626
|
+
const quorumVotes = decoded[8].toString();
|
|
11627
|
+
const initialForkPolicy = decoded[9].toString();
|
|
11628
|
+
const initialMembershipPolicy = decoded[10].toString();
|
|
11629
|
+
const profileCID = decoded[11];
|
|
11630
|
+
const manifestCID = decoded[12];
|
|
11631
|
+
const manifestVersion = decoded[13];
|
|
11632
|
+
return {
|
|
11633
|
+
signature: "createSubDAOWithParams(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256,uint8,uint8,string,string,string)",
|
|
11634
|
+
args: [
|
|
11635
|
+
`"${name}"`,
|
|
11636
|
+
`"${description}"`,
|
|
11637
|
+
accessModel,
|
|
11638
|
+
minStakeAmount,
|
|
11639
|
+
burnAmount,
|
|
11640
|
+
votingDelay,
|
|
11641
|
+
votingPeriod,
|
|
11642
|
+
proposalThreshold,
|
|
11643
|
+
quorumVotes,
|
|
11644
|
+
initialForkPolicy,
|
|
11645
|
+
initialMembershipPolicy,
|
|
11646
|
+
`"${profileCID}"`,
|
|
11647
|
+
`"${manifestCID}"`,
|
|
11648
|
+
`"${manifestVersion}"`
|
|
11649
|
+
]
|
|
11650
|
+
};
|
|
11858
11651
|
} else if (data.startsWith(require("ethers").id("createSubDAO(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256)").slice(0, 10))) {
|
|
11859
11652
|
const { ethers: ethers2 } = require("ethers");
|
|
11860
11653
|
const iface = new ethers2.Interface(["function createSubDAO(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256)"]);
|
|
@@ -12030,6 +11823,24 @@ ${error}` : ""}`;
|
|
|
12030
11823
|
} else if (data.startsWith(require("ethers").id("authorizeBurner(address)").slice(0, 10))) {
|
|
12031
11824
|
const burner = this.extractAddressFromData(data, 0);
|
|
12032
11825
|
return { signature: "authorizeBurner(address)", args: [burner] };
|
|
11826
|
+
} else if (data.startsWith(require("ethers").id("createBoost((address,uint256,uint256,uint256,uint8,address,uint96,uint8,uint8,uint256,uint256))").slice(0, 10))) {
|
|
11827
|
+
const { ethers: ethers2 } = require("ethers");
|
|
11828
|
+
const sig = "createBoost((address,uint256,uint256,uint256,uint8,address,uint96,uint8,uint8,uint256,uint256))";
|
|
11829
|
+
const iface = new ethers2.Interface([`function ${sig}`]);
|
|
11830
|
+
const d = iface.decodeFunctionData("createBoost", data);
|
|
11831
|
+
const params = d?.[0] ?? d;
|
|
11832
|
+
const governor = String(params?.governor ?? params?.[0]);
|
|
11833
|
+
const proposalId = (params?.proposalId ?? params?.[1])?.toString();
|
|
11834
|
+
const perVoter = (params?.perVoter ?? params?.[2])?.toString();
|
|
11835
|
+
const maxVoters = (params?.maxVoters ?? params?.[3])?.toString();
|
|
11836
|
+
const kind = (params?.kind ?? params?.[4])?.toString();
|
|
11837
|
+
const policy = String(params?.policy ?? params?.[5]);
|
|
11838
|
+
const minVotes = (params?.minVotes ?? params?.[6])?.toString();
|
|
11839
|
+
const payoutMode = (params?.payoutMode ?? params?.[7])?.toString();
|
|
11840
|
+
const support = (params?.support ?? params?.[8])?.toString();
|
|
11841
|
+
const startAt = (params?.startAt ?? params?.[9])?.toString();
|
|
11842
|
+
const expiresAt = (params?.expiresAt ?? params?.[10])?.toString();
|
|
11843
|
+
return { signature: sig, args: [governor, proposalId, perVoter, maxVoters, kind, policy, minVotes, payoutMode, support, startAt, expiresAt] };
|
|
12033
11844
|
} else if (data.startsWith(require("ethers").id("createBoost(address,uint256,uint256,uint256,uint8,address,uint96,uint8,uint8,uint256,uint256)").slice(0, 10))) {
|
|
12034
11845
|
const { ethers: ethers2 } = require("ethers");
|
|
12035
11846
|
const sig = "createBoost(address,uint256,uint256,uint256,uint8,address,uint96,uint8,uint8,uint256,uint256)";
|
|
@@ -12100,25 +11911,6 @@ ${error}` : ""}`;
|
|
|
12100
11911
|
const d = iface.decodeFunctionData("forkPromptWithStable", data);
|
|
12101
11912
|
const args = [`"${String(d[0])}"`, `"${String(d[1])}"`, `"${String(d[2])}"`, `"${String(d[3])}"`, "[permit]"];
|
|
12102
11913
|
return { signature: sig, args };
|
|
12103
|
-
} else if (data.startsWith(require("ethers").id("createPremiumPrompt(bytes32,address,uint256)").slice(0, 10))) {
|
|
12104
|
-
const { ethers: ethers2 } = require("ethers");
|
|
12105
|
-
const sig = "createPremiumPrompt(bytes32,address,uint256)";
|
|
12106
|
-
const iface = new ethers2.Interface([`function ${sig}`]);
|
|
12107
|
-
const d = iface.decodeFunctionData("createPremiumPrompt", data);
|
|
12108
|
-
const hash = d[0];
|
|
12109
|
-
const subdao = d[1];
|
|
12110
|
-
const price = d[2].toString();
|
|
12111
|
-
return { signature: sig, args: [hash, subdao, price] };
|
|
12112
|
-
} else if (data.startsWith(require("ethers").id("createPremiumPromptWithManifest(bytes32,address,uint256,string)").slice(0, 10))) {
|
|
12113
|
-
const { ethers: ethers2 } = require("ethers");
|
|
12114
|
-
const sig = "createPremiumPromptWithManifest(bytes32,address,uint256,string)";
|
|
12115
|
-
const iface = new ethers2.Interface([`function ${sig}`]);
|
|
12116
|
-
const d = iface.decodeFunctionData("createPremiumPromptWithManifest", data);
|
|
12117
|
-
const hash = d[0];
|
|
12118
|
-
const subdao = d[1];
|
|
12119
|
-
const price = d[2].toString();
|
|
12120
|
-
const manifest = d[3];
|
|
12121
|
-
return { signature: sig, args: [hash, subdao, price, `"${manifest}"`] };
|
|
12122
11914
|
} else if (data.startsWith(require("ethers").id("claim(uint256,address,uint256,bytes32[])").slice(0, 10))) {
|
|
12123
11915
|
const { ethers: ethers2 } = require("ethers");
|
|
12124
11916
|
const sig = "claim(uint256,address,uint256,bytes32[])";
|
|
@@ -12130,18 +11922,6 @@ ${error}` : ""}`;
|
|
|
12130
11922
|
const proofArray = (d[3] || []).map((x) => String(x));
|
|
12131
11923
|
const formattedProof = `[${proofArray.join(",")}]`;
|
|
12132
11924
|
return { signature: sig, args: [proposalId, account, amount, formattedProof] };
|
|
12133
|
-
} else if (data.startsWith(require("ethers").id("purchaseAccess(bytes32)").slice(0, 10))) {
|
|
12134
|
-
const { ethers: ethers2 } = require("ethers");
|
|
12135
|
-
const iface = new ethers2.Interface(["function purchaseAccess(bytes32)"]);
|
|
12136
|
-
const d = iface.decodeFunctionData("purchaseAccess", data);
|
|
12137
|
-
return { signature: "purchaseAccess(bytes32)", args: [d[0]] };
|
|
12138
|
-
} else if (data.startsWith(require("ethers").id("setProtocolRake(uint96,address)").slice(0, 10))) {
|
|
12139
|
-
const { ethers: ethers2 } = require("ethers");
|
|
12140
|
-
const iface = new ethers2.Interface(["function setProtocolRake(uint96,address)"]);
|
|
12141
|
-
const decoded = iface.decodeFunctionData("setProtocolRake", data);
|
|
12142
|
-
const bps = decoded[0].toString();
|
|
12143
|
-
const treas = decoded[1];
|
|
12144
|
-
return { signature: "setProtocolRake(uint96,address)", args: [bps, treas] };
|
|
12145
11925
|
} else if (data.startsWith(require("ethers").id("revokeBurner(address)").slice(0, 10))) {
|
|
12146
11926
|
const burner = this.extractAddressFromData(data, 0);
|
|
12147
11927
|
return { signature: "revokeBurner(address)", args: [burner] };
|
|
@@ -12591,276 +12371,6 @@ var require_typed = __commonJS({
|
|
|
12591
12371
|
}
|
|
12592
12372
|
});
|
|
12593
12373
|
|
|
12594
|
-
// src/doppler/index.js
|
|
12595
|
-
var require_doppler = __commonJS({
|
|
12596
|
-
"src/doppler/index.js"(exports2, module2) {
|
|
12597
|
-
var { createPublicClient, createWalletClient, http } = require("viem");
|
|
12598
|
-
var { privateKeyToAccount } = require("viem/accounts");
|
|
12599
|
-
var { erc20Abi } = require("viem");
|
|
12600
|
-
var { base, baseSepolia } = require("viem/chains");
|
|
12601
|
-
var dopplerLib = require("@whetstone-research/doppler-sdk");
|
|
12602
|
-
function getChainById(chainId) {
|
|
12603
|
-
if (Number(chainId) === baseSepolia.id) return baseSepolia;
|
|
12604
|
-
if (Number(chainId) === base.id) return base;
|
|
12605
|
-
return { id: Number(chainId), name: `chain-${chainId}` };
|
|
12606
|
-
}
|
|
12607
|
-
function initDoppler(opts) {
|
|
12608
|
-
const chain = getChainById(opts.chainId);
|
|
12609
|
-
const publicClient = createPublicClient({ chain, transport: http(opts.rpcUrl) });
|
|
12610
|
-
let walletClient;
|
|
12611
|
-
if (opts.privateKey) {
|
|
12612
|
-
const pk = opts.privateKey.startsWith("0x") ? opts.privateKey : `0x${opts.privateKey}`;
|
|
12613
|
-
const account = privateKeyToAccount(pk);
|
|
12614
|
-
walletClient = createWalletClient({ chain, transport: http(opts.rpcUrl), account });
|
|
12615
|
-
} else if (opts.account) {
|
|
12616
|
-
walletClient = createWalletClient({ chain, transport: http(opts.rpcUrl), account: opts.account });
|
|
12617
|
-
}
|
|
12618
|
-
const DopplerSDK = dopplerLib.DopplerSDK || dopplerLib.default?.DopplerSDK || dopplerLib;
|
|
12619
|
-
const sdk = new DopplerSDK({ publicClient, walletClient, chainId: chain.id });
|
|
12620
|
-
return sdk;
|
|
12621
|
-
}
|
|
12622
|
-
async function deployDynamicAuction(sdk, user, p) {
|
|
12623
|
-
const DynamicAuctionBuilder = dopplerLib.DynamicAuctionBuilder || dopplerLib.default?.DynamicAuctionBuilder;
|
|
12624
|
-
if (!DynamicAuctionBuilder) throw new Error("DynamicAuctionBuilder missing from doppler-sdk");
|
|
12625
|
-
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);
|
|
12626
|
-
if (p.auction && p.auction.startPrice && p.auction.endPrice && typeof builder.auctionByPriceRange === "function") {
|
|
12627
|
-
builder.auctionByPriceRange({
|
|
12628
|
-
priceRange: { startPrice: p.auction.startPrice, endPrice: p.auction.endPrice },
|
|
12629
|
-
minProceeds: p.auction.minProceeds || 0n,
|
|
12630
|
-
maxProceeds: p.auction.maxProceeds || 0n,
|
|
12631
|
-
durationDays: p.auction.durationDays,
|
|
12632
|
-
epochLength: p.auction.epochLength,
|
|
12633
|
-
numPdSlugs: p.auction.numPdSlugs || 5
|
|
12634
|
-
});
|
|
12635
|
-
} else if (typeof builder.auctionByTicks === "function") {
|
|
12636
|
-
throw new Error("auctionByPriceRange not supported by current doppler-sdk version; please provide tick params instead");
|
|
12637
|
-
} else {
|
|
12638
|
-
throw new Error("No supported auction configuration method on doppler-sdk builder");
|
|
12639
|
-
}
|
|
12640
|
-
builder.withMigration({
|
|
12641
|
-
type: p.migration.type || "uniswapV4",
|
|
12642
|
-
fee: p.migration.fee,
|
|
12643
|
-
tickSpacing: p.migration.tickSpacing,
|
|
12644
|
-
lpRecipient: p.migration.lpRecipient
|
|
12645
|
-
});
|
|
12646
|
-
if (p.governance && typeof builder.withGovernance === "function") {
|
|
12647
|
-
builder.withGovernance(p.governance);
|
|
12648
|
-
}
|
|
12649
|
-
if (p.overrides?.airlock && typeof builder.withAirlock === "function") builder.withAirlock(p.overrides.airlock);
|
|
12650
|
-
if (p.overrides?.dopplerDeployer && typeof builder.withDopplerDeployer === "function") builder.withDopplerDeployer(p.overrides.dopplerDeployer);
|
|
12651
|
-
if (p.overrides?.governanceFactory && typeof builder.withGovernanceFactory === "function") builder.withGovernanceFactory(p.overrides.governanceFactory);
|
|
12652
|
-
if (p.overrides?.v4Initializer && typeof builder.withV4Initializer === "function") builder.withV4Initializer(p.overrides.v4Initializer);
|
|
12653
|
-
const params = builder.build();
|
|
12654
|
-
const result = await sdk.factory.createDynamicAuction(params);
|
|
12655
|
-
return result;
|
|
12656
|
-
}
|
|
12657
|
-
async function getAuctionStatus(sdk, auctionAddress) {
|
|
12658
|
-
const lens = sdk.lens;
|
|
12659
|
-
if (lens && typeof lens.getAuctionStatus === "function") {
|
|
12660
|
-
return await lens.getAuctionStatus({ auctionAddress });
|
|
12661
|
-
}
|
|
12662
|
-
return { auctionAddress, note: "Lens API not available in this doppler-sdk version" };
|
|
12663
|
-
}
|
|
12664
|
-
async function listAuctions(sdk, { limit = 10, cursor } = {}) {
|
|
12665
|
-
const lens = sdk.lens;
|
|
12666
|
-
if (lens) {
|
|
12667
|
-
if (typeof lens.listAuctions === "function") {
|
|
12668
|
-
try {
|
|
12669
|
-
return await lens.listAuctions({ limit, cursor });
|
|
12670
|
-
} catch (e) {
|
|
12671
|
-
}
|
|
12672
|
-
}
|
|
12673
|
-
if (typeof lens.getAuctions === "function") {
|
|
12674
|
-
try {
|
|
12675
|
-
return await lens.getAuctions({ limit, cursor });
|
|
12676
|
-
} catch (e) {
|
|
12677
|
-
}
|
|
12678
|
-
}
|
|
12679
|
-
}
|
|
12680
|
-
const fac = sdk.factory;
|
|
12681
|
-
if (fac && typeof fac.listAuctions === "function") {
|
|
12682
|
-
try {
|
|
12683
|
-
return await fac.listAuctions({ limit, cursor });
|
|
12684
|
-
} catch (e) {
|
|
12685
|
-
}
|
|
12686
|
-
}
|
|
12687
|
-
return { ok: false, error: "LIST_UNSUPPORTED", message: "Listing auctions not supported by this doppler-sdk version" };
|
|
12688
|
-
}
|
|
12689
|
-
async function buyTokens(sdk, { auctionAddress, numeraireAmount }) {
|
|
12690
|
-
const trade = sdk.trade || sdk.swap || sdk.auction;
|
|
12691
|
-
if (trade && typeof trade.buy === "function") {
|
|
12692
|
-
try {
|
|
12693
|
-
return await trade.buy({ auctionAddress, numeraireAmount });
|
|
12694
|
-
} catch (e) {
|
|
12695
|
-
}
|
|
12696
|
-
}
|
|
12697
|
-
return { ok: false, error: "BUY_UNSUPPORTED", message: "Buy not supported by this doppler-sdk version. Use executeV3BuyExactIn/urExecute helpers or upgrade doppler-sdk." };
|
|
12698
|
-
}
|
|
12699
|
-
async function migrate(sdk, asset) {
|
|
12700
|
-
if (sdk.airlock && typeof sdk.airlock.migrate === "function") {
|
|
12701
|
-
return await sdk.airlock.migrate({ asset });
|
|
12702
|
-
}
|
|
12703
|
-
throw new Error("Migrate is not supported by the current doppler-sdk version");
|
|
12704
|
-
}
|
|
12705
|
-
module2.exports = {
|
|
12706
|
-
initDoppler,
|
|
12707
|
-
deployDynamicAuction,
|
|
12708
|
-
getAuctionStatus,
|
|
12709
|
-
listAuctions,
|
|
12710
|
-
buyTokens,
|
|
12711
|
-
migrate
|
|
12712
|
-
};
|
|
12713
|
-
module2.exports.deployStaticAuction = async function deployStaticAuction(sdk, user, p) {
|
|
12714
|
-
const StaticAuctionBuilder = dopplerLib.StaticAuctionBuilder || dopplerLib.default?.StaticAuctionBuilder;
|
|
12715
|
-
if (!StaticAuctionBuilder) throw new Error("StaticAuctionBuilder missing from doppler-sdk");
|
|
12716
|
-
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);
|
|
12717
|
-
if (p.governance?.noOp) builder.withGovernance({ noOp: true });
|
|
12718
|
-
if (p.migration) builder.withMigration(p.migration);
|
|
12719
|
-
if (p.modules?.airlock && typeof builder.withAirlock === "function") builder.withAirlock(p.modules.airlock);
|
|
12720
|
-
if (p.modules?.v3Initializer && typeof builder.withV3Initializer === "function") builder.withV3Initializer(p.modules.v3Initializer);
|
|
12721
|
-
const params = builder.build();
|
|
12722
|
-
const res = await sdk.factory.createStaticAuction(params);
|
|
12723
|
-
return res;
|
|
12724
|
-
};
|
|
12725
|
-
module2.exports.getStaticPoolInfo = async function getStaticPoolInfo(sdk, poolAddress) {
|
|
12726
|
-
const auction = await sdk.getStaticAuction(poolAddress);
|
|
12727
|
-
return auction.getPoolInfo();
|
|
12728
|
-
};
|
|
12729
|
-
module2.exports.quoteV3ExactIn = async function quoteV3ExactIn(sdk, { tokenIn, tokenOut, amountIn, fee, sqrtPriceLimitX96 = 0n }) {
|
|
12730
|
-
return sdk.quoter.quoteExactInputV3({ tokenIn, tokenOut, amountIn, fee, sqrtPriceLimitX96 });
|
|
12731
|
-
};
|
|
12732
|
-
var WETH_ABI = [
|
|
12733
|
-
{ type: "function", name: "deposit", stateMutability: "payable", inputs: [], outputs: [] },
|
|
12734
|
-
{ type: "function", name: "withdraw", stateMutability: "nonpayable", inputs: [{ name: "wad", type: "uint256" }], outputs: [] },
|
|
12735
|
-
{ type: "function", name: "balanceOf", stateMutability: "view", inputs: [{ name: "a", type: "address" }], outputs: [{ type: "uint256" }] }
|
|
12736
|
-
];
|
|
12737
|
-
module2.exports.wrapEthToWethIfNeeded = async function wrapEthToWethIfNeeded({ rpcUrl, chainId, privateKey, weth, owner, minAmount }) {
|
|
12738
|
-
const chain = getChainById(chainId);
|
|
12739
|
-
const accountObj = privateKeyToAccount(privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`);
|
|
12740
|
-
const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
|
|
12741
|
-
const walletClient = createWalletClient({ chain, transport: http(rpcUrl), account: accountObj });
|
|
12742
|
-
const bal = await publicClient.readContract({ address: weth, abi: WETH_ABI, functionName: "balanceOf", args: [owner] });
|
|
12743
|
-
if (bal >= minAmount) return { deposited: 0n };
|
|
12744
|
-
const needed = minAmount - bal;
|
|
12745
|
-
const hash = await walletClient.writeContract({ address: weth, abi: WETH_ABI, functionName: "deposit", args: [], value: needed });
|
|
12746
|
-
await publicClient.waitForTransactionReceipt({ hash });
|
|
12747
|
-
return { deposited: needed, hash };
|
|
12748
|
-
};
|
|
12749
|
-
module2.exports.getDynamicHookInfo = async function getDynamicHookInfo(sdk, hookAddress) {
|
|
12750
|
-
const auction = await sdk.getDynamicAuction(hookAddress);
|
|
12751
|
-
return auction.getHookInfo();
|
|
12752
|
-
};
|
|
12753
|
-
module2.exports.quoteV4ExactIn = async function quoteV4ExactIn(sdk, { poolKey, zeroForOne, exactAmount, hookData }) {
|
|
12754
|
-
return sdk.quoter.quoteExactInputV4({ poolKey, zeroForOne, exactAmount, hookData });
|
|
12755
|
-
};
|
|
12756
|
-
var UR_ABI = [
|
|
12757
|
-
{ name: "execute", type: "function", stateMutability: "payable", inputs: [{ name: "commands", type: "bytes" }, { name: "inputs", type: "bytes[]" }], outputs: [] }
|
|
12758
|
-
];
|
|
12759
|
-
module2.exports.urExecute = async function urExecute({ rpcUrl, chainId, privateKey, universalRouter, commands, inputs, value }) {
|
|
12760
|
-
const chain = getChainById(chainId);
|
|
12761
|
-
const accountObj = privateKeyToAccount(privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`);
|
|
12762
|
-
const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
|
|
12763
|
-
const walletClient = createWalletClient({ chain, transport: http(rpcUrl), account: accountObj });
|
|
12764
|
-
const hash = await walletClient.writeContract({ address: universalRouter, abi: UR_ABI, functionName: "execute", args: [commands, inputs], value: value || 0n });
|
|
12765
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
12766
|
-
return { hash, receipt };
|
|
12767
|
-
};
|
|
12768
|
-
module2.exports.simulateCreateStaticAuction = async function simulateCreateStaticAuction(sdk, builderParams) {
|
|
12769
|
-
const StaticAuctionBuilder = dopplerLib.StaticAuctionBuilder || dopplerLib.default?.StaticAuctionBuilder;
|
|
12770
|
-
if (!StaticAuctionBuilder) throw new Error("StaticAuctionBuilder missing from doppler-sdk");
|
|
12771
|
-
const builder = new StaticAuctionBuilder().tokenConfig(builderParams.token).saleConfig(builderParams.sale).poolByTicks(builderParams.pool).withUserAddress(builderParams.userAddress);
|
|
12772
|
-
if (builderParams.governance) builder.withGovernance(builderParams.governance);
|
|
12773
|
-
if (builderParams.migration) builder.withMigration(builderParams.migration);
|
|
12774
|
-
if (builderParams.modules?.v3Initializer && typeof builder.withV3Initializer === "function") builder.withV3Initializer(builderParams.modules.v3Initializer);
|
|
12775
|
-
if (builderParams.modules?.airlock && typeof builder.withAirlock === "function") builder.withAirlock(builderParams.modules.airlock);
|
|
12776
|
-
const params = builder.build();
|
|
12777
|
-
return sdk.factory.simulateCreateStaticAuction(params);
|
|
12778
|
-
};
|
|
12779
|
-
module2.exports.simulateBundleExactOut = async function simulateBundleExactOut(sdk, createParams, { tokenIn, tokenOut, amount, fee, sqrtPriceLimitX96 = 0n }) {
|
|
12780
|
-
return sdk.factory.simulateBundleExactOutput(createParams, { tokenIn, tokenOut, amount, fee, sqrtPriceLimitX96 });
|
|
12781
|
-
};
|
|
12782
|
-
module2.exports.factoryBundle = async function factoryBundle(sdk, createParams, { commands, inputs, value }) {
|
|
12783
|
-
return sdk.factory.bundle(createParams, commands, inputs, { value });
|
|
12784
|
-
};
|
|
12785
|
-
var V3_SWAP_ROUTER_ABI = [
|
|
12786
|
-
{
|
|
12787
|
-
name: "exactInputSingle",
|
|
12788
|
-
type: "function",
|
|
12789
|
-
stateMutability: "payable",
|
|
12790
|
-
inputs: [
|
|
12791
|
-
{
|
|
12792
|
-
name: "params",
|
|
12793
|
-
type: "tuple",
|
|
12794
|
-
components: [
|
|
12795
|
-
{ name: "tokenIn", type: "address" },
|
|
12796
|
-
{ name: "tokenOut", type: "address" },
|
|
12797
|
-
{ name: "fee", type: "uint24" },
|
|
12798
|
-
{ name: "recipient", type: "address" },
|
|
12799
|
-
{ name: "deadline", type: "uint256" },
|
|
12800
|
-
{ name: "amountIn", type: "uint256" },
|
|
12801
|
-
{ name: "amountOutMinimum", type: "uint256" },
|
|
12802
|
-
{ name: "sqrtPriceLimitX96", type: "uint160" }
|
|
12803
|
-
]
|
|
12804
|
-
}
|
|
12805
|
-
],
|
|
12806
|
-
outputs: [{ name: "amountOut", type: "uint256" }]
|
|
12807
|
-
}
|
|
12808
|
-
];
|
|
12809
|
-
module2.exports.executeV3BuyExactIn = async function executeV3BuyExactIn({
|
|
12810
|
-
rpcUrl,
|
|
12811
|
-
chainId,
|
|
12812
|
-
privateKey,
|
|
12813
|
-
router,
|
|
12814
|
-
tokenIn,
|
|
12815
|
-
tokenOut,
|
|
12816
|
-
fee,
|
|
12817
|
-
amountIn,
|
|
12818
|
-
amountOutMinimum,
|
|
12819
|
-
recipient,
|
|
12820
|
-
deadline
|
|
12821
|
-
}) {
|
|
12822
|
-
const chain = getChainById(chainId);
|
|
12823
|
-
const accountObj = privateKeyToAccount(privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`);
|
|
12824
|
-
const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
|
|
12825
|
-
const walletClient = createWalletClient({ chain, transport: http(rpcUrl), account: accountObj });
|
|
12826
|
-
const allowance = await publicClient.readContract({
|
|
12827
|
-
address: tokenIn,
|
|
12828
|
-
abi: erc20Abi,
|
|
12829
|
-
functionName: "allowance",
|
|
12830
|
-
args: [accountObj.address, router]
|
|
12831
|
-
});
|
|
12832
|
-
if (allowance < amountIn) {
|
|
12833
|
-
await walletClient.writeContract({
|
|
12834
|
-
address: tokenIn,
|
|
12835
|
-
abi: erc20Abi,
|
|
12836
|
-
functionName: "approve",
|
|
12837
|
-
args: [router, amountIn]
|
|
12838
|
-
});
|
|
12839
|
-
}
|
|
12840
|
-
const hash = await walletClient.writeContract({
|
|
12841
|
-
address: router,
|
|
12842
|
-
abi: V3_SWAP_ROUTER_ABI,
|
|
12843
|
-
functionName: "exactInputSingle",
|
|
12844
|
-
args: [
|
|
12845
|
-
{
|
|
12846
|
-
tokenIn,
|
|
12847
|
-
tokenOut,
|
|
12848
|
-
fee,
|
|
12849
|
-
recipient,
|
|
12850
|
-
deadline,
|
|
12851
|
-
amountIn,
|
|
12852
|
-
amountOutMinimum,
|
|
12853
|
-
sqrtPriceLimitX96: 0n
|
|
12854
|
-
}
|
|
12855
|
-
],
|
|
12856
|
-
value: 0n
|
|
12857
|
-
});
|
|
12858
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
12859
|
-
return { hash, receipt };
|
|
12860
|
-
};
|
|
12861
|
-
}
|
|
12862
|
-
});
|
|
12863
|
-
|
|
12864
12374
|
// src/points.js
|
|
12865
12375
|
var require_points = __commonJS({
|
|
12866
12376
|
"src/points.js"(exports2, module2) {
|
|
@@ -14933,7 +14443,6 @@ var require_src = __commonJS({
|
|
|
14933
14443
|
var ipns = require_ipns();
|
|
14934
14444
|
var token = require_token();
|
|
14935
14445
|
var personal = require_personal();
|
|
14936
|
-
var premium = require_premium();
|
|
14937
14446
|
var subgraph = require_subgraph();
|
|
14938
14447
|
var privateTx = require_privateTx();
|
|
14939
14448
|
var safe = require_safe();
|
|
@@ -14952,7 +14461,6 @@ var require_src = __commonJS({
|
|
|
14952
14461
|
var walletTyped = require_typed();
|
|
14953
14462
|
var utils = require_provider();
|
|
14954
14463
|
var errors = require_errors();
|
|
14955
|
-
var doppler = require_doppler();
|
|
14956
14464
|
var adapters = {
|
|
14957
14465
|
transports: require_transports(),
|
|
14958
14466
|
governance: {
|
|
@@ -14988,7 +14496,7 @@ var require_src = __commonJS({
|
|
|
14988
14496
|
SageEchoExecutor,
|
|
14989
14497
|
token,
|
|
14990
14498
|
personal,
|
|
14991
|
-
premium
|
|
14499
|
+
// premium: removed — PremiumPrompts deprecated
|
|
14992
14500
|
treasury,
|
|
14993
14501
|
boost,
|
|
14994
14502
|
// bond module removed; bonds deprecated in CLI/SDK
|
|
@@ -15005,7 +14513,6 @@ var require_src = __commonJS({
|
|
|
15005
14513
|
}),
|
|
15006
14514
|
walletTyped,
|
|
15007
14515
|
errors,
|
|
15008
|
-
doppler,
|
|
15009
14516
|
adapters,
|
|
15010
14517
|
// Season points helpers (airdrops/testnet)
|
|
15011
14518
|
points,
|