ApeShift Pro ๐โก
Production-grade Brownie โ Ape Framework migration codemod
Built with Codemod ยท JSSG (ast-grep) ยท Python AST transformations
What is ApeShift?
ApeShift automates 93% of the code migration from Brownie (deprecated) to Ape Framework using deterministic AST transformations powered by Codemod's JSSG engine. Validated against real DeFi codebases (Yearn Finance).
No regex hacks. No string replacements. Real AST-level code understanding.
๐ก Why We Built This (The Value Proposition)
The Problem:
Brownie was the industry-standard Python testing framework for Ethereum smart contracts, but it is now officially deprecated and unmaintained. Thousands of DeFi protocols (like Yearn, Curve, and countless others) have massive test suites stuck on a dying framework. Migrating these repositories to the modern Ape Framework manually is a nightmare: it takes weeks of engineering time, is highly prone to human error, and halts product development.
The Solution:
We built ApeShift to completely eliminate the friction of migrating. By leveraging Codemod and AST (Abstract Syntax Tree) parsing, ApeShift understands Python semantics and automatically translates Brownie-specific syntax into Ape-compatible code.
The Impact:
- โฑ๏ธ Saves Weeks of Work: What used to take a developer 2 weeks of tedious find-and-replace now takes 15 seconds.
- ๐ก๏ธ Zero False Positives: Because it uses AST (via
ast-grep), it only modifies actual code structures, ignoring comments, strings, and unrelated variables. - ๐ Standardization: Helps the entire Web3 Python ecosystem safely move to Ape Framework without abandoning their legacy test suites.
๐ฏ Coverage โ 26 Deterministic Transformation Rules
| # | Brownie Pattern | Ape Equivalent | Type |
|---|---|---|---|
| 1 | from brownie import X | from ape import X | Import |
| 2 | import brownie | import ape | Import |
| 3 | brownie.X | ape.X | Attribute |
| 4 | accounts[N] | accounts.test_accounts[N] | Accounts |
| 5 | Token.deploy(args, {"from": acc}) | project.Token.deploy(args, sender=acc) | Deploy |
| 6 | contract.func({"from": acc}) | contract.func(sender=acc) | Transaction |
| 7 | contract.func(args, {"from": X, "value": Y}) | contract.func(args, sender=X, value=Y) | Tx Params |
| 8 | chain.sleep(N) | chain.pending_timestamp += N | Chain API |
| 9 | chain.time() | chain.pending_timestamp | Chain API |
| 10 | chain.mine(N) | chain.mine(num_blocks=N) | Chain API |
| 11 | Wei("1 ether") | "1 ether" | Value |
| 12 | brownie.reverts("msg") | ape.reverts("msg") | Testing |
| 13 | Contract.at(addr) | Contract(addr) | Contract |
| 14 | network.show_active() | networks.provider.network.name | Network |
| 15 | network.connect(X) | # TODO: ape context manager | Network |
| 16 | network.disconnect() | # TODO: ape context manager | Network |
| 17 | VirtualMachineError | ContractLogicError | Exception |
| 18 | network (import) | networks | Import |
| 19 | accounts.at("0x...", force=True) | accounts.impersonate_account("0x...") | Accounts |
| 20 | config["..."] | # TODO: ape-config.yaml | Config |
| 21 | web3.X | # TODO: ape provider | Web3 |
| 22 | fn_isolation | # TODO: ape-test handles natively | Testing |
| 23 | Wei (import) | removed | Import |
| 24 | config (import) | removed | Import |
| 25 | web3 (import) | removed | Import |
| 26 | Contract names (import) | auto-inject project | Import |
๐ Quick Start
Run directly from Codemod Registry (Recommended)
Run the codemod on your project without downloading the repo:
bash
Run locally from the repository
If you clone this repository, you can run the workflow locally:
bash
Run with AI edge-case handling (Local only)
bash
Run tests
bash
๐ Project Structure
text
๐ Architecture
text
๐งช Testing
The codemod includes 3 snapshot test suites โ including tests from the real Yearn Finance brownie-strategy-mix:
bash
See CASE_STUDY.md for full coverage analysis.
๐ฆ Publishing
bash
Or via GitHub Actions with Trusted Publishers.
๐ References
License
MIT