@riocrypto/common 1.0.2062 → 1.0.2063

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.
@@ -0,0 +1,3 @@
1
+ import { User } from "../types/user";
2
+ import { Crypto } from "../types/crypto";
3
+ export declare const getUserPayoutVaultId: (user: User, crypto: Crypto) => string;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getUserPayoutVaultId = void 0;
4
+ const user_attribute_1 = require("../types/user-attribute");
5
+ const is_overnight_or_weekend_mexico_city_1 = require("./is-overnight-or-weekend-mexico-city");
6
+ const getUserPayoutVaultId = (user, crypto) => {
7
+ var _a, _b;
8
+ const customPayoutFireblocksVault = user.customPayoutFireblocksVault;
9
+ if (customPayoutFireblocksVault === null || customPayoutFireblocksVault === void 0 ? void 0 : customPayoutFireblocksVault[crypto]) {
10
+ if ((0, is_overnight_or_weekend_mexico_city_1.isOvernightOrWeekendMexicoCity)()) {
11
+ if (customPayoutFireblocksVault[crypto].overrideOvernightAndWeekendVault) {
12
+ return customPayoutFireblocksVault[crypto].fireblocksVaultId;
13
+ }
14
+ else {
15
+ if ((_a = user.attributes) === null || _a === void 0 ? void 0 : _a.includes(user_attribute_1.UserAttribute.useFireblocksOvernightAndWeekendVault)) {
16
+ return "411";
17
+ }
18
+ else {
19
+ return "2";
20
+ }
21
+ }
22
+ }
23
+ else {
24
+ return customPayoutFireblocksVault[crypto].fireblocksVaultId;
25
+ }
26
+ }
27
+ else {
28
+ if ((0, is_overnight_or_weekend_mexico_city_1.isOvernightOrWeekendMexicoCity)()) {
29
+ if ((_b = user.attributes) === null || _b === void 0 ? void 0 : _b.includes(user_attribute_1.UserAttribute.useFireblocksOvernightAndWeekendVault)) {
30
+ return "411";
31
+ }
32
+ else {
33
+ return "2";
34
+ }
35
+ }
36
+ else {
37
+ return "2";
38
+ }
39
+ }
40
+ };
41
+ exports.getUserPayoutVaultId = getUserPayoutVaultId;
@@ -0,0 +1 @@
1
+ export declare const isOvernightOrWeekendMexicoCity: () => boolean;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isOvernightOrWeekendMexicoCity = void 0;
4
+ const isOvernightOrWeekendMexicoCity = () => {
5
+ const mexicoCityTime = new Date().toLocaleString("en-US", {
6
+ timeZone: "America/Mexico_City",
7
+ });
8
+ const currentTime = new Date(mexicoCityTime);
9
+ // Check if it's weekend (0 is Sunday, 6 is Saturday)
10
+ const dayOfWeek = currentTime.getDay();
11
+ if (dayOfWeek === 0 || dayOfWeek === 6) {
12
+ return true;
13
+ }
14
+ const hours = currentTime.getHours();
15
+ const minutes = currentTime.getMinutes();
16
+ // Convert current time to minutes since midnight for easier comparison
17
+ const currentTimeInMinutes = hours * 60 + minutes;
18
+ const eveningCutoff = 19 * 60 + 30; // 7:30 PM = 19:30
19
+ const morningCutoff = 8 * 60; // 8:00 AM = 8:00
20
+ // Check if current time is between 7:30 PM and 8:00 AM
21
+ return (currentTimeInMinutes >= eveningCutoff ||
22
+ currentTimeInMinutes < morningCutoff);
23
+ };
24
+ exports.isOvernightOrWeekendMexicoCity = isOvernightOrWeekendMexicoCity;
package/build/index.d.ts CHANGED
@@ -395,5 +395,7 @@ export * from "./helpers/get-base-url";
395
395
  export * from "./helpers/get-currency-with-country";
396
396
  export * from "./helpers/get-can-disburse-without-cosigner";
397
397
  export * from "./helpers/is-bitso-bank-account";
398
+ export * from "./helpers/is-overnight-or-weekend-mexico-city";
399
+ export * from "./helpers/get-user-payout-vault-id";
398
400
  export * from "./constants/mexico-fiscal-regimens";
399
401
  export * from "./constants/mexican-banks";
package/build/index.js CHANGED
@@ -411,5 +411,7 @@ __exportStar(require("./helpers/get-base-url"), exports);
411
411
  __exportStar(require("./helpers/get-currency-with-country"), exports);
412
412
  __exportStar(require("./helpers/get-can-disburse-without-cosigner"), exports);
413
413
  __exportStar(require("./helpers/is-bitso-bank-account"), exports);
414
+ __exportStar(require("./helpers/is-overnight-or-weekend-mexico-city"), exports);
415
+ __exportStar(require("./helpers/get-user-payout-vault-id"), exports);
414
416
  __exportStar(require("./constants/mexico-fiscal-regimens"), exports);
415
417
  __exportStar(require("./constants/mexican-banks"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common",
3
- "version": "1.0.2062",
3
+ "version": "1.0.2063",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",