react-native-nitro-ark 0.0.94 → 0.0.95

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.
@@ -0,0 +1,90 @@
1
+ ///
2
+ /// BarkNotificationEvent.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 `BarkMovement` to properly resolve imports.
32
+ namespace margelo::nitro::nitroark { struct BarkMovement; }
33
+
34
+ #include <string>
35
+ #include "BarkMovement.hpp"
36
+ #include <optional>
37
+
38
+ namespace margelo::nitro::nitroark {
39
+
40
+ /**
41
+ * A struct which can be represented as a JavaScript object (BarkNotificationEvent).
42
+ */
43
+ struct BarkNotificationEvent final {
44
+ public:
45
+ std::string kind SWIFT_PRIVATE;
46
+ std::optional<BarkMovement> movement SWIFT_PRIVATE;
47
+
48
+ public:
49
+ BarkNotificationEvent() = default;
50
+ explicit BarkNotificationEvent(std::string kind, std::optional<BarkMovement> movement): kind(kind), movement(movement) {}
51
+
52
+ public:
53
+ friend bool operator==(const BarkNotificationEvent& lhs, const BarkNotificationEvent& rhs) = default;
54
+ };
55
+
56
+ } // namespace margelo::nitro::nitroark
57
+
58
+ namespace margelo::nitro {
59
+
60
+ // C++ BarkNotificationEvent <> JS BarkNotificationEvent (object)
61
+ template <>
62
+ struct JSIConverter<margelo::nitro::nitroark::BarkNotificationEvent> final {
63
+ static inline margelo::nitro::nitroark::BarkNotificationEvent fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
64
+ jsi::Object obj = arg.asObject(runtime);
65
+ return margelo::nitro::nitroark::BarkNotificationEvent(
66
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "kind"))),
67
+ JSIConverter<std::optional<margelo::nitro::nitroark::BarkMovement>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "movement")))
68
+ );
69
+ }
70
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroark::BarkNotificationEvent& arg) {
71
+ jsi::Object obj(runtime);
72
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "kind"), JSIConverter<std::string>::toJSI(runtime, arg.kind));
73
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "movement"), JSIConverter<std::optional<margelo::nitro::nitroark::BarkMovement>>::toJSI(runtime, arg.movement));
74
+ return obj;
75
+ }
76
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
77
+ if (!value.isObject()) {
78
+ return false;
79
+ }
80
+ jsi::Object obj = value.getObject(runtime);
81
+ if (!nitro::isPlainObject(runtime, obj)) {
82
+ return false;
83
+ }
84
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "kind")))) return false;
85
+ if (!JSIConverter<std::optional<margelo::nitro::nitroark::BarkMovement>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "movement")))) return false;
86
+ return true;
87
+ }
88
+ };
89
+
90
+ } // namespace margelo::nitro
@@ -0,0 +1,22 @@
1
+ ///
2
+ /// HybridBarkNotificationSubscriptionSpec.cpp
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
+ #include "HybridBarkNotificationSubscriptionSpec.hpp"
9
+
10
+ namespace margelo::nitro::nitroark {
11
+
12
+ void HybridBarkNotificationSubscriptionSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("stop", &HybridBarkNotificationSubscriptionSpec::stop);
18
+ prototype.registerHybridMethod("isActive", &HybridBarkNotificationSubscriptionSpec::isActive);
19
+ });
20
+ }
21
+
22
+ } // namespace margelo::nitro::nitroark
@@ -0,0 +1,63 @@
1
+ ///
2
+ /// HybridBarkNotificationSubscriptionSpec.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/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+
17
+
18
+
19
+
20
+ namespace margelo::nitro::nitroark {
21
+
22
+ using namespace margelo::nitro;
23
+
24
+ /**
25
+ * An abstract base class for `BarkNotificationSubscription`
26
+ * Inherit this class to create instances of `HybridBarkNotificationSubscriptionSpec` in C++.
27
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
28
+ * @example
29
+ * ```cpp
30
+ * class HybridBarkNotificationSubscription: public HybridBarkNotificationSubscriptionSpec {
31
+ * public:
32
+ * HybridBarkNotificationSubscription(...): HybridObject(TAG) { ... }
33
+ * // ...
34
+ * };
35
+ * ```
36
+ */
37
+ class HybridBarkNotificationSubscriptionSpec: public virtual HybridObject {
38
+ public:
39
+ // Constructor
40
+ explicit HybridBarkNotificationSubscriptionSpec(): HybridObject(TAG) { }
41
+
42
+ // Destructor
43
+ ~HybridBarkNotificationSubscriptionSpec() override = default;
44
+
45
+ public:
46
+ // Properties
47
+
48
+
49
+ public:
50
+ // Methods
51
+ virtual void stop() = 0;
52
+ virtual bool isActive() = 0;
53
+
54
+ protected:
55
+ // Hybrid Setup
56
+ void loadHybridMethods() override;
57
+
58
+ protected:
59
+ // Tag for logging
60
+ static constexpr auto TAG = "BarkNotificationSubscription";
61
+ };
62
+
63
+ } // namespace margelo::nitro::nitroark
@@ -32,8 +32,8 @@ namespace margelo::nitro::nitroark {
32
32
  prototype.registerHybridMethod("getArkInfo", &HybridNitroArkSpec::getArkInfo);
33
33
  prototype.registerHybridMethod("offchainBalance", &HybridNitroArkSpec::offchainBalance);
34
34
  prototype.registerHybridMethod("deriveStoreNextKeypair", &HybridNitroArkSpec::deriveStoreNextKeypair);
35
- prototype.registerHybridMethod("peakKeyPair", &HybridNitroArkSpec::peakKeyPair);
36
- prototype.registerHybridMethod("peakAddress", &HybridNitroArkSpec::peakAddress);
35
+ prototype.registerHybridMethod("peekKeyPair", &HybridNitroArkSpec::peekKeyPair);
36
+ prototype.registerHybridMethod("peekAddress", &HybridNitroArkSpec::peekAddress);
37
37
  prototype.registerHybridMethod("newAddress", &HybridNitroArkSpec::newAddress);
38
38
  prototype.registerHybridMethod("signMessage", &HybridNitroArkSpec::signMessage);
39
39
  prototype.registerHybridMethod("signMesssageWithMnemonic", &HybridNitroArkSpec::signMesssageWithMnemonic);
@@ -41,6 +41,9 @@ namespace margelo::nitro::nitroark {
41
41
  prototype.registerHybridMethod("verifyMessage", &HybridNitroArkSpec::verifyMessage);
42
42
  prototype.registerHybridMethod("mailboxKeypair", &HybridNitroArkSpec::mailboxKeypair);
43
43
  prototype.registerHybridMethod("mailboxAuthorization", &HybridNitroArkSpec::mailboxAuthorization);
44
+ prototype.registerHybridMethod("subscribeNotifications", &HybridNitroArkSpec::subscribeNotifications);
45
+ prototype.registerHybridMethod("subscribeArkoorAddressMovements", &HybridNitroArkSpec::subscribeArkoorAddressMovements);
46
+ prototype.registerHybridMethod("subscribeLightningPaymentMovements", &HybridNitroArkSpec::subscribeLightningPaymentMovements);
44
47
  prototype.registerHybridMethod("history", &HybridNitroArkSpec::history);
45
48
  prototype.registerHybridMethod("vtxos", &HybridNitroArkSpec::vtxos);
46
49
  prototype.registerHybridMethod("getFirstExpiringVtxoBlockheight", &HybridNitroArkSpec::getFirstExpiringVtxoBlockheight);
@@ -25,6 +25,10 @@ namespace margelo::nitro::nitroark { struct KeyPairResult; }
25
25
  namespace margelo::nitro::nitroark { struct NewAddressResult; }
26
26
  // Forward declaration of `MailboxAuthorizationResult` to properly resolve imports.
27
27
  namespace margelo::nitro::nitroark { struct MailboxAuthorizationResult; }
28
+ // Forward declaration of `HybridBarkNotificationSubscriptionSpec` to properly resolve imports.
29
+ namespace margelo::nitro::nitroark { class HybridBarkNotificationSubscriptionSpec; }
30
+ // Forward declaration of `BarkNotificationEvent` to properly resolve imports.
31
+ namespace margelo::nitro::nitroark { struct BarkNotificationEvent; }
28
32
  // Forward declaration of `BarkMovement` to properly resolve imports.
29
33
  namespace margelo::nitro::nitroark { struct BarkMovement; }
30
34
  // Forward declaration of `BarkVtxo` to properly resolve imports.
@@ -54,6 +58,10 @@ namespace margelo::nitro::nitroark { struct LightningReceive; }
54
58
  #include "KeyPairResult.hpp"
55
59
  #include "NewAddressResult.hpp"
56
60
  #include "MailboxAuthorizationResult.hpp"
61
+ #include <memory>
62
+ #include "HybridBarkNotificationSubscriptionSpec.hpp"
63
+ #include "BarkNotificationEvent.hpp"
64
+ #include <functional>
57
65
  #include "BarkMovement.hpp"
58
66
  #include <vector>
59
67
  #include "BarkVtxo.hpp"
@@ -118,8 +126,8 @@ namespace margelo::nitro::nitroark {
118
126
  virtual std::shared_ptr<Promise<BarkArkInfo>> getArkInfo() = 0;
119
127
  virtual std::shared_ptr<Promise<OffchainBalanceResult>> offchainBalance() = 0;
120
128
  virtual std::shared_ptr<Promise<KeyPairResult>> deriveStoreNextKeypair() = 0;
121
- virtual std::shared_ptr<Promise<KeyPairResult>> peakKeyPair(double index) = 0;
122
- virtual std::shared_ptr<Promise<NewAddressResult>> peakAddress(double index) = 0;
129
+ virtual std::shared_ptr<Promise<KeyPairResult>> peekKeyPair(double index) = 0;
130
+ virtual std::shared_ptr<Promise<NewAddressResult>> peekAddress(double index) = 0;
123
131
  virtual std::shared_ptr<Promise<NewAddressResult>> newAddress() = 0;
124
132
  virtual std::shared_ptr<Promise<std::string>> signMessage(const std::string& message, double index) = 0;
125
133
  virtual std::shared_ptr<Promise<std::string>> signMesssageWithMnemonic(const std::string& message, const std::string& mnemonic, const std::string& network, double index) = 0;
@@ -127,6 +135,9 @@ namespace margelo::nitro::nitroark {
127
135
  virtual std::shared_ptr<Promise<bool>> verifyMessage(const std::string& message, const std::string& signature, const std::string& publicKey) = 0;
128
136
  virtual std::shared_ptr<Promise<KeyPairResult>> mailboxKeypair() = 0;
129
137
  virtual std::shared_ptr<Promise<MailboxAuthorizationResult>> mailboxAuthorization(double authorizationExpiry) = 0;
138
+ virtual std::shared_ptr<HybridBarkNotificationSubscriptionSpec> subscribeNotifications(const std::function<void(const BarkNotificationEvent& /* event */)>& onEvent) = 0;
139
+ virtual std::shared_ptr<HybridBarkNotificationSubscriptionSpec> subscribeArkoorAddressMovements(const std::string& address, const std::function<void(const BarkNotificationEvent& /* event */)>& onEvent) = 0;
140
+ virtual std::shared_ptr<HybridBarkNotificationSubscriptionSpec> subscribeLightningPaymentMovements(const std::string& paymentHash, const std::function<void(const BarkNotificationEvent& /* event */)>& onEvent) = 0;
130
141
  virtual std::shared_ptr<Promise<std::vector<BarkMovement>>> history() = 0;
131
142
  virtual std::shared_ptr<Promise<std::vector<BarkVtxo>>> vtxos() = 0;
132
143
  virtual std::shared_ptr<Promise<std::optional<double>>> getFirstExpiringVtxoBlockheight() = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nitro-ark",
3
- "version": "0.0.94",
3
+ "version": "0.0.95",
4
4
  "description": "Pure C++ Nitro Modules for Ark client",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/module/index.js",
@@ -164,6 +164,17 @@ export interface BarkMovement {
164
164
  completed_at?: string;
165
165
  }
166
166
 
167
+ export interface BarkNotificationEvent {
168
+ kind: string; // 'movementCreated' | 'movementUpdated' | 'channelLagging'
169
+ movement?: BarkMovement;
170
+ }
171
+
172
+ export interface BarkNotificationSubscription
173
+ extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
174
+ stop(): void;
175
+ isActive(): boolean;
176
+ }
177
+
167
178
  // --- Nitro Module Interface ---
168
179
 
169
180
  export interface NitroArk extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
@@ -188,8 +199,8 @@ export interface NitroArk extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
188
199
  getArkInfo(): Promise<BarkArkInfo>;
189
200
  offchainBalance(): Promise<OffchainBalanceResult>;
190
201
  deriveStoreNextKeypair(): Promise<KeyPairResult>;
191
- peakKeyPair(index: number): Promise<KeyPairResult>;
192
- peakAddress(index: number): Promise<NewAddressResult>;
202
+ peekKeyPair(index: number): Promise<KeyPairResult>;
203
+ peekAddress(index: number): Promise<NewAddressResult>;
193
204
  newAddress(): Promise<NewAddressResult>;
194
205
  signMessage(message: string, index: number): Promise<string>;
195
206
  signMesssageWithMnemonic(
@@ -212,6 +223,17 @@ export interface NitroArk extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
212
223
  mailboxAuthorization(
213
224
  authorizationExpiry: number
214
225
  ): Promise<MailboxAuthorizationResult>;
226
+ subscribeNotifications(
227
+ onEvent: (event: BarkNotificationEvent) => void
228
+ ): BarkNotificationSubscription;
229
+ subscribeArkoorAddressMovements(
230
+ address: string,
231
+ onEvent: (event: BarkNotificationEvent) => void
232
+ ): BarkNotificationSubscription;
233
+ subscribeLightningPaymentMovements(
234
+ paymentHash: string,
235
+ onEvent: (event: BarkNotificationEvent) => void
236
+ ): BarkNotificationSubscription;
215
237
  history(): Promise<BarkMovement[]>;
216
238
  vtxos(): Promise<BarkVtxo[]>;
217
239
  getFirstExpiringVtxoBlockheight(): Promise<number | undefined>;
package/src/index.tsx CHANGED
@@ -14,6 +14,8 @@ import type {
14
14
  KeyPairResult,
15
15
  MailboxAuthorizationResult,
16
16
  LightningReceive,
17
+ BarkNotificationEvent as NitroBarkNotificationEvent,
18
+ BarkNotificationSubscription,
17
19
  BarkMovement as NitroBarkMovement,
18
20
  BarkMovementDestination as NitroBarkMovementDestination,
19
21
  BoardResult,
@@ -48,6 +50,19 @@ export type BarkMovement = NitroBarkMovement & {
48
50
  received_on: BarkMovementDestination[];
49
51
  };
50
52
 
53
+ export type BarkNotificationKind =
54
+ | 'movementCreated'
55
+ | 'movementUpdated'
56
+ | 'channelLagging';
57
+
58
+ export type BarkNotificationEvent = Omit<
59
+ NitroBarkNotificationEvent,
60
+ 'kind' | 'movement'
61
+ > & {
62
+ kind: BarkNotificationKind;
63
+ movement?: BarkMovement;
64
+ };
65
+
51
66
  // Create the hybrid object instance
52
67
  export const NitroArkHybridObject =
53
68
  NitroModules.createHybridObject<NitroArk>('NitroArk');
@@ -216,12 +231,12 @@ export function deriveStoreNextKeypair(): Promise<KeyPairResult> {
216
231
  }
217
232
 
218
233
  /**
219
- * Gets the wallet's VTXO public key (hex string).
234
+ * Peeks the wallet's VTXO public key (hex string).
220
235
  * @param index Index of the VTXO pubkey to retrieve.
221
236
  * @returns A promise resolving to the KeyPairResult object.
222
237
  */
223
- export function peakKeyPair(index: number): Promise<KeyPairResult> {
224
- return NitroArkHybridObject.peakKeyPair(index);
238
+ export function peekKeyPair(index: number): Promise<KeyPairResult> {
239
+ return NitroArkHybridObject.peekKeyPair(index);
225
240
  }
226
241
 
227
242
  /**
@@ -229,8 +244,8 @@ export function peakKeyPair(index: number): Promise<KeyPairResult> {
229
244
  * @param index Index of the address to preview.
230
245
  * @returns A promise resolving to the NewAddressResult object.
231
246
  */
232
- export function peakAddress(index: number): Promise<NewAddressResult> {
233
- return NitroArkHybridObject.peakAddress(index);
247
+ export function peekAddress(index: number): Promise<NewAddressResult> {
248
+ return NitroArkHybridObject.peekAddress(index);
234
249
  }
235
250
 
236
251
  /**
@@ -329,6 +344,51 @@ export function mailboxAuthorization(
329
344
  ) as Promise<MailboxAuthorizationResult>;
330
345
  }
331
346
 
347
+ /**
348
+ * Subscribes to all Bark wallet notifications.
349
+ * @param onEvent Callback invoked whenever a notification is emitted.
350
+ * @returns A subscription handle that can be stopped.
351
+ */
352
+ export function subscribeNotifications(
353
+ onEvent: (event: BarkNotificationEvent) => void
354
+ ): BarkNotificationSubscription {
355
+ return NitroArkHybridObject.subscribeNotifications(
356
+ onEvent as (event: NitroBarkNotificationEvent) => void
357
+ );
358
+ }
359
+
360
+ /**
361
+ * Subscribes to notifications related to a specific Arkoor address.
362
+ * @param address Arkoor address to filter by.
363
+ * @param onEvent Callback invoked whenever a matching notification is emitted.
364
+ * @returns A subscription handle that can be stopped.
365
+ */
366
+ export function subscribeArkoorAddressMovements(
367
+ address: string,
368
+ onEvent: (event: BarkNotificationEvent) => void
369
+ ): BarkNotificationSubscription {
370
+ return NitroArkHybridObject.subscribeArkoorAddressMovements(
371
+ address,
372
+ onEvent as (event: NitroBarkNotificationEvent) => void
373
+ );
374
+ }
375
+
376
+ /**
377
+ * Subscribes to notifications related to a specific Lightning payment hash.
378
+ * @param paymentHash Lightning payment hash to filter by.
379
+ * @param onEvent Callback invoked whenever a matching notification is emitted.
380
+ * @returns A subscription handle that can be stopped.
381
+ */
382
+ export function subscribeLightningPaymentMovements(
383
+ paymentHash: string,
384
+ onEvent: (event: BarkNotificationEvent) => void
385
+ ): BarkNotificationSubscription {
386
+ return NitroArkHybridObject.subscribeLightningPaymentMovements(
387
+ paymentHash,
388
+ onEvent as (event: NitroBarkNotificationEvent) => void
389
+ );
390
+ }
391
+
332
392
  /**
333
393
  * Gets a paginated list of wallet history (balance changes).
334
394
  * @returns A promise resolving to an array of BarkMovement objects.