react-native-candle 0.1.17 → 0.1.19
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 +642 -53
- package/lib/commonjs/index.js +167 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +167 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +81 -3
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts +201 -9
- package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +81 -3
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/specs/RNCandle.nitro.d.ts +201 -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 +111 -6
- package/nitrogen/generated/ios/c++/HybridRNCandleSpecSwift.hpp +125 -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/ExecuteTradeRequest.swift +44 -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++/ExecuteTradeRequest.hpp +73 -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 +25 -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 +271 -3
- package/src/specs/RNCandle.nitro.ts +242 -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
|
|
|
@@ -17,7 +22,8 @@ final class HybridRNCandle: HybridRNCandleSpec {
|
|
|
17
22
|
if let viewModel = rootVC?.rootView.viewModel {
|
|
18
23
|
return viewModel
|
|
19
24
|
}
|
|
20
|
-
throw RNClientError.badInitialization(
|
|
25
|
+
throw RNClientError.badInitialization(
|
|
26
|
+
message: "Failed to properly initialize the client.")
|
|
21
27
|
}
|
|
22
28
|
}
|
|
23
29
|
|
|
@@ -27,11 +33,16 @@ final class HybridRNCandle: HybridRNCandleSpec {
|
|
|
27
33
|
Task { @MainActor in
|
|
28
34
|
let wrapperView = CandleLinkSheetWrapper(
|
|
29
35
|
appUser: .init(
|
|
30
|
-
appKey: appUser.appKey, appSecret: appUser.appSecret,
|
|
36
|
+
appKey: appUser.appKey, appSecret: appUser.appSecret,
|
|
37
|
+
appUserID: appUser.appUserID))
|
|
31
38
|
let hostingVC = UIHostingController(rootView: wrapperView)
|
|
32
39
|
self.rootVC = hostingVC
|
|
33
|
-
guard
|
|
34
|
-
|
|
40
|
+
guard
|
|
41
|
+
let rootViewController = UIApplication.keyWindow?
|
|
42
|
+
.rootViewController
|
|
43
|
+
else {
|
|
44
|
+
throw RNClientError.badInitialization(
|
|
45
|
+
message: "Application root view was not initialized.")
|
|
35
46
|
}
|
|
36
47
|
rootViewController.embed(hostingVC)
|
|
37
48
|
}
|
|
@@ -73,12 +84,9 @@ final class HybridRNCandle: HybridRNCandleSpec {
|
|
|
73
84
|
}
|
|
74
85
|
try viewModel.$linkedAccount
|
|
75
86
|
.removeDuplicates()
|
|
76
|
-
.compactMap
|
|
87
|
+
.compactMap(\.?.toLinkedAccount)
|
|
77
88
|
.receive(on: RunLoop.main)
|
|
78
|
-
.sink
|
|
79
|
-
guard let self else { return }
|
|
80
|
-
onSuccess(self.toLinkedAccount(linkedAccount))
|
|
81
|
-
}
|
|
89
|
+
.sink(receiveValue: onSuccess)
|
|
82
90
|
.store(in: &cancellables)
|
|
83
91
|
}
|
|
84
92
|
}
|
|
@@ -86,36 +94,143 @@ final class HybridRNCandle: HybridRNCandleSpec {
|
|
|
86
94
|
// MARK: - Public
|
|
87
95
|
|
|
88
96
|
public func unlinkAccount(linkedAccountID: String) throws -> Promise<Void> {
|
|
89
|
-
|
|
90
|
-
try await self.viewModel.candleClient.unlinkAccount(
|
|
97
|
+
.async {
|
|
98
|
+
try await self.viewModel.candleClient.unlinkAccount(
|
|
99
|
+
linkedAccountID: linkedAccountID)
|
|
91
100
|
}
|
|
92
101
|
}
|
|
93
102
|
|
|
94
103
|
public func getLinkedAccounts() throws -> Promise<[LinkedAccount]> {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
104
|
+
.async {
|
|
105
|
+
let accounts = try await self.viewModel.candleClient
|
|
106
|
+
.getLinkedAccounts()
|
|
107
|
+
return accounts.map(\.toLinkedAccount)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
public func getAssetAccounts(query: AssetAccountQuery) throws -> Promise<
|
|
112
|
+
[AssetAccount]
|
|
113
|
+
> {
|
|
114
|
+
.async {
|
|
115
|
+
let accounts = try await self.viewModel.candleClient
|
|
116
|
+
.getAssetAccounts(
|
|
117
|
+
query: .init(
|
|
118
|
+
linkedAccountIDs: query.linkedAccountIDs,
|
|
119
|
+
assetKind: query.assetKind?.asCandleModel
|
|
120
|
+
)
|
|
121
|
+
)
|
|
122
|
+
return accounts.map { model in
|
|
123
|
+
let legalAccountKind = model.legalAccountKind.toRNModel
|
|
124
|
+
switch model.details {
|
|
125
|
+
case .FiatAccountDetails(let fiatDetails):
|
|
126
|
+
let ach = fiatDetails.ach.map { details in
|
|
127
|
+
ACHDetails(
|
|
128
|
+
accountNumber: details.accountNumber,
|
|
129
|
+
routingNumber: details.routingNumber,
|
|
130
|
+
accountKind: details.accountKind.toRNModel
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
let wire = fiatDetails.wire.map { details in
|
|
135
|
+
WireDetails(
|
|
136
|
+
accountNumber: details.accountNumber,
|
|
137
|
+
routingNumber: details.routingNumber
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
return AssetAccount(
|
|
141
|
+
legalAccountKind: legalAccountKind,
|
|
142
|
+
nickname: model.nickname,
|
|
143
|
+
details: .init(
|
|
144
|
+
fiatAccountDetails: .init(
|
|
145
|
+
assetKind: fiatDetails.assetKind.rawValue,
|
|
146
|
+
serviceAccountID: fiatDetails.serviceAccountID,
|
|
147
|
+
currencyCode: fiatDetails.currencyCode,
|
|
148
|
+
balance: fiatDetails.balance,
|
|
149
|
+
ach: ach,
|
|
150
|
+
wire: wire,
|
|
151
|
+
linkedAccountID: fiatDetails.linkedAccountID,
|
|
152
|
+
service: fiatDetails.service.toService),
|
|
153
|
+
marketAccountDetails: nil
|
|
154
|
+
)
|
|
155
|
+
)
|
|
156
|
+
case .MarketAccountDetails(let marketDetails):
|
|
157
|
+
return AssetAccount(
|
|
158
|
+
legalAccountKind: legalAccountKind,
|
|
159
|
+
nickname: model.nickname,
|
|
160
|
+
details: .init(
|
|
161
|
+
fiatAccountDetails: nil,
|
|
162
|
+
marketAccountDetails: .init(
|
|
163
|
+
assetKind: marketDetails.assetKind.rawValue,
|
|
164
|
+
serviceAccountID: marketDetails
|
|
165
|
+
.serviceAccountID,
|
|
166
|
+
linkedAccountID: marketDetails.linkedAccountID,
|
|
167
|
+
service: marketDetails.service.toService
|
|
168
|
+
)
|
|
169
|
+
)
|
|
170
|
+
)
|
|
171
|
+
}
|
|
98
172
|
}
|
|
99
|
-
let accounts = try await self.viewModel.candleClient.getLinkedAccounts()
|
|
100
|
-
return accounts.map(self.toLinkedAccount)
|
|
101
173
|
}
|
|
102
174
|
}
|
|
103
175
|
|
|
104
|
-
public func
|
|
176
|
+
public func getTrades(query: TradeQuery) throws -> Promise<[Trade]> {
|
|
105
177
|
.async {
|
|
106
|
-
|
|
178
|
+
let trades = try await self.viewModel.candleClient.getTrades(
|
|
179
|
+
query: .init(
|
|
180
|
+
linkedAccountIDs: query.linkedAccountIDs,
|
|
181
|
+
dateTimeSpan: query.dateTimeSpan,
|
|
182
|
+
gainedAssetKind: query.toGainedAssetKind,
|
|
183
|
+
lostAssetKind: query.toLostAssetKind,
|
|
184
|
+
counterpartyKind: query.toCounterpartyKindPayload
|
|
185
|
+
))
|
|
186
|
+
return trades.map { trade in
|
|
187
|
+
return Trade(
|
|
188
|
+
dateTime: trade.dateTime,
|
|
189
|
+
state: TradeState(fromString: trade.state.rawValue)!,
|
|
190
|
+
counterparty: trade.toCounterparty,
|
|
191
|
+
lost: trade.lost.toAsset,
|
|
192
|
+
gained: trade.gained.toAsset
|
|
193
|
+
)
|
|
194
|
+
}
|
|
107
195
|
}
|
|
108
196
|
}
|
|
109
197
|
|
|
110
|
-
public func
|
|
198
|
+
public func getTradeQuotes(request: TradeQuoteRequest) throws -> Promise<
|
|
199
|
+
[TradeQuote]
|
|
200
|
+
> {
|
|
111
201
|
.async {
|
|
112
|
-
|
|
202
|
+
let accounts = try await self.viewModel.candleClient.getTradeQuotes(
|
|
203
|
+
request:
|
|
204
|
+
.init(
|
|
205
|
+
linkedAccountIDs: request.linkedAccountIDs,
|
|
206
|
+
gained: try request.toGained
|
|
207
|
+
)
|
|
208
|
+
)
|
|
209
|
+
return accounts.map { account in
|
|
210
|
+
TradeQuote(
|
|
211
|
+
lost: account.lost.toAsset,
|
|
212
|
+
gained: account.gained.toAsset
|
|
213
|
+
)
|
|
214
|
+
}
|
|
113
215
|
}
|
|
114
216
|
}
|
|
115
217
|
|
|
116
|
-
func
|
|
218
|
+
public func executeTrade(request: ExecuteTradeRequest) throws -> Promise<
|
|
219
|
+
Trade
|
|
220
|
+
> {
|
|
117
221
|
.async {
|
|
118
|
-
|
|
222
|
+
let trade = try await self.viewModel.candleClient.executeTrade(
|
|
223
|
+
context: .init(
|
|
224
|
+
linkedAccountID: request.linkedAccountID,
|
|
225
|
+
context: request.context)
|
|
226
|
+
)
|
|
227
|
+
return Trade(
|
|
228
|
+
dateTime: trade.dateTime,
|
|
229
|
+
state: trade.state.toRNModel,
|
|
230
|
+
counterparty: trade.toCounterparty,
|
|
231
|
+
lost: trade.lost.toAsset,
|
|
232
|
+
gained: trade.gained.toAsset
|
|
233
|
+
)
|
|
119
234
|
}
|
|
120
235
|
}
|
|
121
236
|
|
|
@@ -128,9 +243,11 @@ final class HybridRNCandle: HybridRNCandleSpec {
|
|
|
128
243
|
public func getAvailableTools() throws -> Promise<[AnyMapHolder]> {
|
|
129
244
|
.async { [weak self] in
|
|
130
245
|
guard let self else {
|
|
131
|
-
throw RNClientError.badInitialization(
|
|
246
|
+
throw RNClientError.badInitialization(
|
|
247
|
+
message: "Self was deinitialized \(#function).")
|
|
132
248
|
}
|
|
133
|
-
let result = try await self.viewModel.candleClient
|
|
249
|
+
let result = try await self.viewModel.candleClient
|
|
250
|
+
.getAvailableTools()
|
|
134
251
|
return result.map(self.toHolder)
|
|
135
252
|
}
|
|
136
253
|
}
|
|
@@ -140,7 +257,7 @@ final class HybridRNCandle: HybridRNCandleSpec {
|
|
|
140
257
|
let result = try await self.viewModel.candleClient.executeTool(
|
|
141
258
|
tool: RNToolCall(name: tool.name, arguments: tool.arguments)
|
|
142
259
|
)
|
|
143
|
-
return try
|
|
260
|
+
return try result.encodedToJSONString
|
|
144
261
|
}
|
|
145
262
|
}
|
|
146
263
|
|
|
@@ -192,51 +309,276 @@ final class HybridRNCandle: HybridRNCandleSpec {
|
|
|
192
309
|
}
|
|
193
310
|
}
|
|
194
311
|
|
|
195
|
-
enum RNClientError: Error {
|
|
196
|
-
case badEncoding
|
|
197
|
-
case badInitialization(message: String)
|
|
198
|
-
}
|
|
199
|
-
|
|
200
312
|
struct RNToolCall: ToolCallRequest, Codable {
|
|
201
313
|
let name: String
|
|
202
314
|
let arguments: String
|
|
203
315
|
}
|
|
204
316
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
extension Encodable {
|
|
320
|
+
var encodedToJSONString: String {
|
|
321
|
+
get throws {
|
|
322
|
+
let data = try JSONEncoder().encode(self)
|
|
323
|
+
if let string = String(data: data, encoding: .utf8) {
|
|
324
|
+
return string
|
|
325
|
+
}
|
|
326
|
+
throw RNClientError.badEncoding
|
|
209
327
|
}
|
|
210
|
-
throw RNClientError.badEncoding
|
|
211
328
|
}
|
|
329
|
+
}
|
|
212
330
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
331
|
+
extension Candle.Models.LinkedAccount {
|
|
332
|
+
var toLinkedAccount: LinkedAccount {
|
|
333
|
+
let service: Service = self.service.toService
|
|
334
|
+
switch details {
|
|
216
335
|
case .ActiveLinkedAccountDetails(let details):
|
|
217
336
|
return LinkedAccount(
|
|
218
|
-
|
|
337
|
+
linkedAccountID: linkedAccountID,
|
|
338
|
+
service: service,
|
|
339
|
+
serviceUserID: serviceUserID,
|
|
219
340
|
details: .init(
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
341
|
+
activeLinkedAccountDetails: .init(
|
|
342
|
+
state: details.state.rawValue,
|
|
343
|
+
accountOpened: details.accountOpened,
|
|
344
|
+
username: details.username,
|
|
345
|
+
emailAddress: details.emailAddress,
|
|
346
|
+
legalName: details.legalName),
|
|
347
|
+
inactiveLinkedAccountDetails: nil)
|
|
227
348
|
)
|
|
228
|
-
case .InactiveLinkedAccountDetails:
|
|
349
|
+
case .InactiveLinkedAccountDetails(let details):
|
|
229
350
|
return LinkedAccount(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
351
|
+
linkedAccountID: linkedAccountID,
|
|
352
|
+
service: service,
|
|
353
|
+
serviceUserID: serviceUserID,
|
|
354
|
+
details: .init(
|
|
355
|
+
activeLinkedAccountDetails: nil,
|
|
356
|
+
inactiveLinkedAccountDetails: .init(
|
|
357
|
+
state: details.state.rawValue))
|
|
358
|
+
)
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
extension Models.MerchantCounterparty {
|
|
364
|
+
var toLocation: MerchantLocation? {
|
|
365
|
+
if let location {
|
|
366
|
+
return .init(
|
|
367
|
+
countryCode: location.countryCode,
|
|
368
|
+
countrySubdivisionCode: location.countrySubdivisionCode,
|
|
369
|
+
localityName: location.localityName)
|
|
370
|
+
}
|
|
371
|
+
return nil
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
extension Models.Trade {
|
|
376
|
+
var toCounterparty: Counterparty {
|
|
377
|
+
switch counterparty {
|
|
378
|
+
case .MerchantCounterparty(let merchant):
|
|
379
|
+
return .init(
|
|
380
|
+
merchantCounterparty: .init(
|
|
381
|
+
kind: merchant.kind.rawValue,
|
|
382
|
+
name: merchant.name, logoURL: merchant.logoURL,
|
|
383
|
+
location: merchant.toLocation
|
|
384
|
+
),
|
|
385
|
+
userCounterparty: nil,
|
|
386
|
+
serviceCounterparty: nil
|
|
387
|
+
)
|
|
388
|
+
case .ServiceCounterparty(let service):
|
|
389
|
+
return .init(
|
|
390
|
+
merchantCounterparty: nil,
|
|
391
|
+
userCounterparty: nil,
|
|
392
|
+
serviceCounterparty: .init(
|
|
393
|
+
kind: service.kind.rawValue,
|
|
394
|
+
service: service.service.toService
|
|
395
|
+
)
|
|
396
|
+
)
|
|
397
|
+
case .UserCounterparty(let user):
|
|
398
|
+
return .init(
|
|
399
|
+
merchantCounterparty: nil,
|
|
400
|
+
userCounterparty: .init(
|
|
401
|
+
kind: user.kind.rawValue,
|
|
402
|
+
legalName: user.legalName,
|
|
403
|
+
avatarURL: user.avatarURL,
|
|
404
|
+
username: user.username
|
|
405
|
+
),
|
|
406
|
+
serviceCounterparty: nil
|
|
407
|
+
)
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
extension Models.TradeAsset {
|
|
413
|
+
var toAsset: TradeAsset {
|
|
414
|
+
switch self {
|
|
415
|
+
case .FiatAsset(let fiatAsset):
|
|
416
|
+
return .init(
|
|
417
|
+
fiatAsset: .init(
|
|
418
|
+
assetKind: fiatAsset.assetKind.rawValue,
|
|
419
|
+
serviceTradeID: fiatAsset.serviceTradeID,
|
|
420
|
+
serviceAccountID: fiatAsset.serviceAccountID,
|
|
421
|
+
currencyCode: fiatAsset.currencyCode,
|
|
422
|
+
amount: fiatAsset.amount,
|
|
423
|
+
linkedAccountID: fiatAsset.linkedAccountID,
|
|
424
|
+
service: fiatAsset.service.toService
|
|
425
|
+
),
|
|
426
|
+
marketTradeAsset: nil,
|
|
427
|
+
transportAsset: nil,
|
|
428
|
+
otherAsset: nil,
|
|
429
|
+
nothingAsset: nil
|
|
430
|
+
)
|
|
431
|
+
case .MarketTradeAsset(let marketAsset):
|
|
432
|
+
return .init(
|
|
433
|
+
fiatAsset: nil,
|
|
434
|
+
marketTradeAsset: .init(
|
|
435
|
+
assetKind: marketAsset.assetKind.rawValue,
|
|
436
|
+
serviceAccountID: marketAsset.serviceAccountID,
|
|
437
|
+
serviceAssetID: marketAsset.serviceAssetID,
|
|
438
|
+
symbol: marketAsset.symbol,
|
|
439
|
+
amount: marketAsset.amount,
|
|
440
|
+
serviceTradeID: marketAsset.serviceTradeID,
|
|
441
|
+
linkedAccountID: marketAsset.linkedAccountID,
|
|
442
|
+
name: marketAsset.name,
|
|
443
|
+
color: marketAsset.color,
|
|
444
|
+
logoURL: marketAsset.logoURL,
|
|
445
|
+
service: marketAsset.service.toService
|
|
446
|
+
),
|
|
447
|
+
transportAsset: nil,
|
|
448
|
+
otherAsset: nil,
|
|
449
|
+
nothingAsset: nil
|
|
450
|
+
)
|
|
451
|
+
case .TransportAsset(let transportAsset):
|
|
452
|
+
return .init(
|
|
453
|
+
fiatAsset: nil,
|
|
454
|
+
marketTradeAsset: nil,
|
|
455
|
+
transportAsset: .init(
|
|
456
|
+
assetKind: transportAsset.assetKind.rawValue,
|
|
457
|
+
serviceTradeID: transportAsset.serviceTradeID,
|
|
458
|
+
serviceAssetID: transportAsset.serviceAssetID,
|
|
459
|
+
name: transportAsset.name,
|
|
460
|
+
description: transportAsset.description,
|
|
461
|
+
imageURL: transportAsset.imageURL,
|
|
462
|
+
originCoordinates: .init(
|
|
463
|
+
latitude: transportAsset.originCoordinates.latitude,
|
|
464
|
+
longitude: transportAsset.originCoordinates.longitude
|
|
465
|
+
),
|
|
466
|
+
originAddress: .init(
|
|
467
|
+
value: transportAsset.originAddress.value),
|
|
468
|
+
destinationCoordinates: .init(
|
|
469
|
+
latitude: transportAsset.destinationCoordinates
|
|
470
|
+
.latitude,
|
|
471
|
+
longitude: transportAsset.destinationCoordinates
|
|
472
|
+
.longitude
|
|
473
|
+
),
|
|
474
|
+
destinationAddress: .init(
|
|
475
|
+
value: transportAsset.destinationAddress.value),
|
|
476
|
+
seats: transportAsset.seats,
|
|
477
|
+
linkedAccountID: transportAsset.linkedAccountID,
|
|
478
|
+
service: transportAsset.service.toService
|
|
479
|
+
),
|
|
480
|
+
otherAsset: nil,
|
|
481
|
+
nothingAsset: nil
|
|
482
|
+
)
|
|
483
|
+
case .OtherAsset(let otherAsset):
|
|
484
|
+
return .init(
|
|
485
|
+
fiatAsset: nil,
|
|
486
|
+
marketTradeAsset: nil,
|
|
487
|
+
transportAsset: nil,
|
|
488
|
+
otherAsset: .init(assetKind: otherAsset.assetKind.rawValue),
|
|
489
|
+
nothingAsset: nil
|
|
234
490
|
)
|
|
491
|
+
case .NothingAsset(let nothingAsset):
|
|
492
|
+
return .init(
|
|
493
|
+
fiatAsset: nil,
|
|
494
|
+
marketTradeAsset: nil,
|
|
495
|
+
transportAsset: nil,
|
|
496
|
+
otherAsset: nil,
|
|
497
|
+
nothingAsset: .init(assetKind: nothingAsset.assetKind.rawValue)
|
|
498
|
+
)
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
extension TradeQuoteRequest {
|
|
504
|
+
var toGained: Models.TradeAssetQuoteRequest {
|
|
505
|
+
get throws {
|
|
506
|
+
if let fiatAssetQuoteRequest = gained.fiatAssetQuoteRequest {
|
|
507
|
+
return Models.TradeAssetQuoteRequest.FiatAssetQuoteRequest(
|
|
508
|
+
.init(
|
|
509
|
+
assetKind: .fiat,
|
|
510
|
+
serviceAccountID: fiatAssetQuoteRequest
|
|
511
|
+
.serviceAccountID,
|
|
512
|
+
currencyCode: fiatAssetQuoteRequest.currencyCode,
|
|
513
|
+
amount: fiatAssetQuoteRequest.amount
|
|
514
|
+
)
|
|
515
|
+
)
|
|
516
|
+
} else if let marketAssetQuoteRequest = gained
|
|
517
|
+
.marketAssetQuoteRequest
|
|
518
|
+
{
|
|
519
|
+
return Models.TradeAssetQuoteRequest.MarketAssetQuoteRequest(
|
|
520
|
+
.init(
|
|
521
|
+
assetKind: .init(
|
|
522
|
+
rawValue: marketAssetQuoteRequest.assetKind)
|
|
523
|
+
?? .stock,
|
|
524
|
+
serviceAccountID: marketAssetQuoteRequest
|
|
525
|
+
.serviceAccountID,
|
|
526
|
+
serviceAssetID: marketAssetQuoteRequest.serviceAssetID,
|
|
527
|
+
symbol: marketAssetQuoteRequest.symbol,
|
|
528
|
+
amount: marketAssetQuoteRequest.amount
|
|
529
|
+
)
|
|
530
|
+
)
|
|
531
|
+
} else if gained.nothingAssetQuoteRequest != nil {
|
|
532
|
+
return Models.TradeAssetQuoteRequest.NothingAssetQuoteRequest(
|
|
533
|
+
.init(assetKind: .nothing)
|
|
534
|
+
)
|
|
535
|
+
} else if let transportAssetQuoteRequest = gained
|
|
536
|
+
.transportAssetQuoteRequest
|
|
537
|
+
{
|
|
538
|
+
return Models.TradeAssetQuoteRequest.TransportAssetQuoteRequest(
|
|
539
|
+
.init(
|
|
540
|
+
assetKind: .transport,
|
|
541
|
+
serviceAssetID: transportAssetQuoteRequest
|
|
542
|
+
.serviceAssetID,
|
|
543
|
+
originCoordinates: transportAssetQuoteRequest
|
|
544
|
+
.originCoordinates?.toCoordinates,
|
|
545
|
+
originAddress: transportAssetQuoteRequest.originAddress?
|
|
546
|
+
.toAddress,
|
|
547
|
+
destinationCoordinates: transportAssetQuoteRequest
|
|
548
|
+
.destinationCoordinates?
|
|
549
|
+
.toCoordinates,
|
|
550
|
+
destinationAddress: transportAssetQuoteRequest
|
|
551
|
+
.destinationAddress?.toAddress,
|
|
552
|
+
seats: transportAssetQuoteRequest.seats
|
|
553
|
+
)
|
|
554
|
+
)
|
|
555
|
+
} else {
|
|
556
|
+
throw RNClientError.badInitialization(
|
|
557
|
+
message:
|
|
558
|
+
"Internal Candle Error: corrupted trade quote request.")
|
|
559
|
+
}
|
|
235
560
|
}
|
|
236
561
|
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
extension Address {
|
|
565
|
+
var toAddress: Models.Address {
|
|
566
|
+
return .init(value: value)
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
extension Coordinates {
|
|
571
|
+
var toCoordinates: Models.Coordinates {
|
|
572
|
+
return .init(
|
|
573
|
+
latitude: latitude,
|
|
574
|
+
longitude: longitude
|
|
575
|
+
)
|
|
576
|
+
}
|
|
577
|
+
}
|
|
237
578
|
|
|
238
|
-
|
|
239
|
-
|
|
579
|
+
extension Service {
|
|
580
|
+
var toService: Models.Service {
|
|
581
|
+
switch self {
|
|
240
582
|
case .apple:
|
|
241
583
|
return .apple
|
|
242
584
|
case .cashApp:
|
|
@@ -400,3 +742,250 @@ final class HybridRNCandle: HybridRNCandleSpec {
|
|
|
400
742
|
}
|
|
401
743
|
}
|
|
402
744
|
}
|
|
745
|
+
|
|
746
|
+
extension Models.Service {
|
|
747
|
+
var toService: Service {
|
|
748
|
+
switch self {
|
|
749
|
+
case .apple:
|
|
750
|
+
return .apple
|
|
751
|
+
case .cashApp:
|
|
752
|
+
return .cashApp
|
|
753
|
+
case .sandbox:
|
|
754
|
+
return .sandbox
|
|
755
|
+
case .robinhood:
|
|
756
|
+
return .robinhood
|
|
757
|
+
case .uber:
|
|
758
|
+
return .uber
|
|
759
|
+
case .lyft:
|
|
760
|
+
return .lyft
|
|
761
|
+
case .venmo:
|
|
762
|
+
return .venmo
|
|
763
|
+
case .chime:
|
|
764
|
+
return .chime
|
|
765
|
+
case .paypal:
|
|
766
|
+
return .paypal
|
|
767
|
+
case .coinbase:
|
|
768
|
+
return .coinbase
|
|
769
|
+
case .discover:
|
|
770
|
+
return .discover
|
|
771
|
+
case .americanExpress:
|
|
772
|
+
return .americanExpress
|
|
773
|
+
case .jpmorganChase:
|
|
774
|
+
return .jpmorganChase
|
|
775
|
+
case .bankOfAmerica:
|
|
776
|
+
return .bankOfAmerica
|
|
777
|
+
case .capitalOne:
|
|
778
|
+
return .capitalOne
|
|
779
|
+
case .citibank:
|
|
780
|
+
return .citibank
|
|
781
|
+
case .vanguard:
|
|
782
|
+
return .vanguard
|
|
783
|
+
case .wellsFargo:
|
|
784
|
+
return .wellsFargo
|
|
785
|
+
case .charlesSchwab:
|
|
786
|
+
return .charlesSchwab
|
|
787
|
+
case .kalshi:
|
|
788
|
+
return .kalshi
|
|
789
|
+
case .experian:
|
|
790
|
+
return .experian
|
|
791
|
+
case .waymo:
|
|
792
|
+
return .waymo
|
|
793
|
+
case .revel:
|
|
794
|
+
return .revel
|
|
795
|
+
case .turo:
|
|
796
|
+
return .turo
|
|
797
|
+
case .getaround:
|
|
798
|
+
return .getaround
|
|
799
|
+
case .zipcar:
|
|
800
|
+
return .zipcar
|
|
801
|
+
case .airbnb:
|
|
802
|
+
return .airbnb
|
|
803
|
+
case .americanAirlines:
|
|
804
|
+
return .americanAirlines
|
|
805
|
+
case .delta:
|
|
806
|
+
return .delta
|
|
807
|
+
case .united:
|
|
808
|
+
return .united
|
|
809
|
+
case .jetblue:
|
|
810
|
+
return .jetblue
|
|
811
|
+
case .southwest:
|
|
812
|
+
return .southwest
|
|
813
|
+
case .hawaiian:
|
|
814
|
+
return .hawaiian
|
|
815
|
+
case .hotels:
|
|
816
|
+
return .hotels
|
|
817
|
+
case .geico:
|
|
818
|
+
return .geico
|
|
819
|
+
case .progressive:
|
|
820
|
+
return .progressive
|
|
821
|
+
case .aaa:
|
|
822
|
+
return .aaa
|
|
823
|
+
case .stateFarm:
|
|
824
|
+
return .stateFarm
|
|
825
|
+
case .hertz:
|
|
826
|
+
return .hertz
|
|
827
|
+
case .avis:
|
|
828
|
+
return .avis
|
|
829
|
+
case .tesla:
|
|
830
|
+
return .tesla
|
|
831
|
+
case .doordash:
|
|
832
|
+
return .doordash
|
|
833
|
+
case .uberEats:
|
|
834
|
+
return .uberEats
|
|
835
|
+
case .grubhub:
|
|
836
|
+
return .grubhub
|
|
837
|
+
case .resy:
|
|
838
|
+
return .resy
|
|
839
|
+
case .opentable:
|
|
840
|
+
return .opentable
|
|
841
|
+
case .starbucks:
|
|
842
|
+
return .starbucks
|
|
843
|
+
case .blueBottle:
|
|
844
|
+
return .blueBottle
|
|
845
|
+
case .costco:
|
|
846
|
+
return .costco
|
|
847
|
+
case .amazon:
|
|
848
|
+
return .amazon
|
|
849
|
+
case .walmart:
|
|
850
|
+
return .walmart
|
|
851
|
+
case .wholeFoods:
|
|
852
|
+
return .wholeFoods
|
|
853
|
+
case .mcdonalds:
|
|
854
|
+
return .mcdonalds
|
|
855
|
+
case .chipotle:
|
|
856
|
+
return .chipotle
|
|
857
|
+
case .sweetgreen:
|
|
858
|
+
return .sweetgreen
|
|
859
|
+
case .snapchat:
|
|
860
|
+
return .snapchat
|
|
861
|
+
case .x:
|
|
862
|
+
return .x
|
|
863
|
+
case .facebook:
|
|
864
|
+
return .facebook
|
|
865
|
+
case .instagram:
|
|
866
|
+
return .instagram
|
|
867
|
+
case .signal:
|
|
868
|
+
return .signal
|
|
869
|
+
case .whatsapp:
|
|
870
|
+
return .whatsapp
|
|
871
|
+
case .messenger:
|
|
872
|
+
return .messenger
|
|
873
|
+
case .linkedin:
|
|
874
|
+
return .linkedin
|
|
875
|
+
case .discord:
|
|
876
|
+
return .discord
|
|
877
|
+
case .messages:
|
|
878
|
+
return .messages
|
|
879
|
+
case .telegram:
|
|
880
|
+
return .telegram
|
|
881
|
+
case .reddit:
|
|
882
|
+
return .reddit
|
|
883
|
+
case .pinterest:
|
|
884
|
+
return .pinterest
|
|
885
|
+
case .newYorkTimes:
|
|
886
|
+
return .newYorkTimes
|
|
887
|
+
case .washingtonPost:
|
|
888
|
+
return .washingtonPost
|
|
889
|
+
case .wallStreetJournal:
|
|
890
|
+
return .wallStreetJournal
|
|
891
|
+
case .cnn:
|
|
892
|
+
return .cnn
|
|
893
|
+
case .yahoo:
|
|
894
|
+
return .yahoo
|
|
895
|
+
case .fox:
|
|
896
|
+
return .fox
|
|
897
|
+
case .perplexity:
|
|
898
|
+
return .perplexity
|
|
899
|
+
case .openai:
|
|
900
|
+
return .openai
|
|
901
|
+
case .polymarket:
|
|
902
|
+
return .polymarket
|
|
903
|
+
case .espn:
|
|
904
|
+
return .espn
|
|
905
|
+
case .youtube:
|
|
906
|
+
return .youtube
|
|
907
|
+
case .netflix:
|
|
908
|
+
return .netflix
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
extension AssetAccountKind {
|
|
914
|
+
var asCandleModel: Models.GetAssetAccounts.Input.Query.AssetKindPayload {
|
|
915
|
+
switch self {
|
|
916
|
+
case .fiat:
|
|
917
|
+
return .fiat
|
|
918
|
+
case .stock:
|
|
919
|
+
return .stock
|
|
920
|
+
case .crypto:
|
|
921
|
+
return .crypto
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
extension Candle.Components.Schemas.LegalAccountKind {
|
|
927
|
+
var toRNModel: LegalAccountKind {
|
|
928
|
+
switch self {
|
|
929
|
+
case .individual:
|
|
930
|
+
return .individual
|
|
931
|
+
case .joint:
|
|
932
|
+
return .joint
|
|
933
|
+
case .rothIra:
|
|
934
|
+
return .rothira
|
|
935
|
+
case .traditionalIra:
|
|
936
|
+
return .traditionalira
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
extension Candle.Components.Schemas.ACHAccountKind {
|
|
942
|
+
var toRNModel: ACHAccountKind {
|
|
943
|
+
switch self {
|
|
944
|
+
case .checking:
|
|
945
|
+
return .checking
|
|
946
|
+
case .savings:
|
|
947
|
+
return .savings
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
extension Models.Trade.StatePayload {
|
|
953
|
+
var toRNModel: TradeState {
|
|
954
|
+
switch self {
|
|
955
|
+
case .success:
|
|
956
|
+
return .success
|
|
957
|
+
case .failure:
|
|
958
|
+
return .failure
|
|
959
|
+
case .inProgress:
|
|
960
|
+
return .inprogress
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
extension TradeQuery {
|
|
966
|
+
|
|
967
|
+
var toGainedAssetKind:
|
|
968
|
+
Candle.Operations.GetLinkedAccountsTrades.Input.Query.GainedAssetKindPayload?
|
|
969
|
+
{
|
|
970
|
+
if let gainedAssetKind {
|
|
971
|
+
return .init(rawValue: gainedAssetKind)
|
|
972
|
+
}
|
|
973
|
+
return nil
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
var toLostAssetKind: Candle.Operations.GetLinkedAccountsTrades.Input.Query.LostAssetKindPayload? {
|
|
977
|
+
if let lostAssetKind {
|
|
978
|
+
return .init(rawValue: lostAssetKind)
|
|
979
|
+
}
|
|
980
|
+
return nil
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
var toCounterpartyKindPayload:
|
|
984
|
+
Candle.Operations.GetLinkedAccountsTrades.Input.Query.CounterpartyKindPayload?
|
|
985
|
+
{
|
|
986
|
+
if let counterpartyKind {
|
|
987
|
+
return .init(rawValue: counterpartyKind)
|
|
988
|
+
}
|
|
989
|
+
return nil
|
|
990
|
+
}
|
|
991
|
+
}
|