fork-test-wallet-policy-changes
Use when changing an allowlist, spending cap, or guard on a live wallet. Replays the change and a representative transfer against a mainnet fork so the policy is proven before real signers approve.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 81
- Forks
- 17
01 前言 Front Matter
- name
- fork-test-wallet-policy-changes
- description
- Use when changing an allowlist, spending cap, or guard on a live wallet. Replays the change and a representative transfer against a mainnet fork so the policy is proven before real signers approve.
02 资源文件 3
- 许可证LICENSE1.0 KB
- 参考文档SOURCE.md357 B
- 参考文档TRUST.auto.yaml2.1 KB
03 SKILL.md 正文
Fork-test wallet policy changes
Policy changes on a live wallet are hard to undo and easy to get subtly wrong — an off-by-one on a cap, a linked-list error in an allowlist, a guard that reverts legitimate spends. This skill proves the change on a fork first.
Procedure
- Snapshot the exact state the change will run against: fork at the current block so token balances, allowances, and the owner set match mainnet.
anvil --fork-url $RPC --fork-block-number $LATEST - Apply the pending policy change on the fork with the same calldata you intend to sign (allowlist add,
setGuard, cap update). - Run a representative transaction that should pass — a normal spend to an allowlisted destination within the cap — and confirm it succeeds on the fork.
- Run the negative cases: over-cap amount, non-allowlisted destination, a below-assumed-decimal token amount, and a transfer during the cool-down. Each must revert with the expected reason.
- For an allowlist change, exercise the linked-list boundary: add at the head, add at the tail, remove the head, remove the tail. Off-by-one in
prevModule/prevOwnerordering shows up only here. - Confirm the change itself is reversible on the fork (a guard can be removed, an allowlist entry deleted) before signing the real one.
- Record the fork block number and the calldata hashes so the mainnet transaction is provably the tested one.
Pitfalls
- Forking at a stale block lets your balance assumptions drift; fork at
latestand state the block number. - A fork has no mempool competition; success on a fork does not prove gas or MEV outcomes, only that the policy logic holds.
- Testing only the happy path misses the whole point; the revert cases are the test.
- An allowlist implemented as a sorted linked list returns a different
prevafter insertions; copy the exact ordering from the fork state, never from memory. - Rebuilding the calldata by hand after the fork test means you signed something untested; hash and compare.
- If the guard reads a price oracle, fork at a block where the oracle value is representative; a manipulated block gives false confidence.
- Anvil's default tip may exclude your recent deployment; pin it with
--fork-block-number. - A policy that passes on a fork can still fail on mainnet under a different
tx.origin; test with the real sender. - Rerun the whole suite after any change to the policy contract; a one-line fix invalidates prior results.
Verification
# on the fork: happy path succeeds, and each negative case reverts
cast send $TOKEN "transfer(address,uint256)" $ALLOWED $SMALL --from $SENDER --rpc-url http://127.0.0.1:8545
cast send $TOKEN "transfer(address,uint256)" $BLOCKED $SMALL --from $SENDER --rpc-url http://127.0.0.1:8545
# expect the first to succeed and the second to revert with the policy reason
Report the fork block, the calldata hash tested, and the pass/revert results, quoting the outputs.
04 同仓库更多 Skills
recipe-performance
Diagnose a specific MetaMask user flow's real-app performance and Sentry critical-user-flow telemetry with deterministic mm-harness recipes. Use for CUF boundaries, cold/warm/background-resume behavior, latency regressions, lifecycle tags, duplicate or blocking network requests, long tasks, layout/paint cost, screen redraws, React rerenders, or browser trace analysis where tests alone cannot prove the real app.
mexc-spot-websocket
MEXC Spot WebSocket workflows for public streams, protobuf handling, depth maintenance, listen keys, and private streams without exposing API keys.
mexc-spot-rest
MEXC Spot REST workflows for public data, signed account requests, orders, wallet/admin actions, and secure signing without exposing API keys.
mexc-futures-websocket
MEXC Futures WebSocket workflows for public streams, private account/order/position streams, ping/pong, subscriptions, and depth maintenance.
0xklen-version-and-refresh-sanctions-lists
暂无简介
verify-tests-cover-changed-lines
Use when a PR adds code that the existing suite may not exercise. Measures patch coverage — the share of newly changed lines hit by tests — before approving.