Thank you for your interest in contributing to the Mycelium SDK! This document provides guidelines and information for contributors
- Code of conduct
- Getting started
- Development workflow
- Code standards
- Testing guidelines
- Documentation
- Pull request process
- Issue reporting
- License
This project follows a code of conduct that we expect all contributors to adhere to:
- Be respectful and inclusive
- Focus on constructive feedback
- Help maintain a welcoming environment
- Respect different viewpoints and experiences
Before contributing, ensure you have:
- pnpm >= 10.9.0
- Node.js >= 22.11.0
- TypeScript >= 5.0.0
- Git with proper configuration
- Anvil >= 1.2.3 (for blockchain package development)
-
Fork the repository on GitHub
-
Clone your fork locally:
git clone https://github.com/your-username/mycelium-sdk.git cd mycelium-sdk -
Install dependencies:
pnpm install
-
Set up environment variables:
# Copy example files cp packages/frontend/.env.example packages/frontend/.env cp packages/blockchain/.env.example packages/blockchain/.env # Configure your environment variables
-
Verify setup:
pnpm run build pnpm run test
- Main branch:
main- production-ready code - Feature branches:
feature/description- new features - Bug fixes:
fix/description- bug fixes - Documentation:
docs/description- documentation updates
# Ensure you're on main and up to date
git checkout main
git pull origin main
# Create and switch to your feature branch
git checkout -b feature/your-feature-name
# Example naming conventions:
git checkout -b feature/add-spark-protocol
git checkout -b fix/wallet-balance-calculation
git checkout -b docs/api-reference-updateBuild all packages:
pnpm run buildRun development servers:
pnpm run devRun tests:
pnpm run testRun linting:
pnpm run lintFormat code:
pnpm run format:fixSpell check:
pnpm run spell- Use strict TypeScript configuration
- Prefer
typeimports:import type { ... } from '...' - Don't import with file extension
- Use aliases for imports
- Each new functionalities should be covered by unit tests
- Avoid
anytype - use proper typing orunknown - Use meaningful variable and function names
- Add JSDoc comments for public APIs (check examples in other classes)
Example:
import type { ChainManager } from '@/tools/ChainManager';
/**
* @internal
*
* Creates a new wallet instance
* @remarks
* The method to create a embedded wallet class using a provider...
* @param userId - Unique user identifier
* @param chainManager - Chain manager instance
* @returns Promise resolving to wallet instance
*/
export async function createWallet(userId: string, chainManager: ChainManager): Promise<Wallet> {
// Implementation
}- Use kebab-case for file names:
wallet-provider.ts - Use PascalCase for class names:
WalletProvider - Use camelCase for functions and variables:
createWallet - Group related functionality in appropriate directories
// Preferred: imports with an alias
import type { WalletConfig } from '@/types/wallet';
// Avoid: imports with absolute imports
export { WalletProvider } from './WalletProvider';
export type { WalletConfig } from './types';
// Avoid: default exports for classes
// Good
export class WalletProvider {}
// Avoid
export default class WalletProvider {}- Use descriptive error messages
- Include context in error objects
- Handle errors gracefully with proper fallbacks
try {
const result = await riskyOperation();
return result;
} catch (error) {
logger.error('Failed to execute operation', { error, context });
throw new Error(`Operation failed: ${error.message}`);
}- Write tests for all public APIs
- Include both unit and integration tests
- Use descriptive test names
- Follow AAA pattern: Arrange, Act, Assert
Example:
describe('WalletProvider', () => {
describe('createWallet', () => {
it('should create wallet with valid user ID', async () => {
// Arrange
const userId = 'test-user-123';
const mockChainManager = createMockChainManager();
// Act
const wallet = await walletProvider.createWallet(userId, mockChainManager);
// Assert
expect(wallet).toBeDefined();
expect(wallet.userId).toBe(userId);
});
});
});All tests:
pnpm run testWatch mode:
cd packages/sdk
pnpm run test:watchSpecific package tests:
cd packages/sdk
pnpm run test- Maintain high test coverage for critical functionality
- Focus on testing business logic and edge cases
- Mock external dependencies appropriately
- Add JSDoc comments for all public APIs
- Include parameter descriptions and return types
- Provide usage examples where helpful
- Use typedoc tags to generate a proper documentation:
@internalto include the class/method description to a dev documentation@publicto include the class/method description to a public documentation
/**
* Deposits into the selected protocol’s vault
*
* @internal
* @category Protocol
* @param amount Human-readable amount string
* @returns Transaction result for the deposit
*/
async earn(amount: string): Promise<VaultTxnResult> {
// Implementation
}- Update relevant README files when adding features
- Include setup instructions for new dependencies
- Document any breaking changes
Generate documentation:
cd packages/sdk
# Public doc
pnpm run docs:public
# Dev doc
pnpm run docs:public-
Ensure your code builds:
pnpm run build
-
Run all tests:
pnpm run test -
Check linting:
pnpm run lint
-
Format code:
pnpm run format:fix
-
Spell check:
pnpm run spell
- Clear title: Use descriptive titles that explain the change
- Detailed description: Explain what changed and why
- Link issues: Reference related issues using
Fixes #123orCloses #123 - Screenshots: Include screenshots for UI changes
- Breaking changes: Clearly mark any breaking changes
Example PR description:
## Description
Adds support for Spark protocol integration in the SDK
## Changes
- Implemented SparkProtocol class extending BaseProtocol
- Added Spark vault configuration constants
- Updated protocol router to include Spark protocol
- Added comprehensive tests for Spark protocol functionality
## Testing
- [x] All existing tests pass
- [x] New tests added for Spark protocol
- [x] Integration tests verify end-to-end functionality
## Breaking changes
None
Fixes #123- All PRs require at least one review
- Address review feedback promptly
- Keep PRs focused and reasonably sized
- Update documentation as needed
When reporting bugs, include:
- Clear description of the issue
- Steps to reproduce the problem
- Expected behavior vs actual behavior
- Environment details (OS, Node version, etc.)
- Code samples if applicable
- Screenshots for UI issues
For feature requests, provide:
- Clear description of the desired feature
- Use case and motivation
- Proposed implementation (if you have ideas)
- Alternatives considered
Use the provided issue templates when available to ensure all necessary information is included
By contributing to Mycelium SDK, you agree that your contributions will be licensed under the same dual license as the project:
- Apache License 2.0 (Non-Commercial) for non-commercial use
- Commercial License for commercial use
See LICENSE for full details
If you need help or have questions:
- GitHub Discussions: Use for general questions and discussions
- GitHub Issues: Use for bug reports and feature requests
- Documentation: Check the generated docs and README files
Contributors will be recognized in:
- Project README contributors section
- Release notes for significant contributions
- GitHub contributor statistics
Thank you for contributing to Mycelium SDK!