react-native-candle 0.1.50 → 0.1.51

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.
Files changed (36) hide show
  1. package/ReactNativeCandle.podspec +1 -1
  2. package/ios/Sources/Types.swift +104 -42
  3. package/lib/commonjs/types.js +46 -5
  4. package/lib/commonjs/types.js.map +1 -1
  5. package/lib/module/types.js +42 -3
  6. package/lib/module/types.js.map +1 -1
  7. package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts +23 -0
  8. package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts.map +1 -1
  9. package/lib/typescript/commonjs/src/types.d.ts +16 -3
  10. package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
  11. package/lib/typescript/module/src/specs/RNCandle.nitro.d.ts +23 -0
  12. package/lib/typescript/module/src/specs/RNCandle.nitro.d.ts.map +1 -1
  13. package/lib/typescript/module/src/types.d.ts +16 -3
  14. package/lib/typescript/module/src/types.d.ts.map +1 -1
  15. package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Bridge.hpp +90 -0
  16. package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Umbrella.hpp +15 -0
  17. package/nitrogen/generated/ios/c++/HybridRNCandleSpecSwift.hpp +24 -9
  18. package/nitrogen/generated/ios/swift/CounterpartyQuoteRequest.swift +131 -0
  19. package/nitrogen/generated/ios/swift/MerchantCounterpartyQuoteRequest.swift +66 -0
  20. package/nitrogen/generated/ios/swift/OtherAssetQuoteRequest.swift +33 -0
  21. package/nitrogen/generated/ios/swift/ServiceCounterpartyQuoteRequest.swift +34 -0
  22. package/nitrogen/generated/ios/swift/TradeAssetQuoteRequest.swift +34 -1
  23. package/nitrogen/generated/ios/swift/TradeQuote.swift +16 -2
  24. package/nitrogen/generated/ios/swift/TradeQuotesRequest.swift +34 -2
  25. package/nitrogen/generated/ios/swift/UserCounterpartyQuoteRequest.swift +96 -0
  26. package/nitrogen/generated/shared/c++/CounterpartyQuoteRequest.hpp +83 -0
  27. package/nitrogen/generated/shared/c++/MerchantCounterpartyQuoteRequest.hpp +72 -0
  28. package/nitrogen/generated/shared/c++/OtherAssetQuoteRequest.hpp +67 -0
  29. package/nitrogen/generated/shared/c++/ServiceCounterpartyQuoteRequest.hpp +67 -0
  30. package/nitrogen/generated/shared/c++/TradeAssetQuoteRequest.hpp +9 -2
  31. package/nitrogen/generated/shared/c++/TradeQuote.hpp +8 -1
  32. package/nitrogen/generated/shared/c++/TradeQuotesRequest.hpp +9 -2
  33. package/nitrogen/generated/shared/c++/UserCounterpartyQuoteRequest.hpp +76 -0
  34. package/package.json +1 -1
  35. package/src/specs/RNCandle.nitro.ts +28 -0
  36. package/src/types.ts +54 -1
@@ -26,12 +26,15 @@ namespace margelo::nitro::rncandle { struct MarketAssetQuoteRequest; }
26
26
  namespace margelo::nitro::rncandle { struct TransportAssetQuoteRequest; }
27
27
  // Forward declaration of `NothingAssetQuoteRequest` to properly resolve imports.
28
28
  namespace margelo::nitro::rncandle { struct NothingAssetQuoteRequest; }
29
+ // Forward declaration of `OtherAssetQuoteRequest` to properly resolve imports.
30
+ namespace margelo::nitro::rncandle { struct OtherAssetQuoteRequest; }
29
31
 
30
32
  #include "FiatAssetQuoteRequest.hpp"
31
33
  #include <optional>
32
34
  #include "MarketAssetQuoteRequest.hpp"
33
35
  #include "TransportAssetQuoteRequest.hpp"
34
36
  #include "NothingAssetQuoteRequest.hpp"
37
+ #include "OtherAssetQuoteRequest.hpp"
35
38
 
