Contributing to tari.js ๐ค
Welcome, builder! We're thrilled you want to contribute to tari.js. Whether you're fixing bugs, adding features, improving docs, or sharing ideas โ every contribution makes the Tari ecosystem stronger.
We welcome contributions to tari.js! This guide will help you get started with contributing to the project, whether you're fixing bugs, adding features, improving documentation, or helping with testing.
๐ Ways to Contributeโ
๐ ๏ธ Code Contributionsโ
- ๐ Fix bugs โ Help resolve issues and improve stability
- โจ Add features โ Implement new functionality and enhancements
- ๐ง Optimize performance โ Make tari.js faster and more efficient
- ๐งช Write tests โ Improve code coverage and reliability
๐ Documentationโ
- ๐ Improve guides โ Make tutorials clearer and more helpful
- ๐ Add examples โ Show real-world usage patterns
- ๐ฅ Create tutorials โ Video guides and walkthroughs
- ๐ Translate content โ Help make tari.js globally accessible
๐ก Ideas & Feedbackโ
- ๐ญ Share use cases โ Tell us how you're using tari.js
- ๐ณ๏ธ Vote on features โ Help prioritize development
- ๐ฏ Request features โ Suggest improvements and new capabilities
- ๐ Report bugs โ Help us find and fix issues
๐ Quick Startโ
Prerequisitesโ
Before contributing, ensure you have:
- Node.js 18+ and pnpm installed
- Git for version control
- tari-ootle repository cloned at the same folder level as tari.js
- Basic knowledge of TypeScript, React, and blockchain concepts
Development Setupโ
-
Fork and Clone
# Fork the repository on GitHub, then:
git clone https://github.com/YOUR-USERNAME/tari.js.git
cd tari.js
# Add upstream remote
git remote add upstream https://github.com/tari-project/tari.js.git -
Install Dependencies
pnpm install
-
Build the Project
moon tarijs:build
-
Run Tests
moon :test
-
Start Documentation Site
moon tari-docs:start
๐ Development Workflowโ
Branch Strategyโ
We use a feature branch workflow:
main
- Production-ready codedevelop
- Integration branch for featuresfeature/feature-name
- Individual featuresbugfix/bug-description
- Bug fixesdocs/documentation-updates
- Documentation changes
Creating a Feature Branchโ
# Update your fork
git checkout main
git pull upstream main
# Create feature branch
git checkout -b feature/your-feature-name
# Make your changes...
git add .
git commit -m "feat: add new wallet integration"
# Push to your fork
git push origin feature/your-feature-name
Commit Message Formatโ
We follow the Conventional Commits specification:
type(scope): brief description
[optional body]
[optional footer]
Types:
feat
: New featurefix
: Bug fixdocs
: Documentation changesstyle
: Code style changes (formatting, etc.)refactor
: Code refactoringtest
: Adding or updating testschore
: Maintenance tasks
Examples:
feat(signer): add TariUniverse wallet integration
fix(provider): handle connection timeout properly
docs(api): update TransactionBuilder examples
test(integration): add end-to-end wallet tests
๐ ๏ธ Project Structureโ
Monorepo Organizationโ
tari.js/
โโโ packages/
โ โโโ tarijs/ # Main package (aggregates all functionality)
โ โโโ tari_provider/ # Base provider interface
โ โโโ tari_signer/ # Base signer interface
โ โโโ indexer_provider/ # Indexer provider implementation
โ โโโ wallet_daemon/ # Wallet daemon integration
โ โโโ metamask_signer/ # MetaMask integration
โ โโโ tari_universe/ # Tari Universe wallet integration
โ โโโ walletconnect/ # WalletConnect integration
โ โโโ builders/ # Transaction building utilities
โ โโโ tarijs_types/ # Shared TypeScript types
โ โโโ tari_permissions/ # Permission system
โโโ docusaurus/ # Documentation website
โโโ scripts/ # Build and utility scripts
โโโ .github/ # CI/CD workflows
Package Developmentโ
Each package follows a consistent structure:
packages/package-name/
โโโ src/
โ โโโ index.ts # Public API exports
โ โโโ types.ts # Package-specific types
โ โโโ [implementation files]
โโโ test/
โ โโโ unit-tests/ # Unit tests
โ โโโ integration-tests/ # Integration tests
โโโ package.json # Package configuration
โโโ tsconfig.json # TypeScript configuration
โโโ moon.yml # Moon task configuration
๐งช Testing Guidelinesโ
Test Typesโ
- Unit Tests - Test individual functions and classes
- Integration Tests - Test package interactions
- End-to-End Tests - Test complete user workflows
Writing Testsโ
We use Vitest for testing. Test files should be co-located with source files or in dedicated test directories.
// Example unit test
import { describe, it, expect, beforeEach } from 'vitest';
import { TransactionBuilder } from '../src/TransactionBuilder';
describe('TransactionBuilder', () => {
let builder: TransactionBuilder;
beforeEach(() => {
builder = new TransactionBuilder(Network.LocalNet);
});
it('should set fee correctly', () => {
const transaction = builder
.fee(100)
.build();
expect(transaction.feeInstructions).toContain(
expect.objectContaining({ amount: 100 })
);
});
it('should throw on invalid fee amount', () => {
expect(() => builder.fee(-1)).toThrow('Fee must be positive');
});
});
Integration Testsโ
// Example integration test
import { describe, it, expect } from 'vitest';
import { WalletDaemonTariSigner, IndexerProvider } from '../src';
describe('Wallet Integration', () => {
it('should connect to wallet daemon and submit transaction', async () => {
const signer = new WalletDaemonTariSigner({
endpoint: 'http://localhost:18103'
});
const provider = new IndexerProvider({
endpoint: 'http://localhost:18300'
});
// Test connection
expect(signer.isConnected()).toBe(true);
// Test account retrieval
const account = await signer.getAccount();
expect(account.address).toMatch(/^account_[a-f0-9]{64}$/);
// Test transaction submission
const transaction = new TransactionBuilder()
.fee(100)
.createAccount(account.public_key)
.build();
const result = await signer.submitTransaction({ transaction });
expect(result.transactionId).toBeDefined();
});
});
Running Testsโ
# Run all tests
moon :test
# Run tests for specific package
moon wallet-daemon:test
# Run tests in watch mode
moon wallet-daemon:test -- --watch
# Run integration tests only
moon :test -- --run integration
๐ Documentation Guidelinesโ
Types of Documentationโ
- API Documentation - Generated from TypeScript types and JSDoc
- User Guides - Step-by-step tutorials and explanations
- Developer Documentation - Architecture and contributing guides
- Code Comments - Inline documentation for complex logic
Writing Documentationโ
JSDoc Commentsโ
/**
* Submits a transaction to the Tari network
*
* @param request - Transaction request containing the transaction and options
* @param request.transaction - The transaction to submit
* @param request.is_dry_run - Whether to perform a dry run (default: false)
* @returns Promise resolving to transaction submission result
*
* @throws {ConnectionError} When the wallet is not connected
* @throws {ValidationError} When the transaction is invalid
*
* @example
* ```typescript
* const transaction = new TransactionBuilder()
* .fee(100)
* .callMethod(account, 'transfer', { amount: 1000, destination: 'account_...' })
* .build();
*
* const result = await signer.submitTransaction({ transaction });
* console.log('Transaction ID:', result.transactionId);
* ```
*/
async submitTransaction(request: SubmitTransactionRequest): Promise<SubmitTransactionResponse> {
// Implementation...
}
Markdown Documentationโ
Follow these guidelines for documentation:
- Clear headings with proper hierarchy
- Code examples for all API methods
- Prerequisites section for setup requirements
- Troubleshooting section for common issues
- Cross-references to related documentation
Documentation Developmentโ
# Start documentation development server
moon tari-docs:start
# Build documentation
moon tari-docs:build
# Deploy documentation (maintainers only)
moon tari-docs:deploy
๐ง Code Style and Standardsโ
TypeScript Standardsโ
- Strict TypeScript configuration enabled
- Explicit types for public APIs
- Interface segregation principle followed
- Consistent naming conventions
// Good: Explicit types and clear naming
interface WalletConnectionConfig {
endpoint: string;
timeout?: number;
retryAttempts?: number;
}
class WalletService {
async connect(config: WalletConnectionConfig): Promise<TariSigner> {
// Implementation with proper error handling
}
}
// Avoid: Any types and unclear naming
class Service {
async connect(config: any): Promise<any> {
// Implementation
}
}
Code Formattingโ
We use Prettier for code formatting:
# Format all files
pnpm run format
# Check formatting
pnpm run format:check
Lintingโ
We use ESLint for code quality:
# Lint all files
pnpm run lint
# Fix linting issues
pnpm run lint:fix
Import Organizationโ
// 1. Node.js built-ins
import { readFileSync } from 'fs';
// 2. External packages
import React from 'react';
import { describe, it, expect } from 'vitest';
// 3. Internal packages (monorepo)
import { TariSigner } from '@tari-project/tari-signer';
import { TransactionBuilder } from '@tari-project/builders';
// 4. Relative imports
import { validateAddress } from '../utils/validation';
import { ConnectionError } from './errors';
๐ Bug Reports and Feature Requestsโ
Reporting Bugsโ
When reporting bugs, include:
-
Environment Information
- OS and browser version
- Node.js and pnpm versions
- tari.js version
- Wallet type and version
-
Clear Description
- What you expected to happen
- What actually happened
- Steps to reproduce
-
Code Examples
- Minimal reproduction case
- Error messages and stack traces
-
Additional Context
- Screenshots or videos if applicable
- Related issues or discussions
Feature Requestsโ
For feature requests, provide:
- Problem Statement - What problem does this solve?
- Proposed Solution - How should it work?
- Alternatives - What other solutions have you considered?
- Use Cases - Specific scenarios where this would be useful
๐ Code Review Processโ
Submitting Pull Requestsโ
- Create Feature Branch from main
- Implement Changes with tests and documentation
- Run Quality Checks
pnpm run lint
pnpm run format:check
moon :test
moon :build - Create Pull Request with clear description
- Address Review Feedback promptly
Pull Request Templateโ
## Description
Brief description of changes and motivation.
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Unit tests pass
- [ ] Integration tests pass
- [ ] Manual testing completed
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] No breaking changes (or clearly documented)
Review Criteriaโ
Reviewers check for:
- Functionality - Does it work as intended?
- Code Quality - Is it maintainable and readable?
- Performance - Any performance implications?
- Security - Are there security considerations?
- Documentation - Is it properly documented?
- Tests - Are there adequate tests?
๐๏ธ Architecture Guidelinesโ
Design Principlesโ
- Interface Segregation - Small, focused interfaces
- Dependency Inversion - Depend on abstractions, not concretions
- Single Responsibility - Each class/function has one purpose
- Open/Closed - Open for extension, closed for modification
Adding New Wallet Integrationsโ
To add a new wallet type:
- Create Package in
packages/
directory - Implement TariSigner interface
- Add Configuration Types for wallet-specific options
- Write Unit Tests for all methods
- Add Integration Tests with actual wallet
- Update Main Package to export new signer
- Add Documentation with usage examples
// Example new signer implementation
export class NewWalletSigner implements TariSigner {
readonly signerName = 'NewWallet';
constructor(private config: NewWalletConfig) {
// Initialize wallet connection
}
isConnected(): boolean {
// Check connection status
}
async getAccount(): Promise<AccountData> {
// Implement account retrieval
}
async submitTransaction(request: SubmitTransactionRequest): Promise<SubmitTransactionResponse> {
// Implement transaction submission
}
// ... implement other TariSigner methods
}
๐ค Community Guidelinesโ
Communicationโ
- Be respectful and professional in all interactions
- Ask questions when you need clarification
- Provide context when reporting issues or requesting help
- Be patient with review processes and responses
Getting Helpโ
- GitHub Discussions - For questions and general discussion
- GitHub Issues - For bug reports and feature requests
- Discord - Real-time chat with the community
- Documentation - Check existing docs before asking
Recognitionโ
Contributors are recognized through:
- GitHub Contributors page
- Release Notes acknowledgments
- Community Highlights in project updates
๐ข Release Processโ
Versioningโ
We follow Semantic Versioning:
- MAJOR version for breaking changes
- MINOR version for new features
- PATCH version for bug fixes
Release Workflowโ
- Feature Freeze - No new features in release branch
- Testing Phase - Comprehensive testing of release candidate
- Documentation Update - Update all relevant documentation
- Release Notes - Document all changes and breaking changes
- Publication - Publish to npm registry
- Announcement - Notify community of new release
๐ Contact and Supportโ
Maintainersโ
- Core Team - GitHub: @tari-project/tari-js-maintainers
- Documentation - Contributions welcome via GitHub
Communityโ
- Discord - Tari Community Discord
- GitHub Discussions - tari.js Discussions
- Twitter - @tari
Reporting Security Issuesโ
For security-related issues, please email: security@tari.com
Do not report security issues through public GitHub issues.
๐ Ready to Contribute?โ
๐ Quick Start Checklistโ
- Set up development environment
- Browse good first issues
- Join our Discord community
- Read the project roadmap
- Make your first contribution!
๐ Join Our Community of Buildersโ
Thank you for contributing to tari.js! Your efforts help make the Tari ecosystem more accessible and robust for everyone. Together, we're building the future of decentralized applications with privacy at the core.
- ๐ Star the repo to show your support
- ๐ข Share tari.js with fellow developers
- ๐ฌ Connect with us on Discord and GitHub
- ๐ Build something amazing and share it with the community
Happy coding, and welcome to the Tari family! ๐