mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 14:12:35 +03:00
feat: add kind to update pair callback
This commit is contained in:
@@ -87,7 +87,10 @@ type PairsConfigSubscription = {
|
||||
|
||||
type PairConfigSubscription = {
|
||||
payload: string,
|
||||
callback: (data: AssetPairUpdate) => void,
|
||||
callback: ({ kind, data }: {
|
||||
kind: 'initial' | 'update',
|
||||
data: AssetPairUpdate,
|
||||
}) => void,
|
||||
}
|
||||
|
||||
type AggregatedOrderbookSubscription = {
|
||||
@@ -418,10 +421,18 @@ class OrionAggregatorWS {
|
||||
}
|
||||
break;
|
||||
case MessageType.ASSET_PAIR_CONFIG_UPDATE: {
|
||||
const pair = json;
|
||||
const [, minQty, pricePrecision] = pair.u;
|
||||
const pair = json.u;
|
||||
const [, minQty, pricePrecision] = pair;
|
||||
|
||||
this.subscriptions[SubscriptionType.ASSET_PAIR_CONFIG_UPDATES_SUBSCRIBE]?.[json.id]?.callback({ minQty, pricePrecision });
|
||||
this.subscriptions[
|
||||
SubscriptionType.ASSET_PAIR_CONFIG_UPDATES_SUBSCRIBE
|
||||
]?.[json.id]?.callback({
|
||||
data: {
|
||||
minQty,
|
||||
pricePrecision,
|
||||
},
|
||||
kind: json.k === 'i' ? 'initial' : 'update',
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import baseMessageSchema from './baseMessageSchema';
|
||||
const assetPairConfigSchema = baseMessageSchema.extend({
|
||||
id: z.string(),
|
||||
T: z.literal(MessageType.ASSET_PAIR_CONFIG_UPDATE),
|
||||
k: z.enum(['i', 'u']),
|
||||
u: z.tuple([
|
||||
z.string(), // pairName
|
||||
z.number(), // minQty
|
||||
|
||||
Reference in New Issue
Block a user