Major Release: v5.0.0
After 528 commits and the combined efforts of the Streamr team streamr-client 5.0.0 is here.
This is basically a new Streamr client with rebuilt internals. The external interface remains largely the same, with some notable changes listed below.
Improvements
- New subscription “pipeline” architecture.
- Many more tests, more edge cases covered.
- More robust/understandable/consistent connection/disconnection handling.
- No more event spaghetti & uncatchable errors.
- No more unavoidable console logging.
- More predictable behaviour around error handling & connection issues.
- Significant improvements to CI workflow, many more (52) test scenarios.
Breaking Changes
subscribe/resendmethods are nowasync.getAddressis nowasync- No more
subscribedevent. Thesubscribe()promise now resolves when this would have fired. - No more
no_resendevent, nowresentis fired whether there were messages or not. autoConnect+autoDisconnectoptions become forcibly disabled if you explicitly callconnect()ordisconnect(). You can reenable automatic behaviour without creating a new client or mutating options usingclient.enableAutoConnect()/client.enableAutoDisconnect(). This means if you explicitlyconnect()you must explicitlydisconnect()orenableAutoDisconnect()to close the connection.connect()&disconnect()no longer error if already {dis}connecting/{dis}connected. This is basically whatensureConnected/ensureDisconnectedprovided before.- The
ensureConnected/ensureDisconnectedmethods still exist but are now just aliases ofconnect&disconnect. - Many DataUnion methods have been renamed and/or changed, see below.
DataUnion changes
DataUnion is now an object which we can operate on. To get an instance of DU object, call client.getDataUnion(contractAddress). As the object encapsulates the contract address, we don't need to specify it when we access the DU methods.
Some methods that need a member address were previously optional, and the default value for those was the currently authenticated user. Now we are more explicit about the parameter and the member address is always required. Also previously there was a dataUnion client option which was a default value for some DU actions. That is no longer supported.
Some options of these methods have changed. Options for new StreamrClient(opts) have moved to a separate dataUnion block, and some properties renamed.
Member join functions
- renamed
joinDataUnion()->join(secret?), if secret is given this will wait until the automatic join request has been processed - added
isMember(memberAddress), returns true if the member is an active member - removed
hasJoined()
Withdraw functions renamed to have word "all" if the amount is not specified
withdrawAll(options?)withdrawAllTo(recipient, options?)signWithdrawAllTo(recipientAddress)signWithdrawAmountTo(recipientAddress, amountTokenWei)- admin:
withdrawFor()->withdrawAllToMember(memberAddress, options?) - admin:
withdrawAllToSigned(memberAddress, recipientAddress, signature, options?) - removed methods that returned the raw withdraw transactions removed:
getWithdrawTx(),getWithdrawTxTo(),getWithdrawTxFor()
Public query functions
- renamed
getDataUnionStats()->getStats(), data format changed getMemberStatsdata format changed- renamed
getBalance()->getWithdrawableEarnings(memberAddress) - removed
getMembers(not currently supported)
Admin functions:
client.deployDataUnion(options)waits until the deployment is ready- renamed
kick()->removeMembers(memberAddressList, options?)
New Features
- Subscription objects are async iterable. You can access this interface if you don’t supply an
onMessagehandler tosubscribe/resend. Note the iteration producesStreamMessageobjects, rather than the message content, as passed as the first argument toonMessage. To get the message content callstreamMessage.getParsedContent(). - Added a
collect()function to subscriptions that collects results into an array of messages and resolves when the subscription ends, mainly/only useful for resends. Won't work if you supply anonMessagehandler. Requires explicit ending of subscription. - Connection emits
donewhen it's been disconnected and will not reconnect. - Connection emits
connectedonly when it's connected and will not be immediately disconnecting.
Other Notable Changes
- Public interfaces are now typed with TypeScript. Internals are currently in the process of being converted.
- Random errors no longer disconnect the client.
- Reconnecting on unexpected disconnection should work reliably now, there's a hard distinction between user-initiated disconnects and those that happen by accident.
- Resends should work more reliably now.
- Cleaned up and improved logging. Logging is overall more verbose but it should be much clearer what’s going on. All logging goes through
Debug('StreamrClient*')except errors emitted by client. - Subscribe, resend & subscribe with resend all use the same machinery now, so their behaviour should now be identical. Previously there were some small differences which led to confusion.
- Uses latest version of streamr-client-protocol
8.0.0.
Bundling & Builds
- Removed regenerator babel transform.
- Node builds are no longer webpack bundles. Just normal JS files & requires.
- source-maps are now always on for web bundles.
- New BundleAnalyzerPlugin produces a bundle size report in
dist/report.html. This is downloadable as an artifact in CI builds.
Testing
- Almost all functionality is now tested via integration tests, rather than implementation-coupled+heavily mocked unit tests.
- Encryption & signing is tested in the browser now
- Publishing & subscribing, with and without encryption/signing is tested against the Java client using streamr-client-testing
- Added Encryption & signing benchmarks
- Significant improvements to test reliability.
- Significant improvements to CI workflow.