@riocrypto/common-server 1.0.1674 → 1.0.1676

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.
Files changed (43) hide show
  1. package/build/clients/bridge-client.js +0 -1
  2. package/build/clients/circle-client.js +0 -1
  3. package/build/clients/cloud-vision-api-client.d.ts +0 -9
  4. package/build/clients/cloud-vision-api-client.js +54 -58
  5. package/build/clients/coincover-client.js +0 -1
  6. package/build/clients/cosigner-client.js +0 -1
  7. package/build/index.d.ts +0 -17
  8. package/build/index.js +0 -17
  9. package/package.json +3 -9
  10. package/build/clients/aiprise-client.d.ts +0 -13
  11. package/build/clients/aiprise-client.js +0 -109
  12. package/build/clients/bitstamp-client.d.ts +0 -16
  13. package/build/clients/bitstamp-client.js +0 -97
  14. package/build/clients/brex-client.d.ts +0 -17
  15. package/build/clients/brex-client.js +0 -92
  16. package/build/clients/ccxt-client.d.ts +0 -25
  17. package/build/clients/ccxt-client.js +0 -164
  18. package/build/clients/coinbase-client.d.ts +0 -13
  19. package/build/clients/coinbase-client.js +0 -119
  20. package/build/clients/etherscan-client.d.ts +0 -7
  21. package/build/clients/etherscan-client.js +0 -40
  22. package/build/clients/fogbender-client.d.ts +0 -7
  23. package/build/clients/fogbender-client.js +0 -47
  24. package/build/clients/google-sheets-api-client.d.ts +0 -10
  25. package/build/clients/google-sheets-api-client.js +0 -75
  26. package/build/clients/gueno-client.d.ts +0 -11
  27. package/build/clients/gueno-client.js +0 -58
  28. package/build/clients/invopop-client.d.ts +0 -17
  29. package/build/clients/invopop-client.js +0 -225
  30. package/build/clients/kapstar-client.d.ts +0 -13
  31. package/build/clients/kapstar-client.js +0 -71
  32. package/build/clients/killb-client.d.ts +0 -13
  33. package/build/clients/killb-client.js +0 -76
  34. package/build/clients/polygon-client.d.ts +0 -11
  35. package/build/clients/polygon-client.js +0 -38
  36. package/build/helpers/get-polygon-exchange-rates.d.ts +0 -8
  37. package/build/helpers/get-polygon-exchange-rates.js +0 -34
  38. package/build/helpers/sanitize-chained-order-doc.d.ts +0 -27
  39. package/build/helpers/sanitize-chained-order-doc.js +0 -10
  40. package/build/helpers/sanitize-order-doc.d.ts +0 -27
  41. package/build/helpers/sanitize-order-doc.js +0 -20
  42. package/build/helpers/sanitize-quote-doc.d.ts +0 -27
  43. package/build/helpers/sanitize-quote-doc.js +0 -17
