Overview
Version 7 of hive-tx is a complete TypeScript rewrite that brings significant improvements to the API design, type safety, and developer experience. While this means breaking changes, the migration path is straightforward and the benefits are substantial.What’s New in v7
Major Improvements:
- Complete TypeScript rewrite with comprehensive type definitions
- Enhanced JSDoc documentation for all methods
- Full typing for all Hive blockchain operations
- New
callWithQuorum()for cross-checking results across multiple nodes - New
callREST()with complete typing for REST APIs - Comprehensive test suite including operation validation
- Three build outputs: ESM, CJS, and browser-ready UMD
- Detailed guides: QUICKSTART.md and EXAMPLES.md
Library Size
The library remains lightweight at approximately 29KB minified+gzipped (including all dependencies).Breaking Changes
1. Transaction Creation API
The transaction creation API has been completely redesigned for better ergonomics and type safety. Before (v6):The new API provides better autocomplete and type checking. You can chain multiple
addOperation() calls or call it multiple times.2. API Call Method Renamed
The genericcall() function has been renamed to callRPC() with improved error handling.
Before (v6):
The new
callRPC() unwraps the result automatically and throws typed errors instead of returning error objects.3. Transaction Broadcast Signature
TheTransaction.broadcast() method signature has changed.
Before (v6):
checkStatus parameter is a boolean that determines whether to verify the transaction was included in a block.
4. Timeout Values Now in Milliseconds
All timeout and expiration values have been standardized to use milliseconds instead of seconds. Before (v6):5. Transaction Constructor Signature
TheTransaction constructor signature has changed to accept an options object.
Before (v6):
6. Removed Property: signedTransaction
TheTransaction.signedTransaction property has been removed.
Before (v6):
7. Configuration: Node URLs
The configuration has changed from a single node to multiple nodes for better failover support. Before (v6):v7 comes with a pre-configured list of reliable nodes. You only need to modify
config.nodes if you want to use custom nodes.8. Removed Configuration: healthcheckInterval
Theconfig.healthcheckInterval option has been removed in v7.
Before (v6):
New Features in v7
callWithQuorum()
Cross-check RPC results across multiple nodes to ensure data integrity.callREST()
Access Hive’s REST APIs with full TypeScript typing.Improved Type Definitions
All operations now have complete type definitions:Better Error Messages
Errors now include detailed information and stack traces:Step-by-Step Migration Guide
Follow these steps to migrate your codebase from v6 to v7:Step 1: Update Package Version
Step 2: Update Imports
The main imports remain the same, but verify you’re importing the correct functions:Step 3: Update Configuration
Convert your node configuration to use an array:Step 4: Update Transaction Creation
Replace alltx.create() calls with tx.addOperation():
Step 5: Update API Calls
Renamecall() to callRPC() and update result handling:
Step 6: Update Broadcast Calls
Review and updatebroadcast() calls:
Step 7: Update Transaction Constructor
If you’re creating transactions from existing transaction objects:Step 8: Remove healthcheckInterval
Remove any references toconfig.healthcheckInterval:
Step 9: Update signedTransaction References
Replacetx.signedTransaction with tx.transaction:
Step 10: Test Thoroughly
Run your test suite to ensure all changes work correctly:Common Migration Pitfalls
Pitfall 1: Forgetting to Convert Timeouts
Pitfall 2: Not Unwrapping callRPC Results
Pitfall 3: Using Old create() Syntax
Pitfall 4: Single Node String
Pitfall 5: Accessing signedTransaction
Migration Checklist
Use this checklist to ensure you’ve covered all migration steps:- Updated package to v7
- Changed
call()tocallRPC() - Updated all
tx.create()totx.addOperation() - Converted all timeout values from seconds to milliseconds
- Changed
config.nodetoconfig.nodes(array) - Updated
Transaction.broadcast()signature - Updated
new Transaction()constructor calls - Replaced
tx.signedTransactionwithtx.transaction - Removed
config.healthcheckIntervalreferences - Updated error handling for new RPCError type
- Ran test suite successfully
- Verified production functionality in staging environment
Need Help?
If you encounter issues during migration:- Join the #dev-chat channel at Hive’s Discord server
- Review the Quick Start Guide for v7 examples
- Check the Transfer Examples for common patterns
- Open an issue on GitHub