react-native-candle 0.1.32 → 0.1.35

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 (38) hide show
  1. package/ReactNativeCandle.podspec +1 -1
  2. package/ios/Sources/RNCandle.swift +131 -60
  3. package/lib/commonjs/index.js +58 -43
  4. package/lib/commonjs/index.js.map +1 -1
  5. package/lib/module/index.js +58 -43
  6. package/lib/module/index.js.map +1 -1
  7. package/lib/typescript/commonjs/src/index.d.ts +45 -37
  8. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  9. package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts +20 -10
  10. package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts.map +1 -1
  11. package/lib/typescript/module/src/index.d.ts +45 -37
  12. package/lib/typescript/module/src/index.d.ts.map +1 -1
  13. package/lib/typescript/module/src/specs/RNCandle.nitro.d.ts +20 -10
  14. package/lib/typescript/module/src/specs/RNCandle.nitro.d.ts.map +1 -1
  15. package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Bridge.hpp +34 -22
  16. package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Umbrella.hpp +15 -12
  17. package/nitrogen/generated/ios/c++/HybridRNCandleSpecSwift.hpp +15 -12
  18. package/nitrogen/generated/ios/swift/AssetAccount.swift +70 -11
  19. package/nitrogen/generated/ios/swift/AssetAccountKind.swift +4 -0
  20. package/nitrogen/generated/ios/swift/{FiatAccountDetails.swift → FiatAccount.swift} +32 -8
  21. package/nitrogen/generated/ios/swift/{LegalAccountKind.swift → FiatMarketAccountKind.swift} +14 -10
  22. package/nitrogen/generated/ios/swift/{MarketAccountDetails.swift → MarketAccount.swift} +31 -7
  23. package/nitrogen/generated/ios/swift/TransportAccount.swift +93 -0
  24. package/nitrogen/generated/ios/swift/TransportAccountKind.swift +42 -0
  25. package/nitrogen/generated/ios/swift/TransportAsset.swift +18 -6
  26. package/nitrogen/generated/shared/c++/AssetAccount.hpp +23 -20
  27. package/nitrogen/generated/shared/c++/AssetAccountKind.hpp +4 -0
  28. package/nitrogen/generated/shared/c++/{FiatAccountDetails.hpp → FiatAccount.hpp} +21 -10
  29. package/nitrogen/generated/shared/c++/FiatMarketAccountKind.hpp +90 -0
  30. package/nitrogen/generated/shared/c++/{MarketAccountDetails.hpp → MarketAccount.hpp} +21 -10
  31. package/nitrogen/generated/shared/c++/TransportAccount.hpp +94 -0
  32. package/nitrogen/generated/shared/c++/{LegalAccountKind.hpp → TransportAccountKind.hpp} +17 -21
  33. package/nitrogen/generated/shared/c++/TransportAsset.hpp +5 -1
  34. package/package.json +4 -4
  35. package/src/index.ts +105 -82
  36. package/src/specs/RNCandle.nitro.ts +27 -15
  37. package/nitrogen/generated/ios/swift/AssetAccountDetails.swift +0 -83
  38. package/nitrogen/generated/shared/c++/AssetAccountDetails.hpp +0 -78
