@poa-box/core 0.1.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.
Files changed (220) hide show
  1. package/README.md +201 -0
  2. package/dist/abis/DirectDemocracyVotingNew.d.ts +749 -0
  3. package/dist/abis/DirectDemocracyVotingNew.js +961 -0
  4. package/dist/abis/ERC20.d.ts +90 -0
  5. package/dist/abis/ERC20.js +125 -0
  6. package/dist/abis/EducationHubNew.d.ts +590 -0
  7. package/dist/abis/EducationHubNew.js +762 -0
  8. package/dist/abis/EligibilityModuleNew.d.ts +1615 -0
  9. package/dist/abis/EligibilityModuleNew.js +2082 -0
  10. package/dist/abis/Executor.d.ts +619 -0
  11. package/dist/abis/Executor.js +796 -0
  12. package/dist/abis/HybridVotingNew.d.ts +898 -0
  13. package/dist/abis/HybridVotingNew.js +1149 -0
  14. package/dist/abis/ImplementationRegistry.d.ts +270 -0
  15. package/dist/abis/ImplementationRegistry.js +355 -0
  16. package/dist/abis/OrgDeployerNew.d.ts +1275 -0
  17. package/dist/abis/OrgDeployerNew.js +1630 -0
  18. package/dist/abis/OrgRegistry.d.ts +670 -0
  19. package/dist/abis/OrgRegistry.js +868 -0
  20. package/dist/abis/ParticipationToken.d.ts +1086 -0
  21. package/dist/abis/ParticipationToken.js +1415 -0
  22. package/dist/abis/PasskeyAccount.d.ts +788 -0
  23. package/dist/abis/PasskeyAccount.js +1019 -0
  24. package/dist/abis/PasskeyAccountFactory.d.ts +344 -0
  25. package/dist/abis/PasskeyAccountFactory.js +449 -0
  26. package/dist/abis/PaymasterHub.d.ts +1603 -0
  27. package/dist/abis/PaymasterHub.js +2048 -0
  28. package/dist/abis/PaymentManager.d.ts +520 -0
  29. package/dist/abis/PaymentManager.js +671 -0
  30. package/dist/abis/PoaManager.d.ts +344 -0
  31. package/dist/abis/PoaManager.js +449 -0
  32. package/dist/abis/QuickJoinNew.d.ts +855 -0
  33. package/dist/abis/QuickJoinNew.js +1098 -0
  34. package/dist/abis/TaskManagerNew.d.ts +1236 -0
  35. package/dist/abis/TaskManagerNew.js +1573 -0
  36. package/dist/abis/ToggleModule.d.ts +193 -0
  37. package/dist/abis/ToggleModule.js +255 -0
  38. package/dist/abis/UniversalAccountRegistry.d.ts +577 -0
  39. package/dist/abis/UniversalAccountRegistry.js +750 -0
  40. package/dist/abis/ZkEmailInvites.d.ts +823 -0
  41. package/dist/abis/ZkEmailInvites.js +1060 -0
  42. package/dist/abis/external/AaveGovernanceV2.d.ts +128 -0
  43. package/dist/abis/external/AaveGovernanceV2.js +177 -0
  44. package/dist/abis/external/AaveGovernanceV3.d.ts +160 -0
  45. package/dist/abis/external/AaveGovernanceV3.js +220 -0
  46. package/dist/abis/external/AragonVoting.d.ts +107 -0
  47. package/dist/abis/external/AragonVoting.js +150 -0
  48. package/dist/abis/external/CurveGaugeController.d.ts +95 -0
  49. package/dist/abis/external/CurveGaugeController.js +130 -0
  50. package/dist/abis/external/CurveVotingEscrow.d.ts +86 -0
  51. package/dist/abis/external/CurveVotingEscrow.js +116 -0
  52. package/dist/abis/external/GovernorAlpha.d.ts +172 -0
  53. package/dist/abis/external/GovernorAlpha.js +228 -0
  54. package/dist/abis/external/MakerDAOChief.d.ts +92 -0
  55. package/dist/abis/external/MakerDAOChief.js +129 -0
  56. package/dist/abis/external/OZGovernor.d.ts +227 -0
  57. package/dist/abis/external/OZGovernor.js +317 -0
  58. package/dist/abis/external/SolidlyVotingEscrow.d.ts +196 -0
  59. package/dist/abis/external/SolidlyVotingEscrow.js +260 -0
  60. package/dist/abis/index.d.ts +62 -0
  61. package/dist/abis/index.js +98 -0
  62. package/dist/chains.d.ts +150 -0
  63. package/dist/chains.js +320 -0
  64. package/dist/context.d.ts +48 -0
  65. package/dist/context.js +38 -0
  66. package/dist/contracts.d.ts +24 -0
  67. package/dist/contracts.js +41 -0
  68. package/dist/encoding.d.ts +58 -0
  69. package/dist/encoding.js +243 -0
  70. package/dist/env.d.ts +10 -0
  71. package/dist/env.js +4 -0
  72. package/dist/error-catalog.d.ts +41 -0
  73. package/dist/error-catalog.js +941 -0
  74. package/dist/errors.d.ts +27 -0
  75. package/dist/errors.js +60 -0
  76. package/dist/execute/ethers.d.ts +93 -0
  77. package/dist/execute/ethers.js +323 -0
  78. package/dist/execute/index.d.ts +7 -0
  79. package/dist/execute/index.js +23 -0
  80. package/dist/execute/sponsored.d.ts +68 -0
  81. package/dist/execute/sponsored.js +277 -0
  82. package/dist/exit-codes.d.ts +18 -0
  83. package/dist/exit-codes.js +21 -0
  84. package/dist/format.d.ts +21 -0
  85. package/dist/format.js +89 -0
  86. package/dist/graph/client.d.ts +298 -0
  87. package/dist/graph/client.js +702 -0
  88. package/dist/graph/documents/activity.d.ts +9 -0
  89. package/dist/graph/documents/activity.js +164 -0
  90. package/dist/graph/documents/beacons.d.ts +172 -0
  91. package/dist/graph/documents/beacons.js +345 -0
  92. package/dist/graph/documents/index.d.ts +21 -0
  93. package/dist/graph/documents/index.js +57 -0
  94. package/dist/graph/documents/infrastructure.d.ts +30 -0
  95. package/dist/graph/documents/infrastructure.js +34 -0
  96. package/dist/graph/documents/org.d.ts +15 -0
  97. package/dist/graph/documents/org.js +249 -0
  98. package/dist/graph/documents/paymaster.d.ts +95 -0
  99. package/dist/graph/documents/paymaster.js +101 -0
  100. package/dist/graph/documents/role.d.ts +6 -0
  101. package/dist/graph/documents/role.js +41 -0
  102. package/dist/graph/documents/roles.d.ts +50 -0
  103. package/dist/graph/documents/roles.js +112 -0
  104. package/dist/graph/documents/task.d.ts +84 -0
  105. package/dist/graph/documents/task.js +236 -0
  106. package/dist/graph/documents/token.d.ts +13 -0
  107. package/dist/graph/documents/token.js +126 -0
  108. package/dist/graph/documents/treasury.d.ts +39 -0
  109. package/dist/graph/documents/treasury.js +136 -0
  110. package/dist/graph/documents/user.d.ts +120 -0
  111. package/dist/graph/documents/user.js +302 -0
  112. package/dist/graph/documents/voting-classes.d.ts +69 -0
  113. package/dist/graph/documents/voting-classes.js +149 -0
  114. package/dist/graph/documents/voting.d.ts +28 -0
  115. package/dist/graph/documents/voting.js +163 -0
  116. package/dist/graph/documents/vouch.d.ts +79 -0
  117. package/dist/graph/documents/vouch.js +171 -0
  118. package/dist/graph/documents/zkemail.d.ts +63 -0
  119. package/dist/graph/documents/zkemail.js +188 -0
  120. package/dist/graph/index.d.ts +2 -0
  121. package/dist/graph/index.js +41 -0
  122. package/dist/index.d.ts +49 -0
  123. package/dist/index.js +92 -0
  124. package/dist/ipfs.d.ts +39 -0
  125. package/dist/ipfs.js +214 -0
  126. package/dist/label-aliases.d.ts +31 -0
  127. package/dist/label-aliases.js +70 -0
  128. package/dist/metadata/education.d.ts +30 -0
  129. package/dist/metadata/education.js +31 -0
  130. package/dist/metadata/index.d.ts +12 -0
  131. package/dist/metadata/index.js +48 -0
  132. package/dist/metadata/org.d.ts +92 -0
  133. package/dist/metadata/org.js +93 -0
  134. package/dist/metadata/proposal.d.ts +44 -0
  135. package/dist/metadata/proposal.js +45 -0
  136. package/dist/metadata/role.d.ts +38 -0
  137. package/dist/metadata/role.js +35 -0
  138. package/dist/metadata/task.d.ts +108 -0
  139. package/dist/metadata/task.js +81 -0
  140. package/dist/metadata/token.d.ts +32 -0
  141. package/dist/metadata/token.js +36 -0
  142. package/dist/metadata/user.d.ts +63 -0
  143. package/dist/metadata/user.js +70 -0
  144. package/dist/multicall.d.ts +32 -0
  145. package/dist/multicall.js +96 -0
  146. package/dist/payout.d.ts +59 -0
  147. package/dist/payout.js +96 -0
  148. package/dist/perms.d.ts +47 -0
  149. package/dist/perms.js +120 -0
  150. package/dist/preflight.d.ts +72 -0
  151. package/dist/preflight.js +269 -0
  152. package/dist/reads/education.d.ts +79 -0
  153. package/dist/reads/education.js +122 -0
  154. package/dist/reads/eligibility.d.ts +377 -0
  155. package/dist/reads/eligibility.js +687 -0
  156. package/dist/reads/index.d.ts +16 -0
  157. package/dist/reads/index.js +55 -0
  158. package/dist/reads/org.d.ts +258 -0
  159. package/dist/reads/org.js +220 -0
  160. package/dist/reads/paymaster.d.ts +147 -0
  161. package/dist/reads/paymaster.js +235 -0
  162. package/dist/reads/project.d.ts +33 -0
  163. package/dist/reads/project.js +62 -0
  164. package/dist/reads/resolve.d.ts +34 -0
  165. package/dist/reads/resolve.js +64 -0
  166. package/dist/reads/task.d.ts +286 -0
  167. package/dist/reads/task.js +280 -0
  168. package/dist/reads/token.d.ts +94 -0
  169. package/dist/reads/token.js +75 -0
  170. package/dist/reads/treasury.d.ts +222 -0
  171. package/dist/reads/treasury.js +241 -0
  172. package/dist/reads/user.d.ts +229 -0
  173. package/dist/reads/user.js +155 -0
  174. package/dist/reads/vote.d.ts +296 -0
  175. package/dist/reads/vote.js +392 -0
  176. package/dist/reads/zkemail.d.ts +117 -0
  177. package/dist/reads/zkemail.js +217 -0
  178. package/dist/similarity.d.ts +36 -0
  179. package/dist/similarity.js +67 -0
  180. package/dist/sponsorship-config.d.ts +47 -0
  181. package/dist/sponsorship-config.js +41 -0
  182. package/dist/stats.d.ts +11 -0
  183. package/dist/stats.js +27 -0
  184. package/dist/task-lens.d.ts +113 -0
  185. package/dist/task-lens.js +210 -0
  186. package/dist/tx/education.d.ts +169 -0
  187. package/dist/tx/education.js +344 -0
  188. package/dist/tx/eligibility.d.ts +511 -0
  189. package/dist/tx/eligibility.js +818 -0
  190. package/dist/tx/governance.d.ts +85 -0
  191. package/dist/tx/governance.js +87 -0
  192. package/dist/tx/index.d.ts +17 -0
  193. package/dist/tx/index.js +56 -0
  194. package/dist/tx/intent.d.ts +67 -0
  195. package/dist/tx/intent.js +48 -0
  196. package/dist/tx/org.d.ts +321 -0
  197. package/dist/tx/org.js +544 -0
  198. package/dist/tx/paymaster.d.ts +140 -0
  199. package/dist/tx/paymaster.js +251 -0
  200. package/dist/tx/project.d.ts +146 -0
  201. package/dist/tx/project.js +217 -0
  202. package/dist/tx/task.d.ts +480 -0
  203. package/dist/tx/task.js +1149 -0
  204. package/dist/tx/token.d.ts +96 -0
  205. package/dist/tx/token.js +165 -0
  206. package/dist/tx/treasury.d.ts +474 -0
  207. package/dist/tx/treasury.js +911 -0
  208. package/dist/tx/user.d.ts +177 -0
  209. package/dist/tx/user.js +292 -0
  210. package/dist/tx/vote.d.ts +332 -0
  211. package/dist/tx/vote.js +762 -0
  212. package/dist/tx/zkemail.d.ts +90 -0
  213. package/dist/tx/zkemail.js +210 -0
  214. package/dist/validation.d.ts +8 -0
  215. package/dist/validation.js +39 -0
  216. package/dist/version.d.ts +142 -0
  217. package/dist/version.js +257 -0
  218. package/dist/zkemail.d.ts +161 -0
  219. package/dist/zkemail.js +299 -0
  220. package/package.json +130 -0
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.documents = void 0;
40
+ __exportStar(require("./client"), exports);
41
+ exports.documents = __importStar(require("./documents"));
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @poa-box/core — the stable POP protocol layer.
3
+ *
4
+ * Subpath imports are the primary API (tree-shake friendly and explicit):
5
+ *
6
+ * @poa-box/core/chains chain table + env-injected resolvers + tokens
7
+ * @poa-box/core/abis generated contract ABIs (ALL_ABIS registry)
8
+ * @poa-box/core/graph/client tiered subgraph client (GraphClient)
9
+ * @poa-box/core/graph/documents GraphQL documents + pure derivation helpers
10
+ * @poa-box/core/reads/* typed reads (resolve, per-domain)
11
+ * @poa-box/core/tx/* TxIntent + per-domain intent builders
12
+ * @poa-box/core/execute/* ethers EOA executor + 4337/7702 sponsored path
13
+ * @poa-box/core/metadata/* canonical metadata builders (key order = protocol)
14
+ * @poa-box/core/ipfs pin/fetch client (injected endpoints)
15
+ * @poa-box/core/payout|perms|zkemail|encoding|… pure domain logic
16
+ *
17
+ * This barrel re-exports the kernel for convenience; bundle-sensitive
18
+ * consumers should prefer subpaths.
19
+ */
20
+ export * from './env';
21
+ export * from './errors';
22
+ export * from './exit-codes';
23
+ export * from './chains';
24
+ export * from './contracts';
25
+ export * from './encoding';
26
+ export * from './format';
27
+ export * from './validation';
28
+ export * from './similarity';
29
+ export * from './stats';
30
+ export * from './label-aliases';
31
+ export * from './multicall';
32
+ export * from './payout';
33
+ export * from './perms';
34
+ export * from './error-catalog';
35
+ export * from './sponsorship-config';
36
+ export * from './context';
37
+ export * from './tx/intent';
38
+ export * from './graph/client';
39
+ export * as documents from './graph/documents';
40
+ export * as abis from './abis';
41
+ export * from './reads/resolve';
42
+ export * from './ipfs';
43
+ export * from './version';
44
+ export * from './task-lens';
45
+ export * from './preflight';
46
+ export * as zkemail from './zkemail';
47
+ export * as intents from './tx';
48
+ export * as reads from './reads';
49
+ export * as metadata from './metadata';
package/dist/index.js ADDED
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ /**
3
+ * @poa-box/core — the stable POP protocol layer.
4
+ *
5
+ * Subpath imports are the primary API (tree-shake friendly and explicit):
6
+ *
7
+ * @poa-box/core/chains chain table + env-injected resolvers + tokens
8
+ * @poa-box/core/abis generated contract ABIs (ALL_ABIS registry)
9
+ * @poa-box/core/graph/client tiered subgraph client (GraphClient)
10
+ * @poa-box/core/graph/documents GraphQL documents + pure derivation helpers
11
+ * @poa-box/core/reads/* typed reads (resolve, per-domain)
12
+ * @poa-box/core/tx/* TxIntent + per-domain intent builders
13
+ * @poa-box/core/execute/* ethers EOA executor + 4337/7702 sponsored path
14
+ * @poa-box/core/metadata/* canonical metadata builders (key order = protocol)
15
+ * @poa-box/core/ipfs pin/fetch client (injected endpoints)
16
+ * @poa-box/core/payout|perms|zkemail|encoding|… pure domain logic
17
+ *
18
+ * This barrel re-exports the kernel for convenience; bundle-sensitive
19
+ * consumers should prefer subpaths.
20
+ */
21
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ var desc = Object.getOwnPropertyDescriptor(m, k);
24
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
25
+ desc = { enumerable: true, get: function() { return m[k]; } };
26
+ }
27
+ Object.defineProperty(o, k2, desc);
28
+ }) : (function(o, m, k, k2) {
29
+ if (k2 === undefined) k2 = k;
30
+ o[k2] = m[k];
31
+ }));
32
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
33
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
34
+ }) : function(o, v) {
35
+ o["default"] = v;
36
+ });
37
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
38
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
39
+ };
40
+ var __importStar = (this && this.__importStar) || (function () {
41
+ var ownKeys = function(o) {
42
+ ownKeys = Object.getOwnPropertyNames || function (o) {
43
+ var ar = [];
44
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
45
+ return ar;
46
+ };
47
+ return ownKeys(o);
48
+ };
49
+ return function (mod) {
50
+ if (mod && mod.__esModule) return mod;
51
+ var result = {};
52
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
53
+ __setModuleDefault(result, mod);
54
+ return result;
55
+ };
56
+ })();
57
+ Object.defineProperty(exports, "__esModule", { value: true });
58
+ exports.metadata = exports.reads = exports.intents = exports.zkemail = exports.abis = exports.documents = void 0;
59
+ __exportStar(require("./env"), exports);
60
+ __exportStar(require("./errors"), exports);
61
+ __exportStar(require("./exit-codes"), exports);
62
+ __exportStar(require("./chains"), exports);
63
+ __exportStar(require("./contracts"), exports);
64
+ __exportStar(require("./encoding"), exports);
65
+ __exportStar(require("./format"), exports);
66
+ __exportStar(require("./validation"), exports);
67
+ __exportStar(require("./similarity"), exports);
68
+ __exportStar(require("./stats"), exports);
69
+ __exportStar(require("./label-aliases"), exports);
70
+ __exportStar(require("./multicall"), exports);
71
+ __exportStar(require("./payout"), exports);
72
+ __exportStar(require("./perms"), exports);
73
+ __exportStar(require("./error-catalog"), exports);
74
+ __exportStar(require("./sponsorship-config"), exports);
75
+ __exportStar(require("./context"), exports);
76
+ __exportStar(require("./tx/intent"), exports);
77
+ __exportStar(require("./graph/client"), exports);
78
+ exports.documents = __importStar(require("./graph/documents"));
79
+ exports.abis = __importStar(require("./abis"));
80
+ __exportStar(require("./reads/resolve"), exports);
81
+ __exportStar(require("./ipfs"), exports);
82
+ __exportStar(require("./version"), exports);
83
+ __exportStar(require("./task-lens"), exports);
84
+ __exportStar(require("./preflight"), exports);
85
+ // NOT re-exported here: ./execute (ethers EOA executor + 4337/7702 sponsored
86
+ // path). It requires the optional viem/permissionless peers at load time, and
87
+ // this barrel must stay loadable for reads-only consumers that skip them.
88
+ // Import executors explicitly: '@poa-box/core/execute/ethers' / '/sponsored'.
89
+ exports.zkemail = __importStar(require("./zkemail"));
90
+ exports.intents = __importStar(require("./tx"));
91
+ exports.reads = __importStar(require("./reads"));
92
+ exports.metadata = __importStar(require("./metadata"));
package/dist/ipfs.d.ts ADDED
@@ -0,0 +1,39 @@
1
+ /**
2
+ * IPFS Client
3
+ * Pin and fetch via The Graph's IPFS endpoint.
4
+ * Uses direct HTTP (FormData) to match frontend behavior.
5
+ *
6
+ * Endpoints, gateway cascade and read-only behavior are injected via
7
+ * IpfsOptions — hosts that used to rely on POP_IPFS_API_URL /
8
+ * POP_IPFS_GATEWAY_URL / POP_READONLY build the options with
9
+ * ipfsOptionsFromEnv(env).
10
+ */
11
+ import { bytes32ToIpfsCid, ipfsCidToBytes32 } from './encoding';
12
+ import { EnvSource } from './env';
13
+ export interface IpfsOptions {
14
+ /** Pinning endpoint. Default: The Graph's IPFS API. */
15
+ apiUrl?: string;
16
+ /** Extra gateways, prepended to PUBLIC_GATEWAYS (deduped). */
17
+ gateways?: string[];
18
+ /** True => pin* throws IpfsError (POP_READONLY semantics). */
19
+ readonly?: boolean;
20
+ /** Fetch implementation override (tests / custom agents). Default: globalThis.fetch. */
21
+ fetch?: typeof fetch;
22
+ }
23
+ /**
24
+ * Build IpfsOptions from an env object using the CLI's historical variable
25
+ * names: POP_IPFS_API_URL, POP_IPFS_GATEWAY_URL, POP_READONLY.
26
+ */
27
+ export declare function ipfsOptionsFromEnv(env: EnvSource): IpfsOptions;
28
+ export declare function pinJson(content: string, opts?: IpfsOptions): Promise<string>;
29
+ /**
30
+ * Pin a file (binary) to IPFS.
31
+ */
32
+ export declare function pinFile(content: Uint8Array, opts?: IpfsOptions): Promise<string>;
33
+ /**
34
+ * Fetch JSON content from IPFS.
35
+ * Accepts CIDv0 (Qm...) or bytes32 (0x...) hash.
36
+ */
37
+ export declare function fetchJson<T = any>(hashOrCid: string, opts?: IpfsOptions): Promise<T | null>;
38
+ /** Re-export encoding helpers for convenience */
39
+ export { bytes32ToIpfsCid, ipfsCidToBytes32 };
package/dist/ipfs.js ADDED
@@ -0,0 +1,214 @@
1
+ "use strict";
2
+ /**
3
+ * IPFS Client
4
+ * Pin and fetch via The Graph's IPFS endpoint.
5
+ * Uses direct HTTP (FormData) to match frontend behavior.
6
+ *
7
+ * Endpoints, gateway cascade and read-only behavior are injected via
8
+ * IpfsOptions — hosts that used to rely on POP_IPFS_API_URL /
9
+ * POP_IPFS_GATEWAY_URL / POP_READONLY build the options with
10
+ * ipfsOptionsFromEnv(env).
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.ipfsCidToBytes32 = exports.bytes32ToIpfsCid = void 0;
14
+ exports.ipfsOptionsFromEnv = ipfsOptionsFromEnv;
15
+ exports.pinJson = pinJson;
16
+ exports.pinFile = pinFile;
17
+ exports.fetchJson = fetchJson;
18
+ const encoding_1 = require("./encoding");
19
+ Object.defineProperty(exports, "bytes32ToIpfsCid", { enumerable: true, get: function () { return encoding_1.bytes32ToIpfsCid; } });
20
+ Object.defineProperty(exports, "ipfsCidToBytes32", { enumerable: true, get: function () { return encoding_1.ipfsCidToBytes32; } });
21
+ const errors_1 = require("./errors");
22
+ const DEFAULT_IPFS_API = 'https://api.thegraph.com/ipfs/api/v0';
23
+ const MAX_RETRIES = 3;
24
+ const BASE_DELAY_MS = 1000;
25
+ /** Public gateways tried in order after the (optional) caller-supplied ones. */
26
+ const PUBLIC_GATEWAYS = [
27
+ 'https://ipfs.io/ipfs/',
28
+ 'https://cloudflare-ipfs.com/ipfs/',
29
+ 'https://gateway.pinata.cloud/ipfs/',
30
+ 'https://dweb.link/ipfs/',
31
+ ];
32
+ /** Per-gateway fetch timeout before cascading to the next gateway. */
33
+ const GATEWAY_TIMEOUT_MS = 5000;
34
+ /**
35
+ * Build IpfsOptions from an env object using the CLI's historical variable
36
+ * names: POP_IPFS_API_URL, POP_IPFS_GATEWAY_URL, POP_READONLY.
37
+ */
38
+ function ipfsOptionsFromEnv(env) {
39
+ const opts = {};
40
+ if (env.POP_IPFS_API_URL)
41
+ opts.apiUrl = env.POP_IPFS_API_URL;
42
+ if (env.POP_IPFS_GATEWAY_URL)
43
+ opts.gateways = [env.POP_IPFS_GATEWAY_URL];
44
+ if (env.POP_READONLY === '1')
45
+ opts.readonly = true;
46
+ return opts;
47
+ }
48
+ function getFetch(opts) {
49
+ return opts?.fetch ?? fetch;
50
+ }
51
+ function getIpfsApiUrl(opts) {
52
+ return opts?.apiUrl || DEFAULT_IPFS_API;
53
+ }
54
+ /**
55
+ * Gateway cascade order: caller-supplied gateways (if any) first, then the
56
+ * public gateways (deduplicated against the supplied values).
57
+ */
58
+ function getGatewayUrls(opts) {
59
+ const urls = [];
60
+ for (const gateway of opts?.gateways ?? []) {
61
+ if (gateway && !urls.includes(gateway))
62
+ urls.push(gateway);
63
+ }
64
+ for (const gateway of PUBLIC_GATEWAYS) {
65
+ if (!urls.includes(gateway))
66
+ urls.push(gateway);
67
+ }
68
+ return urls;
69
+ }
70
+ async function withRetry(fn, maxRetries = MAX_RETRIES, baseDelay = BASE_DELAY_MS) {
71
+ let lastError;
72
+ for (let attempt = 0; attempt < maxRetries; attempt++) {
73
+ try {
74
+ return await fn();
75
+ }
76
+ catch (error) {
77
+ lastError = error;
78
+ if (attempt < maxRetries - 1) {
79
+ const delay = baseDelay * Math.pow(2, attempt);
80
+ await new Promise(resolve => setTimeout(resolve, delay));
81
+ }
82
+ }
83
+ }
84
+ throw lastError;
85
+ }
86
+ /**
87
+ * Pin JSON content to IPFS via The Graph's endpoint.
88
+ * Uses FormData POST to match frontend behavior exactly.
89
+ * Returns CIDv0 (Qm...) string.
90
+ */
91
+ function assertNotReadonly(opts) {
92
+ // Pinning publishes content publicly and irreversibly. Read commands can
93
+ // reach here via --pin (org audit-*, leaderboard, portfolio), so this is a
94
+ // genuine external side effect the read-only mode must refuse.
95
+ if (opts?.readonly) {
96
+ throw new errors_1.IpfsError('POP_READONLY=1 — refusing to pin: pinning publishes to IPFS publicly and irreversibly.');
97
+ }
98
+ }
99
+ async function pinJson(content, opts) {
100
+ assertNotReadonly(opts);
101
+ const apiUrl = getIpfsApiUrl(opts);
102
+ const doFetch = getFetch(opts);
103
+ const result = await withRetry(async () => {
104
+ // Node 18+ and every modern browser have FormData and Blob globally
105
+ const formData = new FormData();
106
+ formData.append('file', new Blob([content], { type: 'application/octet-stream' }));
107
+ const response = await doFetch(`${apiUrl}/add`, {
108
+ method: 'POST',
109
+ body: formData,
110
+ });
111
+ if (!response.ok) {
112
+ throw new Error(`IPFS upload to ${apiUrl}/add failed: ${response.status} ${response.statusText} (pinning endpoint override: POP_IPFS_API_URL)`);
113
+ }
114
+ const data = await response.json();
115
+ return data.Hash;
116
+ });
117
+ if (!result.startsWith('Qm')) {
118
+ throw new Error(`Unexpected IPFS CID format: ${result}`);
119
+ }
120
+ return result;
121
+ }
122
+ /**
123
+ * Pin a file (binary) to IPFS.
124
+ */
125
+ async function pinFile(content, opts) {
126
+ assertNotReadonly(opts);
127
+ const apiUrl = getIpfsApiUrl(opts);
128
+ const doFetch = getFetch(opts);
129
+ const result = await withRetry(async () => {
130
+ const formData = new FormData();
131
+ formData.append('file', new Blob([content]));
132
+ const response = await doFetch(`${apiUrl}/add`, {
133
+ method: 'POST',
134
+ body: formData,
135
+ });
136
+ if (!response.ok) {
137
+ throw new Error(`IPFS upload to ${apiUrl}/add failed: ${response.status} ${response.statusText} (pinning endpoint override: POP_IPFS_API_URL)`);
138
+ }
139
+ const data = await response.json();
140
+ return data.Hash;
141
+ });
142
+ return result;
143
+ }
144
+ /**
145
+ * Fetch JSON content from IPFS.
146
+ * Accepts CIDv0 (Qm...) or bytes32 (0x...) hash.
147
+ */
148
+ async function fetchJson(hashOrCid, opts) {
149
+ if (!hashOrCid)
150
+ return null;
151
+ // Handle zero hashes
152
+ if (hashOrCid.startsWith('0x') && /^0x0+$/.test(hashOrCid))
153
+ return null;
154
+ // Convert bytes32 to CID if needed
155
+ let cid = hashOrCid;
156
+ if (hashOrCid.startsWith('0x')) {
157
+ const converted = (0, encoding_1.bytes32ToIpfsCid)(hashOrCid);
158
+ if (!converted)
159
+ return null;
160
+ cid = converted;
161
+ }
162
+ // Two attempts (1 retry) around the FULL gateway cascade
163
+ const result = await withRetry(() => fetchJsonViaGatewayCascade(cid, opts), 2);
164
+ return result;
165
+ }
166
+ /**
167
+ * Fetch a single CID from one gateway with a hard timeout.
168
+ * Aborts (and cascades) after GATEWAY_TIMEOUT_MS.
169
+ */
170
+ async function fetchFromGateway(gatewayUrl, cid, opts) {
171
+ const doFetch = getFetch(opts);
172
+ const controller = new AbortController();
173
+ const timer = setTimeout(() => controller.abort(), GATEWAY_TIMEOUT_MS);
174
+ try {
175
+ const response = await doFetch(`${gatewayUrl}${cid}`, { signal: controller.signal });
176
+ if (!response.ok) {
177
+ throw new Error(`IPFS fetch failed: ${response.status} ${response.statusText}`);
178
+ }
179
+ const text = await response.text();
180
+ if (text.length > 10 * 1024 * 1024) {
181
+ throw new Error('IPFS response too large (>10MB)');
182
+ }
183
+ try {
184
+ return JSON.parse(text);
185
+ }
186
+ catch {
187
+ throw new Error(`Invalid JSON from IPFS (CID: ${cid}). Response starts with: ${text.slice(0, 100)}`);
188
+ }
189
+ }
190
+ finally {
191
+ clearTimeout(timer);
192
+ }
193
+ }
194
+ /**
195
+ * Try each gateway in order, cascading to the next on any failure
196
+ * (HTTP error, timeout/abort, oversized or non-JSON body).
197
+ * Throws IpfsError once every gateway has failed.
198
+ */
199
+ async function fetchJsonViaGatewayCascade(cid, opts) {
200
+ const gateways = getGatewayUrls(opts);
201
+ const failures = [];
202
+ for (const gatewayUrl of gateways) {
203
+ try {
204
+ return await fetchFromGateway(gatewayUrl, cid, opts);
205
+ }
206
+ catch (error) {
207
+ const reason = error?.name === 'AbortError'
208
+ ? `timed out after ${GATEWAY_TIMEOUT_MS}ms`
209
+ : (error?.message || String(error));
210
+ failures.push(`${gatewayUrl}: ${reason}`);
211
+ }
212
+ }
213
+ throw new errors_1.IpfsError(`All ${gateways.length} gateways failed for CID ${cid}. ${failures.join('; ')}`);
214
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Shared label alias map for contract-name matching.
3
+ *
4
+ * Some contracts identify on-chain with a token symbol (GTC for Gitcoin)
5
+ * or a descriptive technical term (Vote-escrowed CRV for Curve's veCRV)
6
+ * that doesn't literally contain the project's name. This map says
7
+ * "if the expected label is X, consider these on-chain strings to be
8
+ * an acceptable match."
9
+ *
10
+ * Keys are lower-case filename / project labels; values are lower-case
11
+ * tokens expected to appear in the on-chain `name()` return value.
12
+ *
13
+ * Populated from HB#386's corpus identity sweep first-run false positives
14
+ * (task #391) and used by:
15
+ * - src/commands/org/probe-access.ts → matchContractName (task #395, HB)
16
+ * - agent/scripts/audit-corpus-identity-sweep.mjs (filename-fuzzy mode)
17
+ *
18
+ * Additions should be justified with a short comment explaining why the
19
+ * alias is correct (e.g. "Curve's token is CRV; the VotingEscrow contract
20
+ * identifies as 'Vote-escrowed CRV'").
21
+ */
22
+ export declare const LABEL_ALIASES: Record<string, readonly string[]>;
23
+ /**
24
+ * Return the full list of strings considered an acceptable match for the
25
+ * given label: the label itself, plus any aliases registered under any of
26
+ * its lower-cased whitespace-separated words. Case-insensitive.
27
+ *
28
+ * Example:
29
+ * expandAliases("Curve VotingEscrow") → ["curve votingescrow", "crv", "vote-escrowed"]
30
+ */
31
+ export declare function expandAliases(label: string): string[];
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LABEL_ALIASES = void 0;
4
+ exports.expandAliases = expandAliases;
5
+ /**
6
+ * Shared label alias map for contract-name matching.
7
+ *
8
+ * Some contracts identify on-chain with a token symbol (GTC for Gitcoin)
9
+ * or a descriptive technical term (Vote-escrowed CRV for Curve's veCRV)
10
+ * that doesn't literally contain the project's name. This map says
11
+ * "if the expected label is X, consider these on-chain strings to be
12
+ * an acceptable match."
13
+ *
14
+ * Keys are lower-case filename / project labels; values are lower-case
15
+ * tokens expected to appear in the on-chain `name()` return value.
16
+ *
17
+ * Populated from HB#386's corpus identity sweep first-run false positives
18
+ * (task #391) and used by:
19
+ * - src/commands/org/probe-access.ts → matchContractName (task #395, HB)
20
+ * - agent/scripts/audit-corpus-identity-sweep.mjs (filename-fuzzy mode)
21
+ *
22
+ * Additions should be justified with a short comment explaining why the
23
+ * alias is correct (e.g. "Curve's token is CRV; the VotingEscrow contract
24
+ * identifies as 'Vote-escrowed CRV'").
25
+ */
26
+ exports.LABEL_ALIASES = {
27
+ // Gitcoin's token is GTC; Gitcoin's GovernorAlpha contract identifies
28
+ // as "GTC Governor Alpha" on-chain. HB#386 sweep surfaced this.
29
+ gitcoin: ['gtc'],
30
+ // Curve's VotingEscrow contract identifies as "Vote-escrowed CRV" on-chain.
31
+ // The label "curve votingescrow" → actual "Vote-escrowed CRV" is correct
32
+ // but requires the CRV alias (Curve's token). HB#386 sweep.
33
+ curve: ['crv', 'vote-escrowed'],
34
+ // Balancer's veBAL at 0xC128a9954e6c874eA3d62ce62B468bA073093F25 identifies
35
+ // as "Vote Escrowed Balancer BPT" on-chain (the locked token is the 80/20
36
+ // BAL/WETH BPT, not raw BAL). Verified via eth_call name() on ethereum
37
+ // mainnet in HB#290 task #396. Pre-registered to unblock the veToken
38
+ // family expansion queued in Sprint 14.
39
+ balancer: ['bal', 'bpt', 'vote escrowed balancer'],
40
+ // Frax's veFXS at 0xc8418aF6358FFddA74e09Ca9CC3Fe03Ca6aDC5b0 identifies as
41
+ // "Vote-Escrowed FXS" on-chain — same Curve-style naming but with FXS
42
+ // token ticker. Verified via eth_call name() on ethereum mainnet in
43
+ // HB#290 task #396.
44
+ frax: ['fxs', 'vote-escrowed fxs'],
45
+ // Velodrome and Aerodrome are Solidly-style veNFT systems (Velodrome on
46
+ // Optimism, Aerodrome on Base). Both identify their vote-escrow contract
47
+ // with the generic token name "veNFT" rather than the project name.
48
+ // Pre-registered based on the Solidly contract convention. Live
49
+ // verification happens when the audit actually probes them.
50
+ velodrome: ['velo', 'venft'],
51
+ aerodrome: ['aero', 'venft'],
52
+ };
53
+ /**
54
+ * Return the full list of strings considered an acceptable match for the
55
+ * given label: the label itself, plus any aliases registered under any of
56
+ * its lower-cased whitespace-separated words. Case-insensitive.
57
+ *
58
+ * Example:
59
+ * expandAliases("Curve VotingEscrow") → ["curve votingescrow", "crv", "vote-escrowed"]
60
+ */
61
+ function expandAliases(label) {
62
+ const lowered = label.toLowerCase();
63
+ const out = [lowered];
64
+ for (const word of lowered.split(/\s+/).filter(Boolean)) {
65
+ const aliases = exports.LABEL_ALIASES[word];
66
+ if (aliases)
67
+ out.push(...aliases);
68
+ }
69
+ return out;
70
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Education module metadata document.
3
+ *
4
+ * KEY ORDER IS A PROTOCOL CONTRACT: {name, description, link, quiz, answers}
5
+ * MUST match the frontend for subgraph/UI compatibility. Both education
6
+ * writers pin this exact shape:
7
+ * - `pop education create` — src/commands/education/create-module.ts
8
+ * - `pop education update` — src/commands/education/update.ts (re-pin path)
9
+ */
10
+ export interface EducationModuleMetadata {
11
+ name: string;
12
+ description: string;
13
+ link: string;
14
+ quiz: string[];
15
+ answers: string[][];
16
+ }
17
+ /**
18
+ * Port of the metadata document `pop education create` /
19
+ * `pop education update` pin — key order is load-bearing:
20
+ * name, description, link, quiz, answers.
21
+ */
22
+ export declare function buildEducationModuleMetadata(params: {
23
+ name: string;
24
+ description?: string;
25
+ link?: string;
26
+ quiz?: string[];
27
+ answers?: string[][];
28
+ }): EducationModuleMetadata;
29
+ /** Exact serialization the CLI pins (plain JSON.stringify). */
30
+ export declare function serializeEducationModuleMetadata(metadata: EducationModuleMetadata): string;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /**
3
+ * Education module metadata document.
4
+ *
5
+ * KEY ORDER IS A PROTOCOL CONTRACT: {name, description, link, quiz, answers}
6
+ * MUST match the frontend for subgraph/UI compatibility. Both education
7
+ * writers pin this exact shape:
8
+ * - `pop education create` — src/commands/education/create-module.ts
9
+ * - `pop education update` — src/commands/education/update.ts (re-pin path)
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.buildEducationModuleMetadata = buildEducationModuleMetadata;
13
+ exports.serializeEducationModuleMetadata = serializeEducationModuleMetadata;
14
+ /**
15
+ * Port of the metadata document `pop education create` /
16
+ * `pop education update` pin — key order is load-bearing:
17
+ * name, description, link, quiz, answers.
18
+ */
19
+ function buildEducationModuleMetadata(params) {
20
+ return {
21
+ name: params.name,
22
+ description: params.description || '',
23
+ link: params.link || '',
24
+ quiz: params.quiz || [],
25
+ answers: params.answers || [],
26
+ };
27
+ }
28
+ /** Exact serialization the CLI pins (plain JSON.stringify). */
29
+ function serializeEducationModuleMetadata(metadata) {
30
+ return JSON.stringify(metadata);
31
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Canonical metadata builders. KEY ORDER IS A PROTOCOL CONTRACT — the
3
+ * subgraph and every frontend parse these documents; hosts must never
4
+ * hand-build metadata objects.
5
+ */
6
+ export * as education from './education';
7
+ export * as org from './org';
8
+ export * as proposal from './proposal';
9
+ export * as role from './role';
10
+ export * as task from './task';
11
+ export * as token from './token';
12
+ export * as user from './user';
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ /**
3
+ * Canonical metadata builders. KEY ORDER IS A PROTOCOL CONTRACT — the
4
+ * subgraph and every frontend parse these documents; hosts must never
5
+ * hand-build metadata objects.
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.user = exports.token = exports.task = exports.role = exports.proposal = exports.org = exports.education = void 0;
42
+ exports.education = __importStar(require("./education"));
43
+ exports.org = __importStar(require("./org"));
44
+ exports.proposal = __importStar(require("./proposal"));
45
+ exports.role = __importStar(require("./role"));
46
+ exports.task = __importStar(require("./task"));
47
+ exports.token = __importStar(require("./token"));
48
+ exports.user = __importStar(require("./user"));