@sage-protocol/sdk 0.1.8 → 0.1.10

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.
@@ -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.1.7",
17
+ version: "0.1.10",
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",
@@ -143,7 +143,13 @@ var require_abi = __commonJS({
143
143
  "function stats() view returns (uint128 totalSubDAOsCreated, uint128 totalBurnedForCreation)",
144
144
  // On-chain enumeration fallback (naming follows FactoryCoreFacet)
145
145
  "function getSubDAOCount() view returns (uint256)",
146
- "function subDaos(uint256) view returns (address)"
146
+ "function subDaos(uint256) view returns (address)",
147
+ // ISubDAOFactory interface functions
148
+ "function getAllSubDAOs() view returns (address[])",
149
+ "function getSubDAORegistry(address subdaoAddress) view returns (address)",
150
+ "function getRegistrySubDAO(address registryAddress) view returns (address)",
151
+ "function getFactoryStats() view returns (uint256 totalSubDAOs, uint256 totalBurned, uint256 averageBurnPerSubDAO)",
152
+ "function isSubDAO(address subdaoAddress) view returns (bool)"
147
153
  ];
148
154
  var FactoryWrite = [
149
155
  "function createSubDAO(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount) returns (address subDAO, address registry)",
@@ -377,15 +383,31 @@ var require_utils = __commonJS({
377
383
  // src/browser/subgraph.js
378
384
  var require_subgraph = __commonJS({
379
385
  "src/browser/subgraph.js"(exports, module) {
380
- var axios = __require("axios");
381
386
  var { getAddress } = require_utils();
382
387
  async function query(url, document, variables) {
383
388
  if (!url) throw new Error("subgraph url required");
384
- const resp = await axios.post(url, { query: document, variables }, { timeout: 1e4 });
385
- if (resp.data && resp.data.errors) {
386
- throw new Error(resp.data.errors.map((e) => e.message).join("; "));
389
+ const controller = new AbortController();
390
+ const timeoutId = setTimeout(() => controller.abort(), 1e4);
391
+ try {
392
+ const resp = await fetch(url, {
393
+ method: "POST",
394
+ headers: { "Content-Type": "application/json" },
395
+ body: JSON.stringify({ query: document, variables }),
396
+ signal: controller.signal
397
+ });
398
+ clearTimeout(timeoutId);
399
+ if (!resp.ok) {
400
+ throw new Error(`HTTP ${resp.status}: ${resp.statusText}`);
401
+ }
402
+ const data = await resp.json();
403
+ if (data && data.errors) {
404
+ throw new Error(data.errors.map((e) => e.message).join("; "));
405
+ }
406
+ return data.data;
407
+ } catch (error) {
408
+ clearTimeout(timeoutId);
409
+ throw error;
387
410
  }
388
- return resp.data.data;
389
411
  }
390
412
  async function listProposals({ url, governor, first = 20, skip = 0 }) {
391
413
  const data = await query(url, `
@@ -723,9 +745,69 @@ var require_subgraph = __commonJS({
723
745
  // src/browser/ipfs.js
724
746
  var require_ipfs = __commonJS({
725
747
  "src/browser/ipfs.js"(exports, module) {
726
- var axiosDefault = __require("axios");
727
- var FormData = __require("form-data");
728
748
  var { keccak256Sync } = require_utils();
749
+ var browserHttp = {
750
+ async post(url, data, options = {}) {
751
+ const controller = new AbortController();
752
+ const timeout = options.timeout || 15e3;
753
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
754
+ try {
755
+ const response = await fetch(url, {
756
+ method: "POST",
757
+ headers: { "Content-Type": "application/json", ...options.headers },
758
+ body: JSON.stringify(data),
759
+ signal: controller.signal
760
+ });
761
+ clearTimeout(timeoutId);
762
+ if (!response.ok) {
763
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
764
+ }
765
+ return { data: await response.json() };
766
+ } catch (error) {
767
+ clearTimeout(timeoutId);
768
+ throw error;
769
+ }
770
+ },
771
+ async get(url, options = {}) {
772
+ const controller = new AbortController();
773
+ const timeout = options.timeout || 15e3;
774
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
775
+ try {
776
+ const params = options.params || {};
777
+ const queryString = Object.keys(params).length ? "?" + new URLSearchParams(params).toString() : "";
778
+ const response = await fetch(url + queryString, {
779
+ method: "GET",
780
+ headers: options.headers || {},
781
+ signal: controller.signal
782
+ });
783
+ clearTimeout(timeoutId);
784
+ if (!response.ok) {
785
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
786
+ }
787
+ return { data: await response.json() };
788
+ } catch (error) {
789
+ clearTimeout(timeoutId);
790
+ throw error;
791
+ }
792
+ },
793
+ async head(url, options = {}) {
794
+ const controller = new AbortController();
795
+ const timeout = options.timeout || 15e3;
796
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
797
+ try {
798
+ const response = await fetch(url, {
799
+ method: "HEAD",
800
+ headers: options.headers || {},
801
+ signal: controller.signal
802
+ });
803
+ clearTimeout(timeoutId);
804
+ return { status: response.status, ok: response.ok };
805
+ } catch (error) {
806
+ clearTimeout(timeoutId);
807
+ throw error;
808
+ }
809
+ }
810
+ };
729
811
  var DEFAULT_GATEWAY = "https://ipfs.dev.sageprotocol.io/ipfs";
730
812
  function toLowerSafe(value, fallback = "") {
731
813
  if (value == null) return fallback;
@@ -794,8 +876,8 @@ var require_ipfs = __commonJS({
794
876
  }
795
877
  function createClient(options = {}) {
796
878
  const env = options.env || process?.env || {};
797
- const axiosInstance = options.axiosInstance || options.axios || axiosDefault;
798
- const formDataFactory = options.formDataFactory || (() => new FormData());
879
+ const axiosInstance = options.axiosInstance || options.axios || browserHttp;
880
+ const formDataFactory = options.formDataFactory || null;
799
881
  const generateCid = options.generateCid || generateDeterministicCid;
800
882
  const config = {
801
883
  provider: toLowerSafe(options.provider ?? env.SAGE_IPFS_PROVIDER ?? "auto"),
@@ -1276,7 +1358,7 @@ var require_ipfs = __commonJS({
1276
1358
  }
1277
1359
  async function ensureWorkerAccess(options = {}) {
1278
1360
  const env = options.env || process?.env || {};
1279
- const axiosInstance = options.axiosInstance || axiosDefault;
1361
+ const axiosInstance = options.axiosInstance || browserHttp;
1280
1362
  const signer = options.signer;
1281
1363
  if (!signer) throw new Error("worker_signer_required");
1282
1364
  const baseUrl = removeTrailingSlash(options.workerBaseUrl || env.SAGE_IPFS_WORKER_URL || "");
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.1.7",
17
+ version: "0.1.10",
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",
@@ -143,7 +143,13 @@ var require_abi = __commonJS({
143
143
  "function stats() view returns (uint128 totalSubDAOsCreated, uint128 totalBurnedForCreation)",
144
144
  // On-chain enumeration fallback (naming follows FactoryCoreFacet)
145
145
  "function getSubDAOCount() view returns (uint256)",
146
- "function subDaos(uint256) view returns (address)"
146
+ "function subDaos(uint256) view returns (address)",
147
+ // ISubDAOFactory interface functions
148
+ "function getAllSubDAOs() view returns (address[])",
149
+ "function getSubDAORegistry(address subdaoAddress) view returns (address)",
150
+ "function getRegistrySubDAO(address registryAddress) view returns (address)",
151
+ "function getFactoryStats() view returns (uint256 totalSubDAOs, uint256 totalBurned, uint256 averageBurnPerSubDAO)",
152
+ "function isSubDAO(address subdaoAddress) view returns (bool)"
147
153
  ];
148
154
  var FactoryWrite = [
149
155
  "function createSubDAO(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount) returns (address subDAO, address registry)",
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.1.7",
23
+ version: "0.1.10",
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",
@@ -149,7 +149,13 @@ var require_abi = __commonJS({
149
149
  "function stats() view returns (uint128 totalSubDAOsCreated, uint128 totalBurnedForCreation)",
150
150
  // On-chain enumeration fallback (naming follows FactoryCoreFacet)
151
151
  "function getSubDAOCount() view returns (uint256)",
152
- "function subDaos(uint256) view returns (address)"
152
+ "function subDaos(uint256) view returns (address)",
153
+ // ISubDAOFactory interface functions
154
+ "function getAllSubDAOs() view returns (address[])",
155
+ "function getSubDAORegistry(address subdaoAddress) view returns (address)",
156
+ "function getRegistrySubDAO(address registryAddress) view returns (address)",
157
+ "function getFactoryStats() view returns (uint256 totalSubDAOs, uint256 totalBurned, uint256 averageBurnPerSubDAO)",
158
+ "function isSubDAO(address subdaoAddress) view returns (bool)"
153
159
  ];
154
160
  var FactoryWrite = [
155
161
  "function createSubDAO(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount) returns (address subDAO, address registry)",
@@ -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.1.7",
17
+ version: "0.1.10",
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",
@@ -143,7 +143,13 @@ var require_abi = __commonJS({
143
143
  "function stats() view returns (uint128 totalSubDAOsCreated, uint128 totalBurnedForCreation)",
144
144
  // On-chain enumeration fallback (naming follows FactoryCoreFacet)
145
145
  "function getSubDAOCount() view returns (uint256)",
146
- "function subDaos(uint256) view returns (address)"
146
+ "function subDaos(uint256) view returns (address)",
147
+ // ISubDAOFactory interface functions
148
+ "function getAllSubDAOs() view returns (address[])",
149
+ "function getSubDAORegistry(address subdaoAddress) view returns (address)",
150
+ "function getRegistrySubDAO(address registryAddress) view returns (address)",
151
+ "function getFactoryStats() view returns (uint256 totalSubDAOs, uint256 totalBurned, uint256 averageBurnPerSubDAO)",
152
+ "function isSubDAO(address subdaoAddress) view returns (bool)"
147
153
  ];
148
154
  var FactoryWrite = [
149
155
  "function createSubDAO(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount) returns (address subDAO, address registry)",
@@ -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.1.7",
23
+ version: "0.1.10",
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",
@@ -149,7 +149,13 @@ var require_abi = __commonJS({
149
149
  "function stats() view returns (uint128 totalSubDAOsCreated, uint128 totalBurnedForCreation)",
150
150
  // On-chain enumeration fallback (naming follows FactoryCoreFacet)
151
151
  "function getSubDAOCount() view returns (uint256)",
152
- "function subDaos(uint256) view returns (address)"
152
+ "function subDaos(uint256) view returns (address)",
153
+ // ISubDAOFactory interface functions
154
+ "function getAllSubDAOs() view returns (address[])",
155
+ "function getSubDAORegistry(address subdaoAddress) view returns (address)",
156
+ "function getRegistrySubDAO(address registryAddress) view returns (address)",
157
+ "function getFactoryStats() view returns (uint256 totalSubDAOs, uint256 totalBurned, uint256 averageBurnPerSubDAO)",
158
+ "function isSubDAO(address subdaoAddress) view returns (bool)"
153
159
  ];
154
160
  var FactoryWrite = [
155
161
  "function createSubDAO(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount) returns (address subDAO, address registry)",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sage-protocol/sdk",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Backend-agnostic SDK for interacting with the Sage Protocol (governance, SubDAOs, tokens).",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",