feat(mytask): MT-11 challenge/仲裁前端 — ERC-20 质押挑战 + Jury 面板(codex 闭环)#16
Merged
Conversation
clestons
approved these changes
Jul 15, 2026
clestons
left a comment
There was a problem hiding this comment.
APPROVE — 质押挑战/Jury 前端,金额与授权两处最容易出事的地方都对。
- 小数处理 — 全程
parseUnits(raw, token.decimals)/formatUnits(..., decimals),读代币真实 decimals,金额不碰浮点;Number(...)只用于时间戳和 uint8 投票分,安全。 - approve-before-stake 顺序正确 — 挑战路径
checkStakeAllowance后allowance < amount才 approve(额度够就跳过冗余授权)再 challengeWork;Jury 注册走 approve + registerJuror 两步。两条都是先授权后花费。 - 错误解码 —
decode-task-error.ts三层解自定义错误(结构化 revert → 走 errorName;hex blob →decodeErrorResult;纯错误名 → 词匹配),映射到 i18n key,不认识则 null 回落。挺讲究的 UX 防御。
合约侧安全在合约仓,不在本前端 PR;这里是 ABI/参数编码正确性,已核对。小注:Jury 注册在 minStake=0 时仍发一次 approve(0)(注释已说明为流程统一)—— 无害,可留。无阻塞。
— clestons (Opus review)
B 线 MT-11(docs/MODULES_INTEGRATION_PLAN.md §3):对齐 Sepolia 重部署的 TaskEscrowV2(challengeWork 改 ERC-20 质押,challengeStakeToken=xPNT, transferFrom 收取)与 JuryContract(pull 模式奖励池),全部写路径走 useCos72Session().send 免 gas UserOp,零 window.ethereum。 - lib/contracts/jury-abi.ts:新增 JuryContract ABI(registerJuror/vote/ finalizeTask/claimRewards/pendingRewards/isActiveJuror/getTask/getVotes 等) - lib/contracts/task-escrow-abi.ts:challengeWork payable→nonpayable(ERC-20 质押);补 challengeStakeToken/challengeStakeAmount/validationsSatisfied/ getTaskRequiredValidationTags/getTaskValidationRequirement 视图 + TaskChallenged/ChallengeResolved 事件 - lib/task-types.ts:ParsedTask 补 challengeStake/juryTaskHash/canChallenge; 新增 JuryTask/JuryVote/ValidationRequirementView/质押配置类型 - contexts/TaskContext.tsx:沿用 (args, send) 签名新增 17 个函数——挑战侧 getChallengeStakeConfig/checkStakeAllowance/approveStakeToken/challengeWork/ linkJuryValidation,验证要求只读 getValidationRequirements/ getValidationsSatisfied,Jury 侧 getJuryStakingInfo/getJurorStatus/ approveJuryStake/registerJuror/getJuryTask/getJuryVotes/voteOnJuryTask/ finalizeJuryTask/getPendingJuryRewards/claimJuryRewards + juryConfigured - app/tasks/[taskId]:Submitted+挑战期内(社区)→「挑战」按钮(approve xPNT + challengeWork 两个 gasless op,复刻 approve+create 两步模式);Challenged → 挑战信息卡 + linkJuryValidation 入口(bytes32 校验);per-tag 验证要求只读 展示 + satisfied 徽章 - app/tasks/jury(新子页,YAA Layout):陪审员注册(minStake=0 也走 approve+register 两 op)、按哈希加载 jury task、0-100 打分投票、 finalizeTask、pendingRewards 展示 + claimRewards(奖励币+质押币双行) - 任务市场页头部加陪审团面板入口;i18n 新增 taskChallenge/juryPage EN/ZH 双语 key(947 key 平检绿) 门槛:format/type-check/build/lint:check/i18n:check -w aastar-frontend 全绿。 Claude-Session: https://claude.ai/code/session_01MCxVCnKkpzi5sCGf1FZ4CH
Codex REQUEST_CHANGES 三项(对照 ~/Dev/mycelium/MyTask 当前 main a92f319): 【H】ABI 清扫(task-escrow-abi.ts 全文件对照 TaskEscrowV2.sol): - 删 createTaskWithPermit —— MT-5 已从合约删除,调用必失败;前端零引用 - 删 ERC20_ABI 的 permit/nonces —— permit 流已废,前端零引用 - 删 lib/task-types.ts TaskStatus.Disputed=7(含 label/color)—— 合约枚举 只有 0-6(Open..Refunded) - 核对保留:canFinalize/isInChallengePeriod/challengePeriod 等合约均存在; acceptTaskWithSignature/TaskAcceptedWithSignature/DOMAIN_SEPARATOR 本就 不存在于前端,无需处理 【M1/M2】挑战路径错误解码(approve/challengeWork/linkJuryValidation): - TASK_ESCROW_ABI 补 22 个合约自定义 error 定义 - 新增 lib/contracts/decode-task-error.ts:三层解码 —— viem BaseError.walk → ContractFunctionRevertedError.errorName;错误文本内嵌 revert hex → decodeErrorResult;纯文本错误名词边界匹配。10 个高频错误 (InvalidTaskState/ChallengePeriodExpired/TransferFailed/NotCommunity 等) 映射 taskChallenge.errors.* EN/ZH 成对 key,未识别 fallback 原始 message → errors.generic - 详情页 handleChallenge + runAction(覆盖 linkJuryValidation)接入解码 【L1/L2】硬编码文案 i18n 化: - 挑战按钮 "Processing..." → taskChallenge.processing - jury 页两处 "Error" fallback → juryPage.genericError 门槛:format/type-check/build/lint:check/i18n:check -w aastar-frontend 全绿(i18n 960 key 平检)。 Claude-Session: https://claude.ai/code/session_01MCxVCnKkpzi5sCGf1FZ4CH
df6660e to
e483fdd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/dev/stdin