react-native-candle 0.1.26 → 0.1.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/ReactNativeCandle.podspec +1 -1
  2. package/ios/Sources/CandleLinkSheetWrapperView.swift +2 -2
  3. package/ios/Sources/RNCandle.swift +101 -44
  4. package/lib/commonjs/index.js +53 -25
  5. package/lib/commonjs/index.js.map +1 -1
  6. package/lib/module/index.js +53 -25
  7. package/lib/module/index.js.map +1 -1
  8. package/lib/typescript/commonjs/src/index.d.ts +15 -5
  9. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  10. package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts +29 -3
  11. package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts.map +1 -1
  12. package/lib/typescript/module/src/index.d.ts +15 -5
  13. package/lib/typescript/module/src/index.d.ts.map +1 -1
  14. package/lib/typescript/module/src/specs/RNCandle.nitro.d.ts +29 -3
  15. package/lib/typescript/module/src/specs/RNCandle.nitro.d.ts.map +1 -1
  16. package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Bridge.cpp +12 -12
  17. package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Bridge.hpp +110 -72
  18. package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Umbrella.hpp +18 -0
  19. package/nitrogen/generated/ios/c++/HybridRNCandleSpecSwift.hpp +21 -3
  20. package/nitrogen/generated/ios/swift/AssetAccountsResponse.swift +70 -0
  21. package/nitrogen/generated/ios/swift/{Func_void_std__vector_TradeQuote_.swift → Func_void_AssetAccountsResponse.swift} +11 -11
  22. package/nitrogen/generated/ios/swift/{Func_void_std__vector_AssetAccount_.swift → Func_void_TradeQuotesResponse.swift} +11 -12
  23. package/nitrogen/generated/ios/swift/{Func_void_std__vector_Trade_.swift → Func_void_TradesResponse.swift} +11 -12
  24. package/nitrogen/generated/ios/swift/HybridRNCandleSpec.swift +3 -3
  25. package/nitrogen/generated/ios/swift/HybridRNCandleSpec_cxx.swift +21 -51
  26. package/nitrogen/generated/ios/swift/LinkedAccountDetails.swift +33 -1
  27. package/nitrogen/generated/ios/swift/LinkedAccountStatusRef.swift +67 -0
  28. package/nitrogen/generated/ios/swift/StatePayload.swift +42 -0
  29. package/nitrogen/generated/ios/swift/TradeQuote.swift +13 -2
  30. package/nitrogen/generated/ios/swift/TradeQuotesResponse.swift +70 -0
  31. package/nitrogen/generated/ios/swift/TradesResponse.swift +70 -0
  32. package/nitrogen/generated/ios/swift/TransportAsset.swift +25 -2
  33. package/nitrogen/generated/ios/swift/UnavailableLinkedAccountDetails.swift +34 -0
  34. package/nitrogen/generated/shared/c++/AssetAccountsResponse.hpp +78 -0
  35. package/nitrogen/generated/shared/c++/HybridRNCandleSpec.hpp +18 -9
  36. package/nitrogen/generated/shared/c++/LinkedAccountDetails.hpp +9 -2
  37. package/nitrogen/generated/shared/c++/LinkedAccountStatusRef.hpp +86 -0
  38. package/nitrogen/generated/shared/c++/StatePayload.hpp +82 -0
  39. package/nitrogen/generated/shared/c++/TradeQuote.hpp +6 -2
  40. package/nitrogen/generated/shared/c++/TradeQuotesResponse.hpp +78 -0
  41. package/nitrogen/generated/shared/c++/TradesResponse.hpp +78 -0
  42. package/nitrogen/generated/shared/c++/TransportAsset.hpp +9 -1
  43. package/nitrogen/generated/shared/c++/UnavailableLinkedAccountDetails.hpp +69 -0
  44. package/package.json +1 -1
  45. package/src/index.ts +57 -24
  46. package/src/specs/RNCandle.nitro.ts +35 -3
