@riocrypto/common-server 1.0.1649 → 1.0.1651
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.
|
@@ -3,9 +3,9 @@ declare class CoinbaseClient {
|
|
|
3
3
|
private apiKey;
|
|
4
4
|
private baseUrl;
|
|
5
5
|
private productIdMappings;
|
|
6
|
-
constructor(apiKey: string);
|
|
6
|
+
constructor(apiKey: string, env?: "production" | "sandbox");
|
|
7
7
|
private getRequestHeaders;
|
|
8
8
|
createMarketOrder(crypto: Crypto, amount: number): Promise<any>;
|
|
9
9
|
}
|
|
10
|
-
export declare const buildCoinbaseClient: () => Promise<CoinbaseClient>;
|
|
10
|
+
export declare const buildCoinbaseClient: (env?: "production" | "sandbox") => Promise<CoinbaseClient>;
|
|
11
11
|
export {};
|
|
@@ -18,13 +18,21 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
18
18
|
const common_1 = require("@riocrypto/common");
|
|
19
19
|
const crypto_1 = require("crypto");
|
|
20
20
|
class CoinbaseClient {
|
|
21
|
-
constructor(apiKey) {
|
|
21
|
+
constructor(apiKey, env) {
|
|
22
22
|
this.apiKey = apiKey;
|
|
23
|
-
if (
|
|
24
|
-
this.baseUrl =
|
|
23
|
+
if (env) {
|
|
24
|
+
this.baseUrl =
|
|
25
|
+
env === "production"
|
|
26
|
+
? "https://api.exchange.coinbase.com"
|
|
27
|
+
: "https://api-public.sandbox.exchange.coinbase.com";
|
|
25
28
|
}
|
|
26
29
|
else {
|
|
27
|
-
|
|
30
|
+
if ([common_1.RioEnv.Development, common_1.RioEnv.Production, common_1.RioEnv.Staging].includes(process.env.RIO_ENV)) {
|
|
31
|
+
this.baseUrl = "https://api.exchange.coinbase.com";
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.baseUrl = "https://api-public.sandbox.exchange.coinbase.com";
|
|
35
|
+
}
|
|
28
36
|
}
|
|
29
37
|
this.productIdMappings = {
|
|
30
38
|
[common_1.Crypto.USDTEthereum]: "USDT-USD",
|
|
@@ -75,13 +83,13 @@ class CoinbaseClient {
|
|
|
75
83
|
});
|
|
76
84
|
}
|
|
77
85
|
}
|
|
78
|
-
const buildCoinbaseClient = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
|
+
const buildCoinbaseClient = (env) => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
87
|
// Retrieve secrets asynchronously
|
|
80
88
|
const COINBASE_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("COINBASE_API_KEY");
|
|
81
89
|
if (!COINBASE_API_KEY) {
|
|
82
90
|
throw new common_1.SecretManagerError();
|
|
83
91
|
}
|
|
84
92
|
// Create GuenoClient instance and return
|
|
85
|
-
return new CoinbaseClient(COINBASE_API_KEY);
|
|
93
|
+
return new CoinbaseClient(COINBASE_API_KEY, env);
|
|
86
94
|
});
|
|
87
95
|
exports.buildCoinbaseClient = buildCoinbaseClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1651",
|
|
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.1467",
|
|
32
32
|
"@types/express": "^4.17.13",
|
|
33
33
|
"axios": "^1.6.0",
|
|
34
34
|
"ccxt": "^3.0.30",
|