@riocrypto/common-server 1.0.1262 → 1.0.1264

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,11 @@
1
+ import { CircleChain, User } from "@riocrypto/common";
2
+ declare class CircleClient {
3
+ private apiKey;
4
+ private baseUrl;
5
+ constructor(apiKey: string);
6
+ createAddressBookRecipient(user: User, address: string, chain: CircleChain): Promise<{
7
+ id: string;
8
+ }>;
9
+ }
10
+ export declare const buildCircleClient: () => Promise<CircleClient>;
11
+ export {};
@@ -0,0 +1,56 @@
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.buildCircleClient = 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
+ const uuid_1 = require("uuid");
20
+ class CircleClient {
21
+ constructor(apiKey) {
22
+ this.apiKey = apiKey;
23
+ this.baseUrl =
24
+ process.env.RIO_ENV === common_1.RioEnv.Production
25
+ ? "https://api.circle.com"
26
+ : "https://api-sandbox.circle.com";
27
+ }
28
+ createAddressBookRecipient(user, address, chain) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ const uuid = (0, uuid_1.v1)();
31
+ const { data } = yield axios_1.default.post(`${this.baseUrl}/v1/addressBook/recipients`, {
32
+ idempotencyKey: uuid,
33
+ chain,
34
+ address,
35
+ metadata: {
36
+ email: user.email,
37
+ },
38
+ }, {
39
+ headers: {
40
+ Authorization: `Bearer ${this.apiKey}`,
41
+ },
42
+ });
43
+ return data;
44
+ });
45
+ }
46
+ }
47
+ const buildCircleClient = () => __awaiter(void 0, void 0, void 0, function* () {
48
+ // Retrieve secrets asynchronously
49
+ const CIRCLE_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("CIRCLE_API_KEY");
50
+ if (!CIRCLE_API_KEY) {
51
+ throw new common_1.SecretManagerError();
52
+ }
53
+ // Create GuenoClient instance and return
54
+ return new CircleClient(CIRCLE_API_KEY);
55
+ });
56
+ exports.buildCircleClient = buildCircleClient;
package/build/index.d.ts CHANGED
@@ -57,6 +57,7 @@ export * from "./clients/invopop-client";
57
57
  export * from "./clients/cluster-client";
58
58
  export * from "./clients/cosigner-client";
59
59
  export * from "./clients/bitso-client";
60
+ export * from "./clients/circle-client";
60
61
  export * from "./helpers/get-user-helper";
61
62
  export * from "./helpers/get-processor-fees";
62
63
  export * from "./helpers/get-network-fees";
package/build/index.js CHANGED
@@ -73,6 +73,7 @@ __exportStar(require("./clients/invopop-client"), exports);
73
73
  __exportStar(require("./clients/cluster-client"), exports);
74
74
  __exportStar(require("./clients/cosigner-client"), exports);
75
75
  __exportStar(require("./clients/bitso-client"), exports);
76
+ __exportStar(require("./clients/circle-client"), exports);
76
77
  __exportStar(require("./helpers/get-user-helper"), exports);
77
78
  __exportStar(require("./helpers/get-processor-fees"), exports);
78
79
  __exportStar(require("./helpers/get-network-fees"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1262",
3
+ "version": "1.0.1264",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -27,7 +27,7 @@
27
27
  "@everapi/currencyapi-js": "^1.0.6",
28
28
  "@google-cloud/storage": "^6.9.5",
29
29
  "@google-cloud/vision": "^4.0.2",
30
- "@riocrypto/common": "^1.0.1143",
30
+ "@riocrypto/common": "^1.0.1144",
31
31
  "@types/express": "^4.17.13",
32
32
  "axios": "^0.27.2",
33
33
  "ccxt": "^3.0.30",