@riocrypto/common-server 1.0.2658 → 1.0.2662
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,16 @@ 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_MAX_FEE = "1"; // 1 POL max (~$0.13) - protects against extreme gas spikes while only paying actual cost
|
|
23
|
+
const POLYGON_ASSETS = [
|
|
24
|
+
common_1.Crypto.USDCPolygon,
|
|
25
|
+
common_1.Crypto.USDTPolygon,
|
|
26
|
+
common_1.Crypto.USDCPolygonBridged,
|
|
27
|
+
common_1.Crypto.POL,
|
|
28
|
+
];
|
|
29
|
+
const isPolygonAsset = (crypto) => {
|
|
30
|
+
return POLYGON_ASSETS.includes(crypto);
|
|
31
|
+
};
|
|
22
32
|
class FireblocksApiError extends Error {
|
|
23
33
|
constructor(endpoint, method, statusCode, requestData, responseData, requestId, fireblocksCode) {
|
|
24
34
|
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 +145,10 @@ class FireblocksClient {
|
|
|
135
145
|
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local, common_1.RioEnv.Test].includes(process.env.RIO_ENV)) {
|
|
136
146
|
throw new Error("Withdrawals are disabled in sandbox mode.");
|
|
137
147
|
}
|
|
138
|
-
const response = yield this.fireblocks.createTransaction({
|
|
139
|
-
externalTxId: rioId,
|
|
140
|
-
assetId: crypto,
|
|
141
|
-
source: {
|
|
148
|
+
const response = yield this.fireblocks.createTransaction(Object.assign({ externalTxId: rioId, assetId: crypto, source: {
|
|
142
149
|
type: fireblocks_sdk_1.PeerType.VAULT_ACCOUNT,
|
|
143
150
|
id: vaultId ? vaultId : "2",
|
|
144
|
-
},
|
|
145
|
-
destination: {
|
|
151
|
+
}, destination: {
|
|
146
152
|
type: destination.fireblocksWalletId
|
|
147
153
|
? fireblocks_sdk_1.PeerType.EXTERNAL_WALLET
|
|
148
154
|
: fireblocks_sdk_1.PeerType.ONE_TIME_ADDRESS,
|
|
@@ -155,14 +161,7 @@ class FireblocksClient {
|
|
|
155
161
|
id: destination.fireblocksWalletId
|
|
156
162
|
? destination.fireblocksWalletId
|
|
157
163
|
: undefined,
|
|
158
|
-
},
|
|
159
|
-
amount: amountCrypto,
|
|
160
|
-
operation: fireblocks_sdk_1.TransactionOperation.TRANSFER,
|
|
161
|
-
note: notes,
|
|
162
|
-
feeLevel: [common_1.Crypto.USDCPolygon, common_1.Crypto.USDTPolygon].includes(crypto)
|
|
163
|
-
? fireblocks_sdk_1.FeeLevel.HIGH
|
|
164
|
-
: undefined,
|
|
165
|
-
});
|
|
164
|
+
}, amount: amountCrypto, operation: fireblocks_sdk_1.TransactionOperation.TRANSFER, note: notes }, (isPolygonAsset(crypto) ? { maxFee: POLYGON_MAX_FEE } : {})));
|
|
166
165
|
return response.id;
|
|
167
166
|
});
|
|
168
167
|
}
|
|
@@ -389,23 +388,15 @@ class FireblocksClient {
|
|
|
389
388
|
if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local, common_1.RioEnv.Test].includes(process.env.RIO_ENV)) {
|
|
390
389
|
throw new Error("External transfers are disabled in sandbox mode.");
|
|
391
390
|
}
|
|
392
|
-
const response = yield this.fireblocks.createTransaction({
|
|
393
|
-
assetId: crypto,
|
|
394
|
-
source: {
|
|
391
|
+
const response = yield this.fireblocks.createTransaction(Object.assign({ assetId: crypto, source: {
|
|
395
392
|
type: fireblocks_sdk_1.PeerType.VAULT_ACCOUNT,
|
|
396
393
|
id: sourceVaultId,
|
|
397
|
-
},
|
|
398
|
-
destination: {
|
|
394
|
+
}, destination: {
|
|
399
395
|
type: fireblocks_sdk_1.PeerType.ONE_TIME_ADDRESS,
|
|
400
396
|
oneTimeAddress: {
|
|
401
397
|
address: destinationAddress,
|
|
402
398
|
},
|
|
403
|
-
},
|
|
404
|
-
amount: amountCrypto,
|
|
405
|
-
operation: fireblocks_sdk_1.TransactionOperation.TRANSFER,
|
|
406
|
-
externalTxId: rioId,
|
|
407
|
-
note: notes,
|
|
408
|
-
});
|
|
399
|
+
}, amount: amountCrypto, operation: fireblocks_sdk_1.TransactionOperation.TRANSFER, externalTxId: rioId, note: notes }, (isPolygonAsset(crypto) ? { maxFee: POLYGON_MAX_FEE } : {})));
|
|
409
400
|
return response.id;
|
|
410
401
|
});
|
|
411
402
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2662",
|
|
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.2466",
|
|
32
32
|
"@types/express": "^4.17.13",
|
|
33
33
|
"axios": "^1.7.4",
|
|
34
34
|
"crypto-js": "^4.2.0",
|