Skip to content

Commit

Permalink
Merge pull request #116 from blocknative/release/3.3.1
Browse files Browse the repository at this point in the history
Release 3.3.1
  • Loading branch information
lnbc1QWFyb24 authored Apr 22, 2021
2 parents 082e547 + a0f6418 commit 1d466d8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bnc-sdk",
"version": "3.3.0",
"version": "3.3.1",
"description": "SDK to connect to the blocknative backend via a websocket connection",
"keywords": [
"ethereum",
Expand Down
14 changes: 9 additions & 5 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ function configuration(
)
}

const casedScope =
this._system === 'ethereum' ? config.scope.toLowerCase() : config.scope

// resolve previous configuration if exists
const previousConfiguration = this._configurations.get(
config.scope.toLowerCase()
)
const previousConfiguration = this._configurations.get(casedScope)

previousConfiguration &&
previousConfiguration.subscription &&
Expand All @@ -27,7 +28,7 @@ function configuration(
// create emitter for transaction
const emitter = config.watchAddress ? { emitter: createEmitter() } : {}

this._configurations.set(config.scope.toLowerCase(), {
this._configurations.set(casedScope, {
...config,
...emitter,
subscription
Expand All @@ -42,7 +43,10 @@ function configuration(
return new Promise((resolve, reject) => {
subscription.pipe(take(1), timeout(5000)).subscribe({
next: () => resolve({ ...emitter, details: { config } }),
error: reject
error: () =>
reject(
`Configuration with scope: ${config.scope} has been sent to the Blocknative server, but has not received a reply within 5 seconds.`
)
})
})
}
Expand Down
7 changes: 6 additions & 1 deletion src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,12 @@ export function handleMessage(this: any, msg: { data: string }): void {
}

if (event && event.config) {
const configuration = this._configurations.get(event.config.scope)
const casedScope =
this._system === 'ethereum'
? event.config.scope.toLowerCase()
: event.config.scope

const configuration = this._configurations.get(casedScope)

if (configuration && configuration.subscription) {
configuration.subscription.next()
Expand Down

0 comments on commit 1d466d8

Please sign in to comment.