feat: add TokenSafetyHook and ITokenSafetyOracle#20
Conversation
|
@JhiNResH before i do some audit on the hook. Could i suggest some key things to fix ?
it would be better to align this with the shared hook pattern and keep the implementation as close as possible to the base example style, and please remove any remaining provider-specific framing. Once that is cleaned up, happy to review a narrower v2. I would treat this as a standalone policy hook, not something that should be bundled with router or attestation paths. |
…job state v2 rewrite addressing review feedback: - Inherit BaseACPHook, override _preFund only — no manual selector routing - Read paymentToken from getJob(jobId) instead of decoding from callback data - Remove upgradeable pattern — align with non-upgradeable hook style - Remove provider-specific framing (security@maiat.io → security@erc-8183.org) - 9 tests: safe/unsafe/whitelist/no-token/admin/batch/verdict-mask
bd3a633 to
36f7c1b
Compare
|
Rewrote from scratch. All three issues fixed:
9 tests cover: safe token pass, honeypot revert, whitelist bypass, no-token skip, blocked verdict mask, admin access, batch whitelist. Force-pushed — clean single commit on top of current |
|
Hi @JhiNResH,
|
|
Updated PR #20 in commit e73c86d.\n\nAddressed the requested changes:\n1. Pulled current upstream main into this branch.\n2. Added MultiHookRouter support by implementing IERC8183HookMetadata; requiredSelectors() now declares the fund selector.\n3. Moved ITokenSafetyOracle into TokenSafetyHook.sol as an inline minimal interface.\n4. Slimmed the PR down to a single file: contracts/hooks/TokenSafetyHook.sol.\n5. Use case: block unsafe ERC-20 payment tokens before job funds enter escrow.\n6. Problem solved: prevents honeypot/high-tax/blocked payment tokens from entering ERC-8183 job funding while keeping token-risk scoring external to the hook. |
|
Hi @JhiNResH, Thanks for addressing the review feedback. I appreciate the time you put into the revisions. Closing this PR. The hook duplicates the functionality of its own It also fails open in several places:
Thanks for the engagement. |
TokenSafetyHook v2
Gates job funding when payment token is flagged as unsafe by an external oracle.
Changes from v1
FUND_SELselectorBaseACPHook, override_preFund— no manual selector routingpaymentTokenfromgetJob(jobId)How it works
fund(jobId, ...)triggersbeforeAction→_preFundjob.paymentTokenfromAgenticCommerce.getJob(jobId)ITokenSafetyOracle→ if verdict is blocked → revertFiles
contracts/hooks/TokenSafetyHook.solcontracts/interfaces/ITokenSafetyOracle.soltest/TokenSafetyHook.t.solTest plan
forge test --match-contract TokenSafetyHookTest— 9/9 pass_preFundreads token from job state, not callback data