@sage-protocol/sdk 0.2.9 → 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 +3 -2
- package/dist/index.cjs +147 -59
- package/dist/index.mjs +147 -59
- package/dist/node/index.cjs +147 -59
- package/dist/node/index.mjs +147 -59
- package/package.json +1 -1
package/dist/browser/index.mjs
CHANGED
|
@@ -14,7 +14,7 @@ var require_package = __commonJS({
|
|
|
14
14
|
"package.json"(exports, module) {
|
|
15
15
|
module.exports = {
|
|
16
16
|
name: "@sage-protocol/sdk",
|
|
17
|
-
version: "0.
|
|
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",
|
|
@@ -157,6 +157,7 @@ var require_abi = __commonJS({
|
|
|
157
157
|
];
|
|
158
158
|
var FactoryWrite = [
|
|
159
159
|
"function createSubDAO(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount) returns (address subDAO, address registry)",
|
|
160
|
+
// legacy compatibility
|
|
160
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)",
|
|
161
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)",
|
|
162
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)",
|
|
@@ -174,7 +175,7 @@ var require_abi = __commonJS({
|
|
|
174
175
|
];
|
|
175
176
|
var TemplateModule = [
|
|
176
177
|
"function getActiveTemplates() view returns (uint256[])",
|
|
177
|
-
"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)",
|
|
178
179
|
"function getTemplateUsage(uint256) view returns (uint256)",
|
|
179
180
|
"function getTemplateUsageMeta(uint256) view returns (uint256 usage, uint256 cap)",
|
|
180
181
|
"function minCreationBurn() view returns (uint256)",
|
package/dist/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",
|
|
@@ -157,6 +157,7 @@ var require_abi = __commonJS({
|
|
|
157
157
|
];
|
|
158
158
|
var FactoryWrite = [
|
|
159
159
|
"function createSubDAO(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount) returns (address subDAO, address registry)",
|
|
160
|
+
// legacy compatibility
|
|
160
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)",
|
|
161
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)",
|
|
162
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)",
|
|
@@ -174,7 +175,7 @@ var require_abi = __commonJS({
|
|
|
174
175
|
];
|
|
175
176
|
var TemplateModule = [
|
|
176
177
|
"function getActiveTemplates() view returns (uint256[])",
|
|
177
|
-
"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)",
|
|
178
179
|
"function getTemplateUsage(uint256) view returns (uint256)",
|
|
179
180
|
"function getTemplateUsageMeta(uint256) view returns (uint256 usage, uint256 cap)",
|
|
180
181
|
"function minCreationBurn() view returns (uint256)",
|
|
@@ -1831,13 +1832,31 @@ var require_subdao = __commonJS({
|
|
|
1831
1832
|
Number(accessModel ?? 0),
|
|
1832
1833
|
0n,
|
|
1833
1834
|
// minStakeAmount deprecated
|
|
1834
|
-
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
|
|
1835
1854
|
];
|
|
1836
1855
|
let tx;
|
|
1837
1856
|
try {
|
|
1838
|
-
tx = await fac.
|
|
1857
|
+
tx = await fac.createSubDAOWithParams(...args);
|
|
1839
1858
|
} catch (err) {
|
|
1840
|
-
tx = await fac.
|
|
1859
|
+
tx = await fac.createSubDAOWithParams(...args, { gasLimit: 8e6 });
|
|
1841
1860
|
}
|
|
1842
1861
|
const receipt = await tx.wait();
|
|
1843
1862
|
const iface = new Interface(ABI.Factory);
|
|
@@ -3848,6 +3867,43 @@ var require_library = __commonJS({
|
|
|
3848
3867
|
}
|
|
3849
3868
|
return raw;
|
|
3850
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
|
+
}
|
|
3851
3907
|
async function listManifests({ provider, registry, factoryAddress, offset = 0, limit = 50 }) {
|
|
3852
3908
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
3853
3909
|
if (!factoryAddress) throw new SageSDKError(CODES.INVALID_ARGS, "factoryAddress required for V4 listing");
|
|
@@ -3871,45 +3927,15 @@ var require_library = __commonJS({
|
|
|
3871
3927
|
const addr = normalise(registry, "registry");
|
|
3872
3928
|
const dao = normalise(subdao2, "subdao");
|
|
3873
3929
|
const contract = new Contract(addr, ABI.LibraryRegistry, provider);
|
|
3874
|
-
|
|
3875
|
-
return {
|
|
3876
|
-
manifestCID: info.manifestCID,
|
|
3877
|
-
previousCID: "",
|
|
3878
|
-
// Not tracked on-chain (history is in events/subgraph)
|
|
3879
|
-
timestamp: BigInt(info.lastUpdated.toString()),
|
|
3880
|
-
proposer: getAddress(info.lastUpdater),
|
|
3881
|
-
promptCount: 0,
|
|
3882
|
-
// Not tracked on-chain
|
|
3883
|
-
version: info.version,
|
|
3884
|
-
nonce: BigInt(info.nonce.toString()),
|
|
3885
|
-
forkedFromDAO: null,
|
|
3886
|
-
// Removed from on-chain struct; use events/subgraph
|
|
3887
|
-
sxxxForkFee: 0n
|
|
3888
|
-
// Removed from on-chain struct
|
|
3889
|
-
};
|
|
3930
|
+
return resolveLibraryInfo({ contract, dao, libraryId: "default" });
|
|
3890
3931
|
}
|
|
3891
3932
|
async function getLibraryStreamInfo({ provider, registry, subdao: subdao2, libraryId = "default" }) {
|
|
3892
3933
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
3893
3934
|
if (!subdao2) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
|
|
3894
3935
|
const addr = normalise(registry, "registry");
|
|
3895
3936
|
const dao = normalise(subdao2, "subdao");
|
|
3896
|
-
const libId = normaliseLibraryId(libraryId);
|
|
3897
3937
|
const contract = new Contract(addr, ABI.LibraryRegistry, provider);
|
|
3898
|
-
|
|
3899
|
-
return {
|
|
3900
|
-
libraryId: libId,
|
|
3901
|
-
manifestCID: info.manifestCID,
|
|
3902
|
-
previousCID: "",
|
|
3903
|
-
timestamp: BigInt(info.lastUpdated.toString()),
|
|
3904
|
-
proposer: getAddress(info.lastUpdater),
|
|
3905
|
-
promptCount: 0,
|
|
3906
|
-
version: info.version,
|
|
3907
|
-
nonce: BigInt(info.nonce.toString()),
|
|
3908
|
-
forkedFromDAO: null,
|
|
3909
|
-
// Removed from on-chain struct; use events/subgraph
|
|
3910
|
-
sxxxForkFee: 0n
|
|
3911
|
-
// Removed from on-chain struct
|
|
3912
|
-
};
|
|
3938
|
+
return resolveLibraryInfo({ contract, dao, libraryId });
|
|
3913
3939
|
}
|
|
3914
3940
|
async function getLibraryIds({ provider, registry, subdao: subdao2 }) {
|
|
3915
3941
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
@@ -7044,16 +7070,16 @@ var require_factory = __commonJS({
|
|
|
7044
7070
|
accessModel: Number(template[2]),
|
|
7045
7071
|
forkPolicy: Number(template[3]),
|
|
7046
7072
|
membershipPolicy: Number(template[4]),
|
|
7047
|
-
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
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]),
|
|
7055
7082
|
// deprecated alias
|
|
7056
|
-
// template[11] was proposalStakeRequired (deprecated)
|
|
7057
7083
|
proposalCooldownSeconds: BigInt(template[12].toString()),
|
|
7058
7084
|
isActive: Boolean(template[13])
|
|
7059
7085
|
});
|
|
@@ -7074,16 +7100,16 @@ var require_factory = __commonJS({
|
|
|
7074
7100
|
accessModel: Number(template[2]),
|
|
7075
7101
|
forkPolicy: Number(template[3]),
|
|
7076
7102
|
membershipPolicy: Number(template[4]),
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
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]),
|
|
7085
7112
|
// deprecated alias
|
|
7086
|
-
// template[11] was proposalStakeRequired (deprecated)
|
|
7087
7113
|
proposalCooldownSeconds: BigInt(template[12].toString()),
|
|
7088
7114
|
isActive: Boolean(template[13]),
|
|
7089
7115
|
usage: usage != null ? BigInt(usage.toString()) : null,
|
|
@@ -7091,15 +7117,40 @@ var require_factory = __commonJS({
|
|
|
7091
7117
|
};
|
|
7092
7118
|
}
|
|
7093
7119
|
var FactoryWriteInterface = new Interface(ABI.FactoryWrite);
|
|
7094
|
-
function buildCreateSubDAOTx({
|
|
7120
|
+
function buildCreateSubDAOTx({
|
|
7121
|
+
factory: factory2,
|
|
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
|
+
}) {
|
|
7095
7137
|
const addr = normalise(factory2, "factory");
|
|
7096
|
-
const payload = FactoryWriteInterface.encodeFunctionData("
|
|
7138
|
+
const payload = FactoryWriteInterface.encodeFunctionData("createSubDAOWithParams", [
|
|
7097
7139
|
String(name),
|
|
7098
7140
|
String(description),
|
|
7099
7141
|
Number(accessModel),
|
|
7100
|
-
0n,
|
|
7142
|
+
BigInt(minStakeAmount || 0n),
|
|
7101
7143
|
// minStakeAmount deprecated
|
|
7102
|
-
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 || "")
|
|
7103
7154
|
]);
|
|
7104
7155
|
return { to: addr, data: payload, value: 0n };
|
|
7105
7156
|
}
|
|
@@ -11560,6 +11611,43 @@ ${error}` : ""}`;
|
|
|
11560
11611
|
signature: "createSubDAOFromTemplate(uint256,string,string)",
|
|
11561
11612
|
args: [templateId, `"${name}"`, `"${description}"`]
|
|
11562
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
|
+
};
|
|
11563
11651
|
} else if (data.startsWith(require("ethers").id("createSubDAO(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256)").slice(0, 10))) {
|
|
11564
11652
|
const { ethers: ethers2 } = require("ethers");
|
|
11565
11653
|
const iface = new ethers2.Interface(["function createSubDAO(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256)"]);
|
package/dist/index.mjs
CHANGED
|
@@ -20,7 +20,7 @@ var require_package = __commonJS({
|
|
|
20
20
|
"package.json"(exports2, module2) {
|
|
21
21
|
module2.exports = {
|
|
22
22
|
name: "@sage-protocol/sdk",
|
|
23
|
-
version: "0.
|
|
23
|
+
version: "0.3.0",
|
|
24
24
|
description: "Backend-agnostic SDK for interacting with the Sage Protocol (governance, SubDAOs, tokens).",
|
|
25
25
|
main: "dist/index.cjs",
|
|
26
26
|
module: "dist/index.mjs",
|
|
@@ -163,6 +163,7 @@ var require_abi = __commonJS({
|
|
|
163
163
|
];
|
|
164
164
|
var FactoryWrite = [
|
|
165
165
|
"function createSubDAO(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount) returns (address subDAO, address registry)",
|
|
166
|
+
// legacy compatibility
|
|
166
167
|
"function createSubDAOWithStable(string name, string description, uint8 accessModel, uint256 minStakeAmount, (uint256 value,uint256 deadline,uint8 v,bytes32 r,bytes32 s) permit) returns (address subDAO, address registry)",
|
|
167
168
|
"function createSubDAOWithParams(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount, uint256 votingDelay, uint256 votingPeriod, uint256 proposalThreshold, uint256 quorumPercentage, uint8 initialForkPolicy, uint8 initialMembershipPolicy, string profileCID, string manifestCID, string manifestVersion) returns (address subDAO, address registry)",
|
|
168
169
|
"function createSubDAOOperatorWithStable(string name, string description, uint8 accessModel, uint256 minStakeAmount, address operatorExecutor, address operatorAdmin, (uint256 value,uint256 deadline,uint8 v,bytes32 r,bytes32 s) permit) returns (address subDAO, address registry)",
|
|
@@ -180,7 +181,7 @@ var require_abi = __commonJS({
|
|
|
180
181
|
];
|
|
181
182
|
var TemplateModule = [
|
|
182
183
|
"function getActiveTemplates() view returns (uint256[])",
|
|
183
|
-
"function getTemplateStruct(uint256) view returns (string,string,uint8,uint8,uint8,
|
|
184
|
+
"function getTemplateStruct(uint256) view returns (string,string,uint8,uint8,uint8,bool,bool,uint256,uint256,uint256,uint256,uint256,uint256,bool,bytes)",
|
|
184
185
|
"function getTemplateUsage(uint256) view returns (uint256)",
|
|
185
186
|
"function getTemplateUsageMeta(uint256) view returns (uint256 usage, uint256 cap)",
|
|
186
187
|
"function minCreationBurn() view returns (uint256)",
|
|
@@ -1837,13 +1838,31 @@ var require_subdao = __commonJS({
|
|
|
1837
1838
|
Number(accessModel ?? 0),
|
|
1838
1839
|
0n,
|
|
1839
1840
|
// minStakeAmount deprecated
|
|
1840
|
-
BigInt(burnAmount ?? 0n)
|
|
1841
|
+
BigInt(burnAmount ?? 0n),
|
|
1842
|
+
1n,
|
|
1843
|
+
// votingDelay
|
|
1844
|
+
100n,
|
|
1845
|
+
// votingPeriod
|
|
1846
|
+
1n,
|
|
1847
|
+
// proposalThreshold
|
|
1848
|
+
500n * 10n ** 18n,
|
|
1849
|
+
// quorumVotes
|
|
1850
|
+
0,
|
|
1851
|
+
// initialForkPolicy
|
|
1852
|
+
0,
|
|
1853
|
+
// initialMembershipPolicy
|
|
1854
|
+
"",
|
|
1855
|
+
// profileCID
|
|
1856
|
+
"",
|
|
1857
|
+
// manifestCID
|
|
1858
|
+
""
|
|
1859
|
+
// manifestVersion
|
|
1841
1860
|
];
|
|
1842
1861
|
let tx;
|
|
1843
1862
|
try {
|
|
1844
|
-
tx = await fac.
|
|
1863
|
+
tx = await fac.createSubDAOWithParams(...args);
|
|
1845
1864
|
} catch (err) {
|
|
1846
|
-
tx = await fac.
|
|
1865
|
+
tx = await fac.createSubDAOWithParams(...args, { gasLimit: 8e6 });
|
|
1847
1866
|
}
|
|
1848
1867
|
const receipt = await tx.wait();
|
|
1849
1868
|
const iface = new Interface(ABI.Factory);
|
|
@@ -3854,6 +3873,43 @@ var require_library = __commonJS({
|
|
|
3854
3873
|
}
|
|
3855
3874
|
return raw;
|
|
3856
3875
|
}
|
|
3876
|
+
function mapLibraryInfo(info, libraryId = "default") {
|
|
3877
|
+
return {
|
|
3878
|
+
libraryId,
|
|
3879
|
+
manifestCID: info.manifestCID,
|
|
3880
|
+
previousCID: "",
|
|
3881
|
+
// Not tracked on-chain (history is in events/subgraph)
|
|
3882
|
+
timestamp: BigInt(info.lastUpdated.toString()),
|
|
3883
|
+
proposer: getAddress(info.lastUpdater),
|
|
3884
|
+
promptCount: 0,
|
|
3885
|
+
// Not tracked on-chain
|
|
3886
|
+
version: info.version,
|
|
3887
|
+
nonce: BigInt(info.nonce.toString()),
|
|
3888
|
+
forkedFromDAO: null,
|
|
3889
|
+
// Removed from on-chain struct; use events/subgraph
|
|
3890
|
+
sxxxForkFee: 0n
|
|
3891
|
+
// Removed from on-chain struct
|
|
3892
|
+
};
|
|
3893
|
+
}
|
|
3894
|
+
async function resolveLibraryInfo({ contract, dao, libraryId = "default" }) {
|
|
3895
|
+
const libId = normaliseLibraryId(libraryId);
|
|
3896
|
+
let streamError = null;
|
|
3897
|
+
try {
|
|
3898
|
+
const stream = await contract.getLibraryStream(dao, libId);
|
|
3899
|
+
const streamCid = typeof stream?.manifestCID === "string" ? stream.manifestCID.trim() : "";
|
|
3900
|
+
if (streamCid || libId !== "default") {
|
|
3901
|
+
return mapLibraryInfo(stream, libId);
|
|
3902
|
+
}
|
|
3903
|
+
} catch (err) {
|
|
3904
|
+
streamError = err;
|
|
3905
|
+
}
|
|
3906
|
+
if (libId === "default") {
|
|
3907
|
+
const legacy = await contract.getLibrary(dao);
|
|
3908
|
+
return mapLibraryInfo(legacy, libId);
|
|
3909
|
+
}
|
|
3910
|
+
if (streamError) throw streamError;
|
|
3911
|
+
throw new SageSDKError(CODES.NOT_FOUND, `library stream not found`, { dao, libraryId: libId });
|
|
3912
|
+
}
|
|
3857
3913
|
async function listManifests({ provider, registry, factoryAddress, offset = 0, limit = 50 }) {
|
|
3858
3914
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
3859
3915
|
if (!factoryAddress) throw new SageSDKError(CODES.INVALID_ARGS, "factoryAddress required for V4 listing");
|
|
@@ -3877,45 +3933,15 @@ var require_library = __commonJS({
|
|
|
3877
3933
|
const addr = normalise(registry, "registry");
|
|
3878
3934
|
const dao = normalise(subdao, "subdao");
|
|
3879
3935
|
const contract = new Contract(addr, ABI.LibraryRegistry, provider);
|
|
3880
|
-
|
|
3881
|
-
return {
|
|
3882
|
-
manifestCID: info.manifestCID,
|
|
3883
|
-
previousCID: "",
|
|
3884
|
-
// Not tracked on-chain (history is in events/subgraph)
|
|
3885
|
-
timestamp: BigInt(info.lastUpdated.toString()),
|
|
3886
|
-
proposer: getAddress(info.lastUpdater),
|
|
3887
|
-
promptCount: 0,
|
|
3888
|
-
// Not tracked on-chain
|
|
3889
|
-
version: info.version,
|
|
3890
|
-
nonce: BigInt(info.nonce.toString()),
|
|
3891
|
-
forkedFromDAO: null,
|
|
3892
|
-
// Removed from on-chain struct; use events/subgraph
|
|
3893
|
-
sxxxForkFee: 0n
|
|
3894
|
-
// Removed from on-chain struct
|
|
3895
|
-
};
|
|
3936
|
+
return resolveLibraryInfo({ contract, dao, libraryId: "default" });
|
|
3896
3937
|
}
|
|
3897
3938
|
async function getLibraryStreamInfo({ provider, registry, subdao, libraryId = "default" }) {
|
|
3898
3939
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
3899
3940
|
if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
|
|
3900
3941
|
const addr = normalise(registry, "registry");
|
|
3901
3942
|
const dao = normalise(subdao, "subdao");
|
|
3902
|
-
const libId = normaliseLibraryId(libraryId);
|
|
3903
3943
|
const contract = new Contract(addr, ABI.LibraryRegistry, provider);
|
|
3904
|
-
|
|
3905
|
-
return {
|
|
3906
|
-
libraryId: libId,
|
|
3907
|
-
manifestCID: info.manifestCID,
|
|
3908
|
-
previousCID: "",
|
|
3909
|
-
timestamp: BigInt(info.lastUpdated.toString()),
|
|
3910
|
-
proposer: getAddress(info.lastUpdater),
|
|
3911
|
-
promptCount: 0,
|
|
3912
|
-
version: info.version,
|
|
3913
|
-
nonce: BigInt(info.nonce.toString()),
|
|
3914
|
-
forkedFromDAO: null,
|
|
3915
|
-
// Removed from on-chain struct; use events/subgraph
|
|
3916
|
-
sxxxForkFee: 0n
|
|
3917
|
-
// Removed from on-chain struct
|
|
3918
|
-
};
|
|
3944
|
+
return resolveLibraryInfo({ contract, dao, libraryId });
|
|
3919
3945
|
}
|
|
3920
3946
|
async function getLibraryIds({ provider, registry, subdao }) {
|
|
3921
3947
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
@@ -7050,16 +7076,16 @@ var require_factory = __commonJS({
|
|
|
7050
7076
|
accessModel: Number(template[2]),
|
|
7051
7077
|
forkPolicy: Number(template[3]),
|
|
7052
7078
|
membershipPolicy: Number(template[4]),
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7079
|
+
allowForkPolicyOverride: Boolean(template[5]),
|
|
7080
|
+
allowMembershipPolicyOverride: Boolean(template[6]),
|
|
7081
|
+
burnAmount: BigInt(template[7].toString()),
|
|
7082
|
+
votingDelay: BigInt(template[8].toString()),
|
|
7083
|
+
votingPeriod: BigInt(template[9].toString()),
|
|
7084
|
+
proposalThreshold: BigInt(template[10].toString()),
|
|
7085
|
+
// template[11] is quorumVotes (absolute token amount, e.g., 100e18 = 100 SXXX)
|
|
7086
|
+
quorumVotes: BigInt(template[11].toString()),
|
|
7087
|
+
quorumPercentage: Number(template[11]),
|
|
7061
7088
|
// deprecated alias
|
|
7062
|
-
// template[11] was proposalStakeRequired (deprecated)
|
|
7063
7089
|
proposalCooldownSeconds: BigInt(template[12].toString()),
|
|
7064
7090
|
isActive: Boolean(template[13])
|
|
7065
7091
|
});
|
|
@@ -7080,16 +7106,16 @@ var require_factory = __commonJS({
|
|
|
7080
7106
|
accessModel: Number(template[2]),
|
|
7081
7107
|
forkPolicy: Number(template[3]),
|
|
7082
7108
|
membershipPolicy: Number(template[4]),
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7109
|
+
allowForkPolicyOverride: Boolean(template[5]),
|
|
7110
|
+
allowMembershipPolicyOverride: Boolean(template[6]),
|
|
7111
|
+
burnAmount: BigInt(template[7].toString()),
|
|
7112
|
+
votingDelay: BigInt(template[8].toString()),
|
|
7113
|
+
votingPeriod: BigInt(template[9].toString()),
|
|
7114
|
+
proposalThreshold: BigInt(template[10].toString()),
|
|
7115
|
+
// template[11] is quorumVotes (absolute token amount, e.g., 100e18 = 100 SXXX)
|
|
7116
|
+
quorumVotes: BigInt(template[11].toString()),
|
|
7117
|
+
quorumPercentage: Number(template[11]),
|
|
7091
7118
|
// deprecated alias
|
|
7092
|
-
// template[11] was proposalStakeRequired (deprecated)
|
|
7093
7119
|
proposalCooldownSeconds: BigInt(template[12].toString()),
|
|
7094
7120
|
isActive: Boolean(template[13]),
|
|
7095
7121
|
usage: usage != null ? BigInt(usage.toString()) : null,
|
|
@@ -7097,15 +7123,40 @@ var require_factory = __commonJS({
|
|
|
7097
7123
|
};
|
|
7098
7124
|
}
|
|
7099
7125
|
var FactoryWriteInterface = new Interface(ABI.FactoryWrite);
|
|
7100
|
-
function buildCreateSubDAOTx({
|
|
7126
|
+
function buildCreateSubDAOTx({
|
|
7127
|
+
factory,
|
|
7128
|
+
name,
|
|
7129
|
+
description,
|
|
7130
|
+
accessModel,
|
|
7131
|
+
minStakeAmount,
|
|
7132
|
+
burnAmount,
|
|
7133
|
+
votingDelay = 1n,
|
|
7134
|
+
votingPeriod = 100n,
|
|
7135
|
+
proposalThreshold = 1n,
|
|
7136
|
+
quorumVotes = 500n * 10n ** 18n,
|
|
7137
|
+
initialForkPolicy = 0,
|
|
7138
|
+
initialMembershipPolicy = 0,
|
|
7139
|
+
profileCID = "",
|
|
7140
|
+
manifestCID = "",
|
|
7141
|
+
manifestVersion = ""
|
|
7142
|
+
}) {
|
|
7101
7143
|
const addr = normalise(factory, "factory");
|
|
7102
|
-
const payload = FactoryWriteInterface.encodeFunctionData("
|
|
7144
|
+
const payload = FactoryWriteInterface.encodeFunctionData("createSubDAOWithParams", [
|
|
7103
7145
|
String(name),
|
|
7104
7146
|
String(description),
|
|
7105
7147
|
Number(accessModel),
|
|
7106
|
-
0n,
|
|
7148
|
+
BigInt(minStakeAmount || 0n),
|
|
7107
7149
|
// minStakeAmount deprecated
|
|
7108
|
-
BigInt(burnAmount)
|
|
7150
|
+
BigInt(burnAmount),
|
|
7151
|
+
BigInt(votingDelay),
|
|
7152
|
+
BigInt(votingPeriod),
|
|
7153
|
+
BigInt(proposalThreshold),
|
|
7154
|
+
BigInt(quorumVotes),
|
|
7155
|
+
Number(initialForkPolicy),
|
|
7156
|
+
Number(initialMembershipPolicy),
|
|
7157
|
+
String(profileCID || ""),
|
|
7158
|
+
String(manifestCID || ""),
|
|
7159
|
+
String(manifestVersion || "")
|
|
7109
7160
|
]);
|
|
7110
7161
|
return { to: addr, data: payload, value: 0n };
|
|
7111
7162
|
}
|
|
@@ -11566,6 +11617,43 @@ ${error}` : ""}`;
|
|
|
11566
11617
|
signature: "createSubDAOFromTemplate(uint256,string,string)",
|
|
11567
11618
|
args: [templateId, `"${name}"`, `"${description}"`]
|
|
11568
11619
|
};
|
|
11620
|
+
} else if (data.startsWith(__require("ethers").id("createSubDAOWithParams(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256,uint8,uint8,string,string,string)").slice(0, 10))) {
|
|
11621
|
+
const { ethers: ethers2 } = __require("ethers");
|
|
11622
|
+
const iface = new ethers2.Interface(["function createSubDAOWithParams(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256,uint8,uint8,string,string,string)"]);
|
|
11623
|
+
const decoded = iface.decodeFunctionData("createSubDAOWithParams", data);
|
|
11624
|
+
const name = decoded[0];
|
|
11625
|
+
const description = decoded[1];
|
|
11626
|
+
const accessModel = decoded[2].toString();
|
|
11627
|
+
const minStakeAmount = decoded[3].toString();
|
|
11628
|
+
const burnAmount = decoded[4].toString();
|
|
11629
|
+
const votingDelay = decoded[5].toString();
|
|
11630
|
+
const votingPeriod = decoded[6].toString();
|
|
11631
|
+
const proposalThreshold = decoded[7].toString();
|
|
11632
|
+
const quorumVotes = decoded[8].toString();
|
|
11633
|
+
const initialForkPolicy = decoded[9].toString();
|
|
11634
|
+
const initialMembershipPolicy = decoded[10].toString();
|
|
11635
|
+
const profileCID = decoded[11];
|
|
11636
|
+
const manifestCID = decoded[12];
|
|
11637
|
+
const manifestVersion = decoded[13];
|
|
11638
|
+
return {
|
|
11639
|
+
signature: "createSubDAOWithParams(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256,uint8,uint8,string,string,string)",
|
|
11640
|
+
args: [
|
|
11641
|
+
`"${name}"`,
|
|
11642
|
+
`"${description}"`,
|
|
11643
|
+
accessModel,
|
|
11644
|
+
minStakeAmount,
|
|
11645
|
+
burnAmount,
|
|
11646
|
+
votingDelay,
|
|
11647
|
+
votingPeriod,
|
|
11648
|
+
proposalThreshold,
|
|
11649
|
+
quorumVotes,
|
|
11650
|
+
initialForkPolicy,
|
|
11651
|
+
initialMembershipPolicy,
|
|
11652
|
+
`"${profileCID}"`,
|
|
11653
|
+
`"${manifestCID}"`,
|
|
11654
|
+
`"${manifestVersion}"`
|
|
11655
|
+
]
|
|
11656
|
+
};
|
|
11569
11657
|
} else if (data.startsWith(__require("ethers").id("createSubDAO(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256)").slice(0, 10))) {
|
|
11570
11658
|
const { ethers: ethers2 } = __require("ethers");
|
|
11571
11659
|
const iface = new ethers2.Interface(["function createSubDAO(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256)"]);
|
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",
|
|
@@ -157,6 +157,7 @@ var require_abi = __commonJS({
|
|
|
157
157
|
];
|
|
158
158
|
var FactoryWrite = [
|
|
159
159
|
"function createSubDAO(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount) returns (address subDAO, address registry)",
|
|
160
|
+
// legacy compatibility
|
|
160
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)",
|
|
161
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)",
|
|
162
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)",
|
|
@@ -174,7 +175,7 @@ var require_abi = __commonJS({
|
|
|
174
175
|
];
|
|
175
176
|
var TemplateModule = [
|
|
176
177
|
"function getActiveTemplates() view returns (uint256[])",
|
|
177
|
-
"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)",
|
|
178
179
|
"function getTemplateUsage(uint256) view returns (uint256)",
|
|
179
180
|
"function getTemplateUsageMeta(uint256) view returns (uint256 usage, uint256 cap)",
|
|
180
181
|
"function minCreationBurn() view returns (uint256)",
|
|
@@ -1831,13 +1832,31 @@ var require_subdao = __commonJS({
|
|
|
1831
1832
|
Number(accessModel ?? 0),
|
|
1832
1833
|
0n,
|
|
1833
1834
|
// minStakeAmount deprecated
|
|
1834
|
-
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
|
|
1835
1854
|
];
|
|
1836
1855
|
let tx;
|
|
1837
1856
|
try {
|
|
1838
|
-
tx = await fac.
|
|
1857
|
+
tx = await fac.createSubDAOWithParams(...args);
|
|
1839
1858
|
} catch (err) {
|
|
1840
|
-
tx = await fac.
|
|
1859
|
+
tx = await fac.createSubDAOWithParams(...args, { gasLimit: 8e6 });
|
|
1841
1860
|
}
|
|
1842
1861
|
const receipt = await tx.wait();
|
|
1843
1862
|
const iface = new Interface(ABI.Factory);
|
|
@@ -3848,6 +3867,43 @@ var require_library = __commonJS({
|
|
|
3848
3867
|
}
|
|
3849
3868
|
return raw;
|
|
3850
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
|
+
}
|
|
3851
3907
|
async function listManifests({ provider, registry, factoryAddress, offset = 0, limit = 50 }) {
|
|
3852
3908
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
3853
3909
|
if (!factoryAddress) throw new SageSDKError(CODES.INVALID_ARGS, "factoryAddress required for V4 listing");
|
|
@@ -3871,45 +3927,15 @@ var require_library = __commonJS({
|
|
|
3871
3927
|
const addr = normalise(registry, "registry");
|
|
3872
3928
|
const dao = normalise(subdao, "subdao");
|
|
3873
3929
|
const contract = new Contract(addr, ABI.LibraryRegistry, provider);
|
|
3874
|
-
|
|
3875
|
-
return {
|
|
3876
|
-
manifestCID: info.manifestCID,
|
|
3877
|
-
previousCID: "",
|
|
3878
|
-
// Not tracked on-chain (history is in events/subgraph)
|
|
3879
|
-
timestamp: BigInt(info.lastUpdated.toString()),
|
|
3880
|
-
proposer: getAddress(info.lastUpdater),
|
|
3881
|
-
promptCount: 0,
|
|
3882
|
-
// Not tracked on-chain
|
|
3883
|
-
version: info.version,
|
|
3884
|
-
nonce: BigInt(info.nonce.toString()),
|
|
3885
|
-
forkedFromDAO: null,
|
|
3886
|
-
// Removed from on-chain struct; use events/subgraph
|
|
3887
|
-
sxxxForkFee: 0n
|
|
3888
|
-
// Removed from on-chain struct
|
|
3889
|
-
};
|
|
3930
|
+
return resolveLibraryInfo({ contract, dao, libraryId: "default" });
|
|
3890
3931
|
}
|
|
3891
3932
|
async function getLibraryStreamInfo({ provider, registry, subdao, libraryId = "default" }) {
|
|
3892
3933
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
3893
3934
|
if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
|
|
3894
3935
|
const addr = normalise(registry, "registry");
|
|
3895
3936
|
const dao = normalise(subdao, "subdao");
|
|
3896
|
-
const libId = normaliseLibraryId(libraryId);
|
|
3897
3937
|
const contract = new Contract(addr, ABI.LibraryRegistry, provider);
|
|
3898
|
-
|
|
3899
|
-
return {
|
|
3900
|
-
libraryId: libId,
|
|
3901
|
-
manifestCID: info.manifestCID,
|
|
3902
|
-
previousCID: "",
|
|
3903
|
-
timestamp: BigInt(info.lastUpdated.toString()),
|
|
3904
|
-
proposer: getAddress(info.lastUpdater),
|
|
3905
|
-
promptCount: 0,
|
|
3906
|
-
version: info.version,
|
|
3907
|
-
nonce: BigInt(info.nonce.toString()),
|
|
3908
|
-
forkedFromDAO: null,
|
|
3909
|
-
// Removed from on-chain struct; use events/subgraph
|
|
3910
|
-
sxxxForkFee: 0n
|
|
3911
|
-
// Removed from on-chain struct
|
|
3912
|
-
};
|
|
3938
|
+
return resolveLibraryInfo({ contract, dao, libraryId });
|
|
3913
3939
|
}
|
|
3914
3940
|
async function getLibraryIds({ provider, registry, subdao }) {
|
|
3915
3941
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
@@ -7044,16 +7070,16 @@ var require_factory = __commonJS({
|
|
|
7044
7070
|
accessModel: Number(template[2]),
|
|
7045
7071
|
forkPolicy: Number(template[3]),
|
|
7046
7072
|
membershipPolicy: Number(template[4]),
|
|
7047
|
-
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
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]),
|
|
7055
7082
|
// deprecated alias
|
|
7056
|
-
// template[11] was proposalStakeRequired (deprecated)
|
|
7057
7083
|
proposalCooldownSeconds: BigInt(template[12].toString()),
|
|
7058
7084
|
isActive: Boolean(template[13])
|
|
7059
7085
|
});
|
|
@@ -7074,16 +7100,16 @@ var require_factory = __commonJS({
|
|
|
7074
7100
|
accessModel: Number(template[2]),
|
|
7075
7101
|
forkPolicy: Number(template[3]),
|
|
7076
7102
|
membershipPolicy: Number(template[4]),
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
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]),
|
|
7085
7112
|
// deprecated alias
|
|
7086
|
-
// template[11] was proposalStakeRequired (deprecated)
|
|
7087
7113
|
proposalCooldownSeconds: BigInt(template[12].toString()),
|
|
7088
7114
|
isActive: Boolean(template[13]),
|
|
7089
7115
|
usage: usage != null ? BigInt(usage.toString()) : null,
|
|
@@ -7091,15 +7117,40 @@ var require_factory = __commonJS({
|
|
|
7091
7117
|
};
|
|
7092
7118
|
}
|
|
7093
7119
|
var FactoryWriteInterface = new Interface(ABI.FactoryWrite);
|
|
7094
|
-
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
|
+
}) {
|
|
7095
7137
|
const addr = normalise(factory, "factory");
|
|
7096
|
-
const payload = FactoryWriteInterface.encodeFunctionData("
|
|
7138
|
+
const payload = FactoryWriteInterface.encodeFunctionData("createSubDAOWithParams", [
|
|
7097
7139
|
String(name),
|
|
7098
7140
|
String(description),
|
|
7099
7141
|
Number(accessModel),
|
|
7100
|
-
0n,
|
|
7142
|
+
BigInt(minStakeAmount || 0n),
|
|
7101
7143
|
// minStakeAmount deprecated
|
|
7102
|
-
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 || "")
|
|
7103
7154
|
]);
|
|
7104
7155
|
return { to: addr, data: payload, value: 0n };
|
|
7105
7156
|
}
|
|
@@ -11560,6 +11611,43 @@ ${error}` : ""}`;
|
|
|
11560
11611
|
signature: "createSubDAOFromTemplate(uint256,string,string)",
|
|
11561
11612
|
args: [templateId, `"${name}"`, `"${description}"`]
|
|
11562
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
|
+
};
|
|
11563
11651
|
} else if (data.startsWith(require("ethers").id("createSubDAO(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256)").slice(0, 10))) {
|
|
11564
11652
|
const { ethers: ethers2 } = require("ethers");
|
|
11565
11653
|
const iface = new ethers2.Interface(["function createSubDAO(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256)"]);
|
package/dist/node/index.mjs
CHANGED
|
@@ -20,7 +20,7 @@ var require_package = __commonJS({
|
|
|
20
20
|
"package.json"(exports2, module2) {
|
|
21
21
|
module2.exports = {
|
|
22
22
|
name: "@sage-protocol/sdk",
|
|
23
|
-
version: "0.
|
|
23
|
+
version: "0.3.0",
|
|
24
24
|
description: "Backend-agnostic SDK for interacting with the Sage Protocol (governance, SubDAOs, tokens).",
|
|
25
25
|
main: "dist/index.cjs",
|
|
26
26
|
module: "dist/index.mjs",
|
|
@@ -163,6 +163,7 @@ var require_abi = __commonJS({
|
|
|
163
163
|
];
|
|
164
164
|
var FactoryWrite = [
|
|
165
165
|
"function createSubDAO(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount) returns (address subDAO, address registry)",
|
|
166
|
+
// legacy compatibility
|
|
166
167
|
"function createSubDAOWithStable(string name, string description, uint8 accessModel, uint256 minStakeAmount, (uint256 value,uint256 deadline,uint8 v,bytes32 r,bytes32 s) permit) returns (address subDAO, address registry)",
|
|
167
168
|
"function createSubDAOWithParams(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount, uint256 votingDelay, uint256 votingPeriod, uint256 proposalThreshold, uint256 quorumPercentage, uint8 initialForkPolicy, uint8 initialMembershipPolicy, string profileCID, string manifestCID, string manifestVersion) returns (address subDAO, address registry)",
|
|
168
169
|
"function createSubDAOOperatorWithStable(string name, string description, uint8 accessModel, uint256 minStakeAmount, address operatorExecutor, address operatorAdmin, (uint256 value,uint256 deadline,uint8 v,bytes32 r,bytes32 s) permit) returns (address subDAO, address registry)",
|
|
@@ -180,7 +181,7 @@ var require_abi = __commonJS({
|
|
|
180
181
|
];
|
|
181
182
|
var TemplateModule = [
|
|
182
183
|
"function getActiveTemplates() view returns (uint256[])",
|
|
183
|
-
"function getTemplateStruct(uint256) view returns (string,string,uint8,uint8,uint8,
|
|
184
|
+
"function getTemplateStruct(uint256) view returns (string,string,uint8,uint8,uint8,bool,bool,uint256,uint256,uint256,uint256,uint256,uint256,bool,bytes)",
|
|
184
185
|
"function getTemplateUsage(uint256) view returns (uint256)",
|
|
185
186
|
"function getTemplateUsageMeta(uint256) view returns (uint256 usage, uint256 cap)",
|
|
186
187
|
"function minCreationBurn() view returns (uint256)",
|
|
@@ -1837,13 +1838,31 @@ var require_subdao = __commonJS({
|
|
|
1837
1838
|
Number(accessModel ?? 0),
|
|
1838
1839
|
0n,
|
|
1839
1840
|
// minStakeAmount deprecated
|
|
1840
|
-
BigInt(burnAmount ?? 0n)
|
|
1841
|
+
BigInt(burnAmount ?? 0n),
|
|
1842
|
+
1n,
|
|
1843
|
+
// votingDelay
|
|
1844
|
+
100n,
|
|
1845
|
+
// votingPeriod
|
|
1846
|
+
1n,
|
|
1847
|
+
// proposalThreshold
|
|
1848
|
+
500n * 10n ** 18n,
|
|
1849
|
+
// quorumVotes
|
|
1850
|
+
0,
|
|
1851
|
+
// initialForkPolicy
|
|
1852
|
+
0,
|
|
1853
|
+
// initialMembershipPolicy
|
|
1854
|
+
"",
|
|
1855
|
+
// profileCID
|
|
1856
|
+
"",
|
|
1857
|
+
// manifestCID
|
|
1858
|
+
""
|
|
1859
|
+
// manifestVersion
|
|
1841
1860
|
];
|
|
1842
1861
|
let tx;
|
|
1843
1862
|
try {
|
|
1844
|
-
tx = await fac.
|
|
1863
|
+
tx = await fac.createSubDAOWithParams(...args);
|
|
1845
1864
|
} catch (err) {
|
|
1846
|
-
tx = await fac.
|
|
1865
|
+
tx = await fac.createSubDAOWithParams(...args, { gasLimit: 8e6 });
|
|
1847
1866
|
}
|
|
1848
1867
|
const receipt = await tx.wait();
|
|
1849
1868
|
const iface = new Interface(ABI.Factory);
|
|
@@ -3854,6 +3873,43 @@ var require_library = __commonJS({
|
|
|
3854
3873
|
}
|
|
3855
3874
|
return raw;
|
|
3856
3875
|
}
|
|
3876
|
+
function mapLibraryInfo(info, libraryId = "default") {
|
|
3877
|
+
return {
|
|
3878
|
+
libraryId,
|
|
3879
|
+
manifestCID: info.manifestCID,
|
|
3880
|
+
previousCID: "",
|
|
3881
|
+
// Not tracked on-chain (history is in events/subgraph)
|
|
3882
|
+
timestamp: BigInt(info.lastUpdated.toString()),
|
|
3883
|
+
proposer: getAddress(info.lastUpdater),
|
|
3884
|
+
promptCount: 0,
|
|
3885
|
+
// Not tracked on-chain
|
|
3886
|
+
version: info.version,
|
|
3887
|
+
nonce: BigInt(info.nonce.toString()),
|
|
3888
|
+
forkedFromDAO: null,
|
|
3889
|
+
// Removed from on-chain struct; use events/subgraph
|
|
3890
|
+
sxxxForkFee: 0n
|
|
3891
|
+
// Removed from on-chain struct
|
|
3892
|
+
};
|
|
3893
|
+
}
|
|
3894
|
+
async function resolveLibraryInfo({ contract, dao, libraryId = "default" }) {
|
|
3895
|
+
const libId = normaliseLibraryId(libraryId);
|
|
3896
|
+
let streamError = null;
|
|
3897
|
+
try {
|
|
3898
|
+
const stream = await contract.getLibraryStream(dao, libId);
|
|
3899
|
+
const streamCid = typeof stream?.manifestCID === "string" ? stream.manifestCID.trim() : "";
|
|
3900
|
+
if (streamCid || libId !== "default") {
|
|
3901
|
+
return mapLibraryInfo(stream, libId);
|
|
3902
|
+
}
|
|
3903
|
+
} catch (err) {
|
|
3904
|
+
streamError = err;
|
|
3905
|
+
}
|
|
3906
|
+
if (libId === "default") {
|
|
3907
|
+
const legacy = await contract.getLibrary(dao);
|
|
3908
|
+
return mapLibraryInfo(legacy, libId);
|
|
3909
|
+
}
|
|
3910
|
+
if (streamError) throw streamError;
|
|
3911
|
+
throw new SageSDKError(CODES.NOT_FOUND, `library stream not found`, { dao, libraryId: libId });
|
|
3912
|
+
}
|
|
3857
3913
|
async function listManifests({ provider, registry, factoryAddress, offset = 0, limit = 50 }) {
|
|
3858
3914
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
3859
3915
|
if (!factoryAddress) throw new SageSDKError(CODES.INVALID_ARGS, "factoryAddress required for V4 listing");
|
|
@@ -3877,45 +3933,15 @@ var require_library = __commonJS({
|
|
|
3877
3933
|
const addr = normalise(registry, "registry");
|
|
3878
3934
|
const dao = normalise(subdao, "subdao");
|
|
3879
3935
|
const contract = new Contract(addr, ABI.LibraryRegistry, provider);
|
|
3880
|
-
|
|
3881
|
-
return {
|
|
3882
|
-
manifestCID: info.manifestCID,
|
|
3883
|
-
previousCID: "",
|
|
3884
|
-
// Not tracked on-chain (history is in events/subgraph)
|
|
3885
|
-
timestamp: BigInt(info.lastUpdated.toString()),
|
|
3886
|
-
proposer: getAddress(info.lastUpdater),
|
|
3887
|
-
promptCount: 0,
|
|
3888
|
-
// Not tracked on-chain
|
|
3889
|
-
version: info.version,
|
|
3890
|
-
nonce: BigInt(info.nonce.toString()),
|
|
3891
|
-
forkedFromDAO: null,
|
|
3892
|
-
// Removed from on-chain struct; use events/subgraph
|
|
3893
|
-
sxxxForkFee: 0n
|
|
3894
|
-
// Removed from on-chain struct
|
|
3895
|
-
};
|
|
3936
|
+
return resolveLibraryInfo({ contract, dao, libraryId: "default" });
|
|
3896
3937
|
}
|
|
3897
3938
|
async function getLibraryStreamInfo({ provider, registry, subdao, libraryId = "default" }) {
|
|
3898
3939
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
3899
3940
|
if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
|
|
3900
3941
|
const addr = normalise(registry, "registry");
|
|
3901
3942
|
const dao = normalise(subdao, "subdao");
|
|
3902
|
-
const libId = normaliseLibraryId(libraryId);
|
|
3903
3943
|
const contract = new Contract(addr, ABI.LibraryRegistry, provider);
|
|
3904
|
-
|
|
3905
|
-
return {
|
|
3906
|
-
libraryId: libId,
|
|
3907
|
-
manifestCID: info.manifestCID,
|
|
3908
|
-
previousCID: "",
|
|
3909
|
-
timestamp: BigInt(info.lastUpdated.toString()),
|
|
3910
|
-
proposer: getAddress(info.lastUpdater),
|
|
3911
|
-
promptCount: 0,
|
|
3912
|
-
version: info.version,
|
|
3913
|
-
nonce: BigInt(info.nonce.toString()),
|
|
3914
|
-
forkedFromDAO: null,
|
|
3915
|
-
// Removed from on-chain struct; use events/subgraph
|
|
3916
|
-
sxxxForkFee: 0n
|
|
3917
|
-
// Removed from on-chain struct
|
|
3918
|
-
};
|
|
3944
|
+
return resolveLibraryInfo({ contract, dao, libraryId });
|
|
3919
3945
|
}
|
|
3920
3946
|
async function getLibraryIds({ provider, registry, subdao }) {
|
|
3921
3947
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
@@ -7050,16 +7076,16 @@ var require_factory = __commonJS({
|
|
|
7050
7076
|
accessModel: Number(template[2]),
|
|
7051
7077
|
forkPolicy: Number(template[3]),
|
|
7052
7078
|
membershipPolicy: Number(template[4]),
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7079
|
+
allowForkPolicyOverride: Boolean(template[5]),
|
|
7080
|
+
allowMembershipPolicyOverride: Boolean(template[6]),
|
|
7081
|
+
burnAmount: BigInt(template[7].toString()),
|
|
7082
|
+
votingDelay: BigInt(template[8].toString()),
|
|
7083
|
+
votingPeriod: BigInt(template[9].toString()),
|
|
7084
|
+
proposalThreshold: BigInt(template[10].toString()),
|
|
7085
|
+
// template[11] is quorumVotes (absolute token amount, e.g., 100e18 = 100 SXXX)
|
|
7086
|
+
quorumVotes: BigInt(template[11].toString()),
|
|
7087
|
+
quorumPercentage: Number(template[11]),
|
|
7061
7088
|
// deprecated alias
|
|
7062
|
-
// template[11] was proposalStakeRequired (deprecated)
|
|
7063
7089
|
proposalCooldownSeconds: BigInt(template[12].toString()),
|
|
7064
7090
|
isActive: Boolean(template[13])
|
|
7065
7091
|
});
|
|
@@ -7080,16 +7106,16 @@ var require_factory = __commonJS({
|
|
|
7080
7106
|
accessModel: Number(template[2]),
|
|
7081
7107
|
forkPolicy: Number(template[3]),
|
|
7082
7108
|
membershipPolicy: Number(template[4]),
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7109
|
+
allowForkPolicyOverride: Boolean(template[5]),
|
|
7110
|
+
allowMembershipPolicyOverride: Boolean(template[6]),
|
|
7111
|
+
burnAmount: BigInt(template[7].toString()),
|
|
7112
|
+
votingDelay: BigInt(template[8].toString()),
|
|
7113
|
+
votingPeriod: BigInt(template[9].toString()),
|
|
7114
|
+
proposalThreshold: BigInt(template[10].toString()),
|
|
7115
|
+
// template[11] is quorumVotes (absolute token amount, e.g., 100e18 = 100 SXXX)
|
|
7116
|
+
quorumVotes: BigInt(template[11].toString()),
|
|
7117
|
+
quorumPercentage: Number(template[11]),
|
|
7091
7118
|
// deprecated alias
|
|
7092
|
-
// template[11] was proposalStakeRequired (deprecated)
|
|
7093
7119
|
proposalCooldownSeconds: BigInt(template[12].toString()),
|
|
7094
7120
|
isActive: Boolean(template[13]),
|
|
7095
7121
|
usage: usage != null ? BigInt(usage.toString()) : null,
|
|
@@ -7097,15 +7123,40 @@ var require_factory = __commonJS({
|
|
|
7097
7123
|
};
|
|
7098
7124
|
}
|
|
7099
7125
|
var FactoryWriteInterface = new Interface(ABI.FactoryWrite);
|
|
7100
|
-
function buildCreateSubDAOTx({
|
|
7126
|
+
function buildCreateSubDAOTx({
|
|
7127
|
+
factory,
|
|
7128
|
+
name,
|
|
7129
|
+
description,
|
|
7130
|
+
accessModel,
|
|
7131
|
+
minStakeAmount,
|
|
7132
|
+
burnAmount,
|
|
7133
|
+
votingDelay = 1n,
|
|
7134
|
+
votingPeriod = 100n,
|
|
7135
|
+
proposalThreshold = 1n,
|
|
7136
|
+
quorumVotes = 500n * 10n ** 18n,
|
|
7137
|
+
initialForkPolicy = 0,
|
|
7138
|
+
initialMembershipPolicy = 0,
|
|
7139
|
+
profileCID = "",
|
|
7140
|
+
manifestCID = "",
|
|
7141
|
+
manifestVersion = ""
|
|
7142
|
+
}) {
|
|
7101
7143
|
const addr = normalise(factory, "factory");
|
|
7102
|
-
const payload = FactoryWriteInterface.encodeFunctionData("
|
|
7144
|
+
const payload = FactoryWriteInterface.encodeFunctionData("createSubDAOWithParams", [
|
|
7103
7145
|
String(name),
|
|
7104
7146
|
String(description),
|
|
7105
7147
|
Number(accessModel),
|
|
7106
|
-
0n,
|
|
7148
|
+
BigInt(minStakeAmount || 0n),
|
|
7107
7149
|
// minStakeAmount deprecated
|
|
7108
|
-
BigInt(burnAmount)
|
|
7150
|
+
BigInt(burnAmount),
|
|
7151
|
+
BigInt(votingDelay),
|
|
7152
|
+
BigInt(votingPeriod),
|
|
7153
|
+
BigInt(proposalThreshold),
|
|
7154
|
+
BigInt(quorumVotes),
|
|
7155
|
+
Number(initialForkPolicy),
|
|
7156
|
+
Number(initialMembershipPolicy),
|
|
7157
|
+
String(profileCID || ""),
|
|
7158
|
+
String(manifestCID || ""),
|
|
7159
|
+
String(manifestVersion || "")
|
|
7109
7160
|
]);
|
|
7110
7161
|
return { to: addr, data: payload, value: 0n };
|
|
7111
7162
|
}
|
|
@@ -11566,6 +11617,43 @@ ${error}` : ""}`;
|
|
|
11566
11617
|
signature: "createSubDAOFromTemplate(uint256,string,string)",
|
|
11567
11618
|
args: [templateId, `"${name}"`, `"${description}"`]
|
|
11568
11619
|
};
|
|
11620
|
+
} else if (data.startsWith(__require("ethers").id("createSubDAOWithParams(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256,uint8,uint8,string,string,string)").slice(0, 10))) {
|
|
11621
|
+
const { ethers: ethers2 } = __require("ethers");
|
|
11622
|
+
const iface = new ethers2.Interface(["function createSubDAOWithParams(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256,uint8,uint8,string,string,string)"]);
|
|
11623
|
+
const decoded = iface.decodeFunctionData("createSubDAOWithParams", data);
|
|
11624
|
+
const name = decoded[0];
|
|
11625
|
+
const description = decoded[1];
|
|
11626
|
+
const accessModel = decoded[2].toString();
|
|
11627
|
+
const minStakeAmount = decoded[3].toString();
|
|
11628
|
+
const burnAmount = decoded[4].toString();
|
|
11629
|
+
const votingDelay = decoded[5].toString();
|
|
11630
|
+
const votingPeriod = decoded[6].toString();
|
|
11631
|
+
const proposalThreshold = decoded[7].toString();
|
|
11632
|
+
const quorumVotes = decoded[8].toString();
|
|
11633
|
+
const initialForkPolicy = decoded[9].toString();
|
|
11634
|
+
const initialMembershipPolicy = decoded[10].toString();
|
|
11635
|
+
const profileCID = decoded[11];
|
|
11636
|
+
const manifestCID = decoded[12];
|
|
11637
|
+
const manifestVersion = decoded[13];
|
|
11638
|
+
return {
|
|
11639
|
+
signature: "createSubDAOWithParams(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256,uint8,uint8,string,string,string)",
|
|
11640
|
+
args: [
|
|
11641
|
+
`"${name}"`,
|
|
11642
|
+
`"${description}"`,
|
|
11643
|
+
accessModel,
|
|
11644
|
+
minStakeAmount,
|
|
11645
|
+
burnAmount,
|
|
11646
|
+
votingDelay,
|
|
11647
|
+
votingPeriod,
|
|
11648
|
+
proposalThreshold,
|
|
11649
|
+
quorumVotes,
|
|
11650
|
+
initialForkPolicy,
|
|
11651
|
+
initialMembershipPolicy,
|
|
11652
|
+
`"${profileCID}"`,
|
|
11653
|
+
`"${manifestCID}"`,
|
|
11654
|
+
`"${manifestVersion}"`
|
|
11655
|
+
]
|
|
11656
|
+
};
|
|
11569
11657
|
} else if (data.startsWith(__require("ethers").id("createSubDAO(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256)").slice(0, 10))) {
|
|
11570
11658
|
const { ethers: ethers2 } = __require("ethers");
|
|
11571
11659
|
const iface = new ethers2.Interface(["function createSubDAO(string,string,uint8,uint256,uint256,uint256,uint256,uint256,uint256)"]);
|
package/package.json
CHANGED