It has been a busy week for the Hive Stream library, after rolling out support for code-level contracts, the progress has not stopped. Taking on feedback from others, real-world use as well as refining the code by strengthening the number of tests the library has, a tonne of improvements have been made.
The above is a screenshot of the contents of an SQLite table storing a specific transfer action, showcasing a way to store a record of events taking place within your contracts and applications, important for preventing multiple transfers and processing of blocks.
Changes
- Add in support for storage adapters, shipping with a file adapter which replicates what the streamer currently does as well as an SQLite database adapter as well to leverage an SQLite local file database. This allows you to integrate your own adapters when events happen like loading state, saving state, parsing blocks and transactions. Allowing you to back your apps with support for writing to a database, Redis or wherever. The test file that ships with the package shows you how adapters are added here.
- Support for parsing JSON in transfer memo fields
- Ability to watch for custom JSON operations with specific ids using
onCustomJsonId - An example dice contract showcasing how you can write contracts interacting and responding to blockchain events like transfers and custom JSON
- Removed failover code in the streamer library which was falling back to alternative API nodes if one goes down as
dhivenow ships with failover support in the client itself. - Added in utility methods for confirming transactions and getting balances from the Hive API, exposed through the streamer instance.
- Ability to configure custom JSON property values in the configuration such as JSON ID and the payload property name using
JSON_IDandPAYLOAD_IDENTIFIERrespectively. - Covering a lot of the library in unit tests (both the streamer, utility aspects and the dice contract)
- Updating numerous dependencies and tooling artefacts
What's next
More contracts are on the way to showcase what you can do with the library, as well an expansion of the dice contract tutorial where we will create a MongoDB database adapter and show you how you can keep track of transfers to keep a record, ensuring that transactions don't get missed and more. Another planned feature is integrity checks of contracts to ensure that a contract running is the contract you wanted as well as versioning of contracts.
After all of this foundational work, support for Hive Engine tokens and sidechain operations will also be added into the library. All of these changes have been published in a new major version of the hive-stream library version 2.0.0 installable via npm install hive-stream. As always, contributions are always welcomed and feedback/issues.