From dbec14a78f57a98a4d5e7b54e416704784e26d3a Mon Sep 17 00:00:00 2001 From: Mikhail Gladchenko Date: Mon, 19 Feb 2024 14:30:35 +0000 Subject: [PATCH 1/5] feat: expand aus subscription --- package.json | 2 +- src/services/Aggregator/ws/index.ts | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 78c11af2..afc36e12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.60", + "version": "0.20.61-rc0", "description": "Orion Protocol SDK", "main": "./lib/index.cjs", "module": "./lib/index.js", diff --git a/src/services/Aggregator/ws/index.ts b/src/services/Aggregator/ws/index.ts index 69d214cb..a7e77e65 100644 --- a/src/services/Aggregator/ws/index.ts +++ b/src/services/Aggregator/ws/index.ts @@ -102,7 +102,11 @@ type AddressUpdateInitial = { } type AddressUpdateSubscription = { - payload: string + payload: { + S: string + pa?: string[] + } + // payload: string callback: (data: AddressUpdateUpdate | AddressUpdateInitial) => void errorCb?: (message: string) => void } @@ -265,7 +269,20 @@ class AggregatorWS { if ('payload' in subscription) { if (typeof subscription.payload === 'string') { subRequest['S'] = subscription.payload; - } else { // SwapInfoSubscriptionPayload + } else { + for (const [key, value] of Object.entries(subscription.payload)) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + subRequest[key] = value; + } + } + + // Crutch for SwapInfoSubscriptionPayload + if ( + typeof subscription.payload !== 'string' && + 'i' in subscription.payload && + 'o' in subscription.payload && + 'a' in subscription.payload + ) { subRequest['S'] = { d: id, ...subscription.payload, From b55492c26451852a119741cc474d5fe6be8e0090 Mon Sep 17 00:00:00 2001 From: Mikhail Gladchenko Date: Mon, 19 Feb 2024 15:23:02 +0000 Subject: [PATCH 2/5] fix: ts error fix --- src/services/Aggregator/ws/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/Aggregator/ws/index.ts b/src/services/Aggregator/ws/index.ts index a7e77e65..a83d708e 100644 --- a/src/services/Aggregator/ws/index.ts +++ b/src/services/Aggregator/ws/index.ts @@ -374,7 +374,7 @@ class AggregatorWS { if (newestSubId.includes('0x')) { // is wallet address (ADDRESS_UPDATE) const auSubscriptions = this.subscriptions[SubscriptionType.ADDRESS_UPDATES_SUBSCRIBE]; if (auSubscriptions) { - const targetAuSub = Object.entries(auSubscriptions).find(([, value]) => value?.payload === newestSubId); + const targetAuSub = Object.entries(auSubscriptions).find(([, value]) => value?.payload.S === newestSubId); if (targetAuSub) { const [key] = targetAuSub; delete this.subscriptions[SubscriptionType.ADDRESS_UPDATES_SUBSCRIBE]?.[key]; From 500f100d466aa53c6be4c065be02dbf082d41489 Mon Sep 17 00:00:00 2001 From: Mikhail Gladchenko Date: Mon, 19 Feb 2024 15:49:54 +0000 Subject: [PATCH 3/5] fix: logs was added --- package.json | 2 +- src/services/Aggregator/ws/index.ts | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index afc36e12..12c7d9db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.61-rc0", + "version": "0.20.61-rc1", "description": "Orion Protocol SDK", "main": "./lib/index.cjs", "module": "./lib/index.js", diff --git a/src/services/Aggregator/ws/index.ts b/src/services/Aggregator/ws/index.ts index a83d708e..e9c8ba66 100644 --- a/src/services/Aggregator/ws/index.ts +++ b/src/services/Aggregator/ws/index.ts @@ -1,4 +1,4 @@ -import { z } from 'zod'; +import { string, z } from 'zod'; import WebSocket from 'isomorphic-ws'; import { validate as uuidValidate, v4 as uuidv4 } from 'uuid'; import MessageType from './MessageType.js'; @@ -268,14 +268,19 @@ class AggregatorWS { if ('payload' in subscription) { if (typeof subscription.payload === 'string') { + console.log('subscription.payload === string', subscription.payload); subRequest['S'] = subscription.payload; } else { + console.log('subscription.payload === object', subscription.payload); for (const [key, value] of Object.entries(subscription.payload)) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - subRequest[key] = value; + console.log('for in', key, value); + // eslint-disable-next-line @typescript-eslint/consistent-type-assertions + subRequest[key] = value as Json; } } + console.log('subRequest', subRequest); + // Crutch for SwapInfoSubscriptionPayload if ( typeof subscription.payload !== 'string' && @@ -283,11 +288,14 @@ class AggregatorWS { 'o' in subscription.payload && 'a' in subscription.payload ) { + console.log('SwapInfoSubscriptionPayload', subscription.payload); subRequest['S'] = { d: id, ...subscription.payload, }; } + + console.log('subRequest', subRequest); } const subKey = isExclusive ? 'default' : id; From 7c3243df3ba4cdcf05eb8b94ef392dd11d5b8dfe Mon Sep 17 00:00:00 2001 From: Mikhail Gladchenko Date: Mon, 19 Feb 2024 15:53:08 +0000 Subject: [PATCH 4/5] fix: TS fix --- src/services/Aggregator/ws/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/Aggregator/ws/index.ts b/src/services/Aggregator/ws/index.ts index e9c8ba66..9c94a0e0 100644 --- a/src/services/Aggregator/ws/index.ts +++ b/src/services/Aggregator/ws/index.ts @@ -1,4 +1,4 @@ -import { string, z } from 'zod'; +import { z } from 'zod'; import WebSocket from 'isomorphic-ws'; import { validate as uuidValidate, v4 as uuidv4 } from 'uuid'; import MessageType from './MessageType.js'; From bc088838a86733b97e177075acef915905135ebf Mon Sep 17 00:00:00 2001 From: Kirill Litvinov Date: Tue, 23 Apr 2024 17:57:48 +0300 Subject: [PATCH 5/5] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5bfcd1bb..67dd923f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.61-rc1", + "version": "0.20.61-rc2", "description": "Orion Protocol SDK", "main": "./lib/index.cjs", "module": "./lib/index.js",