Refactor Socket Connection
This is a major release with breaking changes that include:
- An architecture change that creates a separate WebSocket connection for each instance of the SDK that is running in the same client and ensures completely separate state between instances
- Removal of the
clientIndex
parameter from the API and also removing it from calls toaccount
,transaction
andunsubscribe
for a better dev experience.
Changes you need to make when upgrading from 1.x.x
to 2.0.0
:
- The SDK is now created from a class instead of a function, requiring the
new
keyword when instantiating:
// 1.x.x
import blocknativeSdk from 'bnc-sdk'
const blocknative = blocknativeSdk(options)
// 2.0.0
import BlocknativeSdk from 'bnc-sdk'
const blocknative = new BlocknativeSdk(options)
- The
clientIndex
parameter has been removed from the API and doesn't need to be included in function calls:
// === watching a transaction === //
// 1.x.x
const { emitter } = blocknative.transaction(blocknative.clientIndex, hash)
// 2.0.0
const { emitter } = blocknative.transaction(hash)
// === watching a account === //
// 1.x.x
const { emitter } = blocknative.account(blocknative.clientIndex, address)
// 2.0.0
const { emitter } = blocknative.account(address)
// === unwatching a transaction === //
// 1.x.x
const { emitter } = blocknative.unsubscribe(blocknative.clientIndex, hash)
// 2.0.0
const { emitter } = blocknative.unsubscribe(hash)
// === unwatching a account === //
// 1.x.x
const { emitter } = blocknative.unsubscribe(blocknative.clientIndex, address)
// 2.0.0
const { emitter } = blocknative.unsubscribe(address)
Changelog: