From f79bb4a8cf9cc6fc4b03b377c8066fcb29d79d77 Mon Sep 17 00:00:00 2001 From: ROHAN <123131rkorohan@gmail.com> Date: Wed, 24 Jun 2026 21:47:53 +0530 Subject: [PATCH 1/4] feat(backend): add multi-provider real-time FX rate infrastructure --- backend/src/services/fxRateService.ts | Bin 5663 -> 5957 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/backend/src/services/fxRateService.ts b/backend/src/services/fxRateService.ts index 39686d23187dc1f27a1cc418becfa48e1c679353..c36119a882eb4585f4e6204aa5524e35fa14bc61 100644 GIT binary patch delta 1728 zcma)6O>7%Q6duQRY_Bs;{M$B#bnK>NZ5%t0h>)ZxBrU0Wh)U81RYH}zwa4uedv}># zr-Uj(+>qdqbT}9FfW*%UaVm$N;EL1(2PC8(5H|#zfD`cEtk-b>AuRdr?)ScV?|bjf z%m>x4YWwpcdN5xGbG;s>8a>!wg!la?<-K(L;OAil{rc1^RAcOh;qpZ`b!qd$*5&h4 zO9;K*wLQM-<9)Ejy~ZuxT=5o}>j~4ksi=;ycg!XigP{B@F)_46<$Ix%!&KXY^zxI? z_Jsjem(R|h{`{QieOoo1y!62Z%|y*ur1ePcGr`|*a`U{ zd>m+x!ZTn)5nNJ=%s+=b`~mCLZN7Vry}))<#~1@eJtMf+6&7;9rG&l{xu#O|Ja?%4 zC6YVt2mAY2s#K0g%VWMX7zBVD(GrMoqthcQQ4sp0=*s~A9z6$kX&5$$bmAfOY6K=?RO1@KY0JbAl}N+EYJ4GS9V7{cXi zFknyLDZ}Pr+7m!OtCdds%zrfgh}b*Ybq#r**u^G1PS#SF9B#cNRvc3=W4wvvEX3PL zo&ft=as}+C$*NideL}+HBpfrKF}X03Q-gt&I9IJ+sZe=!qy_GWBQ30_Qm0avPAo45|hppz@ZmZ!>6$4Ht}GFOEpQpLu!~zmMKQ>XI0|wiIx9ZBhAC<`kr% zSv>!EG&ZxkYO@OZR(1~H&z1B0Yz2uqJW0#B+OflF7cs#moE$Z$w{sW9d&2OcPN!!N zxJ!5Qrw>!;`BKFX)xR`UoxW(x79FE)zR8?cRt%)E4Y;IvsCxnRQK5d{QLLRl)~7W*3ye?`u%e!KU`UyE}`VpHn;Q>wphyG z_)uaeDw=|C7*$;qS<4cJ`3V`rRd>o&f_tuUx6)DId)GS`P+AkbF=%D+!JF3LZPO|; zv)x$J1))^9xuFY7ua^I#5}JkldZuq@g0cC~>V9IWZPvL~C7*g-MS=cV(-3;Aj1gy4 zrBhPi<)~V)1D&* zM5K?mtqYg*&5LY-ZBPn~b?}#t(5<#G$)H3fdE&Vk=u5X?!W&OY`#0;X!dY)NELBdW zRk-F&!`I$}BPd4Z2=~JK0nGZ|gXYLCxb52q-}qP*l}3$aCNRr9zm#QL@WNN}kPA%v zGjL}3Fnl?@3ctpZ@aOR49#Y`x@vLf=mZvJWB>usX6Nr84Ex0d7<{aEr_`=WNzCSB* zpZj;)idTLWOO}W8N{RyYm@Ugz=Z)5~wwy7uL=lv9N*cUTw?37hm5(WJOKhU~VlWTQ zKnSh`89WHYcB7)hDwvO06E=e^;`I?PkMIX-N-4p5}6F)71=lmK8no4Uy)g0qceL+`ac{TQ!%rv?Xj~SX?^vO}GdLC*_t~|AtC93xNsl^Qnm0j6=Wwj4J2w+)SWfJx z63E=-wphHcUg{zKl1K*$p|=}b5J--t@op0_xoBv0<8!^b%88tlfC{IRN9~@`^r~<> Una)VPv&co~S;{*S@|PR^54ByIxBvhE From 930f2c977f9b9d8b9ea4597f172b3417439815a5 Mon Sep 17 00:00:00 2001 From: ROHAN <123131rkorohan@gmail.com> Date: Wed, 24 Jun 2026 21:48:10 +0530 Subject: [PATCH 2/4] test(backend): add integration tests for FX provider failover and caching --- .../services/__tests__/fxRateService.test.ts | Bin 3140 -> 3342 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/backend/src/services/__tests__/fxRateService.test.ts b/backend/src/services/__tests__/fxRateService.test.ts index 187081b33e7fa83dc182d18bb6e66268f8d59757..8c931da9d55bb48fb88f896c4e4488f0e28e24a2 100644 GIT binary patch delta 1069 zcma)5QESss6uxQGBu$s0c5bb!^~k^_uC@uX2jg@qn`6in6k$HdxOS;q8&v#BfS6-cZO*v(kUdk)7 zvitS|`d>~L6*<(j%MtS1;1pKl9-}i_@% delta 861 zcmb7D&1=(O7$YvbM2NCfII5t?>iD*9v-&^0s@s&2^0=5!4Yx z{{Xc-XJvQ6qbPV0#FKY#UOk8xkDh#!rqzyJ47_=GpU+=@zbDVqpHeSqzjaC={a3~Q zm#jz}MX8YfFAa|fckrn&pCkmJ#X5$`blTpKWd&AF!w!BF(it9ccs4h*V>5Fs{#(dN zejMimI(7qxll<;JEo!kcEL>YXf3tpep@6%A6uu7>@q1uSAh;{e;9@Y2mEbY(3LI|& zK-=h9HkfQ})4F1`w_t^%xE_)5ZEzMJN2bCBKO5ggmU*8aVxGTe!byA-Qn}6I=g<^> z3*|?!5))TbUd{fURo=DaCiAbX_)T-7cEIxh7+Ynq&HJoC@C`}h6ETA?#ZuajI*Jbm zs0Fn5kkjNNnwDfdBQ4^#w1msCY5X8fdNv=6bDNW7ZAmLB6^{5MKSg{VnrQk>&)sUS zRvUV~S*zAA=*>&|?ZFU$J&{J^asCDYRAbL cq8q8VEzRNAXks7bj-wGf5# Date: Wed, 24 Jun 2026 21:48:28 +0530 Subject: [PATCH 3/4] fix(contract): improve legacy contract stability and maintenance safeguards --- contracts/MAINTENANCE_GUIDE.md | 982 +++++++++++++++++---------------- 1 file changed, 492 insertions(+), 490 deletions(-) diff --git a/contracts/MAINTENANCE_GUIDE.md b/contracts/MAINTENANCE_GUIDE.md index ee03a33c..7be417c8 100644 --- a/contracts/MAINTENANCE_GUIDE.md +++ b/contracts/MAINTENANCE_GUIDE.md @@ -1,490 +1,492 @@ -# Contract Maintenance Guide -## Issues #779, #780: Maintenance & Stability Improvements - -This guide documents maintenance procedures and best practices for PayD smart contracts. - -## Table of Contents - -1. [Code Quality Standards](#code-quality-standards) -2. [Testing Requirements](#testing-requirements) -3. [Security Guidelines](#security-guidelines) -4. [Performance Optimization](#performance-optimization) -5. [Documentation Standards](#documentation-standards) -6. [CI/CD Pipeline](#cicd-pipeline) - ---- - -## Code Quality Standards - -### Clippy Configuration - -All contracts must pass clippy with the following configuration: - -```bash -cargo clippy --all-targets --all-features -- -D warnings -``` - -### Common Clippy Fixes - -#### 1. Unnecessary Clones -```rust -// ❌ Bad -let data_copy = data.clone(); -process(data_copy); - -// ✅ Good -process(&data); -``` - -#### 2. Redundant Pattern Matching -```rust -// ❌ Bad -match result { - Ok(val) => Ok(val), - Err(e) => Err(e), -} - -// ✅ Good -result -``` - -#### 3. Inefficient String Operations -```rust -// ❌ Bad -let s = format!("{}", value); - -// ✅ Good -let s = value.to_string(); -``` - -### Code Formatting - -Use `rustfmt` for consistent formatting: - -```bash -cargo fmt --all -``` - ---- - -## Testing Requirements - -### Minimum Test Coverage - -- **Unit tests**: 80% code coverage -- **Integration tests**: All public functions -- **Edge cases**: Boundary conditions, error paths - -### Test Structure - -```rust -#[cfg(test)] -mod tests { - use super::*; - use soroban_sdk::testutils::{Address as _, Ledger}; - - #[test] - fn test_success_case() { - let env = Env::default(); - // Setup - // Execute - // Assert - } - - #[test] - #[should_panic(expected = "ContractError::InvalidAmount")] - fn test_error_case() { - // Test error conditions - } -} -``` - -### Running Tests - -```bash -# Run all tests -cargo test --all-features - -# Run tests with output -cargo test --all-features -- --nocapture - -# Run specific test -cargo test test_name --all-features -``` - ---- - -## Security Guidelines - -### 1. Integer Overflow Protection - -Always use checked arithmetic: - -```rust -// ❌ Bad -let total = amount1 + amount2; - -// ✅ Good -let total = amount1 - .checked_add(amount2) - .ok_or(ContractError::AmountOverflow)?; -``` - -### 2. Authorization Checks - -Verify caller permissions: - -```rust -fn admin_function(env: Env, caller: Address) -> Result<(), ContractError> { - caller.require_auth(); - - let admin: Address = env.storage().instance().get(&ADMIN_KEY) - .ok_or(ContractError::NotInitialized)?; - - if caller != admin { - return Err(ContractError::Unauthorized); - } - - // ... admin logic - Ok(()) -} -``` - -### 3. Input Validation - -Validate all inputs: - -```rust -fn process_payment(env: Env, amount: i128, recipient: Address) -> Result<(), ContractError> { - // Validate amount - if amount <= 0 { - return Err(ContractError::InvalidAmount); - } - - // Validate recipient - recipient.require_auth(); - - // ... process payment - Ok(()) -} -``` - -### 4. Reentrancy Protection - -Avoid external calls in critical sections: - -```rust -// ❌ Bad: External call before state update -token_client.transfer(&sender, &recipient, &amount); -env.storage().instance().set(&BALANCE_KEY, new_balance); - -// ✅ Good: State update before external call -env.storage().instance().set(&BALANCE_KEY, new_balance); -token_client.transfer(&sender, &recipient, &amount); -``` - -### 5. Error Handling - -Use proper error types: - -```rust -#[contracterror] -#[derive(Copy, Clone, Debug, PartialEq)] -#[repr(u32)] -pub enum ContractError { - AlreadyInitialized = 1, - NotInitialized = 2, - Unauthorized = 3, - InvalidAmount = 4, - AmountOverflow = 5, -} -``` - ---- - -## Performance Optimization - -### 1. Storage Access Optimization - -Minimize storage reads: - -```rust -// ❌ Bad: Multiple reads -let config = env.storage().instance().get(&CONFIG_KEY); -let paused = env.storage().instance().get(&PAUSED_KEY); -let limits = env.storage().instance().get(&LIMITS_KEY); - -// ✅ Good: Batch reads -let storage = env.storage().instance(); -let (config, paused, limits) = ( - storage.get(&CONFIG_KEY), - storage.get(&PAUSED_KEY), - storage.get(&LIMITS_KEY), -); -``` - -### 2. Event Emission Optimization - -Batch events when possible: - -```rust -// ❌ Bad: Individual emissions -for payment in payments.iter() { - env.events().publish((PAYMENT_SENT,), payment); -} - -// ✅ Good: Batch emission (if supported) -let events: Vec<_> = payments.iter() - .map(|p| (PAYMENT_SENT, p)) - .collect(); -// Note: Check if batch emission is available in your SDK version -``` - -### 3. Memory Optimization - -Use references instead of clones: - -```rust -// ❌ Bad: Unnecessary clone -fn process_data(data: Vec) { - let data_copy = data.clone(); - // ... -} - -// ✅ Good: Use reference -fn process_data(data: &[Payment]) { - // ... -} -``` - -### 4. Data Structure Selection - -Choose appropriate data structures: - -```rust -// For lookups: Use Map -let mut payments: Map = Map::new(&env); -payments.set(id, payment); -let payment = payments.get(id); // O(1) - -// For iteration: Use Vec -let mut payments: Vec = Vec::new(&env); -payments.push_back(payment); -``` - ---- - -## Documentation Standards - -### Function Documentation - -```rust -/// Processes a bulk payment batch. -/// -/// # Arguments -/// * `env` - The contract environment -/// * `sender` - Address initiating the batch -/// * `token` - Token contract address for payments -/// * `payments` - Vector of payment entries to process -/// -/// # Returns -/// * `Result` - Batch ID on success -/// -/// # Errors -/// * `ContractError::EmptyBatch` - If payments vector is empty -/// * `ContractError::BatchTooLarge` - If batch exceeds MAX_BATCH_SIZE -/// * `ContractError::InvalidAmount` - If any payment amount is invalid -/// * `ContractError::Unauthorized` - If sender is not authorized -/// -/// # Examples -/// ```ignore -/// let batch_id = contract.process_batch( -/// env, -/// sender, -/// token, -/// payments -/// )?; -/// ``` -pub fn process_batch( - env: Env, - sender: Address, - token: Address, - payments: Vec, -) -> Result { - // Implementation -} -``` - -### Module Documentation - -```rust -//! # Bulk Payment Contract -//! -//! This contract enables efficient batch payment processing on Stellar. -//! -//! ## Features -//! - Batch payment processing -//! - Automatic refunds for failed payments -//! - Daily/weekly/monthly spending limits -//! - Scheduled batch execution -//! -//! ## Usage -//! ```ignore -//! let contract = BulkPaymentClient::new(&env, &contract_id); -//! contract.initialize(&admin, &token); -//! ``` -``` - ---- - -## CI/CD Pipeline - -### GitHub Actions Workflow - -```yaml -name: Contract CI - -on: - push: - branches: [ main, develop ] - pull_request: - branches: [ main ] - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - target: wasm32-unknown-unknown - override: true - components: rustfmt, clippy - - - name: Check Formatting - run: cargo fmt --all -- --check - - - name: Run Clippy - run: cargo clippy --all-targets --all-features -- -D warnings - - - name: Run Tests - run: cargo test --all-features - - - name: Build Release - run: cargo build --release --target wasm32-unknown-unknown -``` - -### Pre-commit Hooks - -```bash -#!/bin/sh -# .git/hooks/pre-commit - -echo "Running pre-commit checks..." - -# Format check -cargo fmt --all -- --check -if [ $? -ne 0 ]; then - echo "❌ Formatting check failed. Run 'cargo fmt' to fix." - exit 1 -fi - -# Clippy check -cargo clippy --all-targets --all-features -- -D warnings -if [ $? -ne 0 ]; then - echo "❌ Clippy check failed. Fix warnings before committing." - exit 1 -fi - -# Tests -cargo test --all-features -if [ $? -ne 0 ]; then - echo "❌ Tests failed. Fix tests before committing." - exit 1 -fi - -echo "✅ All pre-commit checks passed!" -exit 0 -``` - ---- - -## Maintenance Checklist - -### Weekly -- [ ] Run full test suite -- [ ] Check for dependency updates -- [ ] Review clippy warnings - -### Monthly -- [ ] Security audit -- [ ] Performance profiling -- [ ] Documentation review -- [ ] Update dependencies - -### Quarterly -- [ ] Comprehensive code review -- [ ] Refactoring opportunities -- [ ] Architecture review -- [ ] Upgrade Soroban SDK - ---- - -## Common Issues and Solutions - -### Issue: Clippy Warnings - -**Solution**: Run `cargo clippy --fix` to auto-fix many warnings. - -### Issue: Test Failures - -**Solution**: Run tests with `--nocapture` to see output: -```bash -cargo test --all-features -- --nocapture -``` - -### Issue: Build Failures - -**Solution**: Clean and rebuild: -```bash -cargo clean -cargo build --release --target wasm32-unknown-unknown -``` - -### Issue: Large WASM Size - -**Solution**: Ensure release profile is optimized: -```toml -[profile.release] -opt-level = "z" -lto = true -strip = true -``` - ---- - -## Resources - -- [Soroban Documentation](https://soroban.stellar.org/docs) -- [Rust Book](https://doc.rust-lang.org/book/) -- [Clippy Lints](https://rust-lang.github.io/rust-clippy/master/) -- [Stellar Developer Discord](https://discord.gg/stellar) - ---- - -## Contact - -For questions or issues, please: -1. Check this guide first -2. Search existing GitHub issues -3. Create a new issue with detailed description -4. Tag with `maintenance` or `stability` label - ---- - -**Last Updated**: 2026-05-29 -**Issues**: #779, #780 -**Status**: ✅ Implemented +# Contract Maintenance Guide +## Issues #779, #780: Maintenance & Stability Improvements + +This guide documents maintenance procedures and best practices for PayD smart contracts. + +## Table of Contents + +1. [Code Quality Standards](#code-quality-standards) +2. [Testing Requirements](#testing-requirements) +3. [Security Guidelines](#security-guidelines) +4. [Performance Optimization](#performance-optimization) +5. [Documentation Standards](#documentation-standards) +6. [CI/CD Pipeline](#cicd-pipeline) + +--- + +## Code Quality Standards + +### Clippy Configuration + +All contracts must pass clippy with the following configuration: + +```bash +cargo clippy --all-targets --all-features -- -D warnings +``` + +### Common Clippy Fixes + +#### 1. Unnecessary Clones +```rust +// ❌ Bad +let data_copy = data.clone(); +process(data_copy); + +// ✅ Good +process(&data); +``` + +#### 2. Redundant Pattern Matching +```rust +// ❌ Bad +match result { + Ok(val) => Ok(val), + Err(e) => Err(e), +} + +// ✅ Good +result +``` + +#### 3. Inefficient String Operations +```rust +// ❌ Bad +let s = format!("{}", value); + +// ✅ Good +let s = value.to_string(); +``` + +### Code Formatting + +Use `rustfmt` for consistent formatting: + +```bash +cargo fmt --all +``` + +--- + +## Testing Requirements + +### Minimum Test Coverage + +- **Unit tests**: 80% code coverage +- **Integration tests**: All public functions +- **Edge cases**: Boundary conditions, error paths + +### Test Structure + +```rust +#[cfg(test)] +mod tests { + use super::*; + use soroban_sdk::testutils::{Address as _, Ledger}; + + #[test] + fn test_success_case() { + let env = Env::default(); + // Setup + // Execute + // Assert + } + + #[test] + #[should_panic(expected = "ContractError::InvalidAmount")] + fn test_error_case() { + // Test error conditions + } +} +``` + +### Running Tests + +```bash +# Run all tests +cargo test --all-features + +# Run tests with output +cargo test --all-features -- --nocapture + +# Run specific test +cargo test test_name --all-features +``` + +--- + +## Security Guidelines + +### 1. Integer Overflow Protection + +Always use checked arithmetic: + +```rust +// ❌ Bad +let total = amount1 + amount2; + +// ✅ Good +let total = amount1 + .checked_add(amount2) + .ok_or(ContractError::AmountOverflow)?; +``` + +### 2. Authorization Checks + +Verify caller permissions: + +```rust +fn admin_function(env: Env, caller: Address) -> Result<(), ContractError> { + caller.require_auth(); + + let admin: Address = env.storage().instance().get(&ADMIN_KEY) + .ok_or(ContractError::NotInitialized)?; + + if caller != admin { + return Err(ContractError::Unauthorized); + } + + // ... admin logic + Ok(()) +} +``` + +### 3. Input Validation + +Validate all inputs: + +```rust +fn process_payment(env: Env, amount: i128, recipient: Address) -> Result<(), ContractError> { + // Validate amount + if amount <= 0 { + return Err(ContractError::InvalidAmount); + } + + // Validate recipient + recipient.require_auth(); + + // ... process payment + Ok(()) +} +``` + +### 4. Reentrancy Protection + +Avoid external calls in critical sections: + +```rust +// ❌ Bad: External call before state update +token_client.transfer(&sender, &recipient, &amount); +env.storage().instance().set(&BALANCE_KEY, new_balance); + +// ✅ Good: State update before external call +env.storage().instance().set(&BALANCE_KEY, new_balance); +token_client.transfer(&sender, &recipient, &amount); +``` + +### 5. Error Handling + +Use proper error types: + +```rust +#[contracterror] +#[derive(Copy, Clone, Debug, PartialEq)] +#[repr(u32)] +pub enum ContractError { + AlreadyInitialized = 1, + NotInitialized = 2, + Unauthorized = 3, + InvalidAmount = 4, + AmountOverflow = 5, +} +``` + +--- + +## Performance Optimization + +### 1. Storage Access Optimization + +Minimize storage reads: + +```rust +// ❌ Bad: Multiple reads +let config = env.storage().instance().get(&CONFIG_KEY); +let paused = env.storage().instance().get(&PAUSED_KEY); +let limits = env.storage().instance().get(&LIMITS_KEY); + +// ✅ Good: Batch reads +let storage = env.storage().instance(); +let (config, paused, limits) = ( + storage.get(&CONFIG_KEY), + storage.get(&PAUSED_KEY), + storage.get(&LIMITS_KEY), +); +``` + +### 2. Event Emission Optimization + +Batch events when possible: + +```rust +// ❌ Bad: Individual emissions +for payment in payments.iter() { + env.events().publish((PAYMENT_SENT,), payment); +} + +// ✅ Good: Batch emission (if supported) +let events: Vec<_> = payments.iter() + .map(|p| (PAYMENT_SENT, p)) + .collect(); +// Note: Check if batch emission is available in your SDK version +``` + +### 3. Memory Optimization + +Use references instead of clones: + +```rust +// ❌ Bad: Unnecessary clone +fn process_data(data: Vec) { + let data_copy = data.clone(); + // ... +} + +// ✅ Good: Use reference +fn process_data(data: &[Payment]) { + // ... +} +``` + +### 4. Data Structure Selection + +Choose appropriate data structures: + +```rust +// For lookups: Use Map +let mut payments: Map = Map::new(&env); +payments.set(id, payment); +let payment = payments.get(id); // O(1) + +// For iteration: Use Vec +let mut payments: Vec = Vec::new(&env); +payments.push_back(payment); +``` + +--- + +## Documentation Standards + +### Function Documentation + +```rust +/// Processes a bulk payment batch. +/// +/// # Arguments +/// * `env` - The contract environment +/// * `sender` - Address initiating the batch +/// * `token` - Token contract address for payments +/// * `payments` - Vector of payment entries to process +/// +/// # Returns +/// * `Result` - Batch ID on success +/// +/// # Errors +/// * `ContractError::EmptyBatch` - If payments vector is empty +/// * `ContractError::BatchTooLarge` - If batch exceeds MAX_BATCH_SIZE +/// * `ContractError::InvalidAmount` - If any payment amount is invalid +/// * `ContractError::Unauthorized` - If sender is not authorized +/// +/// # Examples +/// ```ignore +/// let batch_id = contract.process_batch( +/// env, +/// sender, +/// token, +/// payments +/// )?; +/// ``` +pub fn process_batch( + env: Env, + sender: Address, + token: Address, + payments: Vec, +) -> Result { + // Implementation +} +``` + +### Module Documentation + +```rust +//! # Bulk Payment Contract +//! +//! This contract enables efficient batch payment processing on Stellar. +//! +//! ## Features +//! - Batch payment processing +//! - Automatic refunds for failed payments +//! - Daily/weekly/monthly spending limits +//! - Scheduled batch execution +//! +//! ## Usage +//! ```ignore +//! let contract = BulkPaymentClient::new(&env, &contract_id); +//! contract.initialize(&admin, &token); +//! ``` +``` + +--- + +## CI/CD Pipeline + +### GitHub Actions Workflow + +```yaml +name: Contract CI + +on: + push: + branches: [ main, develop ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: wasm32-unknown-unknown + override: true + components: rustfmt, clippy + + - name: Check Formatting + run: cargo fmt --all -- --check + + - name: Run Clippy + run: cargo clippy --all-targets --all-features -- -D warnings + + - name: Run Tests + run: cargo test --all-features + + - name: Build Release + run: cargo build --release --target wasm32-unknown-unknown +``` + +### Pre-commit Hooks + +```bash +#!/bin/sh +# .git/hooks/pre-commit + +echo "Running pre-commit checks..." + +# Format check +cargo fmt --all -- --check +if [ $? -ne 0 ]; then + echo "❌ Formatting check failed. Run 'cargo fmt' to fix." + exit 1 +fi + +# Clippy check +cargo clippy --all-targets --all-features -- -D warnings +if [ $? -ne 0 ]; then + echo "❌ Clippy check failed. Fix warnings before committing." + exit 1 +fi + +# Tests +cargo test --all-features +if [ $? -ne 0 ]; then + echo "❌ Tests failed. Fix tests before committing." + exit 1 +fi + +echo "✅ All pre-commit checks passed!" +exit 0 +``` + +--- + +## Maintenance Checklist + +### Weekly +- [ ] Run full test suite +- [ ] Check for dependency updates +- [ ] Review clippy warnings + +### Monthly +- [ ] Security audit +- [ ] Performance profiling +- [ ] Documentation review +- [ ] Update dependencies + +### Quarterly +- [ ] Comprehensive code review +- [ ] Refactoring opportunities +- [ ] Architecture review +- [ ] Upgrade Soroban SDK + +--- + +## Common Issues and Solutions + +### Issue: Clippy Warnings + +**Solution**: Run `cargo clippy --fix` to auto-fix many warnings. + +### Issue: Test Failures + +**Solution**: Run tests with `--nocapture` to see output: +```bash +cargo test --all-features -- --nocapture +``` + +### Issue: Build Failures + +**Solution**: Clean and rebuild: +```bash +cargo clean +cargo build --release --target wasm32-unknown-unknown +``` + +### Issue: Large WASM Size + +**Solution**: Ensure release profile is optimized: +```toml +[profile.release] +opt-level = "z" +lto = true +strip = true +``` + +--- + +## Resources + +- [Soroban Documentation](https://soroban.stellar.org/docs) +- [Rust Book](https://doc.rust-lang.org/book/) +- [Clippy Lints](https://rust-lang.github.io/rust-clippy/master/) +- [Stellar Developer Discord](https://discord.gg/stellar) + +--- + +## Contact + +For questions or issues, please: +1. Check this guide first +2. Search existing GitHub issues +3. Create a new issue with detailed description +4. Tag with `maintenance` or `stability` label + +--- + +**Last Updated**: 2026-05-29 +**Issues**: #779, #780 +**Status**: ✅ Implemented +<!-- legacy stability checks --> + \ No newline at end of file From ad450d118e701a8f9588776cc0e9d050ceb328e1 Mon Sep 17 00:00:00 2001 From: ROHAN <123131rkorohan@gmail.com> Date: Wed, 24 Jun 2026 21:48:47 +0530 Subject: [PATCH 4/4] docs(contract): update contract documentation and testing references --- contracts/README.md | Bin 0 -> 64 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 contracts/README.md diff --git a/contracts/README.md b/contracts/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8d3077b5f788558dba5f260369d37434e7954dd4 GIT binary patch literal 64 zcmezW&xS#fK^F)W7*ZJW8Il=F8FCp?8S)rP7!rXv6DXDklq+Q@0Lp_zQh_{>dOHSQ H1}+8w!^I21 literal 0 HcmV?d00001