@riocrypto/common-server 1.0.1941 → 1.0.1942

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,31 @@
1
+ import mongoose from "mongoose";
2
+ import { TreasuryProvider, Fiat, Crypto, InternalTradeStatus } from "@riocrypto/common";
3
+ interface InternalTransferAttrs {
4
+ id: string;
5
+ adminId: string;
6
+ createdAt: Date;
7
+ provider: TreasuryProvider;
8
+ originAmount: number;
9
+ originCurrency: Fiat | Crypto;
10
+ destinationAmount: number;
11
+ destinationCurrency: Fiat | Crypto;
12
+ price: number;
13
+ status: InternalTradeStatus;
14
+ }
15
+ interface InternalTransferDoc extends mongoose.Document {
16
+ id: string;
17
+ adminId: string;
18
+ createdAt: Date;
19
+ provider: TreasuryProvider;
20
+ originAmount: number;
21
+ originCurrency: Fiat | Crypto;
22
+ destinationAmount: number;
23
+ destinationCurrency: Fiat | Crypto;
24
+ price: number;
25
+ status: InternalTradeStatus;
26
+ }
27
+ interface InternalTransferModel extends mongoose.Model<InternalTransferDoc> {
28
+ build(attrs: InternalTransferAttrs): InternalTransferDoc;
29
+ }
30
+ declare const buildInternalTransfer: (mongoose: typeof mongoose) => InternalTransferModel;
31
+ export { buildInternalTransfer, InternalTransferDoc, InternalTransferAttrs };
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildInternalTransfer = void 0;
4
+ const common_1 = require("@riocrypto/common");
5
+ const buildInternalTransfer = (mongoose) => {
6
+ // if model is already defined, return it
7
+ if (mongoose.models.InternalTransfer) {
8
+ return mongoose.model("InternalTransfer");
9
+ }
10
+ const InternalTransferSchema = new mongoose.Schema({
11
+ id: {
12
+ type: String,
13
+ required: true,
14
+ },
15
+ adminId: {
16
+ type: String,
17
+ required: true,
18
+ },
19
+ createdAt: {
20
+ type: Date,
21
+ required: true,
22
+ },
23
+ provider: {
24
+ type: String,
25
+ enum: Object.values(common_1.TreasuryProvider),
26
+ required: true,
27
+ },
28
+ originAmount: {
29
+ type: Number,
30
+ required: true,
31
+ },
32
+ originCurrency: {
33
+ type: String,
34
+ required: true,
35
+ },
36
+ destinationAmount: {
37
+ type: Number,
38
+ required: true,
39
+ },
40
+ destinationCurrency: {
41
+ type: String,
42
+ required: true,
43
+ },
44
+ price: {
45
+ type: Number,
46
+ required: true,
47
+ },
48
+ status: {
49
+ type: String,
50
+ enum: Object.values(common_1.InternalTradeStatus),
51
+ required: true,
52
+ },
53
+ }, {
54
+ toJSON: {
55
+ transform(doc, ret) {
56
+ ret.id = ret._id;
57
+ delete ret._id;
58
+ delete ret.__v;
59
+ },
60
+ },
61
+ });
62
+ InternalTransferSchema.statics.build = (attrs) => {
63
+ return new InternalTransfer(attrs);
64
+ };
65
+ const InternalTransfer = mongoose.model("InternalTransfer", InternalTransferSchema);
66
+ return InternalTransfer;
67
+ };
68
+ exports.buildInternalTransfer = buildInternalTransfer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1941",
3
+ "version": "1.0.1942",
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.1712",
31
+ "@riocrypto/common": "^1.0.1714",
32
32
  "@types/express": "^4.17.13",
33
33
  "axios": "^1.7.4",
34
34
  "crypto-js": "^4.2.0",