# Contributing to Equilink

Thank you for your interest in contributing to Equilink! This document provides guidelines and best practices for contributing to the project.

## [How to Contribute](#how-to-contribute)

### Getting Started

1. Fork the repository
2. Clone your fork:

```bash
git clone https://github.com/yourusername/equilink.git
cd equilink
```

3. Create a new branch:

```bash
git checkout -b feature/your-feature-name
```

#### Development Environment Setup

1. Install development dependencies:

```bash
pip install -r requirements-dev.txt
```

2. Install pre-commit hooks:

```bash
pre-commit install
```

### Coding Standards

We follow these coding standards:

**Python**

* Follow PEP 8 style guide
* Use type hints for function arguments and return values
* Maximum line length of 88 characters (Black formatter)
* Docstrings for all public methods and classes (Google style)

Example:

```python
from typing import List, Optional

def process_transaction(
    amount: float,
    token_address: str,
    recipient: Optional[str] = None
) -> List[dict]:
    """Process a blockchain transaction.

    Args:
        amount: The transaction amount.
        token_address: The token contract address.
        recipient: Optional recipient address.

    Returns:
        List of transaction receipts.

    Raises:
        TransactionError: If the transaction fails.
    """
    # Implementation
```

**JavaScript/TypeScript**

* Use ESLint with Airbnb configuration
* Use Prettier for formatting
* Use TypeScript for type safety

### Testing

**Writing Tests**

* Write unit tests for all new features
* Maintain test coverage above 85%
* Use pytest for Python tests
* Use Jest for JavaScript tests

Example test:

```python
import pytest
from equilink.core import Transaction

def test_transaction_validation():
    tx = Transaction(amount=1.0, token="ETH")
    
    # Test valid transaction
    assert tx.validate() is True
    
    # Test invalid amount
    with pytest.raises(ValueError):
        Transaction(amount=-1.0, token="ETH")
```

### Pull Request Process

1. Update documentation if needed
2. Add tests for new features
3. Run the test suite:

```bash
pytest
npm test
```

4. Push to your fork:

```bash
git push origin feature/your-feature-name
```

5. Open a Pull Request with:
   * Clear title and description
   * Link to any related issues
   * Screenshots/videos for UI changes
   * List of testing steps

### Commit Messages

Follow conventional commits specification:

```
<type>(<scope>): <description>

[optional body]

[optional footer]
```

Types:

* feat: New feature
* fix: Bug fix
* docs: Documentation changes
* style: Code style changes
* refactor: Code refactoring
* test: Adding tests
* chore: Maintenance tasks

Example:

```
feat(trading): implement automatic gas optimization

- Add gas price monitoring
- Implement dynamic gas adjustment
- Add configuration options

Closes #123
```

## [Documentation](#documentation)

### Updating Documentation

1. Update relevant .md files in the /docs directory
2. Generate API documentation:

```bash
make docs
```

3. Test documentation locally:

```bash
mkdocs serve
```

### Documentation Style

* Use clear, concise language
* Include code examples
* Provide step-by-step instructions
* Add diagrams when helpful

## [Review Process](#review-process)

1. Code Review Requirements:
   * Two approvals required
   * All CI checks must pass
   * Documentation updated
   * Test coverage maintained
2. Review Checklist:
   * Code follows style guide
   * Tests are comprehensive
   * Documentation is clear
   * Performance impact considered
   * Security implications reviewed

## [Release Process](#release-process)

1. Version Bump:

```bash
bumpversion patch  # or minor/major
```

2. Update CHANGELOG.md
3. Create release PR
4. After merge, create GitHub release

## [Getting Help](#getting-help)

* Join our Discord channel
* Check existing issues
* Tag maintainers in comments
* Attend community calls

## [Recognition](#recognition)

Contributors are recognized in:

* Release notes
* Community announcements

Thank you for contributing to Equilink!
