@riocrypto/common-server 1.0.2479 → 1.0.2481
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/clients/cluster-client.d.ts +1 -3
- package/build/clients/cluster-client.js +0 -44
- package/build/clients/fireblocks-client.d.ts +1 -1
- package/build/clients/secret-manager-client.d.ts +19 -7
- package/build/clients/secret-manager-client.js +75 -60
- package/build/index.d.ts +0 -3
- package/build/index.js +0 -3
- package/build/models/fireblocks-vault.d.ts +2 -2
- package/build/models/order.d.ts +0 -4
- package/build/models/order.js +0 -6
- package/package.json +2 -2
- package/build/models/bid.d.ts +0 -31
- package/build/models/bid.js +0 -59
- package/build/models/chained-order.d.ts +0 -65
- package/build/models/chained-order.js +0 -134
- package/build/models/chained-quote.d.ts +0 -59
- package/build/models/chained-quote.js +0 -117
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Quote, Fiat, Crypto, BitsoBankAccount, Side, Country, Order, CryptoAddress, BankAccount,
|
|
1
|
+
import { Quote, Fiat, Crypto, BitsoBankAccount, Side, Country, Order, CryptoAddress, BankAccount, AuthRole, Auth, ImportOrderData, TreasuryProvider, FXProvider, EmarketsFXTrade, ExternalTradingAlgorithm, ExternalTrade, ExternalTradeType, ExternalTradingProvider, ExternalTradingAlgorithmType, STPMXNWithdrawal, AuthPermission, DeferredPaymentType, TwoWaySettlementType, OrderType, EmarketsSettlementType, EmarketsOrderType } from "@riocrypto/common";
|
|
2
2
|
declare class ClusterClient {
|
|
3
3
|
private baseUrl;
|
|
4
4
|
private clusterApiKey;
|
|
@@ -30,8 +30,6 @@ declare class ClusterClient {
|
|
|
30
30
|
timeInForceStartsAt?: Date;
|
|
31
31
|
timeInForceEndsAt?: Date;
|
|
32
32
|
}): Promise<Quote>;
|
|
33
|
-
getNewChainedQuote(chainedOrderId: string, chainedQuote: ChainedQuote, newOriginAmount?: number): Promise<ChainedQuote>;
|
|
34
|
-
getBidQuote(userId: string, side: Side, country: Country, fiat: Fiat, crypto: Crypto, amountFiat?: number, amountCrypto?: number, USBankTransferMethod?: "ach_push" | "wire", netPrice?: string): Promise<Quote>;
|
|
35
33
|
getCryptoAddresses(userId: string, crypto: Crypto): Promise<CryptoAddress[]>;
|
|
36
34
|
createOrder({ quoteId, userAddressId, payoutBankAccountId, parentOrderId, notes, isAxeTaker, }: {
|
|
37
35
|
quoteId: string;
|
|
@@ -103,50 +103,6 @@ class ClusterClient {
|
|
|
103
103
|
return response.data.quote;
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
|
-
getNewChainedQuote(chainedOrderId, chainedQuote, newOriginAmount) {
|
|
107
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
const response = yield this.axios.post(`${this.baseUrl}/api/quotes/chained`, {
|
|
109
|
-
chainedOrderId,
|
|
110
|
-
originFiat: chainedQuote.originFiat,
|
|
111
|
-
destinationFiat: chainedQuote.destinationFiat,
|
|
112
|
-
originAmountFiat: newOriginAmount,
|
|
113
|
-
originUserId: chainedQuote.originUserId,
|
|
114
|
-
destinationUserId: chainedQuote.destinationUserId,
|
|
115
|
-
crypto: chainedQuote.crypto,
|
|
116
|
-
originCountry: chainedQuote.originCountry,
|
|
117
|
-
destinationCountry: chainedQuote.destinationCountry,
|
|
118
|
-
discount: chainedQuote.discount,
|
|
119
|
-
markup: chainedQuote.markup,
|
|
120
|
-
noMarkups: chainedQuote.noMarkups,
|
|
121
|
-
reissueAfterExpiration: chainedQuote.reissueAfterExpiration,
|
|
122
|
-
}, {
|
|
123
|
-
headers: {
|
|
124
|
-
"x-cluster-api-key": this.clusterApiKey,
|
|
125
|
-
},
|
|
126
|
-
});
|
|
127
|
-
return response.data.chainedQuote;
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
getBidQuote(userId, side, country, fiat, crypto, amountFiat, amountCrypto, USBankTransferMethod, netPrice) {
|
|
131
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
-
const response = yield this.axios.post(`${this.baseUrl}/api/quotes`, {
|
|
133
|
-
userId,
|
|
134
|
-
side,
|
|
135
|
-
crypto,
|
|
136
|
-
fiat,
|
|
137
|
-
amountFiat,
|
|
138
|
-
amountCrypto,
|
|
139
|
-
country,
|
|
140
|
-
USBankTransferMethod,
|
|
141
|
-
netPrice,
|
|
142
|
-
}, {
|
|
143
|
-
headers: {
|
|
144
|
-
"x-cluster-api-key": this.clusterApiKey,
|
|
145
|
-
},
|
|
146
|
-
});
|
|
147
|
-
return response.data.quote;
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
106
|
getCryptoAddresses(userId, crypto) {
|
|
151
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
152
108
|
const response = yield this.axios.get(`${this.baseUrl}/api/addresses?userId=${userId}&crypto=${crypto}`, {
|
|
@@ -27,7 +27,7 @@ declare class FireblocksClient {
|
|
|
27
27
|
getExchangeFiatBalance(): Promise<number>;
|
|
28
28
|
getTransactions(vaultId: string, crypto: Crypto, nextPage?: string): Promise<any>;
|
|
29
29
|
getDepositAddress(vaultId: string, crypto: Crypto): Promise<string>;
|
|
30
|
-
createVault(userId: string, name: string, type: "transactional"
|
|
30
|
+
createVault(userId: string, name: string, type: "transactional", number?: number): Promise<string>;
|
|
31
31
|
createWallet(vaultId: string, crypto: Crypto): Promise<string>;
|
|
32
32
|
internalTransfer(rioId: string, crypto: Crypto, sourceVaultId: string, destinationVaultId: string, amountCrypto: number, notes?: string): Promise<string>;
|
|
33
33
|
externalTransfer(rioId: string, crypto: Crypto, sourceVaultId: string, destinationAddress: string, amountCrypto: number, notes?: string): Promise<string>;
|
|
@@ -8,22 +8,34 @@ declare class SecretManagerClient {
|
|
|
8
8
|
private readonly POLL_INTERVAL_MS;
|
|
9
9
|
constructor(env: RioEnv);
|
|
10
10
|
/**
|
|
11
|
-
* Get a secret value from cache or fetch
|
|
12
|
-
* Once fetched,
|
|
11
|
+
* Get a secret value from cache or fetch the entire secret file
|
|
12
|
+
* Once fetched, all secrets are cached and automatically refreshed every hour
|
|
13
13
|
*/
|
|
14
14
|
getSecretValue(secretId: string): Promise<string | null>;
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Refresh the entire secret cache by fetching the complete secret file
|
|
17
17
|
*/
|
|
18
|
-
private
|
|
18
|
+
private refreshSecretCache;
|
|
19
19
|
/**
|
|
20
|
-
* Set up cache
|
|
20
|
+
* Set up cache with polling for the entire secret file
|
|
21
21
|
*/
|
|
22
22
|
private setupCacheWithPolling;
|
|
23
23
|
/**
|
|
24
|
-
* Clear the
|
|
24
|
+
* Clear the entire secret cache
|
|
25
25
|
*/
|
|
26
|
-
clearCache(
|
|
26
|
+
clearCache(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Get all cached secrets (useful for debugging)
|
|
29
|
+
*/
|
|
30
|
+
getAllSecrets(): Record<string, string> | null;
|
|
31
|
+
/**
|
|
32
|
+
* Get cache status information
|
|
33
|
+
*/
|
|
34
|
+
getCacheStatus(): {
|
|
35
|
+
isLoaded: boolean;
|
|
36
|
+
secretCount: number;
|
|
37
|
+
lastFetched: Date | null;
|
|
38
|
+
};
|
|
27
39
|
}
|
|
28
40
|
export declare const secretManagerClient: SecretManagerClient;
|
|
29
41
|
export {};
|
|
@@ -39,7 +39,7 @@ const fs = __importStar(require("fs"));
|
|
|
39
39
|
class SecretManagerClient {
|
|
40
40
|
constructor(env) {
|
|
41
41
|
this.env = env;
|
|
42
|
-
this.secretCache =
|
|
42
|
+
this.secretCache = null;
|
|
43
43
|
this.POLL_INTERVAL_MS = 60 * 60 * 1000; // 1 hour
|
|
44
44
|
const secretFilePath = "/etc/secrets/secret-manager/secret-manager-service-account-key.json";
|
|
45
45
|
const secretFileContents = fs.readFileSync(secretFilePath, "utf8");
|
|
@@ -56,29 +56,34 @@ class SecretManagerClient {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
|
-
* Get a secret value from cache or fetch
|
|
60
|
-
* Once fetched,
|
|
59
|
+
* Get a secret value from cache or fetch the entire secret file
|
|
60
|
+
* Once fetched, all secrets are cached and automatically refreshed every hour
|
|
61
61
|
*/
|
|
62
62
|
getSecretValue(secretId) {
|
|
63
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
// Check if
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return cachedSecret.value;
|
|
64
|
+
// Check if we have a cache and the secret exists
|
|
65
|
+
if (this.secretCache && this.secretCache.secrets[secretId]) {
|
|
66
|
+
return this.secretCache.secrets[secretId];
|
|
68
67
|
}
|
|
69
|
-
// If not in cache, fetch
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
72
|
-
|
|
68
|
+
// If not in cache or cache doesn't exist, fetch entire secret file
|
|
69
|
+
const success = yield this.refreshSecretCache();
|
|
70
|
+
if (!success) {
|
|
71
|
+
return null;
|
|
73
72
|
}
|
|
74
|
-
|
|
73
|
+
// Check again after refresh
|
|
74
|
+
if (this.secretCache && this.secretCache.secrets[secretId]) {
|
|
75
|
+
return this.secretCache.secrets[secretId];
|
|
76
|
+
}
|
|
77
|
+
// Secret not found even after refresh
|
|
78
|
+
console.error(`Secret ${secretId} not found in secret file`);
|
|
79
|
+
return null;
|
|
75
80
|
});
|
|
76
81
|
}
|
|
77
82
|
/**
|
|
78
|
-
*
|
|
83
|
+
* Refresh the entire secret cache by fetching the complete secret file
|
|
79
84
|
*/
|
|
80
|
-
|
|
81
|
-
var _a, _b;
|
|
85
|
+
refreshSecretCache() {
|
|
86
|
+
var _a, _b, _c;
|
|
82
87
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
88
|
let file;
|
|
84
89
|
if (this.env === common_1.RioEnv.Development) {
|
|
@@ -105,7 +110,14 @@ class SecretManagerClient {
|
|
|
105
110
|
throw new Error("No payload data");
|
|
106
111
|
}
|
|
107
112
|
const secrets = JSON.parse(version.payload.data.toString());
|
|
108
|
-
|
|
113
|
+
// Clear existing polling if it exists
|
|
114
|
+
if ((_c = this.secretCache) === null || _c === void 0 ? void 0 : _c.pollingInterval) {
|
|
115
|
+
clearInterval(this.secretCache.pollingInterval);
|
|
116
|
+
}
|
|
117
|
+
// Set up new cache with polling
|
|
118
|
+
this.setupCacheWithPolling(secrets);
|
|
119
|
+
console.info(`Refreshed ${Object.keys(secrets).length} secrets from ${file}`);
|
|
120
|
+
return true;
|
|
109
121
|
}
|
|
110
122
|
catch (err) {
|
|
111
123
|
attempt++;
|
|
@@ -117,74 +129,77 @@ class SecretManagerClient {
|
|
|
117
129
|
continue;
|
|
118
130
|
}
|
|
119
131
|
else {
|
|
120
|
-
console.error(`Failed to access secret ${
|
|
121
|
-
return
|
|
132
|
+
console.error(`Failed to access secret file ${file}:`, err);
|
|
133
|
+
return false;
|
|
122
134
|
}
|
|
123
135
|
}
|
|
124
136
|
}
|
|
125
|
-
console.error(`Failed to access secret ${
|
|
126
|
-
return
|
|
137
|
+
console.error(`Failed to access secret file ${file} after ${maxRetries} attempts.`);
|
|
138
|
+
return false;
|
|
127
139
|
});
|
|
128
140
|
}
|
|
129
141
|
/**
|
|
130
|
-
* Set up cache
|
|
142
|
+
* Set up cache with polling for the entire secret file
|
|
131
143
|
*/
|
|
132
|
-
setupCacheWithPolling(
|
|
144
|
+
setupCacheWithPolling(secrets) {
|
|
133
145
|
// Only set up polling in non-test environments
|
|
134
146
|
if (process.env.NODE_ENV === "test") {
|
|
135
|
-
// For test environments, just cache the
|
|
136
|
-
this.secretCache
|
|
137
|
-
|
|
147
|
+
// For test environments, just cache the secrets without polling
|
|
148
|
+
this.secretCache = {
|
|
149
|
+
secrets,
|
|
138
150
|
pollingInterval: null,
|
|
139
|
-
|
|
151
|
+
lastFetched: new Date(),
|
|
152
|
+
};
|
|
140
153
|
return;
|
|
141
154
|
}
|
|
142
|
-
// Set up polling interval to refresh
|
|
155
|
+
// Set up polling interval to refresh all secrets
|
|
143
156
|
const pollingInterval = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
144
157
|
try {
|
|
145
|
-
const
|
|
146
|
-
if (
|
|
147
|
-
|
|
148
|
-
// Only update and log if the value has changed
|
|
149
|
-
if (currentCached && currentCached.value !== newValue) {
|
|
150
|
-
console.info(`Secret ${secretId} has been updated`);
|
|
151
|
-
this.secretCache.set(secretId, {
|
|
152
|
-
value: newValue,
|
|
153
|
-
pollingInterval: currentCached.pollingInterval,
|
|
154
|
-
});
|
|
155
|
-
}
|
|
158
|
+
const success = yield this.refreshSecretCache();
|
|
159
|
+
if (!success) {
|
|
160
|
+
console.error("Failed to refresh secret cache during polling");
|
|
156
161
|
}
|
|
157
162
|
}
|
|
158
163
|
catch (error) {
|
|
159
|
-
console.error(
|
|
164
|
+
console.error("Error polling secrets:", error);
|
|
160
165
|
}
|
|
161
166
|
}), this.POLL_INTERVAL_MS);
|
|
162
|
-
// Store the
|
|
163
|
-
this.secretCache
|
|
164
|
-
|
|
167
|
+
// Store the cache with polling interval
|
|
168
|
+
this.secretCache = {
|
|
169
|
+
secrets,
|
|
165
170
|
pollingInterval,
|
|
166
|
-
|
|
171
|
+
lastFetched: new Date(),
|
|
172
|
+
};
|
|
167
173
|
}
|
|
168
174
|
/**
|
|
169
|
-
* Clear the
|
|
175
|
+
* Clear the entire secret cache
|
|
170
176
|
*/
|
|
171
|
-
clearCache(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
clearInterval(cached.pollingInterval);
|
|
176
|
-
}
|
|
177
|
-
this.secretCache.delete(secretId);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
// Clear all cached secrets
|
|
181
|
-
this.secretCache.forEach((cached) => {
|
|
182
|
-
if (cached.pollingInterval) {
|
|
183
|
-
clearInterval(cached.pollingInterval);
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
this.secretCache.clear();
|
|
177
|
+
clearCache() {
|
|
178
|
+
var _a;
|
|
179
|
+
if ((_a = this.secretCache) === null || _a === void 0 ? void 0 : _a.pollingInterval) {
|
|
180
|
+
clearInterval(this.secretCache.pollingInterval);
|
|
187
181
|
}
|
|
182
|
+
this.secretCache = null;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Get all cached secrets (useful for debugging)
|
|
186
|
+
*/
|
|
187
|
+
getAllSecrets() {
|
|
188
|
+
var _a;
|
|
189
|
+
return ((_a = this.secretCache) === null || _a === void 0 ? void 0 : _a.secrets) || null;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Get cache status information
|
|
193
|
+
*/
|
|
194
|
+
getCacheStatus() {
|
|
195
|
+
var _a;
|
|
196
|
+
return {
|
|
197
|
+
isLoaded: !!this.secretCache,
|
|
198
|
+
secretCount: this.secretCache
|
|
199
|
+
? Object.keys(this.secretCache.secrets).length
|
|
200
|
+
: 0,
|
|
201
|
+
lastFetched: ((_a = this.secretCache) === null || _a === void 0 ? void 0 : _a.lastFetched) || null,
|
|
202
|
+
};
|
|
188
203
|
}
|
|
189
204
|
}
|
|
190
205
|
exports.secretManagerClient = new SecretManagerClient(process.env.RIO_ENV || process.env.NEXT_PUBLIC_RIO_ENV);
|
package/build/index.d.ts
CHANGED
|
@@ -40,8 +40,6 @@ export * from "./models/invoice";
|
|
|
40
40
|
export * from "./models/mismatched-bank-payment";
|
|
41
41
|
export * from "./models/bank-transfer";
|
|
42
42
|
export * from "./models/webhook-registration";
|
|
43
|
-
export * from "./models/chained-quote";
|
|
44
|
-
export * from "./models/chained-order";
|
|
45
43
|
export * from "./models/bitso-bank-account";
|
|
46
44
|
export * from "./models/bitso-receiving-account";
|
|
47
45
|
export * from "./models/bitso-fx-order";
|
|
@@ -52,7 +50,6 @@ export * from "./models/circle-payout";
|
|
|
52
50
|
export * from "./models/market-data";
|
|
53
51
|
export * from "./models/telegram-session";
|
|
54
52
|
export * from "./models/temporary-verification";
|
|
55
|
-
export * from "./models/bid";
|
|
56
53
|
export * from "./models/rio-bank-account";
|
|
57
54
|
export * from "./models/address-verification";
|
|
58
55
|
export * from "./models/bank-account-verification";
|
package/build/index.js
CHANGED
|
@@ -56,8 +56,6 @@ __exportStar(require("./models/invoice"), exports);
|
|
|
56
56
|
__exportStar(require("./models/mismatched-bank-payment"), exports);
|
|
57
57
|
__exportStar(require("./models/bank-transfer"), exports);
|
|
58
58
|
__exportStar(require("./models/webhook-registration"), exports);
|
|
59
|
-
__exportStar(require("./models/chained-quote"), exports);
|
|
60
|
-
__exportStar(require("./models/chained-order"), exports);
|
|
61
59
|
__exportStar(require("./models/bitso-bank-account"), exports);
|
|
62
60
|
__exportStar(require("./models/bitso-receiving-account"), exports);
|
|
63
61
|
__exportStar(require("./models/bitso-fx-order"), exports);
|
|
@@ -68,7 +66,6 @@ __exportStar(require("./models/circle-payout"), exports);
|
|
|
68
66
|
__exportStar(require("./models/market-data"), exports);
|
|
69
67
|
__exportStar(require("./models/telegram-session"), exports);
|
|
70
68
|
__exportStar(require("./models/temporary-verification"), exports);
|
|
71
|
-
__exportStar(require("./models/bid"), exports);
|
|
72
69
|
__exportStar(require("./models/rio-bank-account"), exports);
|
|
73
70
|
__exportStar(require("./models/address-verification"), exports);
|
|
74
71
|
__exportStar(require("./models/bank-account-verification"), exports);
|
|
@@ -2,7 +2,7 @@ import { Crypto } from "@riocrypto/common";
|
|
|
2
2
|
import mongoose from "mongoose";
|
|
3
3
|
interface FireblocksVaultAttrs {
|
|
4
4
|
userId: string;
|
|
5
|
-
type: "transactional"
|
|
5
|
+
type: "transactional";
|
|
6
6
|
fireblocksVaultId: string;
|
|
7
7
|
depositAddresses?: {
|
|
8
8
|
[key: string]: string;
|
|
@@ -18,7 +18,7 @@ interface FireblocksVaultAttrs {
|
|
|
18
18
|
}
|
|
19
19
|
interface FireblocksVaultDoc extends mongoose.Document {
|
|
20
20
|
userId: string;
|
|
21
|
-
type: "transactional"
|
|
21
|
+
type: "transactional";
|
|
22
22
|
fireblocksVaultId: string;
|
|
23
23
|
depositAddresses?: {
|
|
24
24
|
[key: string]: string;
|
package/build/models/order.d.ts
CHANGED
|
@@ -42,11 +42,9 @@ interface OrderAttrs {
|
|
|
42
42
|
markup?: number;
|
|
43
43
|
expiredQuotes?: string[];
|
|
44
44
|
imported?: boolean;
|
|
45
|
-
managedWallet?: boolean;
|
|
46
45
|
USBankTransferMethod?: "wire" | "ach_push";
|
|
47
46
|
isAfterHours?: boolean;
|
|
48
47
|
isSurgePricing?: boolean;
|
|
49
|
-
chainedOrderId?: string;
|
|
50
48
|
netPrice: number;
|
|
51
49
|
requestedNetPrice?: number;
|
|
52
50
|
payoutAddressId?: string;
|
|
@@ -173,10 +171,8 @@ interface OrderDoc extends Document {
|
|
|
173
171
|
markup?: number;
|
|
174
172
|
expiredQuotes?: string[];
|
|
175
173
|
imported?: boolean;
|
|
176
|
-
managedWallet?: boolean;
|
|
177
174
|
USBankTransferMethod?: "wire" | "ach_push";
|
|
178
175
|
isAfterHours?: boolean;
|
|
179
|
-
chainedOrderId?: string;
|
|
180
176
|
netPrice: number;
|
|
181
177
|
requestedNetPrice?: number;
|
|
182
178
|
payoutAddressId?: string;
|
package/build/models/order.js
CHANGED
|
@@ -199,18 +199,12 @@ const buildOrder = (mongoose) => {
|
|
|
199
199
|
imported: {
|
|
200
200
|
type: Boolean,
|
|
201
201
|
},
|
|
202
|
-
managedWallet: {
|
|
203
|
-
type: Boolean,
|
|
204
|
-
},
|
|
205
202
|
USBankTransferMethod: {
|
|
206
203
|
type: String,
|
|
207
204
|
},
|
|
208
205
|
isAfterHours: {
|
|
209
206
|
type: Boolean,
|
|
210
207
|
},
|
|
211
|
-
chainedOrderId: {
|
|
212
|
-
type: String,
|
|
213
|
-
},
|
|
214
208
|
exchangeRateOrders: [
|
|
215
209
|
{
|
|
216
210
|
amount: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2481",
|
|
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.
|
|
31
|
+
"@riocrypto/common": "^1.0.2249",
|
|
32
32
|
"@types/express": "^4.17.13",
|
|
33
33
|
"axios": "^1.7.4",
|
|
34
34
|
"crypto-js": "^4.2.0",
|
package/build/models/bid.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { BidStatus } from "@riocrypto/common";
|
|
2
|
-
import { Mongoose, Model, Document } from "mongoose";
|
|
3
|
-
interface BidAttrs {
|
|
4
|
-
createdAt: Date;
|
|
5
|
-
userId: string;
|
|
6
|
-
quoteId: string;
|
|
7
|
-
status: BidStatus;
|
|
8
|
-
message?: string;
|
|
9
|
-
notes?: string;
|
|
10
|
-
file?: string;
|
|
11
|
-
cryptoAddress?: string;
|
|
12
|
-
USBankTransferMethod?: "wire" | "ach_push";
|
|
13
|
-
externalAccountId?: string;
|
|
14
|
-
}
|
|
15
|
-
interface BidDoc extends Document {
|
|
16
|
-
createdAt: Date;
|
|
17
|
-
userId: string;
|
|
18
|
-
quoteId: string;
|
|
19
|
-
status: BidStatus;
|
|
20
|
-
message?: string;
|
|
21
|
-
notes?: string;
|
|
22
|
-
file?: string;
|
|
23
|
-
cryptoAddress?: string;
|
|
24
|
-
USBankTransferMethod?: "wire" | "ach_push";
|
|
25
|
-
externalAccountId?: string;
|
|
26
|
-
}
|
|
27
|
-
interface BidModel extends Model<BidDoc> {
|
|
28
|
-
build(attrs: BidAttrs): BidDoc;
|
|
29
|
-
}
|
|
30
|
-
declare const buildBid: (mongoose: Mongoose) => BidModel;
|
|
31
|
-
export { buildBid, BidDoc, BidAttrs };
|
package/build/models/bid.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildBid = void 0;
|
|
4
|
-
const buildBid = (mongoose) => {
|
|
5
|
-
// if model is already defined, return it
|
|
6
|
-
if (mongoose.models.Bid) {
|
|
7
|
-
return mongoose.model("Bid");
|
|
8
|
-
}
|
|
9
|
-
const BidSchema = new mongoose.Schema({
|
|
10
|
-
createdAt: {
|
|
11
|
-
type: mongoose.Schema.Types.Date,
|
|
12
|
-
required: true,
|
|
13
|
-
},
|
|
14
|
-
userId: {
|
|
15
|
-
type: String,
|
|
16
|
-
required: true,
|
|
17
|
-
},
|
|
18
|
-
quoteId: {
|
|
19
|
-
type: String,
|
|
20
|
-
required: true,
|
|
21
|
-
},
|
|
22
|
-
status: {
|
|
23
|
-
type: String,
|
|
24
|
-
required: true,
|
|
25
|
-
},
|
|
26
|
-
message: {
|
|
27
|
-
type: String,
|
|
28
|
-
},
|
|
29
|
-
notes: {
|
|
30
|
-
type: String,
|
|
31
|
-
},
|
|
32
|
-
file: {
|
|
33
|
-
type: String,
|
|
34
|
-
},
|
|
35
|
-
cryptoAddress: {
|
|
36
|
-
type: String,
|
|
37
|
-
},
|
|
38
|
-
USBankTransferMethod: {
|
|
39
|
-
type: String,
|
|
40
|
-
},
|
|
41
|
-
externalAccountId: {
|
|
42
|
-
type: String,
|
|
43
|
-
},
|
|
44
|
-
}, {
|
|
45
|
-
toJSON: {
|
|
46
|
-
transform(doc, ret) {
|
|
47
|
-
ret.id = ret._id.valueOf();
|
|
48
|
-
delete ret._id;
|
|
49
|
-
delete ret.__v;
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
BidSchema.statics.build = (attrs) => {
|
|
54
|
-
return new Bid(attrs);
|
|
55
|
-
};
|
|
56
|
-
const Bid = mongoose.model("Bid", BidSchema);
|
|
57
|
-
return Bid;
|
|
58
|
-
};
|
|
59
|
-
exports.buildBid = buildBid;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { Country, Fees, Fiat, Crypto, OrderStatus, Processor } from "@riocrypto/common";
|
|
2
|
-
import { Mongoose, Model, Document } from "mongoose";
|
|
3
|
-
interface ChainedOrderAttrs {
|
|
4
|
-
originUserId: string;
|
|
5
|
-
destinationUserId: string;
|
|
6
|
-
chainedQuoteId: string;
|
|
7
|
-
crypto: Crypto;
|
|
8
|
-
price: number;
|
|
9
|
-
originFiat: Fiat;
|
|
10
|
-
destinationFiat: Fiat;
|
|
11
|
-
originCountry: Country;
|
|
12
|
-
destinationCountry: Country;
|
|
13
|
-
originAmountFiat: number;
|
|
14
|
-
destinationAmountFiat: number;
|
|
15
|
-
originOrderId: string;
|
|
16
|
-
destinationOrderId: string;
|
|
17
|
-
originOrderStatus: OrderStatus;
|
|
18
|
-
destinationOrderStatus: OrderStatus;
|
|
19
|
-
originOrderProcessor: Processor;
|
|
20
|
-
destinationOrderProcessor: Processor;
|
|
21
|
-
destinationBankAccountId?: string;
|
|
22
|
-
fees: Fees;
|
|
23
|
-
createdAt: Date;
|
|
24
|
-
brokerId?: string;
|
|
25
|
-
notes?: string;
|
|
26
|
-
netPrice: number;
|
|
27
|
-
requestedNetPrice?: number;
|
|
28
|
-
markup?: number;
|
|
29
|
-
discount?: number;
|
|
30
|
-
expiredQuotes?: string[];
|
|
31
|
-
}
|
|
32
|
-
interface ChainedOrderDoc extends Document {
|
|
33
|
-
originUserId: string;
|
|
34
|
-
destinationUserId: string;
|
|
35
|
-
chainedQuoteId: string;
|
|
36
|
-
crypto: Crypto;
|
|
37
|
-
price: number;
|
|
38
|
-
originFiat: Fiat;
|
|
39
|
-
destinationFiat: Fiat;
|
|
40
|
-
originCountry: Country;
|
|
41
|
-
destinationCountry: Country;
|
|
42
|
-
originAmountFiat: number;
|
|
43
|
-
destinationAmountFiat: number;
|
|
44
|
-
originOrderId: string;
|
|
45
|
-
destinationOrderId: string;
|
|
46
|
-
originOrderStatus: OrderStatus;
|
|
47
|
-
destinationOrderStatus: OrderStatus;
|
|
48
|
-
originOrderProcessor: Processor;
|
|
49
|
-
destinationOrderProcessor: Processor;
|
|
50
|
-
destinationBankAccountId?: string;
|
|
51
|
-
fees: Fees;
|
|
52
|
-
createdAt: Date;
|
|
53
|
-
brokerId?: string;
|
|
54
|
-
notes?: string;
|
|
55
|
-
netPrice: number;
|
|
56
|
-
requestedNetPrice?: number;
|
|
57
|
-
markup?: number;
|
|
58
|
-
discount?: number;
|
|
59
|
-
expiredQuotes?: string[];
|
|
60
|
-
}
|
|
61
|
-
interface ChainedOrderModel extends Model<ChainedOrderDoc> {
|
|
62
|
-
build(attrs: ChainedOrderAttrs): ChainedOrderDoc;
|
|
63
|
-
}
|
|
64
|
-
declare const buildChainedOrder: (mongoose: Mongoose) => ChainedOrderModel;
|
|
65
|
-
export { buildChainedOrder, ChainedOrderDoc, ChainedOrderAttrs };
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildChainedOrder = void 0;
|
|
4
|
-
const buildChainedOrder = (mongoose) => {
|
|
5
|
-
// if model is already defined, return it
|
|
6
|
-
if (mongoose.models.ChainedOrder) {
|
|
7
|
-
return mongoose.model("ChainedOrder");
|
|
8
|
-
}
|
|
9
|
-
const ChainedOrderSchema = new mongoose.Schema({
|
|
10
|
-
originUserId: {
|
|
11
|
-
type: String,
|
|
12
|
-
required: true,
|
|
13
|
-
},
|
|
14
|
-
destinationUserId: {
|
|
15
|
-
type: String,
|
|
16
|
-
required: true,
|
|
17
|
-
},
|
|
18
|
-
destinationBankAccountId: {
|
|
19
|
-
type: String,
|
|
20
|
-
},
|
|
21
|
-
chainedQuoteId: {
|
|
22
|
-
type: String,
|
|
23
|
-
required: true,
|
|
24
|
-
},
|
|
25
|
-
crypto: {
|
|
26
|
-
type: String,
|
|
27
|
-
required: true,
|
|
28
|
-
},
|
|
29
|
-
price: {
|
|
30
|
-
type: Number,
|
|
31
|
-
},
|
|
32
|
-
originFiat: {
|
|
33
|
-
type: String,
|
|
34
|
-
required: true,
|
|
35
|
-
},
|
|
36
|
-
destinationFiat: {
|
|
37
|
-
type: String,
|
|
38
|
-
required: true,
|
|
39
|
-
},
|
|
40
|
-
originCountry: {
|
|
41
|
-
type: String,
|
|
42
|
-
required: true,
|
|
43
|
-
},
|
|
44
|
-
destinationCountry: {
|
|
45
|
-
type: String,
|
|
46
|
-
required: true,
|
|
47
|
-
},
|
|
48
|
-
originAmountFiat: {
|
|
49
|
-
type: Number,
|
|
50
|
-
required: true,
|
|
51
|
-
},
|
|
52
|
-
destinationAmountFiat: {
|
|
53
|
-
type: Number,
|
|
54
|
-
required: true,
|
|
55
|
-
},
|
|
56
|
-
originOrderId: {
|
|
57
|
-
type: String,
|
|
58
|
-
required: true,
|
|
59
|
-
},
|
|
60
|
-
destinationOrderId: {
|
|
61
|
-
type: String,
|
|
62
|
-
required: true,
|
|
63
|
-
},
|
|
64
|
-
originOrderStatus: {
|
|
65
|
-
type: String,
|
|
66
|
-
required: true,
|
|
67
|
-
},
|
|
68
|
-
destinationOrderStatus: {
|
|
69
|
-
type: String,
|
|
70
|
-
required: true,
|
|
71
|
-
},
|
|
72
|
-
originOrderProcessor: {
|
|
73
|
-
type: String,
|
|
74
|
-
required: true,
|
|
75
|
-
},
|
|
76
|
-
destinationOrderProcessor: {
|
|
77
|
-
type: String,
|
|
78
|
-
required: true,
|
|
79
|
-
},
|
|
80
|
-
fees: {
|
|
81
|
-
processingFeeFiat: {
|
|
82
|
-
type: Number,
|
|
83
|
-
},
|
|
84
|
-
transferFeeFiat: {
|
|
85
|
-
type: Number,
|
|
86
|
-
},
|
|
87
|
-
platformFeeFiat: {
|
|
88
|
-
type: Number,
|
|
89
|
-
},
|
|
90
|
-
platformFeeFiatTax: {
|
|
91
|
-
type: Number,
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
brokerId: {
|
|
95
|
-
type: String,
|
|
96
|
-
},
|
|
97
|
-
notes: {
|
|
98
|
-
type: String,
|
|
99
|
-
},
|
|
100
|
-
createdAt: {
|
|
101
|
-
type: mongoose.Schema.Types.Date,
|
|
102
|
-
required: true,
|
|
103
|
-
},
|
|
104
|
-
netPrice: {
|
|
105
|
-
type: Number,
|
|
106
|
-
},
|
|
107
|
-
markup: {
|
|
108
|
-
type: Number,
|
|
109
|
-
},
|
|
110
|
-
discount: {
|
|
111
|
-
type: Number,
|
|
112
|
-
},
|
|
113
|
-
expiredQuotes: {
|
|
114
|
-
type: [String],
|
|
115
|
-
},
|
|
116
|
-
requestedNetPrice: {
|
|
117
|
-
type: Number,
|
|
118
|
-
},
|
|
119
|
-
}, {
|
|
120
|
-
toJSON: {
|
|
121
|
-
transform(doc, ret) {
|
|
122
|
-
ret.id = ret._id.valueOf();
|
|
123
|
-
delete ret._id;
|
|
124
|
-
delete ret.__v;
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
ChainedOrderSchema.statics.build = (attrs) => {
|
|
129
|
-
return new ChainedOrder(attrs);
|
|
130
|
-
};
|
|
131
|
-
const ChainedOrder = mongoose.model("ChainedOrder", ChainedOrderSchema);
|
|
132
|
-
return ChainedOrder;
|
|
133
|
-
};
|
|
134
|
-
exports.buildChainedOrder = buildChainedOrder;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Country, Fees, Fiat, Crypto } from "@riocrypto/common";
|
|
2
|
-
import { Mongoose, Model, Document } from "mongoose";
|
|
3
|
-
interface ChainedQuoteAttrs {
|
|
4
|
-
originUserId: string;
|
|
5
|
-
destinationUserId: string;
|
|
6
|
-
crypto: Crypto;
|
|
7
|
-
originFiat: Fiat;
|
|
8
|
-
destinationFiat: Fiat;
|
|
9
|
-
expiresAt?: Date;
|
|
10
|
-
originCountry: Country;
|
|
11
|
-
destinationCountry: Country;
|
|
12
|
-
originAmountFiat: number;
|
|
13
|
-
destinationAmountFiat: number;
|
|
14
|
-
originQuoteId: string;
|
|
15
|
-
destinationQuoteId: string;
|
|
16
|
-
fees: Fees;
|
|
17
|
-
price: number;
|
|
18
|
-
discount?: number;
|
|
19
|
-
markup?: number;
|
|
20
|
-
noMarkups: boolean;
|
|
21
|
-
isRequote: boolean;
|
|
22
|
-
reissueAfterExpiration: boolean;
|
|
23
|
-
createdAt: Date;
|
|
24
|
-
brokerId?: string;
|
|
25
|
-
netPrice: number;
|
|
26
|
-
requestedNetPrice?: number;
|
|
27
|
-
staticAmountField: "origin" | "destination";
|
|
28
|
-
}
|
|
29
|
-
interface ChainedQuoteDoc extends Document {
|
|
30
|
-
originUserId: string;
|
|
31
|
-
destinationUserId: string;
|
|
32
|
-
crypto: Crypto;
|
|
33
|
-
originFiat: Fiat;
|
|
34
|
-
destinationFiat: Fiat;
|
|
35
|
-
expiresAt?: Date;
|
|
36
|
-
originCountry: Country;
|
|
37
|
-
destinationCountry: Country;
|
|
38
|
-
originAmountFiat: number;
|
|
39
|
-
destinationAmountFiat: number;
|
|
40
|
-
originQuoteId: string;
|
|
41
|
-
destinationQuoteId: string;
|
|
42
|
-
fees: Fees;
|
|
43
|
-
price: number;
|
|
44
|
-
discount?: number;
|
|
45
|
-
markup?: number;
|
|
46
|
-
noMarkups: boolean;
|
|
47
|
-
isRequote: boolean;
|
|
48
|
-
reissueAfterExpiration: boolean;
|
|
49
|
-
createdAt: Date;
|
|
50
|
-
brokerId?: string;
|
|
51
|
-
netPrice: number;
|
|
52
|
-
requestedNetPrice?: number;
|
|
53
|
-
staticAmountField: "origin" | "destination";
|
|
54
|
-
}
|
|
55
|
-
interface ChainedQuoteModel extends Model<ChainedQuoteDoc> {
|
|
56
|
-
build(attrs: ChainedQuoteAttrs): ChainedQuoteDoc;
|
|
57
|
-
}
|
|
58
|
-
declare const buildChainedQuote: (mongoose: Mongoose) => ChainedQuoteModel;
|
|
59
|
-
export { buildChainedQuote, ChainedQuoteDoc, ChainedQuoteAttrs };
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildChainedQuote = void 0;
|
|
4
|
-
const buildChainedQuote = (mongoose) => {
|
|
5
|
-
// if model is already defined, return it
|
|
6
|
-
if (mongoose.models.ChainedQuote) {
|
|
7
|
-
return mongoose.model("ChainedQuote");
|
|
8
|
-
}
|
|
9
|
-
const ChainedQuoteSchema = new mongoose.Schema({
|
|
10
|
-
originUserId: {
|
|
11
|
-
type: String,
|
|
12
|
-
required: true,
|
|
13
|
-
},
|
|
14
|
-
destinationUserId: {
|
|
15
|
-
type: String,
|
|
16
|
-
required: true,
|
|
17
|
-
},
|
|
18
|
-
crypto: {
|
|
19
|
-
type: String,
|
|
20
|
-
required: true,
|
|
21
|
-
},
|
|
22
|
-
originFiat: {
|
|
23
|
-
type: String,
|
|
24
|
-
required: true,
|
|
25
|
-
},
|
|
26
|
-
destinationFiat: {
|
|
27
|
-
type: String,
|
|
28
|
-
required: true,
|
|
29
|
-
},
|
|
30
|
-
expiresAt: {
|
|
31
|
-
type: mongoose.Schema.Types.Date,
|
|
32
|
-
},
|
|
33
|
-
staticAmountField: {
|
|
34
|
-
type: String,
|
|
35
|
-
},
|
|
36
|
-
originCountry: {
|
|
37
|
-
type: String,
|
|
38
|
-
required: true,
|
|
39
|
-
},
|
|
40
|
-
destinationCountry: {
|
|
41
|
-
type: String,
|
|
42
|
-
required: true,
|
|
43
|
-
},
|
|
44
|
-
originAmountFiat: {
|
|
45
|
-
type: Number,
|
|
46
|
-
required: true,
|
|
47
|
-
},
|
|
48
|
-
destinationAmountFiat: {
|
|
49
|
-
type: Number,
|
|
50
|
-
required: true,
|
|
51
|
-
},
|
|
52
|
-
originQuoteId: {
|
|
53
|
-
type: String,
|
|
54
|
-
required: true,
|
|
55
|
-
},
|
|
56
|
-
destinationQuoteId: {
|
|
57
|
-
type: String,
|
|
58
|
-
required: true,
|
|
59
|
-
},
|
|
60
|
-
fees: {
|
|
61
|
-
processingFeeFiat: {
|
|
62
|
-
type: Number,
|
|
63
|
-
},
|
|
64
|
-
transferFeeFiat: {
|
|
65
|
-
type: Number,
|
|
66
|
-
},
|
|
67
|
-
platformFeeFiat: {
|
|
68
|
-
type: Number,
|
|
69
|
-
},
|
|
70
|
-
platformFeeFiatTax: {
|
|
71
|
-
type: Number,
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
price: {
|
|
75
|
-
type: Number,
|
|
76
|
-
},
|
|
77
|
-
discount: {
|
|
78
|
-
type: Number,
|
|
79
|
-
},
|
|
80
|
-
markup: {
|
|
81
|
-
type: Number,
|
|
82
|
-
},
|
|
83
|
-
noMarkups: {
|
|
84
|
-
type: Boolean,
|
|
85
|
-
},
|
|
86
|
-
isRequote: {
|
|
87
|
-
type: Boolean,
|
|
88
|
-
},
|
|
89
|
-
brokerId: {
|
|
90
|
-
type: String,
|
|
91
|
-
},
|
|
92
|
-
createdAt: {
|
|
93
|
-
type: mongoose.Schema.Types.Date,
|
|
94
|
-
required: true,
|
|
95
|
-
},
|
|
96
|
-
netPrice: {
|
|
97
|
-
type: Number,
|
|
98
|
-
},
|
|
99
|
-
requestedNetPrice: {
|
|
100
|
-
type: Number,
|
|
101
|
-
},
|
|
102
|
-
}, {
|
|
103
|
-
toJSON: {
|
|
104
|
-
transform(doc, ret) {
|
|
105
|
-
ret.id = ret._id.valueOf();
|
|
106
|
-
delete ret._id;
|
|
107
|
-
delete ret.__v;
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
ChainedQuoteSchema.statics.build = (attrs) => {
|
|
112
|
-
return new ChainedQuote(attrs);
|
|
113
|
-
};
|
|
114
|
-
const ChainedQuote = mongoose.model("ChainedQuote", ChainedQuoteSchema);
|
|
115
|
-
return ChainedQuote;
|
|
116
|
-
};
|
|
117
|
-
exports.buildChainedQuote = buildChainedQuote;
|