react-native-candle 0.1.27 → 0.1.29
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.
- package/ReactNativeCandle.podspec +1 -1
- package/ios/Sources/CandleLinkSheetWrapperView.swift +4 -4
- package/ios/Sources/RNCandle.swift +76 -36
- package/lib/commonjs/index.js +47 -27
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +47 -27
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +16 -6
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts +28 -6
- package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +16 -6
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/specs/RNCandle.nitro.d.ts +28 -6
- package/lib/typescript/module/src/specs/RNCandle.nitro.d.ts.map +1 -1
- package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Bridge.cpp +12 -12
- package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Bridge.hpp +98 -72
- package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Umbrella.hpp +15 -0
- package/nitrogen/generated/ios/c++/HybridRNCandleSpecSwift.hpp +20 -5
- package/nitrogen/generated/ios/swift/AssetAccountsResponse.swift +70 -0
- package/nitrogen/generated/ios/swift/{Func_void_std__vector_TradeQuote_.swift → Func_void_AssetAccountsResponse.swift} +11 -11
- package/nitrogen/generated/ios/swift/{Func_void_std__vector_AssetAccount_.swift → Func_void_TradeQuotesResponse.swift} +11 -12
- package/nitrogen/generated/ios/swift/{Func_void_std__vector_Trade_.swift → Func_void_TradesResponse.swift} +11 -12
- package/nitrogen/generated/ios/swift/HybridRNCandleSpec.swift +4 -4
- package/nitrogen/generated/ios/swift/HybridRNCandleSpec_cxx.swift +33 -53
- package/nitrogen/generated/ios/swift/LinkedAccountStatusRef.swift +67 -0
- package/nitrogen/generated/ios/swift/StatePayload.swift +42 -0
- package/nitrogen/generated/ios/swift/TradeQuote.swift +13 -2
- package/nitrogen/generated/ios/swift/TradeQuotesResponse.swift +70 -0
- package/nitrogen/generated/ios/swift/TradesResponse.swift +70 -0
- package/nitrogen/generated/ios/swift/TransportAsset.swift +25 -2
- package/nitrogen/generated/shared/c++/AssetAccountsResponse.hpp +78 -0
- package/nitrogen/generated/shared/c++/HybridRNCandleSpec.hpp +19 -10
- package/nitrogen/generated/shared/c++/LinkedAccountStatusRef.hpp +86 -0
- package/nitrogen/generated/shared/c++/StatePayload.hpp +82 -0
- package/nitrogen/generated/shared/c++/TradeQuote.hpp +6 -2
- package/nitrogen/generated/shared/c++/TradeQuotesResponse.hpp +78 -0
- package/nitrogen/generated/shared/c++/TradesResponse.hpp +78 -0
- package/nitrogen/generated/shared/c++/TransportAsset.hpp +9 -1
- package/package.json +1 -1
- package/src/index.ts +52 -25
- package/src/specs/RNCandle.nitro.ts +33 -6
|
@@ -29,18 +29,24 @@ namespace margelo::nitro::rncandle { struct TradeExecutionResult; }
|
|
|
29
29
|
namespace margelo::nitro::rncandle { struct AppUser; }
|
|
30
30
|
// Forward declaration of `LinkedAccountRef` to properly resolve imports.
|
|
31
31
|
namespace margelo::nitro::rncandle { struct LinkedAccountRef; }
|
|
32
|
-
// Forward declaration of `
|
|
33
|
-
namespace margelo::nitro::rncandle { struct
|
|
32
|
+
// Forward declaration of `AssetAccountsResponse` to properly resolve imports.
|
|
33
|
+
namespace margelo::nitro::rncandle { struct AssetAccountsResponse; }
|
|
34
34
|
// Forward declaration of `AssetAccountQuery` to properly resolve imports.
|
|
35
35
|
namespace margelo::nitro::rncandle { struct AssetAccountQuery; }
|
|
36
|
+
// Forward declaration of `AssetAccount` to properly resolve imports.
|
|
37
|
+
namespace margelo::nitro::rncandle { struct AssetAccount; }
|
|
36
38
|
// Forward declaration of `AssetAccountRef` to properly resolve imports.
|
|
37
39
|
namespace margelo::nitro::rncandle { struct AssetAccountRef; }
|
|
38
|
-
// Forward declaration of `
|
|
39
|
-
namespace margelo::nitro::rncandle { struct
|
|
40
|
+
// Forward declaration of `TradesResponse` to properly resolve imports.
|
|
41
|
+
namespace margelo::nitro::rncandle { struct TradesResponse; }
|
|
40
42
|
// Forward declaration of `TradeQuery` to properly resolve imports.
|
|
41
43
|
namespace margelo::nitro::rncandle { struct TradeQuery; }
|
|
44
|
+
// Forward declaration of `Trade` to properly resolve imports.
|
|
45
|
+
namespace margelo::nitro::rncandle { struct Trade; }
|
|
42
46
|
// Forward declaration of `TradeRef` to properly resolve imports.
|
|
43
47
|
namespace margelo::nitro::rncandle { struct TradeRef; }
|
|
48
|
+
// Forward declaration of `TradeQuotesResponse` to properly resolve imports.
|
|
49
|
+
namespace margelo::nitro::rncandle { struct TradeQuotesResponse; }
|
|
44
50
|
// Forward declaration of `TradeQuoteRequest` to properly resolve imports.
|
|
45
51
|
namespace margelo::nitro::rncandle { struct TradeQuoteRequest; }
|
|
46
52
|
// Forward declaration of `AnyMap` to properly resolve imports.
|
|
@@ -61,12 +67,15 @@ namespace margelo::nitro::rncandle { struct ToolCall; }
|
|
|
61
67
|
#include "AppUser.hpp"
|
|
62
68
|
#include <NitroModules/Promise.hpp>
|
|
63
69
|
#include "LinkedAccountRef.hpp"
|
|
64
|
-
#include "
|
|
70
|
+
#include "AssetAccountsResponse.hpp"
|
|
65
71
|
#include "AssetAccountQuery.hpp"
|
|
72
|
+
#include "AssetAccount.hpp"
|
|
66
73
|
#include "AssetAccountRef.hpp"
|
|
67
|
-
#include "
|
|
74
|
+
#include "TradesResponse.hpp"
|
|
68
75
|
#include "TradeQuery.hpp"
|
|
76
|
+
#include "Trade.hpp"
|
|
69
77
|
#include "TradeRef.hpp"
|
|
78
|
+
#include "TradeQuotesResponse.hpp"
|
|
70
79
|
#include "TradeQuoteRequest.hpp"
|
|
71
80
|
#include <NitroModules/AnyMap.hpp>
|
|
72
81
|
#include "ToolCall.hpp"
|
|
@@ -104,15 +113,15 @@ namespace margelo::nitro::rncandle {
|
|
|
104
113
|
// Methods
|
|
105
114
|
virtual void candleLinkSheet(bool isPresented, const std::optional<std::vector<Service>>& services, double cornerRadius, const std::optional<std::string>& customerName, bool showDynamicLoading, PresentationBackground presentationBackground, PresentationStyle presentationStyle, const std::function<void(const LinkedAccount& /* account */)>& onSuccess) = 0;
|
|
106
115
|
virtual void candleTradeExecutionSheet(const TradeQuote& tradeQuote, PresentationBackground presentationBackground, const std::function<void(const TradeExecutionResult& /* result */)>& completion) = 0;
|
|
107
|
-
virtual void initialize(const AppUser& appUser) = 0;
|
|
116
|
+
virtual void initialize(const AppUser& appUser, const std::optional<std::string>& accessGroup) = 0;
|
|
108
117
|
virtual std::shared_ptr<Promise<std::vector<LinkedAccount>>> getLinkedAccounts() = 0;
|
|
109
118
|
virtual std::shared_ptr<Promise<LinkedAccount>> getLinkedAccount(const LinkedAccountRef& ref) = 0;
|
|
110
119
|
virtual std::shared_ptr<Promise<void>> unlinkAccount(const LinkedAccountRef& ref) = 0;
|
|
111
|
-
virtual std::shared_ptr<Promise<
|
|
120
|
+
virtual std::shared_ptr<Promise<AssetAccountsResponse>> getAssetAccounts(const AssetAccountQuery& query) = 0;
|
|
112
121
|
virtual std::shared_ptr<Promise<AssetAccount>> getAssetAccount(const AssetAccountRef& ref) = 0;
|
|
113
|
-
virtual std::shared_ptr<Promise<
|
|
122
|
+
virtual std::shared_ptr<Promise<TradesResponse>> getTrades(const TradeQuery& query) = 0;
|
|
114
123
|
virtual std::shared_ptr<Promise<Trade>> getTrade(const TradeRef& ref) = 0;
|
|
115
|
-
virtual std::shared_ptr<Promise<
|
|
124
|
+
virtual std::shared_ptr<Promise<TradeQuotesResponse>> getTradeQuotes(const TradeQuoteRequest& request) = 0;
|
|
116
125
|
virtual std::shared_ptr<Promise<void>> deleteUser() = 0;
|
|
117
126
|
virtual std::shared_ptr<Promise<std::vector<std::shared_ptr<AnyMap>>>> getAvailableTools() = 0;
|
|
118
127
|
virtual std::shared_ptr<Promise<std::string>> executeTool(const ToolCall& tool) = 0;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// LinkedAccountStatusRef.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 `Service` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::rncandle { enum class Service; }
|
|
23
|
+
// Forward declaration of `StatePayload` to properly resolve imports.
|
|
24
|
+
namespace margelo::nitro::rncandle { enum class StatePayload; }
|
|
25
|
+
|
|
26
|
+
#include <string>
|
|
27
|
+
#include "Service.hpp"
|
|
28
|
+
#include "StatePayload.hpp"
|
|
29
|
+
|
|
30
|
+
namespace margelo::nitro::rncandle {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A struct which can be represented as a JavaScript object (LinkedAccountStatusRef).
|
|
34
|
+
*/
|
|
35
|
+
struct LinkedAccountStatusRef {
|
|
36
|
+
public:
|
|
37
|
+
std::string linkedAccountID SWIFT_PRIVATE;
|
|
38
|
+
Service service SWIFT_PRIVATE;
|
|
39
|
+
std::string serviceUserID SWIFT_PRIVATE;
|
|
40
|
+
StatePayload state SWIFT_PRIVATE;
|
|
41
|
+
|
|
42
|
+
public:
|
|
43
|
+
LinkedAccountStatusRef() = default;
|
|
44
|
+
explicit LinkedAccountStatusRef(std::string linkedAccountID, Service service, std::string serviceUserID, StatePayload state): linkedAccountID(linkedAccountID), service(service), serviceUserID(serviceUserID), state(state) {}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
} // namespace margelo::nitro::rncandle
|
|
48
|
+
|
|
49
|
+
namespace margelo::nitro {
|
|
50
|
+
|
|
51
|
+
using namespace margelo::nitro::rncandle;
|
|
52
|
+
|
|
53
|
+
// C++ LinkedAccountStatusRef <> JS LinkedAccountStatusRef (object)
|
|
54
|
+
template <>
|
|
55
|
+
struct JSIConverter<LinkedAccountStatusRef> final {
|
|
56
|
+
static inline LinkedAccountStatusRef fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
57
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
58
|
+
return LinkedAccountStatusRef(
|
|
59
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "linkedAccountID")),
|
|
60
|
+
JSIConverter<Service>::fromJSI(runtime, obj.getProperty(runtime, "service")),
|
|
61
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "serviceUserID")),
|
|
62
|
+
JSIConverter<StatePayload>::fromJSI(runtime, obj.getProperty(runtime, "state"))
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const LinkedAccountStatusRef& arg) {
|
|
66
|
+
jsi::Object obj(runtime);
|
|
67
|
+
obj.setProperty(runtime, "linkedAccountID", JSIConverter<std::string>::toJSI(runtime, arg.linkedAccountID));
|
|
68
|
+
obj.setProperty(runtime, "service", JSIConverter<Service>::toJSI(runtime, arg.service));
|
|
69
|
+
obj.setProperty(runtime, "serviceUserID", JSIConverter<std::string>::toJSI(runtime, arg.serviceUserID));
|
|
70
|
+
obj.setProperty(runtime, "state", JSIConverter<StatePayload>::toJSI(runtime, arg.state));
|
|
71
|
+
return obj;
|
|
72
|
+
}
|
|
73
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
74
|
+
if (!value.isObject()) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
jsi::Object obj = value.getObject(runtime);
|
|
78
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "linkedAccountID"))) return false;
|
|
79
|
+
if (!JSIConverter<Service>::canConvert(runtime, obj.getProperty(runtime, "service"))) return false;
|
|
80
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "serviceUserID"))) return false;
|
|
81
|
+
if (!JSIConverter<StatePayload>::canConvert(runtime, obj.getProperty(runtime, "state"))) return false;
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// StatePayload.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/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::rncandle {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (StatePayload).
|
|
30
|
+
*/
|
|
31
|
+
enum class StatePayload {
|
|
32
|
+
ACTIVE SWIFT_NAME(active) = 0,
|
|
33
|
+
INACTIVE SWIFT_NAME(inactive) = 1,
|
|
34
|
+
UNAVAILABLE SWIFT_NAME(unavailable) = 2,
|
|
35
|
+
} CLOSED_ENUM;
|
|
36
|
+
|
|
37
|
+
} // namespace margelo::nitro::rncandle
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro {
|
|
40
|
+
|
|
41
|
+
using namespace margelo::nitro::rncandle;
|
|
42
|
+
|
|
43
|
+
// C++ StatePayload <> JS StatePayload (union)
|
|
44
|
+
template <>
|
|
45
|
+
struct JSIConverter<StatePayload> final {
|
|
46
|
+
static inline StatePayload fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
47
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
48
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
49
|
+
case hashString("active"): return StatePayload::ACTIVE;
|
|
50
|
+
case hashString("inactive"): return StatePayload::INACTIVE;
|
|
51
|
+
case hashString("unavailable"): return StatePayload::UNAVAILABLE;
|
|
52
|
+
default: [[unlikely]]
|
|
53
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum StatePayload - invalid value!");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, StatePayload arg) {
|
|
57
|
+
switch (arg) {
|
|
58
|
+
case StatePayload::ACTIVE: return JSIConverter<std::string>::toJSI(runtime, "active");
|
|
59
|
+
case StatePayload::INACTIVE: return JSIConverter<std::string>::toJSI(runtime, "inactive");
|
|
60
|
+
case StatePayload::UNAVAILABLE: return JSIConverter<std::string>::toJSI(runtime, "unavailable");
|
|
61
|
+
default: [[unlikely]]
|
|
62
|
+
throw std::invalid_argument("Cannot convert StatePayload to JS - invalid value: "
|
|
63
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
67
|
+
if (!value.isString()) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
71
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
72
|
+
case hashString("active"):
|
|
73
|
+
case hashString("inactive"):
|
|
74
|
+
case hashString("unavailable"):
|
|
75
|
+
return true;
|
|
76
|
+
default:
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
} // namespace margelo::nitro
|
|
@@ -34,10 +34,11 @@ namespace margelo::nitro::rncandle {
|
|
|
34
34
|
TradeAsset lost SWIFT_PRIVATE;
|
|
35
35
|
TradeAsset gained SWIFT_PRIVATE;
|
|
36
36
|
std::string context SWIFT_PRIVATE;
|
|
37
|
+
std::string expirationDateTime SWIFT_PRIVATE;
|
|
37
38
|
|
|
38
39
|
public:
|
|
39
40
|
TradeQuote() = default;
|
|
40
|
-
explicit TradeQuote(TradeAsset lost, TradeAsset gained, std::string context): lost(lost), gained(gained), context(context) {}
|
|
41
|
+
explicit TradeQuote(TradeAsset lost, TradeAsset gained, std::string context, std::string expirationDateTime): lost(lost), gained(gained), context(context), expirationDateTime(expirationDateTime) {}
|
|
41
42
|
};
|
|
42
43
|
|
|
43
44
|
} // namespace margelo::nitro::rncandle
|
|
@@ -54,7 +55,8 @@ namespace margelo::nitro {
|
|
|
54
55
|
return TradeQuote(
|
|
55
56
|
JSIConverter<TradeAsset>::fromJSI(runtime, obj.getProperty(runtime, "lost")),
|
|
56
57
|
JSIConverter<TradeAsset>::fromJSI(runtime, obj.getProperty(runtime, "gained")),
|
|
57
|
-
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "context"))
|
|
58
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "context")),
|
|
59
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "expirationDateTime"))
|
|
58
60
|
);
|
|
59
61
|
}
|
|
60
62
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const TradeQuote& arg) {
|
|
@@ -62,6 +64,7 @@ namespace margelo::nitro {
|
|
|
62
64
|
obj.setProperty(runtime, "lost", JSIConverter<TradeAsset>::toJSI(runtime, arg.lost));
|
|
63
65
|
obj.setProperty(runtime, "gained", JSIConverter<TradeAsset>::toJSI(runtime, arg.gained));
|
|
64
66
|
obj.setProperty(runtime, "context", JSIConverter<std::string>::toJSI(runtime, arg.context));
|
|
67
|
+
obj.setProperty(runtime, "expirationDateTime", JSIConverter<std::string>::toJSI(runtime, arg.expirationDateTime));
|
|
65
68
|
return obj;
|
|
66
69
|
}
|
|
67
70
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -72,6 +75,7 @@ namespace margelo::nitro {
|
|
|
72
75
|
if (!JSIConverter<TradeAsset>::canConvert(runtime, obj.getProperty(runtime, "lost"))) return false;
|
|
73
76
|
if (!JSIConverter<TradeAsset>::canConvert(runtime, obj.getProperty(runtime, "gained"))) return false;
|
|
74
77
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "context"))) return false;
|
|
78
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "expirationDateTime"))) return false;
|
|
75
79
|
return true;
|
|
76
80
|
}
|
|
77
81
|
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// TradeQuotesResponse.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 `LinkedAccountStatusRef` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::rncandle { struct LinkedAccountStatusRef; }
|
|
23
|
+
// Forward declaration of `TradeQuote` to properly resolve imports.
|
|
24
|
+
namespace margelo::nitro::rncandle { struct TradeQuote; }
|
|
25
|
+
|
|
26
|
+
#include <vector>
|
|
27
|
+
#include "LinkedAccountStatusRef.hpp"
|
|
28
|
+
#include "TradeQuote.hpp"
|
|
29
|
+
|
|
30
|
+
namespace margelo::nitro::rncandle {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A struct which can be represented as a JavaScript object (TradeQuotesResponse).
|
|
34
|
+
*/
|
|
35
|
+
struct TradeQuotesResponse {
|
|
36
|
+
public:
|
|
37
|
+
std::vector<LinkedAccountStatusRef> linkedAccounts SWIFT_PRIVATE;
|
|
38
|
+
std::vector<TradeQuote> tradeQuotes SWIFT_PRIVATE;
|
|
39
|
+
|
|
40
|
+
public:
|
|
41
|
+
TradeQuotesResponse() = default;
|
|
42
|
+
explicit TradeQuotesResponse(std::vector<LinkedAccountStatusRef> linkedAccounts, std::vector<TradeQuote> tradeQuotes): linkedAccounts(linkedAccounts), tradeQuotes(tradeQuotes) {}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
} // namespace margelo::nitro::rncandle
|
|
46
|
+
|
|
47
|
+
namespace margelo::nitro {
|
|
48
|
+
|
|
49
|
+
using namespace margelo::nitro::rncandle;
|
|
50
|
+
|
|
51
|
+
// C++ TradeQuotesResponse <> JS TradeQuotesResponse (object)
|
|
52
|
+
template <>
|
|
53
|
+
struct JSIConverter<TradeQuotesResponse> final {
|
|
54
|
+
static inline TradeQuotesResponse fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
55
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
56
|
+
return TradeQuotesResponse(
|
|
57
|
+
JSIConverter<std::vector<LinkedAccountStatusRef>>::fromJSI(runtime, obj.getProperty(runtime, "linkedAccounts")),
|
|
58
|
+
JSIConverter<std::vector<TradeQuote>>::fromJSI(runtime, obj.getProperty(runtime, "tradeQuotes"))
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const TradeQuotesResponse& arg) {
|
|
62
|
+
jsi::Object obj(runtime);
|
|
63
|
+
obj.setProperty(runtime, "linkedAccounts", JSIConverter<std::vector<LinkedAccountStatusRef>>::toJSI(runtime, arg.linkedAccounts));
|
|
64
|
+
obj.setProperty(runtime, "tradeQuotes", JSIConverter<std::vector<TradeQuote>>::toJSI(runtime, arg.tradeQuotes));
|
|
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::vector<LinkedAccountStatusRef>>::canConvert(runtime, obj.getProperty(runtime, "linkedAccounts"))) return false;
|
|
73
|
+
if (!JSIConverter<std::vector<TradeQuote>>::canConvert(runtime, obj.getProperty(runtime, "tradeQuotes"))) return false;
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// TradesResponse.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 `LinkedAccountStatusRef` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::rncandle { struct LinkedAccountStatusRef; }
|
|
23
|
+
// Forward declaration of `Trade` to properly resolve imports.
|
|
24
|
+
namespace margelo::nitro::rncandle { struct Trade; }
|
|
25
|
+
|
|
26
|
+
#include <vector>
|
|
27
|
+
#include "LinkedAccountStatusRef.hpp"
|
|
28
|
+
#include "Trade.hpp"
|
|
29
|
+
|
|
30
|
+
namespace margelo::nitro::rncandle {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A struct which can be represented as a JavaScript object (TradesResponse).
|
|
34
|
+
*/
|
|
35
|
+
struct TradesResponse {
|
|
36
|
+
public:
|
|
37
|
+
std::vector<LinkedAccountStatusRef> linkedAccounts SWIFT_PRIVATE;
|
|
38
|
+
std::vector<Trade> trades SWIFT_PRIVATE;
|
|
39
|
+
|
|
40
|
+
public:
|
|
41
|
+
TradesResponse() = default;
|
|
42
|
+
explicit TradesResponse(std::vector<LinkedAccountStatusRef> linkedAccounts, std::vector<Trade> trades): linkedAccounts(linkedAccounts), trades(trades) {}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
} // namespace margelo::nitro::rncandle
|
|
46
|
+
|
|
47
|
+
namespace margelo::nitro {
|
|
48
|
+
|
|
49
|
+
using namespace margelo::nitro::rncandle;
|
|
50
|
+
|
|
51
|
+
// C++ TradesResponse <> JS TradesResponse (object)
|
|
52
|
+
template <>
|
|
53
|
+
struct JSIConverter<TradesResponse> final {
|
|
54
|
+
static inline TradesResponse fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
55
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
56
|
+
return TradesResponse(
|
|
57
|
+
JSIConverter<std::vector<LinkedAccountStatusRef>>::fromJSI(runtime, obj.getProperty(runtime, "linkedAccounts")),
|
|
58
|
+
JSIConverter<std::vector<Trade>>::fromJSI(runtime, obj.getProperty(runtime, "trades"))
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const TradesResponse& arg) {
|
|
62
|
+
jsi::Object obj(runtime);
|
|
63
|
+
obj.setProperty(runtime, "linkedAccounts", JSIConverter<std::vector<LinkedAccountStatusRef>>::toJSI(runtime, arg.linkedAccounts));
|
|
64
|
+
obj.setProperty(runtime, "trades", JSIConverter<std::vector<Trade>>::toJSI(runtime, arg.trades));
|
|
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::vector<LinkedAccountStatusRef>>::canConvert(runtime, obj.getProperty(runtime, "linkedAccounts"))) return false;
|
|
73
|
+
if (!JSIConverter<std::vector<Trade>>::canConvert(runtime, obj.getProperty(runtime, "trades"))) return false;
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
} // namespace margelo::nitro
|
|
@@ -48,12 +48,14 @@ namespace margelo::nitro::rncandle {
|
|
|
48
48
|
Coordinates destinationCoordinates SWIFT_PRIVATE;
|
|
49
49
|
Address destinationAddress SWIFT_PRIVATE;
|
|
50
50
|
double seats SWIFT_PRIVATE;
|
|
51
|
+
std::string departureDateTime SWIFT_PRIVATE;
|
|
52
|
+
std::string arrivalDateTime SWIFT_PRIVATE;
|
|
51
53
|
std::string linkedAccountID SWIFT_PRIVATE;
|
|
52
54
|
Service service SWIFT_PRIVATE;
|
|
53
55
|
|
|
54
56
|
public:
|
|
55
57
|
TransportAsset() = default;
|
|
56
|
-
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 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), linkedAccountID(linkedAccountID), service(service) {}
|
|
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) {}
|
|
57
59
|
};
|
|
58
60
|
|
|
59
61
|
} // namespace margelo::nitro::rncandle
|
|
@@ -79,6 +81,8 @@ namespace margelo::nitro {
|
|
|
79
81
|
JSIConverter<Coordinates>::fromJSI(runtime, obj.getProperty(runtime, "destinationCoordinates")),
|
|
80
82
|
JSIConverter<Address>::fromJSI(runtime, obj.getProperty(runtime, "destinationAddress")),
|
|
81
83
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "seats")),
|
|
84
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "departureDateTime")),
|
|
85
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "arrivalDateTime")),
|
|
82
86
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "linkedAccountID")),
|
|
83
87
|
JSIConverter<Service>::fromJSI(runtime, obj.getProperty(runtime, "service"))
|
|
84
88
|
);
|
|
@@ -96,6 +100,8 @@ namespace margelo::nitro {
|
|
|
96
100
|
obj.setProperty(runtime, "destinationCoordinates", JSIConverter<Coordinates>::toJSI(runtime, arg.destinationCoordinates));
|
|
97
101
|
obj.setProperty(runtime, "destinationAddress", JSIConverter<Address>::toJSI(runtime, arg.destinationAddress));
|
|
98
102
|
obj.setProperty(runtime, "seats", JSIConverter<double>::toJSI(runtime, arg.seats));
|
|
103
|
+
obj.setProperty(runtime, "departureDateTime", JSIConverter<std::string>::toJSI(runtime, arg.departureDateTime));
|
|
104
|
+
obj.setProperty(runtime, "arrivalDateTime", JSIConverter<std::string>::toJSI(runtime, arg.arrivalDateTime));
|
|
99
105
|
obj.setProperty(runtime, "linkedAccountID", JSIConverter<std::string>::toJSI(runtime, arg.linkedAccountID));
|
|
100
106
|
obj.setProperty(runtime, "service", JSIConverter<Service>::toJSI(runtime, arg.service));
|
|
101
107
|
return obj;
|
|
@@ -116,6 +122,8 @@ namespace margelo::nitro {
|
|
|
116
122
|
if (!JSIConverter<Coordinates>::canConvert(runtime, obj.getProperty(runtime, "destinationCoordinates"))) return false;
|
|
117
123
|
if (!JSIConverter<Address>::canConvert(runtime, obj.getProperty(runtime, "destinationAddress"))) return false;
|
|
118
124
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "seats"))) return false;
|
|
125
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "departureDateTime"))) return false;
|
|
126
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "arrivalDateTime"))) return false;
|
|
119
127
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "linkedAccountID"))) return false;
|
|
120
128
|
if (!JSIConverter<Service>::canConvert(runtime, obj.getProperty(runtime, "service"))) return false;
|
|
121
129
|
return true;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -38,16 +38,19 @@ import type {
|
|
|
38
38
|
FiatAssetRef,
|
|
39
39
|
MarketTradeAssetRef,
|
|
40
40
|
TradeAssetRef as InternalTradeAssetRef,
|
|
41
|
+
LinkedAccountStatusRef,
|
|
42
|
+
Coordinates,
|
|
43
|
+
Address,
|
|
41
44
|
} from "./specs/RNCandle.nitro";
|
|
42
45
|
|
|
43
46
|
export class CandleClient {
|
|
44
47
|
private candle: RNCandle;
|
|
45
48
|
|
|
46
|
-
constructor(appUser: AppUser) {
|
|
49
|
+
constructor(appUser: AppUser, accessGroup?: string) {
|
|
47
50
|
const CandleHybridObject =
|
|
48
51
|
NitroModules.createHybridObject<RNCandle>("RNCandle");
|
|
49
52
|
this.candle = CandleHybridObject;
|
|
50
|
-
this.candle.initialize(appUser);
|
|
53
|
+
this.candle.initialize(appUser, accessGroup);
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
public presentTradeExecutionSheet(input: {
|
|
@@ -182,11 +185,18 @@ export class CandleClient {
|
|
|
182
185
|
return this.candle.executeTool(tool);
|
|
183
186
|
}
|
|
184
187
|
|
|
185
|
-
public async getAssetAccounts(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
public async getAssetAccounts(query: AssetAccountQuery = {}): Promise<{
|
|
189
|
+
assetAccounts: AssetAccount[];
|
|
190
|
+
linkedAccounts: LinkedAccountStatusRef[];
|
|
191
|
+
}> {
|
|
192
|
+
const { assetAccounts, linkedAccounts } =
|
|
193
|
+
await this.candle.getAssetAccounts(query);
|
|
194
|
+
return {
|
|
195
|
+
assetAccounts: assetAccounts.map((account) =>
|
|
196
|
+
this.convertToAssetAccount(account)
|
|
197
|
+
),
|
|
198
|
+
linkedAccounts,
|
|
199
|
+
};
|
|
190
200
|
}
|
|
191
201
|
|
|
192
202
|
public async getAssetAccount(ref: AssetAccountRef): Promise<AssetAccount> {
|
|
@@ -194,15 +204,21 @@ export class CandleClient {
|
|
|
194
204
|
return this.convertToAssetAccount(account);
|
|
195
205
|
}
|
|
196
206
|
|
|
197
|
-
public async getTrades(query: TradeQuery = {}): Promise<
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
207
|
+
public async getTrades(query: TradeQuery = {}): Promise<{
|
|
208
|
+
trades: Trade[];
|
|
209
|
+
linkedAccounts: LinkedAccountStatusRef[];
|
|
210
|
+
}> {
|
|
211
|
+
const { trades, linkedAccounts } = await this.candle.getTrades(query);
|
|
212
|
+
return {
|
|
213
|
+
trades: trades.map(({ dateTime, counterparty, gained, lost, state }) => ({
|
|
214
|
+
dateTime,
|
|
215
|
+
state,
|
|
216
|
+
counterparty: this.convertToCounterparty(counterparty),
|
|
217
|
+
lost: this.convertTradeAsset(lost),
|
|
218
|
+
gained: this.convertTradeAsset(gained),
|
|
219
|
+
})),
|
|
220
|
+
linkedAccounts,
|
|
221
|
+
};
|
|
206
222
|
}
|
|
207
223
|
|
|
208
224
|
public async getTrade(input: {
|
|
@@ -231,7 +247,10 @@ export class CandleClient {
|
|
|
231
247
|
| ({ assetKind: "transport" } & TransportAssetQuoteRequest)
|
|
232
248
|
| ({ assetKind: "fiat" } & FiatAssetQuoteRequest)
|
|
233
249
|
| ({ assetKind: "stock" | "crypto" } & MarketAssetQuoteRequest);
|
|
234
|
-
}): Promise<
|
|
250
|
+
}): Promise<{
|
|
251
|
+
tradeQuotes: TradeQuote[];
|
|
252
|
+
linkedAccounts: LinkedAccountStatusRef[];
|
|
253
|
+
}> {
|
|
235
254
|
let gainedRequest: TradeAssetQuoteRequest;
|
|
236
255
|
|
|
237
256
|
switch (request.gained.assetKind) {
|
|
@@ -250,18 +269,22 @@ export class CandleClient {
|
|
|
250
269
|
break;
|
|
251
270
|
}
|
|
252
271
|
|
|
253
|
-
const
|
|
272
|
+
const { linkedAccounts, tradeQuotes } = await this.candle.getTradeQuotes({
|
|
254
273
|
linkedAccountIDs: request.linkedAccountIDs,
|
|
255
274
|
gained: gainedRequest,
|
|
256
275
|
});
|
|
257
276
|
|
|
258
|
-
return
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
277
|
+
return {
|
|
278
|
+
tradeQuotes: tradeQuotes.map((quote) => {
|
|
279
|
+
return {
|
|
280
|
+
gained: this.convertTradeAsset(quote.gained),
|
|
281
|
+
lost: this.convertTradeAsset(quote.lost),
|
|
282
|
+
context: quote.context,
|
|
283
|
+
expirationDateTime: quote.expirationDateTime,
|
|
284
|
+
};
|
|
285
|
+
}),
|
|
286
|
+
linkedAccounts,
|
|
287
|
+
};
|
|
265
288
|
}
|
|
266
289
|
|
|
267
290
|
private convertTradeAssetRef(
|
|
@@ -335,6 +358,7 @@ export class CandleClient {
|
|
|
335
358
|
context,
|
|
336
359
|
gained: this.toInternalTradeAsset(gained),
|
|
337
360
|
lost: this.toInternalTradeAsset(lost),
|
|
361
|
+
expirationDateTime: tradeQuote.expirationDateTime,
|
|
338
362
|
};
|
|
339
363
|
}
|
|
340
364
|
|
|
@@ -455,6 +479,7 @@ type TradeQuote = {
|
|
|
455
479
|
gained: TradeAsset;
|
|
456
480
|
lost: TradeAsset;
|
|
457
481
|
context: string;
|
|
482
|
+
expirationDateTime: string;
|
|
458
483
|
};
|
|
459
484
|
|
|
460
485
|
type TradeQueryAssetKind =
|
|
@@ -516,4 +541,6 @@ export type {
|
|
|
516
541
|
Counterparty,
|
|
517
542
|
AssetAccount,
|
|
518
543
|
TradeQuote,
|
|
544
|
+
Coordinates,
|
|
545
|
+
Address,
|
|
519
546
|
};
|