- Fix all TypeScript compilation errors (40+ fixes) - Add missing type definitions (TransactionRequest, SafeInfo) - Fix TransactionRequestStatus vs TransactionStatus confusion - Fix import paths and provider type issues - Fix test file errors and mock providers - Implement comprehensive security features - AES-GCM encryption with PBKDF2 key derivation - Input validation and sanitization - Rate limiting and nonce management - Replay attack prevention - Access control and authorization - Add comprehensive test suite - Integration tests for transaction flow - Security validation tests - Wallet management tests - Encryption and rate limiter tests - E2E tests with Playwright - Add extensive documentation - 12 numbered guides (setup, development, API, security, etc.) - Security documentation and audit reports - Code review and testing reports - Project organization documentation - Update dependencies - Update axios to latest version (security fix) - Update React types to v18 - Fix peer dependency warnings - Add development tooling - CI/CD workflows (GitHub Actions) - Pre-commit hooks (Husky) - Linting and formatting (Prettier, ESLint) - Security audit workflow - Performance benchmarking - Reorganize project structure - Move reports to docs/reports/ - Clean up root directory - Organize documentation - Add new features - Smart wallet management (Gnosis Safe, ERC4337) - Transaction execution and approval workflows - Balance management and token support - Error boundary and monitoring (Sentry) - Fix WalletConnect configuration - Handle missing projectId gracefully - Add environment variable template
2.9 KiB
2.9 KiB
Quick Reference Guide
Quick reference for common tasks and patterns in the Impersonator Smart Wallet system.
Common Code Patterns
Validate Address
import { validateAddress } from "@/utils/security";
const validation = validateAddress(address);
if (!validation.valid) {
throw new Error(validation.error);
}
const checksummed = validation.checksummed!;
Create Transaction
import { useTransaction } from "@/contexts/TransactionContext";
const { createTransaction } = useTransaction();
const tx = await createTransaction({
from: walletAddress,
to: recipientAddress,
value: ethers.utils.parseEther("1.0").toHexString(),
data: "0x",
method: TransactionExecutionMethod.DIRECT_ONCHAIN,
});
Use Secure Storage
import { SecureStorage } from "@/utils/encryption";
const storage = new SecureStorage();
await storage.setItem("key", JSON.stringify(data));
const data = await storage.getItem("key");
Rate Limiting
import { RateLimiter } from "@/utils/security";
const limiter = new RateLimiter();
if (!limiter.checkLimit(userAddress)) {
throw new Error("Rate limit exceeded");
}
Monitor Events
import { monitoring } from "@/utils/monitoring";
monitoring.info("Event occurred", { context });
monitoring.error("Error occurred", error, { context });
File Locations
Key Files
- Main App:
app/page.tsx - Providers:
app/providers.tsx - Types:
types.ts - Constants:
utils/constants.ts
Contexts
- Smart Wallet:
contexts/SmartWalletContext.tsx - Transaction:
contexts/TransactionContext.tsx - Safe Inject:
contexts/SafeInjectContext.tsx
Utilities
- Security:
utils/security.ts - Encryption:
utils/encryption.ts - Monitoring:
utils/monitoring.ts
Helpers
- Communicator:
helpers/communicator.ts - Gnosis Safe:
helpers/smartWallet/gnosisSafe.ts - Transaction:
helpers/transaction/execution.ts - Balance:
helpers/balance/index.ts
Common Tasks
Add New Network
- Add to
NETWORKS.SUPPORTED_NETWORK_IDSinutils/constants.ts - Update network list component
- Test connection
Add New Validation
- Add function to
utils/security.ts - Add JSDoc comment
- Write tests
- Use in components
Add New Component
- Create in appropriate
components/subdirectory - Export component
- Add to parent
- Write tests
Testing Commands
# Run all tests
pnpm test
# Run specific test
pnpm test __tests__/security.test.ts
# Watch mode
pnpm test:watch
# Coverage
pnpm test:coverage
Environment Variables
NEXT_PUBLIC_WC_PROJECT_ID=your_project_id
NEXT_PUBLIC_SENTRY_DSN=your_sentry_dsn
TENDERLY_API_KEY=your_tenderly_key