@@ -0,0 +1,94 @@
1
+ ///
2
+ /// TransportAccount.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
+ // Forward declaration of `TransportAccountKind` to properly resolve imports.
22
+ namespace margelo::nitro::rncandle { enum class TransportAccountKind; }
23
+ // Forward declaration of `Service` to properly resolve imports.
24
+ namespace margelo::nitro::rncandle { enum class Service; }
25
+
26
+ #include <string>
27
+ #include "TransportAccountKind.hpp"
28
+ #include "Service.hpp"
29
+
30
+ namespace margelo::nitro::rncandle {
31
+
32
+ /**
33
+ * A struct which can be represented as a JavaScript object (TransportAccount).
34
+ */
35
+ struct TransportAccount {
36
+ public:
37
+ std::string assetKind SWIFT_PRIVATE;
38
+ std::string serviceAccountID SWIFT_PRIVATE;
39
+ TransportAccountKind accountKind SWIFT_PRIVATE;
40
+ std::string nickname SWIFT_PRIVATE;
41
+ std::string linkedAccountID SWIFT_PRIVATE;
42
+ Service service SWIFT_PRIVATE;
43
+
44
+ public:
45
+ TransportAccount() = default;
46
+ explicit TransportAccount(std::string assetKind, std::string serviceAccountID, TransportAccountKind accountKind, std::string nickname, std::string linkedAccountID, Service service): assetKind(assetKind), serviceAccountID(serviceAccountID), accountKind(accountKind), nickname(nickname), linkedAccountID(linkedAccountID), service(service) {}
47
+ };
48
+
49
+ } // namespace margelo::nitro::rncandle
50
+
51
+ namespace margelo::nitro {
52
+
53
+ using namespace margelo::nitro::rncandle;
54
+
55
+ // C++ TransportAccount <> JS TransportAccount (object)
56
+ template <>
57
+ struct JSIConverter<TransportAccount> final {
58
+ static inline TransportAccount fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
59
+ jsi::Object obj = arg.asObject(runtime);
60
+ return TransportAccount(
61
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "assetKind")),
62
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "serviceAccountID")),
63
+ JSIConverter<TransportAccountKind>::fromJSI(runtime, obj.getProperty(runtime, "accountKind")),
64
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "nickname")),
65
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "linkedAccountID")),
66
+ JSIConverter<Service>::fromJSI(runtime, obj.getProperty(runtime, "service"))
67
+ );
68
+ }
69
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const TransportAccount& arg) {
70
+ jsi::Object obj(runtime);
71
+ obj.setProperty(runtime, "assetKind", JSIConverter<std::string>::toJSI(runtime, arg.assetKind));
72
+ obj.setProperty(runtime, "serviceAccountID", JSIConverter<std::string>::toJSI(runtime, arg.serviceAccountID));
73
+ obj.setProperty(runtime, "accountKind", JSIConverter<TransportAccountKind>::toJSI(runtime, arg.accountKind));
74
+ obj.setProperty(runtime, "nickname", JSIConverter<std::string>::toJSI(runtime, arg.nickname));
75
+ obj.setProperty(runtime, "linkedAccountID", JSIConverter<std::string>::toJSI(runtime, arg.linkedAccountID));
76
+ obj.setProperty(runtime, "service", JSIConverter<Service>::toJSI(runtime, arg.service));
77
+ return obj;
78
+ }
79
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
80
+ if (!value.isObject()) {
81
+ return false;
82
+ }
83
+ jsi::Object obj = value.getObject(runtime);
84
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "assetKind"))) return false;
85
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "serviceAccountID"))) return false;
86
+ if (!JSIConverter<TransportAccountKind>::canConvert(runtime, obj.getProperty(runtime, "accountKind"))) return false;
87
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "nickname"))) return false;
88
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "linkedAccountID"))) return false;
89
+ if (!JSIConverter<Service>::canConvert(runtime, obj.getProperty(runtime, "service"))) return false;
90
+ return true;
91
+ }
92
+ };
93
+
94
+ } // namespace margelo::nitro
@@ -1,5 +1,5 @@
1
1
  ///
2
- /// LegalAccountKind.hpp
2
+ /// TransportAccountKind.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
5
  /// Copyright © 2025 Marc Rousavy @ Margelo