36
39
  namespace margelo::nitro::rncandle {
37
40
 
@@ -44,10 +47,11 @@ namespace margelo::nitro::rncandle {
44
47
  std::optional<MarketAssetQuoteRequest> marketAssetQuoteRequest SWIFT_PRIVATE;
45
48
  std::optional<TransportAssetQuoteRequest> transportAssetQuoteRequest SWIFT_PRIVATE;
46
49
  std::optional<NothingAssetQuoteRequest> nothingAssetQuoteRequest SWIFT_PRIVATE;
50
+ std::optional<OtherAssetQuoteRequest> otherAssetQuoteRequest SWIFT_PRIVATE;
47
51
 
48
52
  public:
49
53
  TradeAssetQuoteRequest() = default;
50
- explicit TradeAssetQuoteRequest(std::optional<FiatAssetQuoteRequest> fiatAssetQuoteRequest, std::optional<MarketAssetQuoteRequest> marketAssetQuoteRequest, std::optional<TransportAssetQuoteRequest> transportAssetQuoteRequest, std::optional<NothingAssetQuoteRequest> nothingAssetQuoteRequest): fiatAssetQuoteRequest(fiatAssetQuoteRequest), marketAssetQuoteRequest(marketAssetQuoteRequest), transportAssetQuoteRequest(transportAssetQuoteRequest), nothingAssetQuoteRequest(nothingAssetQuoteRequest) {}
54
+ explicit TradeAssetQuoteRequest(std::optional<FiatAssetQuoteRequest> fiatAssetQuoteRequest, std::optional<MarketAssetQuoteRequest> marketAssetQuoteRequest, std::optional<TransportAssetQuoteRequest> transportAssetQuoteRequest, std::optional<NothingAssetQuoteRequest> nothingAssetQuoteRequest, std::optional<OtherAssetQuoteRequest> otherAssetQuoteRequest): fiatAssetQuoteRequest(fiatAssetQuoteRequest), marketAssetQuoteRequest(marketAssetQuoteRequest), transportAssetQuoteRequest(transportAssetQuoteRequest), nothingAssetQuoteRequest(nothingAssetQuoteRequest), otherAssetQuoteRequest(otherAssetQuoteRequest) {}
51
55
  };
52
56
 
53
57
  } // namespace margelo::nitro::rncandle
@@ -63,7 +67,8 @@ namespace margelo::nitro {
63
67
  JSIConverter<std::optional<margelo::nitro::rncandle::FiatAssetQuoteRequest>>::fromJSI(runtime, obj.getProperty(runtime, "fiatAssetQuoteRequest")),
64
68
  JSIConverter<std::optional<margelo::nitro::rncandle::MarketAssetQuoteRequest>>::fromJSI(runtime, obj.getProperty(runtime, "marketAssetQuoteRequest")),
65
69
  JSIConverter<std::optional<margelo::nitro::rncandle::TransportAssetQuoteRequest>>::fromJSI(runtime, obj.getProperty(runtime, "transportAssetQuoteRequest")),
66
- JSIConverter<std::optional<margelo::nitro::rncandle::NothingAssetQuoteRequest>>::fromJSI(runtime, obj.getProperty(runtime, "nothingAssetQuoteRequest"))
70
+ JSIConverter<std::optional<margelo::nitro::rncandle::NothingAssetQuoteRequest>>::fromJSI(runtime, obj.getProperty(runtime, "nothingAssetQuoteRequest")),
71
+ JSIConverter<std::optional<margelo::nitro::rncandle::OtherAssetQuoteRequest>>::fromJSI(runtime, obj.getProperty(runtime, "otherAssetQuoteRequest"))
67
72
  );
68
73
  }
