@breeztech/breez-sdk-spark-react-native 0.2.4 → 0.2.5-dev2

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.
@@ -79,6 +79,7 @@ import {
79
79
  uniffiCreateRecord,
80
80
  uniffiRustCallAsync,
81
81
  uniffiTraitInterfaceCall,
82
+ uniffiTraitInterfaceCallAsync,
82
83
  uniffiTraitInterfaceCallAsyncWithError,
83
84
  uniffiTypeNameSymbol,
84
85
  variantOrdinalSymbol,
@@ -248,7 +249,7 @@ export interface EventListener {
248
249
  /**
249
250
  * Called when an event occurs
250
251
  */
251
- onEvent(event: SdkEvent): void;
252
+ onEvent(event: SdkEvent, asyncOpts_?: { signal: AbortSignal }): Promise<void>;
252
253
  }
253
254
 
254
255
  // Put the implementation in a struct so we don't pollute the top-level namespace
@@ -259,23 +260,42 @@ const uniffiCallbackInterfaceEventListener: {
259
260
  // Create the VTable using a series of closures.
260
261
  // ts automatically converts these into C callback functions.
261
262
  vtable: {
262
- onEvent: (uniffiHandle: bigint, event: Uint8Array) => {
263
- const uniffiMakeCall = (): void => {
263
+ onEvent: (
264
+ uniffiHandle: bigint,
265
+ event: Uint8Array,
266
+ uniffiFutureCallback: UniffiForeignFutureCompleteVoid,
267
+ uniffiCallbackData: bigint
268
+ ) => {
269
+ const uniffiMakeCall = async (signal: AbortSignal): Promise<void> => {
264
270
  const jsCallback = FfiConverterTypeEventListener.lift(uniffiHandle);
265
- return jsCallback.onEvent(FfiConverterTypeSdkEvent.lift(event));
271
+ return await jsCallback.onEvent(FfiConverterTypeSdkEvent.lift(event), {
272
+ signal,
273
+ });
266
274
  };
267
- const uniffiResult = UniffiResult.ready<void>();
268
- const uniffiHandleSuccess = (obj: any) => {};
269
- const uniffiHandleError = (code: number, errBuf: UniffiByteArray) => {
270
- UniffiResult.writeError(uniffiResult, code, errBuf);
275
+ const uniffiHandleSuccess = (returnValue: void) => {
276
+ uniffiFutureCallback(
277
+ uniffiCallbackData,
278
+ /* UniffiForeignFutureStructVoid */ {
279
+ callStatus: uniffiCaller.createCallStatus(),
280
+ }
281
+ );
271
282
  };
272
- uniffiTraitInterfaceCall(
283
+ const uniffiHandleError = (code: number, errorBuf: UniffiByteArray) => {
284
+ uniffiFutureCallback(
285
+ uniffiCallbackData,
286
+ /* UniffiForeignFutureStructVoid */ {
287
+ // TODO create callstatus with error.
288
+ callStatus: { code, errorBuf },
289
+ }
290
+ );
291
+ };
292
+ const uniffiForeignFuture = uniffiTraitInterfaceCallAsync(
273
293
  /*makeCall:*/ uniffiMakeCall,
274
294
  /*handleSuccess:*/ uniffiHandleSuccess,
275
295
  /*handleError:*/ uniffiHandleError,
276
296
  /*lowerString:*/ FfiConverterString.lower
277
297
  );
278
- return uniffiResult;
298
+ return UniffiResult.success(uniffiForeignFuture);
279
299
  },
280
300
  uniffiFree: (uniffiHandle: UniffiHandle): void => {
281
301
  // EventListener: this will throw a stale handle error if the handle isn't found.
@@ -785,7 +805,9 @@ const FfiConverterTypeDepositInfo = (() => {
785
805
  /**
786
806
  * Request to get the balance of the wallet
787
807
  */
788
- export type GetInfoRequest = {};
808
+ export type GetInfoRequest = {
809
+ ensureSynced: boolean | undefined;
810
+ };
789
811
 
790
812
  /**
791
813
  * Generated factory for {@link GetInfoRequest} record objects.
@@ -821,11 +843,15 @@ const FfiConverterTypeGetInfoRequest = (() => {
821
843
  type TypeName = GetInfoRequest;
822
844
  class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
823
845
  read(from: RustBuffer): TypeName {
824
- return {};
846
+ return {
847
+ ensureSynced: FfiConverterOptionalBool.read(from),
848
+ };
849
+ }
850
+ write(value: TypeName, into: RustBuffer): void {
851
+ FfiConverterOptionalBool.write(value.ensureSynced, into);
825
852
  }
826
- write(value: TypeName, into: RustBuffer): void {}
827
853
  allocationSize(value: TypeName): number {
828
- return 0;
854
+ return FfiConverterOptionalBool.allocationSize(value.ensureSynced);
829
855
  }
830
856
  }
831
857
  return new FFIConverter();
@@ -6518,7 +6544,10 @@ export interface BreezSdkInterface {
6518
6544
  *
6519
6545
  * A unique identifier for the listener, which can be used to remove it later
6520
6546
  */
6521
- addEventListener(listener: EventListener): string;
6547
+ addEventListener(
6548
+ listener: EventListener,
6549
+ asyncOpts_?: { signal: AbortSignal }
6550
+ ): Promise<string>;
6522
6551
  checkLightningAddressAvailable(
6523
6552
  req: CheckLightningAddressRequest,
6524
6553
  asyncOpts_?: { signal: AbortSignal }
@@ -6634,7 +6663,10 @@ export interface BreezSdkInterface {
6634
6663
  *
6635
6664
  * `true` if the listener was found and removed, `false` otherwise
6636
6665
  */
6637
- removeEventListener(id: string): boolean;
6666
+ removeEventListener(
6667
+ id: string,
6668
+ asyncOpts_?: { signal: AbortSignal }
6669
+ ): Promise<boolean>;
6638
6670
  sendPayment(
6639
6671
  request: SendPaymentRequest,
6640
6672
  asyncOpts_?: { signal: AbortSignal }
@@ -6647,7 +6679,10 @@ export interface BreezSdkInterface {
6647
6679
  /**
6648
6680
  * Synchronizes the wallet with the Spark network
6649
6681
  */
6650
- syncWallet(request: SyncWalletRequest) /*throws*/ : SyncWalletResponse;
6682
+ syncWallet(
6683
+ request: SyncWalletRequest,
6684
+ asyncOpts_?: { signal: AbortSignal }
6685
+ ) /*throws*/ : Promise<SyncWalletResponse>;
6651
6686
  }
6652
6687
 
6653
6688
  /**
@@ -6680,19 +6715,38 @@ export class BreezSdk
6680
6715
  *
6681
6716
  * A unique identifier for the listener, which can be used to remove it later
6682
6717
  */
6683
- public addEventListener(listener: EventListener): string {
6684
- return FfiConverterString.lift(
6685
- uniffiCaller.rustCall(
6686
- /*caller:*/ (callStatus) => {
6718
+ public async addEventListener(
6719
+ listener: EventListener,
6720
+ asyncOpts_?: { signal: AbortSignal }
6721
+ ): Promise<string> {
6722
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
6723
+ try {
6724
+ return await uniffiRustCallAsync(
6725
+ /*rustCaller:*/ uniffiCaller,
6726
+ /*rustFutureFunc:*/ () => {
6687
6727
  return nativeModule().ubrn_uniffi_breez_sdk_spark_fn_method_breezsdk_add_event_listener(
6688
6728
  uniffiTypeBreezSdkObjectFactory.clonePointer(this),
6689
- FfiConverterTypeEventListener.lower(listener),
6690
- callStatus
6729
+ FfiConverterTypeEventListener.lower(listener)
6691
6730
  );
6692
6731
  },
6693
- /*liftString:*/ FfiConverterString.lift
6694
- )
6695
- );
6732
+ /*pollFunc:*/ nativeModule()
6733
+ .ubrn_ffi_breez_sdk_spark_rust_future_poll_rust_buffer,
6734
+ /*cancelFunc:*/ nativeModule()
6735
+ .ubrn_ffi_breez_sdk_spark_rust_future_cancel_rust_buffer,
6736
+ /*completeFunc:*/ nativeModule()
6737
+ .ubrn_ffi_breez_sdk_spark_rust_future_complete_rust_buffer,
6738
+ /*freeFunc:*/ nativeModule()
6739
+ .ubrn_ffi_breez_sdk_spark_rust_future_free_rust_buffer,
6740
+ /*liftFunc:*/ FfiConverterString.lift.bind(FfiConverterString),
6741
+ /*liftString:*/ FfiConverterString.lift,
6742
+ /*asyncOpts:*/ asyncOpts_
6743
+ );
6744
+ } catch (__error: any) {
6745
+ if (uniffiIsDebug && __error instanceof Error) {
6746
+ __error.stack = __stack;
6747
+ }
6748
+ throw __error;
6749
+ }
6696
6750
  }
6697
6751
 
6698
6752
  public async checkLightningAddressAvailable(
@@ -7423,19 +7477,38 @@ export class BreezSdk
7423
7477
  *
7424
7478
  * `true` if the listener was found and removed, `false` otherwise
7425
7479
  */
7426
- public removeEventListener(id: string): boolean {
7427
- return FfiConverterBool.lift(
7428
- uniffiCaller.rustCall(
7429
- /*caller:*/ (callStatus) => {
7480
+ public async removeEventListener(
7481
+ id: string,
7482
+ asyncOpts_?: { signal: AbortSignal }
7483
+ ): Promise<boolean> {
7484
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
7485
+ try {
7486
+ return await uniffiRustCallAsync(
7487
+ /*rustCaller:*/ uniffiCaller,
7488
+ /*rustFutureFunc:*/ () => {
7430
7489
  return nativeModule().ubrn_uniffi_breez_sdk_spark_fn_method_breezsdk_remove_event_listener(
7431
7490
  uniffiTypeBreezSdkObjectFactory.clonePointer(this),
7432
- FfiConverterString.lower(id),
7433
- callStatus
7491
+ FfiConverterString.lower(id)
7434
7492
  );
7435
7493
  },
7436
- /*liftString:*/ FfiConverterString.lift
7437
- )
7438
- );
7494
+ /*pollFunc:*/ nativeModule()
7495
+ .ubrn_ffi_breez_sdk_spark_rust_future_poll_i8,
7496
+ /*cancelFunc:*/ nativeModule()
7497
+ .ubrn_ffi_breez_sdk_spark_rust_future_cancel_i8,
7498
+ /*completeFunc:*/ nativeModule()
7499
+ .ubrn_ffi_breez_sdk_spark_rust_future_complete_i8,
7500
+ /*freeFunc:*/ nativeModule()
7501
+ .ubrn_ffi_breez_sdk_spark_rust_future_free_i8,
7502
+ /*liftFunc:*/ FfiConverterBool.lift.bind(FfiConverterBool),
7503
+ /*liftString:*/ FfiConverterString.lift,
7504
+ /*asyncOpts:*/ asyncOpts_
7505
+ );
7506
+ } catch (__error: any) {
7507
+ if (uniffiIsDebug && __error instanceof Error) {
7508
+ __error.stack = __stack;
7509
+ }
7510
+ throw __error;
7511
+ }
7439
7512
  }
7440
7513
 
7441
7514
  public async sendPayment(
@@ -7521,22 +7594,43 @@ export class BreezSdk
7521
7594
  /**
7522
7595
  * Synchronizes the wallet with the Spark network
7523
7596
  */
7524
- public syncWallet(request: SyncWalletRequest): SyncWalletResponse /*throws*/ {
7525
- return FfiConverterTypeSyncWalletResponse.lift(
7526
- uniffiCaller.rustCallWithError(
7527
- /*liftError:*/ FfiConverterTypeSdkError.lift.bind(
7528
- FfiConverterTypeSdkError
7529
- ),
7530
- /*caller:*/ (callStatus) => {
7597
+ public async syncWallet(
7598
+ request: SyncWalletRequest,
7599
+ asyncOpts_?: { signal: AbortSignal }
7600
+ ): Promise<SyncWalletResponse> /*throws*/ {
7601
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
7602
+ try {
7603
+ return await uniffiRustCallAsync(
7604
+ /*rustCaller:*/ uniffiCaller,
7605
+ /*rustFutureFunc:*/ () => {
7531
7606
  return nativeModule().ubrn_uniffi_breez_sdk_spark_fn_method_breezsdk_sync_wallet(
7532
7607
  uniffiTypeBreezSdkObjectFactory.clonePointer(this),
7533
- FfiConverterTypeSyncWalletRequest.lower(request),
7534
- callStatus
7608
+ FfiConverterTypeSyncWalletRequest.lower(request)
7535
7609
  );
7536
7610
  },
7537
- /*liftString:*/ FfiConverterString.lift
7538
- )
7539
- );
7611
+ /*pollFunc:*/ nativeModule()
7612
+ .ubrn_ffi_breez_sdk_spark_rust_future_poll_rust_buffer,
7613
+ /*cancelFunc:*/ nativeModule()
7614
+ .ubrn_ffi_breez_sdk_spark_rust_future_cancel_rust_buffer,
7615
+ /*completeFunc:*/ nativeModule()
7616
+ .ubrn_ffi_breez_sdk_spark_rust_future_complete_rust_buffer,
7617
+ /*freeFunc:*/ nativeModule()
7618
+ .ubrn_ffi_breez_sdk_spark_rust_future_free_rust_buffer,
7619
+ /*liftFunc:*/ FfiConverterTypeSyncWalletResponse.lift.bind(
7620
+ FfiConverterTypeSyncWalletResponse
7621
+ ),
7622
+ /*liftString:*/ FfiConverterString.lift,
7623
+ /*asyncOpts:*/ asyncOpts_,
7624
+ /*errorHandler:*/ FfiConverterTypeSdkError.lift.bind(
7625
+ FfiConverterTypeSdkError
7626
+ )
7627
+ );
7628
+ } catch (__error: any) {
7629
+ if (uniffiIsDebug && __error instanceof Error) {
7630
+ __error.stack = __stack;
7631
+ }
7632
+ throw __error;
7633
+ }
7540
7634
  }
7541
7635
 
7542
7636
  /**
@@ -7660,6 +7754,7 @@ export interface SdkBuilderInterface {
7660
7754
  withKeySet(
7661
7755
  keySetType: KeySetType,
7662
7756
  useAddressIndex: boolean,
7757
+ accountNumber: /*u32*/ number | undefined,
7663
7758
  asyncOpts_?: { signal: AbortSignal }
7664
7759
  ): Promise<void>;
7665
7760
  withLnurlClient(
@@ -7841,6 +7936,7 @@ export class SdkBuilder
7841
7936
  public async withKeySet(
7842
7937
  keySetType: KeySetType,
7843
7938
  useAddressIndex: boolean,
7939
+ accountNumber: /*u32*/ number | undefined,
7844
7940
  asyncOpts_?: { signal: AbortSignal }
7845
7941
  ): Promise<void> {
7846
7942
  const __stack = uniffiIsDebug ? new Error().stack : undefined;
@@ -7851,7 +7947,8 @@ export class SdkBuilder
7851
7947
  return nativeModule().ubrn_uniffi_breez_sdk_spark_fn_method_sdkbuilder_with_key_set(
7852
7948
  uniffiTypeSdkBuilderObjectFactory.clonePointer(this),
7853
7949
  FfiConverterTypeKeySetType.lower(keySetType),
7854
- FfiConverterBool.lower(useAddressIndex)
7950
+ FfiConverterBool.lower(useAddressIndex),
7951
+ FfiConverterOptionalUInt32.lower(accountNumber)
7855
7952
  );
7856
7953
  },
7857
7954
  /*pollFunc:*/ nativeModule()
@@ -9474,7 +9571,7 @@ function uniffiEnsureInitialized() {
9474
9571
  }
9475
9572
  if (
9476
9573
  nativeModule().ubrn_uniffi_breez_sdk_spark_checksum_method_breezsdk_add_event_listener() !==
9477
- 61844
9574
+ 37737
9478
9575
  ) {
9479
9576
  throw new UniffiInternalError.ApiChecksumMismatch(
9480
9577
  'uniffi_breez_sdk_spark_checksum_method_breezsdk_add_event_listener'
@@ -9634,7 +9731,7 @@ function uniffiEnsureInitialized() {
9634
9731
  }
9635
9732
  if (
9636
9733
  nativeModule().ubrn_uniffi_breez_sdk_spark_checksum_method_breezsdk_remove_event_listener() !==
9637
- 60980
9734
+ 41066
9638
9735
  ) {
9639
9736
  throw new UniffiInternalError.ApiChecksumMismatch(
9640
9737
  'uniffi_breez_sdk_spark_checksum_method_breezsdk_remove_event_listener'
@@ -9658,7 +9755,7 @@ function uniffiEnsureInitialized() {
9658
9755
  }
9659
9756
  if (
9660
9757
  nativeModule().ubrn_uniffi_breez_sdk_spark_checksum_method_breezsdk_sync_wallet() !==
9661
- 36066
9758
+ 30368
9662
9759
  ) {
9663
9760
  throw new UniffiInternalError.ApiChecksumMismatch(
9664
9761
  'uniffi_breez_sdk_spark_checksum_method_breezsdk_sync_wallet'
@@ -9690,7 +9787,7 @@ function uniffiEnsureInitialized() {
9690
9787
  }
9691
9788
  if (
9692
9789
  nativeModule().ubrn_uniffi_breez_sdk_spark_checksum_method_sdkbuilder_with_key_set() !==
9693
- 55523
9790
+ 42926
9694
9791
  ) {
9695
9792
  throw new UniffiInternalError.ApiChecksumMismatch(
9696
9793
  'uniffi_breez_sdk_spark_checksum_method_sdkbuilder_with_key_set'
@@ -9810,7 +9907,7 @@ function uniffiEnsureInitialized() {
9810
9907
  }
9811
9908
  if (
9812
9909
  nativeModule().ubrn_uniffi_breez_sdk_spark_checksum_method_eventlistener_on_event() !==
9813
- 10824
9910
+ 24807
9814
9911
  ) {
9815
9912
  throw new UniffiInternalError.ApiChecksumMismatch(
9816
9913
  'uniffi_breez_sdk_spark_checksum_method_eventlistener_on_event'