Skip to content

Commit 39044c5

Browse files
authored
Merge branch 'main' into copilot/fix-37ff8edf-785b-45fd-9d38-114e310c1829
2 parents 0ac16d5 + b0933d2 commit 39044c5

36 files changed

+4002
-1276
lines changed

.env.example

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Environment variables for Onchain Test Kit
2+
# Copy this file to .env and fill in your values
3+
4+
# Test wallet seed phrase (NEVER use real funds - test wallets only!)
5+
E2E_TEST_SEED_PHRASE="your-test-seed-phrase-here"
6+
7+
# Optional: RPC URLs for fork mode testing
8+
# ETHEREUM_RPC_URL="https://eth-mainnet.g.alchemy.com/v2/your-api-key"
9+
# BASE_RPC_URL="https://mainnet.base.org"
10+
# ARBITRUM_RPC_URL="https://arb1.arbitrum.io/rpc"
11+
12+
# Optional: Test configuration
13+
# TEST_TIMEOUT=30000
14+
# BROWSER_HEADLESS=false

.github/ISSUE_TEMPLATE/setup.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Setup Issues
2+
description: Report issues with development environment setup
3+
title: "[Setup] "
4+
labels: ["setup", "documentation"]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Thanks for reporting a setup issue! Please provide details to help us improve the copilot setup process.
10+
11+
- type: checkboxes
12+
id: setup-steps
13+
attributes:
14+
label: Setup Steps Attempted
15+
description: Which setup steps have you tried?
16+
options:
17+
- label: Ran `npm install`
18+
- label: Ran `npm run build`
19+
- label: Ran `npm run lint`
20+
- label: Ran `npm run test`
21+
- label: Ran `npm run copilot:setup`
22+
- label: Ran `npm run copilot:validate`
23+
- label: Prepared wallet extensions (`npm run prepare-metamask`)
24+
25+
- type: dropdown
26+
id: environment
27+
attributes:
28+
label: Environment
29+
description: What environment are you using?
30+
options:
31+
- GitHub Codespaces
32+
- Local development
33+
- GitHub Actions
34+
- Docker
35+
- Other
36+
37+
- type: input
38+
id: node-version
39+
attributes:
40+
label: Node.js Version
41+
description: What version of Node.js are you using? (run `node --version`)
42+
placeholder: "v18.17.0"
43+
validations:
44+
required: true
45+
46+
- type: textarea
47+
id: error-output
48+
attributes:
49+
label: Error Output
50+
description: Please paste the complete error output
51+
render: shell
52+
validations:
53+
required: true
54+
55+
- type: textarea
56+
id: expected-behavior
57+
attributes:
58+
label: Expected Behavior
59+
description: What did you expect to happen?
60+
validations:
61+
required: true
62+
63+
- type: checkboxes
64+
id: documentation
65+
attributes:
66+
label: Documentation Checked
67+
description: Have you checked the relevant documentation?
68+
options:
69+
- label: Read `.github/copilot-instructions.md`
70+
- label: Checked `AGENTS.md` for general instructions
71+
- label: Reviewed the README setup section
72+
- label: Looked at the setup scripts in `/scripts` directory
73+
74+
- type: textarea
75+
id: additional-context
76+
attributes:
77+
label: Additional Context
78+
description: Add any other context about the problem here.

