diff --git a/README.md b/README.md index 8ea482e..ffc79b2 100644 --- a/README.md +++ b/README.md @@ -286,6 +286,8 @@ const exchangeContract = Exchange__factory.connect( const orderIsOk = await exchangeContract.validateOrder(signedOrder); +if (!orderIsOk) throw new Error("Order invalid"); + const { orderId } = await simpleFetch(orionUnit.orionAggregator.placeOrder)( signedOrder, false // True if you want place order to "internal" orderbook. If you do not want your order to be executed on CEXes or DEXes, but could be filled with the another "internal" order(s). diff --git a/package.json b/package.json index 17f16f9..cb26930 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.12.0", + "version": "0.12.1", "description": "Orion Protocol SDK", "main": "./lib/esm/index.js", "module": "./lib/esm/index.js", diff --git a/src/services/OrionAggregator/ws/index.ts b/src/services/OrionAggregator/ws/index.ts index 913dfe7..343d6bc 100644 --- a/src/services/OrionAggregator/ws/index.ts +++ b/src/services/OrionAggregator/ws/index.ts @@ -139,6 +139,8 @@ const exclusiveSubscriptions = [ ] as const; type WsMessage = string | ArrayBufferLike | Blob | ArrayBufferView; + +const isSubType = (subType: string): subType is keyof Subscription => Object.values(SubscriptionType).some((t) => t === subType); class OrionAggregatorWS { private ws: WebSocket | undefined; @@ -264,14 +266,17 @@ class OrionAggregatorWS { this.ws.onopen = () => { // Re-subscribe to all subscriptions if (isReconnect) { - Object.entries(this.subscriptions).forEach(([type, subscription]) => { - this.send({ - T: type, - ...('payload' in subscription) && { - S: subscription.payload, - }, + Object.keys(this.subscriptions) + .filter(isSubType) + .forEach((subType) => { + const subscriptions = this.subscriptions[subType]; + if (subscriptions) { + Object.keys(subscriptions).forEach((subKey) => { + const sub = subscriptions[subKey]; + if (sub) this.subscribe(subType, sub); + }); + } }); - }); } }; this.ws.onmessage = (e) => {