react-native-candle 0.1.18 → 0.1.20
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/RNCandle.swift +271 -89
- package/lib/commonjs/index.js +73 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +73 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +35 -14
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts +49 -2
- package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +35 -14
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/specs/RNCandle.nitro.d.ts +49 -2
- package/lib/typescript/module/src/specs/RNCandle.nitro.d.ts.map +1 -1
- package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Bridge.cpp +16 -8
- package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Bridge.hpp +167 -43
- package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Umbrella.hpp +30 -0
- package/nitrogen/generated/ios/c++/HybridRNCandleSpecSwift.hpp +58 -4
- package/nitrogen/generated/ios/swift/AssetAccountRef.swift +55 -0
- package/nitrogen/generated/ios/swift/ExecuteTradeRequest.swift +44 -0
- package/nitrogen/generated/ios/swift/FiatAssetRef.swift +75 -0
- package/nitrogen/generated/ios/swift/Func_void_AssetAccount.swift +44 -0
- package/nitrogen/generated/ios/swift/Func_void_LinkedAccount.swift +5 -5
- package/nitrogen/generated/ios/swift/HybridRNCandleSpec.swift +5 -2
- package/nitrogen/generated/ios/swift/HybridRNCandleSpec_cxx.swift +65 -5
- package/nitrogen/generated/ios/swift/LinkedAccountRef.swift +33 -0
- package/nitrogen/generated/ios/swift/MarketTradeAssetRef.swift +55 -0
- package/nitrogen/generated/ios/swift/NothingAssetRef.swift +33 -0
- package/nitrogen/generated/ios/swift/OtherAssetRef.swift +33 -0
- package/nitrogen/generated/ios/swift/TradeAssetRef.swift +176 -0
- package/nitrogen/generated/ios/swift/TradeRef.swift +44 -0
- package/nitrogen/generated/ios/swift/TransportAssetRef.swift +55 -0
- package/nitrogen/generated/shared/c++/AssetAccountRef.hpp +77 -0
- package/nitrogen/generated/shared/c++/ExecuteTradeRequest.hpp +73 -0
- package/nitrogen/generated/shared/c++/FiatAssetRef.hpp +78 -0
- package/nitrogen/generated/shared/c++/HybridRNCandleSpec.cpp +4 -1
- package/nitrogen/generated/shared/c++/HybridRNCandleSpec.hpp +17 -2
- package/nitrogen/generated/shared/c++/LinkedAccountRef.hpp +69 -0
- package/nitrogen/generated/shared/c++/MarketTradeAssetRef.hpp +77 -0
- package/nitrogen/generated/shared/c++/NothingAssetRef.hpp +69 -0
- package/nitrogen/generated/shared/c++/OtherAssetRef.hpp +69 -0
- package/nitrogen/generated/shared/c++/TradeAssetRef.hpp +99 -0
- package/nitrogen/generated/shared/c++/TradeRef.hpp +74 -0
- package/nitrogen/generated/shared/c++/TransportAssetRef.hpp +77 -0
- package/package.json +1 -1
- package/src/index.ts +131 -21
- package/src/specs/RNCandle.nitro.ts +59 -2
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// TradeAssetRef.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
// Forward declaration of `FiatAssetRef` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::rncandle { struct FiatAssetRef; }
|
|
23
|
+
// Forward declaration of `MarketTradeAssetRef` to properly resolve imports.
|
|
24
|
+
namespace margelo::nitro::rncandle { struct MarketTradeAssetRef; }
|
|
25
|
+
// Forward declaration of `TransportAssetRef` to properly resolve imports.
|
|
26
|
+
namespace margelo::nitro::rncandle { struct TransportAssetRef; }
|
|
27
|
+
// Forward declaration of `OtherAssetRef` to properly resolve imports.
|
|
28
|
+
namespace margelo::nitro::rncandle { struct OtherAssetRef; }
|
|
29
|
+
// Forward declaration of `NothingAssetRef` to properly resolve imports.
|
|
30
|
+
namespace margelo::nitro::rncandle { struct NothingAssetRef; }
|
|
31
|
+
|
|
32
|
+
#include <optional>
|
|
33
|
+
#include "FiatAssetRef.hpp"
|
|
34
|
+
#include "MarketTradeAssetRef.hpp"
|
|
35
|
+
#include "TransportAssetRef.hpp"
|
|
36
|
+
#include "OtherAssetRef.hpp"
|
|
37
|
+
#include "NothingAssetRef.hpp"
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro::rncandle {
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A struct which can be represented as a JavaScript object (TradeAssetRef).
|
|
43
|
+
*/
|
|
44
|
+
struct TradeAssetRef {
|
|
45
|
+
public:
|
|
46
|
+
std::optional<FiatAssetRef> fiatAssetRef SWIFT_PRIVATE;
|
|
47
|
+
std::optional<MarketTradeAssetRef> marketTradeAssetRef SWIFT_PRIVATE;
|
|
48
|
+
std::optional<TransportAssetRef> transportAssetRef SWIFT_PRIVATE;
|
|
49
|
+
std::optional<OtherAssetRef> otherAssetRef SWIFT_PRIVATE;
|
|
50
|
+
std::optional<NothingAssetRef> nothingAssetRef SWIFT_PRIVATE;
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
TradeAssetRef() = default;
|
|
54
|
+
explicit TradeAssetRef(std::optional<FiatAssetRef> fiatAssetRef, std::optional<MarketTradeAssetRef> marketTradeAssetRef, std::optional<TransportAssetRef> transportAssetRef, std::optional<OtherAssetRef> otherAssetRef, std::optional<NothingAssetRef> nothingAssetRef): fiatAssetRef(fiatAssetRef), marketTradeAssetRef(marketTradeAssetRef), transportAssetRef(transportAssetRef), otherAssetRef(otherAssetRef), nothingAssetRef(nothingAssetRef) {}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
} // namespace margelo::nitro::rncandle
|
|
58
|
+
|
|
59
|
+
namespace margelo::nitro {
|
|
60
|
+
|
|
61
|
+
using namespace margelo::nitro::rncandle;
|
|
62
|
+
|
|
63
|
+
// C++ TradeAssetRef <> JS TradeAssetRef (object)
|
|
64
|
+
template <>
|
|
65
|
+
struct JSIConverter<TradeAssetRef> final {
|
|
66
|
+
static inline TradeAssetRef fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
67
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
68
|
+
return TradeAssetRef(
|
|
69
|
+
JSIConverter<std::optional<FiatAssetRef>>::fromJSI(runtime, obj.getProperty(runtime, "fiatAssetRef")),
|
|
70
|
+
JSIConverter<std::optional<MarketTradeAssetRef>>::fromJSI(runtime, obj.getProperty(runtime, "marketTradeAssetRef")),
|
|
71
|
+
JSIConverter<std::optional<TransportAssetRef>>::fromJSI(runtime, obj.getProperty(runtime, "transportAssetRef")),
|
|
72
|
+
JSIConverter<std::optional<OtherAssetRef>>::fromJSI(runtime, obj.getProperty(runtime, "otherAssetRef")),
|
|
73
|
+
JSIConverter<std::optional<NothingAssetRef>>::fromJSI(runtime, obj.getProperty(runtime, "nothingAssetRef"))
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const TradeAssetRef& arg) {
|
|
77
|
+
jsi::Object obj(runtime);
|
|
78
|
+
obj.setProperty(runtime, "fiatAssetRef", JSIConverter<std::optional<FiatAssetRef>>::toJSI(runtime, arg.fiatAssetRef));
|
|
79
|
+
obj.setProperty(runtime, "marketTradeAssetRef", JSIConverter<std::optional<MarketTradeAssetRef>>::toJSI(runtime, arg.marketTradeAssetRef));
|
|
80
|
+
obj.setProperty(runtime, "transportAssetRef", JSIConverter<std::optional<TransportAssetRef>>::toJSI(runtime, arg.transportAssetRef));
|
|
81
|
+
obj.setProperty(runtime, "otherAssetRef", JSIConverter<std::optional<OtherAssetRef>>::toJSI(runtime, arg.otherAssetRef));
|
|
82
|
+
obj.setProperty(runtime, "nothingAssetRef", JSIConverter<std::optional<NothingAssetRef>>::toJSI(runtime, arg.nothingAssetRef));
|
|
83
|
+
return obj;
|
|
84
|
+
}
|
|
85
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
86
|
+
if (!value.isObject()) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
jsi::Object obj = value.getObject(runtime);
|
|
90
|
+
if (!JSIConverter<std::optional<FiatAssetRef>>::canConvert(runtime, obj.getProperty(runtime, "fiatAssetRef"))) return false;
|
|
91
|
+
if (!JSIConverter<std::optional<MarketTradeAssetRef>>::canConvert(runtime, obj.getProperty(runtime, "marketTradeAssetRef"))) return false;
|
|
92
|
+
if (!JSIConverter<std::optional<TransportAssetRef>>::canConvert(runtime, obj.getProperty(runtime, "transportAssetRef"))) return false;
|
|
93
|
+
if (!JSIConverter<std::optional<OtherAssetRef>>::canConvert(runtime, obj.getProperty(runtime, "otherAssetRef"))) return false;
|
|
94
|
+
if (!JSIConverter<std::optional<NothingAssetRef>>::canConvert(runtime, obj.getProperty(runtime, "nothingAssetRef"))) return false;
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// TradeRef.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
// Forward declaration of `TradeAssetRef` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::rncandle { struct TradeAssetRef; }
|
|
23
|
+
|
|
24
|
+
#include "TradeAssetRef.hpp"
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::rncandle {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A struct which can be represented as a JavaScript object (TradeRef).
|
|
30
|
+
*/
|
|
31
|
+
struct TradeRef {
|
|
32
|
+
public:
|
|
33
|
+
TradeAssetRef lost SWIFT_PRIVATE;
|
|
34
|
+
TradeAssetRef gained SWIFT_PRIVATE;
|
|
35
|
+
|
|
36
|
+
public:
|
|
37
|
+
TradeRef() = default;
|
|
38
|
+
explicit TradeRef(TradeAssetRef lost, TradeAssetRef gained): lost(lost), gained(gained) {}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
} // namespace margelo::nitro::rncandle
|
|
42
|
+
|
|
43
|
+
namespace margelo::nitro {
|
|
44
|
+
|
|
45
|
+
using namespace margelo::nitro::rncandle;
|
|
46
|
+
|
|
47
|
+
// C++ TradeRef <> JS TradeRef (object)
|
|
48
|
+
template <>
|
|
49
|
+
struct JSIConverter<TradeRef> final {
|
|
50
|
+
static inline TradeRef fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
51
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
52
|
+
return TradeRef(
|
|
53
|
+
JSIConverter<TradeAssetRef>::fromJSI(runtime, obj.getProperty(runtime, "lost")),
|
|
54
|
+
JSIConverter<TradeAssetRef>::fromJSI(runtime, obj.getProperty(runtime, "gained"))
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const TradeRef& arg) {
|
|
58
|
+
jsi::Object obj(runtime);
|
|
59
|
+
obj.setProperty(runtime, "lost", JSIConverter<TradeAssetRef>::toJSI(runtime, arg.lost));
|
|
60
|
+
obj.setProperty(runtime, "gained", JSIConverter<TradeAssetRef>::toJSI(runtime, arg.gained));
|
|
61
|
+
return obj;
|
|
62
|
+
}
|
|
63
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
64
|
+
if (!value.isObject()) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
jsi::Object obj = value.getObject(runtime);
|
|
68
|
+
if (!JSIConverter<TradeAssetRef>::canConvert(runtime, obj.getProperty(runtime, "lost"))) return false;
|
|
69
|
+
if (!JSIConverter<TradeAssetRef>::canConvert(runtime, obj.getProperty(runtime, "gained"))) return false;
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// TransportAssetRef.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 (TransportAssetRef).
|
|
29
|
+
*/
|
|
30
|
+
struct TransportAssetRef {
|
|
31
|
+
public:
|
|
32
|
+
std::string assetKind SWIFT_PRIVATE;
|
|
33
|
+
std::string serviceTradeID SWIFT_PRIVATE;
|
|
34
|
+
std::string linkedAccountID SWIFT_PRIVATE;
|
|
35
|
+
|
|
36
|
+
public:
|
|
37
|
+
TransportAssetRef() = default;
|
|
38
|
+
explicit TransportAssetRef(std::string assetKind, std::string serviceTradeID, std::string linkedAccountID): assetKind(assetKind), serviceTradeID(serviceTradeID), linkedAccountID(linkedAccountID) {}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
} // namespace margelo::nitro::rncandle
|
|
42
|
+
|
|
43
|
+
namespace margelo::nitro {
|
|
44
|
+
|
|
45
|
+
using namespace margelo::nitro::rncandle;
|
|
46
|
+
|
|
47
|
+
// C++ TransportAssetRef <> JS TransportAssetRef (object)
|
|
48
|
+
template <>
|
|
49
|
+
struct JSIConverter<TransportAssetRef> final {
|
|
50
|
+
static inline TransportAssetRef fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
51
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
52
|
+
return TransportAssetRef(
|
|
53
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "assetKind")),
|
|
54
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "serviceTradeID")),
|
|
55
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "linkedAccountID"))
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const TransportAssetRef& arg) {
|
|
59
|
+
jsi::Object obj(runtime);
|
|
60
|
+
obj.setProperty(runtime, "assetKind", JSIConverter<std::string>::toJSI(runtime, arg.assetKind));
|
|
61
|
+
obj.setProperty(runtime, "serviceTradeID", JSIConverter<std::string>::toJSI(runtime, arg.serviceTradeID));
|
|
62
|
+
obj.setProperty(runtime, "linkedAccountID", JSIConverter<std::string>::toJSI(runtime, arg.linkedAccountID));
|
|
63
|
+
return obj;
|
|
64
|
+
}
|
|
65
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
66
|
+
if (!value.isObject()) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
jsi::Object obj = value.getObject(runtime);
|
|
70
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "assetKind"))) return false;
|
|
71
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "serviceTradeID"))) return false;
|
|
72
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "linkedAccountID"))) return false;
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
} // namespace margelo::nitro
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NitroModules } from "react-native-nitro-modules";
|
|
2
2
|
import type {
|
|
3
3
|
AppUser,
|
|
4
|
-
AssetAccount as
|
|
4
|
+
AssetAccount as InternalAssetAccount,
|
|
5
5
|
AssetAccountQuery,
|
|
6
6
|
FiatAsset,
|
|
7
7
|
FiatAssetQuoteRequest,
|
|
@@ -17,7 +17,7 @@ import type {
|
|
|
17
17
|
Service,
|
|
18
18
|
TradeAsset as InternalTradeAsset,
|
|
19
19
|
TradeAssetQuoteRequest,
|
|
20
|
-
TradeQuery,
|
|
20
|
+
TradeQuery as InternalTradeQuery,
|
|
21
21
|
TransportAsset,
|
|
22
22
|
TransportAssetQuoteRequest,
|
|
23
23
|
LegalAccountKind,
|
|
@@ -29,6 +29,15 @@ import type {
|
|
|
29
29
|
ServiceCounterparty,
|
|
30
30
|
Counterparty as InternalCounterparty,
|
|
31
31
|
ActiveLinkedAccountDetails,
|
|
32
|
+
ExecuteTradeRequest,
|
|
33
|
+
AssetAccountRef,
|
|
34
|
+
LinkedAccountRef,
|
|
35
|
+
NothingAssetRef,
|
|
36
|
+
TransportAssetRef,
|
|
37
|
+
OtherAssetRef,
|
|
38
|
+
FiatAssetRef,
|
|
39
|
+
MarketTradeAssetRef,
|
|
40
|
+
TradeAssetRef as InternalTradeAssetRef,
|
|
32
41
|
} from "./specs/RNCandle.nitro";
|
|
33
42
|
|
|
34
43
|
export class CandleClient {
|
|
@@ -105,8 +114,12 @@ export class CandleClient {
|
|
|
105
114
|
});
|
|
106
115
|
}
|
|
107
116
|
|
|
108
|
-
public async
|
|
109
|
-
|
|
117
|
+
public async getLinkedAccount(ref: LinkedAccountRef): Promise<LinkedAccount> {
|
|
118
|
+
return this.candle.getLinkedAccount(ref);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public async unlinkAccount(path: LinkedAccountRef): Promise<void> {
|
|
122
|
+
await this.candle.unlinkAccount(path);
|
|
110
123
|
}
|
|
111
124
|
|
|
112
125
|
public async deleteUser(): Promise<void> {
|
|
@@ -117,6 +130,17 @@ export class CandleClient {
|
|
|
117
130
|
return this.candle.getAvailableTools();
|
|
118
131
|
}
|
|
119
132
|
|
|
133
|
+
public async executeTrade(request: ExecuteTradeRequest): Promise<Trade> {
|
|
134
|
+
const result = await this.candle.executeTrade(request);
|
|
135
|
+
return {
|
|
136
|
+
dateTime: result.dateTime,
|
|
137
|
+
state: result.state,
|
|
138
|
+
counterparty: this.convertToCounterparty(result.counterparty),
|
|
139
|
+
lost: this.convertTradeAsset(result.lost),
|
|
140
|
+
gained: this.convertTradeAsset(result.gained),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
120
144
|
public async executeTool(tool: {
|
|
121
145
|
name: string;
|
|
122
146
|
arguments: string;
|
|
@@ -131,21 +155,12 @@ export class CandleClient {
|
|
|
131
155
|
return accounts.map((account) => this.convertToAssetAccount(account));
|
|
132
156
|
}
|
|
133
157
|
|
|
134
|
-
public async
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
): Promise<
|
|
141
|
-
{
|
|
142
|
-
dateTime: string;
|
|
143
|
-
state: TradeState;
|
|
144
|
-
counterparty: Counterparty;
|
|
145
|
-
lost: TradeAsset;
|
|
146
|
-
gained: TradeAsset;
|
|
147
|
-
}[]
|
|
148
|
-
> {
|
|
158
|
+
public async getAssetAccount(ref: AssetAccountRef): Promise<AssetAccount> {
|
|
159
|
+
const account = await this.candle.getAssetAccount(ref);
|
|
160
|
+
return this.convertToAssetAccount(account);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
public async getTrades(query: TradeQuery = {}): Promise<Trade[]> {
|
|
149
164
|
const trades = await this.candle.getTrades(query);
|
|
150
165
|
return trades.map(({ dateTime, counterparty, gained, lost, state }) => ({
|
|
151
166
|
dateTime,
|
|
@@ -156,6 +171,23 @@ export class CandleClient {
|
|
|
156
171
|
}));
|
|
157
172
|
}
|
|
158
173
|
|
|
174
|
+
public async getTrade(input: {
|
|
175
|
+
lost: TradeAssetRef;
|
|
176
|
+
gained: TradeAssetRef;
|
|
177
|
+
}): Promise<Trade> {
|
|
178
|
+
const trade = await this.candle.getTrade({
|
|
179
|
+
lost: this.convertTradeAssetRef(input.lost),
|
|
180
|
+
gained: this.convertTradeAssetRef(input.gained),
|
|
181
|
+
});
|
|
182
|
+
return {
|
|
183
|
+
dateTime: trade.dateTime,
|
|
184
|
+
state: trade.state,
|
|
185
|
+
counterparty: this.convertToCounterparty(trade.counterparty),
|
|
186
|
+
lost: this.convertTradeAsset(trade.lost),
|
|
187
|
+
gained: this.convertTradeAsset(trade.gained),
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
159
191
|
public async getTradeQuotes(request: {
|
|
160
192
|
linkedAccountIDs?: string;
|
|
161
193
|
gained:
|
|
@@ -202,6 +234,50 @@ export class CandleClient {
|
|
|
202
234
|
});
|
|
203
235
|
}
|
|
204
236
|
|
|
237
|
+
private convertTradeAssetRef(
|
|
238
|
+
tradeAssetRef: TradeAssetRef
|
|
239
|
+
): InternalTradeAssetRef {
|
|
240
|
+
switch (tradeAssetRef.assetKind) {
|
|
241
|
+
case "fiat":
|
|
242
|
+
return {
|
|
243
|
+
fiatAssetRef: {
|
|
244
|
+
assetKind: "fiat",
|
|
245
|
+
linkedAccountID: tradeAssetRef.linkedAccountID,
|
|
246
|
+
serviceTradeID: tradeAssetRef.serviceTradeID,
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
case "stock":
|
|
250
|
+
case "crypto":
|
|
251
|
+
return {
|
|
252
|
+
marketTradeAssetRef: {
|
|
253
|
+
assetKind: tradeAssetRef.assetKind,
|
|
254
|
+
linkedAccountID: tradeAssetRef.linkedAccountID,
|
|
255
|
+
serviceTradeID: tradeAssetRef.serviceTradeID,
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
case "transport":
|
|
259
|
+
return {
|
|
260
|
+
transportAssetRef: {
|
|
261
|
+
assetKind: "transport",
|
|
262
|
+
linkedAccountID: tradeAssetRef.linkedAccountID,
|
|
263
|
+
serviceTradeID: tradeAssetRef.serviceTradeID,
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
case "other":
|
|
267
|
+
return {
|
|
268
|
+
otherAssetRef: {
|
|
269
|
+
assetKind: "other",
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
case "nothing":
|
|
273
|
+
return {
|
|
274
|
+
nothingAssetRef: {
|
|
275
|
+
assetKind: "nothing",
|
|
276
|
+
},
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
205
281
|
private convertTradeAsset(tradeAsset: InternalTradeAsset): TradeAsset {
|
|
206
282
|
if (tradeAsset.fiatAsset !== undefined) {
|
|
207
283
|
return {
|
|
@@ -250,7 +326,7 @@ export class CandleClient {
|
|
|
250
326
|
}
|
|
251
327
|
}
|
|
252
328
|
|
|
253
|
-
private convertToAssetAccount(account:
|
|
329
|
+
private convertToAssetAccount(account: InternalAssetAccount): AssetAccount {
|
|
254
330
|
const { legalAccountKind, nickname } = account;
|
|
255
331
|
const { fiatAccountDetails, marketAccountDetails } = account.details;
|
|
256
332
|
|
|
@@ -298,6 +374,12 @@ type Counterparty =
|
|
|
298
374
|
kind: "service";
|
|
299
375
|
} & ServiceCounterparty);
|
|
300
376
|
|
|
377
|
+
type TradeQuery = {
|
|
378
|
+
gainedAssetKind?: TradeQueryAssetKind;
|
|
379
|
+
lostAssetKind?: TradeQueryAssetKind;
|
|
380
|
+
counterpartyKind?: "merchant" | "user" | "service";
|
|
381
|
+
} & InternalTradeQuery;
|
|
382
|
+
|
|
301
383
|
type TradeQueryAssetKind =
|
|
302
384
|
| "fiat"
|
|
303
385
|
| "stock"
|
|
@@ -328,4 +410,32 @@ type AssetAccount = {
|
|
|
328
410
|
};
|
|
329
411
|
};
|
|
330
412
|
|
|
331
|
-
|
|
413
|
+
type Trade = {
|
|
414
|
+
dateTime: string;
|
|
415
|
+
state: TradeState;
|
|
416
|
+
counterparty: Counterparty;
|
|
417
|
+
lost: TradeAsset;
|
|
418
|
+
gained: TradeAsset;
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
type TradeAssetRef =
|
|
422
|
+
| ({ assetKind: "transport" } & TransportAssetRef)
|
|
423
|
+
| ({ assetKind: "nothing" } & NothingAssetRef)
|
|
424
|
+
| ({ assetKind: "other" } & OtherAssetRef)
|
|
425
|
+
| ({ assetKind: "fiat" } & FiatAssetRef)
|
|
426
|
+
| ({ assetKind: "stock" | "crypto" } & MarketTradeAssetRef);
|
|
427
|
+
|
|
428
|
+
export type {
|
|
429
|
+
LinkedAccountRef,
|
|
430
|
+
AssetAccountRef,
|
|
431
|
+
TradeAssetRef,
|
|
432
|
+
LinkedAccount,
|
|
433
|
+
AppUser,
|
|
434
|
+
Service,
|
|
435
|
+
TradeState,
|
|
436
|
+
TradeAsset,
|
|
437
|
+
Trade,
|
|
438
|
+
TradeQuery,
|
|
439
|
+
Counterparty,
|
|
440
|
+
AssetAccount,
|
|
441
|
+
};
|
|
@@ -218,6 +218,11 @@ export type TradeQuoteRequest = {
|
|
|
218
218
|
gained: TradeAssetQuoteRequest;
|
|
219
219
|
};
|
|
220
220
|
|
|
221
|
+
export type ExecuteTradeRequest = {
|
|
222
|
+
linkedAccountID: string;
|
|
223
|
+
context: string;
|
|
224
|
+
};
|
|
225
|
+
|
|
221
226
|
export type TradeQuote = {
|
|
222
227
|
lost: TradeAsset;
|
|
223
228
|
gained: TradeAsset;
|
|
@@ -339,6 +344,55 @@ export type ToolCall = {
|
|
|
339
344
|
arguments: string;
|
|
340
345
|
};
|
|
341
346
|
|
|
347
|
+
export type LinkedAccountRef = {
|
|
348
|
+
linkedAccountID: string;
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
export type AssetAccountRef = {
|
|
352
|
+
linkedAccountID: string;
|
|
353
|
+
assetKind: string; // "fiat" | "stock" | "crypto"
|
|
354
|
+
serviceAccountID: string;
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
export type FiatAssetRef = {
|
|
358
|
+
assetKind: string; // fiat
|
|
359
|
+
serviceTradeID?: string;
|
|
360
|
+
linkedAccountID: string;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
export type MarketTradeAssetRef = {
|
|
364
|
+
assetKind: string; // "stock" | "crypto"
|
|
365
|
+
serviceTradeID: string;
|
|
366
|
+
linkedAccountID: string;
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
export type TransportAssetRef = {
|
|
370
|
+
assetKind: string; // "transport"
|
|
371
|
+
serviceTradeID: string;
|
|
372
|
+
linkedAccountID: string;
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
export type OtherAssetRef = {
|
|
376
|
+
assetKind: string; // "other"
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
export type NothingAssetRef = {
|
|
380
|
+
assetKind: string; // "nothing"
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
export type TradeAssetRef = {
|
|
384
|
+
fiatAssetRef?: FiatAssetRef;
|
|
385
|
+
marketTradeAssetRef?: MarketTradeAssetRef;
|
|
386
|
+
transportAssetRef?: TransportAssetRef;
|
|
387
|
+
otherAssetRef?: OtherAssetRef;
|
|
388
|
+
nothingAssetRef?: NothingAssetRef;
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
export type TradeRef = {
|
|
392
|
+
lost: TradeAssetRef;
|
|
393
|
+
gained: TradeAssetRef;
|
|
394
|
+
};
|
|
395
|
+
|
|
342
396
|
export interface RNCandle extends HybridObject<{ ios: "swift" }> {
|
|
343
397
|
candleLinkSheet(
|
|
344
398
|
isPresented: boolean,
|
|
@@ -352,11 +406,14 @@ export interface RNCandle extends HybridObject<{ ios: "swift" }> {
|
|
|
352
406
|
): void;
|
|
353
407
|
initialize(appUser: AppUser): void;
|
|
354
408
|
getLinkedAccounts(): Promise<LinkedAccount[]>;
|
|
355
|
-
|
|
409
|
+
getLinkedAccount(ref: LinkedAccountRef): Promise<LinkedAccount>;
|
|
410
|
+
unlinkAccount(ref: LinkedAccountRef): Promise<void>;
|
|
356
411
|
getAssetAccounts(query: AssetAccountQuery): Promise<AssetAccount[]>;
|
|
412
|
+
getAssetAccount(ref: AssetAccountRef): Promise<AssetAccount>;
|
|
357
413
|
getTrades(query: TradeQuery): Promise<Trade[]>;
|
|
414
|
+
getTrade(ref: TradeRef): Promise<Trade>;
|
|
358
415
|
getTradeQuotes(request: TradeQuoteRequest): Promise<TradeQuote[]>;
|
|
359
|
-
|
|
416
|
+
executeTrade(request: ExecuteTradeRequest): Promise<Trade>;
|
|
360
417
|
deleteUser(): Promise<void>;
|
|
361
418
|
// FIXME: The return type should be a more specific type based on the actual tool calls available.
|
|
362
419
|
getAvailableTools(): Promise<Array<AnyMap>>;
|