react-native-nitro-ark 0.0.29 → 0.0.31
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 +151 -70
- package/cpp/generated/ark_cxx.h +35 -27
- package/lib/module/index.js +101 -47
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NitroArk.nitro.d.ts +23 -17
- package/lib/typescript/src/NitroArk.nitro.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +71 -32
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/nitrogen/generated/shared/c++/BarkArkInfo.hpp +93 -0
- package/nitrogen/generated/shared/c++/HybridNitroArkSpec.cpp +11 -3
- package/nitrogen/generated/shared/c++/HybridNitroArkSpec.hpp +21 -13
- package/package.json +1 -1
- package/src/NitroArk.nitro.ts +29 -39
- package/src/index.tsx +113 -80
- package/nitrogen/generated/shared/c++/BarkBalance.hpp +0 -77
- package/nitrogen/generated/shared/c++/BarkRefreshModeType.hpp +0 -94
- package/nitrogen/generated/shared/c++/BarkRefreshOpts.hpp +0 -81
package/src/index.tsx
CHANGED
|
@@ -2,8 +2,8 @@ import { NitroModules } from 'react-native-nitro-modules';
|
|
|
2
2
|
import type {
|
|
3
3
|
NitroArk,
|
|
4
4
|
BarkCreateOpts,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
BarkConfigOpts,
|
|
6
|
+
BarkArkInfo,
|
|
7
7
|
BarkSendManyOutput,
|
|
8
8
|
} from './NitroArk.nitro';
|
|
9
9
|
|
|
@@ -51,15 +51,71 @@ export function isWalletLoaded(): Promise<boolean> {
|
|
|
51
51
|
return NitroArkHybridObject.isWalletLoaded();
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Persists wallet configuration.
|
|
56
|
+
* @param opts The configuration options to persist.
|
|
57
|
+
* @returns A promise that resolves on success or rejects on error.
|
|
58
|
+
*/
|
|
59
|
+
export function persistConfig(opts: BarkConfigOpts): Promise<void> {
|
|
60
|
+
return NitroArkHybridObject.persistConfig(opts);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Runs wallet maintenance tasks.
|
|
65
|
+
* @returns A promise that resolves on success.
|
|
66
|
+
*/
|
|
67
|
+
export function maintenance(): Promise<void> {
|
|
68
|
+
return NitroArkHybridObject.maintenance();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Synchronizes the wallet with the blockchain.
|
|
73
|
+
* @returns A promise that resolves on success.
|
|
74
|
+
*/
|
|
75
|
+
export function sync(): Promise<void> {
|
|
76
|
+
return NitroArkHybridObject.sync();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Synchronizes the Ark-specific parts of the wallet.
|
|
81
|
+
* @returns A promise that resolves on success.
|
|
82
|
+
*/
|
|
83
|
+
export function syncArk(): Promise<void> {
|
|
84
|
+
return NitroArkHybridObject.syncArk();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Synchronizes the rounds of the wallet.
|
|
89
|
+
* @returns A promise that resolves on success.
|
|
90
|
+
*/
|
|
91
|
+
export function syncRounds(): Promise<void> {
|
|
92
|
+
return NitroArkHybridObject.syncRounds();
|
|
93
|
+
}
|
|
94
|
+
|
|
54
95
|
// --- Wallet Info ---
|
|
55
96
|
|
|
56
97
|
/**
|
|
57
|
-
* Gets the
|
|
58
|
-
* @
|
|
59
|
-
* @returns A promise resolving to the BarkBalance object.
|
|
98
|
+
* Gets the Ark-specific information.
|
|
99
|
+
* @returns A promise resolving to the BarkArkInfo object.
|
|
60
100
|
*/
|
|
61
|
-
export function
|
|
62
|
-
return NitroArkHybridObject.
|
|
101
|
+
export function getArkInfo(): Promise<BarkArkInfo> {
|
|
102
|
+
return NitroArkHybridObject.getArkInfo();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Gets the onchain balance for the loaded wallet.
|
|
107
|
+
* @returns A promise resolving to the onchain balance in satoshis.
|
|
108
|
+
*/
|
|
109
|
+
export function onchainBalance(): Promise<number> {
|
|
110
|
+
return NitroArkHybridObject.onchainBalance();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Gets the offchain balance for the loaded wallet.
|
|
115
|
+
* @returns A promise resolving to the offchain balance in satoshis.
|
|
116
|
+
*/
|
|
117
|
+
export function offchainBalance(): Promise<number> {
|
|
118
|
+
return NitroArkHybridObject.offchainBalance();
|
|
63
119
|
}
|
|
64
120
|
|
|
65
121
|
/**
|
|
@@ -81,7 +137,7 @@ export function getOnchainUtxos(no_sync: boolean = false): Promise<string> {
|
|
|
81
137
|
|
|
82
138
|
/**
|
|
83
139
|
* Gets the wallet's VTXO public key (hex string).
|
|
84
|
-
* @param index
|
|
140
|
+
* @param index Index of the VTXO pubkey to retrieve. Use u32::MAX for a new one.
|
|
85
141
|
* @returns A promise resolving to the hex-encoded public key string.
|
|
86
142
|
*/
|
|
87
143
|
export function getVtxoPubkey(index?: number): Promise<string> {
|
|
@@ -163,83 +219,61 @@ export function claimBolt11Payment(bolt11: string): Promise<void> {
|
|
|
163
219
|
// --- Ark Operations ---
|
|
164
220
|
|
|
165
221
|
/**
|
|
166
|
-
*
|
|
167
|
-
* @param
|
|
168
|
-
* @param no_sync If true, skips synchronization with the blockchain. Defaults to false.
|
|
222
|
+
* Boards a specific amount from the onchain wallet into Ark.
|
|
223
|
+
* @param amountSat The amount in satoshis to board.
|
|
169
224
|
* @returns A promise resolving to a JSON status string.
|
|
170
225
|
*/
|
|
171
|
-
export function
|
|
172
|
-
|
|
173
|
-
no_sync: boolean = false
|
|
174
|
-
): Promise<string> {
|
|
175
|
-
if (!refreshOpts.mode_type) {
|
|
176
|
-
return Promise.reject(
|
|
177
|
-
new Error('refreshVtxos requires refreshOpts.mode_type')
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
if (
|
|
181
|
-
refreshOpts.mode_type === 'Specific' &&
|
|
182
|
-
(!refreshOpts.specific_vtxo_ids ||
|
|
183
|
-
refreshOpts.specific_vtxo_ids.length === 0)
|
|
184
|
-
) {
|
|
185
|
-
return Promise.reject(
|
|
186
|
-
new Error(
|
|
187
|
-
"refreshVtxos with mode_type 'Specific' requires non-empty specific_vtxo_ids array"
|
|
188
|
-
)
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
if (
|
|
192
|
-
(refreshOpts.mode_type === 'ThresholdBlocks' ||
|
|
193
|
-
refreshOpts.mode_type === 'ThresholdHours') &&
|
|
194
|
-
(refreshOpts.threshold_value === undefined ||
|
|
195
|
-
refreshOpts.threshold_value <= 0)
|
|
196
|
-
) {
|
|
197
|
-
return Promise.reject(
|
|
198
|
-
new Error(
|
|
199
|
-
`refreshVtxos with mode_type '${refreshOpts.mode_type}' requires a positive threshold_value`
|
|
200
|
-
)
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
return NitroArkHybridObject.refreshVtxos(refreshOpts, no_sync);
|
|
226
|
+
export function boardAmount(amountSat: number): Promise<string> {
|
|
227
|
+
return NitroArkHybridObject.boardAmount(amountSat);
|
|
204
228
|
}
|
|
205
229
|
|
|
206
230
|
/**
|
|
207
|
-
* Boards
|
|
208
|
-
* @param amountSat The amount in satoshis to board.
|
|
209
|
-
* @param no_sync If true, skips synchronization with the onchain wallet. Defaults to false.
|
|
231
|
+
* Boards all available funds from the onchain wallet into Ark.
|
|
210
232
|
* @returns A promise resolving to a JSON status string.
|
|
211
233
|
*/
|
|
212
|
-
export function
|
|
213
|
-
|
|
214
|
-
|
|
234
|
+
export function boardAll(): Promise<string> {
|
|
235
|
+
return NitroArkHybridObject.boardAll();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Sends an Arkoor payment.
|
|
240
|
+
* @param destination The destination Arkoor address.
|
|
241
|
+
* @param amountSat The amount in satoshis to send.
|
|
242
|
+
* @returns A promise resolving to a result string.
|
|
243
|
+
*/
|
|
244
|
+
export function sendArkoorPayment(
|
|
245
|
+
destination: string,
|
|
246
|
+
amountSat: number
|
|
215
247
|
): Promise<string> {
|
|
216
|
-
return NitroArkHybridObject.
|
|
248
|
+
return NitroArkHybridObject.sendArkoorPayment(destination, amountSat);
|
|
217
249
|
}
|
|
218
250
|
|
|
219
251
|
/**
|
|
220
|
-
*
|
|
221
|
-
* @param
|
|
222
|
-
* @
|
|
252
|
+
* Sends a Bolt11 payment.
|
|
253
|
+
* @param destination The Bolt11 invoice.
|
|
254
|
+
* @param amountSat The amount in satoshis to send. Use 0 for invoice amount.
|
|
255
|
+
* @returns A promise resolving to a result string.
|
|
223
256
|
*/
|
|
224
|
-
export function
|
|
225
|
-
|
|
257
|
+
export function sendBolt11Payment(
|
|
258
|
+
destination: string,
|
|
259
|
+
amountSat?: number
|
|
260
|
+
): Promise<string> {
|
|
261
|
+
return NitroArkHybridObject.sendBolt11Payment(destination, amountSat);
|
|
226
262
|
}
|
|
227
263
|
|
|
228
264
|
/**
|
|
229
|
-
* Sends
|
|
230
|
-
* @param
|
|
265
|
+
* Sends a payment to a Lightning Address.
|
|
266
|
+
* @param addr The Lightning Address.
|
|
231
267
|
* @param amountSat The amount in satoshis to send.
|
|
232
|
-
* @param comment
|
|
233
|
-
* @
|
|
234
|
-
* @returns A promise resolving to a JSON status string.
|
|
268
|
+
* @param comment An optional comment.
|
|
269
|
+
* @returns A promise resolving to a result string.
|
|
235
270
|
*/
|
|
236
|
-
export function
|
|
237
|
-
|
|
238
|
-
amountSat: number
|
|
239
|
-
comment: string
|
|
240
|
-
no_sync: boolean = false
|
|
271
|
+
export function sendLnaddr(
|
|
272
|
+
addr: string,
|
|
273
|
+
amountSat: number,
|
|
274
|
+
comment: string
|
|
241
275
|
): Promise<string> {
|
|
242
|
-
return NitroArkHybridObject.
|
|
276
|
+
return NitroArkHybridObject.sendLnaddr(addr, amountSat, comment);
|
|
243
277
|
}
|
|
244
278
|
|
|
245
279
|
/**
|
|
@@ -260,35 +294,35 @@ export function sendRoundOnchain(
|
|
|
260
294
|
// --- Offboarding / Exiting ---
|
|
261
295
|
|
|
262
296
|
/**
|
|
263
|
-
* Offboards specific VTXOs to
|
|
297
|
+
* Offboards specific VTXOs to a destination address.
|
|
264
298
|
* @param vtxoIds Array of VtxoId strings to offboard.
|
|
265
|
-
* @param
|
|
299
|
+
* @param destinationAddress Destination Bitcoin address (if empty, sends to internal wallet).
|
|
266
300
|
* @param no_sync If true, skips synchronization with the wallet. Defaults to false.
|
|
267
301
|
* @returns A promise resolving to a JSON result string.
|
|
268
302
|
*/
|
|
269
303
|
export function offboardSpecific(
|
|
270
304
|
vtxoIds: string[],
|
|
271
|
-
|
|
305
|
+
destinationAddress: string,
|
|
272
306
|
no_sync: boolean = false
|
|
273
307
|
): Promise<string> {
|
|
274
308
|
return NitroArkHybridObject.offboardSpecific(
|
|
275
309
|
vtxoIds,
|
|
276
|
-
|
|
310
|
+
destinationAddress,
|
|
277
311
|
no_sync
|
|
278
312
|
);
|
|
279
313
|
}
|
|
280
314
|
|
|
281
315
|
/**
|
|
282
|
-
* Offboards all VTXOs to
|
|
283
|
-
* @param
|
|
316
|
+
* Offboards all VTXOs to a destination address.
|
|
317
|
+
* @param destinationAddress Destination Bitcoin address (if empty, sends to internal wallet).
|
|
284
318
|
* @param no_sync If true, skips synchronization with the wallet. Defaults to false.
|
|
285
319
|
* @returns A promise resolving to a JSON result string.
|
|
286
320
|
*/
|
|
287
321
|
export function offboardAll(
|
|
288
|
-
|
|
322
|
+
destinationAddress: string,
|
|
289
323
|
no_sync: boolean = false
|
|
290
324
|
): Promise<string> {
|
|
291
|
-
return NitroArkHybridObject.offboardAll(
|
|
325
|
+
return NitroArkHybridObject.offboardAll(destinationAddress, no_sync);
|
|
292
326
|
}
|
|
293
327
|
|
|
294
328
|
/**
|
|
@@ -296,7 +330,7 @@ export function offboardAll(
|
|
|
296
330
|
* @param vtxoIds Array of VtxoId strings to start exiting.
|
|
297
331
|
* @returns A promise resolving to a JSON status string.
|
|
298
332
|
*/
|
|
299
|
-
export function
|
|
333
|
+
export function startExitForVtxos(vtxoIds: string[]): Promise<string> {
|
|
300
334
|
return NitroArkHybridObject.exitStartSpecific(vtxoIds);
|
|
301
335
|
}
|
|
302
336
|
|
|
@@ -304,7 +338,7 @@ export function exitStartSpecific(vtxoIds: string[]): Promise<string> {
|
|
|
304
338
|
* Starts the exit process for all VTXOs in the wallet.
|
|
305
339
|
* @returns A promise resolving to a JSON status string.
|
|
306
340
|
*/
|
|
307
|
-
export function
|
|
341
|
+
export function startExitForEntireWallet(): Promise<string> {
|
|
308
342
|
return NitroArkHybridObject.exitStartAll();
|
|
309
343
|
}
|
|
310
344
|
|
|
@@ -318,10 +352,9 @@ export function exitProgressOnce(): Promise<string> {
|
|
|
318
352
|
|
|
319
353
|
// --- Re-export types and enums ---
|
|
320
354
|
export type {
|
|
355
|
+
NitroArk,
|
|
321
356
|
BarkCreateOpts,
|
|
322
357
|
BarkConfigOpts,
|
|
323
|
-
|
|
324
|
-
BarkRefreshOpts,
|
|
325
|
-
BarkRefreshModeType,
|
|
358
|
+
BarkArkInfo,
|
|
326
359
|
BarkSendManyOutput,
|
|
327
360
|
} from './NitroArk.nitro';
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// BarkBalance.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
|
-
|
|
24
|
-
|
|
25
|
-
namespace margelo::nitro::nitroark {
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* A struct which can be represented as a JavaScript object (BarkBalance).
|
|
29
|
-
*/
|
|
30
|
-
struct BarkBalance {
|
|
31
|
-
public:
|
|
32
|
-
double onchain SWIFT_PRIVATE;
|
|
33
|
-
double offchain SWIFT_PRIVATE;
|
|
34
|
-
double pending_exit SWIFT_PRIVATE;
|
|
35
|
-
|
|
36
|
-
public:
|
|
37
|
-
BarkBalance() = default;
|
|
38
|
-
explicit BarkBalance(double onchain, double offchain, double pending_exit): onchain(onchain), offchain(offchain), pending_exit(pending_exit) {}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
} // namespace margelo::nitro::nitroark
|
|
42
|
-
|
|
43
|
-
namespace margelo::nitro {
|
|
44
|
-
|
|
45
|
-
using namespace margelo::nitro::nitroark;
|
|
46
|
-
|
|
47
|
-
// C++ BarkBalance <> JS BarkBalance (object)
|
|
48
|
-
template <>
|
|
49
|
-
struct JSIConverter<BarkBalance> final {
|
|
50
|
-
static inline BarkBalance fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
51
|
-
jsi::Object obj = arg.asObject(runtime);
|
|
52
|
-
return BarkBalance(
|
|
53
|
-
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "onchain")),
|
|
54
|
-
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "offchain")),
|
|
55
|
-
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "pending_exit"))
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, const BarkBalance& arg) {
|
|
59
|
-
jsi::Object obj(runtime);
|
|
60
|
-
obj.setProperty(runtime, "onchain", JSIConverter<double>::toJSI(runtime, arg.onchain));
|
|
61
|
-
obj.setProperty(runtime, "offchain", JSIConverter<double>::toJSI(runtime, arg.offchain));
|
|
62
|
-
obj.setProperty(runtime, "pending_exit", JSIConverter<double>::toJSI(runtime, arg.pending_exit));
|
|
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<double>::canConvert(runtime, obj.getProperty(runtime, "onchain"))) return false;
|
|
71
|
-
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "offchain"))) return false;
|
|
72
|
-
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "pending_exit"))) return false;
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
} // namespace margelo::nitro
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// BarkRefreshModeType.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/NitroHash.hpp>)
|
|
11
|
-
#include <NitroModules/NitroHash.hpp>
|
|
12
|
-
#else
|
|
13
|
-
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
-
#endif
|
|
15
|
-
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
-
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
-
#else
|
|
18
|
-
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
-
#endif
|
|
20
|
-
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
-
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
-
#else
|
|
23
|
-
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
-
#endif
|
|
25
|
-
|
|
26
|
-
namespace margelo::nitro::nitroark {
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* An enum which can be represented as a JavaScript union (BarkRefreshModeType).
|
|
30
|
-
*/
|
|
31
|
-
enum class BarkRefreshModeType {
|
|
32
|
-
DEFAULTTHRESHOLD SWIFT_NAME(defaultthreshold) = 0,
|
|
33
|
-
THRESHOLDBLOCKS SWIFT_NAME(thresholdblocks) = 1,
|
|
34
|
-
THRESHOLDHOURS SWIFT_NAME(thresholdhours) = 2,
|
|
35
|
-
COUNTERPARTY SWIFT_NAME(counterparty) = 3,
|
|
36
|
-
ALL SWIFT_NAME(all) = 4,
|
|
37
|
-
SPECIFIC SWIFT_NAME(specific) = 5,
|
|
38
|
-
} CLOSED_ENUM;
|
|
39
|
-
|
|
40
|
-
} // namespace margelo::nitro::nitroark
|
|
41
|
-
|
|
42
|
-
namespace margelo::nitro {
|
|
43
|
-
|
|
44
|
-
using namespace margelo::nitro::nitroark;
|
|
45
|
-
|
|
46
|
-
// C++ BarkRefreshModeType <> JS BarkRefreshModeType (union)
|
|
47
|
-
template <>
|
|
48
|
-
struct JSIConverter<BarkRefreshModeType> final {
|
|
49
|
-
static inline BarkRefreshModeType fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
50
|
-
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
51
|
-
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
52
|
-
case hashString("DefaultThreshold"): return BarkRefreshModeType::DEFAULTTHRESHOLD;
|
|
53
|
-
case hashString("ThresholdBlocks"): return BarkRefreshModeType::THRESHOLDBLOCKS;
|
|
54
|
-
case hashString("ThresholdHours"): return BarkRefreshModeType::THRESHOLDHOURS;
|
|
55
|
-
case hashString("Counterparty"): return BarkRefreshModeType::COUNTERPARTY;
|
|
56
|
-
case hashString("All"): return BarkRefreshModeType::ALL;
|
|
57
|
-
case hashString("Specific"): return BarkRefreshModeType::SPECIFIC;
|
|
58
|
-
default: [[unlikely]]
|
|
59
|
-
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum BarkRefreshModeType - invalid value!");
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, BarkRefreshModeType arg) {
|
|
63
|
-
switch (arg) {
|
|
64
|
-
case BarkRefreshModeType::DEFAULTTHRESHOLD: return JSIConverter<std::string>::toJSI(runtime, "DefaultThreshold");
|
|
65
|
-
case BarkRefreshModeType::THRESHOLDBLOCKS: return JSIConverter<std::string>::toJSI(runtime, "ThresholdBlocks");
|
|
66
|
-
case BarkRefreshModeType::THRESHOLDHOURS: return JSIConverter<std::string>::toJSI(runtime, "ThresholdHours");
|
|
67
|
-
case BarkRefreshModeType::COUNTERPARTY: return JSIConverter<std::string>::toJSI(runtime, "Counterparty");
|
|
68
|
-
case BarkRefreshModeType::ALL: return JSIConverter<std::string>::toJSI(runtime, "All");
|
|
69
|
-
case BarkRefreshModeType::SPECIFIC: return JSIConverter<std::string>::toJSI(runtime, "Specific");
|
|
70
|
-
default: [[unlikely]]
|
|
71
|
-
throw std::invalid_argument("Cannot convert BarkRefreshModeType to JS - invalid value: "
|
|
72
|
-
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
76
|
-
if (!value.isString()) {
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
80
|
-
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
81
|
-
case hashString("DefaultThreshold"):
|
|
82
|
-
case hashString("ThresholdBlocks"):
|
|
83
|
-
case hashString("ThresholdHours"):
|
|
84
|
-
case hashString("Counterparty"):
|
|
85
|
-
case hashString("All"):
|
|
86
|
-
case hashString("Specific"):
|
|
87
|
-
return true;
|
|
88
|
-
default:
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
} // namespace margelo::nitro
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// BarkRefreshOpts.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 `BarkRefreshModeType` to properly resolve imports.
|
|
22
|
-
namespace margelo::nitro::nitroark { enum class BarkRefreshModeType; }
|
|
23
|
-
|
|
24
|
-
#include "BarkRefreshModeType.hpp"
|
|
25
|
-
#include <optional>
|
|
26
|
-
#include <vector>
|
|
27
|
-
#include <string>
|
|
28
|
-
|
|
29
|
-
namespace margelo::nitro::nitroark {
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* A struct which can be represented as a JavaScript object (BarkRefreshOpts).
|
|
33
|
-
*/
|
|
34
|
-
struct BarkRefreshOpts {
|
|
35
|
-
public:
|
|
36
|
-
BarkRefreshModeType mode_type SWIFT_PRIVATE;
|
|
37
|
-
std::optional<double> threshold_value SWIFT_PRIVATE;
|
|
38
|
-
std::optional<std::vector<std::string>> specific_vtxo_ids SWIFT_PRIVATE;
|
|
39
|
-
|
|
40
|
-
public:
|
|
41
|
-
BarkRefreshOpts() = default;
|
|
42
|
-
explicit BarkRefreshOpts(BarkRefreshModeType mode_type, std::optional<double> threshold_value, std::optional<std::vector<std::string>> specific_vtxo_ids): mode_type(mode_type), threshold_value(threshold_value), specific_vtxo_ids(specific_vtxo_ids) {}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
} // namespace margelo::nitro::nitroark
|
|
46
|
-
|
|
47
|
-
namespace margelo::nitro {
|
|
48
|
-
|
|
49
|
-
using namespace margelo::nitro::nitroark;
|
|
50
|
-
|
|
51
|
-
// C++ BarkRefreshOpts <> JS BarkRefreshOpts (object)
|
|
52
|
-
template <>
|
|
53
|
-
struct JSIConverter<BarkRefreshOpts> final {
|
|
54
|
-
static inline BarkRefreshOpts fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
55
|
-
jsi::Object obj = arg.asObject(runtime);
|
|
56
|
-
return BarkRefreshOpts(
|
|
57
|
-
JSIConverter<BarkRefreshModeType>::fromJSI(runtime, obj.getProperty(runtime, "mode_type")),
|
|
58
|
-
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "threshold_value")),
|
|
59
|
-
JSIConverter<std::optional<std::vector<std::string>>>::fromJSI(runtime, obj.getProperty(runtime, "specific_vtxo_ids"))
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, const BarkRefreshOpts& arg) {
|
|
63
|
-
jsi::Object obj(runtime);
|
|
64
|
-
obj.setProperty(runtime, "mode_type", JSIConverter<BarkRefreshModeType>::toJSI(runtime, arg.mode_type));
|
|
65
|
-
obj.setProperty(runtime, "threshold_value", JSIConverter<std::optional<double>>::toJSI(runtime, arg.threshold_value));
|
|
66
|
-
obj.setProperty(runtime, "specific_vtxo_ids", JSIConverter<std::optional<std::vector<std::string>>>::toJSI(runtime, arg.specific_vtxo_ids));
|
|
67
|
-
return obj;
|
|
68
|
-
}
|
|
69
|
-
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
70
|
-
if (!value.isObject()) {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
jsi::Object obj = value.getObject(runtime);
|
|
74
|
-
if (!JSIConverter<BarkRefreshModeType>::canConvert(runtime, obj.getProperty(runtime, "mode_type"))) return false;
|
|
75
|
-
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "threshold_value"))) return false;
|
|
76
|
-
if (!JSIConverter<std::optional<std::vector<std::string>>>::canConvert(runtime, obj.getProperty(runtime, "specific_vtxo_ids"))) return false;
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
} // namespace margelo::nitro
|