@@ -0,0 +1,69 @@
1
+ ///
2
+ /// UnavailableLinkedAccountDetails.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
+
22
+
23
+ #include <string>
24
+
25
+ namespace margelo::nitro::rncandle {
26
+
27
+ /**
28
+ * A struct which can be represented as a JavaScript object (UnavailableLinkedAccountDetails).
29
+ */
30
+ struct UnavailableLinkedAccountDetails {
31
+ public:
32
+ std::string state SWIFT_PRIVATE;
33
+
34
+ public:
35
+ UnavailableLinkedAccountDetails() = default;
36
+ explicit UnavailableLinkedAccountDetails(std::string state): state(state) {}
37
+ };
38
+
39
+ } // namespace margelo::nitro::rncandle
40
+
41
+ namespace margelo::nitro {
42
+
43
+ using namespace margelo::nitro::rncandle;
44
+
45
+ // C++ UnavailableLinkedAccountDetails <> JS UnavailableLinkedAccountDetails (object)
46
+ template <>
47
+ struct JSIConverter<UnavailableLinkedAccountDetails> final {
48
+ static inline UnavailableLinkedAccountDetails fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
49
+ jsi::Object obj = arg.asObject(runtime);
50
+ return UnavailableLinkedAccountDetails(
51
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "state"))
52
+ );
53
+ }
54
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const UnavailableLinkedAccountDetails& arg) {
55
+ jsi::Object obj(runtime);
56
+ obj.setProperty(runtime, "state", JSIConverter<std::string>::toJSI(runtime, arg.state));
57
+ return obj;
58
+ }
59
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
60
+ if (!value.isObject()) {
61
+ return false;
62
+ }
63
+ jsi::Object obj = value.getObject(runtime);
64
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "state"))) return false;
65
+ return true;
66
+ }
67
+ };
68
+
69
+ } // namespace margelo::nitro
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-candle",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "description": "Candle SDK for React Native",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/module/index.js",
package/src/index.ts CHANGED
@@ -38,6 +38,7 @@ import type {
38
38
  FiatAssetRef,
39
39
  MarketTradeAssetRef,
40
40
  TradeAssetRef as InternalTradeAssetRef,
41
+ LinkedAccountStatusRef,
41
42
  } from "./specs/RNCandle.nitro";
42
43
 
43
44
  export class CandleClient {
@@ -121,7 +122,7 @@ export class CandleClient {
121
122
  details: { state: "active" } & ActiveLinkedAccountDetails;
122
123
  })
123
124
  | (LinkedAccount & {
124
- details: { state: "inactive" };
125
+ details: { state: "inactive" | "unavailable" };
125
126
  })
126
127
  )[]
127
128
  > {
@@ -143,6 +144,16 @@ export class CandleClient {
143
144
  state: "inactive",
144
145
  },
145
146
  };
147
+ } else if (
148
+ account.details.unavailableLinkedAccountDetails !== undefined
149
+ ) {
150
+ return {
151
+ ...account,
152
+ details: {
153
+ ...account.details.unavailableLinkedAccountDetails,
154
+ state: "unavailable",
155
+ },
156
+ };
146
157
  } else {
147
158
  throw new Error("Internal Candle Error: corrupted linked account.");
148
159
  }
@@ -172,11 +183,18 @@ export class CandleClient {
172
183
  return this.candle.executeTool(tool);
173
184
  }
174
185
 