69
74
  static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::rncandle::TradeAssetQuoteRequest& arg) {
@@ -72,6 +77,7 @@ namespace margelo::nitro {
72
77
  obj.setProperty(runtime, "marketAssetQuoteRequest", JSIConverter<std::optional<margelo::nitro::rncandle::MarketAssetQuoteRequest>>::toJSI(runtime, arg.marketAssetQuoteRequest));
73
78
  obj.setProperty(runtime, "transportAssetQuoteRequest", JSIConverter<std::optional<margelo::nitro::rncandle::TransportAssetQuoteRequest>>::toJSI(runtime, arg.transportAssetQuoteRequest));
74
79
  obj.setProperty(runtime, "nothingAssetQuoteRequest", JSIConverter<std::optional<margelo::nitro::rncandle::NothingAssetQuoteRequest>>::toJSI(runtime, arg.nothingAssetQuoteRequest));
80
+ obj.setProperty(runtime, "otherAssetQuoteRequest", JSIConverter<std::optional<margelo::nitro::rncandle::OtherAssetQuoteRequest>>::toJSI(runtime, arg.otherAssetQuoteRequest));
75
81
  return obj;
76
82
  }
77
83
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -83,6 +89,7 @@ namespace margelo::nitro {
83
89
  if (!JSIConverter<std::optional<margelo::nitro::rncandle::MarketAssetQuoteRequest>>::canConvert(runtime, obj.getProperty(runtime, "marketAssetQuoteRequest"))) return false;
84
90
  if (!JSIConverter<std::optional<margelo::nitro::rncandle::TransportAssetQuoteRequest>>::canConvert(runtime, obj.getProperty(runtime, "transportAssetQuoteRequest"))) return false;
85
91
  if (!JSIConverter<std::optional<margelo::nitro::rncandle::NothingAssetQuoteRequest>>::canConvert(runtime, obj.getProperty(runtime, "nothingAssetQuoteRequest"))) return false;
92
+ if (!JSIConverter<std::optional<margelo::nitro::rncandle::OtherAssetQuoteRequest>>::canConvert(runtime, obj.getProperty(runtime, "otherAssetQuoteRequest"))) return false;
86
93
  return true;
87
94
  }
88
95
  };
@@ -20,8 +20,11 @@
20
20
 
21
21
  // Forward declaration of `TradeAsset` to properly resolve imports.
22
22
  namespace margelo::nitro::rncandle { struct TradeAsset; }
23
+ // Forward declaration of `Counterparty` to properly resolve imports.
24
+ namespace margelo::nitro::rncandle { struct Counterparty; }
23
25
 
24
26
  #include "TradeAsset.hpp"
27
+ #include "Counterparty.hpp"
25
28
  #include <string>
26
29
 
27
30
  namespace margelo::nitro::rncandle {
@@ -33,12 +36,13 @@ namespace margelo::nitro::rncandle {
33
36
  public:
34
37
  TradeAsset lost SWIFT_PRIVATE;
35
38
  TradeAsset gained SWIFT_PRIVATE;
39
+ Counterparty counterparty SWIFT_PRIVATE;
36
40
  std::string context SWIFT_PRIVATE;
37
41
  std::string expirationDateTime SWIFT_PRIVATE;
38
42
 
39
43
  public:
40
44
  TradeQuote() = default;
41
- explicit TradeQuote(TradeAsset lost, TradeAsset gained, std::string context, std::string expirationDateTime): lost(lost), gained(gained), context(context), expirationDateTime(expirationDateTime) {}
45
+ explicit TradeQuote(TradeAsset lost, TradeAsset gained, Counterparty counterparty, std::string context, std::string expirationDateTime): lost(lost), gained(gained), counterparty(counterparty), context(context), expirationDateTime(expirationDateTime) {}
42
46
  };
43
47
 
44
48
  } // namespace margelo::nitro::rncandle
@@ -53,6 +57,7 @@ namespace margelo::nitro {
53
57
  return margelo::nitro::rncandle::TradeQuote(
54
58
  JSIConverter<margelo::nitro::rncandle::TradeAsset>::fromJSI(runtime, obj.getProperty(runtime, "lost")),
55
59
  JSIConverter<margelo::nitro::rncandle::TradeAsset>::fromJSI(runtime, obj.getProperty(runtime, "gained")),
60
+ JSIConverter<margelo::nitro::rncandle::Counterparty>::fromJSI(runtime, obj.getProperty(runtime, "counterparty")),
56
61
  JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "context")),
57
62
  JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "expirationDateTime"))
58
63
  );
@@ -61,6 +66,7 @@ namespace margelo::nitro {
61
66
  jsi::Object obj(runtime);
62
67
  obj.setProperty(runtime, "lost", JSIConverter<margelo::nitro::rncandle::TradeAsset>::toJSI(runtime, arg.lost));
63
68
  obj.setProperty(runtime, "gained", JSIConverter<margelo::nitro::rncandle::TradeAsset>::toJSI(runtime, arg.gained));
69
+ obj.setProperty(runtime, "counterparty", JSIConverter<margelo::nitro::rncandle::Counterparty>::toJSI(runtime, arg.counterparty));
64
70
  obj.setProperty(runtime, "context", JSIConverter<std::string>::toJSI(runtime, arg.context));
65
71
  obj.setProperty(runtime, "expirationDateTime", JSIConverter<std::string>::toJSI(runtime, arg.expirationDateTime));
66
72
  return obj;
@@ -72,6 +78,7 @@ namespace margelo::nitro {
72
78
  jsi::Object obj = value.getObject(runtime);
73
79
  if (!JSIConverter<margelo::nitro::rncandle::TradeAsset>::canConvert(runtime, obj.getProperty(runtime, "lost"))) return false;
74
80
  if (!JSIConverter<margelo::nitro::rncandle::TradeAsset>::canConvert(runtime, obj.getProperty(runtime, "gained"))) return false;
81
+ if (!JSIConverter<margelo::nitro::rncandle::Counterparty>::canConvert(runtime, obj.getProperty(runtime, "counterparty"))) return false;
75
82
  if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "context"))) return false;
