react-native-nitro-ark 0.0.107 → 0.0.109
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/cpp/NitroArk.hpp +132 -0
- package/cpp/generated/ark_cxx.h +86 -0
- package/lib/module/index.js +56 -5
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NitroArk.nitro.d.ts +42 -0
- package/lib/typescript/src/NitroArk.nitro.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +18 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/nitrogen/generated/shared/c++/ExitBlockRefResult.hpp +87 -0
- package/nitrogen/generated/shared/c++/ExitProgressStatusResult.hpp +8 -2
- package/nitrogen/generated/shared/c++/ExitStateDetailsResult.hpp +126 -0
- package/nitrogen/generated/shared/c++/ExitStatusResult.hpp +12 -1
- package/nitrogen/generated/shared/c++/ExitTxOriginResult.hpp +98 -0
- package/nitrogen/generated/shared/c++/ExitTxResult.hpp +89 -0
- package/nitrogen/generated/shared/c++/ExitTxStatusResult.hpp +114 -0
- package/nitrogen/generated/shared/c++/ExitVtxoResult.hpp +12 -2
- package/nitrogen/generated/shared/c++/HybridNitroArkSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridNitroArkSpec.hpp +2 -0
- package/package.json +1 -1
- package/src/NitroArk.nitro.ts +47 -0
- package/src/index.tsx +67 -7
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ExitTxStatusResult.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 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
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
// Forward declaration of `ExitTxOriginResult` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::nitroark { struct ExitTxOriginResult; }
|
|
33
|
+
// Forward declaration of `ExitBlockRefResult` to properly resolve imports.
|
|
34
|
+
namespace margelo::nitro::nitroark { struct ExitBlockRefResult; }
|
|
35
|
+
|
|
36
|
+
#include <string>
|
|
37
|
+
#include <vector>
|
|
38
|
+
#include <optional>
|
|
39
|
+
#include "ExitTxOriginResult.hpp"
|
|
40
|
+
#include "ExitBlockRefResult.hpp"
|
|
41
|
+
|
|
42
|
+
namespace margelo::nitro::nitroark {
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A struct which can be represented as a JavaScript object (ExitTxStatusResult).
|
|
46
|
+
*/
|
|
47
|
+
struct ExitTxStatusResult final {
|
|
48
|
+
public:
|
|
49
|
+
std::string kind SWIFT_PRIVATE;
|
|
50
|
+
std::optional<std::vector<std::string>> txids SWIFT_PRIVATE;
|
|
51
|
+
std::optional<double> min_fee_rate_sat_per_kvb SWIFT_PRIVATE;
|
|
52
|
+
std::optional<double> min_fee_sat SWIFT_PRIVATE;
|
|
53
|
+
std::optional<std::string> child_txid SWIFT_PRIVATE;
|
|
54
|
+
std::optional<ExitTxOriginResult> origin SWIFT_PRIVATE;
|
|
55
|
+
std::optional<ExitBlockRefResult> block SWIFT_PRIVATE;
|
|
56
|
+
|
|
57
|
+
public:
|
|
58
|
+
ExitTxStatusResult() = default;
|
|
59
|
+
explicit ExitTxStatusResult(std::string kind, std::optional<std::vector<std::string>> txids, std::optional<double> min_fee_rate_sat_per_kvb, std::optional<double> min_fee_sat, std::optional<std::string> child_txid, std::optional<ExitTxOriginResult> origin, std::optional<ExitBlockRefResult> block): kind(kind), txids(txids), min_fee_rate_sat_per_kvb(min_fee_rate_sat_per_kvb), min_fee_sat(min_fee_sat), child_txid(child_txid), origin(origin), block(block) {}
|
|
60
|
+
|
|
61
|
+
public:
|
|
62
|
+
friend bool operator==(const ExitTxStatusResult& lhs, const ExitTxStatusResult& rhs) = default;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
} // namespace margelo::nitro::nitroark
|
|
66
|
+
|
|
67
|
+
namespace margelo::nitro {
|
|
68
|
+
|
|
69
|
+
// C++ ExitTxStatusResult <> JS ExitTxStatusResult (object)
|
|
70
|
+
template <>
|
|
71
|
+
struct JSIConverter<margelo::nitro::nitroark::ExitTxStatusResult> final {
|
|
72
|
+
static inline margelo::nitro::nitroark::ExitTxStatusResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
73
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
74
|
+
return margelo::nitro::nitroark::ExitTxStatusResult(
|
|
75
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "kind"))),
|
|
76
|
+
JSIConverter<std::optional<std::vector<std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "txids"))),
|
|
77
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "min_fee_rate_sat_per_kvb"))),
|
|
78
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "min_fee_sat"))),
|
|
79
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "child_txid"))),
|
|
80
|
+
JSIConverter<std::optional<margelo::nitro::nitroark::ExitTxOriginResult>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "origin"))),
|
|
81
|
+
JSIConverter<std::optional<margelo::nitro::nitroark::ExitBlockRefResult>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "block")))
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroark::ExitTxStatusResult& arg) {
|
|
85
|
+
jsi::Object obj(runtime);
|
|
86
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "kind"), JSIConverter<std::string>::toJSI(runtime, arg.kind));
|
|
87
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "txids"), JSIConverter<std::optional<std::vector<std::string>>>::toJSI(runtime, arg.txids));
|
|
88
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "min_fee_rate_sat_per_kvb"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.min_fee_rate_sat_per_kvb));
|
|
89
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "min_fee_sat"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.min_fee_sat));
|
|
90
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "child_txid"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.child_txid));
|
|
91
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "origin"), JSIConverter<std::optional<margelo::nitro::nitroark::ExitTxOriginResult>>::toJSI(runtime, arg.origin));
|
|
92
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "block"), JSIConverter<std::optional<margelo::nitro::nitroark::ExitBlockRefResult>>::toJSI(runtime, arg.block));
|
|
93
|
+
return obj;
|
|
94
|
+
}
|
|
95
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
96
|
+
if (!value.isObject()) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
jsi::Object obj = value.getObject(runtime);
|
|
100
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "kind")))) return false;
|
|
104
|
+
if (!JSIConverter<std::optional<std::vector<std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "txids")))) return false;
|
|
105
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "min_fee_rate_sat_per_kvb")))) return false;
|
|
106
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "min_fee_sat")))) return false;
|
|
107
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "child_txid")))) return false;
|
|
108
|
+
if (!JSIConverter<std::optional<margelo::nitro::nitroark::ExitTxOriginResult>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "origin")))) return false;
|
|
109
|
+
if (!JSIConverter<std::optional<margelo::nitro::nitroark::ExitBlockRefResult>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "block")))) return false;
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
} // namespace margelo::nitro
|
|
@@ -28,9 +28,11 @@
|
|
|
28
28
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
29
|
#endif
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
// Forward declaration of `ExitStateDetailsResult` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::nitroark { struct ExitStateDetailsResult; }
|
|
32
33
|
|
|
33
34
|
#include <string>
|
|
35
|
+
#include "ExitStateDetailsResult.hpp"
|
|
34
36
|
#include <vector>
|
|
35
37
|
|
|
36
38
|
namespace margelo::nitro::nitroark {
|
|
@@ -43,14 +45,16 @@ namespace margelo::nitro::nitroark {
|
|
|
43
45
|
std::string vtxo_id SWIFT_PRIVATE;
|
|
44
46
|
double amount_sat SWIFT_PRIVATE;
|
|
45
47
|
std::string state SWIFT_PRIVATE;
|
|
48
|
+
ExitStateDetailsResult state_details SWIFT_PRIVATE;
|
|
46
49
|
std::vector<std::string> history SWIFT_PRIVATE;
|
|
50
|
+
std::vector<ExitStateDetailsResult> history_details SWIFT_PRIVATE;
|
|
47
51
|
std::vector<std::string> txids SWIFT_PRIVATE;
|
|
48
52
|
bool is_claimable SWIFT_PRIVATE;
|
|
49
53
|
bool is_initialized SWIFT_PRIVATE;
|
|
50
54
|
|
|
51
55
|
public:
|
|
52
56
|
ExitVtxoResult() = default;
|
|
53
|
-
explicit ExitVtxoResult(std::string vtxo_id, double amount_sat, std::string state, std::vector<std::string> history, std::vector<std::string> txids, bool is_claimable, bool is_initialized): vtxo_id(vtxo_id), amount_sat(amount_sat), state(state), history(history), txids(txids), is_claimable(is_claimable), is_initialized(is_initialized) {}
|
|
57
|
+
explicit ExitVtxoResult(std::string vtxo_id, double amount_sat, std::string state, ExitStateDetailsResult state_details, std::vector<std::string> history, std::vector<ExitStateDetailsResult> history_details, std::vector<std::string> txids, bool is_claimable, bool is_initialized): vtxo_id(vtxo_id), amount_sat(amount_sat), state(state), state_details(state_details), history(history), history_details(history_details), txids(txids), is_claimable(is_claimable), is_initialized(is_initialized) {}
|
|
54
58
|
|
|
55
59
|
public:
|
|
56
60
|
friend bool operator==(const ExitVtxoResult& lhs, const ExitVtxoResult& rhs) = default;
|
|
@@ -69,7 +73,9 @@ namespace margelo::nitro {
|
|
|
69
73
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "vtxo_id"))),
|
|
70
74
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "amount_sat"))),
|
|
71
75
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "state"))),
|
|
76
|
+
JSIConverter<margelo::nitro::nitroark::ExitStateDetailsResult>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "state_details"))),
|
|
72
77
|
JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "history"))),
|
|
78
|
+
JSIConverter<std::vector<margelo::nitro::nitroark::ExitStateDetailsResult>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "history_details"))),
|
|
73
79
|
JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "txids"))),
|
|
74
80
|
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "is_claimable"))),
|
|
75
81
|
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "is_initialized")))
|
|
@@ -80,7 +86,9 @@ namespace margelo::nitro {
|
|
|
80
86
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "vtxo_id"), JSIConverter<std::string>::toJSI(runtime, arg.vtxo_id));
|
|
81
87
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "amount_sat"), JSIConverter<double>::toJSI(runtime, arg.amount_sat));
|
|
82
88
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "state"), JSIConverter<std::string>::toJSI(runtime, arg.state));
|
|
89
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "state_details"), JSIConverter<margelo::nitro::nitroark::ExitStateDetailsResult>::toJSI(runtime, arg.state_details));
|
|
83
90
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "history"), JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.history));
|
|
91
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "history_details"), JSIConverter<std::vector<margelo::nitro::nitroark::ExitStateDetailsResult>>::toJSI(runtime, arg.history_details));
|
|
84
92
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "txids"), JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.txids));
|
|
85
93
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "is_claimable"), JSIConverter<bool>::toJSI(runtime, arg.is_claimable));
|
|
86
94
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "is_initialized"), JSIConverter<bool>::toJSI(runtime, arg.is_initialized));
|
|
@@ -97,7 +105,9 @@ namespace margelo::nitro {
|
|
|
97
105
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "vtxo_id")))) return false;
|
|
98
106
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "amount_sat")))) return false;
|
|
99
107
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "state")))) return false;
|
|
108
|
+
if (!JSIConverter<margelo::nitro::nitroark::ExitStateDetailsResult>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "state_details")))) return false;
|
|
100
109
|
if (!JSIConverter<std::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "history")))) return false;
|
|
110
|
+
if (!JSIConverter<std::vector<margelo::nitro::nitroark::ExitStateDetailsResult>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "history_details")))) return false;
|
|
101
111
|
if (!JSIConverter<std::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "txids")))) return false;
|
|
102
112
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "is_claimable")))) return false;
|
|
103
113
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "is_initialized")))) return false;
|
|
@@ -39,6 +39,8 @@ namespace margelo::nitro::nitroark {
|
|
|
39
39
|
prototype.registerHybridMethod("pendingExitTotal", &HybridNitroArkSpec::pendingExitTotal);
|
|
40
40
|
prototype.registerHybridMethod("allClaimableAtHeight", &HybridNitroArkSpec::allClaimableAtHeight);
|
|
41
41
|
prototype.registerHybridMethod("drainExits", &HybridNitroArkSpec::drainExits);
|
|
42
|
+
prototype.registerHybridMethod("extractTransaction", &HybridNitroArkSpec::extractTransaction);
|
|
43
|
+
prototype.registerHybridMethod("broadcastTransaction", &HybridNitroArkSpec::broadcastTransaction);
|
|
42
44
|
prototype.registerHybridMethod("syncPendingRounds", &HybridNitroArkSpec::syncPendingRounds);
|
|
43
45
|
prototype.registerHybridMethod("getArkInfo", &HybridNitroArkSpec::getArkInfo);
|
|
44
46
|
prototype.registerHybridMethod("offchainBalance", &HybridNitroArkSpec::offchainBalance);
|
|
@@ -145,6 +145,8 @@ namespace margelo::nitro::nitroark {
|
|
|
145
145
|
virtual std::shared_ptr<Promise<double>> pendingExitTotal() = 0;
|
|
146
146
|
virtual std::shared_ptr<Promise<std::optional<double>>> allClaimableAtHeight() = 0;
|
|
147
147
|
virtual std::shared_ptr<Promise<std::string>> drainExits(const std::vector<std::string>& vtxoIds, const std::string& destinationAddress, std::optional<double> feeRateSatPerKvb) = 0;
|
|
148
|
+
virtual std::shared_ptr<Promise<std::string>> extractTransaction(const std::string& psbt) = 0;
|
|
149
|
+
virtual std::shared_ptr<Promise<std::string>> broadcastTransaction(const std::string& txHex) = 0;
|
|
148
150
|
virtual std::shared_ptr<Promise<void>> syncPendingRounds() = 0;
|
|
149
151
|
virtual std::shared_ptr<Promise<BarkArkInfo>> getArkInfo() = 0;
|
|
150
152
|
virtual std::shared_ptr<Promise<OffchainBalanceResult>> offchainBalance() = 0;
|
package/package.json
CHANGED
package/src/NitroArk.nitro.ts
CHANGED
|
@@ -83,9 +83,50 @@ export interface BarkFeeEstimate {
|
|
|
83
83
|
vtxos_spent: string[];
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
export interface ExitBlockRefResult {
|
|
87
|
+
height: number;
|
|
88
|
+
hash: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface ExitTxOriginResult {
|
|
92
|
+
kind: string;
|
|
93
|
+
confirmed_in?: ExitBlockRefResult;
|
|
94
|
+
fee_rate_sat_per_kvb?: number;
|
|
95
|
+
total_fee_sat?: number;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface ExitTxStatusResult {
|
|
99
|
+
kind: string;
|
|
100
|
+
txids?: string[];
|
|
101
|
+
min_fee_rate_sat_per_kvb?: number;
|
|
102
|
+
min_fee_sat?: number;
|
|
103
|
+
child_txid?: string;
|
|
104
|
+
origin?: ExitTxOriginResult;
|
|
105
|
+
block?: ExitBlockRefResult;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface ExitTxResult {
|
|
109
|
+
txid: string;
|
|
110
|
+
status: ExitTxStatusResult;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface ExitStateDetailsResult {
|
|
114
|
+
kind: string;
|
|
115
|
+
tip_height: number;
|
|
116
|
+
transactions?: ExitTxResult[];
|
|
117
|
+
confirmed_block?: ExitBlockRefResult;
|
|
118
|
+
claimable_height?: number;
|
|
119
|
+
claimable_since?: ExitBlockRefResult;
|
|
120
|
+
last_scanned_block?: ExitBlockRefResult;
|
|
121
|
+
claim_txid?: string;
|
|
122
|
+
txid?: string;
|
|
123
|
+
block?: ExitBlockRefResult;
|
|
124
|
+
}
|
|
125
|
+
|
|
86
126
|
export interface ExitProgressStatusResult {
|
|
87
127
|
vtxo_id: string;
|
|
88
128
|
state: string;
|
|
129
|
+
state_details: ExitStateDetailsResult;
|
|
89
130
|
error?: string;
|
|
90
131
|
}
|
|
91
132
|
|
|
@@ -93,7 +134,9 @@ export interface ExitVtxoResult {
|
|
|
93
134
|
vtxo_id: string;
|
|
94
135
|
amount_sat: number;
|
|
95
136
|
state: string;
|
|
137
|
+
state_details: ExitStateDetailsResult;
|
|
96
138
|
history: string[];
|
|
139
|
+
history_details: ExitStateDetailsResult[];
|
|
97
140
|
txids: string[];
|
|
98
141
|
is_claimable: boolean;
|
|
99
142
|
is_initialized: boolean;
|
|
@@ -111,7 +154,9 @@ export interface ExitTransactionPackageResult {
|
|
|
111
154
|
export interface ExitStatusResult {
|
|
112
155
|
vtxo_id: string;
|
|
113
156
|
state: string;
|
|
157
|
+
state_details: ExitStateDetailsResult;
|
|
114
158
|
history: string[];
|
|
159
|
+
history_details: ExitStateDetailsResult[];
|
|
115
160
|
transactions: ExitTransactionPackageResult[];
|
|
116
161
|
}
|
|
117
162
|
|
|
@@ -254,6 +299,8 @@ export interface NitroArk extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
|
254
299
|
destinationAddress: string,
|
|
255
300
|
feeRateSatPerKvb?: number
|
|
256
301
|
): Promise<string>;
|
|
302
|
+
extractTransaction(psbt: string): Promise<string>;
|
|
303
|
+
broadcastTransaction(txHex: string): Promise<string>;
|
|
257
304
|
syncPendingRounds(): Promise<void>;
|
|
258
305
|
|
|
259
306
|
// --- Wallet Info ---
|
package/src/index.tsx
CHANGED
|
@@ -10,6 +10,11 @@ import type {
|
|
|
10
10
|
ExitProgressStatusResult as NitroExitProgressStatusResult,
|
|
11
11
|
ExitVtxoResult as NitroExitVtxoResult,
|
|
12
12
|
ExitStatusResult as NitroExitStatusResult,
|
|
13
|
+
ExitBlockRefResult as NitroExitBlockRefResult,
|
|
14
|
+
ExitTxOriginResult as NitroExitTxOriginResult,
|
|
15
|
+
ExitTxStatusResult as NitroExitTxStatusResult,
|
|
16
|
+
ExitTxResult as NitroExitTxResult,
|
|
17
|
+
ExitStateDetailsResult as NitroExitStateDetailsResult,
|
|
13
18
|
ExitTransactionPackageResult as NitroExitTransactionPackageResult,
|
|
14
19
|
LightningSendResult,
|
|
15
20
|
OnchainPaymentResult,
|
|
@@ -48,6 +53,12 @@ export type ExitProgressState =
|
|
|
48
53
|
| 'ClaimInProgress'
|
|
49
54
|
| 'Claimed';
|
|
50
55
|
|
|
56
|
+
export type BlockRef = NitroExitBlockRefResult;
|
|
57
|
+
export type ExitTxOrigin = NitroExitTxOriginResult;
|
|
58
|
+
export type ExitTxStatus = NitroExitTxStatusResult;
|
|
59
|
+
export type ExitTx = NitroExitTxResult;
|
|
60
|
+
export type ExitStateDetails = NitroExitStateDetailsResult;
|
|
61
|
+
|
|
51
62
|
export type ExitProgressStatusResult = Omit<
|
|
52
63
|
NitroExitProgressStatusResult,
|
|
53
64
|
'state'
|
|
@@ -101,10 +112,37 @@ export type BarkNotificationEvent = Omit<
|
|
|
101
112
|
movement?: BarkMovement;
|
|
102
113
|
};
|
|
103
114
|
|
|
104
|
-
// Create the hybrid object instance
|
|
105
115
|
export const NitroArkHybridObject =
|
|
106
116
|
NitroModules.createHybridObject<NitroArk>('NitroArk');
|
|
107
117
|
|
|
118
|
+
function enrichExitProgressStatus(
|
|
119
|
+
result: NitroExitProgressStatusResult
|
|
120
|
+
): ExitProgressStatusResult {
|
|
121
|
+
const { state, ...rest } = result;
|
|
122
|
+
return {
|
|
123
|
+
...rest,
|
|
124
|
+
state: state as ExitProgressState,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function enrichExitVtxo(result: NitroExitVtxoResult): ExitVtxoResult {
|
|
129
|
+
const { state, history: stateHistory, ...rest } = result;
|
|
130
|
+
return {
|
|
131
|
+
...rest,
|
|
132
|
+
state: state as ExitProgressState,
|
|
133
|
+
history: stateHistory as ExitProgressState[],
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function enrichExitStatus(result: NitroExitStatusResult): ExitStatusResult {
|
|
138
|
+
const { state, history: stateHistory, ...rest } = result;
|
|
139
|
+
return {
|
|
140
|
+
...rest,
|
|
141
|
+
state: state as ExitProgressState,
|
|
142
|
+
history: stateHistory as ExitProgressState[],
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
108
146
|
// --- Management ---
|
|
109
147
|
|
|
110
148
|
/**
|
|
@@ -267,9 +305,9 @@ export function syncNoProgress(): Promise<void> {
|
|
|
267
305
|
export function progressExits(
|
|
268
306
|
feeRateSatPerKvb?: number
|
|
269
307
|
): Promise<ExitProgressStatusResult[]> {
|
|
270
|
-
return NitroArkHybridObject.progressExits(feeRateSatPerKvb)
|
|
271
|
-
|
|
272
|
-
|
|
308
|
+
return NitroArkHybridObject.progressExits(feeRateSatPerKvb).then((results) =>
|
|
309
|
+
results.map(enrichExitProgressStatus)
|
|
310
|
+
);
|
|
273
311
|
}
|
|
274
312
|
|
|
275
313
|
/**
|
|
@@ -277,7 +315,9 @@ export function progressExits(
|
|
|
277
315
|
* @returns A promise resolving to simplified exit entries.
|
|
278
316
|
*/
|
|
279
317
|
export function getExitVtxos(): Promise<ExitVtxoResult[]> {
|
|
280
|
-
return NitroArkHybridObject.getExitVtxos()
|
|
318
|
+
return NitroArkHybridObject.getExitVtxos().then((results) =>
|
|
319
|
+
results.map(enrichExitVtxo)
|
|
320
|
+
);
|
|
281
321
|
}
|
|
282
322
|
|
|
283
323
|
/**
|
|
@@ -285,7 +325,9 @@ export function getExitVtxos(): Promise<ExitVtxoResult[]> {
|
|
|
285
325
|
* @returns A promise resolving to claimable exit entries.
|
|
286
326
|
*/
|
|
287
327
|
export function listClaimable(): Promise<ExitVtxoResult[]> {
|
|
288
|
-
return NitroArkHybridObject.listClaimable()
|
|
328
|
+
return NitroArkHybridObject.listClaimable().then((results) =>
|
|
329
|
+
results.map(enrichExitVtxo)
|
|
330
|
+
);
|
|
289
331
|
}
|
|
290
332
|
|
|
291
333
|
/**
|
|
@@ -304,7 +346,7 @@ export function getExitStatus(
|
|
|
304
346
|
vtxoId,
|
|
305
347
|
includeHistory,
|
|
306
348
|
includeTransactions
|
|
307
|
-
)
|
|
349
|
+
).then((result) => (result ? enrichExitStatus(result) : undefined));
|
|
308
350
|
}
|
|
309
351
|
|
|
310
352
|
/**
|
|
@@ -350,6 +392,24 @@ export function drainExits(
|
|
|
350
392
|
);
|
|
351
393
|
}
|
|
352
394
|
|
|
395
|
+
/**
|
|
396
|
+
* Extracts a raw transaction from a base64 PSBT.
|
|
397
|
+
* @param psbt Base64-encoded PSBT.
|
|
398
|
+
* @returns A promise resolving to transaction hex.
|
|
399
|
+
*/
|
|
400
|
+
export function extractTransaction(psbt: string): Promise<string> {
|
|
401
|
+
return NitroArkHybridObject.extractTransaction(psbt);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Broadcasts a raw transaction to the configured blockchain backend.
|
|
406
|
+
* @param txHex Raw transaction hex.
|
|
407
|
+
* @returns A promise resolving to the broadcast transaction ID.
|
|
408
|
+
*/
|
|
409
|
+
export function broadcastTransaction(txHex: string): Promise<string> {
|
|
410
|
+
return NitroArkHybridObject.broadcastTransaction(txHex);
|
|
411
|
+
}
|
|
412
|
+
|
|
353
413
|
/**
|
|
354
414
|
* Synchronizes pending rounds.
|
|
355
415
|
* @returns A promise that resolves on success.
|