Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Major Release: v5.0.0

Choose a tag to compare

@timoxley timoxley released this 12 Mar 19:22
· 431 commits to master since this release

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/resend methods are now async.
  • getAddress is now async
  • No more subscribed event. The subscribe() promise now resolves when this would have fired.
  • No more no_resend event, now resent is fired whether there were messages or not.
  • autoConnect + autoDisconnect options become forcibly disabled if you explicitly call connect() or disconnect(). You can reenable automatic behaviour without creating a new client or mutating options using client.enableAutoConnect()/client.enableAutoDisconnect(). This means if you explicitly connect() you must explicitly disconnect() or enableAutoDisconnect() to close the connection.
  • connect() & disconnect() no longer error if already {dis}connecting/{dis}connected. This is basically what ensureConnected/ensureDisconnected provided before.
  • The ensureConnected/ensureDisconnected methods still exist but are now just aliases of connect & 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
  • getMemberStats data 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 onMessage handler to subscribe/resend. Note the iteration produces StreamMessage objects, rather than the message content, as passed as the first argument to onMessage. To get the message content call streamMessage.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 an onMessage handler. Requires explicit ending of subscription.
  • Connection emits done when it's been disconnected and will not reconnect.
  • Connection emits connected only 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.