@sage-protocol/sdk 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/browser/index.mjs +22 -8
- package/dist/index.cjs +143 -62
- package/dist/index.mjs +143 -62
- package/dist/node/index.cjs +143 -62
- package/dist/node/index.mjs +143 -62
- package/package.json +1 -1
- package/types/index.d.ts +158 -19
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.2.
|
|
23
|
+
version: "0.2.8",
|
|
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",
|
|
@@ -146,7 +146,6 @@ var require_abi = __commonJS({
|
|
|
146
146
|
// Core factory reads
|
|
147
147
|
"function timelockMinDelay() view returns (uint256)",
|
|
148
148
|
"function premiumPromptsAddress() view returns (address)",
|
|
149
|
-
"function simpleKeyStoreAddress() view returns (address)",
|
|
150
149
|
"function governanceConfigAddress() view returns (address)",
|
|
151
150
|
"function libraryRegistryAddress() view returns (address)",
|
|
152
151
|
// Canonical per‑SubDAO mapping
|
|
@@ -333,14 +332,28 @@ var require_abi = __commonJS({
|
|
|
333
332
|
"event TokensSwept(address indexed token, address indexed to, uint256 amount)"
|
|
334
333
|
];
|
|
335
334
|
var GovernanceBoostMerkle = [
|
|
336
|
-
"function
|
|
337
|
-
"function
|
|
338
|
-
"function
|
|
335
|
+
"function createBoost(uint256 proposalId, uint256 totalPool)",
|
|
336
|
+
"function setMerkleRoot(uint256 proposalId, bytes32 root)",
|
|
337
|
+
"function finalize(uint256 proposalId)",
|
|
338
|
+
"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 claimed(uint256 proposalId, address account) view returns (bool)",
|
|
341
|
+
"event BoostCreated(uint256 indexed proposalId, address indexed creator, uint256 totalPool)",
|
|
342
|
+
"event MerkleRootSet(uint256 indexed proposalId, bytes32 merkleRoot)",
|
|
343
|
+
"event RewardClaimed(uint256 indexed proposalId, address indexed voter, uint256 amount)",
|
|
344
|
+
"event BoostFinalized(uint256 indexed proposalId, uint256 totalClaimed, uint256 refunded)"
|
|
339
345
|
];
|
|
340
346
|
var GovernanceBoostDirect = [
|
|
341
|
-
"function
|
|
342
|
-
"function
|
|
343
|
-
"function
|
|
347
|
+
"function createBoost((address governor,uint256 proposalId,uint256 perVoter,uint256 maxVoters,uint8 kind,address policy,uint96 minVotes,uint8 payoutMode,uint8 support,uint256 startAt,uint256 expiresAt) params)",
|
|
348
|
+
"function claim(uint256 proposalId, bytes data)",
|
|
349
|
+
"function finalize(uint256 proposalId)",
|
|
350
|
+
"function pause(uint256 proposalId, bool paused)",
|
|
351
|
+
"function setProtocolRake(uint96 rakeBps, address protocolTreasury)",
|
|
352
|
+
"function getBoost(uint256 proposalId) view returns (tuple(address creator, address governor, uint256 proposalId, uint256 snapshot, uint256 perVoter, uint256 maxVoters, uint256 votersPaid, uint96 minVotes, uint8 payoutMode, uint8 support, uint256 startAt, uint256 expiresAt, uint256 totalPool, uint256 totalPaid, uint8 kind, address policy, bool active, bool paused) boost)",
|
|
353
|
+
"function claimed(uint256 proposalId, address account) view returns (bool)",
|
|
354
|
+
"event BoostCreated(uint256 indexed proposalId, address indexed governor, uint256 perVoter, uint256 maxVoters, uint256 snapshot, uint8 kind, address policy, uint96 minVotes)",
|
|
355
|
+
"event BoostClaimed(uint256 indexed proposalId, address indexed claimer, uint256 amount, uint256 rake)",
|
|
356
|
+
"event BoostFinalized(uint256 indexed proposalId, uint256 paidCount, uint256 refund)"
|
|
344
357
|
];
|
|
345
358
|
var VotingMultiplierNFT = [
|
|
346
359
|
// Constants
|
|
@@ -348,6 +361,7 @@ var require_abi = __commonJS({
|
|
|
348
361
|
"function MAX_NFTS_PER_ACCOUNT() view returns (uint256)",
|
|
349
362
|
// Tier Management
|
|
350
363
|
"function createTier(address dao, string name, uint256 multiplier, uint256 maxSupply, uint256 price) returns (uint256 tierId)",
|
|
364
|
+
"function createTierViaGovernance(address subdao, string name, uint256 multiplier, uint256 maxSupply, uint256 price) returns (uint256 tierId)",
|
|
351
365
|
"function getTier(uint256 tierId) view returns (tuple(string name, uint256 multiplier, uint256 maxSupply, uint256 minted, uint256 price, address dao))",
|
|
352
366
|
"function tierCount() view returns (uint256)",
|
|
353
367
|
"function tiers(uint256) view returns (string name, uint256 multiplier, uint256 maxSupply, uint256 minted, uint256 price, address dao)",
|
|
@@ -6931,6 +6945,7 @@ var require_factory = __commonJS({
|
|
|
6931
6945
|
var { Contract, Interface, getAddress } = __require("ethers");
|
|
6932
6946
|
var ABI = require_abi();
|
|
6933
6947
|
var { SageSDKError, CODES } = require_errors();
|
|
6948
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
6934
6949
|
function normalise(address, label) {
|
|
6935
6950
|
if (!address) throw new SageSDKError(CODES.INVALID_ARGS, `${label} required`);
|
|
6936
6951
|
try {
|
|
@@ -6939,6 +6954,14 @@ var require_factory = __commonJS({
|
|
|
6939
6954
|
throw new SageSDKError(CODES.INVALID_ARGS, `invalid ${label}`, { cause: err });
|
|
6940
6955
|
}
|
|
6941
6956
|
}
|
|
6957
|
+
function normaliseNonZero(address, label) {
|
|
6958
|
+
const addr = normalise(address, label);
|
|
6959
|
+
if (addr === ZERO_ADDRESS) {
|
|
6960
|
+
const hint = label === "operatorAdmin" ? " (set it explicitly; it may be the same as operatorExecutor)" : "";
|
|
6961
|
+
throw new SageSDKError(CODES.INVALID_ARGS, `${label} cannot be zero address${hint}`);
|
|
6962
|
+
}
|
|
6963
|
+
return addr;
|
|
6964
|
+
}
|
|
6942
6965
|
async function getFactoryConfig({ provider, factory }) {
|
|
6943
6966
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
6944
6967
|
const addr = normalise(factory, "factory");
|
|
@@ -6952,7 +6975,6 @@ var require_factory = __commonJS({
|
|
|
6952
6975
|
allowStableForkFee,
|
|
6953
6976
|
timelockMinDelay,
|
|
6954
6977
|
premiumPromptsAddress,
|
|
6955
|
-
simpleKeyStoreAddress,
|
|
6956
6978
|
governanceConfigAddress,
|
|
6957
6979
|
libraryRegistryAddress,
|
|
6958
6980
|
templateModule
|
|
@@ -6975,7 +6997,6 @@ var require_factory = __commonJS({
|
|
|
6975
6997
|
contract.allowStableForkFee().catch(() => null),
|
|
6976
6998
|
contract.timelockMinDelay().catch(() => null),
|
|
6977
6999
|
contract.premiumPromptsAddress().catch(() => null),
|
|
6978
|
-
contract.simpleKeyStoreAddress().catch(() => null),
|
|
6979
7000
|
contract.governanceConfigAddress().catch(() => null),
|
|
6980
7001
|
contract.libraryRegistryAddress().catch(() => null),
|
|
6981
7002
|
contract.templateModule().catch(() => null)
|
|
@@ -6990,7 +7011,6 @@ var require_factory = __commonJS({
|
|
|
6990
7011
|
allowStableForkFee,
|
|
6991
7012
|
timelockMinDelay,
|
|
6992
7013
|
premiumPromptsAddress: premiumPromptsAddress && premiumPromptsAddress !== "0x0000000000000000000000000000000000000000" ? getAddress(premiumPromptsAddress) : null,
|
|
6993
|
-
simpleKeyStoreAddress: simpleKeyStoreAddress && simpleKeyStoreAddress !== "0x0000000000000000000000000000000000000000" ? getAddress(simpleKeyStoreAddress) : null,
|
|
6994
7014
|
governanceConfigAddress: governanceConfigAddress && governanceConfigAddress !== "0x0000000000000000000000000000000000000000" ? getAddress(governanceConfigAddress) : null,
|
|
6995
7015
|
libraryRegistryAddress: libraryRegistryAddress && libraryRegistryAddress !== "0x0000000000000000000000000000000000000000" ? getAddress(libraryRegistryAddress) : null,
|
|
6996
7016
|
templateModule: templateModule ? getAddress(templateModule) : null
|
|
@@ -7204,7 +7224,7 @@ var require_factory = __commonJS({
|
|
|
7204
7224
|
0n,
|
|
7205
7225
|
// minStakeAmount deprecated
|
|
7206
7226
|
normalise(operatorExecutor, "operatorExecutor"),
|
|
7207
|
-
|
|
7227
|
+
normaliseNonZero(operatorAdmin, "operatorAdmin"),
|
|
7208
7228
|
tuple
|
|
7209
7229
|
]);
|
|
7210
7230
|
return { to: addr, data: payload, value: 0n };
|
|
@@ -7236,7 +7256,7 @@ var require_factory = __commonJS({
|
|
|
7236
7256
|
0n,
|
|
7237
7257
|
// minStakeAmount deprecated
|
|
7238
7258
|
normalise(operatorExecutor, "operatorExecutor"),
|
|
7239
|
-
|
|
7259
|
+
normaliseNonZero(operatorAdmin, "operatorAdmin"),
|
|
7240
7260
|
Boolean(anyoneExec),
|
|
7241
7261
|
Boolean(governorProposer),
|
|
7242
7262
|
tuple
|
|
@@ -9457,70 +9477,145 @@ var require_boost = __commonJS({
|
|
|
9457
9477
|
throw new SageSDKError(CODES.RPC_ERROR, "failed to normalise bigint", { cause: err });
|
|
9458
9478
|
}
|
|
9459
9479
|
}
|
|
9460
|
-
|
|
9480
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
9481
|
+
async function getMerkleBoost({ provider, manager, proposalId }) {
|
|
9461
9482
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
9462
9483
|
const addr = normalise(manager, "manager");
|
|
9463
9484
|
const contract = new Contract(addr, ABI.GovernanceBoostMerkle, provider);
|
|
9464
|
-
const
|
|
9465
|
-
if (!
|
|
9485
|
+
const result = await contract.getBoost(proposalId).catch(() => null);
|
|
9486
|
+
if (!result) return null;
|
|
9487
|
+
const [totalPool, totalClaimed, merkleRoot, active, finalized, creator] = result;
|
|
9488
|
+
const creatorAddr = creator ? getAddress(creator) : ZERO_ADDRESS;
|
|
9489
|
+
const pool = toBigInt(totalPool);
|
|
9490
|
+
if (!active && !finalized && pool === 0n && creatorAddr === ZERO_ADDRESS) return null;
|
|
9466
9491
|
return {
|
|
9467
9492
|
manager: addr,
|
|
9468
|
-
proposalId: Number(
|
|
9469
|
-
|
|
9470
|
-
|
|
9471
|
-
|
|
9472
|
-
|
|
9473
|
-
|
|
9493
|
+
proposalId: Number(proposalId),
|
|
9494
|
+
totalPool: pool,
|
|
9495
|
+
totalClaimed: toBigInt(totalClaimed),
|
|
9496
|
+
merkleRoot,
|
|
9497
|
+
active: Boolean(active),
|
|
9498
|
+
finalized: Boolean(finalized),
|
|
9499
|
+
creator: creatorAddr
|
|
9474
9500
|
};
|
|
9475
9501
|
}
|
|
9476
|
-
function
|
|
9502
|
+
function buildMerkleCreateTx({ manager, proposalId, totalPool, amount }) {
|
|
9503
|
+
const addr = normalise(manager, "manager");
|
|
9504
|
+
const pool = totalPool ?? amount;
|
|
9505
|
+
const data = MerkleInterface.encodeFunctionData("createBoost", [Number(proposalId), BigInt(pool ?? 0n)]);
|
|
9506
|
+
return { to: addr, data, value: 0n };
|
|
9507
|
+
}
|
|
9508
|
+
function buildMerkleSetMerkleRootTx({ manager, proposalId, root, merkleRoot }) {
|
|
9509
|
+
const addr = normalise(manager, "manager");
|
|
9510
|
+
const nextRoot = root ?? merkleRoot;
|
|
9511
|
+
const data = MerkleInterface.encodeFunctionData("setMerkleRoot", [Number(proposalId), nextRoot]);
|
|
9512
|
+
return { to: addr, data, value: 0n };
|
|
9513
|
+
}
|
|
9514
|
+
function buildMerkleFinalizeTx({ manager, proposalId }) {
|
|
9477
9515
|
const addr = normalise(manager, "manager");
|
|
9478
|
-
const data = MerkleInterface.encodeFunctionData("
|
|
9516
|
+
const data = MerkleInterface.encodeFunctionData("finalize", [Number(proposalId)]);
|
|
9479
9517
|
return { to: addr, data, value: 0n };
|
|
9480
9518
|
}
|
|
9481
|
-
function
|
|
9519
|
+
function buildMerkleClaimTx({ manager, proposalId, account, amount, proof }) {
|
|
9482
9520
|
const addr = normalise(manager, "manager");
|
|
9483
|
-
const data = MerkleInterface.encodeFunctionData("
|
|
9521
|
+
const data = MerkleInterface.encodeFunctionData("claim", [
|
|
9522
|
+
Number(proposalId),
|
|
9523
|
+
normalise(account, "account"),
|
|
9524
|
+
BigInt(amount ?? 0n),
|
|
9525
|
+
proof || []
|
|
9526
|
+
]);
|
|
9484
9527
|
return { to: addr, data, value: 0n };
|
|
9485
9528
|
}
|
|
9486
|
-
async function
|
|
9529
|
+
async function getDirectBoost({ provider, manager, proposalId }) {
|
|
9487
9530
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
9488
9531
|
const addr = normalise(manager, "manager");
|
|
9489
9532
|
const contract = new Contract(addr, ABI.GovernanceBoostDirect, provider);
|
|
9490
|
-
const
|
|
9491
|
-
if (!
|
|
9533
|
+
const boost = await contract.getBoost(proposalId).catch(() => null);
|
|
9534
|
+
if (!boost) return null;
|
|
9535
|
+
const creatorAddr = boost.creator ? getAddress(boost.creator) : ZERO_ADDRESS;
|
|
9536
|
+
const pool = toBigInt(boost.totalPool);
|
|
9537
|
+
if (!boost.active && pool === 0n && creatorAddr === ZERO_ADDRESS) return null;
|
|
9492
9538
|
return {
|
|
9493
9539
|
manager: addr,
|
|
9494
|
-
proposalId: Number(
|
|
9495
|
-
|
|
9496
|
-
|
|
9497
|
-
|
|
9498
|
-
|
|
9499
|
-
|
|
9540
|
+
proposalId: Number(boost.proposalId ?? proposalId),
|
|
9541
|
+
creator: creatorAddr,
|
|
9542
|
+
governor: boost.governor ? getAddress(boost.governor) : null,
|
|
9543
|
+
snapshot: toBigInt(boost.snapshot),
|
|
9544
|
+
perVoter: toBigInt(boost.perVoter),
|
|
9545
|
+
maxVoters: toBigInt(boost.maxVoters),
|
|
9546
|
+
votersPaid: toBigInt(boost.votersPaid),
|
|
9547
|
+
minVotes: toBigInt(boost.minVotes),
|
|
9548
|
+
payoutMode: Number(boost.payoutMode ?? 0),
|
|
9549
|
+
support: Number(boost.support ?? 0),
|
|
9550
|
+
startAt: Number(boost.startAt ?? 0),
|
|
9551
|
+
expiresAt: Number(boost.expiresAt ?? 0),
|
|
9552
|
+
totalPool: pool,
|
|
9553
|
+
totalPaid: toBigInt(boost.totalPaid),
|
|
9554
|
+
kind: Number(boost.kind ?? 0),
|
|
9555
|
+
policy: boost.policy ? getAddress(boost.policy) : null,
|
|
9556
|
+
active: Boolean(boost.active),
|
|
9557
|
+
paused: Boolean(boost.paused)
|
|
9500
9558
|
};
|
|
9501
9559
|
}
|
|
9502
|
-
function buildDirectCreateTx({
|
|
9560
|
+
function buildDirectCreateTx({
|
|
9561
|
+
manager,
|
|
9562
|
+
governor,
|
|
9563
|
+
proposalId,
|
|
9564
|
+
perVoter,
|
|
9565
|
+
maxVoters,
|
|
9566
|
+
kind = 0,
|
|
9567
|
+
policy = ZERO_ADDRESS,
|
|
9568
|
+
minVotes = 0n,
|
|
9569
|
+
payoutMode = 0,
|
|
9570
|
+
support = 0,
|
|
9571
|
+
startAt = 0n,
|
|
9572
|
+
expiresAt = 0n
|
|
9573
|
+
}) {
|
|
9503
9574
|
const addr = normalise(manager, "manager");
|
|
9504
|
-
const
|
|
9505
|
-
|
|
9506
|
-
|
|
9575
|
+
const params = [
|
|
9576
|
+
normalise(governor, "governor"),
|
|
9577
|
+
BigInt(proposalId ?? 0n),
|
|
9507
9578
|
BigInt(perVoter ?? 0n),
|
|
9508
|
-
BigInt(maxVoters ?? 0n)
|
|
9509
|
-
|
|
9579
|
+
BigInt(maxVoters ?? 0n),
|
|
9580
|
+
Number(kind),
|
|
9581
|
+
policy ? normalise(policy, "policy") : ZERO_ADDRESS,
|
|
9582
|
+
BigInt(minVotes ?? 0n),
|
|
9583
|
+
Number(payoutMode),
|
|
9584
|
+
Number(support),
|
|
9585
|
+
BigInt(startAt ?? 0n),
|
|
9586
|
+
BigInt(expiresAt ?? 0n)
|
|
9587
|
+
];
|
|
9588
|
+
const data = DirectInterface.encodeFunctionData("createBoost", [params]);
|
|
9510
9589
|
return { to: addr, data, value: 0n };
|
|
9511
9590
|
}
|
|
9512
|
-
function
|
|
9591
|
+
function buildDirectClaimTx({ manager, proposalId, data = "0x" }) {
|
|
9513
9592
|
const addr = normalise(manager, "manager");
|
|
9514
|
-
const
|
|
9593
|
+
const callData = DirectInterface.encodeFunctionData("claim", [BigInt(proposalId ?? 0n), data]);
|
|
9594
|
+
return { to: addr, data: callData, value: 0n };
|
|
9595
|
+
}
|
|
9596
|
+
function buildDirectFinalizeTx({ manager, proposalId }) {
|
|
9597
|
+
const addr = normalise(manager, "manager");
|
|
9598
|
+
const data = DirectInterface.encodeFunctionData("finalize", [BigInt(proposalId ?? 0n)]);
|
|
9515
9599
|
return { to: addr, data, value: 0n };
|
|
9516
9600
|
}
|
|
9517
9601
|
module2.exports = {
|
|
9518
|
-
|
|
9519
|
-
|
|
9520
|
-
|
|
9521
|
-
|
|
9602
|
+
// Merkle manager (GovernanceBoostManagerMerkle)
|
|
9603
|
+
getMerkleBoost,
|
|
9604
|
+
buildMerkleCreateTx,
|
|
9605
|
+
buildMerkleSetMerkleRootTx,
|
|
9606
|
+
buildMerkleFinalizeTx,
|
|
9607
|
+
buildMerkleClaimTx,
|
|
9608
|
+
// Legacy names (back-compat)
|
|
9609
|
+
getMerkleConfig: getMerkleBoost,
|
|
9610
|
+
buildMerkleFundTx: buildMerkleCreateTx,
|
|
9611
|
+
buildMerkleSetRootTx: buildMerkleSetMerkleRootTx,
|
|
9612
|
+
// Direct manager (GovernanceBoostManager)
|
|
9613
|
+
getDirectBoost,
|
|
9522
9614
|
buildDirectCreateTx,
|
|
9523
|
-
|
|
9615
|
+
buildDirectClaimTx,
|
|
9616
|
+
buildDirectFinalizeTx,
|
|
9617
|
+
// Legacy name (back-compat)
|
|
9618
|
+
getDirectConfig: getDirectBoost
|
|
9524
9619
|
};
|
|
9525
9620
|
}
|
|
9526
9621
|
});
|
|
@@ -12030,20 +12125,6 @@ ${error}` : ""}`;
|
|
|
12030
12125
|
const price = d[2].toString();
|
|
12031
12126
|
const manifest = d[3];
|
|
12032
12127
|
return { signature: sig, args: [hash, subdao, price, `"${manifest}"`] };
|
|
12033
|
-
} else if (data.startsWith(__require("ethers").id("setWrappedKey(bytes32,bytes,bytes32)").slice(0, 10))) {
|
|
12034
|
-
const { ethers: ethers2 } = __require("ethers");
|
|
12035
|
-
const sig = "setWrappedKey(bytes32,bytes,bytes32)";
|
|
12036
|
-
const iface = new ethers2.Interface([`function ${sig}`]);
|
|
12037
|
-
const d = iface.decodeFunctionData("setWrappedKey", data);
|
|
12038
|
-
const cidHash = d[0];
|
|
12039
|
-
const wrapped = d[1];
|
|
12040
|
-
const wrapperId = d[2];
|
|
12041
|
-
return { signature: sig, args: [cidHash, wrapped, wrapperId] };
|
|
12042
|
-
} else if (data.startsWith(__require("ethers").id("lockKey(bytes32)").slice(0, 10))) {
|
|
12043
|
-
const { ethers: ethers2 } = __require("ethers");
|
|
12044
|
-
const iface = new ethers2.Interface(["function lockKey(bytes32)"]);
|
|
12045
|
-
const d = iface.decodeFunctionData("lockKey", data);
|
|
12046
|
-
return { signature: "lockKey(bytes32)", args: [d[0]] };
|
|
12047
12128
|
} else if (data.startsWith(__require("ethers").id("claim(uint256,address,uint256,bytes32[])").slice(0, 10))) {
|
|
12048
12129
|
const { ethers: ethers2 } = __require("ethers");
|
|
12049
12130
|
const sig = "claim(uint256,address,uint256,bytes32[])";
|
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.2.
|
|
17
|
+
version: "0.2.8",
|
|
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",
|
|
@@ -140,7 +140,6 @@ var require_abi = __commonJS({
|
|
|
140
140
|
// Core factory reads
|
|
141
141
|
"function timelockMinDelay() view returns (uint256)",
|
|
142
142
|
"function premiumPromptsAddress() view returns (address)",
|
|
143
|
-
"function simpleKeyStoreAddress() view returns (address)",
|
|
144
143
|
"function governanceConfigAddress() view returns (address)",
|
|
145
144
|
"function libraryRegistryAddress() view returns (address)",
|
|
146
145
|
// Canonical per‑SubDAO mapping
|
|
@@ -327,14 +326,28 @@ var require_abi = __commonJS({
|
|
|
327
326
|
"event TokensSwept(address indexed token, address indexed to, uint256 amount)"
|
|
328
327
|
];
|
|
329
328
|
var GovernanceBoostMerkle = [
|
|
330
|
-
"function
|
|
331
|
-
"function
|
|
332
|
-
"function
|
|
329
|
+
"function createBoost(uint256 proposalId, uint256 totalPool)",
|
|
330
|
+
"function setMerkleRoot(uint256 proposalId, bytes32 root)",
|
|
331
|
+
"function finalize(uint256 proposalId)",
|
|
332
|
+
"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 claimed(uint256 proposalId, address account) view returns (bool)",
|
|
335
|
+
"event BoostCreated(uint256 indexed proposalId, address indexed creator, uint256 totalPool)",
|
|
336
|
+
"event MerkleRootSet(uint256 indexed proposalId, bytes32 merkleRoot)",
|
|
337
|
+
"event RewardClaimed(uint256 indexed proposalId, address indexed voter, uint256 amount)",
|
|
338
|
+
"event BoostFinalized(uint256 indexed proposalId, uint256 totalClaimed, uint256 refunded)"
|
|
333
339
|
];
|
|
334
340
|
var GovernanceBoostDirect = [
|
|
335
|
-
"function
|
|
336
|
-
"function
|
|
337
|
-
"function
|
|
341
|
+
"function createBoost((address governor,uint256 proposalId,uint256 perVoter,uint256 maxVoters,uint8 kind,address policy,uint96 minVotes,uint8 payoutMode,uint8 support,uint256 startAt,uint256 expiresAt) params)",
|
|
342
|
+
"function claim(uint256 proposalId, bytes data)",
|
|
343
|
+
"function finalize(uint256 proposalId)",
|
|
344
|
+
"function pause(uint256 proposalId, bool paused)",
|
|
345
|
+
"function setProtocolRake(uint96 rakeBps, address protocolTreasury)",
|
|
346
|
+
"function getBoost(uint256 proposalId) view returns (tuple(address creator, address governor, uint256 proposalId, uint256 snapshot, uint256 perVoter, uint256 maxVoters, uint256 votersPaid, uint96 minVotes, uint8 payoutMode, uint8 support, uint256 startAt, uint256 expiresAt, uint256 totalPool, uint256 totalPaid, uint8 kind, address policy, bool active, bool paused) boost)",
|
|
347
|
+
"function claimed(uint256 proposalId, address account) view returns (bool)",
|
|
348
|
+
"event BoostCreated(uint256 indexed proposalId, address indexed governor, uint256 perVoter, uint256 maxVoters, uint256 snapshot, uint8 kind, address policy, uint96 minVotes)",
|
|
349
|
+
"event BoostClaimed(uint256 indexed proposalId, address indexed claimer, uint256 amount, uint256 rake)",
|
|
350
|
+
"event BoostFinalized(uint256 indexed proposalId, uint256 paidCount, uint256 refund)"
|
|
338
351
|
];
|
|
339
352
|
var VotingMultiplierNFT = [
|
|
340
353
|
// Constants
|
|
@@ -342,6 +355,7 @@ var require_abi = __commonJS({
|
|
|
342
355
|
"function MAX_NFTS_PER_ACCOUNT() view returns (uint256)",
|
|
343
356
|
// Tier Management
|
|
344
357
|
"function createTier(address dao, string name, uint256 multiplier, uint256 maxSupply, uint256 price) returns (uint256 tierId)",
|
|
358
|
+
"function createTierViaGovernance(address subdao, string name, uint256 multiplier, uint256 maxSupply, uint256 price) returns (uint256 tierId)",
|
|
345
359
|
"function getTier(uint256 tierId) view returns (tuple(string name, uint256 multiplier, uint256 maxSupply, uint256 minted, uint256 price, address dao))",
|
|
346
360
|
"function tierCount() view returns (uint256)",
|
|
347
361
|
"function tiers(uint256) view returns (string name, uint256 multiplier, uint256 maxSupply, uint256 minted, uint256 price, address dao)",
|
|
@@ -6925,6 +6939,7 @@ var require_factory = __commonJS({
|
|
|
6925
6939
|
var { Contract, Interface, getAddress } = require("ethers");
|
|
6926
6940
|
var ABI = require_abi();
|
|
6927
6941
|
var { SageSDKError, CODES } = require_errors();
|
|
6942
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
6928
6943
|
function normalise(address, label) {
|
|
6929
6944
|
if (!address) throw new SageSDKError(CODES.INVALID_ARGS, `${label} required`);
|
|
6930
6945
|
try {
|
|
@@ -6933,6 +6948,14 @@ var require_factory = __commonJS({
|
|
|
6933
6948
|
throw new SageSDKError(CODES.INVALID_ARGS, `invalid ${label}`, { cause: err });
|
|
6934
6949
|
}
|
|
6935
6950
|
}
|
|
6951
|
+
function normaliseNonZero(address, label) {
|
|
6952
|
+
const addr = normalise(address, label);
|
|
6953
|
+
if (addr === ZERO_ADDRESS) {
|
|
6954
|
+
const hint = label === "operatorAdmin" ? " (set it explicitly; it may be the same as operatorExecutor)" : "";
|
|
6955
|
+
throw new SageSDKError(CODES.INVALID_ARGS, `${label} cannot be zero address${hint}`);
|
|
6956
|
+
}
|
|
6957
|
+
return addr;
|
|
6958
|
+
}
|
|
6936
6959
|
async function getFactoryConfig({ provider, factory }) {
|
|
6937
6960
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
6938
6961
|
const addr = normalise(factory, "factory");
|
|
@@ -6946,7 +6969,6 @@ var require_factory = __commonJS({
|
|
|
6946
6969
|
allowStableForkFee,
|
|
6947
6970
|
timelockMinDelay,
|
|
6948
6971
|
premiumPromptsAddress,
|
|
6949
|
-
simpleKeyStoreAddress,
|
|
6950
6972
|
governanceConfigAddress,
|
|
6951
6973
|
libraryRegistryAddress,
|
|
6952
6974
|
templateModule
|
|
@@ -6969,7 +6991,6 @@ var require_factory = __commonJS({
|
|
|
6969
6991
|
contract.allowStableForkFee().catch(() => null),
|
|
6970
6992
|
contract.timelockMinDelay().catch(() => null),
|
|
6971
6993
|
contract.premiumPromptsAddress().catch(() => null),
|
|
6972
|
-
contract.simpleKeyStoreAddress().catch(() => null),
|
|
6973
6994
|
contract.governanceConfigAddress().catch(() => null),
|
|
6974
6995
|
contract.libraryRegistryAddress().catch(() => null),
|
|
6975
6996
|
contract.templateModule().catch(() => null)
|
|
@@ -6984,7 +7005,6 @@ var require_factory = __commonJS({
|
|
|
6984
7005
|
allowStableForkFee,
|
|
6985
7006
|
timelockMinDelay,
|
|
6986
7007
|
premiumPromptsAddress: premiumPromptsAddress && premiumPromptsAddress !== "0x0000000000000000000000000000000000000000" ? getAddress(premiumPromptsAddress) : null,
|
|
6987
|
-
simpleKeyStoreAddress: simpleKeyStoreAddress && simpleKeyStoreAddress !== "0x0000000000000000000000000000000000000000" ? getAddress(simpleKeyStoreAddress) : null,
|
|
6988
7008
|
governanceConfigAddress: governanceConfigAddress && governanceConfigAddress !== "0x0000000000000000000000000000000000000000" ? getAddress(governanceConfigAddress) : null,
|
|
6989
7009
|
libraryRegistryAddress: libraryRegistryAddress && libraryRegistryAddress !== "0x0000000000000000000000000000000000000000" ? getAddress(libraryRegistryAddress) : null,
|
|
6990
7010
|
templateModule: templateModule ? getAddress(templateModule) : null
|
|
@@ -7198,7 +7218,7 @@ var require_factory = __commonJS({
|
|
|
7198
7218
|
0n,
|
|
7199
7219
|
// minStakeAmount deprecated
|
|
7200
7220
|
normalise(operatorExecutor, "operatorExecutor"),
|
|
7201
|
-
|
|
7221
|
+
normaliseNonZero(operatorAdmin, "operatorAdmin"),
|
|
7202
7222
|
tuple
|
|
7203
7223
|
]);
|
|
7204
7224
|
return { to: addr, data: payload, value: 0n };
|
|
@@ -7230,7 +7250,7 @@ var require_factory = __commonJS({
|
|
|
7230
7250
|
0n,
|
|
7231
7251
|
// minStakeAmount deprecated
|
|
7232
7252
|
normalise(operatorExecutor, "operatorExecutor"),
|
|
7233
|
-
|
|
7253
|
+
normaliseNonZero(operatorAdmin, "operatorAdmin"),
|
|
7234
7254
|
Boolean(anyoneExec),
|
|
7235
7255
|
Boolean(governorProposer),
|
|
7236
7256
|
tuple
|
|
@@ -9451,70 +9471,145 @@ var require_boost = __commonJS({
|
|
|
9451
9471
|
throw new SageSDKError(CODES.RPC_ERROR, "failed to normalise bigint", { cause: err });
|
|
9452
9472
|
}
|
|
9453
9473
|
}
|
|
9454
|
-
|
|
9474
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
9475
|
+
async function getMerkleBoost({ provider, manager, proposalId }) {
|
|
9455
9476
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
9456
9477
|
const addr = normalise(manager, "manager");
|
|
9457
9478
|
const contract = new Contract(addr, ABI.GovernanceBoostMerkle, provider);
|
|
9458
|
-
const
|
|
9459
|
-
if (!
|
|
9479
|
+
const result = await contract.getBoost(proposalId).catch(() => null);
|
|
9480
|
+
if (!result) return null;
|
|
9481
|
+
const [totalPool, totalClaimed, merkleRoot, active, finalized, creator] = result;
|
|
9482
|
+
const creatorAddr = creator ? getAddress(creator) : ZERO_ADDRESS;
|
|
9483
|
+
const pool = toBigInt(totalPool);
|
|
9484
|
+
if (!active && !finalized && pool === 0n && creatorAddr === ZERO_ADDRESS) return null;
|
|
9460
9485
|
return {
|
|
9461
9486
|
manager: addr,
|
|
9462
|
-
proposalId: Number(
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
|
|
9466
|
-
|
|
9467
|
-
|
|
9487
|
+
proposalId: Number(proposalId),
|
|
9488
|
+
totalPool: pool,
|
|
9489
|
+
totalClaimed: toBigInt(totalClaimed),
|
|
9490
|
+
merkleRoot,
|
|
9491
|
+
active: Boolean(active),
|
|
9492
|
+
finalized: Boolean(finalized),
|
|
9493
|
+
creator: creatorAddr
|
|
9468
9494
|
};
|
|
9469
9495
|
}
|
|
9470
|
-
function
|
|
9496
|
+
function buildMerkleCreateTx({ manager, proposalId, totalPool, amount }) {
|
|
9497
|
+
const addr = normalise(manager, "manager");
|
|
9498
|
+
const pool = totalPool ?? amount;
|
|
9499
|
+
const data = MerkleInterface.encodeFunctionData("createBoost", [Number(proposalId), BigInt(pool ?? 0n)]);
|
|
9500
|
+
return { to: addr, data, value: 0n };
|
|
9501
|
+
}
|
|
9502
|
+
function buildMerkleSetMerkleRootTx({ manager, proposalId, root, merkleRoot }) {
|
|
9503
|
+
const addr = normalise(manager, "manager");
|
|
9504
|
+
const nextRoot = root ?? merkleRoot;
|
|
9505
|
+
const data = MerkleInterface.encodeFunctionData("setMerkleRoot", [Number(proposalId), nextRoot]);
|
|
9506
|
+
return { to: addr, data, value: 0n };
|
|
9507
|
+
}
|
|
9508
|
+
function buildMerkleFinalizeTx({ manager, proposalId }) {
|
|
9471
9509
|
const addr = normalise(manager, "manager");
|
|
9472
|
-
const data = MerkleInterface.encodeFunctionData("
|
|
9510
|
+
const data = MerkleInterface.encodeFunctionData("finalize", [Number(proposalId)]);
|
|
9473
9511
|
return { to: addr, data, value: 0n };
|
|
9474
9512
|
}
|
|
9475
|
-
function
|
|
9513
|
+
function buildMerkleClaimTx({ manager, proposalId, account, amount, proof }) {
|
|
9476
9514
|
const addr = normalise(manager, "manager");
|
|
9477
|
-
const data = MerkleInterface.encodeFunctionData("
|
|
9515
|
+
const data = MerkleInterface.encodeFunctionData("claim", [
|
|
9516
|
+
Number(proposalId),
|
|
9517
|
+
normalise(account, "account"),
|
|
9518
|
+
BigInt(amount ?? 0n),
|
|
9519
|
+
proof || []
|
|
9520
|
+
]);
|
|
9478
9521
|
return { to: addr, data, value: 0n };
|
|
9479
9522
|
}
|
|
9480
|
-
async function
|
|
9523
|
+
async function getDirectBoost({ provider, manager, proposalId }) {
|
|
9481
9524
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
9482
9525
|
const addr = normalise(manager, "manager");
|
|
9483
9526
|
const contract = new Contract(addr, ABI.GovernanceBoostDirect, provider);
|
|
9484
|
-
const
|
|
9485
|
-
if (!
|
|
9527
|
+
const boost = await contract.getBoost(proposalId).catch(() => null);
|
|
9528
|
+
if (!boost) return null;
|
|
9529
|
+
const creatorAddr = boost.creator ? getAddress(boost.creator) : ZERO_ADDRESS;
|
|
9530
|
+
const pool = toBigInt(boost.totalPool);
|
|
9531
|
+
if (!boost.active && pool === 0n && creatorAddr === ZERO_ADDRESS) return null;
|
|
9486
9532
|
return {
|
|
9487
9533
|
manager: addr,
|
|
9488
|
-
proposalId: Number(
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9492
|
-
|
|
9493
|
-
|
|
9534
|
+
proposalId: Number(boost.proposalId ?? proposalId),
|
|
9535
|
+
creator: creatorAddr,
|
|
9536
|
+
governor: boost.governor ? getAddress(boost.governor) : null,
|
|
9537
|
+
snapshot: toBigInt(boost.snapshot),
|
|
9538
|
+
perVoter: toBigInt(boost.perVoter),
|
|
9539
|
+
maxVoters: toBigInt(boost.maxVoters),
|
|
9540
|
+
votersPaid: toBigInt(boost.votersPaid),
|
|
9541
|
+
minVotes: toBigInt(boost.minVotes),
|
|
9542
|
+
payoutMode: Number(boost.payoutMode ?? 0),
|
|
9543
|
+
support: Number(boost.support ?? 0),
|
|
9544
|
+
startAt: Number(boost.startAt ?? 0),
|
|
9545
|
+
expiresAt: Number(boost.expiresAt ?? 0),
|
|
9546
|
+
totalPool: pool,
|
|
9547
|
+
totalPaid: toBigInt(boost.totalPaid),
|
|
9548
|
+
kind: Number(boost.kind ?? 0),
|
|
9549
|
+
policy: boost.policy ? getAddress(boost.policy) : null,
|
|
9550
|
+
active: Boolean(boost.active),
|
|
9551
|
+
paused: Boolean(boost.paused)
|
|
9494
9552
|
};
|
|
9495
9553
|
}
|
|
9496
|
-
function buildDirectCreateTx({
|
|
9554
|
+
function buildDirectCreateTx({
|
|
9555
|
+
manager,
|
|
9556
|
+
governor,
|
|
9557
|
+
proposalId,
|
|
9558
|
+
perVoter,
|
|
9559
|
+
maxVoters,
|
|
9560
|
+
kind = 0,
|
|
9561
|
+
policy = ZERO_ADDRESS,
|
|
9562
|
+
minVotes = 0n,
|
|
9563
|
+
payoutMode = 0,
|
|
9564
|
+
support = 0,
|
|
9565
|
+
startAt = 0n,
|
|
9566
|
+
expiresAt = 0n
|
|
9567
|
+
}) {
|
|
9497
9568
|
const addr = normalise(manager, "manager");
|
|
9498
|
-
const
|
|
9499
|
-
|
|
9500
|
-
|
|
9569
|
+
const params = [
|
|
9570
|
+
normalise(governor, "governor"),
|
|
9571
|
+
BigInt(proposalId ?? 0n),
|
|
9501
9572
|
BigInt(perVoter ?? 0n),
|
|
9502
|
-
BigInt(maxVoters ?? 0n)
|
|
9503
|
-
|
|
9573
|
+
BigInt(maxVoters ?? 0n),
|
|
9574
|
+
Number(kind),
|
|
9575
|
+
policy ? normalise(policy, "policy") : ZERO_ADDRESS,
|
|
9576
|
+
BigInt(minVotes ?? 0n),
|
|
9577
|
+
Number(payoutMode),
|
|
9578
|
+
Number(support),
|
|
9579
|
+
BigInt(startAt ?? 0n),
|
|
9580
|
+
BigInt(expiresAt ?? 0n)
|
|
9581
|
+
];
|
|
9582
|
+
const data = DirectInterface.encodeFunctionData("createBoost", [params]);
|
|
9504
9583
|
return { to: addr, data, value: 0n };
|
|
9505
9584
|
}
|
|
9506
|
-
function
|
|
9585
|
+
function buildDirectClaimTx({ manager, proposalId, data = "0x" }) {
|
|
9507
9586
|
const addr = normalise(manager, "manager");
|
|
9508
|
-
const
|
|
9587
|
+
const callData = DirectInterface.encodeFunctionData("claim", [BigInt(proposalId ?? 0n), data]);
|
|
9588
|
+
return { to: addr, data: callData, value: 0n };
|
|
9589
|
+
}
|
|
9590
|
+
function buildDirectFinalizeTx({ manager, proposalId }) {
|
|
9591
|
+
const addr = normalise(manager, "manager");
|
|
9592
|
+
const data = DirectInterface.encodeFunctionData("finalize", [BigInt(proposalId ?? 0n)]);
|
|
9509
9593
|
return { to: addr, data, value: 0n };
|
|
9510
9594
|
}
|
|
9511
9595
|
module2.exports = {
|
|
9512
|
-
|
|
9513
|
-
|
|
9514
|
-
|
|
9515
|
-
|
|
9596
|
+
// Merkle manager (GovernanceBoostManagerMerkle)
|
|
9597
|
+
getMerkleBoost,
|
|
9598
|
+
buildMerkleCreateTx,
|
|
9599
|
+
buildMerkleSetMerkleRootTx,
|
|
9600
|
+
buildMerkleFinalizeTx,
|
|
9601
|
+
buildMerkleClaimTx,
|
|
9602
|
+
// Legacy names (back-compat)
|
|
9603
|
+
getMerkleConfig: getMerkleBoost,
|
|
9604
|
+
buildMerkleFundTx: buildMerkleCreateTx,
|
|
9605
|
+
buildMerkleSetRootTx: buildMerkleSetMerkleRootTx,
|
|
9606
|
+
// Direct manager (GovernanceBoostManager)
|
|
9607
|
+
getDirectBoost,
|
|
9516
9608
|
buildDirectCreateTx,
|
|
9517
|
-
|
|
9609
|
+
buildDirectClaimTx,
|
|
9610
|
+
buildDirectFinalizeTx,
|
|
9611
|
+
// Legacy name (back-compat)
|
|
9612
|
+
getDirectConfig: getDirectBoost
|
|
9518
9613
|
};
|
|
9519
9614
|
}
|
|
9520
9615
|
});
|
|
@@ -12024,20 +12119,6 @@ ${error}` : ""}`;
|
|
|
12024
12119
|
const price = d[2].toString();
|
|
12025
12120
|
const manifest = d[3];
|
|
12026
12121
|
return { signature: sig, args: [hash, subdao, price, `"${manifest}"`] };
|
|
12027
|
-
} else if (data.startsWith(require("ethers").id("setWrappedKey(bytes32,bytes,bytes32)").slice(0, 10))) {
|
|
12028
|
-
const { ethers: ethers2 } = require("ethers");
|
|
12029
|
-
const sig = "setWrappedKey(bytes32,bytes,bytes32)";
|
|
12030
|
-
const iface = new ethers2.Interface([`function ${sig}`]);
|
|
12031
|
-
const d = iface.decodeFunctionData("setWrappedKey", data);
|
|
12032
|
-
const cidHash = d[0];
|
|
12033
|
-
const wrapped = d[1];
|
|
12034
|
-
const wrapperId = d[2];
|
|
12035
|
-
return { signature: sig, args: [cidHash, wrapped, wrapperId] };
|
|
12036
|
-
} else if (data.startsWith(require("ethers").id("lockKey(bytes32)").slice(0, 10))) {
|
|
12037
|
-
const { ethers: ethers2 } = require("ethers");
|
|
12038
|
-
const iface = new ethers2.Interface(["function lockKey(bytes32)"]);
|
|
12039
|
-
const d = iface.decodeFunctionData("lockKey", data);
|
|
12040
|
-
return { signature: "lockKey(bytes32)", args: [d[0]] };
|
|
12041
12122
|
} else if (data.startsWith(require("ethers").id("claim(uint256,address,uint256,bytes32[])").slice(0, 10))) {
|
|
12042
12123
|
const { ethers: ethers2 } = require("ethers");
|
|
12043
12124
|
const sig = "claim(uint256,address,uint256,bytes32[])";
|