react-native-candle 0.1.20 → 0.1.21
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/CandleActionViewModel.swift +13 -0
- package/ios/Sources/CandleTradeExecutionSheetWrapper.swift +31 -0
- package/ios/Sources/HostingViewController.swift +7 -0
- package/ios/Sources/RNCandle.swift +166 -39
- package/lib/commonjs/index.js +77 -13
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +77 -13
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +21 -7
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts +6 -1
- package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +21 -7
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/specs/RNCandle.nitro.d.ts +6 -1
- package/lib/typescript/module/src/specs/RNCandle.nitro.d.ts.map +1 -1
- package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Bridge.cpp +8 -0
- package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Bridge.hpp +115 -81
- package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Umbrella.hpp +3 -3
- package/nitrogen/generated/ios/c++/HybridRNCandleSpecSwift.hpp +57 -59
- package/nitrogen/generated/ios/swift/Func_void_TradeExecutionResult.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridRNCandleSpec.swift +3 -1
- package/nitrogen/generated/ios/swift/HybridRNCandleSpec_cxx.swift +23 -21
- package/nitrogen/generated/ios/swift/TradeExecutionResult.swift +82 -0
- package/nitrogen/generated/ios/swift/TradeQuote.swift +13 -2
- package/nitrogen/generated/shared/c++/HybridRNCandleSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridRNCandleSpec.hpp +7 -7
- package/nitrogen/generated/shared/c++/TradeExecutionResult.hpp +76 -0
- package/nitrogen/generated/shared/c++/TradeQuote.hpp +7 -2
- package/package.json +1 -1
- package/src/index.ts +88 -20
- package/src/specs/RNCandle.nitro.ts +11 -1
- package/nitrogen/generated/ios/swift/ExecuteTradeRequest.swift +0 -44
- package/nitrogen/generated/shared/c++/ExecuteTradeRequest.hpp +0 -73
|
@@ -34,8 +34,6 @@ namespace margelo::nitro::rncandle { struct AssetAccount; }
|
|
|
34
34
|
namespace margelo::nitro::rncandle { struct Coordinates; }
|
|
35
35
|
// Forward declaration of `Counterparty` to properly resolve imports.
|
|
36
36
|
namespace margelo::nitro::rncandle { struct Counterparty; }
|
|
37
|
-
// Forward declaration of `ExecuteTradeRequest` to properly resolve imports.
|
|
38
|
-
namespace margelo::nitro::rncandle { struct ExecuteTradeRequest; }
|
|
39
37
|
// Forward declaration of `FiatAccountDetails` to properly resolve imports.
|
|
40
38
|
namespace margelo::nitro::rncandle { struct FiatAccountDetails; }
|
|
41
39
|
// Forward declaration of `FiatAssetQuoteRequest` to properly resolve imports.
|
|
@@ -94,6 +92,8 @@ namespace margelo::nitro::rncandle { struct TradeAssetQuoteRequest; }
|
|
|
94
92
|
namespace margelo::nitro::rncandle { struct TradeAssetRef; }
|
|
95
93
|
// Forward declaration of `TradeAsset` to properly resolve imports.
|
|
96
94
|
namespace margelo::nitro::rncandle { struct TradeAsset; }
|
|
95
|
+
// Forward declaration of `TradeExecutionResult` to properly resolve imports.
|
|
96
|
+
namespace margelo::nitro::rncandle { struct TradeExecutionResult; }
|
|
97
97
|
// Forward declaration of `TradeQuery` to properly resolve imports.
|
|
98
98
|
namespace margelo::nitro::rncandle { struct TradeQuery; }
|
|
99
99
|
// Forward declaration of `TradeQuoteRequest` to properly resolve imports.
|
|
@@ -130,7 +130,6 @@ namespace margelo::nitro::rncandle { struct WireDetails; }
|
|
|
130
130
|
#include "AssetAccountRef.hpp"
|
|
131
131
|
#include "Coordinates.hpp"
|
|
132
132
|
#include "Counterparty.hpp"
|
|
133
|
-
#include "ExecuteTradeRequest.hpp"
|
|
134
133
|
#include "FiatAccountDetails.hpp"
|
|
135
134
|
#include "FiatAsset.hpp"
|
|
136
135
|
#include "FiatAssetQuoteRequest.hpp"
|
|
@@ -161,6 +160,7 @@ namespace margelo::nitro::rncandle { struct WireDetails; }
|
|
|
161
160
|
#include "TradeAsset.hpp"
|
|
162
161
|
#include "TradeAssetQuoteRequest.hpp"
|
|
163
162
|
#include "TradeAssetRef.hpp"
|
|
163
|
+
#include "TradeExecutionResult.hpp"
|
|
164
164
|
#include "TradeQuery.hpp"
|
|
165
165
|
#include "TradeQuote.hpp"
|
|
166
166
|
#include "TradeQuoteRequest.hpp"
|
|
@@ -26,6 +26,40 @@ namespace margelo::nitro::rncandle { struct LinkedAccountDetails; }
|
|
|
26
26
|
namespace margelo::nitro::rncandle { struct ActiveLinkedAccountDetails; }
|
|
27
27
|
// Forward declaration of `InactiveLinkedAccountDetails` to properly resolve imports.
|
|
28
28
|
namespace margelo::nitro::rncandle { struct InactiveLinkedAccountDetails; }
|
|
29
|
+
// Forward declaration of `TradeQuote` to properly resolve imports.
|
|
30
|
+
namespace margelo::nitro::rncandle { struct TradeQuote; }
|
|
31
|
+
// Forward declaration of `TradeAsset` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::rncandle { struct TradeAsset; }
|
|
33
|
+
// Forward declaration of `FiatAsset` to properly resolve imports.
|
|
34
|
+
namespace margelo::nitro::rncandle { struct FiatAsset; }
|
|
35
|
+
// Forward declaration of `MarketTradeAsset` to properly resolve imports.
|
|
36
|
+
namespace margelo::nitro::rncandle { struct MarketTradeAsset; }
|
|
37
|
+
// Forward declaration of `TransportAsset` to properly resolve imports.
|
|
38
|
+
namespace margelo::nitro::rncandle { struct TransportAsset; }
|
|
39
|
+
// Forward declaration of `Coordinates` to properly resolve imports.
|
|
40
|
+
namespace margelo::nitro::rncandle { struct Coordinates; }
|
|
41
|
+
// Forward declaration of `Address` to properly resolve imports.
|
|
42
|
+
namespace margelo::nitro::rncandle { struct Address; }
|
|
43
|
+
// Forward declaration of `OtherAsset` to properly resolve imports.
|
|
44
|
+
namespace margelo::nitro::rncandle { struct OtherAsset; }
|
|
45
|
+
// Forward declaration of `NothingAsset` to properly resolve imports.
|
|
46
|
+
namespace margelo::nitro::rncandle { struct NothingAsset; }
|
|
47
|
+
// Forward declaration of `TradeExecutionResult` to properly resolve imports.
|
|
48
|
+
namespace margelo::nitro::rncandle { struct TradeExecutionResult; }
|
|
49
|
+
// Forward declaration of `Trade` to properly resolve imports.
|
|
50
|
+
namespace margelo::nitro::rncandle { struct Trade; }
|
|
51
|
+
// Forward declaration of `TradeState` to properly resolve imports.
|
|
52
|
+
namespace margelo::nitro::rncandle { enum class TradeState; }
|
|
53
|
+
// Forward declaration of `Counterparty` to properly resolve imports.
|
|
54
|
+
namespace margelo::nitro::rncandle { struct Counterparty; }
|
|
55
|
+
// Forward declaration of `MerchantCounterparty` to properly resolve imports.
|
|
56
|
+
namespace margelo::nitro::rncandle { struct MerchantCounterparty; }
|
|
57
|
+
// Forward declaration of `MerchantLocation` to properly resolve imports.
|
|
58
|
+
namespace margelo::nitro::rncandle { struct MerchantLocation; }
|
|
59
|
+
// Forward declaration of `UserCounterparty` to properly resolve imports.
|
|
60
|
+
namespace margelo::nitro::rncandle { struct UserCounterparty; }
|
|
61
|
+
// Forward declaration of `ServiceCounterparty` to properly resolve imports.
|
|
62
|
+
namespace margelo::nitro::rncandle { struct ServiceCounterparty; }
|
|
29
63
|
// Forward declaration of `AppUser` to properly resolve imports.
|
|
30
64
|
namespace margelo::nitro::rncandle { struct AppUser; }
|
|
31
65
|
// Forward declaration of `LinkedAccountRef` to properly resolve imports.
|
|
@@ -52,36 +86,6 @@ namespace margelo::nitro::rncandle { struct AssetAccountQuery; }
|
|
|
52
86
|
namespace margelo::nitro::rncandle { enum class AssetAccountKind; }
|
|
53
87
|
// Forward declaration of `AssetAccountRef` to properly resolve imports.
|
|
54
88
|
namespace margelo::nitro::rncandle { struct AssetAccountRef; }
|
|
55
|
-
// Forward declaration of `Trade` to properly resolve imports.
|
|
56
|
-
namespace margelo::nitro::rncandle { struct Trade; }
|
|
57
|
-
// Forward declaration of `TradeState` to properly resolve imports.
|
|
58
|
-
namespace margelo::nitro::rncandle { enum class TradeState; }
|
|
59
|
-
// Forward declaration of `Counterparty` to properly resolve imports.
|
|
60
|
-
namespace margelo::nitro::rncandle { struct Counterparty; }
|
|
61
|
-
// Forward declaration of `MerchantCounterparty` to properly resolve imports.
|
|
62
|
-
namespace margelo::nitro::rncandle { struct MerchantCounterparty; }
|
|
63
|
-
// Forward declaration of `MerchantLocation` to properly resolve imports.
|
|
64
|
-
namespace margelo::nitro::rncandle { struct MerchantLocation; }
|
|
65
|
-
// Forward declaration of `UserCounterparty` to properly resolve imports.
|
|
66
|
-
namespace margelo::nitro::rncandle { struct UserCounterparty; }
|
|
67
|
-
// Forward declaration of `ServiceCounterparty` to properly resolve imports.
|
|
68
|
-
namespace margelo::nitro::rncandle { struct ServiceCounterparty; }
|
|
69
|
-
// Forward declaration of `TradeAsset` to properly resolve imports.
|
|
70
|
-
namespace margelo::nitro::rncandle { struct TradeAsset; }
|
|
71
|
-
// Forward declaration of `FiatAsset` to properly resolve imports.
|
|
72
|
-
namespace margelo::nitro::rncandle { struct FiatAsset; }
|
|
73
|
-
// Forward declaration of `MarketTradeAsset` to properly resolve imports.
|
|
74
|
-
namespace margelo::nitro::rncandle { struct MarketTradeAsset; }
|
|
75
|
-
// Forward declaration of `TransportAsset` to properly resolve imports.
|
|
76
|
-
namespace margelo::nitro::rncandle { struct TransportAsset; }
|
|
77
|
-
// Forward declaration of `Coordinates` to properly resolve imports.
|
|
78
|
-
namespace margelo::nitro::rncandle { struct Coordinates; }
|
|
79
|
-
// Forward declaration of `Address` to properly resolve imports.
|
|
80
|
-
namespace margelo::nitro::rncandle { struct Address; }
|
|
81
|
-
// Forward declaration of `OtherAsset` to properly resolve imports.
|
|
82
|
-
namespace margelo::nitro::rncandle { struct OtherAsset; }
|
|
83
|
-
// Forward declaration of `NothingAsset` to properly resolve imports.
|
|
84
|
-
namespace margelo::nitro::rncandle { struct NothingAsset; }
|
|
85
89
|
// Forward declaration of `TradeQuery` to properly resolve imports.
|
|
86
90
|
namespace margelo::nitro::rncandle { struct TradeQuery; }
|
|
87
91
|
// Forward declaration of `TradeRef` to properly resolve imports.
|
|
@@ -98,8 +102,6 @@ namespace margelo::nitro::rncandle { struct TransportAssetRef; }
|
|
|
98
102
|
namespace margelo::nitro::rncandle { struct OtherAssetRef; }
|
|
99
103
|
// Forward declaration of `NothingAssetRef` to properly resolve imports.
|
|
100
104
|
namespace margelo::nitro::rncandle { struct NothingAssetRef; }
|
|
101
|
-
// Forward declaration of `TradeQuote` to properly resolve imports.
|
|
102
|
-
namespace margelo::nitro::rncandle { struct TradeQuote; }
|
|
103
105
|
// Forward declaration of `TradeQuoteRequest` to properly resolve imports.
|
|
104
106
|
namespace margelo::nitro::rncandle { struct TradeQuoteRequest; }
|
|
105
107
|
// Forward declaration of `TradeAssetQuoteRequest` to properly resolve imports.
|
|
@@ -112,8 +114,6 @@ namespace margelo::nitro::rncandle { struct MarketAssetQuoteRequest; }
|
|
|
112
114
|
namespace margelo::nitro::rncandle { struct TransportAssetQuoteRequest; }
|
|
113
115
|
// Forward declaration of `NothingAssetQuoteRequest` to properly resolve imports.
|
|
114
116
|
namespace margelo::nitro::rncandle { struct NothingAssetQuoteRequest; }
|
|
115
|
-
// Forward declaration of `ExecuteTradeRequest` to properly resolve imports.
|
|
116
|
-
namespace margelo::nitro::rncandle { struct ExecuteTradeRequest; }
|
|
117
117
|
// Forward declaration of `AnyMap` to properly resolve imports.
|
|
118
118
|
namespace NitroModules { class AnyMap; }
|
|
119
119
|
// Forward declaration of `ToolCall` to properly resolve imports.
|
|
@@ -130,6 +130,23 @@ namespace margelo::nitro::rncandle { struct ToolCall; }
|
|
|
130
130
|
#include "LinkedAccountDetails.hpp"
|
|
131
131
|
#include "ActiveLinkedAccountDetails.hpp"
|
|
132
132
|
#include "InactiveLinkedAccountDetails.hpp"
|
|
133
|
+
#include "TradeQuote.hpp"
|
|
134
|
+
#include "TradeAsset.hpp"
|
|
135
|
+
#include "FiatAsset.hpp"
|
|
136
|
+
#include "MarketTradeAsset.hpp"
|
|
137
|
+
#include "TransportAsset.hpp"
|
|
138
|
+
#include "Coordinates.hpp"
|
|
139
|
+
#include "Address.hpp"
|
|
140
|
+
#include "OtherAsset.hpp"
|
|
141
|
+
#include "NothingAsset.hpp"
|
|
142
|
+
#include "TradeExecutionResult.hpp"
|
|
143
|
+
#include "Trade.hpp"
|
|
144
|
+
#include "TradeState.hpp"
|
|
145
|
+
#include "Counterparty.hpp"
|
|
146
|
+
#include "MerchantCounterparty.hpp"
|
|
147
|
+
#include "MerchantLocation.hpp"
|
|
148
|
+
#include "UserCounterparty.hpp"
|
|
149
|
+
#include "ServiceCounterparty.hpp"
|
|
133
150
|
#include "AppUser.hpp"
|
|
134
151
|
#include <NitroModules/Promise.hpp>
|
|
135
152
|
#include "LinkedAccountRef.hpp"
|
|
@@ -144,21 +161,6 @@ namespace margelo::nitro::rncandle { struct ToolCall; }
|
|
|
144
161
|
#include "AssetAccountQuery.hpp"
|
|
145
162
|
#include "AssetAccountKind.hpp"
|
|
146
163
|
#include "AssetAccountRef.hpp"
|
|
147
|
-
#include "Trade.hpp"
|
|
148
|
-
#include "TradeState.hpp"
|
|
149
|
-
#include "Counterparty.hpp"
|
|
150
|
-
#include "MerchantCounterparty.hpp"
|
|
151
|
-
#include "MerchantLocation.hpp"
|
|
152
|
-
#include "UserCounterparty.hpp"
|
|
153
|
-
#include "ServiceCounterparty.hpp"
|
|
154
|
-
#include "TradeAsset.hpp"
|
|
155
|
-
#include "FiatAsset.hpp"
|
|
156
|
-
#include "MarketTradeAsset.hpp"
|
|
157
|
-
#include "TransportAsset.hpp"
|
|
158
|
-
#include "Coordinates.hpp"
|
|
159
|
-
#include "Address.hpp"
|
|
160
|
-
#include "OtherAsset.hpp"
|
|
161
|
-
#include "NothingAsset.hpp"
|
|
162
164
|
#include "TradeQuery.hpp"
|
|
163
165
|
#include "TradeRef.hpp"
|
|
164
166
|
#include "TradeAssetRef.hpp"
|
|
@@ -167,14 +169,12 @@ namespace margelo::nitro::rncandle { struct ToolCall; }
|
|
|
167
169
|
#include "TransportAssetRef.hpp"
|
|
168
170
|
#include "OtherAssetRef.hpp"
|
|
169
171
|
#include "NothingAssetRef.hpp"
|
|
170
|
-
#include "TradeQuote.hpp"
|
|
171
172
|
#include "TradeQuoteRequest.hpp"
|
|
172
173
|
#include "TradeAssetQuoteRequest.hpp"
|
|
173
174
|
#include "FiatAssetQuoteRequest.hpp"
|
|
174
175
|
#include "MarketAssetQuoteRequest.hpp"
|
|
175
176
|
#include "TransportAssetQuoteRequest.hpp"
|
|
176
177
|
#include "NothingAssetQuoteRequest.hpp"
|
|
177
|
-
#include "ExecuteTradeRequest.hpp"
|
|
178
178
|
#include <NitroModules/AnyMap.hpp>
|
|
179
179
|
#include "ToolCall.hpp"
|
|
180
180
|
|
|
@@ -223,6 +223,12 @@ namespace margelo::nitro::rncandle {
|
|
|
223
223
|
std::rethrow_exception(__result.error());
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
|
+
inline void candleTradeExecutionSheet(const TradeQuote& tradeQuote, PresentationBackground presentationBackground, const std::function<void(const TradeExecutionResult& /* result */)>& completion) override {
|
|
227
|
+
auto __result = _swiftPart.candleTradeExecutionSheet(tradeQuote, static_cast<int>(presentationBackground), completion);
|
|
228
|
+
if (__result.hasError()) [[unlikely]] {
|
|
229
|
+
std::rethrow_exception(__result.error());
|
|
230
|
+
}
|
|
231
|
+
}
|
|
226
232
|
inline void initialize(const AppUser& appUser) override {
|
|
227
233
|
auto __result = _swiftPart.initialize(appUser);
|
|
228
234
|
if (__result.hasError()) [[unlikely]] {
|
|
@@ -293,14 +299,6 @@ namespace margelo::nitro::rncandle {
|
|
|
293
299
|
auto __value = std::move(__result.value());
|
|
294
300
|
return __value;
|
|
295
301
|
}
|
|
296
|
-
inline std::shared_ptr<Promise<Trade>> executeTrade(const ExecuteTradeRequest& request) override {
|
|
297
|
-
auto __result = _swiftPart.executeTrade(request);
|
|
298
|
-
if (__result.hasError()) [[unlikely]] {
|
|
299
|
-
std::rethrow_exception(__result.error());
|
|
300
|
-
}
|
|
301
|
-
auto __value = std::move(__result.value());
|
|
302
|
-
return __value;
|
|
303
|
-
}
|
|
304
302
|
inline std::shared_ptr<Promise<void>> deleteUser() override {
|
|
305
303
|
auto __result = _swiftPart.deleteUser();
|
|
306
304
|
if (__result.hasError()) [[unlikely]] {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_TradeExecutionResult.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
|
+
/// Wraps a Swift `(_ result: TradeExecutionResult) -> Void` as a class.
|
|
11
|
+
/// This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
12
|
+
public final class Func_void_TradeExecutionResult {
|
|
13
|
+
public typealias bridge = margelo.nitro.rncandle.bridge.swift
|
|
14
|
+
|
|
15
|
+
private let closure: (_ result: TradeExecutionResult) -> Void
|
|
16
|
+
|
|
17
|
+
public init(_ closure: @escaping (_ result: TradeExecutionResult) -> Void) {
|
|
18
|
+
self.closure = closure
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@inline(__always)
|
|
22
|
+
public func call(result: TradeExecutionResult) {
|
|
23
|
+
self.closure(result)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
28
|
+
* This acquires one additional strong reference on the object!
|
|
29
|
+
*/
|
|
30
|
+
@inline(__always)
|
|
31
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
32
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Casts an unsafe pointer to a `Func_void_TradeExecutionResult`.
|
|
37
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_TradeExecutionResult>`.
|
|
38
|
+
* This removes one strong reference from the object!
|
|
39
|
+
*/
|
|
40
|
+
@inline(__always)
|
|
41
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer)
|
|
42
|
+
-> Func_void_TradeExecutionResult
|
|
43
|
+
{
|
|
44
|
+
return Unmanaged<Func_void_TradeExecutionResult>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -18,6 +18,9 @@ public protocol HybridRNCandleSpec_protocol: HybridObject {
|
|
|
18
18
|
showDynamicLoading: Bool, presentationBackground: PresentationBackground,
|
|
19
19
|
presentationStyle: PresentationStyle, onSuccess: @escaping (_ account: LinkedAccount) -> Void)
|
|
20
20
|
throws
|
|
21
|
+
func candleTradeExecutionSheet(
|
|
22
|
+
tradeQuote: TradeQuote, presentationBackground: PresentationBackground,
|
|
23
|
+
completion: @escaping (_ result: TradeExecutionResult) -> Void) throws
|
|
21
24
|
func initialize(appUser: AppUser) throws
|
|
22
25
|
func getLinkedAccounts() throws -> Promise<[LinkedAccount]>
|
|
23
26
|
func getLinkedAccount(ref: LinkedAccountRef) throws -> Promise<LinkedAccount>
|
|
@@ -27,7 +30,6 @@ public protocol HybridRNCandleSpec_protocol: HybridObject {
|
|
|
27
30
|
func getTrades(query: TradeQuery) throws -> Promise<[Trade]>
|
|
28
31
|
func getTrade(ref: TradeRef) throws -> Promise<Trade>
|
|
29
32
|
func getTradeQuotes(request: TradeQuoteRequest) throws -> Promise<[TradeQuote]>
|
|
30
|
-
func executeTrade(request: ExecuteTradeRequest) throws -> Promise<Trade>
|
|
31
33
|
func deleteUser() throws -> Promise<Void>
|
|
32
34
|
func getAvailableTools() throws -> Promise<[AnyMapHolder]>
|
|
33
35
|
func executeTool(tool: ToolCall) throws -> Promise<String>
|
|
@@ -137,6 +137,29 @@ public class HybridRNCandleSpec_cxx {
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
@inline(__always)
|
|
141
|
+
public final func candleTradeExecutionSheet(
|
|
142
|
+
tradeQuote: TradeQuote, presentationBackground: Int32,
|
|
143
|
+
completion: bridge.Func_void_TradeExecutionResult
|
|
144
|
+
) -> bridge.Result_void_ {
|
|
145
|
+
do {
|
|
146
|
+
try self.__implementation.candleTradeExecutionSheet(
|
|
147
|
+
tradeQuote: tradeQuote,
|
|
148
|
+
presentationBackground: margelo.nitro.rncandle.PresentationBackground(
|
|
149
|
+
rawValue: presentationBackground)!,
|
|
150
|
+
completion: { () -> (TradeExecutionResult) -> Void in
|
|
151
|
+
let __wrappedFunction = bridge.wrap_Func_void_TradeExecutionResult(completion)
|
|
152
|
+
return { (__result: TradeExecutionResult) -> Void in
|
|
153
|
+
__wrappedFunction.call(__result)
|
|
154
|
+
}
|
|
155
|
+
}())
|
|
156
|
+
return bridge.create_Result_void_()
|
|
157
|
+
} catch (let __error) {
|
|
158
|
+
let __exceptionPtr = __error.toCpp()
|
|
159
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
140
163
|
@inline(__always)
|
|
141
164
|
public final func initialize(appUser: AppUser) -> bridge.Result_void_ {
|
|
142
165
|
do {
|
|
@@ -355,27 +378,6 @@ public class HybridRNCandleSpec_cxx {
|
|
|
355
378
|
}
|
|
356
379
|
}
|
|
357
380
|
|
|
358
|
-
@inline(__always)
|
|
359
|
-
public final func executeTrade(request: ExecuteTradeRequest)
|
|
360
|
-
-> bridge.Result_std__shared_ptr_Promise_Trade___
|
|
361
|
-
{
|
|
362
|
-
do {
|
|
363
|
-
let __result = try self.__implementation.executeTrade(request: request)
|
|
364
|
-
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_Trade__ in
|
|
365
|
-
let __promise = bridge.create_std__shared_ptr_Promise_Trade__()
|
|
366
|
-
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_Trade__(__promise)
|
|
367
|
-
__result
|
|
368
|
-
.then({ __result in __promiseHolder.resolve(__result) })
|
|
369
|
-
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
370
|
-
return __promise
|
|
371
|
-
}()
|
|
372
|
-
return bridge.create_Result_std__shared_ptr_Promise_Trade___(__resultCpp)
|
|
373
|
-
} catch (let __error) {
|
|
374
|
-
let __exceptionPtr = __error.toCpp()
|
|
375
|
-
return bridge.create_Result_std__shared_ptr_Promise_Trade___(__exceptionPtr)
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
381
|
@inline(__always)
|
|
380
382
|
public final func deleteUser() -> bridge.Result_std__shared_ptr_Promise_void___ {
|
|
381
383
|
do {
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// TradeExecutionResult.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 `TradeExecutionResult`, backed by a C++ struct.
|
|
11
|
+
public typealias TradeExecutionResult = margelo.nitro.rncandle.TradeExecutionResult
|
|
12
|
+
|
|
13
|
+
extension TradeExecutionResult {
|
|
14
|
+
private typealias bridge = margelo.nitro.rncandle.bridge.swift
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Create a new instance of `TradeExecutionResult`.
|
|
18
|
+
*/
|
|
19
|
+
public init(trade: Trade?, error: String?) {
|
|
20
|
+
self.init(
|
|
21
|
+
{ () -> bridge.std__optional_Trade_ in
|
|
22
|
+
if let __unwrappedValue = trade {
|
|
23
|
+
return bridge.create_std__optional_Trade_(__unwrappedValue)
|
|
24
|
+
} else {
|
|
25
|
+
return .init()
|
|
26
|
+
}
|
|
27
|
+
}(),
|
|
28
|
+
{ () -> bridge.std__optional_std__string_ in
|
|
29
|
+
if let __unwrappedValue = error {
|
|
30
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
31
|
+
} else {
|
|
32
|
+
return .init()
|
|
33
|
+
}
|
|
34
|
+
}())
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public var trade: Trade? {
|
|
38
|
+
@inline(__always)
|
|
39
|
+
get {
|
|
40
|
+
return { () -> Trade? in
|
|
41
|
+
if let __unwrapped = self.__trade.value {
|
|
42
|
+
return __unwrapped
|
|
43
|
+
} else {
|
|
44
|
+
return nil
|
|
45
|
+
}
|
|
46
|
+
}()
|
|
47
|
+
}
|
|
48
|
+
@inline(__always)
|
|
49
|
+
set {
|
|
50
|
+
self.__trade = { () -> bridge.std__optional_Trade_ in
|
|
51
|
+
if let __unwrappedValue = newValue {
|
|
52
|
+
return bridge.create_std__optional_Trade_(__unwrappedValue)
|
|
53
|
+
} else {
|
|
54
|
+
return .init()
|
|
55
|
+
}
|
|
56
|
+
}()
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public var error: String? {
|
|
61
|
+
@inline(__always)
|
|
62
|
+
get {
|
|
63
|
+
return { () -> String? in
|
|
64
|
+
if let __unwrapped = self.__error.value {
|
|
65
|
+
return String(__unwrapped)
|
|
66
|
+
} else {
|
|
67
|
+
return nil
|
|
68
|
+
}
|
|
69
|
+
}()
|
|
70
|
+
}
|
|
71
|
+
@inline(__always)
|
|
72
|
+
set {
|
|
73
|
+
self.__error = { () -> bridge.std__optional_std__string_ in
|
|
74
|
+
if let __unwrappedValue = newValue {
|
|
75
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
76
|
+
} else {
|
|
77
|
+
return .init()
|
|
78
|
+
}
|
|
79
|
+
}()
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -16,8 +16,8 @@ extension TradeQuote {
|
|
|
16
16
|
/**
|
|
17
17
|
* Create a new instance of `TradeQuote`.
|
|
18
18
|
*/
|
|
19
|
-
public init(lost: TradeAsset, gained: TradeAsset) {
|
|
20
|
-
self.init(lost, gained)
|
|
19
|
+
public init(lost: TradeAsset, gained: TradeAsset, context: String) {
|
|
20
|
+
self.init(lost, gained, std.string(context))
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
public var lost: TradeAsset {
|
|
@@ -41,4 +41,15 @@ extension TradeQuote {
|
|
|
41
41
|
self.__gained = newValue
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
+
|
|
45
|
+
public var context: String {
|
|
46
|
+
@inline(__always)
|
|
47
|
+
get {
|
|
48
|
+
return String(self.__context)
|
|
49
|
+
}
|
|
50
|
+
@inline(__always)
|
|
51
|
+
set {
|
|
52
|
+
self.__context = std.string(newValue)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
44
55
|
}
|
|
@@ -15,6 +15,7 @@ namespace margelo::nitro::rncandle {
|
|
|
15
15
|
// load custom methods/properties
|
|
16
16
|
registerHybrids(this, [](Prototype& prototype) {
|
|
17
17
|
prototype.registerHybridMethod("candleLinkSheet", &HybridRNCandleSpec::candleLinkSheet);
|
|
18
|
+
prototype.registerHybridMethod("candleTradeExecutionSheet", &HybridRNCandleSpec::candleTradeExecutionSheet);
|
|
18
19
|
prototype.registerHybridMethod("initialize", &HybridRNCandleSpec::initialize);
|
|
19
20
|
prototype.registerHybridMethod("getLinkedAccounts", &HybridRNCandleSpec::getLinkedAccounts);
|
|
20
21
|
prototype.registerHybridMethod("getLinkedAccount", &HybridRNCandleSpec::getLinkedAccount);
|
|
@@ -24,7 +25,6 @@ namespace margelo::nitro::rncandle {
|
|
|
24
25
|
prototype.registerHybridMethod("getTrades", &HybridRNCandleSpec::getTrades);
|
|
25
26
|
prototype.registerHybridMethod("getTrade", &HybridRNCandleSpec::getTrade);
|
|
26
27
|
prototype.registerHybridMethod("getTradeQuotes", &HybridRNCandleSpec::getTradeQuotes);
|
|
27
|
-
prototype.registerHybridMethod("executeTrade", &HybridRNCandleSpec::executeTrade);
|
|
28
28
|
prototype.registerHybridMethod("deleteUser", &HybridRNCandleSpec::deleteUser);
|
|
29
29
|
prototype.registerHybridMethod("getAvailableTools", &HybridRNCandleSpec::getAvailableTools);
|
|
30
30
|
prototype.registerHybridMethod("executeTool", &HybridRNCandleSpec::executeTool);
|
|
@@ -21,6 +21,10 @@ namespace margelo::nitro::rncandle { enum class PresentationBackground; }
|
|
|
21
21
|
namespace margelo::nitro::rncandle { enum class PresentationStyle; }
|
|
22
22
|
// Forward declaration of `LinkedAccount` to properly resolve imports.
|
|
23
23
|
namespace margelo::nitro::rncandle { struct LinkedAccount; }
|
|
24
|
+
// Forward declaration of `TradeQuote` to properly resolve imports.
|
|
25
|
+
namespace margelo::nitro::rncandle { struct TradeQuote; }
|
|
26
|
+
// Forward declaration of `TradeExecutionResult` to properly resolve imports.
|
|
27
|
+
namespace margelo::nitro::rncandle { struct TradeExecutionResult; }
|
|
24
28
|
// Forward declaration of `AppUser` to properly resolve imports.
|
|
25
29
|
namespace margelo::nitro::rncandle { struct AppUser; }
|
|
26
30
|
// Forward declaration of `LinkedAccountRef` to properly resolve imports.
|
|
@@ -37,12 +41,8 @@ namespace margelo::nitro::rncandle { struct Trade; }
|
|
|
37
41
|
namespace margelo::nitro::rncandle { struct TradeQuery; }
|
|
38
42
|
// Forward declaration of `TradeRef` to properly resolve imports.
|
|
39
43
|
namespace margelo::nitro::rncandle { struct TradeRef; }
|
|
40
|
-
// Forward declaration of `TradeQuote` to properly resolve imports.
|
|
41
|
-
namespace margelo::nitro::rncandle { struct TradeQuote; }
|
|
42
44
|
// Forward declaration of `TradeQuoteRequest` to properly resolve imports.
|
|
43
45
|
namespace margelo::nitro::rncandle { struct TradeQuoteRequest; }
|
|
44
|
-
// Forward declaration of `ExecuteTradeRequest` to properly resolve imports.
|
|
45
|
-
namespace margelo::nitro::rncandle { struct ExecuteTradeRequest; }
|
|
46
46
|
// Forward declaration of `AnyMap` to properly resolve imports.
|
|
47
47
|
namespace NitroModules { class AnyMap; }
|
|
48
48
|
// Forward declaration of `ToolCall` to properly resolve imports.
|
|
@@ -56,6 +56,8 @@ namespace margelo::nitro::rncandle { struct ToolCall; }
|
|
|
56
56
|
#include "PresentationStyle.hpp"
|
|
57
57
|
#include <functional>
|
|
58
58
|
#include "LinkedAccount.hpp"
|
|
59
|
+
#include "TradeQuote.hpp"
|
|
60
|
+
#include "TradeExecutionResult.hpp"
|
|
59
61
|
#include "AppUser.hpp"
|
|
60
62
|
#include <NitroModules/Promise.hpp>
|
|
61
63
|
#include "LinkedAccountRef.hpp"
|
|
@@ -65,9 +67,7 @@ namespace margelo::nitro::rncandle { struct ToolCall; }
|
|
|
65
67
|
#include "Trade.hpp"
|
|
66
68
|
#include "TradeQuery.hpp"
|
|
67
69
|
#include "TradeRef.hpp"
|
|
68
|
-
#include "TradeQuote.hpp"
|
|
69
70
|
#include "TradeQuoteRequest.hpp"
|
|
70
|
-
#include "ExecuteTradeRequest.hpp"
|
|
71
71
|
#include <NitroModules/AnyMap.hpp>
|
|
72
72
|
#include "ToolCall.hpp"
|
|
73
73
|
|
|
@@ -103,6 +103,7 @@ namespace margelo::nitro::rncandle {
|
|
|
103
103
|
public:
|
|
104
104
|
// Methods
|
|
105
105
|
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
|
+
virtual void candleTradeExecutionSheet(const TradeQuote& tradeQuote, PresentationBackground presentationBackground, const std::function<void(const TradeExecutionResult& /* result */)>& completion) = 0;
|
|
106
107
|
virtual void initialize(const AppUser& appUser) = 0;
|
|
107
108
|
virtual std::shared_ptr<Promise<std::vector<LinkedAccount>>> getLinkedAccounts() = 0;
|
|
108
109
|
virtual std::shared_ptr<Promise<LinkedAccount>> getLinkedAccount(const LinkedAccountRef& ref) = 0;
|
|
@@ -112,7 +113,6 @@ namespace margelo::nitro::rncandle {
|
|
|
112
113
|
virtual std::shared_ptr<Promise<std::vector<Trade>>> getTrades(const TradeQuery& query) = 0;
|
|
113
114
|
virtual std::shared_ptr<Promise<Trade>> getTrade(const TradeRef& ref) = 0;
|
|
114
115
|
virtual std::shared_ptr<Promise<std::vector<TradeQuote>>> getTradeQuotes(const TradeQuoteRequest& request) = 0;
|
|
115
|
-
virtual std::shared_ptr<Promise<Trade>> executeTrade(const ExecuteTradeRequest& request) = 0;
|
|
116
116
|
virtual std::shared_ptr<Promise<void>> deleteUser() = 0;
|
|
117
117
|
virtual std::shared_ptr<Promise<std::vector<std::shared_ptr<AnyMap>>>> getAvailableTools() = 0;
|
|
118
118
|
virtual std::shared_ptr<Promise<std::string>> executeTool(const ToolCall& tool) = 0;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// TradeExecutionResult.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 `Trade` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::rncandle { struct Trade; }
|
|
23
|
+
|
|
24
|
+
#include <optional>
|
|
25
|
+
#include "Trade.hpp"
|
|
26
|
+
#include <string>
|
|
27
|
+
|
|
28
|
+
namespace margelo::nitro::rncandle {
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A struct which can be represented as a JavaScript object (TradeExecutionResult).
|
|
32
|
+
*/
|
|
33
|
+
struct TradeExecutionResult {
|
|
34
|
+
public:
|
|
35
|
+
std::optional<Trade> trade SWIFT_PRIVATE;
|
|
36
|
+
std::optional<std::string> error SWIFT_PRIVATE;
|
|
37
|
+
|
|
38
|
+
public:
|
|
39
|
+
TradeExecutionResult() = default;
|
|
40
|
+
explicit TradeExecutionResult(std::optional<Trade> trade, std::optional<std::string> error): trade(trade), error(error) {}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
} // namespace margelo::nitro::rncandle
|
|
44
|
+
|
|
45
|
+
namespace margelo::nitro {
|
|
46
|
+
|
|
47
|
+
using namespace margelo::nitro::rncandle;
|
|
48
|
+
|
|
49
|
+
// C++ TradeExecutionResult <> JS TradeExecutionResult (object)
|
|
50
|
+
template <>
|
|
51
|
+
struct JSIConverter<TradeExecutionResult> final {
|
|
52
|
+
static inline TradeExecutionResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
53
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
54
|
+
return TradeExecutionResult(
|
|
55
|
+
JSIConverter<std::optional<Trade>>::fromJSI(runtime, obj.getProperty(runtime, "trade")),
|
|
56
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "error"))
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const TradeExecutionResult& arg) {
|
|
60
|
+
jsi::Object obj(runtime);
|
|
61
|
+
obj.setProperty(runtime, "trade", JSIConverter<std::optional<Trade>>::toJSI(runtime, arg.trade));
|
|
62
|
+
obj.setProperty(runtime, "error", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.error));
|
|
63
|
+
return obj;
|
|
64
|
+
}
|
|
65
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
66
|
+
if (!value.isObject()) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
jsi::Object obj = value.getObject(runtime);
|
|
70
|
+
if (!JSIConverter<std::optional<Trade>>::canConvert(runtime, obj.getProperty(runtime, "trade"))) return false;
|
|
71
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "error"))) return false;
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
} // namespace margelo::nitro
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
namespace margelo::nitro::rncandle { struct TradeAsset; }
|
|
23
23
|
|
|
24
24
|
#include "TradeAsset.hpp"
|
|
25
|
+
#include <string>
|
|
25
26
|
|
|
26
27
|
namespace margelo::nitro::rncandle {
|
|
27
28
|
|
|
@@ -32,10 +33,11 @@ namespace margelo::nitro::rncandle {
|
|
|
32
33
|
public:
|
|
33
34
|
TradeAsset lost SWIFT_PRIVATE;
|
|
34
35
|
TradeAsset gained SWIFT_PRIVATE;
|
|
36
|
+
std::string context SWIFT_PRIVATE;
|
|
35
37
|
|
|
36
38
|
public:
|
|
37
39
|
TradeQuote() = default;
|
|
38
|
-
explicit TradeQuote(TradeAsset lost, TradeAsset gained): lost(lost), gained(gained) {}
|
|
40
|
+
explicit TradeQuote(TradeAsset lost, TradeAsset gained, std::string context): lost(lost), gained(gained), context(context) {}
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
} // namespace margelo::nitro::rncandle
|
|
@@ -51,13 +53,15 @@ namespace margelo::nitro {
|
|
|
51
53
|
jsi::Object obj = arg.asObject(runtime);
|
|
52
54
|
return TradeQuote(
|
|
53
55
|
JSIConverter<TradeAsset>::fromJSI(runtime, obj.getProperty(runtime, "lost")),
|
|
54
|
-
JSIConverter<TradeAsset>::fromJSI(runtime, obj.getProperty(runtime, "gained"))
|
|
56
|
+
JSIConverter<TradeAsset>::fromJSI(runtime, obj.getProperty(runtime, "gained")),
|
|
57
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "context"))
|
|
55
58
|
);
|
|
56
59
|
}
|
|
57
60
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const TradeQuote& arg) {
|
|
58
61
|
jsi::Object obj(runtime);
|
|
59
62
|
obj.setProperty(runtime, "lost", JSIConverter<TradeAsset>::toJSI(runtime, arg.lost));
|
|
60
63
|
obj.setProperty(runtime, "gained", JSIConverter<TradeAsset>::toJSI(runtime, arg.gained));
|
|
64
|
+
obj.setProperty(runtime, "context", JSIConverter<std::string>::toJSI(runtime, arg.context));
|
|
61
65
|
return obj;
|
|
62
66
|
}
|
|
63
67
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -67,6 +71,7 @@ namespace margelo::nitro {
|
|
|
67
71
|
jsi::Object obj = value.getObject(runtime);
|
|
68
72
|
if (!JSIConverter<TradeAsset>::canConvert(runtime, obj.getProperty(runtime, "lost"))) return false;
|
|
69
73
|
if (!JSIConverter<TradeAsset>::canConvert(runtime, obj.getProperty(runtime, "gained"))) return false;
|
|
74
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "context"))) return false;
|
|
70
75
|
return true;
|
|
71
76
|
}
|
|
72
77
|
};
|