@@ -1,225 +0,0 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.buildInvopopClient = void 0;
16
- const secret_manager_client_1 = require("./secret-manager-client");
17
- const axios_1 = __importDefault(require("axios"));
18
- const common_1 = require("@riocrypto/common");
19
- const uuid_1 = require("uuid");
20
- const market_data_1 = require("../models/market-data");
21
- class InvopopClient {
22
- constructor(apiKey) {
23
- this.apiKey = apiKey;
24
- this.baseUrl = "https://api.invopop.com";
25
- }
26
- createJob(mongoose, order, user) {
27
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
28
- return __awaiter(this, void 0, void 0, function* () {
29
- if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
30
- throw new Error("Cannot create invoice in sandbox environment");
31
- }
32
- const uuid = (0, uuid_1.v1)();
33
- const operationDate = new Date(order.createdAt);
34
- const operationYear = operationDate.getFullYear();
35
- const operationMonth = String(operationDate.getMonth() + 1).padStart(2, "0"); // Month is zero-indexed
36
- const operationDay = String(operationDate.getDate()).padStart(2, "0");
37
- const operationDateFormatted = `${operationYear}-${operationMonth}-${operationDay}`;
38
- const issueDate = new Date();
39
- const mexicoCityOffset = -6;
40
- issueDate.setUTCHours(issueDate.getUTCHours() + mexicoCityOffset);
41
- const issueYear = issueDate.getFullYear();
42
- const issueMonth = String(issueDate.getMonth() + 1).padStart(2, "0"); // Month is zero-indexed
43
- const issueDay = String(issueDate.getDate()).padStart(2, "0");
44
- const issueDateFormatted = `${issueYear}-${issueMonth}-${issueDay}`;
45
- let customerName;
46
- let postalCode;
47
- let rfc;
48
- let fiscalRegimenCode;
49
- let cfdiUseCode;
50
- if (((_c = (_b = (_a = user.onboarding) === null || _a === void 0 ? void 0 : _a.MX) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c.country) === common_1.CountryOfOrigin.Mexico) {
51
- if (!((_e = (_d = user.invoicing) === null || _d === void 0 ? void 0 : _d.MX) === null || _e === void 0 ? void 0 : _e.shouldInvoice)) {
52
- customerName = "PÚBLICO EN GENERAL";
53
- postalCode = "66260";
54
- rfc = "XAXX010101000";
55
- fiscalRegimenCode = "616";
56
- cfdiUseCode = "S01";
57
- }
58
- else if ((_g = (_f = user.invoicing) === null || _f === void 0 ? void 0 : _f.MX) === null || _g === void 0 ? void 0 : _g.fiscalName) {
59
- customerName = (_h = user.invoicing) === null || _h === void 0 ? void 0 : _h.MX.fiscalName.toLocaleUpperCase();
60
- postalCode = (_l = (_k = (_j = user.onboarding) === null || _j === void 0 ? void 0 : _j.MX) === null || _k === void 0 ? void 0 : _k.address) === null || _l === void 0 ? void 0 : _l.postalCode;
61
- rfc = (_o = (_m = user.onboarding) === null || _m === void 0 ? void 0 : _m.MX) === null || _o === void 0 ? void 0 : _o.taxId;
62
- fiscalRegimenCode = (_q = (_p = user.invoicing) === null || _p === void 0 ? void 0 : _p.MX.fiscalRegimenCode) === null || _q === void 0 ? void 0 : _q.toString();
63
- if (!fiscalRegimenCode) {
64
- throw new Error("Missing fiscal regimen code");
65
- }
66
- if (["606", "612", "621", "625", "626"].includes(fiscalRegimenCode)) {
67
- cfdiUseCode = "G03";
68
- }
69
- else {
70
- cfdiUseCode = "S01";
71
- }
72
- }
73
- }
74
- else {
75
- customerName = (0, common_1.getUserName)(user).toLocaleUpperCase();
76
- postalCode = "66260";
77
- rfc = "XEXX010101000";
78
- fiscalRegimenCode = "616";
79
- cfdiUseCode = "S01";
80
- }
81
- if (!customerName) {
82
- throw new Error("Customer name not found");
83
- }
84
- if (!postalCode) {
85
- throw new Error("Postal code not found");
86
- }
87
- if (!rfc) {
88
- throw new Error("RFC not found");
89
- }
90
- if (!fiscalRegimenCode) {
91
- throw new Error("Fiscal regimen code not found");
92
- }
93
- if (!cfdiUseCode) {
94
- throw new Error("CFDI use code not found");
95
- }
96
- const isUSDOrder = order.fiat === common_1.Fiat.USD;
97
- const MarketData = (0, market_data_1.buildMarketData)(mongoose);
98
- const marketData = yield MarketData.findOne();
99
- if (!marketData) {
100
- throw new common_1.NotFoundError("Market data");
101
- }
102
- if (isUSDOrder &&
103
- (!marketData.previousDayConversionRatesFromUSD.MXN.value ||
104
- !marketData.previousDayConversionRatesToUSD.MXN.value)) {
105
- throw new Error("Missing previous day MXN<>USD exchange rates");
106
- }
107
- const { data } = yield axios_1.default.put(`${this.baseUrl}/transform/v1/jobs/${uuid}`, {
108
- workflow_id: "5b123900-1035-4c8c-a97a-36b940d7a21e",
109
- data: {
110
- $schema: "https://gobl.org/draft-0/bill/invoice",
111
- code: "",
112
- type: "standard",
113
- currency: common_1.Fiat.MXN,
114
- issue_date: issueDateFormatted,
115
- op_date: operationDateFormatted,
116
- supplier: {
117
- name: "RAMPA BLOCKCHAIN",
118
- tax_id: {
119
- country: "MX",
120
- zone: "66260",
121
- code: "RBL2206107N8",
122
- },
123
- identities: [
124
- {
125
- key: "mx-cfdi-fiscal-regime",
126
- code: "601",
127
- },
128
- ],
129
- },
130
- customer: {
131
- name: customerName,
132
- tax_id: {
133
- country: "MX",
134
- zone: postalCode,
135
- code: rfc,
136
- },
137
- identities: [
138
- {
139
- key: "mx-cfdi-fiscal-regime",
140
- code: fiscalRegimenCode,
141
- },
142
- {
143
- key: "mx-cfdi-use",
144
- code: cfdiUseCode,
145
- },
146
- ],
147
- },
148
- lines: [
149
- {
150
- i: 1,
151
- quantity: "1",
152
- item: {
153
- name: "Facilitación de Compra-Venta de Activos Virtuales",
154
- identities: [{ key: "mx-cfdi-prod-serv", code: "80151500" }],
155
- price: !isUSDOrder
156
- ? (_r = order.actualFees.platformFeeFiat) === null || _r === void 0 ? void 0 : _r.toFixed(2)
157
- : ((order.actualFees.platformFeeFiat || 0) *
158
- marketData.previousDayConversionRatesFromUSD.MXN.value).toFixed(2),
159
- },
160
- taxes: [
161
- {
162
- cat: "VAT",
163
- rate: order.actualFees.platformFeeFiatTax
164
- ? "standard"
165
- : "zero",
166
- },
167
- ],
168
- },
169
- ],
170
- payment: {
171
- instructions: {
172
- key: "credit-transfer",
173
- },
174
- },
175
- },
176
- }, {
177
- headers: {
178
- Authorization: `Bearer ${this.apiKey}`,
179
- },
180
- });
181
- return data;
182
- });
183
- }
184
- getJob(id) {
185
- return __awaiter(this, void 0, void 0, function* () {
186
- const { data } = yield axios_1.default.get(`${this.baseUrl}/transform/v1/jobs/${id}`, {
187
- headers: {
188
- Authorization: `Bearer ${this.apiKey}`,
189
- },
190
- });
191
- if (data.status === "OK") {
192
- const xmlAttachment = data.attachments.find((attachment) => attachment.mime === "text/xml; charset=utf-8");
193
- const pdfAttachment = data.attachments.find((attachment) => attachment.mime === "application/pdf");
194
- if (!xmlAttachment || !pdfAttachment) {
195
- throw new Error("An attachment was not found");
196
- }
197
- return {
198
- status: "completed",
199
- pdfUrl: pdfAttachment.url,
200
- xmlUrl: xmlAttachment.url,
201
- };
202
- }
203
- else if (data.status === "KO") {
204
- return {
205
- status: "failed",
206
- };
207
- }
208
- else {
209
- return {
210
- status: "pending",
211
- };
212
- }
213
- });
214
- }
215
- }
216
- const buildInvopopClient = () => __awaiter(void 0, void 0, void 0, function* () {
217
- // Retrieve secrets asynchronously
218
- const INVOPOP_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("INVOPOP_API_KEY");
219
- if (!INVOPOP_API_KEY) {
220
- throw new common_1.SecretManagerError();
221
- }
222
- // Create GuenoClient instance and return
223
- return new InvopopClient(INVOPOP_API_KEY);
224
- });
225
- exports.buildInvopopClient = buildInvopopClient;
@@ -1,13 +0,0 @@
1
- import { KapstarInvoiceResponse, User } from "@riocrypto/common";
2
- import { Axios } from "axios";
3
- declare class KapstarClient {
4
- private userId;
5
- private apiKey;
6
- axiosInstance: Axios;
7
- constructor(userId: string, apiKey: string);
8
- getBRLExchangeRateUSD(): Promise<number>;
9
- createInvoice(amount: number, orderId: string, user: User): Promise<KapstarInvoiceResponse>;
10
- createPIXPayment(amount: number, pixKey: string): Promise<KapstarInvoiceResponse>;
11
- }
12
- export declare const buildKapstarClient: () => Promise<KapstarClient>;
13
- export {};
@@ -1,71 +0,0 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.buildKapstarClient = void 0;
16
- const common_1 = require("@riocrypto/common");
17
- const axios_1 = __importDefault(require("axios"));
18
- const secret_manager_client_1 = require("./secret-manager-client");
19
- class KapstarClient {
20
- constructor(userId, apiKey) {
21
- this.userId = userId;
22
- this.apiKey = apiKey;
23
- this.axiosInstance = axios_1.default.create({
24
- baseURL: `https://api.ecsa.finance`,
25
- headers: {
26
- "User-Id": this.userId,
27
- "X-Api-key": this.apiKey,
28
- },
29
- });
30
- }
31
- getBRLExchangeRateUSD() {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- const kapstarResponse = yield this.axiosInstance.get("/quotation-service/v1/quotation/last");
34
- return 1 / kapstarResponse.data;
35
- });
36
- }
37
- createInvoice(amount, orderId, user) {
38
- var _a, _b;
39
- return __awaiter(this, void 0, void 0, function* () {
40
- const kapstarResponse = yield this.axiosInstance.post("/transaction-service/v1/external/invoice", {
41
- amount,
42
- name: (0, common_1.getUserName)(user),
43
- tags: [orderId],
44
- tax_id: (_b = (_a = user.onboarding) === null || _a === void 0 ? void 0 : _a.BR) === null || _b === void 0 ? void 0 : _b.taxId,
45
- });
46
- return kapstarResponse.data;
47
- });
48
- }
49
- createPIXPayment(amount, pixKey) {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- const kapstarResponse = yield axios_1.default.post("/transaction-service/v1/external/pix-payment", {
52
- amount: amount,
53
- pix_key: pixKey,
54
- });
55
- return kapstarResponse.data;
56
- });
57
- }
58
- }
59
- const buildKapstarClient = () => __awaiter(void 0, void 0, void 0, function* () {
60
- const KAPSTAR_USER_ID = yield secret_manager_client_1.secretManagerClient.getSecretValue("KAPSTAR_USER_ID");
61
- if (!KAPSTAR_USER_ID) {
62
- throw new Error("Unable to get KAPSTAR_USER_ID");
63
- }
64
- const KAPSTAR_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("KAPSTAR_API_KEY");
65
- if (!KAPSTAR_API_KEY) {
66
- throw new Error("Unable to get KAPSTAR_API_KEY");
67
- }
68
- const kapstarClient = new KapstarClient(KAPSTAR_USER_ID, KAPSTAR_API_KEY);
69
- return kapstarClient;
70
- });
71
- exports.buildKapstarClient = buildKapstarClient;
@@ -1,13 +0,0 @@
1
- import { User } from "@riocrypto/common";
2
- declare class KillbClient {
3
- private apiKey;
4
- private username;
5
- private password;
6
- private baseUrl;
7
- constructor(apiKey: string, username: string, password: string);
8
- getBearerToken(): Promise<string>;
9
- createUser(user: User): Promise<string>;
10
- formatDateToYYYYMMDD(date: Date): string;
11
- }
12
- export declare const buildKillbClient: () => Promise<KillbClient>;
13
- export {};
@@ -1,76 +0,0 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.buildKillbClient = void 0;
16
- const secret_manager_client_1 = require("./secret-manager-client");
17
- const axios_1 = __importDefault(require("axios"));
18
- const common_1 = require("@riocrypto/common");
19
- class KillbClient {
20
- constructor(apiKey, username, password) {
21
- this.apiKey = apiKey;
22
- this.username = username;
23
- this.password = password;
24
- if ([common_1.RioEnv.Production, common_1.RioEnv.Staging].includes(process.env.RIO_ENV)) {
25
- this.baseUrl = "https://sandbox.killb.app";
26
- }
27
- else {
28
- this.baseUrl = "https://sandbox.killb.app";
29
- }
30
- }
31
- getBearerToken() {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- const { data } = yield axios_1.default.post(`${this.baseUrl}/api/v1/auth/login`, {
34
- email: this.username,
35
- paassword: this.password,
36
- }, {
37
- headers: {
38
- "Api-Key": this.apiKey,
39
- },
40
- });
41
- return data.data.accessToken;
42
- });
43
- }
44
- createUser(user) {
45
- return __awaiter(this, void 0, void 0, function* () {
46
- const dateOfBirth = this.formatDateToYYYYMMDD(new Date(user.individualData.birthday));
47
- const { data } = yield axios_1.default.post(`${this.baseUrl}/api/v1/auth/login`, {
48
- email: this.username,
49
- paassword: this.password,
50
- }, {
51
- headers: {
52
- "Api-Key": this.apiKey,
53
- },
54
- });
55
- return data.data.accessToken;
56
- });
57
- }
58
- formatDateToYYYYMMDD(date) {
59
- const year = date.getFullYear();
60
- const month = (date.getMonth() + 1).toString().padStart(2, "0"); // Month is zero-based
61
- const day = date.getDate().toString().padStart(2, "0");
62
- return `${year}-${month}-${day}`;
63
- }
64
- }
65
- const buildKillbClient = () => __awaiter(void 0, void 0, void 0, function* () {
66
- // Retrieve secrets asynchronously
67
- const KILLB_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("KILLB_API_KEY");
68
- const KILLB_USERNAME = yield secret_manager_client_1.secretManagerClient.getSecretValue("KILLB_USERNAME");
69
- const KILLB_PASSWORD = yield secret_manager_client_1.secretManagerClient.getSecretValue("KILLB_PASSWORD");
70
- if (!KILLB_API_KEY || !KILLB_USERNAME || !KILLB_PASSWORD) {
71
- throw new common_1.SecretManagerError();
72
- }
73
- // Create GuenoClient instance and return
74
- return new KillbClient(KILLB_API_KEY, KILLB_USERNAME, KILLB_PASSWORD);
75
- });
76
- exports.buildKillbClient = buildKillbClient;
@@ -1,11 +0,0 @@
1
- import { Fiat } from "@riocrypto/common";
2
- declare class PolygonClient {
3
- private apiKey;
4
- constructor(apiKey: string);
5
- getExchangeRateData(from: Fiat, to: Fiat): Promise<{
6
- ask: number;
7
- bid: number;
8
- }>;
9
- }
10
- export declare const buildPolygonClient: () => Promise<PolygonClient>;
11
- export {};
@@ -1,38 +0,0 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.buildPolygonClient = void 0;
16
- const common_1 = require("@riocrypto/common");
17
- const axios_1 = __importDefault(require("axios"));
18
- const secret_manager_client_1 = require("./secret-manager-client");
19
- class PolygonClient {
20
- constructor(apiKey) {
21
- this.apiKey = apiKey;
22
- }
23
- getExchangeRateData(from, to) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- const { data } = yield axios_1.default.get(`https://api.polygon.io/v1/last_quote/currencies/${from}/${to}?apiKey=${this.apiKey}`);
26
- return data.last;
27
- });
28
- }
29
- }
30
- const buildPolygonClient = () => __awaiter(void 0, void 0, void 0, function* () {
31
- const POLYGON_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("POLYGON_API_KEY");
32
- if (!POLYGON_API_KEY) {
33
- throw new common_1.SecretManagerError();
34
- }
35
- // Create FixerClient instance and return
36
- return new PolygonClient(POLYGON_API_KEY);
37
- });
38
- exports.buildPolygonClient = buildPolygonClient;
@@ -1,8 +0,0 @@
1
- import { Fiat } from "@riocrypto/common";
2
- import { Mongoose } from "mongoose";
3
- export declare const getPolygonExchangeRates: (mongoose: Mongoose, fiat: Fiat) => Promise<{
4
- conversionRateToUSD: number;
5
- conversionRateToUSDWithMarkups?: number | undefined;
6
- conversionRateFromUSD: number;
7
- conversionRateFromUSDWithMarkups?: number | undefined;
8
- }>;
@@ -1,34 +0,0 @@
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.getPolygonExchangeRates = void 0;
13
- const common_1 = require("@riocrypto/common");
14
- const polygon_client_1 = require("../clients/polygon-client");
15
- const rio_settings_1 = require("../models/rio-settings");
16
- const getPolygonExchangeRates = (mongoose, fiat) => __awaiter(void 0, void 0, void 0, function* () {
17
- const RioSettings = (0, rio_settings_1.buildRioSettings)(mongoose);
18
- const rioSettings = yield RioSettings.findOne();
19
- if (!rioSettings) {
20
- throw new Error("Rio settings not found");
21
- }
22
- const polygonClient = yield (0, polygon_client_1.buildPolygonClient)();
23
- const conversionRateToUSD = fiat === common_1.Fiat.PEN
24
- ? (yield polygonClient.getExchangeRateData(fiat, common_1.Fiat.USD)).bid
25
- : (yield polygonClient.getExchangeRateData(fiat, common_1.Fiat.USD)).ask;
26
- let conversionRateFromUSD = fiat === common_1.Fiat.BRL
27
- ? 1 / conversionRateToUSD
28
- : (yield polygonClient.getExchangeRateData(common_1.Fiat.USD, fiat)).bid;
29
- return {
30
- conversionRateToUSD,
31
- conversionRateFromUSD,
32
- };
33
- });
34
- exports.getPolygonExchangeRates = getPolygonExchangeRates;
@@ -1,27 +0,0 @@
1
- /// <reference types="mongoose/types/aggregate" />
2
- /// <reference types="mongoose/types/callback" />
3
- /// <reference types="mongoose/types/collection" />
4
- /// <reference types="mongoose/types/connection" />
5
- /// <reference types="mongoose/types/cursor" />
6
- /// <reference types="mongoose/types/document" />
7
- /// <reference types="mongoose/types/error" />
8
- /// <reference types="mongoose/types/expressions" />
9
- /// <reference types="mongoose/types/helpers" />
10
- /// <reference types="mongoose/types/middlewares" />
11
- /// <reference types="mongoose/types/indexes" />
12
- /// <reference types="mongoose/types/models" />
13
- /// <reference types="mongoose/types/mongooseoptions" />
14
- /// <reference types="mongoose/types/pipelinestage" />
15
- /// <reference types="mongoose/types/populate" />
16
- /// <reference types="mongoose/types/query" />
17
- /// <reference types="mongoose/types/schemaoptions" />
18
- /// <reference types="mongoose/types/schematypes" />
19
- /// <reference types="mongoose/types/session" />
20
- /// <reference types="mongoose/types/types" />
21
- /// <reference types="mongoose/types/utility" />
22
- /// <reference types="mongoose/types/validation" />
23
- /// <reference types="mongoose/types/virtuals" />
24
- /// <reference types="mongoose" />
25
- /// <reference types="mongoose/types/inferschematype" />
26
- import { ChainedOrderDoc } from "../models/chained-order";
27
- export declare const sanitizeChainedOrderDoc: (doc: ChainedOrderDoc) => import("mongoose").FlattenMaps<any>;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sanitizeChainedOrderDoc = void 0;
4
- const sanitizeChainedOrderDoc = (doc) => {
5
- const obj = doc.toJSON();
6
- delete obj.originOrderProcessor;
7
- delete obj.destinationOrderProcessor;
8
- return obj;
9
- };
10
- exports.sanitizeChainedOrderDoc = sanitizeChainedOrderDoc;
@@ -1,27 +0,0 @@
1
- /// <reference types="mongoose/types/aggregate" />
2
- /// <reference types="mongoose/types/callback" />
3
- /// <reference types="mongoose/types/collection" />
4
- /// <reference types="mongoose/types/connection" />
5
- /// <reference types="mongoose/types/cursor" />
6
- /// <reference types="mongoose/types/document" />
7
- /// <reference types="mongoose/types/error" />
8
- /// <reference types="mongoose/types/expressions" />
9
- /// <reference types="mongoose/types/helpers" />
10
- /// <reference types="mongoose/types/middlewares" />
11
- /// <reference types="mongoose/types/indexes" />
12
- /// <reference types="mongoose/types/models" />
13
- /// <reference types="mongoose/types/mongooseoptions" />
14
- /// <reference types="mongoose/types/pipelinestage" />
15
- /// <reference types="mongoose/types/populate" />
16
- /// <reference types="mongoose/types/query" />
17
- /// <reference types="mongoose/types/schemaoptions" />
18
- /// <reference types="mongoose/types/schematypes" />
19
- /// <reference types="mongoose/types/session" />
20
- /// <reference types="mongoose/types/types" />
21
- /// <reference types="mongoose/types/utility" />
22
- /// <reference types="mongoose/types/validation" />
23
- /// <reference types="mongoose/types/virtuals" />
24
- /// <reference types="mongoose" />
25
- /// <reference types="mongoose/types/inferschematype" />
26
- import { OrderDoc } from "../models/order";
27
- export declare const sanitizeOrderDoc: (doc: OrderDoc) => import("mongoose").FlattenMaps<any>;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sanitizeOrderDoc = void 0;
4
- const sanitizeOrderDoc = (doc) => {
5
- const obj = doc.toJSON();
6
- delete obj.substatus;
7
- delete obj.liquidityProvider;
8
- delete obj.processor;
9
- delete obj.actualFees;
10
- delete obj.conversionRateUSD;
11
- delete obj.conversionRateUSDWithMarkups;
12
- delete obj.actualConversionRateUSD;
13
- delete obj.managedWallet;
14
- delete obj.exchangeRateOrders;
15
- delete obj.autoFXDisabled;
16
- delete obj.discount;
17
- delete obj.markup;
18
- return obj;
19
- };
20
- exports.sanitizeOrderDoc = sanitizeOrderDoc;
@@ -1,27 +0,0 @@
1
- /// <reference types="mongoose/types/aggregate" />
2
- /// <reference types="mongoose/types/callback" />
3
- /// <reference types="mongoose/types/collection" />
4
- /// <reference types="mongoose/types/connection" />
5
- /// <reference types="mongoose/types/cursor" />
6
- /// <reference types="mongoose/types/document" />
7
- /// <reference types="mongoose/types/error" />
8
- /// <reference types="mongoose/types/expressions" />
9
- /// <reference types="mongoose/types/helpers" />
10
- /// <reference types="mongoose/types/middlewares" />
11
- /// <reference types="mongoose/types/indexes" />
12
- /// <reference types="mongoose/types/models" />
13
- /// <reference types="mongoose/types/mongooseoptions" />
14
- /// <reference types="mongoose/types/pipelinestage" />
15
- /// <reference types="mongoose/types/populate" />
16
- /// <reference types="mongoose/types/query" />
17
- /// <reference types="mongoose/types/schemaoptions" />
18
- /// <reference types="mongoose/types/schematypes" />
19
- /// <reference types="mongoose/types/session" />
20
- /// <reference types="mongoose/types/types" />
21
- /// <reference types="mongoose/types/utility" />
22
- /// <reference types="mongoose/types/validation" />
23
- /// <reference types="mongoose/types/virtuals" />
24
- /// <reference types="mongoose" />
25
- /// <reference types="mongoose/types/inferschematype" />
26
- import { QuoteDoc } from "../models/quote";
27
- export declare const sanitizeQuoteDoc: (doc: QuoteDoc) => import("mongoose").FlattenMaps<any>;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sanitizeQuoteDoc = void 0;
4
- const sanitizeQuoteDoc = (doc) => {
5
- const obj = doc.toJSON();
6
- delete obj.liquidityProvider;
7
- delete obj.processor;
8
- delete obj.noMarkups;
9
- delete obj.conversionRateUSD;
10
- delete obj.conversionRateUSDWithMarkups;
11
- delete obj.discount;
12
- delete obj.markup;
13
- delete obj.isBid;
14
- delete obj.assetPriceInUSD;
15
- return obj;
16
- };
17
- exports.sanitizeQuoteDoc = sanitizeQuoteDoc;