76
83
  if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "expirationDateTime"))) return false;
77
84
  return true;
@@ -20,10 +20,13 @@
20
20
 
21
21
  // Forward declaration of `TradeAssetQuoteRequest` to properly resolve imports.
22
22
  namespace margelo::nitro::rncandle { struct TradeAssetQuoteRequest; }
23
+ // Forward declaration of `CounterpartyQuoteRequest` to properly resolve imports.
24
+ namespace margelo::nitro::rncandle { struct CounterpartyQuoteRequest; }
23
25
 
24
26
  #include <string>
25
27
  #include <optional>
26
28
  #include "TradeAssetQuoteRequest.hpp"
29
+ #include "CounterpartyQuoteRequest.hpp"
27
30
 
28
31
  namespace margelo::nitro::rncandle {
29
32
 
@@ -35,10 +38,11 @@ namespace margelo::nitro::rncandle {
35
38
  std::optional<std::string> linkedAccountIDs SWIFT_PRIVATE;
36
39
  TradeAssetQuoteRequest gained SWIFT_PRIVATE;
37
40
  TradeAssetQuoteRequest lost SWIFT_PRIVATE;
41
+ std::optional<CounterpartyQuoteRequest> counterparty SWIFT_PRIVATE;
38
42
 
39
43
  public:
40
44
  TradeQuotesRequest() = default;
41
- explicit TradeQuotesRequest(std::optional<std::string> linkedAccountIDs, TradeAssetQuoteRequest gained, TradeAssetQuoteRequest lost): linkedAccountIDs(linkedAccountIDs), gained(gained), lost(lost) {}
45
+ explicit TradeQuotesRequest(std::optional<std::string> linkedAccountIDs, TradeAssetQuoteRequest gained, TradeAssetQuoteRequest lost, std::optional<CounterpartyQuoteRequest> counterparty): linkedAccountIDs(linkedAccountIDs), gained(gained), lost(lost), counterparty(counterparty) {}
42
46
  };
43
47
 
44
48
  } // namespace margelo::nitro::rncandle
@@ -53,7 +57,8 @@ namespace margelo::nitro {
53
57
  return margelo::nitro::rncandle::TradeQuotesRequest(
54
58
  JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "linkedAccountIDs")),
55
59
  JSIConverter<margelo::nitro::rncandle::TradeAssetQuoteRequest>::fromJSI(runtime, obj.getProperty(runtime, "gained")),
56
- JSIConverter<margelo::nitro::rncandle::TradeAssetQuoteRequest>::fromJSI(runtime, obj.getProperty(runtime, "lost"))
60
+ JSIConverter<margelo::nitro::rncandle::TradeAssetQuoteRequest>::fromJSI(runtime, obj.getProperty(runtime, "lost")),
61
+ JSIConverter<std::optional<margelo::nitro::rncandle::CounterpartyQuoteRequest>>::fromJSI(runtime, obj.getProperty(runtime, "counterparty"))
57
62
  );
58
63
  }
59
64
  static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::rncandle::TradeQuotesRequest& arg) {
@@ -61,6 +66,7 @@ namespace margelo::nitro {
61
66
  obj.setProperty(runtime, "linkedAccountIDs", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.linkedAccountIDs));
62
67
  obj.setProperty(runtime, "gained", JSIConverter<margelo::nitro::rncandle::TradeAssetQuoteRequest>::toJSI(runtime, arg.gained));
63
68
  obj.setProperty(runtime, "lost", JSIConverter<margelo::nitro::rncandle::TradeAssetQuoteRequest>::toJSI(runtime, arg.lost));
69
+ obj.setProperty(runtime, "counterparty", JSIConverter<std::optional<margelo::nitro::rncandle::CounterpartyQuoteRequest>>::toJSI(runtime, arg.counterparty));
64
70
  return obj;
65
71
  }
