Skip to main content

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

Version 7 introduces several breaking changes that require code updates. Review each section below carefully.

1. Transaction Creation API

The transaction creation API has been completely redesigned for better ergonomics and type safety. Before (v6):
After (v7):
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 generic call() function has been renamed to callRPC() with improved error handling. Before (v6):
After (v7):
The new callRPC() unwraps the result automatically and throws typed errors instead of returning error objects.

3. Transaction Broadcast Signature

The Transaction.broadcast() method signature has changed. Before (v6):
After (v7):
The 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):
After (v7):
This is a critical change. If you don’t update timeout values, your requests will timeout almost immediately!

5. Transaction Constructor Signature

The Transaction constructor signature has changed to accept an options object. Before (v6):
After (v7):

6. Removed Property: signedTransaction

The Transaction.signedTransaction property has been removed. Before (v6):
After (v7):

7. Configuration: Node URLs

The configuration has changed from a single node to multiple nodes for better failover support. Before (v6):
After (v7):
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

The config.healthcheckInterval option has been removed in v7. Before (v6):
After (v7):

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 all tx.create() calls with tx.addOperation():

Step 5: Update API Calls

Rename call() to callRPC() and update result handling:

Step 6: Update Broadcast Calls

Review and update broadcast() calls:

Step 7: Update Transaction Constructor

If you’re creating transactions from existing transaction objects:

Step 8: Remove healthcheckInterval

Remove any references to config.healthcheckInterval:

Step 9: Update signedTransaction References

Replace tx.signedTransaction with tx.transaction:

Step 10: Test Thoroughly

Run your test suite to ensure all changes work correctly:

Common Migration Pitfalls

Watch out for these common issues during migration:

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() to callRPC()
  • Updated all tx.create() to tx.addOperation()
  • Converted all timeout values from seconds to milliseconds
  • Changed config.node to config.nodes (array)
  • Updated Transaction.broadcast() signature
  • Updated new Transaction() constructor calls
  • Replaced tx.signedTransaction with tx.transaction
  • Removed config.healthcheckInterval references
  • 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:

Example: Complete Migration

Here’s a complete before/after example showing a typical v6 codebase migrated to v7:

Before (v6)

After (v7)

The v7 code is cleaner, more type-safe, and provides better error handling!