@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,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* TaskManager Lens Reader
|
|
4
|
+
* Authoritative on-chain task state via TaskManager.getLensData(uint8,bytes),
|
|
5
|
+
* bypassing subgraph lag. Key numbering and tuple shapes verified against
|
|
6
|
+
* contracts repo origin/main src/TaskManager.sol (getLensData dispatcher) and
|
|
7
|
+
* src/lens/TaskManagerLens.sol (whose getStorage routes through the same
|
|
8
|
+
* variants).
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.TASK_STATUS_NAMES = exports.TASK_STATUS = exports.STORAGE_KEYS = void 0;
|
|
12
|
+
exports.taskStatusName = taskStatusName;
|
|
13
|
+
exports.encodeLensCall = encodeLensCall;
|
|
14
|
+
exports.decodeLensResult = decodeLensResult;
|
|
15
|
+
exports.decodeTaskInfo = decodeTaskInfo;
|
|
16
|
+
exports.getTaskOnChain = getTaskOnChain;
|
|
17
|
+
exports.enrichTasksWithDeadlines = enrichTasksWithDeadlines;
|
|
18
|
+
exports.deriveClaimState = deriveClaimState;
|
|
19
|
+
exports.getFoldersRoot = getFoldersRoot;
|
|
20
|
+
exports.getOrganizerHats = getOrganizerHats;
|
|
21
|
+
exports.getPermissionHats = getPermissionHats;
|
|
22
|
+
exports.getTaskApplicants = getTaskApplicants;
|
|
23
|
+
const ethers_1 = require("ethers");
|
|
24
|
+
const contracts_1 = require("./contracts");
|
|
25
|
+
const encoding_1 = require("./encoding");
|
|
26
|
+
/**
|
|
27
|
+
* TaskManager.getLensData variant selectors, verified against contracts repo
|
|
28
|
+
* origin/main src/TaskManager.sol. NOTE: these are NOT the TaskManagerLens.sol
|
|
29
|
+
* StorageKey enum indexes — that enum keys the lens contract's own
|
|
30
|
+
* getStorage(); the CLI calls the TaskManager dispatcher directly with the
|
|
31
|
+
* variant numbers below (TaskManagerLens.sol itself forwards to these).
|
|
32
|
+
*/
|
|
33
|
+
exports.STORAGE_KEYS = {
|
|
34
|
+
/** abi.encode(uint256 id) → task tuple (see decodeTaskInfo) */
|
|
35
|
+
TASK_INFO: 1,
|
|
36
|
+
/** abi.encode(bytes32 pid) → (uint128 cap, uint128 spent, bool exists) */
|
|
37
|
+
PROJECT_INFO: 2,
|
|
38
|
+
/** '' → (address hats) */
|
|
39
|
+
HATS: 3,
|
|
40
|
+
/** '' → (address executor) */
|
|
41
|
+
EXECUTOR: 4,
|
|
42
|
+
/** '' → (uint256[] hatIds) */
|
|
43
|
+
CREATOR_HATS: 5,
|
|
44
|
+
/** '' → (uint256[] hatIds) */
|
|
45
|
+
PERMISSION_HATS: 6,
|
|
46
|
+
/** abi.encode(uint256 id) → (address[] applicants) */
|
|
47
|
+
TASK_APPLICANTS: 7,
|
|
48
|
+
/** abi.encode(uint256 id, address applicant) → (bytes32 hash) */
|
|
49
|
+
TASK_APPLICATION: 8,
|
|
50
|
+
/** abi.encode(bytes32 pid, address token) → (uint128 cap, uint128 spent) */
|
|
51
|
+
BOUNTY_BUDGET: 9,
|
|
52
|
+
/** '' → (bytes32 foldersRoot) */
|
|
53
|
+
FOLDERS_ROOT: 10,
|
|
54
|
+
/** '' → (uint256[] hatIds) */
|
|
55
|
+
ORGANIZER_HATS: 11,
|
|
56
|
+
};
|
|
57
|
+
/** Task Status enum (TaskManager.sol). */
|
|
58
|
+
exports.TASK_STATUS = {
|
|
59
|
+
UNCLAIMED: 0,
|
|
60
|
+
CLAIMED: 1,
|
|
61
|
+
SUBMITTED: 2,
|
|
62
|
+
COMPLETED: 3,
|
|
63
|
+
CANCELLED: 4,
|
|
64
|
+
};
|
|
65
|
+
exports.TASK_STATUS_NAMES = ['UNCLAIMED', 'CLAIMED', 'SUBMITTED', 'COMPLETED', 'CANCELLED'];
|
|
66
|
+
function taskStatusName(status) {
|
|
67
|
+
return exports.TASK_STATUS_NAMES[status] ?? `UNKNOWN(${status})`;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* v6 task tuple returned by getLensData variant 1 (10 static fields).
|
|
71
|
+
* Pre-v6 implementations return only the first 7 (no deadline words).
|
|
72
|
+
*/
|
|
73
|
+
const TASK_TUPLE_V6 = ['bytes32', 'uint96', 'address', 'uint96', 'bool', 'uint8', 'address', 'uint48', 'uint32', 'uint48'];
|
|
74
|
+
const TASK_TUPLE_LEGACY = ['bytes32', 'uint96', 'address', 'uint96', 'bool', 'uint8', 'address'];
|
|
75
|
+
let lensInterface = null;
|
|
76
|
+
/** Minimal Interface holding just getLensData from the synced TaskManagerNew ABI. */
|
|
77
|
+
function getLensInterface() {
|
|
78
|
+
if (!lensInterface) {
|
|
79
|
+
const fragment = (0, contracts_1.loadAbi)('TaskManagerNew').find((f) => f.type === 'function' && f.name === 'getLensData');
|
|
80
|
+
if (!fragment) {
|
|
81
|
+
throw new Error('getLensData not found in TaskManagerNew ABI. Run yarn sync-abis.');
|
|
82
|
+
}
|
|
83
|
+
lensInterface = new ethers_1.ethers.utils.Interface([fragment]);
|
|
84
|
+
}
|
|
85
|
+
return lensInterface;
|
|
86
|
+
}
|
|
87
|
+
/** Encode a raw eth_call payload for TaskManager.getLensData. */
|
|
88
|
+
function encodeLensCall(key, params = '0x') {
|
|
89
|
+
return getLensInterface().encodeFunctionData('getLensData', [key, params]);
|
|
90
|
+
}
|
|
91
|
+
/** Unwrap the `bytes` payload from a raw getLensData return. */
|
|
92
|
+
function decodeLensResult(returnData) {
|
|
93
|
+
return getLensInterface().decodeFunctionResult('getLensData', returnData)[0];
|
|
94
|
+
}
|
|
95
|
+
async function callLens(provider, taskManagerAddr, key, params = '0x') {
|
|
96
|
+
const raw = await provider.call({ to: taskManagerAddr, data: encodeLensCall(key, params) });
|
|
97
|
+
return decodeLensResult(raw);
|
|
98
|
+
}
|
|
99
|
+
function asNumber(value) {
|
|
100
|
+
return typeof value === 'number' ? value : ethers_1.ethers.BigNumber.from(value).toNumber();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Decode the task payload from getLensData variant 1. Tries the v6 10-field
|
|
104
|
+
* tuple first; pre-v6 payloads are only 7 words, so the v6 decode throws
|
|
105
|
+
* (out-of-bounds) — fall back to the legacy tuple and leave the deadline
|
|
106
|
+
* fields undefined.
|
|
107
|
+
*/
|
|
108
|
+
function decodeTaskInfo(data) {
|
|
109
|
+
try {
|
|
110
|
+
const d = ethers_1.ethers.utils.defaultAbiCoder.decode(TASK_TUPLE_V6, data);
|
|
111
|
+
return {
|
|
112
|
+
projectId: d[0],
|
|
113
|
+
payout: d[1],
|
|
114
|
+
claimer: d[2],
|
|
115
|
+
bountyPayout: d[3],
|
|
116
|
+
requiresApplication: d[4],
|
|
117
|
+
status: asNumber(d[5]),
|
|
118
|
+
bountyToken: d[6],
|
|
119
|
+
absoluteDeadline: asNumber(d[7]),
|
|
120
|
+
completionWindow: asNumber(d[8]),
|
|
121
|
+
claimDeadline: asNumber(d[9]),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
const d = ethers_1.ethers.utils.defaultAbiCoder.decode(TASK_TUPLE_LEGACY, data);
|
|
126
|
+
return {
|
|
127
|
+
projectId: d[0],
|
|
128
|
+
payout: d[1],
|
|
129
|
+
claimer: d[2],
|
|
130
|
+
bountyPayout: d[3],
|
|
131
|
+
requiresApplication: d[4],
|
|
132
|
+
status: asNumber(d[5]),
|
|
133
|
+
bountyToken: d[6],
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Read a single task's on-chain state. Accepts plain numeric IDs or
|
|
139
|
+
* subgraph-format IDs ("contractAddress-taskId").
|
|
140
|
+
*/
|
|
141
|
+
async function getTaskOnChain(provider, taskManagerAddr, taskId) {
|
|
142
|
+
const params = ethers_1.ethers.utils.defaultAbiCoder.encode(['uint256'], [(0, encoding_1.parseTaskId)(taskId)]);
|
|
143
|
+
const payload = await callLens(provider, taskManagerAddr, exports.STORAGE_KEYS.TASK_INFO, params);
|
|
144
|
+
return decodeTaskInfo(payload);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Fetch on-chain state for many tasks with bounded concurrency (default 5,
|
|
148
|
+
* capped at 50 tasks). Per-task failures are collected, never thrown, so
|
|
149
|
+
* callers can render partial data.
|
|
150
|
+
*/
|
|
151
|
+
async function enrichTasksWithDeadlines(provider, taskManagerAddr, ids, opts) {
|
|
152
|
+
const concurrency = Math.max(1, opts?.concurrency ?? 5);
|
|
153
|
+
const cap = opts?.cap ?? 50;
|
|
154
|
+
const capped = ids.slice(0, cap);
|
|
155
|
+
const tasks = new Map();
|
|
156
|
+
const errors = [];
|
|
157
|
+
for (let i = 0; i < capped.length; i += concurrency) {
|
|
158
|
+
const chunk = capped.slice(i, i + concurrency);
|
|
159
|
+
await Promise.all(chunk.map(async (id) => {
|
|
160
|
+
const key = String(id);
|
|
161
|
+
try {
|
|
162
|
+
tasks.set(key, await getTaskOnChain(provider, taskManagerAddr, id));
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
errors.push({ id: key, message: err?.message || String(err) });
|
|
166
|
+
}
|
|
167
|
+
}));
|
|
168
|
+
}
|
|
169
|
+
return { tasks, errors };
|
|
170
|
+
}
|
|
171
|
+
const EXPIRING_SOON_WINDOW_SECONDS = 24 * 60 * 60;
|
|
172
|
+
/**
|
|
173
|
+
* Classify a CLAIMED task's deadline state. `claimDeadline` takes precedence
|
|
174
|
+
* over `absoluteDeadline`; zero/undefined deadlines mean "no deadline".
|
|
175
|
+
* A deadline strictly in the past means the claim is forfeitable.
|
|
176
|
+
*/
|
|
177
|
+
function deriveClaimState(task, now) {
|
|
178
|
+
if (task.status !== exports.TASK_STATUS.CLAIMED)
|
|
179
|
+
return 'none';
|
|
180
|
+
const deadline = task.claimDeadline || task.absoluteDeadline;
|
|
181
|
+
if (!deadline)
|
|
182
|
+
return 'none';
|
|
183
|
+
const ts = now ?? Math.floor(Date.now() / 1000);
|
|
184
|
+
if (deadline < ts)
|
|
185
|
+
return 'expired-claimable';
|
|
186
|
+
if (deadline <= ts + EXPIRING_SOON_WINDOW_SECONDS)
|
|
187
|
+
return 'expiring-soon';
|
|
188
|
+
return 'on-track';
|
|
189
|
+
}
|
|
190
|
+
/** Read the org's task folders merkle root (getLensData variant 10). */
|
|
191
|
+
async function getFoldersRoot(provider, taskManagerAddr) {
|
|
192
|
+
const payload = await callLens(provider, taskManagerAddr, exports.STORAGE_KEYS.FOLDERS_ROOT);
|
|
193
|
+
return ethers_1.ethers.utils.defaultAbiCoder.decode(['bytes32'], payload)[0];
|
|
194
|
+
}
|
|
195
|
+
/** Read organizer hat IDs (getLensData variant 11). */
|
|
196
|
+
async function getOrganizerHats(provider, taskManagerAddr) {
|
|
197
|
+
const payload = await callLens(provider, taskManagerAddr, exports.STORAGE_KEYS.ORGANIZER_HATS);
|
|
198
|
+
return ethers_1.ethers.utils.defaultAbiCoder.decode(['uint256[]'], payload)[0];
|
|
199
|
+
}
|
|
200
|
+
/** Read permission hat IDs (getLensData variant 6). */
|
|
201
|
+
async function getPermissionHats(provider, taskManagerAddr) {
|
|
202
|
+
const payload = await callLens(provider, taskManagerAddr, exports.STORAGE_KEYS.PERMISSION_HATS);
|
|
203
|
+
return ethers_1.ethers.utils.defaultAbiCoder.decode(['uint256[]'], payload)[0];
|
|
204
|
+
}
|
|
205
|
+
/** Read a task's applicant addresses (getLensData variant 7). */
|
|
206
|
+
async function getTaskApplicants(provider, taskManagerAddr, taskId) {
|
|
207
|
+
const params = ethers_1.ethers.utils.defaultAbiCoder.encode(['uint256'], [(0, encoding_1.parseTaskId)(taskId)]);
|
|
208
|
+
const payload = await callLens(provider, taskManagerAddr, exports.STORAGE_KEYS.TASK_APPLICANTS, params);
|
|
209
|
+
return ethers_1.ethers.utils.defaultAbiCoder.decode(['address[]'], payload)[0];
|
|
210
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Education write builders.
|
|
3
|
+
*
|
|
4
|
+
* Ports:
|
|
5
|
+
* - `pop education create` — src/commands/education/create-module.ts
|
|
6
|
+
* - `pop education complete` — src/commands/education/complete.ts
|
|
7
|
+
* - `pop education update` — src/commands/education/update.ts
|
|
8
|
+
* - `pop education remove` — src/commands/education/remove.ts
|
|
9
|
+
*
|
|
10
|
+
* EducationHub facts (verified contracts origin/main src/EducationHub.sol):
|
|
11
|
+
* - createModule hashes the correct answer into the module PERMANENTLY —
|
|
12
|
+
* updateModule never touches answerHash, so changing quiz content cannot
|
|
13
|
+
* change which answer index passes (remove + recreate to change it).
|
|
14
|
+
* - updateModule is a FULL OVERWRITE of title + contentHash + payout.
|
|
15
|
+
* - removeModule is a permanent delete with no undo.
|
|
16
|
+
* - The chain stores only {answerHash, payout, exists}; module metadata is
|
|
17
|
+
* event-only, so preservation reads go through the subgraph/IPFS.
|
|
18
|
+
*/
|
|
19
|
+
import { ethers } from 'ethers';
|
|
20
|
+
import type { TxIntent } from './intent';
|
|
21
|
+
import type { PopContext } from '../context';
|
|
22
|
+
export interface CreateModuleArgs {
|
|
23
|
+
educationHubAddress: string;
|
|
24
|
+
/** Module title (encoded with stringToBytes). */
|
|
25
|
+
name: string;
|
|
26
|
+
/** bytes32 of the pinned module metadata CID. */
|
|
27
|
+
contentHash: string;
|
|
28
|
+
/** PT reward in whole tokens — encoded parseUnits(String(payout), 18) like the CLI. */
|
|
29
|
+
payout: number | string;
|
|
30
|
+
/** Index of the correct answer (0-255) — PERMANENT after creation. */
|
|
31
|
+
correctAnswer: number;
|
|
32
|
+
orgId?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Port of `pop education create` — src/commands/education/create-module.ts.
|
|
36
|
+
* EducationHubNew.createModule(stringToBytes(name), contentHash,
|
|
37
|
+
* payoutWei(18d), correctAnswer uint8). Validates payout > 0 (the contract
|
|
38
|
+
* reverts InvalidPayout for 0) and correctAnswer 0-255, same messages as the
|
|
39
|
+
* CLI.
|
|
40
|
+
*/
|
|
41
|
+
export declare function buildCreateModule(a: CreateModuleArgs): TxIntent;
|
|
42
|
+
export interface CompleteModuleArgs {
|
|
43
|
+
educationHubAddress: string;
|
|
44
|
+
/** Module ID — accepts the subgraph "address-id" form (parseModuleId). */
|
|
45
|
+
moduleId: string | number;
|
|
46
|
+
/** Answer index (0-based). Wrong answers are only knowable on-chain (InvalidAnswer). */
|
|
47
|
+
answer: number;
|
|
48
|
+
orgId?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Port of `pop education complete` — src/commands/education/complete.ts.
|
|
52
|
+
* EducationHubNew.completeModule(moduleId, answer uint8) — pays PT once per
|
|
53
|
+
* account (reverts AlreadyCompleted on a second attempt, ModuleUnknown for
|
|
54
|
+
* missing modules). Validates answer 0-255, same message as the CLI.
|
|
55
|
+
*/
|
|
56
|
+
export declare function buildCompleteModule(a: CompleteModuleArgs): TxIntent;
|
|
57
|
+
export interface UpdateModuleArgs {
|
|
58
|
+
educationHubAddress: string;
|
|
59
|
+
/** Module ID — accepts the subgraph "address-id" form (parseModuleId). */
|
|
60
|
+
moduleId: string | number;
|
|
61
|
+
/** FULL replacement title (updateModule overwrites it even when unchanged). */
|
|
62
|
+
name: string;
|
|
63
|
+
/** FULL replacement contentHash (pass the current one to keep metadata). */
|
|
64
|
+
contentHash: string;
|
|
65
|
+
/**
|
|
66
|
+
* FULL replacement payout in PT WEI (BigNumber), not whole tokens — the
|
|
67
|
+
* resolved builder writes back the on-chain value when unchanged, so this
|
|
68
|
+
* stays in wei end-to-end (unlike createModule, where the CLI parses a
|
|
69
|
+
* whole-token number).
|
|
70
|
+
*/
|
|
71
|
+
payoutWei: ethers.BigNumberish;
|
|
72
|
+
orgId?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Port of `pop education update` — src/commands/education/update.ts.
|
|
76
|
+
* EducationHubNew.updateModule(id, stringToBytes(name), contentHash,
|
|
77
|
+
* payoutWei) — full overwrite of title + contentHash + payout; the answer
|
|
78
|
+
* hash is IMMUTABLE.
|
|
79
|
+
*/
|
|
80
|
+
export declare function buildUpdateModule(a: UpdateModuleArgs): TxIntent;
|
|
81
|
+
export interface RemoveModuleArgs {
|
|
82
|
+
educationHubAddress: string;
|
|
83
|
+
/** Module ID — accepts the subgraph "address-id" form (parseModuleId). */
|
|
84
|
+
moduleId: string | number;
|
|
85
|
+
orgId?: string;
|
|
86
|
+
/** Display-only module title for confirmation UIs. */
|
|
87
|
+
title?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Port of `pop education remove` — src/commands/education/remove.ts.
|
|
91
|
+
* EducationHubNew.removeModule(moduleId) — PERMANENT delete, no undo; past
|
|
92
|
+
* completions keep their minted PT but the module disappears for everyone.
|
|
93
|
+
*/
|
|
94
|
+
export declare function buildRemoveModule(a: RemoveModuleArgs): TxIntent;
|
|
95
|
+
export interface CreateModuleParams {
|
|
96
|
+
/** Org name or 0x id. */
|
|
97
|
+
org: string;
|
|
98
|
+
name: string;
|
|
99
|
+
description?: string;
|
|
100
|
+
link?: string;
|
|
101
|
+
payout: number | string;
|
|
102
|
+
quiz?: string[];
|
|
103
|
+
answers?: string[][];
|
|
104
|
+
correctAnswer: number;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Resolved builder for `pop education create` — src/commands/education/create-module.ts.
|
|
108
|
+
* Resolves the org's EducationHub, pins the module metadata
|
|
109
|
+
* ({name, description, link, quiz, answers} — key order load-bearing), and
|
|
110
|
+
* delegates to buildCreateModule.
|
|
111
|
+
*/
|
|
112
|
+
export declare function createModuleIntent(ctx: PopContext, params: CreateModuleParams): Promise<TxIntent>;
|
|
113
|
+
export interface CompleteModuleParams {
|
|
114
|
+
/** Org name or 0x id. */
|
|
115
|
+
org: string;
|
|
116
|
+
/** Module ID. */
|
|
117
|
+
module: string | number;
|
|
118
|
+
/** Answer index (0-based). */
|
|
119
|
+
answer: number;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Resolved builder for `pop education complete` — src/commands/education/complete.ts.
|
|
123
|
+
* Resolves the org's EducationHub and delegates to buildCompleteModule. The
|
|
124
|
+
* CLI's pre-flight (module exists via getModule, not-already-completed via
|
|
125
|
+
* hasCompleted) is a host concern — see checkModuleExists/checkNotCompleted
|
|
126
|
+
* in the CLI's education helpers.
|
|
127
|
+
*/
|
|
128
|
+
export declare function completeModuleIntent(ctx: PopContext, params: CompleteModuleParams): Promise<TxIntent>;
|
|
129
|
+
export interface UpdateModuleParams {
|
|
130
|
+
/** Org name or 0x id. */
|
|
131
|
+
org: string;
|
|
132
|
+
/** Module ID. */
|
|
133
|
+
module: string | number;
|
|
134
|
+
/** New PT reward in whole tokens (must be > 0). Omit to preserve. */
|
|
135
|
+
payout?: number;
|
|
136
|
+
name?: string;
|
|
137
|
+
description?: string;
|
|
138
|
+
link?: string;
|
|
139
|
+
quiz?: string[];
|
|
140
|
+
answers?: string[][];
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Resolved builder for `pop education update` — src/commands/education/update.ts.
|
|
144
|
+
*
|
|
145
|
+
* READ-MERGE issued concurrently (Promise.allSettled): payout + existence
|
|
146
|
+
* from on-chain getModule — deliberately NOT the indexed payout, because a
|
|
147
|
+
* full overwrite writes the read-back value and a stale one would silently
|
|
148
|
+
* ROLL BACK a concurrent raise; the same call is the ModuleUnknown existence
|
|
149
|
+
* gate. Title/metadata come from FETCH_MODULES_FOR_UPDATE (the chain stores
|
|
150
|
+
* only {answerHash, payout, exists} — metadata is event-only) with an IPFS
|
|
151
|
+
* fallback. Metadata is re-pinned ONLY when its content actually changes —
|
|
152
|
+
* same key order as create ({name, description, link, quiz, answers}).
|
|
153
|
+
*
|
|
154
|
+
* Requires ctx.provider (the on-chain getModule read).
|
|
155
|
+
*/
|
|
156
|
+
export declare function updateModuleIntent(ctx: PopContext, params: UpdateModuleParams): Promise<TxIntent>;
|
|
157
|
+
export interface RemoveModuleParams {
|
|
158
|
+
/** Org name or 0x id. */
|
|
159
|
+
org: string;
|
|
160
|
+
/** Module ID to remove (permanent — no undo). */
|
|
161
|
+
module: string | number;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Resolved builder for `pop education remove` — src/commands/education/remove.ts.
|
|
165
|
+
* Resolves the org's EducationHub, fetches a best-effort title for the
|
|
166
|
+
* confirmation summary (subgraph may lag — never blocks), and delegates to
|
|
167
|
+
* buildRemoveModule. DESTRUCTIVE: hosts should require explicit confirmation.
|
|
168
|
+
*/
|
|
169
|
+
export declare function removeModuleIntent(ctx: PopContext, params: RemoveModuleParams): Promise<TxIntent>;
|