react-native-candle 0.1.43 → 0.1.44
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 +4 -7
- package/ios/Sources/CandleLinkSheetWrapperView.swift +40 -59
- package/ios/Sources/CandleLinkViewModel.swift +21 -31
- package/ios/Sources/CandleTradeExecutionSheetWrapper.swift +14 -23
- package/ios/Sources/HostingViewController.swift +26 -26
- package/ios/Sources/RNCandle.swift +159 -1307
- package/ios/Sources/Types.swift +847 -0
- package/ios/Sources/UIApplication++.swift +5 -9
- package/lib/commonjs/context.js +17 -0
- package/lib/commonjs/context.js.map +1 -0
- package/lib/commonjs/index.js +17 -407
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/provider.js +117 -0
- package/lib/commonjs/provider.js.map +1 -0
- package/lib/commonjs/types.js +271 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/context.js +12 -0
- package/lib/module/context.js.map +1 -0
- package/lib/module/index.js +2 -408
- package/lib/module/index.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/provider.js +111 -0
- package/lib/module/provider.js.map +1 -0
- package/lib/module/types.js +256 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/commonjs/src/context.d.ts +47 -0
- package/lib/typescript/commonjs/src/context.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +4 -166
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/provider.d.ts +8 -0
- package/lib/typescript/commonjs/src/provider.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts +22 -24
- package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types.d.ts +125 -0
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
- package/lib/typescript/module/src/context.d.ts +47 -0
- package/lib/typescript/module/src/context.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +4 -166
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/provider.d.ts +8 -0
- package/lib/typescript/module/src/provider.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/RNCandle.nitro.d.ts +22 -24
- package/lib/typescript/module/src/specs/RNCandle.nitro.d.ts.map +1 -1
- package/lib/typescript/module/src/types.d.ts +125 -0
- package/lib/typescript/module/src/types.d.ts.map +1 -0
- package/nitrogen/generated/.gitattributes +1 -1
- package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Bridge.cpp +15 -31
- package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Bridge.hpp +379 -242
- package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Umbrella.hpp +23 -22
- package/nitrogen/generated/ios/ReactNativeCandleAutolinking.mm +1 -1
- package/nitrogen/generated/ios/ReactNativeCandleAutolinking.swift +2 -4
- package/nitrogen/generated/ios/c++/HybridRNCandleSpecSwift.hpp +36 -42
- package/nitrogen/generated/ios/swift/ActiveLinkedAccountDetails.swift +6 -3
- package/nitrogen/generated/ios/swift/AssetAccount.swift +6 -3
- package/nitrogen/generated/ios/swift/AssetAccountKind.swift +4 -4
- package/nitrogen/generated/ios/swift/AssetAccountRef.swift +5 -5
- package/nitrogen/generated/ios/swift/{AssetAccountQuery.swift → AssetAccountsQuery.swift} +7 -6
- package/nitrogen/generated/ios/swift/Counterparty.swift +8 -3
- package/nitrogen/generated/ios/swift/CounterpartyKind.swift +42 -0
- package/nitrogen/generated/ios/swift/FiatAccount.swift +4 -2
- package/nitrogen/generated/ios/swift/FiatAsset.swift +2 -1
- package/nitrogen/generated/ios/swift/FiatAssetQuoteRequest.swift +4 -2
- package/nitrogen/generated/ios/swift/FiatAssetRef.swift +2 -1
- package/nitrogen/generated/ios/swift/Func_void_LinkedAccount.swift +5 -5
- package/nitrogen/generated/ios/swift/HybridRNCandleSpec.swift +7 -7
- package/nitrogen/generated/ios/swift/HybridRNCandleSpec_cxx.swift +40 -65
- package/nitrogen/generated/ios/swift/LinkedAccountDetails.swift +15 -3
- package/nitrogen/generated/ios/swift/{StatePayload.swift → LinkedAccountState.swift} +6 -6
- package/nitrogen/generated/ios/swift/LinkedAccountStatusRef.swift +4 -3
- package/nitrogen/generated/ios/swift/MarketAccount.swift +5 -5
- package/nitrogen/generated/ios/swift/MarketAssetKind.swift +38 -0
- package/nitrogen/generated/ios/swift/MarketAssetQuoteRequest.swift +11 -8
- package/nitrogen/generated/ios/swift/MarketTradeAsset.swift +7 -7
- package/nitrogen/generated/ios/swift/MarketTradeAssetRef.swift +5 -5
- package/nitrogen/generated/ios/swift/MerchantCounterparty.swift +2 -1
- package/nitrogen/generated/ios/swift/TradeAsset.swift +10 -5
- package/nitrogen/generated/ios/swift/TradeAssetKind.swift +54 -0
- package/nitrogen/generated/ios/swift/TradeAssetQuoteRequest.swift +15 -4
- package/nitrogen/generated/ios/swift/TradeAssetRef.swift +11 -5
- package/nitrogen/generated/ios/swift/TradeExecutionResult.swift +4 -2
- package/nitrogen/generated/ios/swift/{TradeQuoteRequest.swift → TradeQuotesRequest.swift} +7 -6
- package/nitrogen/generated/ios/swift/{TradeQuery.swift → TradesQuery.swift} +29 -45
- package/nitrogen/generated/ios/swift/TransportAssetQuoteRequest.swift +12 -6
- package/nitrogen/generated/shared/c++/ACHAccountKind.hpp +7 -9
- package/nitrogen/generated/shared/c++/ACHDetails.hpp +7 -9
- package/nitrogen/generated/shared/c++/ActiveLinkedAccountDetails.hpp +4 -6
- package/nitrogen/generated/shared/c++/Address.hpp +4 -6
- package/nitrogen/generated/shared/c++/AssetAccount.hpp +14 -16
- package/nitrogen/generated/shared/c++/AssetAccountKind.hpp +15 -17
- package/nitrogen/generated/shared/c++/AssetAccountRef.hpp +12 -12
- package/nitrogen/generated/shared/c++/{AssetAccountQuery.hpp → AssetAccountsQuery.hpp} +14 -16
- package/nitrogen/generated/shared/c++/AssetAccountsResponse.hpp +11 -13
- package/nitrogen/generated/shared/c++/Coordinates.hpp +4 -6
- package/nitrogen/generated/shared/c++/Counterparty.hpp +14 -16
- package/nitrogen/generated/shared/c++/CounterpartyKind.hpp +80 -0
- package/nitrogen/generated/shared/c++/FiatAccount.hpp +16 -18
- package/nitrogen/generated/shared/c++/FiatAsset.hpp +7 -9
- package/nitrogen/generated/shared/c++/FiatAssetQuoteRequest.hpp +4 -6
- package/nitrogen/generated/shared/c++/FiatAssetRef.hpp +4 -6
- package/nitrogen/generated/shared/c++/FiatMarketAccountKind.hpp +13 -15
- package/nitrogen/generated/shared/c++/HybridRNCandleSpec.cpp +1 -2
- package/nitrogen/generated/shared/c++/HybridRNCandleSpec.hpp +17 -27
- package/nitrogen/generated/shared/c++/InactiveLinkedAccountDetails.hpp +4 -6
- package/nitrogen/generated/shared/c++/LinkedAccount.hpp +10 -12
- package/nitrogen/generated/shared/c++/LinkedAccountDetails.hpp +14 -16
- package/nitrogen/generated/shared/c++/LinkedAccountRef.hpp +4 -6
- package/nitrogen/generated/shared/c++/{StatePayload.hpp → LinkedAccountState.hpp} +15 -17
- package/nitrogen/generated/shared/c++/LinkedAccountStatusRef.hpp +15 -17
- package/nitrogen/generated/shared/c++/MarketAccount.hpp +18 -17
- package/nitrogen/generated/shared/c++/MarketAssetKind.hpp +76 -0
- package/nitrogen/generated/shared/c++/MarketAssetQuoteRequest.hpp +12 -12
- package/nitrogen/generated/shared/c++/MarketTradeAsset.hpp +15 -14
- package/nitrogen/generated/shared/c++/MarketTradeAssetRef.hpp +12 -12
- package/nitrogen/generated/shared/c++/MerchantCounterparty.hpp +8 -10
- package/nitrogen/generated/shared/c++/MerchantLocation.hpp +4 -6
- package/nitrogen/generated/shared/c++/NothingAsset.hpp +4 -6
- package/nitrogen/generated/shared/c++/NothingAssetQuoteRequest.hpp +4 -6
- package/nitrogen/generated/shared/c++/NothingAssetRef.hpp +4 -6
- package/nitrogen/generated/shared/c++/OtherAsset.hpp +4 -6
- package/nitrogen/generated/shared/c++/OtherAssetRef.hpp +4 -6
- package/nitrogen/generated/shared/c++/PresentationBackground.hpp +7 -9
- package/nitrogen/generated/shared/c++/PresentationStyle.hpp +7 -9
- package/nitrogen/generated/shared/c++/Service.hpp +163 -165
- package/nitrogen/generated/shared/c++/ServiceCounterparty.hpp +7 -9
- package/nitrogen/generated/shared/c++/Trade.hpp +16 -18
- package/nitrogen/generated/shared/c++/TradeAsset.hpp +20 -22
- package/nitrogen/generated/shared/c++/TradeAssetKind.hpp +92 -0
- package/nitrogen/generated/shared/c++/TradeAssetQuoteRequest.hpp +17 -19
- package/nitrogen/generated/shared/c++/TradeAssetRef.hpp +20 -22
- package/nitrogen/generated/shared/c++/TradeExecutionResult.hpp +8 -10
- package/nitrogen/generated/shared/c++/TradeQuote.hpp +10 -12
- package/nitrogen/generated/shared/c++/{TradeQuoteRequest.hpp → TradeQuotesRequest.hpp} +17 -19
- package/nitrogen/generated/shared/c++/TradeQuotesResponse.hpp +11 -13
- package/nitrogen/generated/shared/c++/TradeRef.hpp +10 -12
- package/nitrogen/generated/shared/c++/TradeState.hpp +9 -11
- package/nitrogen/generated/shared/c++/TradesQuery.hpp +89 -0
- package/nitrogen/generated/shared/c++/TradesResponse.hpp +11 -13
- package/nitrogen/generated/shared/c++/TransportAccount.hpp +10 -12
- package/nitrogen/generated/shared/c++/TransportAccountKind.hpp +9 -11
- package/nitrogen/generated/shared/c++/TransportAsset.hpp +19 -21
- package/nitrogen/generated/shared/c++/TransportAssetQuoteRequest.hpp +16 -18
- package/nitrogen/generated/shared/c++/TransportAssetRef.hpp +4 -6
- package/nitrogen/generated/shared/c++/UnavailableLinkedAccountDetails.hpp +4 -6
- package/nitrogen/generated/shared/c++/UserCounterparty.hpp +4 -6
- package/nitrogen/generated/shared/c++/WireDetails.hpp +4 -6
- package/package.json +9 -11
- package/src/context.ts +86 -0
- package/src/index.ts +4 -634
- package/src/provider.tsx +152 -0
- package/src/specs/RNCandle.nitro.ts +38 -29
- package/src/types.ts +462 -0
- package/nitrogen/generated/ios/swift/AppUser.swift +0 -75
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +0 -44
- package/nitrogen/generated/ios/swift/Func_void_std__vector_std__shared_ptr_AnyMap__.swift +0 -47
- package/nitrogen/generated/ios/swift/ToolCall.swift +0 -44
- package/nitrogen/generated/shared/c++/AppUser.hpp +0 -78
- package/nitrogen/generated/shared/c++/ToolCall.hpp +0 -73
- package/nitrogen/generated/shared/c++/TradeQuery.hpp +0 -86
package/src/types.ts
ADDED
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ACHDetails,
|
|
3
|
+
ActiveLinkedAccountDetails,
|
|
4
|
+
FiatAsset,
|
|
5
|
+
FiatAssetQuoteRequest,
|
|
6
|
+
FiatAssetRef,
|
|
7
|
+
FiatMarketAccountKind,
|
|
8
|
+
LinkedAccount as _LinkedAccount,
|
|
9
|
+
MarketAssetQuoteRequest,
|
|
10
|
+
MarketTradeAsset,
|
|
11
|
+
MarketTradeAssetRef,
|
|
12
|
+
MerchantCounterparty,
|
|
13
|
+
NothingAsset,
|
|
14
|
+
NothingAssetQuoteRequest,
|
|
15
|
+
NothingAssetRef,
|
|
16
|
+
OtherAsset,
|
|
17
|
+
OtherAssetRef,
|
|
18
|
+
Service,
|
|
19
|
+
ServiceCounterparty,
|
|
20
|
+
TradeState,
|
|
21
|
+
TransportAccountKind,
|
|
22
|
+
TransportAsset,
|
|
23
|
+
TransportAssetQuoteRequest,
|
|
24
|
+
TransportAssetRef,
|
|
25
|
+
UserCounterparty,
|
|
26
|
+
WireDetails,
|
|
27
|
+
Trade as _Trade,
|
|
28
|
+
TradeQuotesRequest as _TradeQuotesRequest,
|
|
29
|
+
LinkedAccountDetails as _LinkedAccountDetails,
|
|
30
|
+
AssetAccount as _AssetAccount,
|
|
31
|
+
TradeRef as _TradeRef,
|
|
32
|
+
TradeAssetRef as _TradeAssetRef,
|
|
33
|
+
TradeAsset as _TradeAsset,
|
|
34
|
+
TradeQuote as _TradeQuote,
|
|
35
|
+
Counterparty as _Counterparty,
|
|
36
|
+
TradeAssetQuoteRequest as _TradeAssetQuoteRequest,
|
|
37
|
+
InactiveLinkedAccountDetails,
|
|
38
|
+
UnavailableLinkedAccountDetails,
|
|
39
|
+
TradeAssetKind,
|
|
40
|
+
} from "./specs/RNCandle.nitro";
|
|
41
|
+
|
|
42
|
+
export type {
|
|
43
|
+
ACHDetails,
|
|
44
|
+
ActiveLinkedAccountDetails,
|
|
45
|
+
FiatAsset,
|
|
46
|
+
FiatAssetQuoteRequest,
|
|
47
|
+
FiatAssetRef,
|
|
48
|
+
FiatMarketAccountKind,
|
|
49
|
+
MarketAssetQuoteRequest,
|
|
50
|
+
MarketTradeAsset,
|
|
51
|
+
MarketTradeAssetRef,
|
|
52
|
+
MerchantCounterparty,
|
|
53
|
+
NothingAsset,
|
|
54
|
+
NothingAssetQuoteRequest,
|
|
55
|
+
NothingAssetRef,
|
|
56
|
+
OtherAsset,
|
|
57
|
+
OtherAssetRef,
|
|
58
|
+
Service,
|
|
59
|
+
ServiceCounterparty,
|
|
60
|
+
TradeState,
|
|
61
|
+
TransportAccountKind,
|
|
62
|
+
TransportAsset,
|
|
63
|
+
TradesQuery,
|
|
64
|
+
TransportAssetQuoteRequest,
|
|
65
|
+
TransportAssetRef,
|
|
66
|
+
UserCounterparty,
|
|
67
|
+
WireDetails,
|
|
68
|
+
PresentationBackground,
|
|
69
|
+
PresentationStyle,
|
|
70
|
+
LinkedAccountRef,
|
|
71
|
+
AssetAccountsQuery,
|
|
72
|
+
AssetAccountRef,
|
|
73
|
+
TradeAssetKind,
|
|
74
|
+
LinkedAccountStatusRef,
|
|
75
|
+
} from "./specs/RNCandle.nitro";
|
|
76
|
+
|
|
77
|
+
export type TradeQuoteAssetKind =
|
|
78
|
+
| "nothing"
|
|
79
|
+
| "transport"
|
|
80
|
+
| "fiat"
|
|
81
|
+
| "stock"
|
|
82
|
+
| "crypto";
|
|
83
|
+
|
|
84
|
+
// Discriminated unions
|
|
85
|
+
|
|
86
|
+
export type TradeAssetQuoteRequest =
|
|
87
|
+
| ({
|
|
88
|
+
assetKind: "nothing";
|
|
89
|
+
} & NothingAssetQuoteRequest)
|
|
90
|
+
| ({ assetKind: "transport" } & TransportAssetQuoteRequest)
|
|
91
|
+
| ({ assetKind: "fiat" } & FiatAssetQuoteRequest)
|
|
92
|
+
| ({ assetKind: "stock" | "crypto" } & MarketAssetQuoteRequest);
|
|
93
|
+
|
|
94
|
+
export type TradeAsset =
|
|
95
|
+
| ({
|
|
96
|
+
assetKind: "nothing";
|
|
97
|
+
} & NothingAsset)
|
|
98
|
+
| ({
|
|
99
|
+
assetKind: "other";
|
|
100
|
+
} & OtherAsset)
|
|
101
|
+
| ({ assetKind: "transport" } & TransportAsset)
|
|
102
|
+
| ({ assetKind: "fiat" } & FiatAsset)
|
|
103
|
+
| ({ assetKind: "stock" | "crypto" } & MarketTradeAsset);
|
|
104
|
+
|
|
105
|
+
export type Counterparty =
|
|
106
|
+
| ({ kind: "merchant" } & MerchantCounterparty)
|
|
107
|
+
| ({
|
|
108
|
+
kind: "user";
|
|
109
|
+
} & UserCounterparty)
|
|
110
|
+
| ({
|
|
111
|
+
kind: "service";
|
|
112
|
+
} & ServiceCounterparty);
|
|
113
|
+
|
|
114
|
+
export type AssetAccount = {
|
|
115
|
+
serviceAccountID: string;
|
|
116
|
+
nickname: string;
|
|
117
|
+
linkedAccountID: string;
|
|
118
|
+
service: Service;
|
|
119
|
+
} & (
|
|
120
|
+
| {
|
|
121
|
+
assetKind: "fiat";
|
|
122
|
+
accountKind: FiatMarketAccountKind;
|
|
123
|
+
currencyCode: string;
|
|
124
|
+
balance?: number;
|
|
125
|
+
ach?: ACHDetails;
|
|
126
|
+
wire?: WireDetails;
|
|
127
|
+
}
|
|
128
|
+
| {
|
|
129
|
+
assetKind: "stock" | "crypto";
|
|
130
|
+
accountKind: FiatMarketAccountKind;
|
|
131
|
+
}
|
|
132
|
+
| {
|
|
133
|
+
assetKind: "transport";
|
|
134
|
+
accountKind: TransportAccountKind;
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
export type TradeAssetRef =
|
|
139
|
+
| ({ assetKind: "transport" } & TransportAssetRef)
|
|
140
|
+
| ({ assetKind: "nothing" } & NothingAssetRef)
|
|
141
|
+
| ({ assetKind: "other" } & OtherAssetRef)
|
|
142
|
+
| ({ assetKind: "fiat" } & FiatAssetRef)
|
|
143
|
+
| ({ assetKind: "stock" | "crypto" } & MarketTradeAssetRef);
|
|
144
|
+
|
|
145
|
+
export type LinkedAccountDetails =
|
|
146
|
+
| ({ state: "active" } & ActiveLinkedAccountDetails)
|
|
147
|
+
| ({ state: "inactive" } & InactiveLinkedAccountDetails)
|
|
148
|
+
| ({ state: "unavailable" } & UnavailableLinkedAccountDetails);
|
|
149
|
+
|
|
150
|
+
// Composite types
|
|
151
|
+
|
|
152
|
+
export type TradeQuotesRequest<
|
|
153
|
+
GainedAssetKind extends TradeQuoteAssetKind,
|
|
154
|
+
LostAssetKind extends TradeQuoteAssetKind
|
|
155
|
+
> = {
|
|
156
|
+
linkedAccountIDs?: string;
|
|
157
|
+
gained: TradeAssetQuoteRequest & { assetKind: GainedAssetKind };
|
|
158
|
+
lost: TradeAssetQuoteRequest & { assetKind: LostAssetKind };
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export type TradeRef = {
|
|
162
|
+
lost: TradeAssetRef;
|
|
163
|
+
gained: TradeAssetRef;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export type TradeQuote<
|
|
167
|
+
GainedAssetKind extends TradeQuoteAssetKind,
|
|
168
|
+
LostAssetKind extends TradeQuoteAssetKind
|
|
169
|
+
> = {
|
|
170
|
+
gained: TradeAsset & { assetKind: GainedAssetKind };
|
|
171
|
+
lost: TradeAsset & { assetKind: LostAssetKind };
|
|
172
|
+
context: string;
|
|
173
|
+
expirationDateTime: string;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export type Trade<
|
|
177
|
+
GainedAssetKind extends TradeAssetKind,
|
|
178
|
+
LostAssetKind extends TradeAssetKind
|
|
179
|
+
> = {
|
|
180
|
+
dateTime: string;
|
|
181
|
+
state: TradeState;
|
|
182
|
+
counterparty: Counterparty;
|
|
183
|
+
gained: TradeAsset & { assetKind: GainedAssetKind };
|
|
184
|
+
lost: TradeAsset & { assetKind: LostAssetKind };
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export type LinkedAccount = Omit<_LinkedAccount, "details"> & {
|
|
188
|
+
details: LinkedAccountDetails;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// TO discriminated unions
|
|
192
|
+
|
|
193
|
+
export const toNativeTradeAssetRef = (
|
|
194
|
+
tradeAssetRef: TradeAssetRef
|
|
195
|
+
): _TradeAssetRef => {
|
|
196
|
+
switch (tradeAssetRef.assetKind) {
|
|
197
|
+
case "fiat":
|
|
198
|
+
return { fiatAssetRef: tradeAssetRef };
|
|
199
|
+
case "stock":
|
|
200
|
+
case "crypto":
|
|
201
|
+
return { marketTradeAssetRef: tradeAssetRef };
|
|
202
|
+
case "transport":
|
|
203
|
+
return { transportAssetRef: tradeAssetRef };
|
|
204
|
+
case "other":
|
|
205
|
+
return { otherAssetRef: tradeAssetRef };
|
|
206
|
+
case "nothing":
|
|
207
|
+
return { nothingAssetRef: tradeAssetRef };
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export const toNativeTradeAsset = (tradeAsset: TradeAsset): _TradeAsset => {
|
|
212
|
+
switch (tradeAsset.assetKind) {
|
|
213
|
+
case "fiat":
|
|
214
|
+
return { fiatAsset: tradeAsset };
|
|
215
|
+
case "stock":
|
|
216
|
+
case "crypto":
|
|
217
|
+
return { marketTradeAsset: tradeAsset };
|
|
218
|
+
case "transport":
|
|
219
|
+
return { transportAsset: tradeAsset };
|
|
220
|
+
case "other":
|
|
221
|
+
return { otherAsset: tradeAsset };
|
|
222
|
+
case "nothing":
|
|
223
|
+
return { nothingAsset: tradeAsset };
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export const toNativeTradeAssetQuoteRequest = (
|
|
228
|
+
tradeAssetQuoteRequest: TradeAssetQuoteRequest
|
|
229
|
+
): _TradeAssetQuoteRequest => {
|
|
230
|
+
switch (tradeAssetQuoteRequest.assetKind) {
|
|
231
|
+
case "fiat":
|
|
232
|
+
return { fiatAssetQuoteRequest: tradeAssetQuoteRequest };
|
|
233
|
+
case "stock":
|
|
234
|
+
case "crypto":
|
|
235
|
+
return { marketAssetQuoteRequest: tradeAssetQuoteRequest };
|
|
236
|
+
case "transport":
|
|
237
|
+
return { transportAssetQuoteRequest: tradeAssetQuoteRequest };
|
|
238
|
+
case "nothing":
|
|
239
|
+
return { nothingAssetQuoteRequest: tradeAssetQuoteRequest };
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
// TO composite types
|
|
244
|
+
|
|
245
|
+
export const toNativeTradeQuote = (
|
|
246
|
+
tradeQuote: TradeQuote<TradeQuoteAssetKind, TradeQuoteAssetKind>
|
|
247
|
+
): _TradeQuote => ({
|
|
248
|
+
...tradeQuote,
|
|
249
|
+
gained: toNativeTradeAsset(tradeQuote.gained),
|
|
250
|
+
lost: toNativeTradeAsset(tradeQuote.lost),
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
export const toNativeTradeQuoteRequest = (
|
|
254
|
+
tradeQuoteRequest: TradeQuotesRequest<
|
|
255
|
+
TradeQuoteAssetKind,
|
|
256
|
+
TradeQuoteAssetKind
|
|
257
|
+
>
|
|
258
|
+
): _TradeQuotesRequest => ({
|
|
259
|
+
...tradeQuoteRequest,
|
|
260
|
+
gained: toNativeTradeAssetQuoteRequest(tradeQuoteRequest.gained),
|
|
261
|
+
lost: toNativeTradeAssetQuoteRequest(tradeQuoteRequest.lost),
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
export const toNativeTradeRef = (tradeRef: TradeRef): _TradeRef => ({
|
|
265
|
+
gained: toNativeTradeAssetRef(tradeRef.gained),
|
|
266
|
+
lost: toNativeTradeAssetRef(tradeRef.lost),
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// FROM discriminated unions
|
|
270
|
+
|
|
271
|
+
export const fromNativeTradeAsset = (
|
|
272
|
+
nativeTradeAsset: _TradeAsset
|
|
273
|
+
): TradeAsset => {
|
|
274
|
+
const {
|
|
275
|
+
fiatAsset,
|
|
276
|
+
marketTradeAsset,
|
|
277
|
+
transportAsset,
|
|
278
|
+
otherAsset,
|
|
279
|
+
nothingAsset,
|
|
280
|
+
} = nativeTradeAsset;
|
|
281
|
+
|
|
282
|
+
if (fiatAsset !== undefined) {
|
|
283
|
+
return {
|
|
284
|
+
...fiatAsset,
|
|
285
|
+
assetKind: "fiat",
|
|
286
|
+
};
|
|
287
|
+
} else if (marketTradeAsset !== undefined) {
|
|
288
|
+
return {
|
|
289
|
+
...marketTradeAsset,
|
|
290
|
+
assetKind: marketTradeAsset.assetKind,
|
|
291
|
+
};
|
|
292
|
+
} else if (transportAsset !== undefined) {
|
|
293
|
+
return {
|
|
294
|
+
...transportAsset,
|
|
295
|
+
assetKind: "transport",
|
|
296
|
+
};
|
|
297
|
+
} else if (otherAsset !== undefined) {
|
|
298
|
+
return { assetKind: "other" };
|
|
299
|
+
} else if (nothingAsset !== undefined) {
|
|
300
|
+
return { assetKind: "nothing" };
|
|
301
|
+
} else {
|
|
302
|
+
throw new Error("Internal Candle Error: corrupted trade asset.");
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
export const fromNativeCounterparty = (
|
|
307
|
+
nativeCounterparty: _Counterparty
|
|
308
|
+
): Counterparty => {
|
|
309
|
+
const { merchantCounterparty, userCounterparty, serviceCounterparty } =
|
|
310
|
+
nativeCounterparty;
|
|
311
|
+
|
|
312
|
+
if (merchantCounterparty !== undefined) {
|
|
313
|
+
return {
|
|
314
|
+
...merchantCounterparty,
|
|
315
|
+
kind: "merchant",
|
|
316
|
+
};
|
|
317
|
+
} else if (userCounterparty !== undefined) {
|
|
318
|
+
return {
|
|
319
|
+
...userCounterparty,
|
|
320
|
+
kind: "user",
|
|
321
|
+
};
|
|
322
|
+
} else if (serviceCounterparty !== undefined) {
|
|
323
|
+
return {
|
|
324
|
+
...serviceCounterparty,
|
|
325
|
+
kind: "service",
|
|
326
|
+
};
|
|
327
|
+
} else {
|
|
328
|
+
throw new Error("Internal Candle Error: corrupted counterparty.");
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
export const fromNativeAssetAccount = (
|
|
333
|
+
nativeAssetAccount: _AssetAccount
|
|
334
|
+
): AssetAccount => {
|
|
335
|
+
const { fiatAccount, marketAccount, transportAccount } = nativeAssetAccount;
|
|
336
|
+
|
|
337
|
+
if (fiatAccount !== undefined) {
|
|
338
|
+
return {
|
|
339
|
+
...fiatAccount,
|
|
340
|
+
assetKind: "fiat",
|
|
341
|
+
};
|
|
342
|
+
} else if (marketAccount !== undefined) {
|
|
343
|
+
return {
|
|
344
|
+
...marketAccount,
|
|
345
|
+
assetKind: marketAccount.assetKind,
|
|
346
|
+
};
|
|
347
|
+
} else if (transportAccount !== undefined) {
|
|
348
|
+
return {
|
|
349
|
+
...transportAccount,
|
|
350
|
+
assetKind: "transport",
|
|
351
|
+
};
|
|
352
|
+
} else {
|
|
353
|
+
throw new Error("Internal Candle Error: corrupted asset account.");
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
export const fromNativeLinkedAccountDetails = (
|
|
358
|
+
nativeLinkedAccountDetails: _LinkedAccountDetails
|
|
359
|
+
): LinkedAccountDetails => {
|
|
360
|
+
const {
|
|
361
|
+
activeLinkedAccountDetails,
|
|
362
|
+
inactiveLinkedAccountDetails,
|
|
363
|
+
unavailableLinkedAccountDetails,
|
|
364
|
+
} = nativeLinkedAccountDetails;
|
|
365
|
+
|
|
366
|
+
if (activeLinkedAccountDetails !== undefined) {
|
|
367
|
+
return {
|
|
368
|
+
...activeLinkedAccountDetails,
|
|
369
|
+
state: "active",
|
|
370
|
+
};
|
|
371
|
+
} else if (inactiveLinkedAccountDetails !== undefined) {
|
|
372
|
+
return {
|
|
373
|
+
...inactiveLinkedAccountDetails,
|
|
374
|
+
state: "inactive",
|
|
375
|
+
};
|
|
376
|
+
} else if (unavailableLinkedAccountDetails !== undefined) {
|
|
377
|
+
return {
|
|
378
|
+
...unavailableLinkedAccountDetails,
|
|
379
|
+
state: "unavailable",
|
|
380
|
+
};
|
|
381
|
+
} else {
|
|
382
|
+
throw new Error("Internal Candle Error: corrupted linked account details");
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
// FROM composite types
|
|
387
|
+
|
|
388
|
+
export const fromNativeLinkedAccount = (
|
|
389
|
+
nativeLinkedAccount: _LinkedAccount
|
|
390
|
+
): LinkedAccount => ({
|
|
391
|
+
...nativeLinkedAccount,
|
|
392
|
+
details: fromNativeLinkedAccountDetails(nativeLinkedAccount.details),
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
export const fromNativeTrade = (
|
|
396
|
+
nativeTrade: _Trade
|
|
397
|
+
): Trade<TradeAssetKind, TradeAssetKind> => ({
|
|
398
|
+
...nativeTrade,
|
|
399
|
+
counterparty: fromNativeCounterparty(nativeTrade.counterparty),
|
|
400
|
+
lost: fromNativeTradeAsset(nativeTrade.lost),
|
|
401
|
+
gained: fromNativeTradeAsset(nativeTrade.gained),
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
export const fromNativeTradeAndQuote =
|
|
405
|
+
<
|
|
406
|
+
GainedAssetKind extends TradeQuoteAssetKind,
|
|
407
|
+
LostAssetKind extends TradeQuoteAssetKind
|
|
408
|
+
>(
|
|
409
|
+
tradeQuote: TradeQuote<GainedAssetKind, LostAssetKind>
|
|
410
|
+
) =>
|
|
411
|
+
(nativeTrade: _Trade): Trade<GainedAssetKind, LostAssetKind> => ({
|
|
412
|
+
...nativeTrade,
|
|
413
|
+
counterparty: fromNativeCounterparty(nativeTrade.counterparty),
|
|
414
|
+
gained: assertTradeAsset({
|
|
415
|
+
tradeAsset: fromNativeTradeAsset(nativeTrade.gained),
|
|
416
|
+
expectedAssetKind: tradeQuote.gained.assetKind,
|
|
417
|
+
}),
|
|
418
|
+
lost: assertTradeAsset({
|
|
419
|
+
tradeAsset: fromNativeTradeAsset(nativeTrade.lost),
|
|
420
|
+
expectedAssetKind: tradeQuote.lost.assetKind,
|
|
421
|
+
}),
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
export const fromNativeTradeQuoteAndRequest =
|
|
425
|
+
<
|
|
426
|
+
GainedAssetKind extends TradeQuoteAssetKind,
|
|
427
|
+
LostAssetKind extends TradeQuoteAssetKind
|
|
428
|
+
>(
|
|
429
|
+
tradeQuoteRequest: TradeQuotesRequest<GainedAssetKind, LostAssetKind>
|
|
430
|
+
) =>
|
|
431
|
+
(
|
|
432
|
+
nativeTradeQuote: _TradeQuote
|
|
433
|
+
): TradeQuote<GainedAssetKind, LostAssetKind> => ({
|
|
434
|
+
...nativeTradeQuote,
|
|
435
|
+
gained: assertTradeAsset({
|
|
436
|
+
tradeAsset: fromNativeTradeAsset(nativeTradeQuote.gained),
|
|
437
|
+
expectedAssetKind: tradeQuoteRequest.gained.assetKind,
|
|
438
|
+
}),
|
|
439
|
+
lost: assertTradeAsset({
|
|
440
|
+
tradeAsset: fromNativeTradeAsset(nativeTradeQuote.lost),
|
|
441
|
+
expectedAssetKind: tradeQuoteRequest.lost.assetKind,
|
|
442
|
+
}),
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
// Generics assertions
|
|
446
|
+
|
|
447
|
+
export const assertTradeAsset = <
|
|
448
|
+
ExpectedAssetKind extends TradeQuoteAssetKind
|
|
449
|
+
>(input: {
|
|
450
|
+
tradeAsset: TradeAsset;
|
|
451
|
+
expectedAssetKind: ExpectedAssetKind;
|
|
452
|
+
}): TradeAsset & {
|
|
453
|
+
assetKind: ExpectedAssetKind;
|
|
454
|
+
} => {
|
|
455
|
+
if (input.tradeAsset.assetKind !== input.expectedAssetKind) {
|
|
456
|
+
throw new Error("Internal Candle Error: unexpected trade asset kind.");
|
|
457
|
+
}
|
|
458
|
+
// NOTE: This cast is due to a TypeScript generics limitation and should be cleaned up when possible
|
|
459
|
+
return input.tradeAsset as TradeAsset & {
|
|
460
|
+
assetKind: ExpectedAssetKind;
|
|
461
|
+
};
|
|
462
|
+
};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// AppUser.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 `AppUser`, backed by a C++ struct.
|
|
11
|
-
public typealias AppUser = margelo.nitro.rncandle.AppUser
|
|
12
|
-
|
|
13
|
-
extension AppUser {
|
|
14
|
-
private typealias bridge = margelo.nitro.rncandle.bridge.swift
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Create a new instance of `AppUser`.
|
|
18
|
-
*/
|
|
19
|
-
public init(appKey: String, appSecret: String, appUserID: String?) {
|
|
20
|
-
self.init(
|
|
21
|
-
std.string(appKey), std.string(appSecret),
|
|
22
|
-
{ () -> bridge.std__optional_std__string_ in
|
|
23
|
-
if let __unwrappedValue = appUserID {
|
|
24
|
-
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
25
|
-
} else {
|
|
26
|
-
return .init()
|
|
27
|
-
}
|
|
28
|
-
}())
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public var appKey: String {
|
|
32
|
-
@inline(__always)
|
|
33
|
-
get {
|
|
34
|
-
return String(self.__appKey)
|
|
35
|
-
}
|
|
36
|
-
@inline(__always)
|
|
37
|
-
set {
|
|
38
|
-
self.__appKey = std.string(newValue)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public var appSecret: String {
|
|
43
|
-
@inline(__always)
|
|
44
|
-
get {
|
|
45
|
-
return String(self.__appSecret)
|
|
46
|
-
}
|
|
47
|
-
@inline(__always)
|
|
48
|
-
set {
|
|
49
|
-
self.__appSecret = std.string(newValue)
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
public var appUserID: String? {
|
|
54
|
-
@inline(__always)
|
|
55
|
-
get {
|
|
56
|
-
return { () -> String? in
|
|
57
|
-
if let __unwrapped = self.__appUserID.value {
|
|
58
|
-
return String(__unwrapped)
|
|
59
|
-
} else {
|
|
60
|
-
return nil
|
|
61
|
-
}
|
|
62
|
-
}()
|
|
63
|
-
}
|
|
64
|
-
@inline(__always)
|
|
65
|
-
set {
|
|
66
|
-
self.__appUserID = { () -> bridge.std__optional_std__string_ in
|
|
67
|
-
if let __unwrappedValue = newValue {
|
|
68
|
-
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
69
|
-
} else {
|
|
70
|
-
return .init()
|
|
71
|
-
}
|
|
72
|
-
}()
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// Func_void_std__string.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 `(_ value: String) -> 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_std__string {
|
|
13
|
-
public typealias bridge = margelo.nitro.rncandle.bridge.swift
|
|
14
|
-
|
|
15
|
-
private let closure: (_ value: String) -> Void
|
|
16
|
-
|
|
17
|
-
public init(_ closure: @escaping (_ value: String) -> Void) {
|
|
18
|
-
self.closure = closure
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@inline(__always)
|
|
22
|
-
public func call(value: std.string) {
|
|
23
|
-
self.closure(String(value))
|
|
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_std__string`.
|
|
37
|
-
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__string>`.
|
|
38
|
-
* This removes one strong reference from the object!
|
|
39
|
-
*/
|
|
40
|
-
@inline(__always)
|
|
41
|
-
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__string {
|
|
42
|
-
return Unmanaged<Func_void_std__string>.fromOpaque(pointer).takeRetainedValue()
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// Func_void_std__vector_std__shared_ptr_AnyMap__.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 `(_ value: [AnyMapHolder]) -> 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_std__vector_std__shared_ptr_AnyMap__ {
|
|
13
|
-
public typealias bridge = margelo.nitro.rncandle.bridge.swift
|
|
14
|
-
|
|
15
|
-
private let closure: (_ value: [AnyMapHolder]) -> Void
|
|
16
|
-
|
|
17
|
-
public init(_ closure: @escaping (_ value: [AnyMapHolder]) -> Void) {
|
|
18
|
-
self.closure = closure
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@inline(__always)
|
|
22
|
-
public func call(value: bridge.std__vector_std__shared_ptr_AnyMap__) {
|
|
23
|
-
self.closure(value.map({ __item in AnyMapHolder(withCppPart: __item) }))
|
|
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_std__vector_std__shared_ptr_AnyMap__`.
|
|
37
|
-
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__vector_std__shared_ptr_AnyMap__>`.
|
|
38
|
-
* This removes one strong reference from the object!
|
|
39
|
-
*/
|
|
40
|
-
@inline(__always)
|
|
41
|
-
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer)
|
|
42
|
-
-> Func_void_std__vector_std__shared_ptr_AnyMap__
|
|
43
|
-
{
|
|
44
|
-
return Unmanaged<Func_void_std__vector_std__shared_ptr_AnyMap__>.fromOpaque(pointer)
|
|
45
|
-
.takeRetainedValue()
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// ToolCall.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 `ToolCall`, backed by a C++ struct.
|
|
11
|
-
public typealias ToolCall = margelo.nitro.rncandle.ToolCall
|
|
12
|
-
|
|
13
|
-
extension ToolCall {
|
|
14
|
-
private typealias bridge = margelo.nitro.rncandle.bridge.swift
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Create a new instance of `ToolCall`.
|
|
18
|
-
*/
|
|
19
|
-
public init(name: String, arguments: String) {
|
|
20
|
-
self.init(std.string(name), std.string(arguments))
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public var name: String {
|
|
24
|
-
@inline(__always)
|
|
25
|
-
get {
|
|
26
|
-
return String(self.__name)
|
|
27
|
-
}
|
|
28
|
-
@inline(__always)
|
|
29
|
-
set {
|
|
30
|
-
self.__name = std.string(newValue)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public var arguments: String {
|
|
35
|
-
@inline(__always)
|
|
36
|
-
get {
|
|
37
|
-
return String(self.__arguments)
|
|
38
|
-
}
|
|
39
|
-
@inline(__always)
|
|
40
|
-
set {
|
|
41
|
-
self.__arguments = std.string(newValue)
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|