@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.
- package/README.md +201 -0
- package/dist/abis/DirectDemocracyVotingNew.d.ts +749 -0
- package/dist/abis/DirectDemocracyVotingNew.js +961 -0
- package/dist/abis/ERC20.d.ts +90 -0
- package/dist/abis/ERC20.js +125 -0
- package/dist/abis/EducationHubNew.d.ts +590 -0
- package/dist/abis/EducationHubNew.js +762 -0
- package/dist/abis/EligibilityModuleNew.d.ts +1615 -0
- package/dist/abis/EligibilityModuleNew.js +2082 -0
- package/dist/abis/Executor.d.ts +619 -0
- package/dist/abis/Executor.js +796 -0
- package/dist/abis/HybridVotingNew.d.ts +898 -0
- package/dist/abis/HybridVotingNew.js +1149 -0
- package/dist/abis/ImplementationRegistry.d.ts +270 -0
- package/dist/abis/ImplementationRegistry.js +355 -0
- package/dist/abis/OrgDeployerNew.d.ts +1275 -0
- package/dist/abis/OrgDeployerNew.js +1630 -0
- package/dist/abis/OrgRegistry.d.ts +670 -0
- package/dist/abis/OrgRegistry.js +868 -0
- package/dist/abis/ParticipationToken.d.ts +1086 -0
- package/dist/abis/ParticipationToken.js +1415 -0
- package/dist/abis/PasskeyAccount.d.ts +788 -0
- package/dist/abis/PasskeyAccount.js +1019 -0
- package/dist/abis/PasskeyAccountFactory.d.ts +344 -0
- package/dist/abis/PasskeyAccountFactory.js +449 -0
- package/dist/abis/PaymasterHub.d.ts +1603 -0
- package/dist/abis/PaymasterHub.js +2048 -0
- package/dist/abis/PaymentManager.d.ts +520 -0
- package/dist/abis/PaymentManager.js +671 -0
- package/dist/abis/PoaManager.d.ts +344 -0
- package/dist/abis/PoaManager.js +449 -0
- package/dist/abis/QuickJoinNew.d.ts +855 -0
- package/dist/abis/QuickJoinNew.js +1098 -0
- package/dist/abis/TaskManagerNew.d.ts +1236 -0
- package/dist/abis/TaskManagerNew.js +1573 -0
- package/dist/abis/ToggleModule.d.ts +193 -0
- package/dist/abis/ToggleModule.js +255 -0
- package/dist/abis/UniversalAccountRegistry.d.ts +577 -0
- package/dist/abis/UniversalAccountRegistry.js +750 -0
- package/dist/abis/ZkEmailInvites.d.ts +823 -0
- package/dist/abis/ZkEmailInvites.js +1060 -0
- package/dist/abis/external/AaveGovernanceV2.d.ts +128 -0
- package/dist/abis/external/AaveGovernanceV2.js +177 -0
- package/dist/abis/external/AaveGovernanceV3.d.ts +160 -0
- package/dist/abis/external/AaveGovernanceV3.js +220 -0
- package/dist/abis/external/AragonVoting.d.ts +107 -0
- package/dist/abis/external/AragonVoting.js +150 -0
- package/dist/abis/external/CurveGaugeController.d.ts +95 -0
- package/dist/abis/external/CurveGaugeController.js +130 -0
- package/dist/abis/external/CurveVotingEscrow.d.ts +86 -0
- package/dist/abis/external/CurveVotingEscrow.js +116 -0
- package/dist/abis/external/GovernorAlpha.d.ts +172 -0
- package/dist/abis/external/GovernorAlpha.js +228 -0
- package/dist/abis/external/MakerDAOChief.d.ts +92 -0
- package/dist/abis/external/MakerDAOChief.js +129 -0
- package/dist/abis/external/OZGovernor.d.ts +227 -0
- package/dist/abis/external/OZGovernor.js +317 -0
- package/dist/abis/external/SolidlyVotingEscrow.d.ts +196 -0
- package/dist/abis/external/SolidlyVotingEscrow.js +260 -0
- package/dist/abis/index.d.ts +62 -0
- package/dist/abis/index.js +98 -0
- package/dist/chains.d.ts +150 -0
- package/dist/chains.js +320 -0
- package/dist/context.d.ts +48 -0
- package/dist/context.js +38 -0
- package/dist/contracts.d.ts +24 -0
- package/dist/contracts.js +41 -0
- package/dist/encoding.d.ts +58 -0
- package/dist/encoding.js +243 -0
- package/dist/env.d.ts +10 -0
- package/dist/env.js +4 -0
- package/dist/error-catalog.d.ts +41 -0
- package/dist/error-catalog.js +941 -0
- package/dist/errors.d.ts +27 -0
- package/dist/errors.js +60 -0
- package/dist/execute/ethers.d.ts +93 -0
- package/dist/execute/ethers.js +323 -0
- package/dist/execute/index.d.ts +7 -0
- package/dist/execute/index.js +23 -0
- package/dist/execute/sponsored.d.ts +68 -0
- package/dist/execute/sponsored.js +277 -0
- package/dist/exit-codes.d.ts +18 -0
- package/dist/exit-codes.js +21 -0
- package/dist/format.d.ts +21 -0
- package/dist/format.js +89 -0
- package/dist/graph/client.d.ts +298 -0
- package/dist/graph/client.js +702 -0
- package/dist/graph/documents/activity.d.ts +9 -0
- package/dist/graph/documents/activity.js +164 -0
- package/dist/graph/documents/beacons.d.ts +172 -0
- package/dist/graph/documents/beacons.js +345 -0
- package/dist/graph/documents/index.d.ts +21 -0
- package/dist/graph/documents/index.js +57 -0
- package/dist/graph/documents/infrastructure.d.ts +30 -0
- package/dist/graph/documents/infrastructure.js +34 -0
- package/dist/graph/documents/org.d.ts +15 -0
- package/dist/graph/documents/org.js +249 -0
- package/dist/graph/documents/paymaster.d.ts +95 -0
- package/dist/graph/documents/paymaster.js +101 -0
- package/dist/graph/documents/role.d.ts +6 -0
- package/dist/graph/documents/role.js +41 -0
- package/dist/graph/documents/roles.d.ts +50 -0
- package/dist/graph/documents/roles.js +112 -0
- package/dist/graph/documents/task.d.ts +84 -0
- package/dist/graph/documents/task.js +236 -0
- package/dist/graph/documents/token.d.ts +13 -0
- package/dist/graph/documents/token.js +126 -0
- package/dist/graph/documents/treasury.d.ts +39 -0
- package/dist/graph/documents/treasury.js +136 -0
- package/dist/graph/documents/user.d.ts +120 -0
- package/dist/graph/documents/user.js +302 -0
- package/dist/graph/documents/voting-classes.d.ts +69 -0
- package/dist/graph/documents/voting-classes.js +149 -0
- package/dist/graph/documents/voting.d.ts +28 -0
- package/dist/graph/documents/voting.js +163 -0
- package/dist/graph/documents/vouch.d.ts +79 -0
- package/dist/graph/documents/vouch.js +171 -0
- package/dist/graph/documents/zkemail.d.ts +63 -0
- package/dist/graph/documents/zkemail.js +188 -0
- package/dist/graph/index.d.ts +2 -0
- package/dist/graph/index.js +41 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +92 -0
- package/dist/ipfs.d.ts +39 -0
- package/dist/ipfs.js +214 -0
- package/dist/label-aliases.d.ts +31 -0
- package/dist/label-aliases.js +70 -0
- package/dist/metadata/education.d.ts +30 -0
- package/dist/metadata/education.js +31 -0
- package/dist/metadata/index.d.ts +12 -0
- package/dist/metadata/index.js +48 -0
- package/dist/metadata/org.d.ts +92 -0
- package/dist/metadata/org.js +93 -0
- package/dist/metadata/proposal.d.ts +44 -0
- package/dist/metadata/proposal.js +45 -0
- package/dist/metadata/role.d.ts +38 -0
- package/dist/metadata/role.js +35 -0
- package/dist/metadata/task.d.ts +108 -0
- package/dist/metadata/task.js +81 -0
- package/dist/metadata/token.d.ts +32 -0
- package/dist/metadata/token.js +36 -0
- package/dist/metadata/user.d.ts +63 -0
- package/dist/metadata/user.js +70 -0
- package/dist/multicall.d.ts +32 -0
- package/dist/multicall.js +96 -0
- package/dist/payout.d.ts +59 -0
- package/dist/payout.js +96 -0
- package/dist/perms.d.ts +47 -0
- package/dist/perms.js +120 -0
- package/dist/preflight.d.ts +72 -0
- package/dist/preflight.js +269 -0
- package/dist/reads/education.d.ts +79 -0
- package/dist/reads/education.js +122 -0
- package/dist/reads/eligibility.d.ts +377 -0
- package/dist/reads/eligibility.js +687 -0
- package/dist/reads/index.d.ts +16 -0
- package/dist/reads/index.js +55 -0
- package/dist/reads/org.d.ts +258 -0
- package/dist/reads/org.js +220 -0
- package/dist/reads/paymaster.d.ts +147 -0
- package/dist/reads/paymaster.js +235 -0
- package/dist/reads/project.d.ts +33 -0
- package/dist/reads/project.js +62 -0
- package/dist/reads/resolve.d.ts +34 -0
- package/dist/reads/resolve.js +64 -0
- package/dist/reads/task.d.ts +286 -0
- package/dist/reads/task.js +280 -0
- package/dist/reads/token.d.ts +94 -0
- package/dist/reads/token.js +75 -0
- package/dist/reads/treasury.d.ts +222 -0
- package/dist/reads/treasury.js +241 -0
- package/dist/reads/user.d.ts +229 -0
- package/dist/reads/user.js +155 -0
- package/dist/reads/vote.d.ts +296 -0
- package/dist/reads/vote.js +392 -0
- package/dist/reads/zkemail.d.ts +117 -0
- package/dist/reads/zkemail.js +217 -0
- package/dist/similarity.d.ts +36 -0
- package/dist/similarity.js +67 -0
- package/dist/sponsorship-config.d.ts +47 -0
- package/dist/sponsorship-config.js +41 -0
- package/dist/stats.d.ts +11 -0
- package/dist/stats.js +27 -0
- package/dist/task-lens.d.ts +113 -0
- package/dist/task-lens.js +210 -0
- package/dist/tx/education.d.ts +169 -0
- package/dist/tx/education.js +344 -0
- package/dist/tx/eligibility.d.ts +511 -0
- package/dist/tx/eligibility.js +818 -0
- package/dist/tx/governance.d.ts +85 -0
- package/dist/tx/governance.js +87 -0
- package/dist/tx/index.d.ts +17 -0
- package/dist/tx/index.js +56 -0
- package/dist/tx/intent.d.ts +67 -0
- package/dist/tx/intent.js +48 -0
- package/dist/tx/org.d.ts +321 -0
- package/dist/tx/org.js +544 -0
- package/dist/tx/paymaster.d.ts +140 -0
- package/dist/tx/paymaster.js +251 -0
- package/dist/tx/project.d.ts +146 -0
- package/dist/tx/project.js +217 -0
- package/dist/tx/task.d.ts +480 -0
- package/dist/tx/task.js +1149 -0
- package/dist/tx/token.d.ts +96 -0
- package/dist/tx/token.js +165 -0
- package/dist/tx/treasury.d.ts +474 -0
- package/dist/tx/treasury.js +911 -0
- package/dist/tx/user.d.ts +177 -0
- package/dist/tx/user.js +292 -0
- package/dist/tx/vote.d.ts +332 -0
- package/dist/tx/vote.js +762 -0
- package/dist/tx/zkemail.d.ts +90 -0
- package/dist/tx/zkemail.js +210 -0
- package/dist/validation.d.ts +8 -0
- package/dist/validation.js +39 -0
- package/dist/version.d.ts +142 -0
- package/dist/version.js +257 -0
- package/dist/zkemail.d.ts +161 -0
- package/dist/zkemail.js +299 -0
- package/package.json +130 -0
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Beacon / implementation queries — "which implementation is behind this proxy,
|
|
4
|
+
* and which version is that".
|
|
5
|
+
*
|
|
6
|
+
* Everything here replaces an RPC read that was either expensive or silently
|
|
7
|
+
* unreliable:
|
|
8
|
+
*
|
|
9
|
+
* - eth_getStorageAt(proxy, EIP-1967 beacon slot) + beacon.implementation()
|
|
10
|
+
* → RegisteredContract.beacon → SwitchableBeaconContract.mode → the
|
|
11
|
+
* implementation the beacon resolves to.
|
|
12
|
+
* - PoaManager.getCurrentImplementationById(typeId)
|
|
13
|
+
* → Beacon(typeId).currentImplementation.
|
|
14
|
+
* - OrgRegistry.isAutoUpgrade(keccak256(orgId ‖ typeId))
|
|
15
|
+
* → RegisteredContract.autoUpgrade (and no ContractUnknown revert path).
|
|
16
|
+
* - eth_getLogs(ImplementationRegistered, block 0 → latest)
|
|
17
|
+
* → BeaconUpgradeEvent.{newImplementation,version}.
|
|
18
|
+
*
|
|
19
|
+
* VERIFIED AGAINST LIVE DATA (Gnosis poa-gnosis-v-1 and Arbitrum poa-arb-v-1,
|
|
20
|
+
* 2026-07-30) — every field selected below is non-null on real rows, with two
|
|
21
|
+
* deliberate exceptions that are handled as gaps rather than trusted:
|
|
22
|
+
*
|
|
23
|
+
* - SwitchableBeaconContract.mirrorBeacon is NULL on EVERY live row on BOTH
|
|
24
|
+
* deployments. The Mirror branch therefore joins the global Beacon by
|
|
25
|
+
* typeId (RegisteredContract.typeId), never by mirrorBeacon.
|
|
26
|
+
* - SwitchableBeaconContract.pinnedImplementation is NULL on every live row
|
|
27
|
+
* and there is not a single row with mode = "Pinned" on either chain, so
|
|
28
|
+
* the field has never been observed populated. Pinned beacons therefore
|
|
29
|
+
* fall back to RPC unless the row actually carries a value.
|
|
30
|
+
*
|
|
31
|
+
* The join that IS used was checked end to end on Gnosis org "Test6":
|
|
32
|
+
* RegisteredContract(TaskManager).beacon = 0x4af43d51…d4da7c5
|
|
33
|
+
* == eth_getStorageAt(proxy 0x3d93f0d0…, EIP-1967 beacon slot)
|
|
34
|
+
* SwitchableBeaconContract(0x4af43d51…).mode = "Mirror"
|
|
35
|
+
* Beacon("gnosis-<TaskManager typeId>").currentImplementation
|
|
36
|
+
* = 0x7833c467… == beacon.implementation() over RPC. Match.
|
|
37
|
+
*
|
|
38
|
+
* A separate workstream is adding an implementation-address-keyed entity to
|
|
39
|
+
* the subgraph (Beacon.currentImplementation only answers for the CURRENT
|
|
40
|
+
* mirror implementation, not pinned or historical ones). Both query sets are
|
|
41
|
+
* expressed as tier ARRAYS fed to queryWithFieldFallback so that entity can be
|
|
42
|
+
* slotted in as a new tier 0 without touching any caller.
|
|
43
|
+
*/
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.IMPLEMENTATION_VERSIONS_BEACONS_ONLY = exports.IMPLEMENTATION_VERSIONS_FULL = exports.ORG_MODULE_BEACONS_MINIMAL = exports.ORG_MODULE_BEACONS_NO_SWITCHABLE = exports.ORG_MODULE_BEACONS_FULL = void 0;
|
|
46
|
+
exports.checksumAddress = checksumAddress;
|
|
47
|
+
exports.buildOrgBeaconSnapshot = buildOrgBeaconSnapshot;
|
|
48
|
+
exports.resolveImplementationFromSnapshot = resolveImplementationFromSnapshot;
|
|
49
|
+
exports.latestImplementationFromSnapshot = latestImplementationFromSnapshot;
|
|
50
|
+
exports.autoUpgradeFromSnapshot = autoUpgradeFromSnapshot;
|
|
51
|
+
exports.beaconAddressFromSnapshot = beaconAddressFromSnapshot;
|
|
52
|
+
exports.fetchOrgBeaconSnapshot = fetchOrgBeaconSnapshot;
|
|
53
|
+
exports.fetchImplementationVersionIndex = fetchImplementationVersionIndex;
|
|
54
|
+
const ethers_1 = require("ethers");
|
|
55
|
+
// ────────────────────────── documents (tiered) ──────────────────────────
|
|
56
|
+
/** Tier 0: RegisteredContract + SwitchableBeaconContract + global Beacon. */
|
|
57
|
+
exports.ORG_MODULE_BEACONS_FULL = `
|
|
58
|
+
query OrgModuleBeacons($orgId: Bytes!, $orgIdStr: String!) {
|
|
59
|
+
registeredContracts(first: 100, where: { orgId: $orgId }) {
|
|
60
|
+
id
|
|
61
|
+
typeId
|
|
62
|
+
proxy
|
|
63
|
+
beacon
|
|
64
|
+
autoUpgrade
|
|
65
|
+
}
|
|
66
|
+
switchableBeaconContracts(first: 100, where: { organization: $orgIdStr }) {
|
|
67
|
+
id
|
|
68
|
+
typeId
|
|
69
|
+
mode
|
|
70
|
+
mirrorBeacon
|
|
71
|
+
pinnedImplementation
|
|
72
|
+
}
|
|
73
|
+
beacons(first: 100) {
|
|
74
|
+
typeId
|
|
75
|
+
typeName
|
|
76
|
+
currentImplementation
|
|
77
|
+
version
|
|
78
|
+
# Needed to prove a Mirror beacon still mirrors THIS global beacon.
|
|
79
|
+
# Only tier 0 selects it: tiers 1/2 carry no SwitchableBeaconContract rows,
|
|
80
|
+
# so their mode is unknown and they already degrade to RPC.
|
|
81
|
+
beaconAddress
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
85
|
+
/** Tier 1: deployment without SwitchableBeaconContract (mode unknown → RPC). */
|
|
86
|
+
exports.ORG_MODULE_BEACONS_NO_SWITCHABLE = `
|
|
87
|
+
query OrgModuleBeaconsNoSwitchable($orgId: Bytes!) {
|
|
88
|
+
registeredContracts(first: 100, where: { orgId: $orgId }) {
|
|
89
|
+
id
|
|
90
|
+
typeId
|
|
91
|
+
proxy
|
|
92
|
+
beacon
|
|
93
|
+
autoUpgrade
|
|
94
|
+
}
|
|
95
|
+
beacons(first: 100) {
|
|
96
|
+
typeId
|
|
97
|
+
typeName
|
|
98
|
+
currentImplementation
|
|
99
|
+
version
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
`;
|
|
103
|
+
/** Tier 2: global beacons only (still kills getCurrentImplementationById). */
|
|
104
|
+
exports.ORG_MODULE_BEACONS_MINIMAL = `
|
|
105
|
+
query OrgModuleBeaconsMinimal {
|
|
106
|
+
beacons(first: 100) {
|
|
107
|
+
typeId
|
|
108
|
+
typeName
|
|
109
|
+
currentImplementation
|
|
110
|
+
version
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
114
|
+
/** Tier 0: implementation → version index (global beacons + upgrade history). */
|
|
115
|
+
exports.IMPLEMENTATION_VERSIONS_FULL = `
|
|
116
|
+
query ImplementationVersions($first: Int!, $skip: Int!) {
|
|
117
|
+
beacons(first: 100) {
|
|
118
|
+
typeId
|
|
119
|
+
typeName
|
|
120
|
+
currentImplementation
|
|
121
|
+
version
|
|
122
|
+
}
|
|
123
|
+
beaconUpgradeEvents(first: $first, skip: $skip, orderBy: upgradedAt, orderDirection: asc) {
|
|
124
|
+
typeId
|
|
125
|
+
newImplementation
|
|
126
|
+
version
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
`;
|
|
130
|
+
/** Tier 1: deployment without BeaconUpgradeEvent — current implementations only. */
|
|
131
|
+
exports.IMPLEMENTATION_VERSIONS_BEACONS_ONLY = `
|
|
132
|
+
query ImplementationVersionsBeaconsOnly {
|
|
133
|
+
beacons(first: 100) {
|
|
134
|
+
typeId
|
|
135
|
+
typeName
|
|
136
|
+
currentImplementation
|
|
137
|
+
version
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
`;
|
|
141
|
+
function lower(value) {
|
|
142
|
+
return typeof value === 'string' && value.length > 0 ? value.toLowerCase() : null;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Checksum an address that came from the subgraph (which lowercases them) so
|
|
146
|
+
* subgraph-served values are byte-identical to the RPC-served ones the JSON
|
|
147
|
+
* output has always carried. Returns null for anything unparseable/zero.
|
|
148
|
+
*/
|
|
149
|
+
function checksumAddress(value) {
|
|
150
|
+
if (!value)
|
|
151
|
+
return null;
|
|
152
|
+
try {
|
|
153
|
+
const addr = ethers_1.ethers.utils.getAddress(value);
|
|
154
|
+
return addr === ethers_1.ethers.constants.AddressZero ? null : addr;
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/** Build the per-typeId index from raw query rows (pure — unit testable). */
|
|
161
|
+
function buildOrgBeaconSnapshot(data, tierIndex = 0) {
|
|
162
|
+
const byTypeId = new Map();
|
|
163
|
+
const entry = (typeId) => {
|
|
164
|
+
const key = typeId.toLowerCase();
|
|
165
|
+
let e = byTypeId.get(key);
|
|
166
|
+
if (!e) {
|
|
167
|
+
e = {};
|
|
168
|
+
byTypeId.set(key, e);
|
|
169
|
+
}
|
|
170
|
+
return e;
|
|
171
|
+
};
|
|
172
|
+
for (const beacon of data.beacons ?? []) {
|
|
173
|
+
if (beacon?.typeId)
|
|
174
|
+
entry(beacon.typeId).globalBeacon = beacon;
|
|
175
|
+
}
|
|
176
|
+
for (const rc of data.registeredContracts ?? []) {
|
|
177
|
+
if (rc?.typeId)
|
|
178
|
+
entry(rc.typeId).registered = rc;
|
|
179
|
+
}
|
|
180
|
+
// Switchable beacons are joined through RegisteredContract.beacon (the exact
|
|
181
|
+
// link) rather than through typeId, and NEVER through mirrorBeacon, which is
|
|
182
|
+
// null on every live row.
|
|
183
|
+
const switchableByAddress = new Map();
|
|
184
|
+
for (const sb of data.switchableBeaconContracts ?? []) {
|
|
185
|
+
const key = lower(sb?.id);
|
|
186
|
+
if (key)
|
|
187
|
+
switchableByAddress.set(key, sb);
|
|
188
|
+
}
|
|
189
|
+
for (const e of byTypeId.values()) {
|
|
190
|
+
const beaconAddr = lower(e.registered?.beacon);
|
|
191
|
+
if (!beaconAddr)
|
|
192
|
+
continue;
|
|
193
|
+
const sb = switchableByAddress.get(beaconAddr);
|
|
194
|
+
if (sb)
|
|
195
|
+
e.switchable = sb;
|
|
196
|
+
}
|
|
197
|
+
return { byTypeId, tierIndex };
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Which implementation the org's module proxy currently delegates to, per the
|
|
201
|
+
* subgraph. Returns null whenever the subgraph cannot answer with confidence —
|
|
202
|
+
* the caller must then fall back to RPC. Never guesses.
|
|
203
|
+
*/
|
|
204
|
+
function resolveImplementationFromSnapshot(snapshot, typeId) {
|
|
205
|
+
const entry = snapshot?.byTypeId.get(typeId.toLowerCase());
|
|
206
|
+
if (!entry)
|
|
207
|
+
return null;
|
|
208
|
+
const mode = entry.switchable?.mode ?? null;
|
|
209
|
+
// The deployed mappings write exactly two strings: "Mirror" (handleMirrorSet /
|
|
210
|
+
// autoUpgrade registration) and "Static" (handlePinned). "Pinned" is NOT one of
|
|
211
|
+
// them — it is accepted only as a forward-compatible alias in case the schema is
|
|
212
|
+
// ever renamed, so that a rename cannot silently reclassify a pinned beacon.
|
|
213
|
+
if (mode === 'Static' || mode === 'Pinned') {
|
|
214
|
+
// pinnedImplementation has never been observed populated on any live row
|
|
215
|
+
// (there is not one pinned beacon on Gnosis or Arbitrum). Trust it only
|
|
216
|
+
// when the row genuinely carries an address; otherwise fall back to RPC.
|
|
217
|
+
const pinned = checksumAddress(entry.switchable?.pinnedImplementation);
|
|
218
|
+
if (!pinned)
|
|
219
|
+
return null;
|
|
220
|
+
return { implementation: pinned, version: null, mode };
|
|
221
|
+
}
|
|
222
|
+
if (mode === 'Mirror') {
|
|
223
|
+
// A Mirror beacon points at whatever SwitchableBeacon.setMirror(addr) was last
|
|
224
|
+
// given, and that target only has to be a contract with a non-zero
|
|
225
|
+
// implementation — nothing ties it to the POA global beacon for this typeId.
|
|
226
|
+
// So joining the global beacon by typeId is only sound while the org still
|
|
227
|
+
// mirrors the global beacon. mirrorBeacon is null on all 101 live rows because
|
|
228
|
+
// the SwitchableBeacon CONSTRUCTOR sets it without emitting MirrorSet; the
|
|
229
|
+
// first real setMirror populates it. When it is populated and disagrees with
|
|
230
|
+
// the global beacon's address, fail closed to RPC rather than reporting the
|
|
231
|
+
// global implementation with upToDate: true.
|
|
232
|
+
const mirror = entry.switchable?.mirrorBeacon;
|
|
233
|
+
const globalBeaconAddress = entry.globalBeacon?.beaconAddress;
|
|
234
|
+
if (mirror && globalBeaconAddress && mirror.toLowerCase() !== globalBeaconAddress.toLowerCase()) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
const impl = checksumAddress(entry.globalBeacon?.currentImplementation);
|
|
238
|
+
if (!impl)
|
|
239
|
+
return null;
|
|
240
|
+
return { implementation: impl, version: entry.globalBeacon?.version ?? null, mode };
|
|
241
|
+
}
|
|
242
|
+
// Unknown/absent mode: a beacon we cannot classify may be pinned, and
|
|
243
|
+
// assuming Mirror would report the wrong implementation. Fall back to RPC.
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
/** Latest protocol implementation for a module type (PoaManager equivalent). */
|
|
247
|
+
function latestImplementationFromSnapshot(snapshot, typeId) {
|
|
248
|
+
const beacon = snapshot?.byTypeId.get(typeId.toLowerCase())?.globalBeacon;
|
|
249
|
+
return checksumAddress(beacon?.currentImplementation);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Registration-time autoUpgrade HINT — NOT an OrgRegistry.isAutoUpgrade equivalent.
|
|
253
|
+
*
|
|
254
|
+
* The deployed subgraph writes RegisteredContract.autoUpgrade once, inside
|
|
255
|
+
* handleContractRegistered, and never again: schema.graphql annotates it
|
|
256
|
+
* "immutable, set at registration" and there is no AutoUpgradeSet handler at all.
|
|
257
|
+
* OrgRegistry.setAutoUpgrade(orgId, typeId, bool) is a live mutator, so after an
|
|
258
|
+
* executor turns auto-upgrade OFF this value keeps reporting the registration-time
|
|
259
|
+
* `true` forever — and 91/91 live Gnosis rows are `true`, so the divergent case has
|
|
260
|
+
* never once been exercised.
|
|
261
|
+
*
|
|
262
|
+
* Callers that render a pinning claim MUST prefer the on-chain isAutoUpgrade read
|
|
263
|
+
* and use this only when OrgRegistry is unreachable (see org/status.ts).
|
|
264
|
+
*/
|
|
265
|
+
function autoUpgradeFromSnapshot(snapshot, typeId) {
|
|
266
|
+
const rc = snapshot?.byTypeId.get(typeId.toLowerCase())?.registered;
|
|
267
|
+
return typeof rc?.autoUpgrade === 'boolean' ? rc.autoUpgrade : null;
|
|
268
|
+
}
|
|
269
|
+
/** The proxy's beacon address, when indexed — lets callers skip getStorageAt. */
|
|
270
|
+
function beaconAddressFromSnapshot(snapshot, typeId) {
|
|
271
|
+
return checksumAddress(snapshot?.byTypeId.get(typeId.toLowerCase())?.registered?.beacon);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Fetch the org's module→beacon snapshot. Throws only on transport failure;
|
|
275
|
+
* callers treat a throw as "no snapshot" and use their RPC path.
|
|
276
|
+
*/
|
|
277
|
+
async function fetchOrgBeaconSnapshot(client, orgId, chainId) {
|
|
278
|
+
const tiers = [
|
|
279
|
+
{ query: exports.ORG_MODULE_BEACONS_FULL, variables: { orgId, orgIdStr: orgId } },
|
|
280
|
+
{ query: exports.ORG_MODULE_BEACONS_NO_SWITCHABLE, variables: { orgId } },
|
|
281
|
+
{ query: exports.ORG_MODULE_BEACONS_MINIMAL, variables: {} },
|
|
282
|
+
];
|
|
283
|
+
const { data, tierIndex } = await client.queryWithFieldFallback(tiers, { chainId });
|
|
284
|
+
return buildOrgBeaconSnapshot(data ?? {}, tierIndex);
|
|
285
|
+
}
|
|
286
|
+
const PAGE_SIZE = 1000;
|
|
287
|
+
const MAX_PAGES = 5;
|
|
288
|
+
/**
|
|
289
|
+
* Every implementation address the subgraph can name a version for, keyed by
|
|
290
|
+
* lowercased address.
|
|
291
|
+
*
|
|
292
|
+
* Sources: Beacon.currentImplementation (the live one per type) and
|
|
293
|
+
* BeaconUpgradeEvent.newImplementation (every implementation a global beacon
|
|
294
|
+
* has ever pointed at). Verified live: 71 upgrade events on Gnosis with zero
|
|
295
|
+
* null newImplementation/version values, and identical implementation
|
|
296
|
+
* addresses on Arbitrum (deterministic deploys), so the index is chain-safe.
|
|
297
|
+
*
|
|
298
|
+
* NOT covered: an implementation that was registered but never promoted onto a
|
|
299
|
+
* global beacon (only reachable by pinning to it). Callers keep the registry
|
|
300
|
+
* eth_getLogs scan as the explicit fallback for exactly that case.
|
|
301
|
+
*/
|
|
302
|
+
async function fetchImplementationVersionIndex(client, chainId) {
|
|
303
|
+
const index = new Map();
|
|
304
|
+
const typeNameById = new Map();
|
|
305
|
+
let tierIndex = 0;
|
|
306
|
+
for (let page = 0; page < MAX_PAGES; page++) {
|
|
307
|
+
const tiers = [
|
|
308
|
+
{ query: exports.IMPLEMENTATION_VERSIONS_FULL, variables: { first: PAGE_SIZE, skip: page * PAGE_SIZE } },
|
|
309
|
+
{ query: exports.IMPLEMENTATION_VERSIONS_BEACONS_ONLY, variables: {} },
|
|
310
|
+
];
|
|
311
|
+
const { data, tierIndex: tier } = await client.queryWithFieldFallback(tiers, { chainId });
|
|
312
|
+
tierIndex = tier;
|
|
313
|
+
for (const beacon of (data?.beacons ?? [])) {
|
|
314
|
+
if (!beacon?.currentImplementation)
|
|
315
|
+
continue;
|
|
316
|
+
if (beacon.typeId)
|
|
317
|
+
typeNameById.set(beacon.typeId.toLowerCase(), beacon.typeName);
|
|
318
|
+
index.set(beacon.currentImplementation.toLowerCase(), {
|
|
319
|
+
typeName: beacon.typeName,
|
|
320
|
+
version: beacon.version ?? '',
|
|
321
|
+
implementation: ethers_1.ethers.utils.getAddress(beacon.currentImplementation),
|
|
322
|
+
latest: true,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
const events = data?.beaconUpgradeEvents ?? [];
|
|
326
|
+
for (const ev of events) {
|
|
327
|
+
if (!ev?.newImplementation || !ev?.version)
|
|
328
|
+
continue;
|
|
329
|
+
const key = ev.newImplementation.toLowerCase();
|
|
330
|
+
// A current implementation already recorded as `latest` must not be
|
|
331
|
+
// demoted by its own historical upgrade event.
|
|
332
|
+
if (index.has(key))
|
|
333
|
+
continue;
|
|
334
|
+
index.set(key, {
|
|
335
|
+
typeName: typeNameById.get(ev.typeId?.toLowerCase() ?? '') ?? '',
|
|
336
|
+
version: ev.version,
|
|
337
|
+
implementation: ethers_1.ethers.utils.getAddress(ev.newImplementation),
|
|
338
|
+
latest: false,
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
if (tier !== 0 || events.length < PAGE_SIZE)
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
return { index, tierIndex };
|
|
345
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GraphQL documents by domain, re-exported as namespaces.
|
|
3
|
+
* Moved verbatim from the CLI's src/queries/ — raw documents stay exported so
|
|
4
|
+
* consumers (e.g. Apollo users) can keep their cache layer and still use the
|
|
5
|
+
* canonical queries.
|
|
6
|
+
*/
|
|
7
|
+
export * as activityDocuments from './activity';
|
|
8
|
+
export * as beaconsDocuments from './beacons';
|
|
9
|
+
export * as infrastructureDocuments from './infrastructure';
|
|
10
|
+
export * as orgDocuments from './org';
|
|
11
|
+
export * as paymasterDocuments from './paymaster';
|
|
12
|
+
export * as roleDocuments from './role';
|
|
13
|
+
export * as rolesDocuments from './roles';
|
|
14
|
+
export * as taskDocuments from './task';
|
|
15
|
+
export * as tokenDocuments from './token';
|
|
16
|
+
export * as treasuryDocuments from './treasury';
|
|
17
|
+
export * as userDocuments from './user';
|
|
18
|
+
export * as votingClassesDocuments from './voting-classes';
|
|
19
|
+
export * as votingDocuments from './voting';
|
|
20
|
+
export * as vouchDocuments from './vouch';
|
|
21
|
+
export * as zkemailDocuments from './zkemail';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* GraphQL documents by domain, re-exported as namespaces.
|
|
4
|
+
* Moved verbatim from the CLI's src/queries/ — raw documents stay exported so
|
|
5
|
+
* consumers (e.g. Apollo users) can keep their cache layer and still use the
|
|
6
|
+
* canonical queries.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.zkemailDocuments = exports.vouchDocuments = exports.votingDocuments = exports.votingClassesDocuments = exports.userDocuments = exports.treasuryDocuments = exports.tokenDocuments = exports.taskDocuments = exports.rolesDocuments = exports.roleDocuments = exports.paymasterDocuments = exports.orgDocuments = exports.infrastructureDocuments = exports.beaconsDocuments = exports.activityDocuments = void 0;
|
|
43
|
+
exports.activityDocuments = __importStar(require("./activity"));
|
|
44
|
+
exports.beaconsDocuments = __importStar(require("./beacons"));
|
|
45
|
+
exports.infrastructureDocuments = __importStar(require("./infrastructure"));
|
|
46
|
+
exports.orgDocuments = __importStar(require("./org"));
|
|
47
|
+
exports.paymasterDocuments = __importStar(require("./paymaster"));
|
|
48
|
+
exports.roleDocuments = __importStar(require("./role"));
|
|
49
|
+
exports.rolesDocuments = __importStar(require("./roles"));
|
|
50
|
+
exports.taskDocuments = __importStar(require("./task"));
|
|
51
|
+
exports.tokenDocuments = __importStar(require("./token"));
|
|
52
|
+
exports.treasuryDocuments = __importStar(require("./treasury"));
|
|
53
|
+
exports.userDocuments = __importStar(require("./user"));
|
|
54
|
+
exports.votingClassesDocuments = __importStar(require("./voting-classes"));
|
|
55
|
+
exports.votingDocuments = __importStar(require("./voting"));
|
|
56
|
+
exports.vouchDocuments = __importStar(require("./vouch"));
|
|
57
|
+
exports.zkemailDocuments = __importStar(require("./zkemail"));
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Infrastructure Queries
|
|
3
|
+
* Fetch global contract addresses from subgraph.
|
|
4
|
+
*/
|
|
5
|
+
export declare const FETCH_INFRASTRUCTURE_ADDRESSES = "\n query FetchInfrastructureAddresses {\n universalAccountRegistries(first: 1) {\n id\n totalAccounts\n }\n poaManagerContracts(first: 1) {\n id\n registry\n orgDeployerProxy\n orgRegistryProxy\n paymasterHubProxy\n globalAccountRegistryProxy\n }\n orgRegistryContracts(first: 1) {\n id\n totalOrgs\n }\n beacons {\n id\n typeName\n beaconAddress\n currentImplementation\n version\n }\n }\n";
|
|
6
|
+
export interface InfrastructureAddresses {
|
|
7
|
+
universalAccountRegistries: Array<{
|
|
8
|
+
id: string;
|
|
9
|
+
totalAccounts: string;
|
|
10
|
+
}>;
|
|
11
|
+
poaManagerContracts: Array<{
|
|
12
|
+
id: string;
|
|
13
|
+
registry: string;
|
|
14
|
+
orgDeployerProxy: string;
|
|
15
|
+
orgRegistryProxy: string;
|
|
16
|
+
paymasterHubProxy: string;
|
|
17
|
+
globalAccountRegistryProxy: string;
|
|
18
|
+
}>;
|
|
19
|
+
orgRegistryContracts: Array<{
|
|
20
|
+
id: string;
|
|
21
|
+
totalOrgs: string;
|
|
22
|
+
}>;
|
|
23
|
+
beacons: Array<{
|
|
24
|
+
id: string;
|
|
25
|
+
typeName: string;
|
|
26
|
+
beaconAddress: string;
|
|
27
|
+
currentImplementation: string;
|
|
28
|
+
version: string;
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Infrastructure Queries
|
|
4
|
+
* Fetch global contract addresses from subgraph.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.FETCH_INFRASTRUCTURE_ADDRESSES = void 0;
|
|
8
|
+
exports.FETCH_INFRASTRUCTURE_ADDRESSES = `
|
|
9
|
+
query FetchInfrastructureAddresses {
|
|
10
|
+
universalAccountRegistries(first: 1) {
|
|
11
|
+
id
|
|
12
|
+
totalAccounts
|
|
13
|
+
}
|
|
14
|
+
poaManagerContracts(first: 1) {
|
|
15
|
+
id
|
|
16
|
+
registry
|
|
17
|
+
orgDeployerProxy
|
|
18
|
+
orgRegistryProxy
|
|
19
|
+
paymasterHubProxy
|
|
20
|
+
globalAccountRegistryProxy
|
|
21
|
+
}
|
|
22
|
+
orgRegistryContracts(first: 1) {
|
|
23
|
+
id
|
|
24
|
+
totalOrgs
|
|
25
|
+
}
|
|
26
|
+
beacons {
|
|
27
|
+
id
|
|
28
|
+
typeName
|
|
29
|
+
beaconAddress
|
|
30
|
+
currentImplementation
|
|
31
|
+
version
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Organization Queries
|
|
3
|
+
* Ported from frontend queries.js
|
|
4
|
+
*/
|
|
5
|
+
export declare const FETCH_ORG_BY_ID = "\n query FetchOrgById($id: Bytes!) {\n organization(id: $id) {\n id\n name\n metadataHash\n deployedAt\n topHatId\n roleHatIds\n participationToken {\n id\n name\n symbol\n totalSupply\n }\n quickJoin {\n id\n }\n hybridVoting {\n id\n thresholdPct\n quorum\n }\n directDemocracyVoting {\n id\n thresholdPct\n quorum\n }\n taskManager {\n id\n projects {\n id\n title\n deleted\n }\n }\n educationHub {\n id\n nextModuleId\n }\n executorContract {\n id\n }\n eligibilityModule {\n id\n }\n paymentManager {\n id\n }\n zkEmailInvites {\n id\n }\n users {\n id\n address\n account {\n username\n metadata {\n avatar\n }\n }\n participationTokenBalance\n membershipStatus\n currentHatIds\n }\n roles(where: { isUserRole: true }) {\n id\n hatId\n name\n image\n canVote\n isUserRole\n }\n }\n }\n";
|
|
6
|
+
export declare const FETCH_ORG_FULL_DATA = "\n query FetchOrgFullData($orgId: Bytes!) {\n organization(id: $orgId) {\n id\n name\n metadataHash\n metadataAdminHatId\n metadata {\n id\n description\n template\n backgroundColor\n logo\n hideTreasury\n useTokenSymbol\n taskPayoutHoursOnly\n taskPayoutHourlyRate\n links {\n name\n url\n index\n }\n }\n deployedAt\n topHatId\n roleHatIds\n participationToken {\n id\n name\n symbol\n totalSupply\n }\n quickJoin {\n id\n }\n hybridVoting {\n id\n thresholdPct\n quorum\n }\n directDemocracyVoting {\n id\n thresholdPct\n quorum\n }\n zkEmailInvites {\n id\n }\n taskManager {\n id\n creatorHatIds\n projects(where: { deleted: false }, first: 100) {\n id\n tasks(first: 1000) {\n id\n status\n }\n }\n }\n educationHub {\n id\n modules {\n id\n moduleId\n title\n contentHash\n metadata {\n description\n link\n quiz\n answersJson\n }\n payout\n status\n completions {\n learner\n }\n }\n }\n executorContract {\n id\n }\n eligibilityModule {\n id\n }\n paymentManager {\n id\n }\n users(orderBy: participationTokenBalance, orderDirection: desc, first: 100) {\n id\n address\n account {\n username\n metadata {\n avatar\n }\n }\n participationTokenBalance\n membershipStatus\n currentHatIds\n totalTasksCompleted\n totalVotes\n firstSeenAt\n }\n roles(where: { isUserRole: true }) {\n id\n hatId\n name\n image\n canVote\n isUserRole\n hat {\n name\n }\n }\n }\n }\n";
|
|
7
|
+
export declare const GET_ORG_BY_NAME = "\n query GetOrgByName($name: String!) {\n organizations(where: { name: $name }, first: 1) {\n id\n name\n }\n }\n";
|
|
8
|
+
export declare const FETCH_USER_ORGANIZATIONS = "\n query FetchUserOrganizations($userAddress: Bytes!) {\n users(where: { address: $userAddress, membershipStatus: Active }) {\n id\n membershipStatus\n participationTokenBalance\n totalTasksCompleted\n totalVotes\n organization {\n id\n name\n metadataHash\n participationToken {\n symbol\n }\n }\n }\n }\n";
|
|
9
|
+
/**
|
|
10
|
+
* Just the org's payout convention + token symbol.
|
|
11
|
+
*
|
|
12
|
+
* Deliberately narrow: `pop task create` needs it on every invocation to price a task the way
|
|
13
|
+
* the web app would, and FETCH_ORG_FULL_DATA pulls every user, role, task and proposal.
|
|
14
|
+
*/
|
|
15
|
+
export declare const FETCH_ORG_PAYOUT_CONFIG = "\n query FetchOrgPayoutConfig($orgId: Bytes!) {\n organization(id: $orgId) {\n id\n metadata {\n useTokenSymbol\n taskPayoutHoursOnly\n taskPayoutHourlyRate\n }\n participationToken {\n symbol\n }\n }\n }\n";
|