@arbiwallet/contracts 1.0.202 → 1.0.203

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.
@@ -6,26 +6,29 @@
6
6
 
7
7
  /* eslint-disable */
8
8
  import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
9
+ import { wrappers } from "protobufjs";
9
10
  import { Observable } from "rxjs";
11
+ import { Struct } from "./google/protobuf/struct";
10
12
 
11
13
  export const protobufPackage = "exchange_rates";
12
14
 
13
15
  export interface CalculateExchangeRequest {
14
- managerUserId: number;
16
+ managerUserId: string;
17
+ managerId?: string | undefined;
15
18
  inputCurrency: string;
16
19
  outputCurrency: string;
17
20
  currencyForAmount: string;
18
21
  amount: number;
19
22
  adjustment?: number | undefined;
20
23
  promoDiscount?: number | undefined;
21
- customerId?: number | undefined;
24
+ customerId?: string | undefined;
22
25
  disableRounding?: boolean | undefined;
23
26
  fixedRate?: number | undefined;
24
27
  }
25
28
 
26
- export interface CalculateExchangeResponse {
29
+ export interface CalculateExchangeResult {
27
30
  result: boolean;
28
- calculationId?: number | undefined;
31
+ calculationId?: string | undefined;
29
32
  inputCurrencyQuantity: number;
30
33
  outputCurrencyQuantity: number;
31
34
  exchangeRateForMessage: string;
@@ -34,21 +37,28 @@ export interface CalculateExchangeResponse {
34
37
  finalPercent: number;
35
38
  adjustment: number;
36
39
  hasCustomer: boolean;
37
- customerId?: number | undefined;
40
+ customerId?: string | undefined;
38
41
  availableAgents: number[];
39
42
  }
40
43
 
44
+ export interface CalculateExchangeResponse {
45
+ ok: boolean;
46
+ result?: CalculateExchangeResult | undefined;
47
+ error?: string | undefined;
48
+ validationErrors?: { [key: string]: any } | undefined;
49
+ }
50
+
41
51
  export interface GetExchangeCalculationRequest {
42
- calculationId?: number | undefined;
52
+ calculationId: string;
43
53
  }
44
54
 
45
55
  export interface ExchangeCalculation {
46
- id: number;
47
- customerId?: number | undefined;
48
- managerId?: number | undefined;
49
- inputCurrencyId: number;
50
- outputCurrencyId: number;
51
- currencyForAmountId: number;
56
+ id: string;
57
+ customerId?: string | undefined;
58
+ managerId?: string | undefined;
59
+ inputCurrencyId: string;
60
+ outputCurrencyId: string;
61
+ currencyForAmountId: string;
52
62
  amount: number;
53
63
  inputCurrencyQuantity: number;
54
64
  outputCurrencyQuantity: number;
@@ -62,25 +72,32 @@ export interface ExchangeCalculation {
62
72
  }
63
73
 
64
74
  export interface GetExchangeCalculationResponse {
65
- result: boolean;
75
+ ok: boolean;
66
76
  calculation?: ExchangeCalculation | undefined;
77
+ error?: string | undefined;
78
+ validationErrors?: { [key: string]: any } | undefined;
67
79
  }
68
80
 
69
- export interface GetExchanheRatesRequest {
81
+ export interface GetExchangeRatesRequest {
70
82
  }
71
83
 
72
- export interface GetExchanheRatesResponse {
73
- dataJson: string;
84
+ export interface GetExchangeRatesResponse {
85
+ ok: boolean;
86
+ result?: string | undefined;
87
+ error?: string | undefined;
88
+ validationErrors?: { [key: string]: any } | undefined;
74
89
  }
75
90
 
76
91
  export const EXCHANGE_RATES_PACKAGE_NAME = "exchange_rates";
77
92
 
93
+ wrappers[".google.protobuf.Struct"] = { fromObject: Struct.wrap, toObject: Struct.unwrap } as any;
94
+
78
95
  export interface ExchangeRatesServiceClient {
79
96
  calculateExchange(request: CalculateExchangeRequest): Observable<CalculateExchangeResponse>;
80
97
 
81
98
  getExchangeCalculation(request: GetExchangeCalculationRequest): Observable<GetExchangeCalculationResponse>;
82
99
 
83
- getExchanheRates(request: GetExchanheRatesRequest): Observable<GetExchanheRatesResponse>;
100
+ getExchangeRates(request: GetExchangeRatesRequest): Observable<GetExchangeRatesResponse>;
84
101
  }
85
102
 
86
103
  export interface ExchangeRatesServiceController {
@@ -95,14 +112,14 @@ export interface ExchangeRatesServiceController {
95
112
  | Observable<GetExchangeCalculationResponse>
96
113
  | GetExchangeCalculationResponse;
97
114
 
98
- getExchanheRates(
99
- request: GetExchanheRatesRequest,
100
- ): Promise<GetExchanheRatesResponse> | Observable<GetExchanheRatesResponse> | GetExchanheRatesResponse;
115
+ getExchangeRates(
116
+ request: GetExchangeRatesRequest,
117
+ ): Promise<GetExchangeRatesResponse> | Observable<GetExchangeRatesResponse> | GetExchangeRatesResponse;
101
118
  }
102
119
 
103
120
  export function ExchangeRatesServiceControllerMethods() {
104
121
  return function (constructor: Function) {
105
- const grpcMethods: string[] = ["calculateExchange", "getExchangeCalculation", "getExchanheRates"];
122
+ const grpcMethods: string[] = ["calculateExchange", "getExchangeCalculation", "getExchangeRates"];
106
123
  for (const method of grpcMethods) {
107
124
  const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
108
125
  GrpcMethod("ExchangeRatesService", method)(constructor.prototype[method], method, descriptor);
@@ -0,0 +1,197 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.11.4
4
+ // protoc v7.34.0
5
+ // source: google/protobuf/struct.proto
6
+
7
+ /* eslint-disable */
8
+ import { wrappers } from "protobufjs";
9
+
10
+ export const protobufPackage = "google.protobuf";
11
+
12
+ /**
13
+ * `NullValue` is a singleton enumeration to represent the null value for the
14
+ * `Value` type union.
15
+ *
16
+ * The JSON representation for `NullValue` is JSON `null`.
17
+ */
18
+ export enum NullValue {
19
+ /** NULL_VALUE - Null value. */
20
+ NULL_VALUE = 0,
21
+ UNRECOGNIZED = -1,
22
+ }
23
+
24
+ /**
25
+ * `Struct` represents a structured data value, consisting of fields
26
+ * which map to dynamically typed values. In some languages, `Struct`
27
+ * might be supported by a native representation. For example, in
28
+ * scripting languages like JS a struct is represented as an
29
+ * object. The details of that representation are described together
30
+ * with the proto support for the language.
31
+ *
32
+ * The JSON representation for `Struct` is JSON object.
33
+ */
34
+ export interface Struct {
35
+ /** Unordered map of dynamically typed values. */
36
+ fields: { [key: string]: any | undefined };
37
+ }
38
+
39
+ export interface Struct_FieldsEntry {
40
+ key: string;
41
+ value: any | undefined;
42
+ }
43
+
44
+ /**
45
+ * `Value` represents a dynamically typed value which can be either
46
+ * null, a number, a string, a boolean, a recursive struct value, or a
47
+ * list of values. A producer of value is expected to set one of these
48
+ * variants. Absence of any variant indicates an error.
49
+ *
50
+ * The JSON representation for `Value` is JSON value.
51
+ */
52
+ export interface Value {
53
+ /** Represents a null value. */
54
+ nullValue?:
55
+ | NullValue
56
+ | undefined;
57
+ /** Represents a double value. */
58
+ numberValue?:
59
+ | number
60
+ | undefined;
61
+ /** Represents a string value. */
62
+ stringValue?:
63
+ | string
64
+ | undefined;
65
+ /** Represents a boolean value. */
66
+ boolValue?:
67
+ | boolean
68
+ | undefined;
69
+ /** Represents a structured value. */
70
+ structValue?:
71
+ | { [key: string]: any }
72
+ | undefined;
73
+ /** Represents a repeated `Value`. */
74
+ listValue?: Array<any> | undefined;
75
+ }
76
+
77
+ /**
78
+ * `ListValue` is a wrapper around a repeated field of values.
79
+ *
80
+ * The JSON representation for `ListValue` is JSON array.
81
+ */
82
+ export interface ListValue {
83
+ /** Repeated field of dynamically typed values. */
84
+ values: any[];
85
+ }
86
+
87
+ export const GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf";
88
+
89
+ function createBaseStruct(): Struct {
90
+ return { fields: {} };
91
+ }
92
+
93
+ export const Struct: MessageFns<Struct> & StructWrapperFns = {
94
+ wrap(object: { [key: string]: any } | undefined): Struct {
95
+ const struct = createBaseStruct();
96
+
97
+ if (object !== undefined) {
98
+ for (const key of globalThis.Object.keys(object)) {
99
+ struct.fields[key] = Value.wrap(object[key]);
100
+ }
101
+ }
102
+ return struct;
103
+ },
104
+
105
+ unwrap(message: Struct): { [key: string]: any } {
106
+ const object: { [key: string]: any } = {};
107
+ if (message.fields) {
108
+ for (const key of globalThis.Object.keys(message.fields)) {
109
+ object[key] = Value.unwrap(message.fields[key]);
110
+ }
111
+ }
112
+ return object;
113
+ },
114
+ };
115
+
116
+ function createBaseValue(): Value {
117
+ return {};
118
+ }
119
+
120
+ export const Value: MessageFns<Value> & AnyValueWrapperFns = {
121
+ wrap(value: any): Value {
122
+ const result = {} as any;
123
+ if (value === null) {
124
+ result.nullValue = NullValue.NULL_VALUE;
125
+ } else if (typeof value === "boolean") {
126
+ result.boolValue = value;
127
+ } else if (typeof value === "number") {
128
+ result.numberValue = value;
129
+ } else if (typeof value === "string") {
130
+ result.stringValue = value;
131
+ } else if (globalThis.Array.isArray(value)) {
132
+ result.listValue = ListValue.wrap(value);
133
+ } else if (typeof value === "object") {
134
+ result.structValue = Struct.wrap(value);
135
+ } else if (typeof value !== "undefined") {
136
+ throw new globalThis.Error("Unsupported any value type: " + typeof value);
137
+ }
138
+ return result;
139
+ },
140
+
141
+ unwrap(message: any): string | number | boolean | Object | null | Array<any> | undefined {
142
+ if (message?.hasOwnProperty("stringValue") && message.stringValue !== undefined) {
143
+ return message.stringValue;
144
+ } else if (message?.hasOwnProperty("numberValue") && message?.numberValue !== undefined) {
145
+ return message.numberValue;
146
+ } else if (message?.hasOwnProperty("boolValue") && message?.boolValue !== undefined) {
147
+ return message.boolValue;
148
+ } else if (message?.hasOwnProperty("structValue") && message?.structValue !== undefined) {
149
+ return Struct.unwrap(message.structValue as any);
150
+ } else if (message?.hasOwnProperty("listValue") && message?.listValue !== undefined) {
151
+ return ListValue.unwrap(message.listValue);
152
+ } else if (message?.hasOwnProperty("nullValue") && message?.nullValue !== undefined) {
153
+ return null;
154
+ }
155
+ return undefined;
156
+ },
157
+ };
158
+
159
+ function createBaseListValue(): ListValue {
160
+ return { values: [] };
161
+ }
162
+
163
+ export const ListValue: MessageFns<ListValue> & ListValueWrapperFns = {
164
+ wrap(array: Array<any> | undefined): ListValue {
165
+ const result = createBaseListValue();
166
+ result.values = (array ?? []).map(Value.wrap);
167
+ return result;
168
+ },
169
+
170
+ unwrap(message: ListValue): Array<any> {
171
+ if (message?.hasOwnProperty("values") && globalThis.Array.isArray(message.values)) {
172
+ return message.values.map(Value.unwrap);
173
+ } else {
174
+ return message as any;
175
+ }
176
+ },
177
+ };
178
+
179
+ wrappers[".google.protobuf.Struct"] = { fromObject: Struct.wrap, toObject: Struct.unwrap } as any;
180
+
181
+ export interface MessageFns<T> {
182
+ }
183
+
184
+ export interface StructWrapperFns {
185
+ wrap(object: { [key: string]: any } | undefined): Struct;
186
+ unwrap(message: Struct): { [key: string]: any };
187
+ }
188
+
189
+ export interface AnyValueWrapperFns {
190
+ wrap(value: any): Value;
191
+ unwrap(message: any): string | number | boolean | Object | null | Array<any> | undefined;
192
+ }
193
+
194
+ export interface ListValueWrapperFns {
195
+ wrap(array: Array<any> | undefined): ListValue;
196
+ unwrap(message: ListValue): Array<any>;
197
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arbiwallet/contracts",
3
3
  "descriptions": "Generate and manage smart contracts for ArbiWallet",
4
- "version": "1.0.202",
4
+ "version": "1.0.203",
5
5
  "scripts": {
6
6
  "generate": "protoc -I ./proto ./proto/*.proto --ts_proto_out=./gen --ts_proto_opt=nestJs=true,package=omit"
7
7
  },
@@ -2,6 +2,8 @@ syntax = "proto3";
2
2
 
3
3
  package exchange_rates;
4
4
 
5
+ import "google/protobuf/struct.proto";
6
+
5
7
  option csharp_namespace = "ExchangeRates";
6
8
  option java_multiple_files = true;
7
9
  option java_package = "com.arbiwallet.exchange.rates";
@@ -9,25 +11,27 @@ option java_package = "com.arbiwallet.exchange.rates";
9
11
  service ExchangeRatesService {
10
12
  rpc CalculateExchange(CalculateExchangeRequest) returns (CalculateExchangeResponse);
11
13
  rpc GetExchangeCalculation(GetExchangeCalculationRequest) returns (GetExchangeCalculationResponse);
12
- rpc GetExchanheRates(GetExchanheRatesRequest) returns (GetExchanheRatesResponse);
14
+ rpc GetExchangeRates(GetExchangeRatesRequest) returns (GetExchangeRatesResponse);
13
15
  }
14
16
 
15
17
  message CalculateExchangeRequest {
16
- int64 manager_user_id = 1;
17
- string input_currency = 2;
18
- string output_currency = 3;
19
- string currency_for_amount = 4;
20
- double amount = 5;
21
- optional double adjustment = 6;
22
- optional double promo_discount = 7;
23
- optional int64 customer_id = 8;
24
- optional bool disable_rounding = 9;
25
- optional double fixed_rate = 10;
18
+ string manager_user_id = 1;
19
+ optional string manager_id = 2;
20
+
21
+ string input_currency = 3;
22
+ string output_currency = 4;
23
+ string currency_for_amount = 5;
24
+ double amount = 6;
25
+ optional double adjustment = 7;
26
+ optional double promo_discount = 8;
27
+ optional string customer_id = 9;
28
+ optional bool disable_rounding = 10;
29
+ optional double fixed_rate = 11;
26
30
  }
27
31
 
28
- message CalculateExchangeResponse {
32
+ message CalculateExchangeResult {
29
33
  bool result = 1;
30
- optional int64 calculation_id = 2;
34
+ optional string calculation_id = 2;
31
35
  double input_currency_quantity = 3;
32
36
  double output_currency_quantity = 4;
33
37
  string exchange_rate_for_message = 5;
@@ -36,21 +40,28 @@ message CalculateExchangeResponse {
36
40
  double final_percent = 8;
37
41
  double adjustment = 9;
38
42
  bool has_customer = 10;
39
- optional int64 customer_id = 11;
40
- repeated int64 available_agents = 12;
43
+ optional string customer_id = 11;
44
+ repeated int32 available_agents = 12;
45
+ }
46
+
47
+ message CalculateExchangeResponse {
48
+ bool ok = 1;
49
+ optional CalculateExchangeResult result = 2;
50
+ optional string error = 3;
51
+ optional google.protobuf.Struct validationErrors = 4;
41
52
  }
42
53
 
43
54
  message GetExchangeCalculationRequest {
44
- optional int64 calculation_id = 1;
55
+ string calculation_id = 1;
45
56
  }
46
57
 
47
58
  message ExchangeCalculation {
48
- int64 id = 1;
49
- optional int64 customer_id = 2;
50
- optional int64 manager_id = 3;
51
- int64 input_currency_id = 4;
52
- int64 output_currency_id = 5;
53
- int64 currency_for_amount_id = 6;
59
+ string id = 1;
60
+ optional string customer_id = 2;
61
+ optional string manager_id = 3;
62
+ string input_currency_id = 4;
63
+ string output_currency_id = 5;
64
+ string currency_for_amount_id = 6;
54
65
  double amount = 7;
55
66
  double input_currency_quantity = 8;
56
67
  double output_currency_quantity = 9;
@@ -64,12 +75,17 @@ message ExchangeCalculation {
64
75
  }
65
76
 
66
77
  message GetExchangeCalculationResponse {
67
- bool result = 1;
78
+ bool ok = 1;
68
79
  optional ExchangeCalculation calculation = 2;
80
+ optional string error = 3;
81
+ optional google.protobuf.Struct validationErrors = 4;
69
82
  }
70
83
 
71
- message GetExchanheRatesRequest {}
84
+ message GetExchangeRatesRequest {}
72
85
 
73
- message GetExchanheRatesResponse {
74
- string data_json = 1;
86
+ message GetExchangeRatesResponse {
87
+ bool ok = 1;
88
+ optional string result = 2;
89
+ optional string error = 3;
90
+ optional google.protobuf.Struct validationErrors = 4;
75
91
  }