react-native-candle 0.1.17 → 0.1.18
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 +2 -167
- package/ios/Sources/RNCandle.swift +542 -46
- package/lib/commonjs/index.js +157 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +157 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +79 -3
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts +197 -9
- package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +79 -3
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/specs/RNCandle.nitro.d.ts +197 -9
- package/lib/typescript/module/src/specs/RNCandle.nitro.d.ts.map +1 -1
- package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Bridge.cpp +36 -4
- package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Bridge.hpp +528 -35
- package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Umbrella.hpp +108 -6
- package/nitrogen/generated/ios/c++/HybridRNCandleSpecSwift.hpp +122 -12
- package/nitrogen/generated/ios/swift/ACHAccountKind.swift +38 -0
- package/nitrogen/generated/ios/swift/ACHDetails.swift +55 -0
- package/nitrogen/generated/ios/swift/{Details.swift → ActiveLinkedAccountDetails.swift} +55 -22
- package/nitrogen/generated/ios/swift/Address.swift +33 -0
- package/nitrogen/generated/ios/swift/AssetAccount.swift +55 -0
- package/nitrogen/generated/ios/swift/AssetAccountDetails.swift +83 -0
- package/nitrogen/generated/ios/swift/AssetAccountKind.swift +42 -0
- package/nitrogen/generated/ios/swift/AssetAccountQuery.swift +76 -0
- package/nitrogen/generated/ios/swift/Coordinates.swift +44 -0
- package/nitrogen/generated/ios/swift/Counterparty.swift +115 -0
- package/nitrogen/generated/ios/swift/FiatAccountDetails.swift +165 -0
- package/nitrogen/generated/ios/swift/FiatAsset.swift +123 -0
- package/nitrogen/generated/ios/swift/FiatAssetQuoteRequest.swift +119 -0
- package/nitrogen/generated/ios/swift/Func_void_Trade.swift +44 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_AssetAccount_.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_TradeQuote_.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_Trade_.swift +45 -0
- package/nitrogen/generated/ios/swift/HybridRNCandleSpec.swift +4 -3
- package/nitrogen/generated/ios/swift/HybridRNCandleSpec_cxx.swift +79 -40
- package/nitrogen/generated/ios/swift/InactiveLinkedAccountDetails.swift +33 -0
- package/nitrogen/generated/ios/swift/LegalAccountKind.swift +46 -0
- package/nitrogen/generated/ios/swift/LinkedAccount.swift +16 -34
- package/nitrogen/generated/ios/swift/LinkedAccountDetails.swift +87 -0
- package/nitrogen/generated/ios/swift/MarketAccountDetails.swift +69 -0
- package/nitrogen/generated/ios/swift/MarketAssetQuoteRequest.swift +151 -0
- package/nitrogen/generated/ios/swift/MarketTradeAsset.swift +150 -0
- package/nitrogen/generated/ios/swift/MerchantCounterparty.swift +86 -0
- package/nitrogen/generated/ios/swift/MerchantLocation.swift +55 -0
- package/nitrogen/generated/ios/swift/NothingAsset.swift +33 -0
- package/nitrogen/generated/ios/swift/NothingAssetQuoteRequest.swift +33 -0
- package/nitrogen/generated/ios/swift/OtherAsset.swift +33 -0
- package/nitrogen/generated/ios/swift/ServiceCounterparty.swift +44 -0
- package/nitrogen/generated/ios/swift/Trade.swift +80 -0
- package/nitrogen/generated/ios/swift/TradeAsset.swift +175 -0
- package/nitrogen/generated/ios/swift/TradeAssetQuoteRequest.swift +148 -0
- package/nitrogen/generated/ios/swift/TradeQuery.swift +175 -0
- package/nitrogen/generated/ios/swift/TradeQuote.swift +44 -0
- package/nitrogen/generated/ios/swift/TradeQuoteRequest.swift +63 -0
- package/nitrogen/generated/ios/swift/TradeState.swift +42 -0
- package/nitrogen/generated/ios/swift/TransportAsset.swift +174 -0
- package/nitrogen/generated/ios/swift/TransportAssetQuoteRequest.swift +212 -0
- package/nitrogen/generated/ios/swift/UserCounterparty.swift +66 -0
- package/nitrogen/generated/ios/swift/WireDetails.swift +44 -0
- package/nitrogen/generated/shared/c++/{State.hpp → ACHAccountKind.hpp} +17 -17
- package/nitrogen/generated/shared/c++/ACHDetails.hpp +79 -0
- package/nitrogen/generated/shared/c++/{Details.hpp → ActiveLinkedAccountDetails.hpp} +25 -23
- package/nitrogen/generated/shared/c++/Address.hpp +69 -0
- package/nitrogen/generated/shared/c++/AssetAccount.hpp +82 -0
- package/nitrogen/generated/shared/c++/AssetAccountDetails.hpp +78 -0
- package/nitrogen/generated/shared/c++/AssetAccountKind.hpp +82 -0
- package/nitrogen/generated/shared/c++/AssetAccountQuery.hpp +76 -0
- package/nitrogen/generated/shared/c++/Coordinates.hpp +73 -0
- package/nitrogen/generated/shared/c++/Counterparty.hpp +85 -0
- package/nitrogen/generated/shared/c++/FiatAccountDetails.hpp +106 -0
- package/nitrogen/generated/shared/c++/FiatAsset.hpp +96 -0
- package/nitrogen/generated/shared/c++/FiatAssetQuoteRequest.hpp +82 -0
- package/nitrogen/generated/shared/c++/HybridRNCandleSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridRNCandleSpec.hpp +22 -3
- package/nitrogen/generated/shared/c++/InactiveLinkedAccountDetails.hpp +69 -0
- package/nitrogen/generated/shared/c++/LegalAccountKind.hpp +86 -0
- package/nitrogen/generated/shared/c++/LinkedAccount.hpp +13 -14
- package/nitrogen/generated/shared/c++/LinkedAccountDetails.hpp +78 -0
- package/nitrogen/generated/shared/c++/MarketAccountDetails.hpp +83 -0
- package/nitrogen/generated/shared/c++/MarketAssetQuoteRequest.hpp +86 -0
- package/nitrogen/generated/shared/c++/MarketTradeAsset.hpp +111 -0
- package/nitrogen/generated/shared/c++/MerchantCounterparty.hpp +84 -0
- package/nitrogen/generated/shared/c++/MerchantLocation.hpp +77 -0
- package/nitrogen/generated/shared/c++/NothingAsset.hpp +69 -0
- package/nitrogen/generated/shared/c++/NothingAssetQuoteRequest.hpp +69 -0
- package/nitrogen/generated/shared/c++/OtherAsset.hpp +69 -0
- package/nitrogen/generated/shared/c++/ServiceCounterparty.hpp +75 -0
- package/nitrogen/generated/shared/c++/Trade.hpp +93 -0
- package/nitrogen/generated/shared/c++/TradeAsset.hpp +99 -0
- package/nitrogen/generated/shared/c++/TradeAssetQuoteRequest.hpp +92 -0
- package/nitrogen/generated/shared/c++/TradeQuery.hpp +86 -0
- package/nitrogen/generated/shared/c++/TradeQuote.hpp +74 -0
- package/nitrogen/generated/shared/c++/TradeQuoteRequest.hpp +76 -0
- package/nitrogen/generated/shared/c++/TradeState.hpp +82 -0
- package/nitrogen/generated/shared/c++/TransportAsset.hpp +125 -0
- package/nitrogen/generated/shared/c++/TransportAssetQuoteRequest.hpp +99 -0
- package/nitrogen/generated/shared/c++/UserCounterparty.hpp +81 -0
- package/nitrogen/generated/shared/c++/WireDetails.hpp +73 -0
- package/package.json +1 -1
- package/src/index.ts +259 -3
- package/src/specs/RNCandle.nitro.ts +237 -10
- package/nitrogen/generated/ios/swift/State.swift +0 -38
|
@@ -5,6 +5,11 @@ import NitroModules
|
|
|
5
5
|
import SwiftUI
|
|
6
6
|
import UIKit
|
|
7
7
|
|
|
8
|
+
public enum RNClientError: Error {
|
|
9
|
+
case badEncoding
|
|
10
|
+
case badInitialization(message: String)
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
@available(iOS 17.0, *)
|
|
9
14
|
final class HybridRNCandle: HybridRNCandleSpec {
|
|
10
15
|
|
|
@@ -73,12 +78,9 @@ final class HybridRNCandle: HybridRNCandleSpec {
|
|
|
73
78
|
}
|
|
74
79
|
try viewModel.$linkedAccount
|
|
75
80
|
.removeDuplicates()
|
|
76
|
-
.compactMap
|
|
81
|
+
.compactMap(\.?.toLinkedAccount)
|
|
77
82
|
.receive(on: RunLoop.main)
|
|
78
|
-
.sink
|
|
79
|
-
guard let self else { return }
|
|
80
|
-
onSuccess(self.toLinkedAccount(linkedAccount))
|
|
81
|
-
}
|
|
83
|
+
.sink(receiveValue: onSuccess)
|
|
82
84
|
.store(in: &cancellables)
|
|
83
85
|
}
|
|
84
86
|
}
|
|
@@ -86,39 +88,123 @@ final class HybridRNCandle: HybridRNCandleSpec {
|
|
|
86
88
|
// MARK: - Public
|
|
87
89
|
|
|
88
90
|
public func unlinkAccount(linkedAccountID: String) throws -> Promise<Void> {
|
|
89
|
-
|
|
91
|
+
.async {
|
|
90
92
|
try await self.viewModel.candleClient.unlinkAccount(linkedAccountID: linkedAccountID)
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
public func getLinkedAccounts() throws -> Promise<[LinkedAccount]> {
|
|
95
|
-
|
|
96
|
-
guard let self else {
|
|
97
|
-
throw RNClientError.badInitialization(message: "Self was deinitialized \(#function).")
|
|
98
|
-
}
|
|
97
|
+
.async {
|
|
99
98
|
let accounts = try await self.viewModel.candleClient.getLinkedAccounts()
|
|
100
|
-
return accounts.map(
|
|
99
|
+
return accounts.map(\.toLinkedAccount)
|
|
101
100
|
}
|
|
102
101
|
}
|
|
103
102
|
|
|
104
|
-
public func getAssetAccounts() throws -> Promise<
|
|
103
|
+
public func getAssetAccounts(query: AssetAccountQuery) throws -> Promise<[AssetAccount]> {
|
|
105
104
|
.async {
|
|
106
|
-
|
|
105
|
+
let accounts = try await self.viewModel.candleClient.getAssetAccounts(
|
|
106
|
+
query: .init(
|
|
107
|
+
linkedAccountIDs: query.linkedAccountIDs,
|
|
108
|
+
assetKind: query.assetKind?.asCandleModel
|
|
109
|
+
)
|
|
110
|
+
)
|
|
111
|
+
return accounts.map { model in
|
|
112
|
+
let legalAccountKind = model.legalAccountKind.toRNModel
|
|
113
|
+
switch model.details {
|
|
114
|
+
case .FiatAccountDetails(let fiatDetails):
|
|
115
|
+
let ach = fiatDetails.ach.map { details in
|
|
116
|
+
ACHDetails(
|
|
117
|
+
accountNumber: details.accountNumber,
|
|
118
|
+
routingNumber: details.routingNumber,
|
|
119
|
+
accountKind: details.accountKind.toRNModel
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
let wire = fiatDetails.wire.map { details in
|
|
124
|
+
WireDetails(
|
|
125
|
+
accountNumber: details.accountNumber,
|
|
126
|
+
routingNumber: details.routingNumber
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
return AssetAccount(
|
|
130
|
+
legalAccountKind: legalAccountKind,
|
|
131
|
+
nickname: model.nickname,
|
|
132
|
+
details: .init(
|
|
133
|
+
fiatAccountDetails: .init(
|
|
134
|
+
assetKind: fiatDetails.assetKind.rawValue,
|
|
135
|
+
serviceAccountID: fiatDetails.serviceAccountID,
|
|
136
|
+
currencyCode: fiatDetails.currencyCode,
|
|
137
|
+
balance: fiatDetails.balance,
|
|
138
|
+
ach: ach,
|
|
139
|
+
wire: wire,
|
|
140
|
+
linkedAccountID: fiatDetails.linkedAccountID,
|
|
141
|
+
service: fiatDetails.service.toService),
|
|
142
|
+
marketAccountDetails: nil
|
|
143
|
+
)
|
|
144
|
+
)
|
|
145
|
+
case .MarketAccountDetails(let marketDetails):
|
|
146
|
+
return AssetAccount(
|
|
147
|
+
legalAccountKind: legalAccountKind,
|
|
148
|
+
nickname: model.nickname,
|
|
149
|
+
details: .init(
|
|
150
|
+
fiatAccountDetails: nil,
|
|
151
|
+
marketAccountDetails: .init(
|
|
152
|
+
assetKind: marketDetails.assetKind.rawValue,
|
|
153
|
+
serviceAccountID: marketDetails.serviceAccountID,
|
|
154
|
+
linkedAccountID: marketDetails.linkedAccountID,
|
|
155
|
+
service: marketDetails.service.toService
|
|
156
|
+
)
|
|
157
|
+
)
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
107
161
|
}
|
|
108
162
|
}
|
|
109
163
|
|
|
110
|
-
public func getTrades(
|
|
164
|
+
public func getTrades(query: TradeQuery) throws -> Promise<[Trade]> {
|
|
111
165
|
.async {
|
|
112
|
-
|
|
166
|
+
let trades = try await self.viewModel.candleClient.getTrades(
|
|
167
|
+
query: .init(
|
|
168
|
+
linkedAccountIDs: query.linkedAccountIDs,
|
|
169
|
+
dateTimeSpan: query.dateTimeSpan,
|
|
170
|
+
gainedAssetKind: .init(rawValue: query.gainedAssetKind ?? ""),
|
|
171
|
+
lostAssetKind: .init(rawValue: query.lostAssetKind ?? ""),
|
|
172
|
+
counterpartyKind: .init(rawValue: query.counterpartyKind ?? "")
|
|
173
|
+
))
|
|
174
|
+
return trades.map { trade in
|
|
175
|
+
return Trade(
|
|
176
|
+
dateTime: trade.dateTime,
|
|
177
|
+
state: TradeState(fromString: trade.state.rawValue)!,
|
|
178
|
+
counterparty: trade.toCounterparty,
|
|
179
|
+
lost: trade.lost.toAsset,
|
|
180
|
+
gained: trade.gained.toAsset
|
|
181
|
+
)
|
|
182
|
+
}
|
|
113
183
|
}
|
|
114
184
|
}
|
|
115
185
|
|
|
116
|
-
func getTradeQuotes(
|
|
186
|
+
public func getTradeQuotes(request: TradeQuoteRequest) throws -> Promise<[TradeQuote]> {
|
|
117
187
|
.async {
|
|
118
|
-
|
|
188
|
+
let accounts = try await self.viewModel.candleClient.getTradeQuotes(
|
|
189
|
+
request:
|
|
190
|
+
.init(
|
|
191
|
+
linkedAccountIDs: request.linkedAccountIDs,
|
|
192
|
+
gained: try request.toGained
|
|
193
|
+
)
|
|
194
|
+
)
|
|
195
|
+
return accounts.map { account in
|
|
196
|
+
TradeQuote(
|
|
197
|
+
lost: account.lost.toAsset,
|
|
198
|
+
gained: account.gained.toAsset
|
|
199
|
+
)
|
|
200
|
+
}
|
|
119
201
|
}
|
|
120
202
|
}
|
|
121
203
|
|
|
204
|
+
public func submitTrade(serviceTradeID: String) throws -> Promise<Trade> {
|
|
205
|
+
throw RNClientError.badInitialization(message: "Not implemented.")
|
|
206
|
+
}
|
|
207
|
+
|
|
122
208
|
public func deleteUser() throws -> Promise<Void> {
|
|
123
209
|
.async {
|
|
124
210
|
try await self.viewModel.candleClient.deleteUser()
|
|
@@ -140,7 +226,7 @@ final class HybridRNCandle: HybridRNCandleSpec {
|
|
|
140
226
|
let result = try await self.viewModel.candleClient.executeTool(
|
|
141
227
|
tool: RNToolCall(name: tool.name, arguments: tool.arguments)
|
|
142
228
|
)
|
|
143
|
-
return try
|
|
229
|
+
return try result.encodedToJSONString
|
|
144
230
|
}
|
|
145
231
|
}
|
|
146
232
|
|
|
@@ -192,51 +278,422 @@ final class HybridRNCandle: HybridRNCandleSpec {
|
|
|
192
278
|
}
|
|
193
279
|
}
|
|
194
280
|
|
|
195
|
-
enum RNClientError: Error {
|
|
196
|
-
case badEncoding
|
|
197
|
-
case badInitialization(message: String)
|
|
198
|
-
}
|
|
199
|
-
|
|
200
281
|
struct RNToolCall: ToolCallRequest, Codable {
|
|
201
282
|
let name: String
|
|
202
283
|
let arguments: String
|
|
203
284
|
}
|
|
204
285
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
extension Encodable {
|
|
289
|
+
var encodedToJSONString: String {
|
|
290
|
+
get throws {
|
|
291
|
+
let data = try JSONEncoder().encode(self)
|
|
292
|
+
if let string = String(data: data, encoding: .utf8) {
|
|
293
|
+
return string
|
|
294
|
+
}
|
|
295
|
+
throw RNClientError.badEncoding
|
|
209
296
|
}
|
|
210
|
-
throw RNClientError.badEncoding
|
|
211
297
|
}
|
|
298
|
+
}
|
|
212
299
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
300
|
+
extension Candle.Models.LinkedAccount {
|
|
301
|
+
var toLinkedAccount: LinkedAccount {
|
|
302
|
+
let service: Service = self.service.toService
|
|
303
|
+
switch details {
|
|
216
304
|
case .ActiveLinkedAccountDetails(let details):
|
|
217
305
|
return LinkedAccount(
|
|
218
|
-
|
|
306
|
+
linkedAccountID: linkedAccountID,
|
|
307
|
+
service: service,
|
|
308
|
+
serviceUserID: serviceUserID,
|
|
219
309
|
details: .init(
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
service: service
|
|
310
|
+
activeLinkedAccountDetails: .init(
|
|
311
|
+
state: details.state.rawValue,
|
|
312
|
+
accountOpened: details.accountOpened,
|
|
313
|
+
username: details.username,
|
|
314
|
+
emailAddress: details.emailAddress,
|
|
315
|
+
legalName: details.legalName), inactiveLinkedAccountDetails: nil)
|
|
227
316
|
)
|
|
228
|
-
case .InactiveLinkedAccountDetails:
|
|
317
|
+
case .InactiveLinkedAccountDetails(let details):
|
|
229
318
|
return LinkedAccount(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
319
|
+
linkedAccountID: linkedAccountID,
|
|
320
|
+
service: service,
|
|
321
|
+
serviceUserID: serviceUserID,
|
|
322
|
+
details: .init(
|
|
323
|
+
activeLinkedAccountDetails: nil,
|
|
324
|
+
inactiveLinkedAccountDetails: .init(state: details.state.rawValue))
|
|
325
|
+
)
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
extension Models.MerchantCounterparty {
|
|
331
|
+
var toLocation: MerchantLocation? {
|
|
332
|
+
if let location {
|
|
333
|
+
return .init(
|
|
334
|
+
countryCode: location.countryCode, countrySubdivisionCode: location.countrySubdivisionCode,
|
|
335
|
+
localityName: location.localityName)
|
|
336
|
+
}
|
|
337
|
+
return nil
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
extension Models.Trade {
|
|
342
|
+
var toCounterparty: Counterparty {
|
|
343
|
+
switch counterparty {
|
|
344
|
+
case .MerchantCounterparty(let merchant):
|
|
345
|
+
return .init(
|
|
346
|
+
merchantCounterparty: .init(
|
|
347
|
+
kind: merchant.kind.rawValue,
|
|
348
|
+
name: merchant.name, logoURL: merchant.logoURL,
|
|
349
|
+
location: merchant.toLocation
|
|
350
|
+
),
|
|
351
|
+
userCounterparty: nil,
|
|
352
|
+
serviceCounterparty: nil
|
|
353
|
+
)
|
|
354
|
+
case .ServiceCounterparty(let service):
|
|
355
|
+
return .init(
|
|
356
|
+
merchantCounterparty: nil,
|
|
357
|
+
userCounterparty: nil,
|
|
358
|
+
serviceCounterparty: .init(
|
|
359
|
+
kind: service.kind.rawValue,
|
|
360
|
+
service: service.service.toService
|
|
361
|
+
)
|
|
362
|
+
)
|
|
363
|
+
case .UserCounterparty(let user):
|
|
364
|
+
return .init(
|
|
365
|
+
merchantCounterparty: nil,
|
|
366
|
+
userCounterparty: .init(
|
|
367
|
+
kind: user.kind.rawValue,
|
|
368
|
+
legalName: user.legalName,
|
|
369
|
+
avatarURL: user.avatarURL,
|
|
370
|
+
username: user.username
|
|
371
|
+
),
|
|
372
|
+
serviceCounterparty: nil
|
|
373
|
+
)
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
extension Models.TradeAsset {
|
|
379
|
+
var toAsset: TradeAsset {
|
|
380
|
+
switch self {
|
|
381
|
+
case .FiatAsset(let fiatAsset):
|
|
382
|
+
return .init(
|
|
383
|
+
fiatAsset: .init(
|
|
384
|
+
assetKind: fiatAsset.assetKind.rawValue,
|
|
385
|
+
serviceTradeID: fiatAsset.serviceTradeID,
|
|
386
|
+
serviceAccountID: fiatAsset.serviceAccountID,
|
|
387
|
+
currencyCode: fiatAsset.currencyCode,
|
|
388
|
+
amount: fiatAsset.amount,
|
|
389
|
+
linkedAccountID: fiatAsset.linkedAccountID,
|
|
390
|
+
service: fiatAsset.service.toService
|
|
391
|
+
),
|
|
392
|
+
marketTradeAsset: nil,
|
|
393
|
+
transportAsset: nil,
|
|
394
|
+
otherAsset: nil,
|
|
395
|
+
nothingAsset: nil
|
|
234
396
|
)
|
|
397
|
+
case .MarketTradeAsset(let marketAsset):
|
|
398
|
+
return .init(
|
|
399
|
+
fiatAsset: nil,
|
|
400
|
+
marketTradeAsset: .init(
|
|
401
|
+
assetKind: marketAsset.assetKind.rawValue,
|
|
402
|
+
serviceAccountID: marketAsset.serviceAccountID,
|
|
403
|
+
serviceAssetID: marketAsset.serviceAssetID,
|
|
404
|
+
symbol: marketAsset.symbol,
|
|
405
|
+
amount: marketAsset.amount,
|
|
406
|
+
serviceTradeID: marketAsset.serviceTradeID,
|
|
407
|
+
linkedAccountID: marketAsset.linkedAccountID,
|
|
408
|
+
name: marketAsset.name,
|
|
409
|
+
color: marketAsset.color,
|
|
410
|
+
logoURL: marketAsset.logoURL,
|
|
411
|
+
service: marketAsset.service.toService
|
|
412
|
+
),
|
|
413
|
+
transportAsset: nil,
|
|
414
|
+
otherAsset: nil,
|
|
415
|
+
nothingAsset: nil
|
|
416
|
+
)
|
|
417
|
+
case .TransportAsset(let transportAsset):
|
|
418
|
+
return .init(
|
|
419
|
+
fiatAsset: nil,
|
|
420
|
+
marketTradeAsset: nil,
|
|
421
|
+
transportAsset: .init(
|
|
422
|
+
assetKind: transportAsset.assetKind.rawValue,
|
|
423
|
+
serviceTradeID: transportAsset.serviceTradeID,
|
|
424
|
+
serviceAssetID: transportAsset.serviceAssetID,
|
|
425
|
+
name: transportAsset.name,
|
|
426
|
+
description: transportAsset.description,
|
|
427
|
+
imageURL: transportAsset.imageURL,
|
|
428
|
+
originCoordinates: .init(
|
|
429
|
+
latitude: transportAsset.originCoordinates.latitude,
|
|
430
|
+
longitude: transportAsset.originCoordinates.longitude
|
|
431
|
+
),
|
|
432
|
+
originAddress: .init(value: transportAsset.originAddress.value),
|
|
433
|
+
destinationCoordinates: .init(
|
|
434
|
+
latitude: transportAsset.destinationCoordinates.latitude,
|
|
435
|
+
longitude: transportAsset.destinationCoordinates.longitude
|
|
436
|
+
),
|
|
437
|
+
destinationAddress: .init(value: transportAsset.destinationAddress.value),
|
|
438
|
+
seats: transportAsset.seats,
|
|
439
|
+
linkedAccountID: transportAsset.linkedAccountID,
|
|
440
|
+
service: transportAsset.service.toService
|
|
441
|
+
),
|
|
442
|
+
otherAsset: nil,
|
|
443
|
+
nothingAsset: nil
|
|
444
|
+
)
|
|
445
|
+
case .OtherAsset(let otherAsset):
|
|
446
|
+
return .init(
|
|
447
|
+
fiatAsset: nil,
|
|
448
|
+
marketTradeAsset: nil,
|
|
449
|
+
transportAsset: nil,
|
|
450
|
+
otherAsset: .init(assetKind: otherAsset.assetKind.rawValue),
|
|
451
|
+
nothingAsset: nil
|
|
452
|
+
)
|
|
453
|
+
case .NothingAsset(let nothingAsset):
|
|
454
|
+
return .init(
|
|
455
|
+
fiatAsset: nil,
|
|
456
|
+
marketTradeAsset: nil,
|
|
457
|
+
transportAsset: nil,
|
|
458
|
+
otherAsset: nil,
|
|
459
|
+
nothingAsset: .init(assetKind: nothingAsset.assetKind.rawValue)
|
|
460
|
+
)
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
extension TradeQuoteRequest {
|
|
466
|
+
var toGained: Models.TradeAssetQuoteRequest {
|
|
467
|
+
get throws {
|
|
468
|
+
if let fiatAssetQuoteRequest = gained.fiatAssetQuoteRequest {
|
|
469
|
+
return Models.TradeAssetQuoteRequest.FiatAssetQuoteRequest(
|
|
470
|
+
.init(
|
|
471
|
+
assetKind: .fiat,
|
|
472
|
+
serviceAccountID: fiatAssetQuoteRequest.serviceAccountID,
|
|
473
|
+
currencyCode: fiatAssetQuoteRequest.currencyCode,
|
|
474
|
+
amount: fiatAssetQuoteRequest.amount
|
|
475
|
+
)
|
|
476
|
+
)
|
|
477
|
+
} else if let marketAssetQuoteRequest = gained.marketAssetQuoteRequest {
|
|
478
|
+
return Models.TradeAssetQuoteRequest.MarketAssetQuoteRequest(
|
|
479
|
+
.init(
|
|
480
|
+
assetKind: .init(rawValue: marketAssetQuoteRequest.assetKind) ?? .stock,
|
|
481
|
+
serviceAccountID: marketAssetQuoteRequest.serviceAccountID,
|
|
482
|
+
serviceAssetID: marketAssetQuoteRequest.serviceAssetID,
|
|
483
|
+
symbol: marketAssetQuoteRequest.symbol,
|
|
484
|
+
amount: marketAssetQuoteRequest.amount
|
|
485
|
+
)
|
|
486
|
+
)
|
|
487
|
+
} else if gained.nothingAssetQuoteRequest != nil {
|
|
488
|
+
return Models.TradeAssetQuoteRequest.NothingAssetQuoteRequest(
|
|
489
|
+
.init(assetKind: .nothing)
|
|
490
|
+
)
|
|
491
|
+
} else if let transportAssetQuoteRequest = gained.transportAssetQuoteRequest {
|
|
492
|
+
return Models.TradeAssetQuoteRequest.TransportAssetQuoteRequest(
|
|
493
|
+
.init(
|
|
494
|
+
assetKind: .transport,
|
|
495
|
+
serviceAssetID: transportAssetQuoteRequest.serviceAssetID,
|
|
496
|
+
originCoordinates: transportAssetQuoteRequest.originCoordinates?.toCoordinates,
|
|
497
|
+
originAddress: transportAssetQuoteRequest.originAddress?.toAddress,
|
|
498
|
+
destinationCoordinates: transportAssetQuoteRequest.destinationCoordinates?
|
|
499
|
+
.toCoordinates,
|
|
500
|
+
destinationAddress: transportAssetQuoteRequest.destinationAddress?.toAddress,
|
|
501
|
+
seats: transportAssetQuoteRequest.seats
|
|
502
|
+
)
|
|
503
|
+
)
|
|
504
|
+
} else {
|
|
505
|
+
throw RNClientError.badInitialization(
|
|
506
|
+
message: "Internal Candle Error: corrupted trade quote request.")
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
extension Address {
|
|
513
|
+
var toAddress: Models.Address {
|
|
514
|
+
return .init(value: value)
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
extension Coordinates {
|
|
519
|
+
var toCoordinates: Models.Coordinates {
|
|
520
|
+
return .init(
|
|
521
|
+
latitude: latitude,
|
|
522
|
+
longitude: longitude
|
|
523
|
+
)
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
extension Service {
|
|
528
|
+
var toService: Models.Service {
|
|
529
|
+
switch self {
|
|
530
|
+
case .apple:
|
|
531
|
+
return .apple
|
|
532
|
+
case .cashApp:
|
|
533
|
+
return .cashApp
|
|
534
|
+
case .sandbox:
|
|
535
|
+
return .sandbox
|
|
536
|
+
case .robinhood:
|
|
537
|
+
return .robinhood
|
|
538
|
+
case .uber:
|
|
539
|
+
return .uber
|
|
540
|
+
case .lyft:
|
|
541
|
+
return .lyft
|
|
542
|
+
case .venmo:
|
|
543
|
+
return .venmo
|
|
544
|
+
case .chime:
|
|
545
|
+
return .chime
|
|
546
|
+
case .paypal:
|
|
547
|
+
return .paypal
|
|
548
|
+
case .coinbase:
|
|
549
|
+
return .coinbase
|
|
550
|
+
case .discover:
|
|
551
|
+
return .discover
|
|
552
|
+
case .americanExpress:
|
|
553
|
+
return .americanExpress
|
|
554
|
+
case .jpmorganChase:
|
|
555
|
+
return .jpmorganChase
|
|
556
|
+
case .bankOfAmerica:
|
|
557
|
+
return .bankOfAmerica
|
|
558
|
+
case .capitalOne:
|
|
559
|
+
return .capitalOne
|
|
560
|
+
case .citibank:
|
|
561
|
+
return .citibank
|
|
562
|
+
case .vanguard:
|
|
563
|
+
return .vanguard
|
|
564
|
+
case .wellsFargo:
|
|
565
|
+
return .wellsFargo
|
|
566
|
+
case .charlesSchwab:
|
|
567
|
+
return .charlesSchwab
|
|
568
|
+
case .kalshi:
|
|
569
|
+
return .kalshi
|
|
570
|
+
case .experian:
|
|
571
|
+
return .experian
|
|
572
|
+
case .waymo:
|
|
573
|
+
return .waymo
|
|
574
|
+
case .revel:
|
|
575
|
+
return .revel
|
|
576
|
+
case .turo:
|
|
577
|
+
return .turo
|
|
578
|
+
case .getaround:
|
|
579
|
+
return .getaround
|
|
580
|
+
case .zipcar:
|
|
581
|
+
return .zipcar
|
|
582
|
+
case .airbnb:
|
|
583
|
+
return .airbnb
|
|
584
|
+
case .americanAirlines:
|
|
585
|
+
return .americanAirlines
|
|
586
|
+
case .delta:
|
|
587
|
+
return .delta
|
|
588
|
+
case .united:
|
|
589
|
+
return .united
|
|
590
|
+
case .jetblue:
|
|
591
|
+
return .jetblue
|
|
592
|
+
case .southwest:
|
|
593
|
+
return .southwest
|
|
594
|
+
case .hawaiian:
|
|
595
|
+
return .hawaiian
|
|
596
|
+
case .hotels:
|
|
597
|
+
return .hotels
|
|
598
|
+
case .geico:
|
|
599
|
+
return .geico
|
|
600
|
+
case .progressive:
|
|
601
|
+
return .progressive
|
|
602
|
+
case .aaa:
|
|
603
|
+
return .aaa
|
|
604
|
+
case .stateFarm:
|
|
605
|
+
return .stateFarm
|
|
606
|
+
case .hertz:
|
|
607
|
+
return .hertz
|
|
608
|
+
case .avis:
|
|
609
|
+
return .avis
|
|
610
|
+
case .tesla:
|
|
611
|
+
return .tesla
|
|
612
|
+
case .doordash:
|
|
613
|
+
return .doordash
|
|
614
|
+
case .uberEats:
|
|
615
|
+
return .uberEats
|
|
616
|
+
case .grubhub:
|
|
617
|
+
return .grubhub
|
|
618
|
+
case .resy:
|
|
619
|
+
return .resy
|
|
620
|
+
case .opentable:
|
|
621
|
+
return .opentable
|
|
622
|
+
case .starbucks:
|
|
623
|
+
return .starbucks
|
|
624
|
+
case .blueBottle:
|
|
625
|
+
return .blueBottle
|
|
626
|
+
case .costco:
|
|
627
|
+
return .costco
|
|
628
|
+
case .amazon:
|
|
629
|
+
return .amazon
|
|
630
|
+
case .walmart:
|
|
631
|
+
return .walmart
|
|
632
|
+
case .wholeFoods:
|
|
633
|
+
return .wholeFoods
|
|
634
|
+
case .mcdonalds:
|
|
635
|
+
return .mcdonalds
|
|
636
|
+
case .chipotle:
|
|
637
|
+
return .chipotle
|
|
638
|
+
case .sweetgreen:
|
|
639
|
+
return .sweetgreen
|
|
640
|
+
case .snapchat:
|
|
641
|
+
return .snapchat
|
|
642
|
+
case .x:
|
|
643
|
+
return .x
|
|
644
|
+
case .facebook:
|
|
645
|
+
return .facebook
|
|
646
|
+
case .instagram:
|
|
647
|
+
return .instagram
|
|
648
|
+
case .signal:
|
|
649
|
+
return .signal
|
|
650
|
+
case .whatsapp:
|
|
651
|
+
return .whatsapp
|
|
652
|
+
case .messenger:
|
|
653
|
+
return .messenger
|
|
654
|
+
case .linkedin:
|
|
655
|
+
return .linkedin
|
|
656
|
+
case .discord:
|
|
657
|
+
return .discord
|
|
658
|
+
case .messages:
|
|
659
|
+
return .messages
|
|
660
|
+
case .telegram:
|
|
661
|
+
return .telegram
|
|
662
|
+
case .reddit:
|
|
663
|
+
return .reddit
|
|
664
|
+
case .pinterest:
|
|
665
|
+
return .pinterest
|
|
666
|
+
case .newYorkTimes:
|
|
667
|
+
return .newYorkTimes
|
|
668
|
+
case .washingtonPost:
|
|
669
|
+
return .washingtonPost
|
|
670
|
+
case .wallStreetJournal:
|
|
671
|
+
return .wallStreetJournal
|
|
672
|
+
case .cnn:
|
|
673
|
+
return .cnn
|
|
674
|
+
case .yahoo:
|
|
675
|
+
return .yahoo
|
|
676
|
+
case .fox:
|
|
677
|
+
return .fox
|
|
678
|
+
case .perplexity:
|
|
679
|
+
return .perplexity
|
|
680
|
+
case .openai:
|
|
681
|
+
return .openai
|
|
682
|
+
case .polymarket:
|
|
683
|
+
return .polymarket
|
|
684
|
+
case .espn:
|
|
685
|
+
return .espn
|
|
686
|
+
case .youtube:
|
|
687
|
+
return .youtube
|
|
688
|
+
case .netflix:
|
|
689
|
+
return .netflix
|
|
235
690
|
}
|
|
236
691
|
}
|
|
692
|
+
}
|
|
237
693
|
|
|
238
|
-
|
|
239
|
-
|
|
694
|
+
extension Models.Service {
|
|
695
|
+
var toService: Service {
|
|
696
|
+
switch self {
|
|
240
697
|
case .apple:
|
|
241
698
|
return .apple
|
|
242
699
|
case .cashApp:
|
|
@@ -400,3 +857,42 @@ final class HybridRNCandle: HybridRNCandleSpec {
|
|
|
400
857
|
}
|
|
401
858
|
}
|
|
402
859
|
}
|
|
860
|
+
|
|
861
|
+
extension AssetAccountKind {
|
|
862
|
+
var asCandleModel: Models.GetAssetAccounts.Input.Query.AssetKindPayload {
|
|
863
|
+
switch self {
|
|
864
|
+
case .fiat:
|
|
865
|
+
return .fiat
|
|
866
|
+
case .stock:
|
|
867
|
+
return .stock
|
|
868
|
+
case .crypto:
|
|
869
|
+
return .crypto
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
extension Candle.Components.Schemas.LegalAccountKind {
|
|
875
|
+
var toRNModel: LegalAccountKind {
|
|
876
|
+
switch self {
|
|
877
|
+
case .individual:
|
|
878
|
+
return .individual
|
|
879
|
+
case .joint:
|
|
880
|
+
return .joint
|
|
881
|
+
case .rothIra:
|
|
882
|
+
return .rothira
|
|
883
|
+
case .traditionalIra:
|
|
884
|
+
return .traditionalira
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
extension Candle.Components.Schemas.ACHAccountKind {
|
|
890
|
+
var toRNModel: ACHAccountKind {
|
|
891
|
+
switch self {
|
|
892
|
+
case .checking:
|
|
893
|
+
return .checking
|
|
894
|
+
case .savings:
|
|
895
|
+
return .savings
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
}
|