@riocrypto/common-server 1.0.2659 → 1.0.2663
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.
|
@@ -19,6 +19,20 @@ const secret_manager_client_1 = require("./secret-manager-client");
|
|
|
19
19
|
const node_cache_1 = __importDefault(require("node-cache"));
|
|
20
20
|
const cache = new node_cache_1.default({ stdTTL: 60 });
|
|
21
21
|
const cache2 = new node_cache_1.default({ stdTTL: 10000 });
|
|
22
|
+
const POLYGON_FEE_CONFIG = {
|
|
23
|
+
maxFee: "4",
|
|
24
|
+
priorityFee: "50",
|
|
25
|
+
gasLimit: "100000",
|
|
26
|
+
};
|
|
27
|
+
const POLYGON_ASSETS = [
|
|
28
|
+
common_1.Crypto.USDCPolygon,
|
|
29
|
+
common_1.Crypto.USDTPolygon,
|
|
30
|
+
common_1.Crypto.USDCPolygonBridged,
|
|
31
|
+
common_1.Crypto.POL,
|
|
32
|
+
];
|
|
33
|
+
const isPolygonAsset = (crypto) => {
|
|
34
|
+
return POLYGON_ASSETS.includes(crypto);
|
|
35
|
+
};
|
|
22
36
|
class FireblocksApiError extends Error {
|
|
23
37
|
constructor(endpoint, method, statusCode, requestData, responseData, requestId, fireblocksCode) {
|
|
24
38
|
const message = `Fireblocks API Error: ${method} ${endpoint} - Status: ${statusCode !== null && statusCode !== void 0 ? statusCode : "unknown"} - Code: ${fireblocksCode !== null && fireblocksCode !== void 0 ? fireblocksCode : "unknown"} - RequestId: ${requestId !== null && requestId !== void 0 ? requestId : "unknown"}`;
|
|
@@ -135,14 +149,10 @@ class FireblocksClient {
|
|
|
135
149
|
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local, common_1.RioEnv.Test].includes(process.env.RIO_ENV)) {
|
|
136
150
|
throw new Error("Withdrawals are disabled in sandbox mode.");
|
|
137
151
|
}
|
|
138
|
-
const response = yield this.fireblocks.createTransaction({
|
|
139
|
-
externalTxId: rioId,
|
|
140
|
-
assetId: crypto,
|
|
141
|
-
source: {
|
|
152
|
+
const response = yield this.fireblocks.createTransaction(Object.assign({ externalTxId: rioId, assetId: crypto, source: {
|
|
142
153
|
type: fireblocks_sdk_1.PeerType.VAULT_ACCOUNT,
|
|
143
154
|
id: vaultId ? vaultId : "2",
|
|
144
|
-
},
|
|
145
|
-
destination: {
|
|
155
|
+
}, destination: {
|
|
146
156
|
type: destination.fireblocksWalletId
|
|
147
157
|
? fireblocks_sdk_1.PeerType.EXTERNAL_WALLET
|
|
148
158
|
: fireblocks_sdk_1.PeerType.ONE_TIME_ADDRESS,
|
|
@@ -155,14 +165,13 @@ class FireblocksClient {
|
|
|
155
165
|
id: destination.fireblocksWalletId
|
|
156
166
|
? destination.fireblocksWalletId
|
|
157
167
|
: undefined,
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
});
|
|
168
|
+
}, amount: amountCrypto, operation: fireblocks_sdk_1.TransactionOperation.TRANSFER, note: notes }, (isPolygonAsset(crypto)
|
|
169
|
+
? {
|
|
170
|
+
maxFee: POLYGON_FEE_CONFIG.maxFee,
|
|
171
|
+
priorityFee: POLYGON_FEE_CONFIG.priorityFee,
|
|
172
|
+
gasLimit: POLYGON_FEE_CONFIG.gasLimit,
|
|
173
|
+
}
|
|
174
|
+
: {})));
|
|
166
175
|
return response.id;
|
|
167
176
|
});
|
|
168
177
|
}
|
|
@@ -389,23 +398,21 @@ class FireblocksClient {
|
|
|
389
398
|
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local, common_1.RioEnv.Test].includes(process.env.RIO_ENV)) {
|
|
390
399
|
throw new Error("External transfers are disabled in sandbox mode.");
|
|
391
400
|
}
|
|
392
|
-
const response = yield this.fireblocks.createTransaction({
|
|
393
|
-
assetId: crypto,
|
|
394
|
-
source: {
|
|
401
|
+
const response = yield this.fireblocks.createTransaction(Object.assign({ assetId: crypto, source: {
|
|
395
402
|
type: fireblocks_sdk_1.PeerType.VAULT_ACCOUNT,
|
|
396
403
|
id: sourceVaultId,
|
|
397
|
-
},
|
|
398
|
-
destination: {
|
|
404
|
+
}, destination: {
|
|
399
405
|
type: fireblocks_sdk_1.PeerType.ONE_TIME_ADDRESS,
|
|
400
406
|
oneTimeAddress: {
|
|
401
407
|
address: destinationAddress,
|
|
402
408
|
},
|
|
403
|
-
},
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
+
}, amount: amountCrypto, operation: fireblocks_sdk_1.TransactionOperation.TRANSFER, externalTxId: rioId, note: notes }, (isPolygonAsset(crypto)
|
|
410
|
+
? {
|
|
411
|
+
maxFee: POLYGON_FEE_CONFIG.maxFee,
|
|
412
|
+
priorityFee: POLYGON_FEE_CONFIG.priorityFee,
|
|
413
|
+
gasLimit: POLYGON_FEE_CONFIG.gasLimit,
|
|
414
|
+
}
|
|
415
|
+
: {})));
|
|
409
416
|
return response.id;
|
|
410
417
|
});
|
|
411
418
|
}
|