66
72
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -71,6 +77,7 @@ namespace margelo::nitro {
71
77
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "linkedAccountIDs"))) return false;
72
78
  if (!JSIConverter<margelo::nitro::rncandle::TradeAssetQuoteRequest>::canConvert(runtime, obj.getProperty(runtime, "gained"))) return false;
73
79
  if (!JSIConverter<margelo::nitro::rncandle::TradeAssetQuoteRequest>::canConvert(runtime, obj.getProperty(runtime, "lost"))) return false;
80
+ if (!JSIConverter<std::optional<margelo::nitro::rncandle::CounterpartyQuoteRequest>>::canConvert(runtime, obj.getProperty(runtime, "counterparty"))) return false;
74
81
  return true;
75
82
  }
76
83
  };
@@ -0,0 +1,76 @@
1
+ ///
2
+ /// UserCounterpartyQuoteRequest.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+
21
+
22
+
23
+ #include <string>
24
+ #include <optional>
25
+
26
+ namespace margelo::nitro::rncandle {
27
+
28
+ /**
29
+ * A struct which can be represented as a JavaScript object (UserCounterpartyQuoteRequest).
30
+ */
31
+ struct UserCounterpartyQuoteRequest {
32
+ public:
33
+ std::string kind SWIFT_PRIVATE;
34
+ std::optional<std::string> legalName SWIFT_PRIVATE;
35
+ std::optional<std::string> username SWIFT_PRIVATE;
36
+
37
+ public:
38
+ UserCounterpartyQuoteRequest() = default;
39
+ explicit UserCounterpartyQuoteRequest(std::string kind, std::optional<std::string> legalName, std::optional<std::string> username): kind(kind), legalName(legalName), username(username) {}
40
+ };
41
+
42
+ } // namespace margelo::nitro::rncandle
43
+
44
+ namespace margelo::nitro {
45
+
46
+ // C++ UserCounterpartyQuoteRequest <> JS UserCounterpartyQuoteRequest (object)
47
+ template <>
48
+ struct JSIConverter<margelo::nitro::rncandle::UserCounterpartyQuoteRequest> final {
49
+ static inline margelo::nitro::rncandle::UserCounterpartyQuoteRequest fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
50
+ jsi::Object obj = arg.asObject(runtime);
51
+ return margelo::nitro::rncandle::UserCounterpartyQuoteRequest(
52
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "kind")),
53
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "legalName")),
54
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "username"))
55
+ );
56
+ }
57
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::rncandle::UserCounterpartyQuoteRequest& arg) {
58
+ jsi::Object obj(runtime);
59
+ obj.setProperty(runtime, "kind", JSIConverter<std::string>::toJSI(runtime, arg.kind));
60
+ obj.setProperty(runtime, "legalName", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.legalName));
61
+ obj.setProperty(runtime, "username", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.username));
62
+ return obj;
63
+ }
64
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
65
+ if (!value.isObject()) {
66
+ return false;
67
+ }
68
+ jsi::Object obj = value.getObject(runtime);
69
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "kind"))) return false;
70
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "legalName"))) return false;
71
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "username"))) return false;
72
+ return true;
73
+ }
74
+ };
75
+
76
+ } // namespace margelo::nitro
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-candle",
3
- "version": "0.1.50",
3
+ "version": "0.1.51",
4
4
  "description": "Candle SDK for React Native",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/module/index.js",
@@ -231,17 +231,44 @@ export type NothingAssetQuoteRequest = {
231
231
  assetKind: string; // "nothing"
232
232
  };
233
233
 
