mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-13 21:52:36 +03:00
Fixed re-subscribe bug
This commit is contained in:
@@ -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).
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user