-
-
Notifications
You must be signed in to change notification settings - Fork 0
Contributing
Thank you for your interest in contributing to validator0x! This guide will help you get started with contributing to the project.
There are many ways you can contribute to validator0x:
- π Report bugs - Help us identify and fix issues
- π‘ Suggest features - Share ideas for new functionality
- π Improve documentation - Make our docs clearer and more helpful
- π§ Submit bug fixes - Fix issues you've encountered
- β¨ Add blockchain support - Implement validation for new chains
- π§ͺ Write tests - Improve test coverage
- π¨ Improve code quality - Refactor and optimize existing code
- π Translate documentation - Help make validator0x accessible globally
- Node.js 16+ and npm/yarn/pnpm
- Git
- TypeScript knowledge (for code contributions)
- Understanding of blockchain address formats (for validation logic)
Click the "Fork" button at the top of the validator0x repository to create your own copy.
git clone https://github.com/YOUR_USERNAME/validator0x.git
cd validator0xgit remote add upstream https://github.com/Samarth208P/validator0x.gitnpm installgit checkout -b feature/your-feature-name
# or
git checkout -b fix/bug-descriptionBranch Naming Convention:
-
feature/- New features -
fix/- Bug fixes -
docs/- Documentation updates -
test/- Test additions/modifications -
refactor/- Code refactoring
validator0x/
βββ src/
β βββ index.ts # Main exports
β βββ validators/ # Chain-specific validators
β βββ formatters/ # Address formatting utilities
β βββ types/ # TypeScript type definitions
β βββ utils/ # Helper functions
βββ tests/ # Test files
βββ docs/ # Documentation
βββ examples/ # Usage examples
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage# Build TypeScript
npm run build
# Build and watch for changes
npm run build:watch# Run linter
npm run lint
# Fix linting issues
npm run lint:fix
# Format code
npm run format- Use TypeScript for all new code
- Include proper type annotations
- Avoid
anytype unless absolutely necessary - Use interfaces for object shapes
- Export types for public APIs
Example:
interface ValidationOptions {
strict?: boolean;
network?: 'mainnet' | 'testnet';
}
export function validateAddress(
address: string,
blockchain: BlockchainType,
options?: ValidationOptions
): ValidationResult {
// Implementation
}- Write self-documenting code
- Keep functions small and focused
- Use meaningful variable names
- Add comments for complex logic only
- Follow DRY (Don't Repeat Yourself) principle
- Add JSDoc comments for public APIs
- Update README.md if adding new features
- Update wiki documentation when needed
- Include code examples in docs
Example:
/**
* Validates a blockchain wallet address.
*
* @param address - The wallet address string to validate
* @param blockchain - The blockchain type (ethereum, solana, bitcoin, polygon)
* @param options - Optional validation settings
* @returns ValidationResult object with validation details
*
* @example
* ```typescript
* const result = validateAddress('0x742d35Cc...', 'ethereum');
* console.log(result.valid); // true or false
* ```
*/- Write tests for all new features
- Aim for >90% code coverage
- Use descriptive test names
- Test both success and failure cases
- Include edge cases
Example:
describe('validateAddress', () => {
describe('Ethereum', () => {
it('should validate correct Ethereum address', () => {
const result = validateAddress(
'0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
'ethereum'
);
expect(result.valid).toBe(true);
});
it('should reject invalid Ethereum address', () => {
const result = validateAddress('invalid', 'ethereum');
expect(result.valid).toBe(false);
expect(result.error).toBeDefined();
});
it('should enforce checksum in strict mode', () => {
const result = validateAddress(
'0x742d35cc6634c0532925a3b844bc9e7595f0beb',
'ethereum',
{ strict: true }
);
expect(result.valid).toBe(false);
});
});
});-
Sync with upstream
git fetch upstream git rebase upstream/main
-
Run all checks
npm run lint npm test npm run build -
Commit your changes
git add . git commit -m "feat: add support for XYZ blockchain"
Commit Message Format:
-
feat:- New feature -
fix:- Bug fix -
docs:- Documentation changes -
test:- Test additions/changes -
refactor:- Code refactoring -
chore:- Build/tooling changes
-
-
Push to your fork
git push origin feature/your-feature-name
- Go to your fork on GitHub
- Click "New Pull Request"
- Select your branch
- Fill out the PR template:
- Clear description of changes
- Related issue number (if applicable)
- Screenshots (for UI changes)
- Testing steps
## Description
Brief description of what this PR does
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Related Issue
Fixes #(issue number)
## Testing
- [ ] Tests pass locally
- [ ] New tests added (if applicable)
- [ ] Manual testing completed
## Screenshots (if applicable)
Add screenshots here
## Checklist
- [ ] Code follows project style guidelines
- [ ] Self-review completed
- [ ] Comments added for complex code
- [ ] Documentation updated
- [ ] No new warnings generated- Maintainers will review your PR
- Address any requested changes
- Once approved, your PR will be merged
- Your contribution will be credited in the changelog
Want to add support for a new blockchain? Follow these steps:
- Understand the address structure
- Identify validation rules
- Check for checksum algorithms
- Find testnet formats
Create a new file in src/validators/:
// src/validators/yourchain.ts
export function validateYourChain(address: string): boolean {
// Validation logic
return true;
}Create test file in tests/:
// tests/yourchain.test.ts
describe('YourChain Validation', () => {
it('should validate valid addresses', () => {
// Test cases
});
});Add to BlockchainType in src/types/index.ts:
export type BlockchainType =
| 'ethereum'
| 'solana'
| 'bitcoin'
| 'polygon'
| 'yourchain'; // Add this- Update README.md supported chains list
- Add examples to wiki
- Update API documentation
- Check if the issue already exists
- Verify you're using the latest version
- Test with minimal code to isolate the issue
**Describe the bug**
Clear description of what the bug is
**To Reproduce**
Steps to reproduce the behavior:
1. Call function with '...'
2. See error
**Expected behavior**
What you expected to happen
**Actual behavior**
What actually happened
**Code sample**
\`\`\`typescript
// Your code here
\`\`\`
**Environment:**
- validator0x version: [e.g., 0.1.0]
- Node.js version: [e.g., 18.0.0]
- TypeScript version: [e.g., 5.0.0]
- OS: [e.g., Ubuntu 22.04]
**Additional context**
Any other relevant information**Is your feature request related to a problem?**
Description of the problem
**Describe the solution you'd like**
Clear description of what you want to happen
**Describe alternatives you've considered**
Other solutions you've thought about
**Use case**
Real-world scenario where this would be useful
**Additional context**
Screenshots, examples, or other contextWe are committed to providing a welcoming and inclusive environment for all contributors.
Positive behavior:
- Using welcoming and inclusive language
- Being respectful of differing viewpoints
- Gracefully accepting constructive criticism
- Focusing on what's best for the community
- Showing empathy towards other community members
Unacceptable behavior:
- Trolling, insulting/derogatory comments
- Public or private harassment
- Publishing others' private information
- Any conduct inappropriate in a professional setting
Violations of the code of conduct may result in:
- Warning
- Temporary ban
- Permanent ban
Report violations to: samarth208p@gmail.com
Contributors will be recognized in:
- README.md contributors section
- Release notes
- Project changelog
Top contributors may receive:
- Collaborator access
- Special mentions
- Swag (when available)
- π¬ GitHub Discussions
- π§ Email: samarth208p@gmail.com
- π¦ Twitter: @SamPy4X
By contributing to validator0x, you agree that your contributions will be licensed under the project's MIT License.
Thank you for contributing to validator0x! Your efforts help make Web3 development better for everyone. π