{"id":26217044,"url":"https://github.com/hadv/vito-contracts","last_synced_at":"2026-04-29T05:33:56.516Z","repository":{"id":280800023,"uuid":"943129642","full_name":"hadv/vito-contracts","owner":"hadv","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-05T10:51:12.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-05T11:35:31.015Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hadv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-05T08:06:00.000Z","updated_at":"2025-03-05T10:51:16.000Z","dependencies_parsed_at":"2025-03-05T11:47:18.648Z","dependency_job_id":null,"html_url":"https://github.com/hadv/vito-contracts","commit_stats":null,"previous_names":["hadv/vito-contracts"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hadv%2Fvito-contracts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hadv%2Fvito-contracts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hadv%2Fvito-contracts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hadv%2Fvito-contracts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hadv","download_url":"https://codeload.github.com/hadv/vito-contracts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243213980,"owners_count":20254902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-12T12:18:48.482Z","updated_at":"2025-12-26T05:46:51.066Z","avatar_url":"https://github.com/hadv.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vito Contracts - Safe Transaction Pool \u0026 Guard\n\nThis repository contains smart contracts for Safe wallet transaction management and security guards, including a modular SafeTxPool implementation and delegate call restrictions.\n\n## Overview\n\n### SafeGuard\nThe SafeGuard contract is a guard implementation for the Safe (formerly Gnosis Safe) smart contract wallet. It restricts delegate calls to only allowed target addresses, providing an additional layer of security.\n\n### SafeTxPool (Refactored Modular Architecture)\nThe SafeTxPool has been refactored into a modular architecture to solve contract size limitations and improve maintainability:\n\n- **SafeTxPoolRegistry**: Main interface contract (13,240 bytes)\n- **SafeTxPoolCore**: Core transaction pool functionality (10,595 bytes)\n- **AddressBookManager**: Address book management (3,409 bytes)\n- **DelegateCallManager**: Delegate call permissions (4,913 bytes)\n- **TrustedContractManager**: Trusted contract management (1,650 bytes)\n- **TransactionValidator**: Transaction validation logic (5,580 bytes)\n\n**Key Benefits:**\n- ✅ All contracts well within 24KB size limit\n- ✅ 100% backward compatibility with original SafeTxPool\n- ✅ Enhanced security with proper access control\n- ✅ Modular design for easier maintenance and upgrades\n\n## Development\n\nThis project uses [Foundry](https://github.com/foundry-rs/foundry) for development and testing.\n\n### Install Dependencies\n\n```bash\nforge install\n```\n\n### Run Tests\n\n```bash\nforge test\n```\n\n### Run Tests with Coverage\n\n```bash\nforge coverage\n```\n\n## Deployment Guide\n\n### Prerequisites\n\n1. **Install Foundry**: Follow the [Foundry installation guide](https://book.getfoundry.sh/getting-started/installation)\n2. **Clone and setup**:\n   ```bash\n   git clone https://github.com/hadv/vito-contracts\n   cd vito-contracts\n   forge install\n   ```\n\n### Environment Setup\n\nCreate a `.env` file from the example:\n\n```bash\ncp .env.example .env\n```\n\nEdit `.env` with your values:\n```bash\nPRIVATE_KEY=your_private_key_without_0x_prefix\nRPC_URL=your_rpc_endpoint_url\nETHERSCAN_API_KEY=your_etherscan_api_key_for_verification\n```\n\n### Pre-deployment Checks\n\nPre-commit checks run automatically via Git hooks before each commit:\n\n- ✅ All contracts build successfully\n- ✅ All tests pass (105/105)\n- ✅ Contract sizes are within limits\n\nThe Git pre-commit hook ensures code quality automatically. If checks fail, the commit will be blocked until issues are resolved.\n\n### Deployment Options\n\n#### Option 1: Deploy SafeTxPool\n\nDeploy the SafeTxPool with modular architecture:\n\n```bash\nsource .env \u0026\u0026 forge script script/DeploySafeTxPool.s.sol:DeploySafeTxPool --rpc-url $RPC_URL --broadcast --verify -vvvv\n```\n\n**What gets deployed:**\n1. SafeTxPoolCore (transaction management)\n2. AddressBookManager (address book functionality)\n3. DelegateCallManager (delegate call permissions)\n4. TrustedContractManager (trusted contract management)\n5. TransactionValidator (validation logic)\n6. **SafeTxPoolRegistry** (main interface - use this address)\n\n#### Option 2: Deploy SafeGuard Only\n\nDeploy just the SafeGuard for delegate call restrictions:\n\n```bash\nsource .env \u0026\u0026 forge script script/DeploySafeGuard.s.sol:DeploySafeGuard --rpc-url $RPC_URL --broadcast --verify -vvvv\n```\n\n### Deployment Flags\n\n- `--verify`: Verify contracts on Etherscan (recommended)\n- `--chain-id \u003cid\u003e`: Specify network chain ID\n- `--gas-price \u003cprice\u003e`: Set specific gas price\n- `--legacy`: For networks not supporting EIP-1559\n- `-vvvv`: Verbose output for debugging\n\n### Network-Specific Examples\n\n#### Deploy to Ethereum Mainnet\n```bash\nsource .env \u0026\u0026 forge script script/DeploySafeTxPool.s.sol:DeploySafeTxPool \\\n  --rpc-url $RPC_URL \\\n  --broadcast \\\n  --verify \\\n  --chain-id 1 \\\n  -vvvv\n```\n\n#### Deploy to Sepolia Testnet\n```bash\nsource .env \u0026\u0026 forge script script/DeploySafeTxPool.s.sol:DeploySafeTxPool \\\n  --rpc-url $RPC_URL \\\n  --broadcast \\\n  --verify \\\n  --chain-id 11155111 \\\n  -vvvv\n```\n\n#### Deploy to Polygon\n```bash\nsource .env \u0026\u0026 forge script script/DeploySafeTxPool.s.sol:DeploySafeTxPool \\\n  --rpc-url $RPC_URL \\\n  --broadcast \\\n  --verify \\\n  --chain-id 137 \\\n  -vvvv\n```\n\n### Post-Deployment Verification\n\nAfter deployment, verify the contracts are working correctly:\n\n```bash\n# Check contract sizes\nforge build --sizes\n\n# Run all tests\nforge test\n\n# Check specific contract deployment\ncast code \u003cDEPLOYED_CONTRACT_ADDRESS\u003e --rpc-url $RPC_URL\n```\n\n## Contract Usage\n\n### SafeTxPool\n\nThe SafeTxPool provides comprehensive transaction management with a modular architecture:\n\n#### 1. Basic Setup\n```solidity\n// Use the SafeTxPoolRegistry address from deployment\nSafeTxPoolRegistry pool = SafeTxPoolRegistry(DEPLOYED_REGISTRY_ADDRESS);\n```\n\n#### 2. Transaction Pool Functions\n```solidity\n// Propose a transaction\npool.proposeTx(txHash, safe, to, value, data, operation, nonce);\n\n// Sign a transaction\npool.signTx(txHash, signature);\n\n// Get transaction details\n(safe, to, value, data, operation, proposer, nonce, txId) = pool.getTxDetails(txHash);\n\n// Get pending transactions\nbytes32[] memory pending = pool.getPendingTxHashes(safe, offset, limit);\n```\n\n#### 3. Address Book Management\n```solidity\n// Add address to Safe's address book (only Safe can call)\npool.addAddressBookEntry(safe, walletAddress, \"Recipient Name\");\n\n// Remove address from address book\npool.removeAddressBookEntry(safe, walletAddress);\n\n// Get all address book entries\nIAddressBookManager.AddressBookEntry[] memory entries = pool.getAddressBookEntries(safe);\n```\n\n#### 4. Delegate Call Management\n```solidity\n// Enable delegate calls for a Safe\npool.setDelegateCallEnabled(safe, true);\n\n// Add allowed delegate call target\npool.addDelegateCallTarget(safe, targetAddress);\n\n// Check if delegate calls are enabled\nbool enabled = pool.isDelegateCallEnabled(safe);\n```\n\n#### 5. Trusted Contract Management\n```solidity\n// Add trusted contract (bypasses some validations)\npool.addTrustedContract(safe, tokenAddress, \"Token Name\");\n\n// Check if contract is trusted\nbool trusted = pool.isTrustedContract(safe, contractAddress);\n\n// Get all trusted contracts\nITrustedContractManager.TrustedContractEntry[] memory contracts = pool.getTrustedContracts(safe);\n```\n\n#### 6. Guard Functionality\nSet the SafeTxPoolRegistry as a Guard on your Safe:\n\n```solidity\n// In your Safe wallet, call:\nsafe.setGuard(DEPLOYED_REGISTRY_ADDRESS);\n```\n\n**Benefits of using as Guard:**\n- ✅ Automatic transaction validation\n- ✅ Address book enforcement\n- ✅ Delegate call restrictions\n- ✅ Automatic execution tracking\n- ✅ Enhanced security for Safe transactions\n\n### SafeGuard (Standalone)\n\nFor delegate call restrictions only:\n\n```solidity\nSafeGuard guard = SafeGuard(DEPLOYED_GUARD_ADDRESS);\n\n// Add allowed target for delegate calls\nguard.addAllowedTarget(targetAddress);\n\n// Set as guard on Safe\nsafe.setGuard(address(guard));\n```\n\n### Upgrading from Previous Versions\n\nIf you were using an earlier version of SafeTxPool, the current modular architecture is **100% backward compatible**:\n\n```solidity\n// Same interface as before\nSafeTxPoolRegistry pool = SafeTxPoolRegistry(DEPLOYED_REGISTRY_ADDRESS);\npool.proposeTx(...); // Same function signature\npool.addAddressBookEntry(...); // Same function signature\n// All existing functions work identically\n```\n\n**Upgrade benefits:**\n- ✅ All contracts within 24KB size limit\n- ✅ Enhanced security with proper access control\n- ✅ Modular architecture for easier maintenance\n- ✅ Same interface - no code changes required\n\n## Troubleshooting\n\n### Common Issues\n\n#### 1. Contract Size Limit Error\n```\nError: some contracts exceed the runtime size limit (EIP-170: 24576 bytes)\n```\n**Solution**: Use the refactored SafeTxPool deployment instead of the original.\n\n#### 2. Build Failures\n```bash\n# Clean and rebuild\nforge clean\nforge build\n\n# Format code\nforge fmt\n```\n\n#### 3. Test Failures\n```bash\n# Run specific test\nforge test --match-contract SafeTxPool -vvv\n\n# Run with gas reporting\nforge test --gas-report\n```\n\n#### 4. Deployment Issues\n- Ensure sufficient ETH balance for gas\n- Check RPC URL is correct\n- Verify private key format (no 0x prefix)\n- For verification, ensure ETHERSCAN_API_KEY is set\n\n### Getting Help\n\n- **Documentation**: See [REFACTORING_GUIDE.md](REFACTORING_GUIDE.md) for detailed architecture information\n- **Issues**: Report bugs on [GitHub Issues](https://github.com/hadv/vito-contracts/issues)\n- **Testing**: Pre-commit hooks automatically run comprehensive checks before each commit\n\n## Architecture\n\nFor detailed information about the refactored architecture, contract interactions, and migration guide, see:\n- 📖 [REFACTORING_GUIDE.md](REFACTORING_GUIDE.md) - Comprehensive refactoring documentation\n- 🧪 [test/](test/) - Test files with usage examples\n- 📜 [script/](script/) - Deployment scripts\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhadv%2Fvito-contracts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhadv%2Fvito-contracts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhadv%2Fvito-contracts/lists"}