@riocrypto/common-server 1.0.2674 → 1.0.2676

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.
@@ -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
  }
@@ -17,6 +17,8 @@ const sanitizeOrderDoc = (doc) => {
17
17
  delete obj.discount;
18
18
  delete obj.markup;
19
19
  delete obj.rioPayoutFireblocksVaultId;
20
+ delete obj.assetPriceInUSD;
21
+ delete obj.actualAssetPriceInUSD;
20
22
  delete obj.previousActiveStatus;
21
23
  if (((_a = obj.payoutsSent) === null || _a === void 0 ? void 0 : _a.length) > 0) {
22
24
  obj.payoutsSent = obj.payoutsSent.map((payout) => {
@@ -26,6 +26,8 @@ interface OrderAttrs {
26
26
  wireMessage?: string;
27
27
  parentOrderId?: string;
28
28
  marketPrice: number;
29
+ assetPriceInUSD: number;
30
+ actualAssetPriceInUSD?: number;
29
31
  price?: number;
30
32
  depositAddress?: string;
31
33
  depositTxId?: string;
@@ -166,6 +168,8 @@ interface OrderDoc extends Document {
166
168
  fees: Fees;
167
169
  actualFees?: Fees;
168
170
  marketPrice: number;
171
+ assetPriceInUSD: number;
172
+ actualAssetPriceInUSD?: number;
169
173
  price?: number;
170
174
  depositAddress?: string;
171
175
  depositTxId?: string;
@@ -171,6 +171,12 @@ const buildOrder = (mongoose) => {
171
171
  marketPrice: {
172
172
  type: Number,
173
173
  },
174
+ assetPriceInUSD: {
175
+ type: Number,
176
+ },
177
+ actualAssetPriceInUSD: {
178
+ type: Number,
179
+ },
174
180
  price: {
175
181
  type: Number,
176
182
  },
@@ -17,6 +17,7 @@ interface QuoteAttrs {
17
17
  processor: Processor;
18
18
  fees: Fees;
19
19
  assetPriceInUSD: number;
20
+ actualAssetPriceInUSD?: number;
20
21
  price?: number;
21
22
  marketPrice: number;
22
23
  createdAt: Date;
@@ -65,6 +66,7 @@ interface QuoteDoc extends Document {
65
66
  price?: number;
66
67
  marketPrice: number;
67
68
  assetPriceInUSD: number;
69
+ actualAssetPriceInUSD?: number;
68
70
  quoteInCrypto: boolean;
69
71
  noMarkups: boolean;
70
72
  reissueAfterExpiration: boolean;
@@ -100,6 +100,9 @@ const buildQuote = (mongoose) => {
100
100
  assetPriceInUSD: {
101
101
  type: Number,
102
102
  },
103
+ actualAssetPriceInUSD: {
104
+ type: Number,
105
+ },
103
106
  brokerId: {
104
107
  type: String,
105
108
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2674",
3
+ "version": "1.0.2676",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "@google-cloud/secret-manager": "^5.3.0",
29
29
  "@google-cloud/storage": "^6.9.5",
30
30
  "@hyperdx/node-opentelemetry": "^0.7.0",
31
- "@riocrypto/common": "^1.0.2470",
31
+ "@riocrypto/common": "^1.0.2471",
32
32
  "@types/express": "^4.17.13",
33
33
  "axios": "^1.7.4",
34
34
  "crypto-js": "^4.2.0",