@@ -26,13 +26,12 @@
26
26
  namespace margelo::nitro::rncandle {
27
27
 
28
28
  /**
29
- * An enum which can be represented as a JavaScript union (LegalAccountKind).
29
+ * An enum which can be represented as a JavaScript union (TransportAccountKind).
30
30
  */
31
- enum class LegalAccountKind {
31
+ enum class TransportAccountKind {
32
32
  INDIVIDUAL SWIFT_NAME(individual) = 0,
33
33
  JOINT SWIFT_NAME(joint) = 1,
34
- TRADITIONALIRA SWIFT_NAME(traditionalira) = 2,
35
- ROTHIRA SWIFT_NAME(rothira) = 3,
34
+ BUSINESS SWIFT_NAME(business) = 2,
36
35
  } CLOSED_ENUM;
37
36
 
38
37
  } // namespace margelo::nitro::rncandle
@@ -41,28 +40,26 @@ namespace margelo::nitro {
41
40
 
42
41
  using namespace margelo::nitro::rncandle;
43
42
 
44
- // C++ LegalAccountKind <> JS LegalAccountKind (union)
43
+ // C++ TransportAccountKind <> JS TransportAccountKind (union)
45
44
  template <>
46
- struct JSIConverter<LegalAccountKind> final {
47
- static inline LegalAccountKind fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
45
+ struct JSIConverter<TransportAccountKind> final {
46
+ static inline TransportAccountKind fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
48
47
  std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
49
48
  switch (hashString(unionValue.c_str(), unionValue.size())) {
50
- case hashString("individual"): return LegalAccountKind::INDIVIDUAL;
51
- case hashString("joint"): return LegalAccountKind::JOINT;
52
- case hashString("traditionalIra"): return LegalAccountKind::TRADITIONALIRA;
53
- case hashString("rothIra"): return LegalAccountKind::ROTHIRA;
49
+ case hashString("individual"): return TransportAccountKind::INDIVIDUAL;
50
+ case hashString("joint"): return TransportAccountKind::JOINT;
51
+ case hashString("business"): return TransportAccountKind::BUSINESS;
54
52
  default: [[unlikely]]
55
- throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum LegalAccountKind - invalid value!");
53
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum TransportAccountKind - invalid value!");
56
54
  }
57
55
  }
58
- static inline jsi::Value toJSI(jsi::Runtime& runtime, LegalAccountKind arg) {
56
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, TransportAccountKind arg) {
59
57
  switch (arg) {
60
- case LegalAccountKind::INDIVIDUAL: return JSIConverter<std::string>::toJSI(runtime, "individual");
61
- case LegalAccountKind::JOINT: return JSIConverter<std::string>::toJSI(runtime, "joint");
62
- case LegalAccountKind::TRADITIONALIRA: return JSIConverter<std::string>::toJSI(runtime, "traditionalIra");
63
- case LegalAccountKind::ROTHIRA: return JSIConverter<std::string>::toJSI(runtime, "rothIra");
58
+ case TransportAccountKind::INDIVIDUAL: return JSIConverter<std::string>::toJSI(runtime, "individual");
59
+ case TransportAccountKind::JOINT: return JSIConverter<std::string>::toJSI(runtime, "joint");
60
+ case TransportAccountKind::BUSINESS: return JSIConverter<std::string>::toJSI(runtime, "business");
64
61
  default: [[unlikely]]
65
- throw std::invalid_argument("Cannot convert LegalAccountKind to JS - invalid value: "
62
+ throw std::invalid_argument("Cannot convert TransportAccountKind to JS - invalid value: "
66
63
  + std::to_string(static_cast<int>(arg)) + "!");
67
64
  }
68
65
  }
@@ -74,8 +71,7 @@ namespace margelo::nitro {
74
71
  switch (hashString(unionValue.c_str(), unionValue.size())) {
75
72
  case hashString("individual"):
76
73
  case hashString("joint"):
77
- case hashString("traditionalIra"):
78
- case hashString("rothIra"):
74
+ case hashString("business"):
79
75
  return true;
80
76
  default:
81
77
  return false;
@@ -40,6 +40,7 @@ namespace margelo::nitro::rncandle {
40
40
  std::string assetKind SWIFT_PRIVATE;
41
41
  std::string serviceTradeID SWIFT_PRIVATE;
42
42
  std::string serviceAssetID SWIFT_PRIVATE;
43
+ std::string serviceAccountID SWIFT_PRIVATE;
43
44
  std::string name SWIFT_PRIVATE;
44
45
  std::string description SWIFT_PRIVATE;
45
46
  std::string imageURL SWIFT_PRIVATE;
@@ -55,7 +56,7 @@ namespace margelo::nitro::rncandle {
55
56
 
56
57
  public:
57
58
  TransportAsset() = default;
58
- explicit TransportAsset(std::string assetKind, std::string serviceTradeID, std::string serviceAssetID, std::string name, std::string description, std::string imageURL, Coordinates originCoordinates, Address originAddress, Coordinates destinationCoordinates, Address destinationAddress, double seats, std::string departureDateTime, std::string arrivalDateTime, std::string linkedAccountID, Service service): assetKind(assetKind), serviceTradeID(serviceTradeID), serviceAssetID(serviceAssetID), name(name), description(description), imageURL(imageURL), originCoordinates(originCoordinates), originAddress(originAddress), destinationCoordinates(destinationCoordinates), destinationAddress(destinationAddress), seats(seats), departureDateTime(departureDateTime), arrivalDateTime(arrivalDateTime), linkedAccountID(linkedAccountID), service(service) {}
59
+ explicit TransportAsset(std::string assetKind, std::string serviceTradeID, std::string serviceAssetID, std::string serviceAccountID, std::string name, std::string description, std::string imageURL, Coordinates originCoordinates, Address originAddress, Coordinates destinationCoordinates, Address destinationAddress, double seats, std::string departureDateTime, std::string arrivalDateTime, std::string linkedAccountID, Service service): assetKind(assetKind), serviceTradeID(serviceTradeID), serviceAssetID(serviceAssetID), serviceAccountID(serviceAccountID), name(name), description(description), imageURL(imageURL), originCoordinates(originCoordinates), originAddress(originAddress), destinationCoordinates(destinationCoordinates), destinationAddress(destinationAddress), seats(seats), departureDateTime(departureDateTime), arrivalDateTime(arrivalDateTime), linkedAccountID(linkedAccountID), service(service) {}
59
60
  };
60
61
 
61
62
  } // namespace margelo::nitro::rncandle
@@ -73,6 +74,7 @@ namespace margelo::nitro {
73
74
  JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "assetKind")),
74
75
  JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "serviceTradeID")),
75
76
  JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "serviceAssetID")),
77
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "serviceAccountID")),
76
78
  JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "name")),
