@riocrypto/common-server 1.0.2811 → 1.0.2815
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.
- package/build/helpers/get-bulk-bank-payment-from-static-reference.d.ts +3 -0
- package/build/helpers/get-bulk-bank-payment-from-static-reference.js +57 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/models/fireblocks-transfer.d.ts +2 -0
- package/build/models/fireblocks-transfer.js +3 -0
- package/package.json +2 -2
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getBulkBankPaymentFromStaticReference = void 0;
|
|
13
|
+
const common_1 = require("@riocrypto/common");
|
|
14
|
+
const bulk_bank_payment_1 = require("../models/bulk-bank-payment");
|
|
15
|
+
const static_bank_payment_reference_1 = require("../models/static-bank-payment-reference");
|
|
16
|
+
const user_1 = require("../models/user");
|
|
17
|
+
const getBulkBankPaymentFromStaticReference = (reference, amount, mongoose) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
// Ensure reference is defined
|
|
19
|
+
if (!reference) {
|
|
20
|
+
throw new Error("Invalid reference. Reference cannot be empty.");
|
|
21
|
+
}
|
|
22
|
+
// Check if first 3 characters are SPR
|
|
23
|
+
if (!reference.startsWith("SPR")) {
|
|
24
|
+
throw new Error("Invalid reference. Reference must start with SPR.");
|
|
25
|
+
}
|
|
26
|
+
const StaticBankPaymentReference = (0, static_bank_payment_reference_1.buildStaticBankPaymentReference)(mongoose);
|
|
27
|
+
const staticBankPaymentReference = yield StaticBankPaymentReference.findOne({
|
|
28
|
+
reference: reference,
|
|
29
|
+
});
|
|
30
|
+
if (!staticBankPaymentReference) {
|
|
31
|
+
throw new Error("Static bank payment reference not found");
|
|
32
|
+
}
|
|
33
|
+
const User = (0, user_1.buildUser)(mongoose);
|
|
34
|
+
const user = yield User.findById(staticBankPaymentReference.userId);
|
|
35
|
+
if (!user) {
|
|
36
|
+
throw new Error("User not found");
|
|
37
|
+
}
|
|
38
|
+
const BulkBankPayment = (0, bulk_bank_payment_1.buildBulkBankPayment)(mongoose);
|
|
39
|
+
// Find the oldest bulk bank payment that is awaiting payment and has the
|
|
40
|
+
// same amount and fiat as the static bank payment reference
|
|
41
|
+
const bulkBankPayment = yield BulkBankPayment.findOne({
|
|
42
|
+
userId: user.id,
|
|
43
|
+
fiat: staticBankPaymentReference.fiat,
|
|
44
|
+
status: {
|
|
45
|
+
$in: [
|
|
46
|
+
common_1.BulkBankPaymentStatus.AwaitingPayment,
|
|
47
|
+
common_1.BulkBankPaymentStatus.AwaitingAsyncPayment,
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
amount: amount,
|
|
51
|
+
}).sort({ createdAt: 1 });
|
|
52
|
+
if (!bulkBankPayment) {
|
|
53
|
+
throw new Error("Bulk bank payment not found");
|
|
54
|
+
}
|
|
55
|
+
return bulkBankPayment;
|
|
56
|
+
});
|
|
57
|
+
exports.getBulkBankPaymentFromStaticReference = getBulkBankPaymentFromStaticReference;
|
package/build/index.d.ts
CHANGED
|
@@ -169,6 +169,7 @@ export * from "./helpers/get-bulk-payment-from-reference";
|
|
|
169
169
|
export * from "./helpers/extract-error-message";
|
|
170
170
|
export * from "./helpers/get-exchange-rates-with-markups";
|
|
171
171
|
export * from "./helpers/get-order-from-static-reference";
|
|
172
|
+
export * from "./helpers/get-bulk-bank-payment-from-static-reference";
|
|
172
173
|
export * from "./helpers/is-after-hours";
|
|
173
174
|
export * from "./helpers/interpolate-forward-curve-rate";
|
|
174
175
|
export * from "./helpers/find-user-tier-forward-curve-rate";
|
package/build/index.js
CHANGED
|
@@ -185,6 +185,7 @@ __exportStar(require("./helpers/get-bulk-payment-from-reference"), exports);
|
|
|
185
185
|
__exportStar(require("./helpers/extract-error-message"), exports);
|
|
186
186
|
__exportStar(require("./helpers/get-exchange-rates-with-markups"), exports);
|
|
187
187
|
__exportStar(require("./helpers/get-order-from-static-reference"), exports);
|
|
188
|
+
__exportStar(require("./helpers/get-bulk-bank-payment-from-static-reference"), exports);
|
|
188
189
|
__exportStar(require("./helpers/is-after-hours"), exports);
|
|
189
190
|
__exportStar(require("./helpers/interpolate-forward-curve-rate"), exports);
|
|
190
191
|
__exportStar(require("./helpers/find-user-tier-forward-curve-rate"), exports);
|
|
@@ -20,6 +20,7 @@ interface FireblocksTransferAttrs {
|
|
|
20
20
|
status: FireblocksTransferStatus;
|
|
21
21
|
retryCount: number;
|
|
22
22
|
dispatchAttemptedAt?: Date;
|
|
23
|
+
reconciliationAlertedAt?: Date;
|
|
23
24
|
}[];
|
|
24
25
|
netAmountTransfered?: number;
|
|
25
26
|
}
|
|
@@ -43,6 +44,7 @@ interface FireblocksTransferDoc extends mongoose.Document {
|
|
|
43
44
|
status: FireblocksTransferStatus;
|
|
44
45
|
retryCount: number;
|
|
45
46
|
dispatchAttemptedAt?: Date;
|
|
47
|
+
reconciliationAlertedAt?: Date;
|
|
46
48
|
}[];
|
|
47
49
|
netAmountTransfered?: number;
|
|
48
50
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2815",
|
|
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.6.0",
|
|
29
29
|
"@google-cloud/storage": "^7.19.0",
|
|
30
30
|
"@hyperdx/node-opentelemetry": "^0.10.3",
|
|
31
|
-
"@riocrypto/common": "1.0.
|
|
31
|
+
"@riocrypto/common": "1.0.2617",
|
|
32
32
|
"@slack/web-api": "^7.15.0",
|
|
33
33
|
"@types/express": "^4.17.25",
|
|
34
34
|
"axios": "1.16.0",
|