@riocrypto/common-server 1.0.1627 → 1.0.1630
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,13 @@
|
|
|
1
|
+
import { Crypto } from "@riocrypto/common";
|
|
2
|
+
declare class CoincoverClient {
|
|
3
|
+
private apiKey;
|
|
4
|
+
private baseUrl;
|
|
5
|
+
private coingeckoMappings;
|
|
6
|
+
constructor(apiKey: string);
|
|
7
|
+
checkTransaction(transactionId: string, userId: string, crypto: Crypto, originVaultId: string, destinationAddress: string, amount: number): Promise<{
|
|
8
|
+
approved: boolean;
|
|
9
|
+
rejectionCode?: string;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
export declare const buildCoincoverClient: () => Promise<CoincoverClient>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
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.buildCoincoverClient = 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 CoincoverClient {
|
|
20
|
+
constructor(apiKey) {
|
|
21
|
+
this.apiKey = apiKey;
|
|
22
|
+
if ([common_1.RioEnv.Development, common_1.RioEnv.Production, common_1.RioEnv.Staging].includes(process.env.RIO_ENV)) {
|
|
23
|
+
this.baseUrl = "https://api.txm.coincover.com";
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
this.baseUrl = "https://api.txm-uat.coincover.com";
|
|
27
|
+
}
|
|
28
|
+
this.coingeckoMappings = {
|
|
29
|
+
[common_1.Crypto.BTC]: "bitcoin",
|
|
30
|
+
[common_1.Crypto.ETH]: "ethereum",
|
|
31
|
+
[common_1.Crypto.USDTEthereum]: "tether",
|
|
32
|
+
[common_1.Crypto.USDTPolygon]: "tether",
|
|
33
|
+
[common_1.Crypto.USDTTron]: "tether",
|
|
34
|
+
[common_1.Crypto.USDC]: "usd-coin",
|
|
35
|
+
[common_1.Crypto.USDCPolygon]: "usd-coin",
|
|
36
|
+
[common_1.Crypto.USDCSolana]: "usd-coin",
|
|
37
|
+
[common_1.Crypto.USDCPolygonBridged]: "usd-coin",
|
|
38
|
+
[common_1.Crypto.TRON]: "tron",
|
|
39
|
+
[common_1.Crypto.SOL]: "solana",
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
checkTransaction(transactionId, userId, crypto, originVaultId, destinationAddress, amount) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const { data } = yield axios_1.default.post(`${this.baseUrl}/transaction`, {
|
|
45
|
+
transactionCustomerId: transactionId,
|
|
46
|
+
coin: this.coingeckoMappings[crypto],
|
|
47
|
+
walletId: `${originVaultId}-${crypto}`,
|
|
48
|
+
outputs: [
|
|
49
|
+
{
|
|
50
|
+
amount: amount.toString(),
|
|
51
|
+
userId,
|
|
52
|
+
destination: destinationAddress,
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
}, {
|
|
56
|
+
headers: {
|
|
57
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
if (!data) {
|
|
61
|
+
return {
|
|
62
|
+
approved: false,
|
|
63
|
+
rejectionCode: "NO_RESPONSE",
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if (data.status === "GREEN") {
|
|
67
|
+
return {
|
|
68
|
+
approved: true,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
return {
|
|
73
|
+
approved: false,
|
|
74
|
+
rejectionCode: data.code,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const buildCoincoverClient = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
81
|
+
// Retrieve secrets asynchronously
|
|
82
|
+
const COINCOVER_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("COINCOVER_API_KEY");
|
|
83
|
+
if (!COINCOVER_API_KEY) {
|
|
84
|
+
throw new common_1.SecretManagerError();
|
|
85
|
+
}
|
|
86
|
+
// Create GuenoClient instance and return
|
|
87
|
+
return new CoincoverClient(COINCOVER_API_KEY);
|
|
88
|
+
});
|
|
89
|
+
exports.buildCoincoverClient = buildCoincoverClient;
|
package/build/index.d.ts
CHANGED
|
@@ -76,6 +76,7 @@ export * from "./clients/cosigner-client";
|
|
|
76
76
|
export * from "./clients/bitso-client";
|
|
77
77
|
export * from "./clients/circle-client";
|
|
78
78
|
export * from "./clients/polygon-client";
|
|
79
|
+
export * from "./clients/coincover-client";
|
|
79
80
|
export * from "./clients/fogbender-client";
|
|
80
81
|
export * from "./helpers/get-user-helper";
|
|
81
82
|
export * from "./helpers/get-processor-fees";
|
package/build/index.js
CHANGED
|
@@ -92,6 +92,7 @@ __exportStar(require("./clients/cosigner-client"), exports);
|
|
|
92
92
|
__exportStar(require("./clients/bitso-client"), exports);
|
|
93
93
|
__exportStar(require("./clients/circle-client"), exports);
|
|
94
94
|
__exportStar(require("./clients/polygon-client"), exports);
|
|
95
|
+
__exportStar(require("./clients/coincover-client"), exports);
|
|
95
96
|
__exportStar(require("./clients/fogbender-client"), exports);
|
|
96
97
|
__exportStar(require("./helpers/get-user-helper"), exports);
|
|
97
98
|
__exportStar(require("./helpers/get-processor-fees"), exports);
|
|
@@ -10,6 +10,7 @@ interface InternalSwapAttrs {
|
|
|
10
10
|
providerFee: number;
|
|
11
11
|
provider: SwapProvider;
|
|
12
12
|
origin: SwapOrigin;
|
|
13
|
+
destination: SwapOrigin;
|
|
13
14
|
status: "created" | "processing" | "firstLegComplete" | "complete" | "failed";
|
|
14
15
|
}
|
|
15
16
|
interface InternalSwapDoc extends Document {
|
|
@@ -22,6 +23,7 @@ interface InternalSwapDoc extends Document {
|
|
|
22
23
|
providerFee: number;
|
|
23
24
|
provider: SwapProvider;
|
|
24
25
|
origin: SwapOrigin;
|
|
26
|
+
destination: SwapOrigin;
|
|
25
27
|
status: "created" | "processing" | "firstLegComplete" | "complete" | "failed";
|
|
26
28
|
}
|
|
27
29
|
interface InternalSwapModel extends Model<InternalSwapDoc> {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1630",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@google-cloud/storage": "^6.9.5",
|
|
29
29
|
"@google-cloud/vision": "^4.0.2",
|
|
30
30
|
"@hyperdx/node-opentelemetry": "^0.4.2",
|
|
31
|
-
"@riocrypto/common": "^1.0.
|
|
31
|
+
"@riocrypto/common": "^1.0.1463",
|
|
32
32
|
"@types/express": "^4.17.13",
|
|
33
33
|
"axios": "^1.6.0",
|
|
34
34
|
"ccxt": "^3.0.30",
|