Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The architecture follows a **hybrid server/client model**: sensitive operations
| API | Bags.fm API v1 (server-side proxy) |
| Database | Supabase (PostgreSQL + Auth + RLS) |
| Telemetry | Custom event logger with Sentry integration |
| Testing | Vitest (TS), Hardhat (Solidity) |
| Testing | Vitest (TS) [Primary], Hardhat (Solidity) [Legacy] |

---

Expand Down Expand Up @@ -195,8 +195,9 @@ graph TB
- `.env` with: `BAGS_API_KEY`, `SUPABASE_SERVICE_ROLE_KEY`, `NEXT_PUBLIC_SOLANA_RPC_URL`

### Testing
- `npm run test:ts`: Vitest suite for client, routes, and logic (22+ tests).
- `npm run test`: Hardhat suite for Solidity contracts.
- `npm run test`: Primary Vitest suite for Solana client, routes, and logic (26+ tests).
- `npm run test:ts`: Alias for the primary Solana Vitest suite.
- `npm run test:evm`: Legacy Hardhat suite for archived Solidity contracts (`legacy/evm/`).

---

Expand Down
55 changes: 55 additions & 0 deletions docs/reports/p0-10-evm-migration-execution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# P0-10 Report: Migrate Legacy EVM Contract Suite to legacy/evm

Date: 2026-05-25
Task ID: P0-10
Area: Repository Hygiene & Smart Contract Engineering

## 1. Executive Summary

This task successfully resolves the repository hygiene gaps surrounding the deprecated Ethereum Virtual Machine (EVM) Solidity contracts. As BagFi has transitioned into a **Solana-first** non-custodial asset platform, the legacy Solidity zappers and vault contracts are no longer utilized by the Next.js production builds.

To prevent legacy compilation and test failures from blocking automated developer pipelines, CI/CD gates, and local verification runs:
1. We migrated the Solidity contracts, Hardhat configuration, and JavaScript tests into a dedicated subfolder (`legacy/evm/`).
2. We decoupled Hardhat from the default `npm run test` gate, re-routing it to the TypeScript Solana-native **Vitest** test suite.
3. We enabled isolated, self-contained execution of the legacy EVM test suite via a new dedicated command (`npm run test:evm`).

---

## 2. Restructuring Actions

We relocated the following legacy assets into `legacy/evm/`:
- **Contracts**: `contracts/` directory moved to `legacy/evm/contracts/`
- **Configuration**: `hardhat.config.js` moved to `legacy/evm/hardhat.config.js`
- **Tests**:
- `test/BagFiZapper.test.cjs` moved to `legacy/evm/test/BagFiZapper.test.cjs`
- `test/SmartBagVault.test.cjs` moved to `legacy/evm/test/SmartBagVault.test.cjs`

This aligns perfectly with Hardhat's relative resolution mechanics. Because paths inside `legacy/evm/hardhat.config.js` are configured relative to the configuration file, compiler cache and build artifacts will naturally compile under `legacy/evm/cache/` and `legacy/evm/artifacts/` without cluttering the root workspace.

---

## 3. Package & Script Updates

### Scripts Updated
In **[package.json](file:///Users/ekf/Downloads/Projects/bagfi/package.json)**, we updated the test scripts:
```json
"scripts": {
"test": "vitest run",
"test:ts": "vitest run",
"test:evm": "hardhat test --config legacy/evm/hardhat.config.js"
}
```
- Running `npm run test` or `npm test` now executes the Solana Vitest suite directly.
- Running `npm run test:evm` executes the legacy EVM test suite in isolation.

### Documentation Updated
- **[README.md](file:///Users/ekf/Downloads/Projects/bagfi/legacy/evm/README.md) [NEW]**: Created a detailed readme inside the legacy folder detailing the deprecation status, structural directory mapping, and standalone testing steps.
- **[ARCHITECTURE.md](file:///Users/ekf/Downloads/Projects/bagfi/ARCHITECTURE.md)**: Updated testing and tech stack sections to represent the Vitest-first architecture and document the legacy EVM subfolder mapping.

---

## 4. Verification & Validation

- **Primary tests**: Run `npm run test` (which now runs vitest) - **26/26 tests passed** successfully.
- **Lint validation**: Run `npm run lint` - **0 errors**, passed.
- **Next.js compilation**: Run `npm run build` - compiled and optimized successfully.
39 changes: 39 additions & 0 deletions legacy/evm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Legacy EVM Contracts & Hardhat Suite

This directory contains the legacy Ethereum Virtual Machine (EVM) smart contracts and testing suite for BagFi.

## ⚠️ Deprecation Status

As of **May 2026**, the BagFi platform has successfully migrated to a **Solana-first, non-custodial** architecture.
The core automated yield-generating "Smart Bags" are executed directly on the Solana mainnet, leveraging **Bags.fm** proxy layers and the **Jupiter API** for trades and allocations.

As a result:
- The solidity contracts inside this directory are **deprecated** and not used by the production Next.js frontend.
- These contracts are preserved here for historical reference, auditing context, and potential future multi-chain expansions.
- Hardhat tests have been decoupled from the primary CI/CD build pipelines and local launch gates.

---

## 📂 Directory Layout

* `contracts/` — Legacy ERC-4626 vault and zap-in contracts:
* `SmartBagVault.sol` — Standard ERC-4626 portfolio vault.
* `BagFiZapper.sol` — 1-click swap and deposit zapper.
* `test/` — JavaScript Hardhat test suites.
* `hardhat.config.js` — Hardhat compilation and path configurations.

---

## 🧪 Running EVM Tests

To run the Hardhat test suite, execute the following command from the **root** of the repository:

```bash
npm run test:evm
```

This is a wrapper that executes:
```bash
npx hardhat test --config legacy/evm/hardhat.config.js
```
All relative paths inside `hardhat.config.js` resolve relative to this directory, allowing compilation caches and artifacts to generate cleanly under `legacy/evm/cache/` and `legacy/evm/artifacts/`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../build-info/1282d9a13b7ab675f783ff431077ec65.json"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Ownable",
"sourceName": "@openzeppelin/contracts/access/Ownable.sol",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "OwnableInvalidOwner",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "OwnableUnauthorizedAccount",
"type": "error"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x",
"deployedBytecode": "0x",
"linkReferences": {},
"deployedLinkReferences": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../build-info/1282d9a13b7ab675f783ff431077ec65.json"
}
Loading
Loading