@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,16 @@
1
+ /**
2
+ * Typed subgraph reads by domain. reads/resolve.ts (org resolution) is
3
+ * re-exported flat; each domain is a namespace.
4
+ */
5
+ export * from './resolve';
6
+ export * as education from './education';
7
+ export * as eligibility from './eligibility';
8
+ export * as org from './org';
9
+ export * as paymaster from './paymaster';
10
+ export * as project from './project';
11
+ export * as task from './task';
12
+ export * as token from './token';
13
+ export * as treasury from './treasury';
14
+ export * as user from './user';
15
+ export * as vote from './vote';
16
+ export * as zkemail from './zkemail';
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ /**
3
+ * Typed subgraph reads by domain. reads/resolve.ts (org resolution) is
4
+ * re-exported flat; each domain is a namespace.
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
23
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
24
+ };
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.zkemail = exports.vote = exports.user = exports.treasury = exports.token = exports.task = exports.project = exports.paymaster = exports.org = exports.eligibility = exports.education = void 0;
44
+ __exportStar(require("./resolve"), exports);
45
+ exports.education = __importStar(require("./education"));
46
+ exports.eligibility = __importStar(require("./eligibility"));
47
+ exports.org = __importStar(require("./org"));
48
+ exports.paymaster = __importStar(require("./paymaster"));
49
+ exports.project = __importStar(require("./project"));
50
+ exports.task = __importStar(require("./task"));
51
+ exports.token = __importStar(require("./token"));
52
+ exports.treasury = __importStar(require("./treasury"));
53
+ exports.user = __importStar(require("./user"));
54
+ exports.vote = __importStar(require("./vote"));
55
+ exports.zkemail = __importStar(require("./zkemail"));
@@ -0,0 +1,258 @@
1
+ /**
2
+ * Org reads — typed wrappers over the org subgraph documents.
3
+ *
4
+ * Ports the read layer of:
5
+ * - `pop org view` — src/commands/org/view.ts
6
+ * - `pop org list` — src/commands/org/list.ts
7
+ * - `pop org members` — src/commands/org/members.ts
8
+ * - `pop org roles` — src/commands/org/roles.ts
9
+ * - `pop org status` — src/commands/org/status.ts (activity slice only; the
10
+ * module-version panel is beacon/RPC machinery owned by the infra layer)
11
+ *
12
+ * Rows come back raw from the subgraph — a null row means "not indexed on
13
+ * this chain", which for a young org can mean "not indexed YET", not
14
+ * "nonexistent".
15
+ */
16
+ import { ethers } from 'ethers';
17
+ import type { GraphClient, ChainQueryResult } from '../graph/client';
18
+ import type { InfrastructureAddresses } from '../graph/documents/infrastructure';
19
+ import type { IpfsOptions } from '../ipfs';
20
+ export interface OrgModuleRef {
21
+ id: string;
22
+ }
23
+ /** Raw Organization row as returned by FETCH_ORG_FULL_DATA. */
24
+ export interface OrganizationFullRow {
25
+ id: string;
26
+ name: string | null;
27
+ metadataHash: string | null;
28
+ metadataAdminHatId: string | null;
29
+ metadata: Record<string, any> | null;
30
+ deployedAt: string | null;
31
+ topHatId: string | null;
32
+ roleHatIds: string[] | null;
33
+ participationToken: {
34
+ id: string;
35
+ name: string;
36
+ symbol: string;
37
+ totalSupply: string;
38
+ } | null;
39
+ quickJoin: OrgModuleRef | null;
40
+ hybridVoting: {
41
+ id: string;
42
+ thresholdPct: string | number;
43
+ quorum: string | number;
44
+ } | null;
45
+ directDemocracyVoting: {
46
+ id: string;
47
+ thresholdPct: string | number;
48
+ quorum: string | number;
49
+ } | null;
50
+ zkEmailInvites: OrgModuleRef | null;
51
+ taskManager: {
52
+ id: string;
53
+ creatorHatIds: string[] | null;
54
+ projects: Array<{
55
+ id: string;
56
+ tasks: Array<{
57
+ id: string;
58
+ status: string;
59
+ }>;
60
+ }>;
61
+ } | null;
62
+ educationHub: {
63
+ id: string;
64
+ modules: any[];
65
+ } | null;
66
+ executorContract: OrgModuleRef | null;
67
+ eligibilityModule: OrgModuleRef | null;
68
+ paymentManager: OrgModuleRef | null;
69
+ users: Array<{
70
+ id: string;
71
+ address: string;
72
+ account: {
73
+ username: string | null;
74
+ metadata: {
75
+ avatar: string | null;
76
+ } | null;
77
+ } | null;
78
+ participationTokenBalance: string;
79
+ membershipStatus: string;
80
+ currentHatIds: string[] | null;
81
+ totalTasksCompleted: string | null;
82
+ totalVotes: string | null;
83
+ firstSeenAt: string | null;
84
+ }>;
85
+ roles: Array<{
86
+ id: string;
87
+ hatId: string;
88
+ name: string | null;
89
+ image: string | null;
90
+ canVote: boolean;
91
+ isUserRole: boolean;
92
+ hat: {
93
+ name: string | null;
94
+ } | null;
95
+ }>;
96
+ }
97
+ /** Verbatim from src/commands/org/list.ts. */
98
+ export declare const LIST_ORGS_QUERY = "\n query ListOrgs($first: Int!) {\n organizations(first: $first, orderBy: deployedAt, orderDirection: desc) {\n id\n name\n deployedAt\n }\n }\n";
99
+ /** Verbatim from src/commands/org/members.ts. */
100
+ export declare const FETCH_MEMBERS = "\n query FetchMembers($orgId: Bytes!) {\n organization(id: $orgId) {\n participationToken {\n totalSupply\n }\n users(orderBy: participationTokenBalance, orderDirection: desc, first: 100) {\n address\n participationTokenBalance\n membershipStatus\n totalTasksCompleted\n totalVotes\n firstSeenAt\n account {\n username\n }\n }\n }\n }\n";
101
+ /**
102
+ * Resolve an org name to its 0x id (passthrough for 0x input) — the name
103
+ * lookup `pop org view` performs. Returns null when the name matches nothing
104
+ * (unlike reads/resolve.resolveOrgId, which throws — view-style callers want
105
+ * "not found" as data).
106
+ */
107
+ export declare function findOrgId(client: GraphClient, orgIdOrName: string, chainId?: number): Promise<string | null>;
108
+ /**
109
+ * Port of the `pop org view` read — src/commands/org/view.ts.
110
+ * Full org snapshot (modules, roles, token, voting config, members) via
111
+ * FETCH_ORG_FULL_DATA. Accepts a name or 0x id; null when not indexed.
112
+ */
113
+ export declare function getOrganization(client: GraphClient, orgIdOrName: string, chainId?: number): Promise<OrganizationFullRow | null>;
114
+ /**
115
+ * The org's metadata document: the indexed projection when present, else the
116
+ * raw IPFS doc behind metadataHash (`pop org view` fallback). Never throws —
117
+ * null when neither source answers. NOTE: for the update-metadata merge base
118
+ * use the RAW IPFS doc, not this convenience read (see tx/org.ts).
119
+ */
120
+ export declare function getOrgMetadataDoc(org: Pick<OrganizationFullRow, 'metadata' | 'metadataHash'>, ipfs?: IpfsOptions): Promise<Record<string, any> | null>;
121
+ /**
122
+ * Current metadata-admin hat (0 = unset → topHat fallback) — port of
123
+ * readMetadataAdminHat in src/commands/org/view.ts.
124
+ *
125
+ * Subgraph-first: Organization.metadataAdminHatId is rewritten by
126
+ * handleOrgMetadataAdminHatSet on every OrgMetadataAdminHatSet event and is
127
+ * non-null on every live org. Only when the subgraph has no value AND a
128
+ * provider is supplied do we resolve the OrgRegistry and read the on-chain
129
+ * getter. Returns null when neither source is reachable; never throws.
130
+ * Display-only by convention — never gate a write on it.
131
+ */
132
+ export declare function getMetadataAdminHat(client: GraphClient, orgId: string, chainId?: number, provider?: ethers.providers.Provider): Promise<string | null>;
133
+ export interface OrgListRow {
134
+ id: string;
135
+ name: string | null;
136
+ deployedAt: string | null;
137
+ }
138
+ /**
139
+ * Port of the single-chain `pop org list` read — src/commands/org/list.ts.
140
+ */
141
+ export declare function listOrgs(client: GraphClient, chainId?: number, first?: number): Promise<OrgListRow[]>;
142
+ /**
143
+ * Port of the all-chain `pop org list` sweep — src/commands/org/list.ts.
144
+ * Per-chain failures are reported in ChainQueryResult.error, not thrown.
145
+ */
146
+ export declare function listOrgsAllChains(client: GraphClient, first?: number): Promise<Array<ChainQueryResult<{
147
+ organizations: OrgListRow[];
148
+ }>>>;
149
+ export interface UserOrganizationRow {
150
+ id: string;
151
+ membershipStatus: string;
152
+ participationTokenBalance: string;
153
+ totalTasksCompleted: string | null;
154
+ totalVotes: string | null;
155
+ organization: {
156
+ id: string;
157
+ name: string | null;
158
+ metadataHash: string | null;
159
+ participationToken: {
160
+ symbol: string;
161
+ } | null;
162
+ } | null;
163
+ }
164
+ /**
165
+ * Port of the `pop org list --member` read — src/commands/org/list.ts
166
+ * (FETCH_USER_ORGANIZATIONS): active memberships for an address.
167
+ */
168
+ export declare function listUserOrganizations(client: GraphClient, userAddress: string, chainId?: number): Promise<UserOrganizationRow[]>;
169
+ export interface OrgMembersResult {
170
+ participationToken: {
171
+ totalSupply: string;
172
+ } | null;
173
+ users: Array<{
174
+ address: string;
175
+ participationTokenBalance: string;
176
+ membershipStatus: string;
177
+ totalTasksCompleted: string | null;
178
+ totalVotes: string | null;
179
+ firstSeenAt: string | null;
180
+ account: {
181
+ username: string | null;
182
+ } | null;
183
+ }>;
184
+ }
185
+ /**
186
+ * Port of the `pop org members` read — src/commands/org/members.ts.
187
+ * Raw member rows ordered by PT balance desc (top 100), plus totalSupply for
188
+ * share math. Null when the org is not indexed.
189
+ */
190
+ export declare function listMembers(client: GraphClient, orgId: string, chainId?: number): Promise<OrgMembersResult | null>;
191
+ export interface OrgRolesResult {
192
+ organization: {
193
+ roles: Array<{
194
+ id: string;
195
+ hatId: string;
196
+ name: string | null;
197
+ image: string | null;
198
+ canVote: boolean;
199
+ isUserRole: boolean;
200
+ /** Present only when tier 0 served (Hat.vouchConfig schema). */
201
+ hat?: {
202
+ id: string;
203
+ vouchConfig: {
204
+ enabled: boolean;
205
+ quorum: string;
206
+ membershipHatId: string;
207
+ combinesWithHierarchy: boolean;
208
+ } | null;
209
+ } | null;
210
+ }>;
211
+ users: Array<{
212
+ address: string;
213
+ participationTokenBalance: string;
214
+ membershipStatus: string;
215
+ currentHatIds: string[] | null;
216
+ account: {
217
+ username: string | null;
218
+ } | null;
219
+ }>;
220
+ eligibilityModule: {
221
+ id: string;
222
+ } | null;
223
+ } | null;
224
+ }
225
+ /**
226
+ * Port of the `pop org roles` read — src/commands/org/roles.ts.
227
+ *
228
+ * Tier 0 carries Role.hat.vouchConfig (present + populated on Gnosis and
229
+ * Arbitrum; a null vouchConfig means "never configured", verified equal to
230
+ * isVouchingEnabled()==false / quorum==0 on-chain). Tier 1 is the
231
+ * pre-vouchConfig schema; GraphQL validates the whole document, so the
232
+ * unknown-field fallback is what keeps older deployments working. When
233
+ * tierIndex === 1 serves, the CLI falls back to batched EligibilityModule
234
+ * reads through Multicall3 — that RPC path stays host-side.
235
+ */
236
+ export declare function listRoles(client: GraphClient, orgId: string, chainId?: number): Promise<{
237
+ data: OrgRolesResult;
238
+ tierIndex: number;
239
+ }>;
240
+ /**
241
+ * Port of the `pop org status` activity read — src/commands/org/status.ts
242
+ * (FETCH_ORG_ACTIVITY). The extra module addresses scope the top-level
243
+ * proposal/vouch/token-request slices; the CLI passes '' for missing modules.
244
+ * Raw result; the status command's module-version panel (beacons/multicall)
245
+ * is separate infrastructure.
246
+ */
247
+ export declare function getOrgActivity(client: GraphClient, modules: {
248
+ orgId: string;
249
+ hybridVotingAddress?: string | null;
250
+ eligibilityModuleAddress?: string | null;
251
+ participationTokenAddress?: string | null;
252
+ }, chainId?: number): Promise<any>;
253
+ /**
254
+ * Global infrastructure addresses (`FETCH_INFRASTRUCTURE_ADDRESSES`) — the
255
+ * OrgDeployer/OrgRegistry/PaymasterHub/UniversalAccountRegistry proxies and
256
+ * the beacon table.
257
+ */
258
+ export declare function getInfrastructureAddresses(client: GraphClient, chainId?: number): Promise<InfrastructureAddresses>;
@@ -0,0 +1,220 @@
1
+ "use strict";
2
+ /**
3
+ * Org reads — typed wrappers over the org subgraph documents.
4
+ *
5
+ * Ports the read layer of:
6
+ * - `pop org view` — src/commands/org/view.ts
7
+ * - `pop org list` — src/commands/org/list.ts
8
+ * - `pop org members` — src/commands/org/members.ts
9
+ * - `pop org roles` — src/commands/org/roles.ts
10
+ * - `pop org status` — src/commands/org/status.ts (activity slice only; the
11
+ * module-version panel is beacon/RPC machinery owned by the infra layer)
12
+ *
13
+ * Rows come back raw from the subgraph — a null row means "not indexed on
14
+ * this chain", which for a young org can mean "not indexed YET", not
15
+ * "nonexistent".
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.FETCH_MEMBERS = exports.LIST_ORGS_QUERY = void 0;
19
+ exports.findOrgId = findOrgId;
20
+ exports.getOrganization = getOrganization;
21
+ exports.getOrgMetadataDoc = getOrgMetadataDoc;
22
+ exports.getMetadataAdminHat = getMetadataAdminHat;
23
+ exports.listOrgs = listOrgs;
24
+ exports.listOrgsAllChains = listOrgsAllChains;
25
+ exports.listUserOrganizations = listUserOrganizations;
26
+ exports.listMembers = listMembers;
27
+ exports.listRoles = listRoles;
28
+ exports.getOrgActivity = getOrgActivity;
29
+ exports.getInfrastructureAddresses = getInfrastructureAddresses;
30
+ const org_1 = require("../graph/documents/org");
31
+ const roles_1 = require("../graph/documents/roles");
32
+ const activity_1 = require("../graph/documents/activity");
33
+ const infrastructure_1 = require("../graph/documents/infrastructure");
34
+ const contracts_1 = require("../contracts");
35
+ const ipfs_1 = require("../ipfs");
36
+ // ---------------------------------------------------------------------------
37
+ // Inline documents ported from the org command files (not in src/queries)
38
+ // ---------------------------------------------------------------------------
39
+ /** Verbatim from src/commands/org/list.ts. */
40
+ exports.LIST_ORGS_QUERY = `
41
+ query ListOrgs($first: Int!) {
42
+ organizations(first: $first, orderBy: deployedAt, orderDirection: desc) {
43
+ id
44
+ name
45
+ deployedAt
46
+ }
47
+ }
48
+ `;
49
+ /** Verbatim from src/commands/org/members.ts. */
50
+ exports.FETCH_MEMBERS = `
51
+ query FetchMembers($orgId: Bytes!) {
52
+ organization(id: $orgId) {
53
+ participationToken {
54
+ totalSupply
55
+ }
56
+ users(orderBy: participationTokenBalance, orderDirection: desc, first: 100) {
57
+ address
58
+ participationTokenBalance
59
+ membershipStatus
60
+ totalTasksCompleted
61
+ totalVotes
62
+ firstSeenAt
63
+ account {
64
+ username
65
+ }
66
+ }
67
+ }
68
+ }
69
+ `;
70
+ // ---------------------------------------------------------------------------
71
+ // Reads
72
+ // ---------------------------------------------------------------------------
73
+ /**
74
+ * Resolve an org name to its 0x id (passthrough for 0x input) — the name
75
+ * lookup `pop org view` performs. Returns null when the name matches nothing
76
+ * (unlike reads/resolve.resolveOrgId, which throws — view-style callers want
77
+ * "not found" as data).
78
+ */
79
+ async function findOrgId(client, orgIdOrName, chainId) {
80
+ if (orgIdOrName.startsWith('0x'))
81
+ return orgIdOrName;
82
+ const result = await client.query(org_1.GET_ORG_BY_NAME, { name: orgIdOrName }, chainId);
83
+ return result.organizations?.[0]?.id ?? null;
84
+ }
85
+ /**
86
+ * Port of the `pop org view` read — src/commands/org/view.ts.
87
+ * Full org snapshot (modules, roles, token, voting config, members) via
88
+ * FETCH_ORG_FULL_DATA. Accepts a name or 0x id; null when not indexed.
89
+ */
90
+ async function getOrganization(client, orgIdOrName, chainId) {
91
+ const orgId = await findOrgId(client, orgIdOrName, chainId);
92
+ if (!orgId)
93
+ return null;
94
+ const result = await client.query(org_1.FETCH_ORG_FULL_DATA, { orgId }, chainId);
95
+ return result.organization ?? null;
96
+ }
97
+ /**
98
+ * The org's metadata document: the indexed projection when present, else the
99
+ * raw IPFS doc behind metadataHash (`pop org view` fallback). Never throws —
100
+ * null when neither source answers. NOTE: for the update-metadata merge base
101
+ * use the RAW IPFS doc, not this convenience read (see tx/org.ts).
102
+ */
103
+ async function getOrgMetadataDoc(org, ipfs) {
104
+ if (org.metadata)
105
+ return org.metadata;
106
+ if (!org.metadataHash)
107
+ return null;
108
+ try {
109
+ return await (0, ipfs_1.fetchJson)(org.metadataHash, ipfs);
110
+ }
111
+ catch {
112
+ return null;
113
+ }
114
+ }
115
+ /**
116
+ * Current metadata-admin hat (0 = unset → topHat fallback) — port of
117
+ * readMetadataAdminHat in src/commands/org/view.ts.
118
+ *
119
+ * Subgraph-first: Organization.metadataAdminHatId is rewritten by
120
+ * handleOrgMetadataAdminHatSet on every OrgMetadataAdminHatSet event and is
121
+ * non-null on every live org. Only when the subgraph has no value AND a
122
+ * provider is supplied do we resolve the OrgRegistry and read the on-chain
123
+ * getter. Returns null when neither source is reachable; never throws.
124
+ * Display-only by convention — never gate a write on it.
125
+ */
126
+ async function getMetadataAdminHat(client, orgId, chainId, provider) {
127
+ try {
128
+ const result = await client.query(roles_1.FETCH_ORG_METADATA_ADMIN_HAT, { orgId }, chainId);
129
+ const fromSubgraph = result.organization?.metadataAdminHatId;
130
+ if (fromSubgraph !== undefined && fromSubgraph !== null) {
131
+ return String(fromSubgraph);
132
+ }
133
+ }
134
+ catch { /* fall through to RPC */ }
135
+ if (!provider)
136
+ return null;
137
+ try {
138
+ const infra = await client.query(infrastructure_1.FETCH_INFRASTRUCTURE_ADDRESSES, {}, chainId);
139
+ const orgRegistryAddr = infra.poaManagerContracts?.[0]?.orgRegistryProxy;
140
+ if (!orgRegistryAddr)
141
+ return null;
142
+ const registry = (0, contracts_1.createReadContract)(orgRegistryAddr, 'OrgRegistry', provider);
143
+ const hat = await registry.getOrgMetadataAdminHat(orgId);
144
+ return hat.toString();
145
+ }
146
+ catch {
147
+ return null;
148
+ }
149
+ }
150
+ /**
151
+ * Port of the single-chain `pop org list` read — src/commands/org/list.ts.
152
+ */
153
+ async function listOrgs(client, chainId, first = 50) {
154
+ const result = await client.query(exports.LIST_ORGS_QUERY, { first }, chainId);
155
+ return result.organizations || [];
156
+ }
157
+ /**
158
+ * Port of the all-chain `pop org list` sweep — src/commands/org/list.ts.
159
+ * Per-chain failures are reported in ChainQueryResult.error, not thrown.
160
+ */
161
+ async function listOrgsAllChains(client, first = 50) {
162
+ return client.queryAllChains(exports.LIST_ORGS_QUERY, { first });
163
+ }
164
+ /**
165
+ * Port of the `pop org list --member` read — src/commands/org/list.ts
166
+ * (FETCH_USER_ORGANIZATIONS): active memberships for an address.
167
+ */
168
+ async function listUserOrganizations(client, userAddress, chainId) {
169
+ const result = await client.query(org_1.FETCH_USER_ORGANIZATIONS, { userAddress }, chainId);
170
+ return result.users || [];
171
+ }
172
+ /**
173
+ * Port of the `pop org members` read — src/commands/org/members.ts.
174
+ * Raw member rows ordered by PT balance desc (top 100), plus totalSupply for
175
+ * share math. Null when the org is not indexed.
176
+ */
177
+ async function listMembers(client, orgId, chainId) {
178
+ const result = await client.query(exports.FETCH_MEMBERS, { orgId }, chainId);
179
+ return result.organization ?? null;
180
+ }
181
+ /**
182
+ * Port of the `pop org roles` read — src/commands/org/roles.ts.
183
+ *
184
+ * Tier 0 carries Role.hat.vouchConfig (present + populated on Gnosis and
185
+ * Arbitrum; a null vouchConfig means "never configured", verified equal to
186
+ * isVouchingEnabled()==false / quorum==0 on-chain). Tier 1 is the
187
+ * pre-vouchConfig schema; GraphQL validates the whole document, so the
188
+ * unknown-field fallback is what keeps older deployments working. When
189
+ * tierIndex === 1 serves, the CLI falls back to batched EligibilityModule
190
+ * reads through Multicall3 — that RPC path stays host-side.
191
+ */
192
+ async function listRoles(client, orgId, chainId) {
193
+ return client.queryWithFieldFallback([
194
+ { query: roles_1.FETCH_ROLES_MEMBERS_AND_VOUCH, variables: { id: orgId } },
195
+ { query: roles_1.FETCH_ROLES_AND_MEMBERS, variables: { id: orgId } },
196
+ ], { chainId });
197
+ }
198
+ /**
199
+ * Port of the `pop org status` activity read — src/commands/org/status.ts
200
+ * (FETCH_ORG_ACTIVITY). The extra module addresses scope the top-level
201
+ * proposal/vouch/token-request slices; the CLI passes '' for missing modules.
202
+ * Raw result; the status command's module-version panel (beacons/multicall)
203
+ * is separate infrastructure.
204
+ */
205
+ async function getOrgActivity(client, modules, chainId) {
206
+ return client.query(activity_1.FETCH_ORG_ACTIVITY, {
207
+ orgId: modules.orgId,
208
+ hybridVotingId: modules.hybridVotingAddress || '',
209
+ eligibilityModuleId: modules.eligibilityModuleAddress || '',
210
+ tokenAddress: modules.participationTokenAddress || '',
211
+ }, chainId);
212
+ }
213
+ /**
214
+ * Global infrastructure addresses (`FETCH_INFRASTRUCTURE_ADDRESSES`) — the
215
+ * OrgDeployer/OrgRegistry/PaymasterHub/UniversalAccountRegistry proxies and
216
+ * the beacon table.
217
+ */
218
+ async function getInfrastructureAddresses(client, chainId) {
219
+ return client.query(infrastructure_1.FETCH_INFRASTRUCTURE_ADDRESSES, {}, chainId);
220
+ }