234
+ export type OtherAssetQuoteRequest = {
235
+ assetKind: string; // "other"
236
+ };
237
+
234
238
  export type TradeAssetQuoteRequest = {
235
239
  fiatAssetQuoteRequest?: FiatAssetQuoteRequest;
236
240
  marketAssetQuoteRequest?: MarketAssetQuoteRequest;
237
241
  transportAssetQuoteRequest?: TransportAssetQuoteRequest;
238
242
  nothingAssetQuoteRequest?: NothingAssetQuoteRequest;
243
+ otherAssetQuoteRequest?: OtherAssetQuoteRequest;
244
+ };
245
+
246
+ export type MerchantCounterpartyQuoteRequest = {
247
+ kind: string; // "merchant";
248
+ name?: string;
249
+ };
250
+
251
+ export type UserCounterpartyQuoteRequest = {
252
+ kind: string; // "user"
253
+ legalName?: string;
254
+ username?: string;
255
+ };
256
+
257
+ export type ServiceCounterpartyQuoteRequest = {
258
+ kind: string; // "service"
259
+ };
260
+
261
+ export type CounterpartyQuoteRequest = {
262
+ userCounterpartyQuoteRequest?: UserCounterpartyQuoteRequest;
263
+ merchantCounterpartyQuoteRequest?: MerchantCounterpartyQuoteRequest;
264
+ serviceCounterpartyQuoteRequest?: ServiceCounterpartyQuoteRequest;
239
265
  };
240
266
 
241
267
  export type TradeQuotesRequest = {
242
268
  linkedAccountIDs?: string;
243
269
  gained: TradeAssetQuoteRequest;
244
270
  lost: TradeAssetQuoteRequest;
271
+ counterparty?: CounterpartyQuoteRequest;
245
272
  };
246
273
 
