react-native-candle 0.1.33 → 0.1.36

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 +28 -20
  4. package/lib/commonjs/index.js.map +1 -1
  5. package/lib/module/index.js +28 -20
  6. package/lib/module/index.js.map +1 -1
  7. package/lib/typescript/commonjs/src/index.d.ts +31 -28
  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 +31 -28
  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 +62 -46
  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
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,
@@ -36,6 +36,7 @@ import type {
36
36
  ServiceCounterparty,
37
37
  TradeAssetQuoteRequest,
38
38
  TradeState,
39
+ TransportAccountKind,
39
40
  TransportAsset,
40
41
  TransportAssetQuoteRequest,
41
42
  TransportAssetRef,
@@ -135,16 +136,7 @@ export class CandleClient {
135
136
  );
136
137
  }
137
138
 
138
- public async getLinkedAccounts(): Promise<
139
- (
140
- | (LinkedAccount & {
141
- details: { state: "active" } & ActiveLinkedAccountDetails;
142
- })
143
- | (LinkedAccount & {
144
- details: { state: "inactive" | "unavailable" };
145
- })
146
- )[]
147
- > {
139
+ public async getLinkedAccounts(): Promise<LinkedAccountDetail[]> {
148
140
  const accounts = await this.candle.getLinkedAccounts();
149
141
  return accounts.map((account) => {
150
142
  if (account.details.activeLinkedAccountDetails !== undefined) {
@@ -471,6 +463,14 @@ export class CandleClient {
471
463
  }
472
464
  }
473
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
+
474
474
  private assertMarketAssetKind(kind: string): "stock" | "crypto" {
475
475
  if (kind !== "stock" && kind !== "crypto") {
476
476
  throw new Error("Internal Candle Error: corrupted market account.");
@@ -479,27 +479,31 @@ export class CandleClient {
479
479
  }
480
480
  }
481
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
+
482
490
  private convertToAssetAccount(account: InternalAssetAccount): AssetAccount {
483
- const { legalAccountKind, nickname } = account;
484
- const { fiatAccountDetails, marketAccountDetails } = account.details;
491
+ const { fiatAccount, marketAccount, transportAccount } = account;
485
492
 
486
- if (fiatAccountDetails !== undefined) {
493
+ if (fiatAccount !== undefined) {
487
494
  return {
488
- legalAccountKind,
489
- nickname,
490
- details: {
491
- ...fiatAccountDetails,
492
- assetKind: "fiat",
493
- },
495
+ ...fiatAccount,
496
+ assetKind: this.assertFiatAssetKind(fiatAccount.assetKind),
494
497
  };
495
- } else if (marketAccountDetails !== undefined) {
498
+ } else if (marketAccount !== undefined) {
496
499
  return {
497
- legalAccountKind,
498
- nickname,
499
- details: {
500
- ...marketAccountDetails,
501
- assetKind: this.assertMarketAssetKind(marketAccountDetails.assetKind),
502
- },
500
+ ...marketAccount,
501
+ assetKind: this.assertMarketAssetKind(marketAccount.assetKind),
502
+ };
503
+ } else if (transportAccount !== undefined) {
504
+ return {
505
+ ...transportAccount,
506
+ assetKind: this.assertTransportAssetKind(transportAccount.assetKind),
503
507
  };
504
508
  } else {
505
509
  throw new Error("Internal Candle Error: corrupted asset account.");
@@ -562,26 +566,28 @@ type TradeQueryAssetKind =
562
566
  | "nothing";
563
567
 
564
568
  type AssetAccount = {
565
- legalAccountKind: LegalAccountKind;
569
+ serviceAccountID: string;
566
570
  nickname: string;
567
- details:
568
- | {
569
- assetKind: "fiat";
570
- serviceAccountID: string;
571
- currencyCode: string;
572
- balance?: number;
573
- linkedAccountID: string;
574
- service: Service;
575
- ach?: ACHDetails;
576
- wire?: WireDetails;
577
- }
578
- | {
579
- assetKind: "stock" | "crypto";
580
- serviceAccountID: string;
581
- linkedAccountID: string;
582
- service: Service;
583
- };
584
- };
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
+ );
585
591
 
586
592
  type Trade = {
587
593
  dateTime: string;
@@ -598,6 +604,14 @@ type TradeAssetRef =
598
604
  | ({ assetKind: "fiat" } & FiatAssetRef)
599
605
  | ({ assetKind: "stock" | "crypto" } & MarketTradeAssetRef);
600
606
 
607
+ type LinkedAccountDetail =
608
+ | (LinkedAccount & {
609
+ details: { state: "active" } & ActiveLinkedAccountDetails;
610
+ })
611
+ | (LinkedAccount & {
612
+ details: { state: "inactive" | "unavailable" };
613
+ });
614
+
601
615
  export type {
602
616
  Address,
603
617
  AppUser,
@@ -607,7 +621,9 @@ export type {
607
621
  Coordinates,
608
622
  Counterparty,
609
623
  LinkedAccount,
624
+ LinkedAccountDetail,
610
625
  LinkedAccountRef,
626
+ LinkedAccountStatusRef,
611
627
  Service,
612
628
  Trade,
613
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
- }
@@ -1,78 +0,0 @@
1
- ///
2
- /// AssetAccountDetails.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 `FiatAccountDetails` to properly resolve imports.
22
- namespace margelo::nitro::rncandle { struct FiatAccountDetails; }
23
- // Forward declaration of `MarketAccountDetails` to properly resolve imports.
24
- namespace margelo::nitro::rncandle { struct MarketAccountDetails; }
25
-
26
- #include <optional>
27
- #include "FiatAccountDetails.hpp"
28
- #include "MarketAccountDetails.hpp"
29
-
30
- namespace margelo::nitro::rncandle {
31
-
32
- /**
33
- * A struct which can be represented as a JavaScript object (AssetAccountDetails).
34
- */
35
- struct AssetAccountDetails {
36
- public:
37
- std::optional<FiatAccountDetails> fiatAccountDetails SWIFT_PRIVATE;
38
- std::optional<MarketAccountDetails> marketAccountDetails SWIFT_PRIVATE;
39
-
40
- public:
41
- AssetAccountDetails() = default;
42
- explicit AssetAccountDetails(std::optional<FiatAccountDetails> fiatAccountDetails, std::optional<MarketAccountDetails> marketAccountDetails): fiatAccountDetails(fiatAccountDetails), marketAccountDetails(marketAccountDetails) {}
43
- };
44
-
45
- } // namespace margelo::nitro::rncandle
46
-
47
- namespace margelo::nitro {
48
-
49
- using namespace margelo::nitro::rncandle;
50
-
51
- // C++ AssetAccountDetails <> JS AssetAccountDetails (object)
52
- template <>
53
- struct JSIConverter<AssetAccountDetails> final {
54
- static inline AssetAccountDetails fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
55
- jsi::Object obj = arg.asObject(runtime);
56
- return AssetAccountDetails(
57
- JSIConverter<std::optional<FiatAccountDetails>>::fromJSI(runtime, obj.getProperty(runtime, "fiatAccountDetails")),
58
- JSIConverter<std::optional<MarketAccountDetails>>::fromJSI(runtime, obj.getProperty(runtime, "marketAccountDetails"))
59
- );
60
- }
61
- static inline jsi::Value toJSI(jsi::Runtime& runtime, const AssetAccountDetails& arg) {
62
- jsi::Object obj(runtime);
63
- obj.setProperty(runtime, "fiatAccountDetails", JSIConverter<std::optional<FiatAccountDetails>>::toJSI(runtime, arg.fiatAccountDetails));
64
- obj.setProperty(runtime, "marketAccountDetails", JSIConverter<std::optional<MarketAccountDetails>>::toJSI(runtime, arg.marketAccountDetails));
65
- return obj;
66
- }
67
- static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
68
- if (!value.isObject()) {
69
- return false;
70
- }
71
- jsi::Object obj = value.getObject(runtime);
72
- if (!JSIConverter<std::optional<FiatAccountDetails>>::canConvert(runtime, obj.getProperty(runtime, "fiatAccountDetails"))) return false;
73
- if (!JSIConverter<std::optional<MarketAccountDetails>>::canConvert(runtime, obj.getProperty(runtime, "marketAccountDetails"))) return false;
74
- return true;
75
- }
76
- };
77
-
78
- } // namespace margelo::nitro