@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,9 @@
1
+ /**
2
+ * Org Activity Query
3
+ * Compound query for agent heartbeat — fetches all recent changes since a timestamp.
4
+ * Single subgraph round-trip replaces 6+ separate calls.
5
+ *
6
+ * Uses nested org queries for tasks/members (known working pattern),
7
+ * and top-level queries for vouches/tokenRequests/proposals (validated in other query files).
8
+ */
9
+ export declare const FETCH_ORG_ACTIVITY = "\n query FetchOrgActivity(\n $orgId: Bytes!\n $hybridVotingId: String\n $eligibilityModuleId: Bytes\n $tokenAddress: String\n ) {\n # Org overview + tasks + members via nested pattern (known working)\n organization(id: $orgId) {\n id\n name\n participationToken {\n id\n totalSupply\n symbol\n }\n paymentManager {\n distributionCounter\n }\n taskManager {\n id\n projects(where: { deleted: false }, first: 50) {\n id\n title\n tasks(first: 200, orderBy: taskId, orderDirection: desc) {\n id\n taskId\n title\n status\n payout\n assignee\n assigneeUsername\n completer\n completerUsername\n createdAt\n assignedAt\n submittedAt\n completedAt\n }\n }\n }\n users(orderBy: firstSeenAt, orderDirection: desc, first: 20) {\n address\n account { username }\n membershipStatus\n joinMethod\n firstSeenAt\n currentHatIds\n }\n directDemocracyVoting {\n ddvProposals(\n where: { status: \"Active\" }\n orderBy: startTimestamp\n orderDirection: desc\n first: 50\n ) {\n id\n proposalId\n title\n metadata { description optionNames }\n numOptions\n startTimestamp\n endTimestamp\n status\n isHatRestricted\n restrictedHatIds\n votes { voter optionIndexes optionWeights }\n }\n }\n }\n\n # Active hybrid proposals \u2014 top-level query (validated: proposals entity exists)\n activeHybridProposals: proposals(\n where: { hybridVoting: $hybridVotingId, status: \"Active\" }\n orderBy: startTimestamp\n orderDirection: desc\n first: 50\n ) {\n id\n proposalId\n title\n metadata { description optionNames }\n numOptions\n startTimestamp\n endTimestamp\n status\n isHatRestricted\n restrictedHatIds\n votes {\n voter\n voterUsername\n optionIndexes\n optionWeights\n classRawPowers\n votedAt\n }\n }\n\n # Recently ended hybrid proposals (catch outcomes since last heartbeat)\n endedHybridProposals: proposals(\n where: { hybridVoting: $hybridVotingId, status: \"Ended\" }\n orderBy: startTimestamp\n orderDirection: desc\n first: 10\n ) {\n id\n proposalId\n title\n status\n winningOption\n isValid\n wasExecuted\n executionFailed\n executionError\n votes { voter optionIndexes optionWeights }\n }\n\n # Active vouches \u2014 top-level query (validated in vouch.ts). isActive carries the\n # epoch filter: deployments that index the vouch epoch flip it false for every vouch\n # a configureVouching/resetVouches/clearWearerVouches voided, so this listing needs no\n # extra field. Older deployments still list superseded vouches \u2014 stale rather than\n # wrong, which is fine for an activity feed but NOT for quorum maths (see vouch.ts).\n activeVouches: vouches(\n where: { eligibilityModule: $eligibilityModuleId, isActive: true }\n orderBy: createdAt\n orderDirection: desc\n first: 100\n ) {\n hatId\n wearer\n wearerUsername\n voucher\n voucherUsername\n vouchCount\n createdAt\n }\n\n # Pending token requests \u2014 top-level query (validated in token.ts)\n pendingTokenRequests: tokenRequests(\n where: { participationToken: $tokenAddress, status: Pending }\n orderBy: createdAt\n orderDirection: desc\n first: 50\n ) {\n requestId\n requester\n amount\n metadata { reason }\n status\n createdAt\n }\n }\n";
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ /**
3
+ * Org Activity Query
4
+ * Compound query for agent heartbeat — fetches all recent changes since a timestamp.
5
+ * Single subgraph round-trip replaces 6+ separate calls.
6
+ *
7
+ * Uses nested org queries for tasks/members (known working pattern),
8
+ * and top-level queries for vouches/tokenRequests/proposals (validated in other query files).
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.FETCH_ORG_ACTIVITY = void 0;
12
+ exports.FETCH_ORG_ACTIVITY = `
13
+ query FetchOrgActivity(
14
+ $orgId: Bytes!
15
+ $hybridVotingId: String
16
+ $eligibilityModuleId: Bytes
17
+ $tokenAddress: String
18
+ ) {
19
+ # Org overview + tasks + members via nested pattern (known working)
20
+ organization(id: $orgId) {
21
+ id
22
+ name
23
+ participationToken {
24
+ id
25
+ totalSupply
26
+ symbol
27
+ }
28
+ paymentManager {
29
+ distributionCounter
30
+ }
31
+ taskManager {
32
+ id
33
+ projects(where: { deleted: false }, first: 50) {
34
+ id
35
+ title
36
+ tasks(first: 200, orderBy: taskId, orderDirection: desc) {
37
+ id
38
+ taskId
39
+ title
40
+ status
41
+ payout
42
+ assignee
43
+ assigneeUsername
44
+ completer
45
+ completerUsername
46
+ createdAt
47
+ assignedAt
48
+ submittedAt
49
+ completedAt
50
+ }
51
+ }
52
+ }
53
+ users(orderBy: firstSeenAt, orderDirection: desc, first: 20) {
54
+ address
55
+ account { username }
56
+ membershipStatus
57
+ joinMethod
58
+ firstSeenAt
59
+ currentHatIds
60
+ }
61
+ directDemocracyVoting {
62
+ ddvProposals(
63
+ where: { status: "Active" }
64
+ orderBy: startTimestamp
65
+ orderDirection: desc
66
+ first: 50
67
+ ) {
68
+ id
69
+ proposalId
70
+ title
71
+ metadata { description optionNames }
72
+ numOptions
73
+ startTimestamp
74
+ endTimestamp
75
+ status
76
+ isHatRestricted
77
+ restrictedHatIds
78
+ votes { voter optionIndexes optionWeights }
79
+ }
80
+ }
81
+ }
82
+
83
+ # Active hybrid proposals — top-level query (validated: proposals entity exists)
84
+ activeHybridProposals: proposals(
85
+ where: { hybridVoting: $hybridVotingId, status: "Active" }
86
+ orderBy: startTimestamp
87
+ orderDirection: desc
88
+ first: 50
89
+ ) {
90
+ id
91
+ proposalId
92
+ title
93
+ metadata { description optionNames }
94
+ numOptions
95
+ startTimestamp
96
+ endTimestamp
97
+ status
98
+ isHatRestricted
99
+ restrictedHatIds
100
+ votes {
101
+ voter
102
+ voterUsername
103
+ optionIndexes
104
+ optionWeights
105
+ classRawPowers
106
+ votedAt
107
+ }
108
+ }
109
+
110
+ # Recently ended hybrid proposals (catch outcomes since last heartbeat)
111
+ endedHybridProposals: proposals(
112
+ where: { hybridVoting: $hybridVotingId, status: "Ended" }
113
+ orderBy: startTimestamp
114
+ orderDirection: desc
115
+ first: 10
116
+ ) {
117
+ id
118
+ proposalId
119
+ title
120
+ status
121
+ winningOption
122
+ isValid
123
+ wasExecuted
124
+ executionFailed
125
+ executionError
126
+ votes { voter optionIndexes optionWeights }
127
+ }
128
+
129
+ # Active vouches — top-level query (validated in vouch.ts). isActive carries the
130
+ # epoch filter: deployments that index the vouch epoch flip it false for every vouch
131
+ # a configureVouching/resetVouches/clearWearerVouches voided, so this listing needs no
132
+ # extra field. Older deployments still list superseded vouches — stale rather than
133
+ # wrong, which is fine for an activity feed but NOT for quorum maths (see vouch.ts).
134
+ activeVouches: vouches(
135
+ where: { eligibilityModule: $eligibilityModuleId, isActive: true }
136
+ orderBy: createdAt
137
+ orderDirection: desc
138
+ first: 100
139
+ ) {
140
+ hatId
141
+ wearer
142
+ wearerUsername
143
+ voucher
144
+ voucherUsername
145
+ vouchCount
146
+ createdAt
147
+ }
148
+
149
+ # Pending token requests — top-level query (validated in token.ts)
150
+ pendingTokenRequests: tokenRequests(
151
+ where: { participationToken: $tokenAddress, status: Pending }
152
+ orderBy: createdAt
153
+ orderDirection: desc
154
+ first: 50
155
+ ) {
156
+ requestId
157
+ requester
158
+ amount
159
+ metadata { reason }
160
+ status
161
+ createdAt
162
+ }
163
+ }
164
+ `;
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Beacon / implementation queries — "which implementation is behind this proxy,
3
+ * and which version is that".
4
+ *
5
+ * Everything here replaces an RPC read that was either expensive or silently
6
+ * unreliable:
7
+ *
8
+ * - eth_getStorageAt(proxy, EIP-1967 beacon slot) + beacon.implementation()
9
+ * → RegisteredContract.beacon → SwitchableBeaconContract.mode → the
10
+ * implementation the beacon resolves to.
11
+ * - PoaManager.getCurrentImplementationById(typeId)
12
+ * → Beacon(typeId).currentImplementation.
13
+ * - OrgRegistry.isAutoUpgrade(keccak256(orgId ‖ typeId))
14
+ * → RegisteredContract.autoUpgrade (and no ContractUnknown revert path).
15
+ * - eth_getLogs(ImplementationRegistered, block 0 → latest)
16
+ * → BeaconUpgradeEvent.{newImplementation,version}.
17
+ *
18
+ * VERIFIED AGAINST LIVE DATA (Gnosis poa-gnosis-v-1 and Arbitrum poa-arb-v-1,
19
+ * 2026-07-30) — every field selected below is non-null on real rows, with two
20
+ * deliberate exceptions that are handled as gaps rather than trusted:
21
+ *
22
+ * - SwitchableBeaconContract.mirrorBeacon is NULL on EVERY live row on BOTH
23
+ * deployments. The Mirror branch therefore joins the global Beacon by
24
+ * typeId (RegisteredContract.typeId), never by mirrorBeacon.
25
+ * - SwitchableBeaconContract.pinnedImplementation is NULL on every live row
26
+ * and there is not a single row with mode = "Pinned" on either chain, so
27
+ * the field has never been observed populated. Pinned beacons therefore
28
+ * fall back to RPC unless the row actually carries a value.
29
+ *
30
+ * The join that IS used was checked end to end on Gnosis org "Test6":
31
+ * RegisteredContract(TaskManager).beacon = 0x4af43d51…d4da7c5
32
+ * == eth_getStorageAt(proxy 0x3d93f0d0…, EIP-1967 beacon slot)
33
+ * SwitchableBeaconContract(0x4af43d51…).mode = "Mirror"
34
+ * Beacon("gnosis-<TaskManager typeId>").currentImplementation
35
+ * = 0x7833c467… == beacon.implementation() over RPC. Match.
36
+ *
37
+ * A separate workstream is adding an implementation-address-keyed entity to
38
+ * the subgraph (Beacon.currentImplementation only answers for the CURRENT
39
+ * mirror implementation, not pinned or historical ones). Both query sets are
40
+ * expressed as tier ARRAYS fed to queryWithFieldFallback so that entity can be
41
+ * slotted in as a new tier 0 without touching any caller.
42
+ */
43
+ import type { GraphClient } from '../client';
44
+ export interface BeaconRow {
45
+ typeId: string;
46
+ typeName: string;
47
+ currentImplementation: string;
48
+ version: string | null;
49
+ /**
50
+ * The global beacon's own address. Only selected by the org-module documents,
51
+ * where it is needed to prove a Mirror beacon still mirrors THIS beacon.
52
+ */
53
+ beaconAddress?: string | null;
54
+ }
55
+ export interface RegisteredContractRow {
56
+ id: string;
57
+ typeId: string;
58
+ proxy: string;
59
+ beacon: string | null;
60
+ autoUpgrade: boolean | null;
61
+ }
62
+ export interface SwitchableBeaconRow {
63
+ /** The beacon's own address (entity id), lowercased by the indexer. */
64
+ id: string;
65
+ typeId: string | null;
66
+ /**
67
+ * "Mirror" | "Static" as written by the deployed mappings ("Pinned" is
68
+ * accepted as a forward-compatible alias). Anything else is unknown → RPC.
69
+ */
70
+ mode: string | null;
71
+ /**
72
+ * NULL on every live row today, because the SwitchableBeacon constructor sets
73
+ * it without emitting MirrorSet. A real setMirror() populates it — at which
74
+ * point it MUST be compared against Beacon.beaconAddress before joining the
75
+ * global beacon by typeId.
76
+ */
77
+ mirrorBeacon: string | null;
78
+ /** Never observed populated; only trusted when actually present. */
79
+ pinnedImplementation: string | null;
80
+ }
81
+ /** Tier 0: RegisteredContract + SwitchableBeaconContract + global Beacon. */
82
+ export declare const ORG_MODULE_BEACONS_FULL = "\n query OrgModuleBeacons($orgId: Bytes!, $orgIdStr: String!) {\n registeredContracts(first: 100, where: { orgId: $orgId }) {\n id\n typeId\n proxy\n beacon\n autoUpgrade\n }\n switchableBeaconContracts(first: 100, where: { organization: $orgIdStr }) {\n id\n typeId\n mode\n mirrorBeacon\n pinnedImplementation\n }\n beacons(first: 100) {\n typeId\n typeName\n currentImplementation\n version\n # Needed to prove a Mirror beacon still mirrors THIS global beacon.\n # Only tier 0 selects it: tiers 1/2 carry no SwitchableBeaconContract rows,\n # so their mode is unknown and they already degrade to RPC.\n beaconAddress\n }\n }\n";
83
+ /** Tier 1: deployment without SwitchableBeaconContract (mode unknown → RPC). */
84
+ export declare const ORG_MODULE_BEACONS_NO_SWITCHABLE = "\n query OrgModuleBeaconsNoSwitchable($orgId: Bytes!) {\n registeredContracts(first: 100, where: { orgId: $orgId }) {\n id\n typeId\n proxy\n beacon\n autoUpgrade\n }\n beacons(first: 100) {\n typeId\n typeName\n currentImplementation\n version\n }\n }\n";
85
+ /** Tier 2: global beacons only (still kills getCurrentImplementationById). */
86
+ export declare const ORG_MODULE_BEACONS_MINIMAL = "\n query OrgModuleBeaconsMinimal {\n beacons(first: 100) {\n typeId\n typeName\n currentImplementation\n version\n }\n }\n";
87
+ /** Tier 0: implementation → version index (global beacons + upgrade history). */
88
+ export declare const IMPLEMENTATION_VERSIONS_FULL = "\n query ImplementationVersions($first: Int!, $skip: Int!) {\n beacons(first: 100) {\n typeId\n typeName\n currentImplementation\n version\n }\n beaconUpgradeEvents(first: $first, skip: $skip, orderBy: upgradedAt, orderDirection: asc) {\n typeId\n newImplementation\n version\n }\n }\n";
89
+ /** Tier 1: deployment without BeaconUpgradeEvent — current implementations only. */
90
+ export declare const IMPLEMENTATION_VERSIONS_BEACONS_ONLY = "\n query ImplementationVersionsBeaconsOnly {\n beacons(first: 100) {\n typeId\n typeName\n currentImplementation\n version\n }\n }\n";
91
+ export interface ModuleBeaconEntry {
92
+ registered?: RegisteredContractRow;
93
+ switchable?: SwitchableBeaconRow;
94
+ globalBeacon?: BeaconRow;
95
+ }
96
+ export interface OrgBeaconSnapshot {
97
+ /** Keyed by lowercased typeId. */
98
+ byTypeId: Map<string, ModuleBeaconEntry>;
99
+ /** Which queryWithFieldFallback tier answered (0 = richest). */
100
+ tierIndex: number;
101
+ }
102
+ /**
103
+ * Checksum an address that came from the subgraph (which lowercases them) so
104
+ * subgraph-served values are byte-identical to the RPC-served ones the JSON
105
+ * output has always carried. Returns null for anything unparseable/zero.
106
+ */
107
+ export declare function checksumAddress(value: string | null | undefined): string | null;
108
+ /** Build the per-typeId index from raw query rows (pure — unit testable). */
109
+ export declare function buildOrgBeaconSnapshot(data: {
110
+ registeredContracts?: RegisteredContractRow[];
111
+ switchableBeaconContracts?: SwitchableBeaconRow[];
112
+ beacons?: BeaconRow[];
113
+ }, tierIndex?: number): OrgBeaconSnapshot;
114
+ /**
115
+ * Which implementation the org's module proxy currently delegates to, per the
116
+ * subgraph. Returns null whenever the subgraph cannot answer with confidence —
117
+ * the caller must then fall back to RPC. Never guesses.
118
+ */
119
+ export declare function resolveImplementationFromSnapshot(snapshot: OrgBeaconSnapshot | null | undefined, typeId: string): {
120
+ implementation: string;
121
+ version: string | null;
122
+ mode: string;
123
+ } | null;
124
+ /** Latest protocol implementation for a module type (PoaManager equivalent). */
125
+ export declare function latestImplementationFromSnapshot(snapshot: OrgBeaconSnapshot | null | undefined, typeId: string): string | null;
126
+ /**
127
+ * Registration-time autoUpgrade HINT — NOT an OrgRegistry.isAutoUpgrade equivalent.
128
+ *
129
+ * The deployed subgraph writes RegisteredContract.autoUpgrade once, inside
130
+ * handleContractRegistered, and never again: schema.graphql annotates it
131
+ * "immutable, set at registration" and there is no AutoUpgradeSet handler at all.
132
+ * OrgRegistry.setAutoUpgrade(orgId, typeId, bool) is a live mutator, so after an
133
+ * executor turns auto-upgrade OFF this value keeps reporting the registration-time
134
+ * `true` forever — and 91/91 live Gnosis rows are `true`, so the divergent case has
135
+ * never once been exercised.
136
+ *
137
+ * Callers that render a pinning claim MUST prefer the on-chain isAutoUpgrade read
138
+ * and use this only when OrgRegistry is unreachable (see org/status.ts).
139
+ */
140
+ export declare function autoUpgradeFromSnapshot(snapshot: OrgBeaconSnapshot | null | undefined, typeId: string): boolean | null;
141
+ /** The proxy's beacon address, when indexed — lets callers skip getStorageAt. */
142
+ export declare function beaconAddressFromSnapshot(snapshot: OrgBeaconSnapshot | null | undefined, typeId: string): string | null;
143
+ /**
144
+ * Fetch the org's module→beacon snapshot. Throws only on transport failure;
145
+ * callers treat a throw as "no snapshot" and use their RPC path.
146
+ */
147
+ export declare function fetchOrgBeaconSnapshot(client: GraphClient, orgId: string, chainId?: number): Promise<OrgBeaconSnapshot>;
148
+ export interface ImplementationVersionRow {
149
+ typeName: string;
150
+ version: string;
151
+ implementation: string;
152
+ /** True when this address is a global beacon's CURRENT implementation. */
153
+ latest: boolean;
154
+ }
155
+ /**
156
+ * Every implementation address the subgraph can name a version for, keyed by
157
+ * lowercased address.
158
+ *
159
+ * Sources: Beacon.currentImplementation (the live one per type) and
160
+ * BeaconUpgradeEvent.newImplementation (every implementation a global beacon
161
+ * has ever pointed at). Verified live: 71 upgrade events on Gnosis with zero
162
+ * null newImplementation/version values, and identical implementation
163
+ * addresses on Arbitrum (deterministic deploys), so the index is chain-safe.
164
+ *
165
+ * NOT covered: an implementation that was registered but never promoted onto a
166
+ * global beacon (only reachable by pinning to it). Callers keep the registry
167
+ * eth_getLogs scan as the explicit fallback for exactly that case.
168
+ */
169
+ export declare function fetchImplementationVersionIndex(client: GraphClient, chainId?: number): Promise<{
170
+ index: Map<string, ImplementationVersionRow>;
171
+ tierIndex: number;
172
+ }>;