// This file is automatically generated, so please do not edit it.
// @generated by `flutter_rust_bridge`@ 2.12.0.

// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import

import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';

import '../frb_generated.dart';
import '../lib.dart';
import 'accounts.dart';
import 'error.dart';

// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `backend`, `clone`, `fmt`, `get_public_key`, `nip04_decrypt`, `nip04_encrypt`, `nip44_decrypt`, `nip44_encrypt`, `sign_event`

/// Register an external signer for an existing account.
///
/// This function is used to re-register an external signer after app restart.
/// Unlike the login functions, this does NOT perform any account setup or key
/// package publishing - it only registers the signer so that subsequent
/// signing operations will work.
///
/// Call this on app startup when restoring an external signer account session.
Future<void> registerExternalSigner({
  required String pubkey,
  required FutureOr<String> Function(String) signEvent,
  required FutureOr<String> Function(String, String) nip04Encrypt,
  required FutureOr<String> Function(String, String) nip04Decrypt,
  required FutureOr<String> Function(String, String) nip44Encrypt,
  required FutureOr<String> Function(String, String) nip44Decrypt,
}) => RustLib.instance.api.crateApiSignerRegisterExternalSigner(
  pubkey: pubkey,
  signEvent: signEvent,
  nip04Encrypt: nip04Encrypt,
  nip04Decrypt: nip04Decrypt,
  nip44Encrypt: nip44Encrypt,
  nip44Decrypt: nip44Decrypt,
);

/// Step 1 of the multi-step external signer login flow.
///
/// Creates an account for the given public key using the provided signer
/// callbacks, then attempts to discover existing relay lists from the network.
///
/// Returns `LoginStatus::Complete` on the happy path, or
/// `LoginStatus::NeedsRelayLists` if relay lists were not found.
Future<LoginResult> loginExternalSignerStart({
  required String pubkey,
  required FutureOr<String> Function(String) signEvent,
  required FutureOr<String> Function(String, String) nip04Encrypt,
  required FutureOr<String> Function(String, String) nip04Decrypt,
  required FutureOr<String> Function(String, String) nip44Encrypt,
  required FutureOr<String> Function(String, String) nip44Decrypt,
}) => RustLib.instance.api.crateApiSignerLoginExternalSignerStart(
  pubkey: pubkey,
  signEvent: signEvent,
  nip04Encrypt: nip04Encrypt,
  nip04Decrypt: nip04Decrypt,
  nip44Encrypt: nip44Encrypt,
  nip44Decrypt: nip44Decrypt,
);

/// Step 2a for external signer: publish default relay lists and complete login.
///
/// Called after `login_external_signer_start` returned `NeedsRelayLists`.
Future<LoginResult> loginExternalSignerPublishDefaultRelays({
  required String pubkey,
}) => RustLib.instance.api.crateApiSignerLoginExternalSignerPublishDefaultRelays(pubkey: pubkey);

/// Step 2b for external signer: search a user-provided relay for existing lists.
///
/// Called after `login_external_signer_start` returned `NeedsRelayLists`.
Future<LoginResult> loginExternalSignerWithCustomRelay({
  required String pubkey,
  required String relayUrl,
}) => RustLib.instance.api.crateApiSignerLoginExternalSignerWithCustomRelay(
  pubkey: pubkey,
  relayUrl: relayUrl,
);

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<DartSigner>>
abstract class DartSigner implements RustOpaqueInterface {
  // HINT: Make it `#[frb(sync)]` to let it become the default constructor of Dart class.
  /// Creates a new DartSigner with the given callbacks.
  static Future<DartSigner> newInstance({
    required PublicKey pubkey,
    required FutureOr<String> Function(String) signEvent,
    required FutureOr<String> Function(String, String) nip04Encrypt,
    required FutureOr<String> Function(String, String) nip04Decrypt,
    required FutureOr<String> Function(String, String) nip44Encrypt,
    required FutureOr<String> Function(String, String) nip44Decrypt,
  }) => RustLib.instance.api.crateApiSignerDartSignerNew(
    pubkey: pubkey,
    signEvent: signEvent,
    nip04Encrypt: nip04Encrypt,
    nip04Decrypt: nip04Decrypt,
    nip44Encrypt: nip44Encrypt,
    nip44Decrypt: nip44Decrypt,
  );
}