247
274
  export type ExecuteTradeRequest = {
@@ -252,6 +279,7 @@ export type ExecuteTradeRequest = {
252
279
  export type TradeQuote = {
253
280
  lost: TradeAsset;
254
281
  gained: TradeAsset;
282
+ counterparty: Counterparty;
255
283
  context: string;
256
284
  expirationDateTime: string;
257
285
  };
package/src/types.ts CHANGED
@@ -15,6 +15,7 @@ import type {
15
15
  NothingAssetRef,
16
16
  OtherAsset,
17
17
  OtherAssetRef,
18
+ OtherAssetQuoteRequest,
18
19
  Service,
19
20
  ServiceCounterparty,
20
21
  TradeState,
@@ -33,10 +34,14 @@ import type {
33
34
  TradeAsset as _TradeAsset,
34
35
  TradeQuote as _TradeQuote,
35
36
  Counterparty as _Counterparty,
37
+ CounterpartyQuoteRequest as _CounterpartyQuoteRequest,
36
38
  TradeAssetQuoteRequest as _TradeAssetQuoteRequest,
37
39
  InactiveLinkedAccountDetails,
38
40
  UnavailableLinkedAccountDetails,
39
41
  TradeAssetKind,
42
+ MerchantCounterpartyQuoteRequest,
43
+ ServiceCounterpartyQuoteRequest,
44
+ UserCounterpartyQuoteRequest,
40
45
  } from "./specs/RNCandle.nitro";
41
46
 
42
47
  export type {
@@ -47,6 +52,10 @@ export type {
47
52
  FiatAssetRef,
48
53
  FiatMarketAccountKind,
49
54
  MarketAssetQuoteRequest,
55
+ UserCounterpartyQuoteRequest,
56
+ OtherAssetQuoteRequest,
57
+ MerchantCounterpartyQuoteRequest,
58
+ ServiceCounterpartyQuoteRequest,
50
59
  MarketTradeAsset,
51
60
  MarketTradeAssetRef,
52
61
  MerchantCounterparty,
@@ -89,7 +98,15 @@ export type TradeAssetQuoteRequest =
89
98
  } & NothingAssetQuoteRequest)
90
99
  | ({ assetKind: "transport" } & TransportAssetQuoteRequest)
91
100
  | ({ assetKind: "fiat" } & FiatAssetQuoteRequest)
92
- | ({ assetKind: "stock" | "crypto" } & MarketAssetQuoteRequest);
101
+ | ({ assetKind: "stock" | "crypto" } & MarketAssetQuoteRequest)
102
+ | ({ assetKind: "other" } & OtherAssetQuoteRequest);
103
+
104
+ export type CounterpartyQuoteRequest =
105
+ | ({
106
+ kind: "user";
107
+ } & UserCounterpartyQuoteRequest)
108
+ | ({ kind: "merchant" } & MerchantCounterpartyQuoteRequest)
109
+ | ({ kind: "service" } & ServiceCounterpartyQuoteRequest);
93
110
 
94
111
  export type TradeAsset =
95
112
  | ({
@@ -156,6 +173,7 @@ export type TradeQuotesRequest<
156
173
  linkedAccountIDs?: string;
157
174
  gained: TradeAssetQuoteRequest & { assetKind: GainedAssetKind };
158
175
  lost: TradeAssetQuoteRequest & { assetKind: LostAssetKind };
176
+ counterparty?: CounterpartyQuoteRequest;
159
177
  };
160
178
 
161
179
  export type TradeRef = {
@@ -169,6 +187,7 @@ export type TradeQuote<
169
187
  > = {
170
188
  gained: TradeAsset & { assetKind: GainedAssetKind };
171
189
  lost: TradeAsset & { assetKind: LostAssetKind };
190
+ counterparty: Counterparty;
172
191
  context: string;
173
192
  expirationDateTime: string;
174
193
  };
@@ -224,6 +243,19 @@ export const toNativeTradeAsset = (tradeAsset: TradeAsset): _TradeAsset => {
224
243
  }
225
244
  };
226
245
 
246
+ export const toNativeCounterparty = (
247
+ counterparty: Counterparty
248
+ ): _Counterparty => {
249
+ switch (counterparty.kind) {
250
+ case "user":
251
+ return { userCounterparty: counterparty };
252
+ case "merchant":
253
+ return { merchantCounterparty: counterparty };
254
+ case "service":
255
+ return { serviceCounterparty: counterparty };
256
+ }
257
+ };
258
+
227
259
  export const toNativeTradeAssetQuoteRequest = (
228
260
  tradeAssetQuoteRequest: TradeAssetQuoteRequest
229
261
  ): _TradeAssetQuoteRequest => {
@@ -235,11 +267,26 @@ export const toNativeTradeAssetQuoteRequest = (
235
267
  return { marketAssetQuoteRequest: tradeAssetQuoteRequest };
236
268
  case "transport":
237
269
  return { transportAssetQuoteRequest: tradeAssetQuoteRequest };
270
+ case "other":
271
+ return { otherAssetQuoteRequest: tradeAssetQuoteRequest };
238
272
  case "nothing":
239
273
  return { nothingAssetQuoteRequest: tradeAssetQuoteRequest };
240
274
  }
241
275
  };
242
276
 
277
+ export const toNativeCounterpartyQuoteRequest = (
278
+ counterpartyQuoteRequest: CounterpartyQuoteRequest
279
+ ): _CounterpartyQuoteRequest => {
280
+ switch (counterpartyQuoteRequest.kind) {
281
+ case "user":
282
+ return { userCounterpartyQuoteRequest: counterpartyQuoteRequest };
283
+ case "merchant":
284
+ return { merchantCounterpartyQuoteRequest: counterpartyQuoteRequest };
285
+ case "service":
286
+ return { serviceCounterpartyQuoteRequest: counterpartyQuoteRequest };
287
+ }
288
+ };
289
+
243
290
  // TO composite types
244
291
 
245
292
  export const toNativeTradeQuote = (
@@ -248,6 +295,7 @@ export const toNativeTradeQuote = (
248
295
  ...tradeQuote,
249
296
  gained: toNativeTradeAsset(tradeQuote.gained),
250
297
  lost: toNativeTradeAsset(tradeQuote.lost),
298
+ counterparty: toNativeCounterparty(tradeQuote.counterparty),
251
299
  });
252
300
 
253
301
  export const toNativeTradeQuoteRequest = (
@@ -259,6 +307,10 @@ export const toNativeTradeQuoteRequest = (
259
307
  ...tradeQuoteRequest,
260
308
  gained: toNativeTradeAssetQuoteRequest(tradeQuoteRequest.gained),
261
309
  lost: toNativeTradeAssetQuoteRequest(tradeQuoteRequest.lost),
310
+ counterparty:
311
+ tradeQuoteRequest.counterparty === undefined
312
+ ? undefined
313
+ : toNativeCounterpartyQuoteRequest(tradeQuoteRequest.counterparty),
262
314
  });
263
315
 
264
316
  export const toNativeTradeRef = (tradeRef: TradeRef): _TradeRef => ({
@@ -440,6 +492,7 @@ export const fromNativeTradeQuoteAndRequest =
440
492
  tradeAsset: fromNativeTradeAsset(nativeTradeQuote.lost),
441
493
  expectedAssetKind: tradeQuoteRequest.lost.assetKind,
442
494
  }),
495
+ counterparty: fromNativeCounterparty(nativeTradeQuote.counterparty),
443
496
  });
444
497
 
445
498
  // Generics assertions