@riocrypto/common-server 1.0.2673 → 1.0.2675

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -149,6 +149,7 @@ declare class ClusterClient {
149
149
  }): Promise<ExternalTrade>;
150
150
  deleteExternalTrade(id: string): Promise<void>;
151
151
  getEmarketsTrade(id: string): Promise<EmarketsFXTrade>;
152
+ getTransnetworkTrade(id: string): Promise<TransnetworkFXTrade>;
152
153
  updateExternalTradingAlgorithmLimitPrice(id: string, limitPrice: number): Promise<void>;
153
154
  startExternalTradingAlgorithm({ type, provider, originCurrency, destinationCurrency, maxOriginAmount, maxDestinationAmount, limitPrice, replaceOrderDifferenceThreshold, isPostOnly, spread, clipSize, }: {
154
155
  type: ExternalTradingAlgorithmType;
@@ -523,6 +523,16 @@ class ClusterClient {
523
523
  return response.data;
524
524
  });
525
525
  }
526
+ getTransnetworkTrade(id) {
527
+ return __awaiter(this, void 0, void 0, function* () {
528
+ const response = yield this.axios.get(`${this.baseUrl}/api/transnetwork/bot/trades/${id}`, {
529
+ headers: {
530
+ "x-cluster-api-key": this.clusterApiKey,
531
+ },
532
+ });
533
+ return response.data;
534
+ });
535
+ }
526
536
  updateExternalTradingAlgorithmLimitPrice(id, limitPrice) {
527
537
  return __awaiter(this, void 0, void 0, function* () {
528
538
  yield this.axios.patch(`${this.baseUrl}/api/trading/external/algorithms/${id}`, { limitPrice }, {
@@ -38,17 +38,26 @@ const getBulkPaymentFromReference = (reference, mongoose) => __awaiter(void 0, v
38
38
  if (!referenceText.includes("bp")) {
39
39
  throw new Error("Bulk payment not found");
40
40
  }
41
- // Match by ID pattern: 2 chars from random portion (8-9) + last 6 chars
42
- const bulkPayment = bulkPayments.find((bulkPayment) => {
41
+ // Priority 1: New format - 2 chars from random portion (8-9) + last 6 chars
42
+ const bulkPaymentNewFormat = bulkPayments.find((bulkPayment) => {
43
43
  const bulkPaymentId = bulkPayment.id.toString().toLowerCase();
44
44
  const randomPrefix = bulkPaymentId.slice(8, 10);
45
45
  const last6 = bulkPaymentId.slice(-6);
46
46
  const reference8Chars = randomPrefix + last6;
47
47
  return referenceText.includes(reference8Chars);
48
48
  });
49
- if (!bulkPayment) {
49
+ if (bulkPaymentNewFormat) {
50
+ return bulkPaymentNewFormat;
51
+ }
52
+ // Priority 2: Old format - just last 6 chars (backwards compatibility)
53
+ const bulkPaymentOldFormat = bulkPayments.find((bulkPayment) => {
54
+ const bulkPaymentId = bulkPayment.id.toString().toLowerCase();
55
+ const last6 = bulkPaymentId.slice(-6);
56
+ return referenceText.includes(last6);
57
+ });
58
+ if (!bulkPaymentOldFormat) {
50
59
  throw new Error("Bulk payment not found");
51
60
  }
52
- return bulkPayment;
61
+ return bulkPaymentOldFormat;
53
62
  });
54
63
  exports.getBulkPaymentFromReference = getBulkPaymentFromReference;
@@ -33,6 +33,7 @@ const getOrderFromReference = (reference, mongoose) => __awaiter(void 0, void 0,
33
33
  const batchSize = 1000;
34
34
  let skip = 0;
35
35
  let foundOrder = null;
36
+ let foundOrderOldFormat = null;
36
37
  while (!foundOrder) {
37
38
  // Query only active orders (exclude completed/cancelled/failed) in batches
38
39
  const orders = yield Order.find({
@@ -47,19 +48,29 @@ const getOrderFromReference = (reference, mongoose) => __awaiter(void 0, void 0,
47
48
  break;
48
49
  }
49
50
  // Check each order ID against the reference
50
- // Reference format: 2 chars from random portion (8-9) + last 6 chars
51
+ // Priority 1: New format - 2 chars from random portion (8-9) + last 6 chars
52
+ // Priority 2: Old format - just last 6 chars (backwards compatibility)
51
53
  for (const order of orders) {
52
54
  const orderId = order._id.toString().toLowerCase();
53
55
  const randomPrefix = orderId.slice(8, 10);
54
56
  const last6 = orderId.slice(-6);
55
57
  const reference8Chars = randomPrefix + last6;
58
+ // Check new 8-char format first (takes priority)
56
59
  if (referenceText.includes(reference8Chars)) {
57
60
  foundOrder = yield Order.findById(order._id);
58
61
  break;
59
62
  }
63
+ // Track old 6-char format match as fallback (only if no 8-char match yet)
64
+ if (!foundOrderOldFormat && referenceText.includes(last6)) {
65
+ foundOrderOldFormat = yield Order.findById(order._id);
66
+ }
60
67
  }
61
68
  skip += batchSize;
62
69
  }
70
+ // Use 8-char match if found, otherwise fall back to 6-char match
71
+ if (!foundOrder && foundOrderOldFormat) {
72
+ foundOrder = foundOrderOldFormat;
73
+ }
63
74
  if (!foundOrder) {
64
75
  throw new Error("Order not found");
65
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2673",
3
+ "version": "1.0.2675",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",