.github/agents/README.md

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
# AI Coding Agents Configuration
2+
3+
This directory contains configuration and guidelines for AI coding agents working with the Onchain Test Kit repository. These instructions help coding agents understand the project structure, development workflows, and best practices.
4+
5+
## Overview
6+
7+
The Onchain Test Kit is an end-to-end testing toolkit for blockchain applications, powered by Playwright. This repository supports multiple AI coding agents with specialized instructions to help them work effectively on blockchain testing scenarios.
8+
9+
## Quick Start for Agents
10+
11+
```bash
12+
# 1. Setup the development environment
13+
npm install && npm run build && npm run test
14+
15+
# 2. Prepare wallet extensions for testing
16+
npm run prepare-metamask
17+
18+
# 3. Configure environment variables
19+
cp .env.example .env
20+
# Edit .env to add E2E_TEST_SEED_PHRASE (test-only seed phrase)
21+
```
22+
23+
## Documentation Structure
24+
25+
### Primary Instructions
26+
- **[`.github/copilot-instructions.md`](../copilot-instructions.md)** - Main instructions for GitHub Copilot and general AI agents
27+
- **[`AGENTS.md`](../../AGENTS.md)** - Comprehensive guide for all AI coding agents
28+
- **[`CLAUDE.md`](../../CLAUDE.md)** - Claude AI-specific optimizations and patterns
29+
- **[`GEMINI.md`](../../GEMINI.md)** - Gemini AI rapid development workflows
30+
31+
### Specialized Instructions
32+
- **[`development.instructions.md`](../instructions/development.instructions.md)** - Development environment and coding standards
33+
- **[`testing.instructions.md`](../instructions/testing.instructions.md)** - Comprehensive testing strategies
34+
- **[`wallet-integration.instructions.md`](../instructions/wallet-integration.instructions.md)** - Wallet-specific implementation patterns
35+
36+
## Key Concepts for Agents
37+
38+
### Repository Purpose
39+
This toolkit enables end-to-end testing of blockchain applications with:
40+
- Automated wallet interactions (MetaMask, Coinbase Wallet, Phantom)
41+
- Fork mode testing against real blockchain data
42+
- Type-safe configuration using TypeScript
43+
- Cross-chain testing capabilities
44+
45+
### Core Technologies
46+
- **TypeScript** (strict mode, no `any` types)
47+
- **Playwright** for browser automation
48+
- **Viem** for Ethereum interactions
49+
- **Biome** for linting and formatting
50+
- **Anvil/Foundry** for local blockchain nodes
51+
52+
### Architecture Principles
53+
54+
#### 1. Fluent Configuration API
55+
```typescript
56+
const config = configure()
57+
.withLocalNode({ fork: rpcUrl, chainId: 1 })
58+
.withMetaMask()
59+
.withSeedPhrase({ seedPhrase, password })
60+
.withNetwork({ name, rpcUrl, chainId, symbol })
61+
.build();
62+
```
63+
64+
#### 2. Test Creation Pattern
65+
```typescript
66+
const test = createOnchainTest(config);
67+
68+
test('wallet interaction', async ({ page, metamask, node }) => {
69+
await page.goto('http://localhost:3000');
70+
await metamask.handleAction('connect', { shouldApprove: true });
71+
await expect(page.getByTestId('connected')).toBeVisible();
72+
});
73+
```
74+
75+
#### 3. Wallet Action Abstraction
76+
All wallet interactions use a unified action interface:
77+
- `connect` - Connect wallet to DApp
78+
- `transaction` - Approve/reject transactions
79+
- `signature` - Sign messages
80+
- `switchNetwork` - Change networks
81+
- `tokenApproval` - Approve token spending
82+
83+
## Development Guidelines
84+
85+
### Code Quality Standards
86+
- **TypeScript strict mode** - No implicit `any`, proper typing required
87+
- **Biome linting** - Run `npm run lint:fix` before committing
88+
- **Comprehensive testing** - All features require tests
89+
- **Documentation** - Update README and docs for API changes
90+
91+
### Build and Test Workflow
92+
```bash
93+
# Standard development cycle
94+
npm run build # Compile TypeScript
95+
npm run lint:fix # Fix formatting and style
96+
npm run test # Run Playwright tests
97+
```
98+
99+
### Testing Philosophy
100+
- **End-to-end focus** - Test complete user workflows
101+
- **Fork mode realism** - Use real blockchain data when possible
102+
- **Cross-wallet compatibility** - Ensure features work with all supported wallets
103+
- **Type safety** - Leverage TypeScript for compile-time verification
104+
105+
## Agent-Specific Guidance
106+
107+
### For GitHub Copilot
108+
- Use descriptive function/variable names for better suggestions
109+
- Add JSDoc comments for complex functions
110+
- Follow existing patterns for consistent completions
111+
- Read `.github/copilot-instructions.md` for detailed guidance
112+
113+
### For Claude AI
114+
- Focus on comprehensive analysis and edge cases
115+
- Design thorough test coverage strategies
116+
- Consider blockchain complexity and multi-chain scenarios
117+
- Read `CLAUDE.md` for deep analysis patterns
118+
119+
### For Gemini AI
120+
- Start with simple, working implementations
121+
- Iterate quickly with fast feedback cycles
122+
- Focus on user experience and performance
123+
- Read `GEMINI.md` for rapid development workflows
124+
125+
### For Other Agents
126+
- Follow patterns in `AGENTS.md`
127+
- Maintain consistency with established code structure
128+
- Prioritize type safety and comprehensive testing
129+
- Adapt guidelines as needed for your specific capabilities
130+
131+
## Critical Files for Agents
132+
133+
### Core API Surface
134+
- **`src/configBuilder.ts`** - Main configuration API (changes affect all users)
135+
- **`src/createOnchainTest.ts`** - Core test setup logic
136+
- **`src/wallets/*/index.ts`** - Wallet-specific implementations
137+
138+
### Build and CLI
139+
- **`package.json`** - Build scripts and dependencies
140+
- **`tsconfig.json`** - TypeScript configuration
141+
- **`biome.json`** - Linting and formatting rules
142+
- **`src/cli/*.mjs`** - Wallet preparation scripts
143+
144+
### Testing Infrastructure
145+
- **`tests/`** - Test files and fixtures
146+
- **`playwright.config.ts`** - Playwright configuration
147+
148+
## Common Tasks
149+
150+
### Adding Wallet Support
151+
1. Create `src/wallets/NewWallet/` directory
152+
2. Implement wallet class extending BaseWallet
153+
3. Add Playwright fixtures
154+
4. Create CLI preparation script
155+
5. Update configuration builder
156+
6. Add comprehensive tests
157+
158+
### Adding Wallet Actions
159+
1. Define action type in base interfaces
160+
2. Implement in all wallet classes
161+
3. Add parameter validation
162+
4. Create tests for all wallets
163+
5. Update documentation
164+
165+
### Configuration Changes
166+
1. Maintain backward compatibility
167+
2. Add validation for new parameters
168+
3. Update type definitions
169+
4. Provide migration guides if breaking
170+
171+
## Known Issues
172+
173+
### Wallet Extensions
174+
-**MetaMask** - Works correctly
175+
- ⚠️ **Coinbase Wallet** - Extension download currently broken (upstream issue)
176+
- ⚠️ **Phantom** - Extension download currently broken (upstream issue)
177+
178+
### Environment Requirements
179+
- Node.js >= 14.0.0 (recommended >= 18.0.0)
180+
- Foundry for local blockchain testing
181+
- Test-only seed phrases (NEVER use real funds)
182+
183+
## Best Practices for Agents
184+
185+
### 1. Understand Before Changing
186+
- Read relevant instruction files before making changes
187+
- Build and test to understand current state
188+
- Identify patterns in existing code
189+
- Check for similar implementations
190+
191+
### 2. Make Minimal Changes
192+
- Focus on the specific issue or feature
193+
- Avoid refactoring unrelated code
194+
- Maintain existing patterns and style
195+
- Test changes incrementally
196+
197+
### 3. Maintain Type Safety
198+
- Use proper TypeScript types throughout
199+
- Leverage discriminated unions for action types
200+
- Ensure proper async/await typing
201+
- Avoid using `any` type
202+
203+
### 4. Comprehensive Testing
204+
- Add tests for new functionality
205+
- Test edge cases and error conditions
206+
- Ensure cross-wallet compatibility
207+
- Use fork mode for realistic scenarios
208+
209+
### 5. Documentation
210+
- Update README for API changes
211+
- Add JSDoc comments for public APIs
212+
- Include usage examples
213+
- Keep documentation current
214+
215+
## Getting Help
216+
217+
If you encounter issues or need clarification:
218+
1. Check the relevant instruction files listed above
219+
2. Review existing code for similar patterns
220+
3. Consult CONTRIBUTING.md for contribution guidelines
221+
4. Check README.md for project overview
222+
223+
## Security Considerations
224+
225+
- Never commit real seed phrases or private keys
226+
- Use test-only credentials in .env files
227+
- Validate user inputs in wallet interactions
228+
- Handle sensitive data appropriately
229+
230+
---
231+
232+
**Remember**: This toolkit focuses on making blockchain testing accessible and reliable. Prioritize clear APIs, comprehensive error handling, and type safety over premature optimization.

0 commit comments

Comments
 (0)