175
- public async getAssetAccounts(
176
- query: AssetAccountQuery = {}
177
- ): Promise<AssetAccount[]> {
178
- const accounts = await this.candle.getAssetAccounts(query);
179
- return accounts.map((account) => this.convertToAssetAccount(account));
186
+ public async getAssetAccounts(query: AssetAccountQuery = {}): Promise<{
187
+ assetAccounts: AssetAccount[];
188
+ linkedAccounts: LinkedAccountStatusRef[];
189
+ }> {
190
+ const { assetAccounts, linkedAccounts } =
191
+ await this.candle.getAssetAccounts(query);
192
+ return {
193
+ assetAccounts: assetAccounts.map((account) =>
194
+ this.convertToAssetAccount(account)
195
+ ),
196
+ linkedAccounts,
197
+ };
180
198
  }
181
199
 
182
200
  public async getAssetAccount(ref: AssetAccountRef): Promise<AssetAccount> {
@@ -184,15 +202,21 @@ export class CandleClient {
184
202
  return this.convertToAssetAccount(account);
185
203
  }
186
204
 
187
- public async getTrades(query: TradeQuery = {}): Promise<Trade[]> {
188
- const trades = await this.candle.getTrades(query);
189
- return trades.map(({ dateTime, counterparty, gained, lost, state }) => ({
190
- dateTime,
191
- state,
192
- counterparty: this.convertToCounterparty(counterparty),
193
- lost: this.convertTradeAsset(lost),
194
- gained: this.convertTradeAsset(gained),
195
- }));
205
+ public async getTrades(query: TradeQuery = {}): Promise<{
206
+ trades: Trade[];
207
+ linkedAccounts: LinkedAccountStatusRef[];
208
+ }> {
209
+ const { trades, linkedAccounts } = await this.candle.getTrades(query);
210
+ return {
211
+ trades: trades.map(({ dateTime, counterparty, gained, lost, state }) => ({
212
+ dateTime,
213
+ state,
214
+ counterparty: this.convertToCounterparty(counterparty),
215
+ lost: this.convertTradeAsset(lost),
216
+ gained: this.convertTradeAsset(gained),
217
+ })),
218
+ linkedAccounts,
219
+ };
196
220
  }
197
221
 
198
222
  public async getTrade(input: {
@@ -221,7 +245,10 @@ export class CandleClient {
221
245
  | ({ assetKind: "transport" } & TransportAssetQuoteRequest)
222
246
  | ({ assetKind: "fiat" } & FiatAssetQuoteRequest)
223
247
  | ({ assetKind: "stock" | "crypto" } & MarketAssetQuoteRequest);
224
- }): Promise<TradeQuote[]> {
248
+ }): Promise<{
249
+ tradeQuotes: TradeQuote[];
250
+ linkedAccounts: LinkedAccountStatusRef[];
251
+ }> {
225
252
  let gainedRequest: TradeAssetQuoteRequest;
226
253
 
227
254
  switch (request.gained.assetKind) {
@@ -240,18 +267,22 @@ export class CandleClient {
240
267
  break;
241
268
  }
242
269
 
243
- const quotes = await this.candle.getTradeQuotes({
270
+ const { linkedAccounts, tradeQuotes } = await this.candle.getTradeQuotes({
244
271
  linkedAccountIDs: request.linkedAccountIDs,
245
272
  gained: gainedRequest,
246
273
  });
247
274
 
248
- return quotes.map((quote) => {
249
- return {
250
- gained: this.convertTradeAsset(quote.gained),
251
- lost: this.convertTradeAsset(quote.lost),
252
- context: quote.context,
253
- };
254
- });
275
+ return {
276
+ tradeQuotes: tradeQuotes.map((quote) => {
277
+ return {
278
+ gained: this.convertTradeAsset(quote.gained),
279
+ lost: this.convertTradeAsset(quote.lost),
280
+ context: quote.context,
281
+ expirationDateTime: quote.expirationDateTime,
282
+ };
283
+ }),
284
+ linkedAccounts,
285
+ };
255
286
  }
256
287
 
257
288
  private convertTradeAssetRef(
@@ -325,6 +356,7 @@ export class CandleClient {
325
356
  context,
326
357
  gained: this.toInternalTradeAsset(gained),
327
358
  lost: this.toInternalTradeAsset(lost),
359
+ expirationDateTime: tradeQuote.expirationDateTime,
328
360
  };
329
361
  }
330
362
 
@@ -445,6 +477,7 @@ type TradeQuote = {
445
477
  gained: TradeAsset;
446
478
  lost: TradeAsset;
447
479
  context: string;
480
+ expirationDateTime: string;
448
481
  };
449
482
 
450
483
  type TradeQueryAssetKind =
@@ -107,6 +107,8 @@ export type TransportAsset = {
107
107
  destinationCoordinates: Coordinates;
108
108
  destinationAddress: Address;
109
109
  seats: number;
110
+ departureDateTime: string;
111
+ arrivalDateTime: string;
110
112
  linkedAccountID: string;
111
113
  service: Service;
112
114
  };
@@ -227,6 +229,7 @@ export type TradeQuote = {
227
229
  lost: TradeAsset;
228
230
  gained: TradeAsset;
229
231
  context: string;
232
+ expirationDateTime: string;
230
233
  };
231
234
 
232
235
  export type Service =
@@ -328,9 +331,14 @@ export type InactiveLinkedAccountDetails = {
328
331
  state: string; // "inactive"
329
332
  };
330
333
 
334
+ export type UnavailableLinkedAccountDetails = {
335
+ state: string; // "unavailable"
336
+ };
337
+
331
338
  export type LinkedAccountDetails = {
332
339
  activeLinkedAccountDetails?: ActiveLinkedAccountDetails;
333
340
  inactiveLinkedAccountDetails?: InactiveLinkedAccountDetails;
341
+ unavailableLinkedAccountDetails?: UnavailableLinkedAccountDetails;
334
342
  };
335
343
 
336
344
  export type LinkedAccount = {
@@ -399,6 +407,30 @@ export type TradeExecutionResult = {
399
407
  error?: string;
400
408
  };
401
409
 
410
+ export type StatePayload = "active" | "inactive" | "unavailable";
411
+
412
+ export type LinkedAccountStatusRef = {
413
+ linkedAccountID: string;
414
+ service: Service;
415
+ serviceUserID: string;
416
+ state: StatePayload;
417
+ };
418
+
419
+ export type AssetAccountsResponse = {
420
+ linkedAccounts: LinkedAccountStatusRef[];
421
+ assetAccounts: AssetAccount[];
422
+ };
423
+
424
+ export type TradesResponse = {
425
+ linkedAccounts: LinkedAccountStatusRef[];
426
+ trades: Trade[];
427
+ };
428
+
429
+ export type TradeQuotesResponse = {
430
+ linkedAccounts: LinkedAccountStatusRef[];
431
+ tradeQuotes: TradeQuote[];
432
+ };
433
+
402
434
  export interface RNCandle extends HybridObject<{ ios: "swift" }> {
403
435
  candleLinkSheet(
404
436
  isPresented: boolean,
@@ -419,11 +451,11 @@ export interface RNCandle extends HybridObject<{ ios: "swift" }> {
419
451
  getLinkedAccounts(): Promise<LinkedAccount[]>;
420
452
  getLinkedAccount(ref: LinkedAccountRef): Promise<LinkedAccount>;
421
453
  unlinkAccount(ref: LinkedAccountRef): Promise<void>;
422
- getAssetAccounts(query: AssetAccountQuery): Promise<AssetAccount[]>;
454
+ getAssetAccounts(query: AssetAccountQuery): Promise<AssetAccountsResponse>;
423
455
  getAssetAccount(ref: AssetAccountRef): Promise<AssetAccount>;
424
- getTrades(query: TradeQuery): Promise<Trade[]>;
456
+ getTrades(query: TradeQuery): Promise<TradesResponse>;
425
457
  getTrade(ref: TradeRef): Promise<Trade>;
426
- getTradeQuotes(request: TradeQuoteRequest): Promise<TradeQuote[]>;
458
+ getTradeQuotes(request: TradeQuoteRequest): Promise<TradeQuotesResponse>;
427
459
  deleteUser(): Promise<void>;
428
460
  // FIXME: The return type should be a more specific type based on the actual tool calls available.
429
461
  getAvailableTools(): Promise<Array<AnyMap>>;