77
79
  JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "description")),
78
80
  JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "imageURL")),
@@ -92,6 +94,7 @@ namespace margelo::nitro {
92
94
  obj.setProperty(runtime, "assetKind", JSIConverter<std::string>::toJSI(runtime, arg.assetKind));
93
95
  obj.setProperty(runtime, "serviceTradeID", JSIConverter<std::string>::toJSI(runtime, arg.serviceTradeID));
94
96
  obj.setProperty(runtime, "serviceAssetID", JSIConverter<std::string>::toJSI(runtime, arg.serviceAssetID));
97
+ obj.setProperty(runtime, "serviceAccountID", JSIConverter<std::string>::toJSI(runtime, arg.serviceAccountID));
95
98
  obj.setProperty(runtime, "name", JSIConverter<std::string>::toJSI(runtime, arg.name));
96
99
  obj.setProperty(runtime, "description", JSIConverter<std::string>::toJSI(runtime, arg.description));
97
100
  obj.setProperty(runtime, "imageURL", JSIConverter<std::string>::toJSI(runtime, arg.imageURL));
@@ -114,6 +117,7 @@ namespace margelo::nitro {
114
117
  if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "assetKind"))) return false;
115
118
  if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "serviceTradeID"))) return false;
116
119
  if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "serviceAssetID"))) return false;
120
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "serviceAccountID"))) return false;
117
121
  if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "name"))) return false;
118
122
  if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "description"))) return false;
119
123
  if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "imageURL"))) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-candle",
3
- "version": "0.1.32",
3
+ "version": "0.1.35",
4
4
  "description": "Candle SDK for React Native",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/module/index.js",
@@ -58,9 +58,9 @@
58
58
  "nitro-codegen": "^0.25.2",
59
59
  "react-native-nitro-modules": "^0.25.2",
60
60
  "react-native-builder-bob": "^0.35.2",
