tbtc-v2
tbtc-v2 copied to clipboard
feat(sdk): Add gasless deposit type exports and comprehensive test coverage
Summary
Implements SDK type exports and test infrastructure for gasless tBTC deposits feature, where relayer backend pays all gas fees for deposit reveals.
This PR establishes the foundation for gasless deposits by adding type exports, comprehensive test coverage, and documentation.
Changes
Type System
- Export GaslessDepositResult interface for deposit initialization results
- Export GaslessRevealPayload interface for backend relay submission
- Add type export validation tests to prevent regressions
Test Coverage
- Comprehensive unit tests for initiateGaslessDeposit (L1 and L2 paths)
- Comprehensive unit tests for buildGaslessRelayPayload (owner encoding)
- Error handling tests for unsupported chains and uninitialized contracts
- Validation tests for Bitcoin recovery address formats (P2PKH, P2WPKH)
- Chain-specific owner encoding tests (bytes32 for L1, address for L2)
Documentation
- JSDoc documentation for gasless deposit helper methods
- Document depositKey computation happens on backend (Bitcoin hash256)
- Document chain-specific owner encoding requirements
Code Quality
- Remove unused test variables
- Fix all linting errors (6 to 0)
- All 683 tests passing with zero regressions
Technical Details
Owner Encoding:
- L1 deposits: bytes32 format (left-padded address)
- L2 deposits: address format (20 bytes extracted from extraData)
Bitcoin Algorithm:
- depositKey computation uses Bitcoin hash256 (double-SHA256)
- Backend responsibility, SDK provides raw transaction data
Files Changed
- typescript/src/services/deposits/deposits-service.ts - JSDoc documentation
- typescript/test/services/deposits.test.ts - Comprehensive test suite
- typescript/test/exports/gasless-types.test.ts - Type export validation
- typescript/api-reference/ - Generated documentation
Checklist
- [x] Code follows project conventions
- [x] All tests passing
- [x] Linting passes (no warnings)
- [x] Code formatted (yarn format:fix)
- [x] Build succeeds (yarn build)
- [x] Documentation regenerated (yarn docs)
- [x] No breaking changes