diff --git a/package.json b/package.json index 42efa26..6f27515 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/configuration.ts b/src/configuration.ts index 45fd15f..20e369a 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -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 && @@ -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 @@ -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.` + ) }) }) } diff --git a/src/messages.ts b/src/messages.ts index ea4d002..6fc394b 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -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()