Skip to content

Commit c65af3c

Browse files
cursoragentOba-One
andcommitted
Refactor: Modularize and organize Cursor rules
Co-authored-by: contact <[email protected]>
1 parent c2916cb commit c65af3c

File tree

13 files changed

+1930
-441
lines changed

13 files changed

+1930
-441
lines changed

.cursor/cursor-config.json

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,38 @@
11
{
22
"rules": [
33
{
4-
"include": ".cursor/rules.md",
5-
"description": "Cookie Jar root-level rules - monorepo workflow, Guild standards, environment setup"
4+
"include": ".cursor/rules/root-standards.mdc",
5+
"description": "Cookie Jar monorepo standards - always applied",
6+
"alwaysApply": true
67
},
78
{
8-
"include": "client/.cursor/rules.md",
9-
"description": "Frontend rules - Next.js, React, Web3, component patterns, testing",
9+
"include": ".cursor/rules/web3-patterns.mdc",
10+
"description": "Web3 integration patterns with viem/wagmi",
11+
"when": "path.match(/\\.(ts|tsx|sol)$/)"
12+
},
13+
{
14+
"include": ".cursor/rules/testing-patterns.mdc",
15+
"description": "Testing standards for unit, integration, and E2E tests",
16+
"when": "path.match(/\\.(test|spec|t)\\.(ts|tsx|sol)$/)"
17+
},
18+
{
19+
"include": ".cursor/rules/deployment.mdc",
20+
"description": "Production deployment patterns and security",
21+
"when": "path.match(/script\\/.*\\.s\\.sol$/) || path.includes('deploy')"
22+
},
23+
{
24+
"include": "client/.cursor/rules/frontend-standards.mdc",
25+
"description": "Frontend development standards - Next.js, React, TypeScript",
1026
"when": "path.includes('client/')"
1127
},
1228
{
13-
"include": "contracts/.cursor/rules.md",
14-
"description": "Smart contract rules - Foundry, Solidity, security, gas optimization",
29+
"include": "contracts/.cursor/rules/solidity-standards.mdc",
30+
"description": "Solidity standards - security, gas optimization, testing",
1531
"when": "path.includes('contracts/')"
1632
},
1733
{
18-
"include": "e2e/.cursor/rules.md",
19-
"description": "E2E testing rules - Playwright, accessibility, performance monitoring",
34+
"include": "e2e/.cursor/rules/e2e-standards.mdc",
35+
"description": "E2E testing with Playwright - user flows and accessibility",
2036
"when": "path.includes('e2e/')"
2137
}
2238
],

.cursor/rules.md

Lines changed: 0 additions & 49 deletions
This file was deleted.

.cursor/rules/deployment.mdc

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
---
2+
description: Production deployment patterns, security checklists, and verification steps
3+
globs:
4+
- "**/script/**"
5+
- "**/*.s.sol"
6+
alwaysApply: false
7+
---
8+
9+
# Deployment Patterns
10+
11+
## Secure Wallet Setup
12+
**ALWAYS use Foundry keystore for production deployments:**
13+
14+
```bash
15+
# Import wallet securely
16+
cast wallet import deployer --interactive
17+
18+
# Verify keystore
19+
cast wallet list
20+
21+
# NEVER use private keys in env files for production
22+
```
23+
24+
## Pre-Deployment Checklist
25+
26+
### Environment Setup
27+
- [ ] `.env` configured with correct values
28+
- [ ] RPC URLs verified and tested
29+
- [ ] Etherscan API key configured
30+
- [ ] Factory configuration values reviewed
31+
- [ ] Secure wallet keystore created
32+
33+
### Contract Verification
34+
- [ ] All tests passing: `forge test`
35+
- [ ] Gas optimization verified: `forge build --sizes`
36+
- [ ] Contract size under 24KB limit
37+
- [ ] NatSpec documentation complete
38+
- [ ] Security audit completed (for mainnet)
39+
40+
### Network Configuration
41+
- [ ] Correct network RPC URL in `.env`
42+
- [ ] Sufficient funds in deployment wallet
43+
- [ ] Gas price checked and acceptable
44+
- [ ] Testnet deployment successful
45+
46+
## Deployment Command Pattern
47+
48+
```bash
49+
# Export environment variables
50+
export $(cat .env | xargs)
51+
52+
# Deploy to target network
53+
cd contracts
54+
forge script script/Deploy.s.sol:Deploy \
55+
--rpc-url $NETWORK_RPC_URL \
56+
--account deployer \
57+
--broadcast \
58+
--verify \
59+
--gas-estimate-multiplier 120
60+
61+
# Example networks
62+
--rpc-url base-sepolia # Base Sepolia testnet
63+
--rpc-url base # Base mainnet
64+
--rpc-url ethereum # Ethereum mainnet
65+
```
66+
67+
## Mainnet Deployment Requirements
68+
69+
### Code Review
70+
```solidity
71+
// REQUIRED: Explicit mainnet acknowledgment
72+
// I ACKNOWLEDGE MAINNET DEPLOYMENT
73+
// This contract will be deployed to mainnet with real funds
74+
// All security measures have been reviewed and approved
75+
```
76+
77+
### Security Measures
78+
- [ ] Multi-sig ownership configured
79+
- [ ] Timelock on admin functions
80+
- [ ] Emergency pause functionality tested
81+
- [ ] Access controls verified
82+
- [ ] Reentrancy guards in place
83+
- [ ] Input validation complete
84+
85+
### Post-Deployment Verification
86+
```bash
87+
# Verify contract on block explorer
88+
forge verify-contract \
89+
--chain-id $CHAIN_ID \
90+
--etherscan-api-key $ETHERSCAN_API_KEY \
91+
$CONTRACT_ADDRESS \
92+
src/CookieJar.sol:CookieJar
93+
94+
# Test contract functions
95+
cast call $CONTRACT_ADDRESS "owner()" --rpc-url $RPC_URL
96+
cast call $CONTRACT_ADDRESS "version()" --rpc-url $RPC_URL
97+
98+
# Verify ownership transfer (if applicable)
99+
cast send $CONTRACT_ADDRESS \
100+
"transferOwnership(address)" \
101+
$NEW_OWNER \
102+
--account deployer \
103+
--rpc-url $RPC_URL
104+
```
105+
106+
## Testnet Deployment Workflow
107+
108+
```bash
109+
# 1. Deploy to testnet
110+
pnpm deploy:base-sepolia
111+
112+
# 2. Verify deployment
113+
pnpm verify:deployment
114+
115+
# 3. Seed test data (if needed)
116+
pnpm seed:testnet
117+
118+
# 4. Test frontend integration
119+
pnpm dev:base-sepolia
120+
121+
# 5. Run E2E tests against testnet
122+
pnpm test:e2e:testnet
123+
```
124+
125+
## Deployment Script Pattern
126+
127+
```solidity
128+
// script/Deploy.s.sol
129+
pragma solidity ^0.8.0;
130+
131+
import "forge-std/Script.sol";
132+
import "../src/CookieJarFactory.sol";
133+
134+
contract Deploy is Script {
135+
function run() external {
136+
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY");
137+
138+
vm.startBroadcast(deployerPrivateKey);
139+
140+
// 1. Deploy dependencies first
141+
CookieJarRegistry registry = new CookieJarRegistry();
142+
143+
// 2. Deploy main contracts
144+
CookieJarFactory factory = new CookieJarFactory({
145+
registry: address(registry),
146+
feeCollector: vm.envAddress("FEE_COLLECTOR"),
147+
minDeposit: vm.envUint("MIN_DEPOSIT")
148+
});
149+
150+
// 3. Configure contracts
151+
registry.transferOwnership(address(factory));
152+
153+
vm.stopBroadcast();
154+
155+
// 4. Log deployment addresses
156+
console.log("Registry:", address(registry));
157+
console.log("Factory:", address(factory));
158+
}
159+
}
160+
```
161+
162+
## Contract Upgrade Pattern
163+
164+
### For Immutable Contracts
165+
```solidity
166+
// Deploy new version
167+
// Update frontend to use new address
168+
// Communicate deprecation timeline
169+
// Provide migration tools for users
170+
```
171+
172+
### For Upgradeable Contracts (if used)
173+
```solidity
174+
// Use transparent proxy pattern
175+
// Test upgrade on testnet first
176+
// Verify storage layout compatibility
177+
// Execute upgrade via multi-sig
178+
// Monitor for issues post-upgrade
179+
```
180+
181+
## Rollback Plan
182+
183+
### If Deployment Fails
184+
1. Do NOT retry immediately
185+
2. Diagnose root cause
186+
3. Fix issues in separate branch
187+
4. Test fix on testnet
188+
5. Deploy again with proper verification
189+
190+
### If Critical Bug Found
191+
1. Pause contract (if pausable)
192+
2. Communicate with users immediately
193+
3. Deploy fix to testnet
194+
4. Audit fix thoroughly
195+
5. Deploy fix to mainnet via multi-sig
196+
6. Resume operations after verification
197+
198+
## Frontend Deployment
199+
200+
### Vercel Deployment
201+
```bash
202+
# Build and verify locally first
203+
pnpm build
204+
205+
# Check for build errors
206+
# Verify environment variables in Vercel dashboard
207+
# Deploy
208+
vercel --prod
209+
210+
# Post-deployment checks
211+
- [ ] Contract addresses correct
212+
- [ ] All pages load successfully
213+
- [ ] Wallet connection works
214+
- [ ] Transactions succeed
215+
- [ ] Analytics tracking works
216+
```
217+
218+
### Environment Variables for Production
219+
```bash
220+
# Required
221+
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=
222+
NEXT_PUBLIC_ALCHEMY_API_KEY=
223+
224+
# Optional but recommended
225+
NEXT_PUBLIC_ENABLE_ANALYTICS=true
226+
NEXT_PUBLIC_SENTRY_DSN=
227+
```
228+
229+
## Monitoring & Alerts
230+
231+
### Post-Deployment Monitoring
232+
- [ ] Set up Tenderly alerts for contract events
233+
- [ ] Monitor gas usage patterns
234+
- [ ] Track transaction success rates
235+
- [ ] Set up Sentry for frontend errors
236+
- [ ] Configure uptime monitoring
237+
- [ ] Set up block explorer alerts
238+
239+
### Key Metrics to Track
240+
- Transaction success rate: > 95%
241+
- Average gas cost: within expected range
242+
- Frontend error rate: < 1%
243+
- API response time: < 500ms
244+
- Contract balance: monitored via alerts
245+
246+
## Documentation Updates
247+
248+
### After Deployment
249+
- [ ] Update contract addresses in README
250+
- [ ] Add block explorer links
251+
- [ ] Update deployment documentation
252+
- [ ] Create migration guide (if applicable)
253+
- [ ] Announce deployment to community

0 commit comments

Comments
 (0)