61
- "release-it": "^18.1.2",
62
- "@release-it/bumper": "^7.0.1",
63
- "@release-it/conventional-changelog": "^10.0.0"
61
+ "release-it": "^19.0.4",
62
+ "@release-it/bumper": "^7.0.5",
63
+ "@release-it/conventional-changelog": "^10.0.1"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "react": "*",
package/src/index.ts CHANGED
@@ -10,13 +10,13 @@ import type {
10
10
  FiatAsset,
11
11
  FiatAssetQuoteRequest,
12
12
  FiatAssetRef,
13
+ FiatMarketAccountKind,
13
14
  AssetAccount as InternalAssetAccount,
14
15
  Counterparty as InternalCounterparty,
15
16
  TradeAsset as InternalTradeAsset,
16
17
  TradeAssetRef as InternalTradeAssetRef,
17
18
  TradeQuery as InternalTradeQuery,
18
19
  TradeQuote as InternalTradeQuote,
19
- LegalAccountKind,
20
20
  LinkedAccount,
21
21
  LinkedAccountRef,
22
22
  LinkedAccountStatusRef,
@@ -35,8 +35,8 @@ import type {
35
35
  Service,
36
36
  ServiceCounterparty,
37
37
  TradeAssetQuoteRequest,
38
- TradeExecutionResult,
39
38
  TradeState,
39
+ TransportAccountKind,
40
40
  TransportAsset,
41
41
  TransportAssetQuoteRequest,
42
42
  TransportAssetRef,
@@ -54,48 +54,56 @@ export class CandleClient {
54
54
  this.candle.initialize(appUser, accessGroup);
55
55
  }
56
56
 
57
- public async executeTrade<
57
+ public presentCandleTradeExecutionSheet<
58
58
  GainedAssetKind extends AssetKind,
59
59
  LostAssetKind extends AssetKind
60
60
  >(input: {
61
61
  tradeQuote: TradeQuote<GainedAssetKind, LostAssetKind>;
62
62
  presentationBackground?: PresentationBackground;
63
- }): Promise<
64
- Trade & {
65
- gained: { assetKind: GainedAssetKind };
66
- lost: { assetKind: LostAssetKind };
67
- }
68
- > {
63
+ completion?: (
64
+ result:
65
+ | (Trade & {
66
+ kind: "success";
67
+ gained: { assetKind: GainedAssetKind };
68
+ lost: { assetKind: LostAssetKind };
69
+ })
70
+ | { kind: "failure"; error: Error }
71
+ ) => void;
72
+ }): void {
69
73
  const quote = this.convertTradeQuote(input.tradeQuote);
70
- const promise: Promise<TradeExecutionResult> = new Promise((callback) => {
71
- this.candle.candleTradeExecutionSheet(
72
- quote,
73
- input.presentationBackground ?? "default",
74
- callback
75
- );
76
- });
77
- const result = await promise;
78
- if (result.trade !== undefined) {
79
- return {
80
- ...result.trade,
81
- counterparty: this.convertToCounterparty(result.trade.counterparty),
82
- lost: this.assertTradeAsset({
83
- tradeAsset: this.convertTradeAsset(result.trade.lost),
84
- expectedAssetKind: input.tradeQuote.lost.assetKind,
85
- }),
86
- gained: this.assertTradeAsset({
87
- tradeAsset: this.convertTradeAsset(result.trade.gained),
88
- expectedAssetKind: input.tradeQuote.gained.assetKind,
89
- }),
90
- };
91
- } else {
92
- if (result.error === undefined) {
93
- throw new Error(
94
- "Internal Candle Error: corrupted trade execution result."
95
- );
74
+ this.candle.candleTradeExecutionSheet(
75
+ quote,
76
+ input.presentationBackground ?? "default",
77
+ (result) => {
78
+ if (input.completion === undefined) {
79
+ return;
80
+ }
81
+ if (result.trade !== undefined) {
82
+ input.completion({
83
+ kind: "success",
84
+ ...result.trade,
85
+ counterparty: this.convertToCounterparty(result.trade.counterparty),
86
+ lost: this.assertTradeAsset({
87
+ tradeAsset: this.convertTradeAsset(result.trade.lost),
88
+ expectedAssetKind: input.tradeQuote.lost.assetKind,
89
+ }),
90
+ gained: this.assertTradeAsset({
91
+ tradeAsset: this.convertTradeAsset(result.trade.gained),
92
+ expectedAssetKind: input.tradeQuote.gained.assetKind,
93
+ }),
94
+ });
95
+ } else {
96
+ if (result.error === undefined) {
97
+ throw new Error(
98
+ "Internal Candle Error: corrupted trade execution result."
99
+ );
100
+ } else {
101
+ const error = new Error(result.error);
102
+ input.completion({ kind: "failure", error });
103
+ }
104
+ }
96
105
  }
97
- throw result.error;
98
- }
106
+ );
99
107
  }
100
108
 
101
109
  public presentCandleLinkSheet({
@@ -128,16 +136,7 @@ export class CandleClient {
128
136
  );
129
137
  }
130
138
 
131
- public async getLinkedAccounts(): Promise<
132
- (
133
- | (LinkedAccount & {
134
- details: { state: "active" } & ActiveLinkedAccountDetails;
135
- })
136
- | (LinkedAccount & {
137
- details: { state: "inactive" | "unavailable" };
138
- })
139
- )[]
140
- > {
139
+ public async getLinkedAccounts(): Promise<LinkedAccountDetail[]> {
141
140
  const accounts = await this.candle.getLinkedAccounts();
142
141
  return accounts.map((account) => {
143
142
  if (account.details.activeLinkedAccountDetails !== undefined) {
@@ -464,6 +463,14 @@ export class CandleClient {
464
463
  }
465
464
  }
466
465
 
466
+ private assertFiatAssetKind(kind: string): "fiat" {
467
+ if (kind !== "fiat") {
468
+ throw new Error("Internal Candle Error: corrupted market account.");
469
+ } else {
470
+ return kind;
471
+ }
472
+ }
473
+
467
474
  private assertMarketAssetKind(kind: string): "stock" | "crypto" {
468
475
  if (kind !== "stock" && kind !== "crypto") {
469
476
  throw new Error("Internal Candle Error: corrupted market account.");
@@ -472,27 +479,31 @@ export class CandleClient {
472
479
  }
473
480
  }
474
481
 
482
+ private assertTransportAssetKind(kind: string): "transport" {
483
+ if (kind !== "transport") {
484
+ throw new Error("Internal Candle Error: corrupted market account.");
485
+ } else {
486
+ return kind;
487
+ }
488
+ }
489
+
475
490
  private convertToAssetAccount(account: InternalAssetAccount): AssetAccount {
476
- const { legalAccountKind, nickname } = account;
477
- const { fiatAccountDetails, marketAccountDetails } = account.details;
491
+ const { fiatAccount, marketAccount, transportAccount } = account;
478
492
 
479
- if (fiatAccountDetails !== undefined) {
493
+ if (fiatAccount !== undefined) {
480
494
  return {
481
- legalAccountKind,
482
- nickname,
483
- details: {
484
- ...fiatAccountDetails,
485
- assetKind: "fiat",
486
- },
495
+ ...fiatAccount,
496
+ assetKind: this.assertFiatAssetKind(fiatAccount.assetKind),
487
497
  };
488
- } else if (marketAccountDetails !== undefined) {
498
+ } else if (marketAccount !== undefined) {
489
499
  return {
490
- legalAccountKind,
491
- nickname,
492
- details: {
493
- ...marketAccountDetails,
494
- assetKind: this.assertMarketAssetKind(marketAccountDetails.assetKind),
495
- },
500
+ ...marketAccount,
501
+ assetKind: this.assertMarketAssetKind(marketAccount.assetKind),
502
+ };
503
+ } else if (transportAccount !== undefined) {
504
+ return {
505
+ ...transportAccount,
506
+ assetKind: this.assertTransportAssetKind(transportAccount.assetKind),
496
507
  };
497
508
  } else {
498
509
  throw new Error("Internal Candle Error: corrupted asset account.");
@@ -555,26 +566,28 @@ type TradeQueryAssetKind =
555
566
  | "nothing";
556
567
 
557
568
  type AssetAccount = {
558
- legalAccountKind: LegalAccountKind;
569
+ serviceAccountID: string;
559
570
  nickname: string;
560
- details:
561
- | {
562
- assetKind: "fiat";
563
- serviceAccountID: string;
564
- currencyCode: string;
565
- balance?: number;
566
- linkedAccountID: string;
567
- service: Service;
568
- ach?: ACHDetails;
569
- wire?: WireDetails;
570
- }
571
- | {
572
- assetKind: "stock" | "crypto";
573
- serviceAccountID: string;
574
- linkedAccountID: string;
575
- service: Service;
576
- };
577
- };
571
+ linkedAccountID: string;
572
+ service: Service;
573
+ } & (
574
+ | {
575
+ assetKind: "fiat";
576
+ accountKind: FiatMarketAccountKind;
577
+ currencyCode: string;
578
+ balance?: number;
579
+ ach?: ACHDetails;
580
+ wire?: WireDetails;
581
+ }
582
+ | {
583
+ assetKind: "stock" | "crypto";
584
+ accountKind: FiatMarketAccountKind;
585
+ }
586
+ | {
587
+ assetKind: "transport";
588
+ accountKind: TransportAccountKind;
589
+ }
590
+ );
578
591
 
579
592
  type Trade = {
580
593
  dateTime: string;
@@ -591,6 +604,14 @@ type TradeAssetRef =
591
604
  | ({ assetKind: "fiat" } & FiatAssetRef)
592
605
  | ({ assetKind: "stock" | "crypto" } & MarketTradeAssetRef);
593
606
 
607
+ type LinkedAccountDetail =
608
+ | (LinkedAccount & {
609
+ details: { state: "active" } & ActiveLinkedAccountDetails;
610
+ })
611
+ | (LinkedAccount & {
612
+ details: { state: "inactive" | "unavailable" };
613
+ });
614
+
594
615
  export type {
595
616
  Address,
596
617
  AppUser,
@@ -600,7 +621,9 @@ export type {
600
621
  Coordinates,
601
622
  Counterparty,
602
623
  LinkedAccount,
624
+ LinkedAccountDetail,
603
625
  LinkedAccountRef,
626
+ LinkedAccountStatusRef,
604
627
  Service,
605
628
  Trade,
606
629
  TradeAsset,
@@ -19,9 +19,20 @@ export type WireDetails = {
19
19
  routingNumber: string;
20
20
  };
21
21
 
22
- type FiatAccountDetails = {
22
+ export type FiatMarketAccountKind =
23
+ | "individual"
24
+ | "joint"
25
+ | "traditionalIRA"
26
+ | "rothIRA"
27
+ | "business";
28
+
29
+ export type TransportAccountKind = "individual" | "joint" | "business";
30
+
31
+ type FiatAccount = {
23
32
  assetKind: string; // fiat
24
33
  serviceAccountID: string;
34
+ accountKind: FiatMarketAccountKind;
35
+ nickname: string;
25
36
  currencyCode: string;
26
37
  balance?: number;
27
38
  ach?: ACHDetails;
@@ -30,31 +41,31 @@ type FiatAccountDetails = {
30
41
  service: Service;
31
42
  };
32
43
 
33
- type MarketAccountDetails = {
44
+ type MarketAccount = {
34
45
  assetKind: string; // "stock" | "crypto"
35
46
  serviceAccountID: string;
47
+ accountKind: FiatMarketAccountKind;
48
+ nickname: string;
36
49
  linkedAccountID: string;
37
50
  service: Service;
38
51
  };
39
52
 
40
- type AssetAccountDetails = {
41
- fiatAccountDetails?: FiatAccountDetails;
42
- marketAccountDetails?: MarketAccountDetails;
53
+ type TransportAccount = {
54
+ assetKind: string; // "transport"
55
+ serviceAccountID: string;
56
+ accountKind: TransportAccountKind;
57
+ nickname: string;
58
+ linkedAccountID: string;
59
+ service: Service;
43
60
  };
44
61
 
45
- export type LegalAccountKind =
46
- | "individual"
47
- | "joint"
48
- | "traditionalIra"
49
- | "rothIra";
50
-
51
62
  export type AssetAccount = {
52
- legalAccountKind: LegalAccountKind;
53
- nickname: string;
54
- details: AssetAccountDetails;
63
+ fiatAccount?: FiatAccount;
64
+ marketAccount?: MarketAccount;
65
+ transportAccount?: TransportAccount;
55
66
  };
56
67
 
57
- type AssetAccountKind = "fiat" | "stock" | "crypto";
68
+ type AssetAccountKind = "fiat" | "stock" | "crypto" | "transport";
58
69
 
59
70
  export type AssetAccountQuery = {
60
71
  linkedAccountIDs?: string;
@@ -98,6 +109,7 @@ export type TransportAsset = {
98
109
  assetKind: string; // "transport"
99
110
  serviceTradeID: string;
100
111
  serviceAssetID: string;
112
+ serviceAccountID: string;
101
113
  name: string;
102
114
  description: string;
103
115
  // FIXME: use URL type for url fields
@@ -1,83 +0,0 @@
1
- ///
2
- /// AssetAccountDetails.swift
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
- import NitroModules
9
-
10
- /// Represents an instance of `AssetAccountDetails`, backed by a C++ struct.
11
- public typealias AssetAccountDetails = margelo.nitro.rncandle.AssetAccountDetails
12
-
13
- extension AssetAccountDetails {
14
- private typealias bridge = margelo.nitro.rncandle.bridge.swift
15
-
16
- /**
17
- * Create a new instance of `AssetAccountDetails`.
18
- */
19
- public init(fiatAccountDetails: FiatAccountDetails?, marketAccountDetails: MarketAccountDetails?)
20
- {
21
- self.init(
22
- { () -> bridge.std__optional_FiatAccountDetails_ in
23
- if let __unwrappedValue = fiatAccountDetails {
24
- return bridge.create_std__optional_FiatAccountDetails_(__unwrappedValue)
25
- } else {
26
- return .init()
27
- }
28
- }(),
29
- { () -> bridge.std__optional_MarketAccountDetails_ in
30
- if let __unwrappedValue = marketAccountDetails {
31
- return bridge.create_std__optional_MarketAccountDetails_(__unwrappedValue)
32
- } else {
33
- return .init()
34
- }
35
- }())
36
- }
37
-
38
- public var fiatAccountDetails: FiatAccountDetails? {
39
- @inline(__always)
40
- get {
41
- return { () -> FiatAccountDetails? in
42
- if let __unwrapped = self.__fiatAccountDetails.value {
43
- return __unwrapped
44
- } else {
45
- return nil
46
- }
47
- }()
48
- }
49
- @inline(__always)
50
- set {
51
- self.__fiatAccountDetails = { () -> bridge.std__optional_FiatAccountDetails_ in
52
- if let __unwrappedValue = newValue {
53
- return bridge.create_std__optional_FiatAccountDetails_(__unwrappedValue)
54
- } else {
55
- return .init()
56
- }
57
- }()
58
- }
59
- }
60
-
61
- public var marketAccountDetails: MarketAccountDetails? {
62
- @inline(__always)
63
- get {
64
- return { () -> MarketAccountDetails? in
65
- if let __unwrapped = self.__marketAccountDetails.value {
66
- return __unwrapped
67
- } else {
68
- return nil
69
- }
70
- }()
71
- }
72
- @inline(__always)
73
- set {
74
- self.__marketAccountDetails = { () -> bridge.std__optional_MarketAccountDetails_ in
75
- if let __unwrappedValue = newValue {
76
- return bridge.create_std__optional_MarketAccountDetails_(__unwrappedValue)
77
- } else {
78
- return .init()
79
- }
80
- }()
81
- }
82
- }
83
- }