// This file was autogenerated by some hot garbage in the
// `uniffi-bindgen-react-native` crate. Trust me, you don't want to mess with
// it!
#include "fedimint_client_uniffi.hpp"

#include "UniffiJsiTypes.h"
#include <iostream>
#include <map>
#include <stdexcept>
#include <thread>
#include <utility>

namespace react = facebook::react;
namespace jsi = facebook::jsi;

// Calling into Rust.
extern "C" {
typedef void (*UniffiRustFutureContinuationCallback)(uint64_t data,
                                                     int8_t poll_result);
typedef void (*UniffiForeignFutureFree)(uint64_t handle);
typedef void (*UniffiCallbackInterfaceFree)(uint64_t handle);
typedef struct UniffiForeignFuture {
  uint64_t handle;
  UniffiForeignFutureFree free;
} UniffiForeignFuture;
typedef struct UniffiForeignFutureStructU8 {
  uint8_t return_value;
  RustCallStatus call_status;
} UniffiForeignFutureStructU8;
typedef void (*UniffiForeignFutureCompleteU8)(
    uint64_t callback_data, UniffiForeignFutureStructU8 result);
typedef struct UniffiForeignFutureStructI8 {
  int8_t return_value;
  RustCallStatus call_status;
} UniffiForeignFutureStructI8;
typedef void (*UniffiForeignFutureCompleteI8)(
    uint64_t callback_data, UniffiForeignFutureStructI8 result);
typedef struct UniffiForeignFutureStructU16 {
  uint16_t return_value;
  RustCallStatus call_status;
} UniffiForeignFutureStructU16;
typedef void (*UniffiForeignFutureCompleteU16)(
    uint64_t callback_data, UniffiForeignFutureStructU16 result);
typedef struct UniffiForeignFutureStructI16 {
  int16_t return_value;
  RustCallStatus call_status;
} UniffiForeignFutureStructI16;
typedef void (*UniffiForeignFutureCompleteI16)(
    uint64_t callback_data, UniffiForeignFutureStructI16 result);
typedef struct UniffiForeignFutureStructU32 {
  uint32_t return_value;
  RustCallStatus call_status;
} UniffiForeignFutureStructU32;
typedef void (*UniffiForeignFutureCompleteU32)(
    uint64_t callback_data, UniffiForeignFutureStructU32 result);
typedef struct UniffiForeignFutureStructI32 {
  int32_t return_value;
  RustCallStatus call_status;
} UniffiForeignFutureStructI32;
typedef void (*UniffiForeignFutureCompleteI32)(
    uint64_t callback_data, UniffiForeignFutureStructI32 result);
typedef struct UniffiForeignFutureStructU64 {
  uint64_t return_value;
  RustCallStatus call_status;
} UniffiForeignFutureStructU64;
typedef void (*UniffiForeignFutureCompleteU64)(
    uint64_t callback_data, UniffiForeignFutureStructU64 result);
typedef struct UniffiForeignFutureStructI64 {
  int64_t return_value;
  RustCallStatus call_status;
} UniffiForeignFutureStructI64;
typedef void (*UniffiForeignFutureCompleteI64)(
    uint64_t callback_data, UniffiForeignFutureStructI64 result);
typedef struct UniffiForeignFutureStructF32 {
  float return_value;
  RustCallStatus call_status;
} UniffiForeignFutureStructF32;
typedef void (*UniffiForeignFutureCompleteF32)(
    uint64_t callback_data, UniffiForeignFutureStructF32 result);
typedef struct UniffiForeignFutureStructF64 {
  double return_value;
  RustCallStatus call_status;
} UniffiForeignFutureStructF64;
typedef void (*UniffiForeignFutureCompleteF64)(
    uint64_t callback_data, UniffiForeignFutureStructF64 result);
typedef struct UniffiForeignFutureStructPointer {
  void *return_value;
  RustCallStatus call_status;
} UniffiForeignFutureStructPointer;
typedef void (*UniffiForeignFutureCompletePointer)(
    uint64_t callback_data, UniffiForeignFutureStructPointer result);
typedef struct UniffiForeignFutureStructRustBuffer {
  RustBuffer return_value;
  RustCallStatus call_status;
} UniffiForeignFutureStructRustBuffer;
typedef void (*UniffiForeignFutureCompleteRustBuffer)(
    uint64_t callback_data, UniffiForeignFutureStructRustBuffer result);
typedef struct UniffiForeignFutureStructVoid {
  RustCallStatus call_status;
} UniffiForeignFutureStructVoid;
typedef void (*UniffiForeignFutureCompleteVoid)(
    uint64_t callback_data, UniffiForeignFutureStructVoid result);
typedef void (*UniffiCallbackInterfaceRpcCallbackMethod0)(
    uint64_t uniffi_handle, RustBuffer response_json, void *uniffi_out_return,
    RustCallStatus *rust_call_status);
typedef struct UniffiVTableCallbackInterfaceRpcCallback {
  UniffiCallbackInterfaceRpcCallbackMethod0 on_response;
  UniffiCallbackInterfaceFree uniffi_free;
} UniffiVTableCallbackInterfaceRpcCallback;
void *uniffi_fedimint_client_uniffi_fn_clone_rpchandler(
    void *ptr, RustCallStatus *uniffi_out_err);
void uniffi_fedimint_client_uniffi_fn_free_rpchandler(
    void *ptr, RustCallStatus *uniffi_out_err);
void *uniffi_fedimint_client_uniffi_fn_constructor_rpchandler_new(
    RustBuffer db_path, RustCallStatus *uniffi_out_err);
void uniffi_fedimint_client_uniffi_fn_method_rpchandler_rpc(
    void *ptr, RustBuffer request_json, uint64_t callback,
    RustCallStatus *uniffi_out_err);
void uniffi_fedimint_client_uniffi_fn_init_callback_vtable_rpccallback(
    UniffiVTableCallbackInterfaceRpcCallback *vtable);
RustBuffer
ffi_fedimint_client_uniffi_rustbuffer_alloc(uint64_t size,
                                            RustCallStatus *uniffi_out_err);
RustBuffer ffi_fedimint_client_uniffi_rustbuffer_from_bytes(
    ForeignBytes bytes, RustCallStatus *uniffi_out_err);
void ffi_fedimint_client_uniffi_rustbuffer_free(RustBuffer buf,
                                                RustCallStatus *uniffi_out_err);
RustBuffer ffi_fedimint_client_uniffi_rustbuffer_reserve(
    RustBuffer buf, uint64_t additional, RustCallStatus *uniffi_out_err);
void ffi_fedimint_client_uniffi_rust_future_poll_u8(
    /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
    /*handle*/ uint64_t callback_data);
void ffi_fedimint_client_uniffi_rust_future_cancel_u8(
    /*handle*/ uint64_t handle);
void ffi_fedimint_client_uniffi_rust_future_free_u8(
    /*handle*/ uint64_t handle);
uint8_t ffi_fedimint_client_uniffi_rust_future_complete_u8(
    /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
void ffi_fedimint_client_uniffi_rust_future_poll_i8(
    /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
    /*handle*/ uint64_t callback_data);
void ffi_fedimint_client_uniffi_rust_future_cancel_i8(
    /*handle*/ uint64_t handle);
void ffi_fedimint_client_uniffi_rust_future_free_i8(
    /*handle*/ uint64_t handle);
int8_t ffi_fedimint_client_uniffi_rust_future_complete_i8(
    /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
void ffi_fedimint_client_uniffi_rust_future_poll_u16(
    /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
    /*handle*/ uint64_t callback_data);
void ffi_fedimint_client_uniffi_rust_future_cancel_u16(
    /*handle*/ uint64_t handle);
void ffi_fedimint_client_uniffi_rust_future_free_u16(
    /*handle*/ uint64_t handle);
uint16_t ffi_fedimint_client_uniffi_rust_future_complete_u16(
    /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
void ffi_fedimint_client_uniffi_rust_future_poll_i16(
    /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
    /*handle*/ uint64_t callback_data);
void ffi_fedimint_client_uniffi_rust_future_cancel_i16(
    /*handle*/ uint64_t handle);
void ffi_fedimint_client_uniffi_rust_future_free_i16(
    /*handle*/ uint64_t handle);
int16_t ffi_fedimint_client_uniffi_rust_future_complete_i16(
    /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
void ffi_fedimint_client_uniffi_rust_future_poll_u32(
    /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
    /*handle*/ uint64_t callback_data);
void ffi_fedimint_client_uniffi_rust_future_cancel_u32(
    /*handle*/ uint64_t handle);
void ffi_fedimint_client_uniffi_rust_future_free_u32(
    /*handle*/ uint64_t handle);
uint32_t ffi_fedimint_client_uniffi_rust_future_complete_u32(
    /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
void ffi_fedimint_client_uniffi_rust_future_poll_i32(
    /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
    /*handle*/ uint64_t callback_data);
void ffi_fedimint_client_uniffi_rust_future_cancel_i32(
    /*handle*/ uint64_t handle);
void ffi_fedimint_client_uniffi_rust_future_free_i32(
    /*handle*/ uint64_t handle);
int32_t ffi_fedimint_client_uniffi_rust_future_complete_i32(
    /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
void ffi_fedimint_client_uniffi_rust_future_poll_u64(
    /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
    /*handle*/ uint64_t callback_data);
void ffi_fedimint_client_uniffi_rust_future_cancel_u64(
    /*handle*/ uint64_t handle);
void ffi_fedimint_client_uniffi_rust_future_free_u64(
    /*handle*/ uint64_t handle);
uint64_t ffi_fedimint_client_uniffi_rust_future_complete_u64(
    /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
void ffi_fedimint_client_uniffi_rust_future_poll_i64(
    /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
    /*handle*/ uint64_t callback_data);
void ffi_fedimint_client_uniffi_rust_future_cancel_i64(
    /*handle*/ uint64_t handle);
void ffi_fedimint_client_uniffi_rust_future_free_i64(
    /*handle*/ uint64_t handle);
int64_t ffi_fedimint_client_uniffi_rust_future_complete_i64(
    /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
void ffi_fedimint_client_uniffi_rust_future_poll_f32(
    /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
    /*handle*/ uint64_t callback_data);
void ffi_fedimint_client_uniffi_rust_future_cancel_f32(
    /*handle*/ uint64_t handle);
void ffi_fedimint_client_uniffi_rust_future_free_f32(
    /*handle*/ uint64_t handle);
float ffi_fedimint_client_uniffi_rust_future_complete_f32(
    /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
void ffi_fedimint_client_uniffi_rust_future_poll_f64(
    /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
    /*handle*/ uint64_t callback_data);
void ffi_fedimint_client_uniffi_rust_future_cancel_f64(
    /*handle*/ uint64_t handle);
void ffi_fedimint_client_uniffi_rust_future_free_f64(
    /*handle*/ uint64_t handle);
double ffi_fedimint_client_uniffi_rust_future_complete_f64(
    /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
void ffi_fedimint_client_uniffi_rust_future_poll_pointer(
    /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
    /*handle*/ uint64_t callback_data);
void ffi_fedimint_client_uniffi_rust_future_cancel_pointer(
    /*handle*/ uint64_t handle);
void ffi_fedimint_client_uniffi_rust_future_free_pointer(
    /*handle*/ uint64_t handle);
void *ffi_fedimint_client_uniffi_rust_future_complete_pointer(
    /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
void ffi_fedimint_client_uniffi_rust_future_poll_rust_buffer(
    /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
    /*handle*/ uint64_t callback_data);
void ffi_fedimint_client_uniffi_rust_future_cancel_rust_buffer(
    /*handle*/ uint64_t handle);
void ffi_fedimint_client_uniffi_rust_future_free_rust_buffer(
    /*handle*/ uint64_t handle);
RustBuffer ffi_fedimint_client_uniffi_rust_future_complete_rust_buffer(
    /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
void ffi_fedimint_client_uniffi_rust_future_poll_void(
    /*handle*/ uint64_t handle, UniffiRustFutureContinuationCallback callback,
    /*handle*/ uint64_t callback_data);
void ffi_fedimint_client_uniffi_rust_future_cancel_void(
    /*handle*/ uint64_t handle);
void ffi_fedimint_client_uniffi_rust_future_free_void(
    /*handle*/ uint64_t handle);
void ffi_fedimint_client_uniffi_rust_future_complete_void(
    /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
uint16_t uniffi_fedimint_client_uniffi_checksum_method_rpchandler_rpc();
uint16_t uniffi_fedimint_client_uniffi_checksum_constructor_rpchandler_new();
uint16_t
uniffi_fedimint_client_uniffi_checksum_method_rpccallback_on_response();
uint32_t ffi_fedimint_client_uniffi_uniffi_contract_version();
}

namespace uniffi::fedimint_client_uniffi {
template <typename T> struct Bridging;

using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <typename T> struct Bridging<ReferenceHolder<T>> {
  static jsi::Value jsNew(jsi::Runtime &rt) {
    auto holder = jsi::Object(rt);
    return holder;
  }
  static T fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
                  const jsi::Value &value) {
    auto obj = value.asObject(rt);
    if (obj.hasProperty(rt, "pointee")) {
      auto pointee = obj.getProperty(rt, "pointee");
      return uniffi::fedimint_client_uniffi::Bridging<T>::fromJs(
          rt, callInvoker, pointee);
    }
    throw jsi::JSError(rt,
                       "Expected ReferenceHolder to have a pointee property. "
                       "This is likely a bug in uniffi-bindgen-react-native");
  }
};
} // namespace uniffi::fedimint_client_uniffi
namespace uniffi::fedimint_client_uniffi {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<RustBuffer> {
  static RustBuffer rustbuffer_alloc(int32_t size) {
    RustCallStatus status = {UNIFFI_CALL_STATUS_OK};
    return ffi_fedimint_client_uniffi_rustbuffer_alloc(size, &status);
  }

  static void rustbuffer_free(RustBuffer buf) {
    RustCallStatus status = {UNIFFI_CALL_STATUS_OK};
    ffi_fedimint_client_uniffi_rustbuffer_free(buf, &status);
  }

  static RustBuffer rustbuffer_from_bytes(ForeignBytes bytes) {
    RustCallStatus status = {UNIFFI_CALL_STATUS_OK};
    return ffi_fedimint_client_uniffi_rustbuffer_from_bytes(bytes, &status);
  }

  static RustBuffer fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker>,
                           const jsi::Value &value) {
    try {
      auto buffer =
          uniffi_jsi::Bridging<jsi::ArrayBuffer>::value_to_arraybuffer(rt,
                                                                       value);
      auto bytes = ForeignBytes{
          .len = static_cast<int32_t>(buffer.length(rt)),
          .data = buffer.data(rt),
      };

      // This buffer is constructed from foreign bytes. Rust scaffolding copies
      // the bytes, to make the RustBuffer.
      auto buf = rustbuffer_from_bytes(bytes);
      // Once it leaves this function, the buffer is immediately passed back
      // into Rust, where it's used to deserialize into the Rust versions of the
      // arguments. At that point, the copy is destroyed.
      return buf;
    } catch (const std::logic_error &e) {
      throw jsi::JSError(rt, e.what());
    }
  }

  static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker>,
                         RustBuffer buf) {
    // We need to make a copy of the bytes from Rust's memory space into
    // Javascripts memory space. We need to do this because the two languages
    // manages memory very differently: a garbage collector needs to track all
    // the memory at runtime, Rust is doing it all closer to compile time.
    uint8_t *bytes = new uint8_t[buf.len];
    std::memcpy(bytes, buf.data, buf.len);

    // Construct an ArrayBuffer with copy of the bytes from the RustBuffer.
    auto payload = std::make_shared<uniffi_jsi::CMutableBuffer>(
        uniffi_jsi::CMutableBuffer((uint8_t *)bytes, buf.len));
    auto arrayBuffer = jsi::ArrayBuffer(rt, payload);

    // Once we have a Javascript version, we no longer need the Rust version, so
    // we can call into Rust to tell it it's okay to free that memory.
    rustbuffer_free(buf);

    // Finally, return the ArrayBuffer.
    return uniffi_jsi::Bridging<jsi::ArrayBuffer>::arraybuffer_to_value(
        rt, arrayBuffer);
    ;
  }
};

} // namespace uniffi::fedimint_client_uniffi

namespace uniffi::fedimint_client_uniffi {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<RustCallStatus> {
  static jsi::Value jsSuccess(jsi::Runtime &rt) {
    auto statusObject = jsi::Object(rt);
    statusObject.setProperty(rt, "code", jsi::Value(rt, UNIFFI_CALL_STATUS_OK));
    return statusObject;
  }
  static RustCallStatus rustSuccess(jsi::Runtime &rt) {
    return {UNIFFI_CALL_STATUS_OK};
  }
  static void copyIntoJs(jsi::Runtime &rt,
                         std::shared_ptr<CallInvoker> callInvoker,
                         const RustCallStatus status,
                         const jsi::Value &jsStatus) {
    auto statusObject = jsStatus.asObject(rt);
    if (status.error_buf.data != nullptr) {
      auto rbuf = Bridging<RustBuffer>::toJs(rt, callInvoker, status.error_buf);
      statusObject.setProperty(rt, "errorBuf", rbuf);
    }
    if (status.code != UNIFFI_CALL_STATUS_OK) {
      auto code =
          uniffi_jsi::Bridging<uint8_t>::toJs(rt, callInvoker, status.code);
      statusObject.setProperty(rt, "code", code);
    }
  }

  static RustCallStatus fromJs(jsi::Runtime &rt,
                               std::shared_ptr<CallInvoker> invoker,
                               const jsi::Value &jsStatus) {
    RustCallStatus status;
    auto statusObject = jsStatus.asObject(rt);
    if (statusObject.hasProperty(rt, "errorBuf")) {
      auto rbuf = statusObject.getProperty(rt, "errorBuf");
      status.error_buf = Bridging<RustBuffer>::fromJs(rt, invoker, rbuf);
    }
    if (statusObject.hasProperty(rt, "code")) {
      auto code = statusObject.getProperty(rt, "code");
      status.code = uniffi_jsi::Bridging<uint8_t>::fromJs(rt, invoker, code);
    }
    return status;
  }

  static void copyFromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> invoker,
                         const jsi::Value &jsStatus, RustCallStatus *status) {
    auto statusObject = jsStatus.asObject(rt);
    if (statusObject.hasProperty(rt, "errorBuf")) {
      auto rbuf = statusObject.getProperty(rt, "errorBuf");
      status->error_buf = Bridging<RustBuffer>::fromJs(rt, invoker, rbuf);
    }
    if (statusObject.hasProperty(rt, "code")) {
      auto code = statusObject.getProperty(rt, "code");
      status->code = uniffi_jsi::Bridging<uint8_t>::fromJs(rt, invoker, code);
    }
  }
};

} // namespace uniffi::fedimint_client_uniffi
// In other uniffi bindings, it is assumed that the foreign language holds on
// to the vtable, which the Rust just gets a pointer to.
// Here, we need to hold on to them, but also be able to clear them at just the
// right time so we can support hot-reloading.
namespace uniffi::fedimint_client_uniffi::registry {
template <typename T> class VTableHolder {
public:
  T vtable;
  VTableHolder(T v) : vtable(v) {}
};

// Mutex to bind the storage and setting of vtable together.
// We declare it here, but the lock is taken by callers of the putTable
// method who are also sending a pointer to Rust.
static std::mutex vtableMutex;

// Registry to hold all vtables so they persist even when JS objects are GC'd.
// The only reason this exists is to prevent a dangling pointer in the
// Rust machinery: i.e. we don't need to access or write to this registry
// after startup.
// Registry to hold all vtables so they persist even when JS objects are GC'd.
// Maps string identifiers to vtable holders using type erasure
static std::unordered_map<std::string, std::shared_ptr<void>> vtableRegistry;

// Add a vtable to the registry with an identifier
template <typename T>
static T *putTable(std::string_view identifier, T vtable) {
  auto holder = std::make_shared<VTableHolder<T>>(vtable);
  // Store the raw pointer to the vtable before type erasure
  T *rawPtr = &(holder->vtable);
  // Store the holder using type erasure with the string identifier
  vtableRegistry[std::string(identifier)] = std::shared_ptr<void>(holder);
  return rawPtr;
}

// Clear the registry.
//
// Conceptually, this is called after teardown of the module (i.e. after
// teardown of the jsi::Runtime). However, because Rust is dropping callbacks
// because the Runtime is being torn down, we must keep the registry intact
// until after the runtime goes away.
//
// Therefore, in practice we should call this when the next runtime is
// being stood up.
static void clearRegistry() {
  std::lock_guard<std::mutex> lock(vtableMutex);
  vtableRegistry.clear();
}
} // namespace uniffi::fedimint_client_uniffi::registry

// This calls into Rust.
// Implementation of callback function calling from Rust to JS
// RustFutureContinuationCallback

// Callback function:
// uniffi::fedimint_client_uniffi::cb::rustfuturecontinuationcallback::UniffiRustFutureContinuationCallback
//
// We have the following constraints:
// - we need to pass a function pointer to Rust.
// - we need a jsi::Runtime and jsi::Function to call into JS.
// - function pointers can't store state, so we can't use a lamda.
//
// For this, we store a lambda as a global, as `rsLambda`. The `callback`
// function calls the lambda, which itself calls the `body` which then calls
// into JS.
//
// We then give the `callback` function pointer to Rust which will call the
// lambda sometime in the future.
namespace uniffi::fedimint_client_uniffi::cb::rustfuturecontinuationcallback {
using namespace facebook;

// We need to store a lambda in a global so we can call it from
// a function pointer. The function pointer is passed to Rust.
static std::function<void(uint64_t, int8_t)> rsLambda = nullptr;

// This is the main body of the callback. It's called from the lambda,
// which itself is called from the callback function which is passed to Rust.
static void body(jsi::Runtime &rt,
                 std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
                 std::shared_ptr<jsi::Value> callbackValue, uint64_t rs_data,
                 int8_t rs_pollResult) {

  // Convert the arguments from Rust, into jsi::Values.
  // We'll use the Bridging class to do this…
  auto js_data = uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_data);
  auto js_pollResult =
      uniffi_jsi::Bridging<int8_t>::toJs(rt, callInvoker, rs_pollResult);

  // Now we are ready to call the callback.
  // We are already on the JS thread, because this `body` function was
  // invoked from the CallInvoker.
  try {
    // Getting the callback function
    auto cb = callbackValue->asObject(rt).asFunction(rt);
    auto uniffiResult = cb.call(rt, js_data, js_pollResult);

  } catch (const jsi::JSError &error) {
    std::cout << "Error in callback UniffiRustFutureContinuationCallback: "
              << error.what() << std::endl;
    throw error;
  }
}

static void callback(uint64_t rs_data, int8_t rs_pollResult) {
  // If the runtime has shutdown, then there is no point in trying to
  // call into Javascript. BUT how do we tell if the runtime has shutdown?
  //
  // Answer: the module destructor calls into callback `cleanup` method,
  // which nulls out the rsLamda.
  //
  // If rsLamda is null, then there is no runtime to call into.
  if (rsLambda == nullptr) {
    // This only occurs when destructors are calling into Rust free/drop,
    // which causes the JS callback to be dropped.
    return;
  }

  // The runtime, the actual callback jsi::funtion, and the callInvoker
  // are all in the lambda.
  rsLambda(rs_data, rs_pollResult);
}

static UniffiRustFutureContinuationCallback
makeCallbackFunction( // uniffi::fedimint_client_uniffi::cb::rustfuturecontinuationcallback
    jsi::Runtime &rt,
    std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
    const jsi::Value &value) {
  if (rsLambda != nullptr) {
    // `makeCallbackFunction` is called in two circumstances:
    //
    // 1. at startup, when initializing callback interface vtables.
    // 2. when polling futures. This happens at least once per future that is
    //    exposed to Javascript. We know that this is always the same function,
    //    `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
    //
    // We can therefore return the callback function without making anything
    // new if we've been initialized already.
    return callback;
  }
  auto callbackFunction = value.asObject(rt).asFunction(rt);
  auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
  rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_data,
                                               int8_t rs_pollResult) {
    // We immediately make a lambda which will do the work of transforming the
    // arguments into JSI values and calling the callback.
    uniffi_runtime::UniffiCallFunc jsLambda =
        [callInvoker, callbackValue, rs_data,
         rs_pollResult](jsi::Runtime &rt) mutable {
          body(rt, callInvoker, callbackValue, rs_data, rs_pollResult);
        };
    // We'll then call that lambda from the callInvoker which will
    // look after calling it on the correct thread.

    callInvoker->invokeNonBlocking(rt, jsLambda);
  };
  return callback;
}

// This method is called from the destructor of NativeFedimintClientUniffi,
// which only happens when the jsi::Runtime is being destroyed.
static void cleanup() {
  // The lambda holds a reference to the the Runtime, so when this is nulled
  // out, then the pointer will no longer be left dangling.
  rsLambda = nullptr;
}
} // namespace
  // uniffi::fedimint_client_uniffi::cb::rustfuturecontinuationcallback
  // Implementation of callback function calling from JS to Rust
  // ForeignFutureFree, passed from Rust to JS as part of async callbacks.
namespace uniffi::fedimint_client_uniffi {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureFree> {
  static jsi::Value toJs(jsi::Runtime &rt,
                         std::shared_ptr<CallInvoker> callInvoker,
                         UniffiForeignFutureFree rsCallback) {
    return jsi::Function::createFromHostFunction(
        rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureFree"), 1,
        [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
                                  const jsi::Value *arguments,
                                  size_t count) -> jsi::Value {
          return intoRust(rt, callInvoker, thisValue, arguments, count,
                          rsCallback);
        });
  }

  static jsi::Value intoRust(jsi::Runtime &rt,
                             std::shared_ptr<CallInvoker> callInvoker,
                             const jsi::Value &thisValue,
                             const jsi::Value *args, size_t count,
                             UniffiForeignFutureFree func) {
    // Convert the arguments into the Rust, with Bridging<T>::fromJs,
    // then call the rs_callback with those arguments.
    func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]));

    return jsi::Value::undefined();
  }
};
} // namespace uniffi::fedimint_client_uniffi
  // Implementation of free callback function CallbackInterfaceFree

// Callback function:
// uniffi::fedimint_client_uniffi::st::foreignfuture::foreignfuture::free::UniffiCallbackInterfaceFree
//
// We have the following constraints:
// - we need to pass a function pointer to Rust.
// - we need a jsi::Runtime and jsi::Function to call into JS.
// - function pointers can't store state, so we can't use a lamda.
//
// For this, we store a lambda as a global, as `rsLambda`. The `callback`
// function calls the lambda, which itself calls the `body` which then calls
// into JS.
//
// We then give the `callback` function pointer to Rust which will call the
// lambda sometime in the future.
namespace uniffi::fedimint_client_uniffi::st::foreignfuture::foreignfuture::
    free {
using namespace facebook;

// We need to store a lambda in a global so we can call it from
// a function pointer. The function pointer is passed to Rust.
static std::function<void(uint64_t)> rsLambda = nullptr;

// This is the main body of the callback. It's called from the lambda,
// which itself is called from the callback function which is passed to Rust.
static void body(jsi::Runtime &rt,
                 std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
                 std::shared_ptr<jsi::Value> callbackValue,
                 uint64_t rs_handle) {

  // Convert the arguments from Rust, into jsi::Values.
  // We'll use the Bridging class to do this…
  auto js_handle =
      uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_handle);

  // Now we are ready to call the callback.
  // We are already on the JS thread, because this `body` function was
  // invoked from the CallInvoker.
  try {
    // Getting the callback function
    auto cb = callbackValue->asObject(rt).asFunction(rt);
    auto uniffiResult = cb.call(rt, js_handle);

  } catch (const jsi::JSError &error) {
    std::cout << "Error in callback UniffiCallbackInterfaceFree: "
              << error.what() << std::endl;
    throw error;
  }
}

static void callback(uint64_t rs_handle) {
  // If the runtime has shutdown, then there is no point in trying to
  // call into Javascript. BUT how do we tell if the runtime has shutdown?
  //
  // Answer: the module destructor calls into callback `cleanup` method,
  // which nulls out the rsLamda.
  //
  // If rsLamda is null, then there is no runtime to call into.
  if (rsLambda == nullptr) {
    // This only occurs when destructors are calling into Rust free/drop,
    // which causes the JS callback to be dropped.
    return;
  }

  // The runtime, the actual callback jsi::funtion, and the callInvoker
  // are all in the lambda.
  rsLambda(rs_handle);
}

static UniffiCallbackInterfaceFree
makeCallbackFunction( // uniffi::fedimint_client_uniffi::st::foreignfuture::foreignfuture::free
    jsi::Runtime &rt,
    std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
    const jsi::Value &value) {
  if (rsLambda != nullptr) {
    // `makeCallbackFunction` is called in two circumstances:
    //
    // 1. at startup, when initializing callback interface vtables.
    // 2. when polling futures. This happens at least once per future that is
    //    exposed to Javascript. We know that this is always the same function,
    //    `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
    //
    // We can therefore return the callback function without making anything
    // new if we've been initialized already.
    return callback;
  }
  auto callbackFunction = value.asObject(rt).asFunction(rt);
  auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
  rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_handle) {
    // We immediately make a lambda which will do the work of transforming the
    // arguments into JSI values and calling the callback.
    uniffi_runtime::UniffiCallFunc jsLambda =
        [callInvoker, callbackValue, rs_handle](jsi::Runtime &rt) mutable {
          body(rt, callInvoker, callbackValue, rs_handle);
        };
    // We'll then call that lambda from the callInvoker which will
    // look after calling it on the correct thread.

    callInvoker->invokeNonBlocking(rt, jsLambda);
  };
  return callback;
}

// This method is called from the destructor of NativeFedimintClientUniffi,
// which only happens when the jsi::Runtime is being destroyed.
static void cleanup() {
  // The lambda holds a reference to the the Runtime, so when this is nulled
  // out, then the pointer will no longer be left dangling.
  rsLambda = nullptr;
}
} // namespace
  // uniffi::fedimint_client_uniffi::st::foreignfuture::foreignfuture::free

// Callback function:
// uniffi::fedimint_client_uniffi::st::vtablecallbackinterfacerpccallback::vtablecallbackinterfacerpccallback::free::UniffiCallbackInterfaceFree
//
// We have the following constraints:
// - we need to pass a function pointer to Rust.
// - we need a jsi::Runtime and jsi::Function to call into JS.
// - function pointers can't store state, so we can't use a lamda.
//
// For this, we store a lambda as a global, as `rsLambda`. The `callback`
// function calls the lambda, which itself calls the `body` which then calls
// into JS.
//
// We then give the `callback` function pointer to Rust which will call the
// lambda sometime in the future.
namespace uniffi::fedimint_client_uniffi::st::
    vtablecallbackinterfacerpccallback::vtablecallbackinterfacerpccallback::
        free {
using namespace facebook;

// We need to store a lambda in a global so we can call it from
// a function pointer. The function pointer is passed to Rust.
static std::function<void(uint64_t)> rsLambda = nullptr;

// This is the main body of the callback. It's called from the lambda,
// which itself is called from the callback function which is passed to Rust.
static void body(jsi::Runtime &rt,
                 std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
                 std::shared_ptr<jsi::Value> callbackValue,
                 uint64_t rs_handle) {

  // Convert the arguments from Rust, into jsi::Values.
  // We'll use the Bridging class to do this…
  auto js_handle =
      uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_handle);

  // Now we are ready to call the callback.
  // We are already on the JS thread, because this `body` function was
  // invoked from the CallInvoker.
  try {
    // Getting the callback function
    auto cb = callbackValue->asObject(rt).asFunction(rt);
    auto uniffiResult = cb.call(rt, js_handle);

  } catch (const jsi::JSError &error) {
    std::cout << "Error in callback UniffiCallbackInterfaceFree: "
              << error.what() << std::endl;
    throw error;
  }
}

static void callback(uint64_t rs_handle) {
  // If the runtime has shutdown, then there is no point in trying to
  // call into Javascript. BUT how do we tell if the runtime has shutdown?
  //
  // Answer: the module destructor calls into callback `cleanup` method,
  // which nulls out the rsLamda.
  //
  // If rsLamda is null, then there is no runtime to call into.
  if (rsLambda == nullptr) {
    // This only occurs when destructors are calling into Rust free/drop,
    // which causes the JS callback to be dropped.
    return;
  }

  // The runtime, the actual callback jsi::funtion, and the callInvoker
  // are all in the lambda.
  rsLambda(rs_handle);
}

static UniffiCallbackInterfaceFree
makeCallbackFunction( // uniffi::fedimint_client_uniffi::st::vtablecallbackinterfacerpccallback::vtablecallbackinterfacerpccallback::free
    jsi::Runtime &rt,
    std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
    const jsi::Value &value) {
  if (rsLambda != nullptr) {
    // `makeCallbackFunction` is called in two circumstances:
    //
    // 1. at startup, when initializing callback interface vtables.
    // 2. when polling futures. This happens at least once per future that is
    //    exposed to Javascript. We know that this is always the same function,
    //    `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
    //
    // We can therefore return the callback function without making anything
    // new if we've been initialized already.
    return callback;
  }
  auto callbackFunction = value.asObject(rt).asFunction(rt);
  auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
  rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_handle) {
    // We immediately make a lambda which will do the work of transforming the
    // arguments into JSI values and calling the callback.
    uniffi_runtime::UniffiCallFunc jsLambda =
        [callInvoker, callbackValue, rs_handle](jsi::Runtime &rt) mutable {
          body(rt, callInvoker, callbackValue, rs_handle);
        };
    // We'll then call that lambda from the callInvoker which will
    // look after calling it on the correct thread.

    callInvoker->invokeNonBlocking(rt, jsLambda);
  };
  return callback;
}

// This method is called from the destructor of NativeFedimintClientUniffi,
// which only happens when the jsi::Runtime is being destroyed.
static void cleanup() {
  // The lambda holds a reference to the the Runtime, so when this is nulled
  // out, then the pointer will no longer be left dangling.
  rsLambda = nullptr;
}
} // namespace
  // uniffi::fedimint_client_uniffi::st::vtablecallbackinterfacerpccallback::vtablecallbackinterfacerpccallback::free
namespace uniffi::fedimint_client_uniffi {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFuture> {
  static UniffiForeignFuture fromJs(jsi::Runtime &rt,
                                    std::shared_ptr<CallInvoker> callInvoker,
                                    const jsi::Value &jsValue) {
    // Check if the input is an object
    if (!jsValue.isObject()) {
      throw jsi::JSError(rt, "Expected an object for UniffiForeignFuture");
    }

    // Get the object from the jsi::Value
    auto jsObject = jsValue.getObject(rt);

    // Create the vtable struct
    UniffiForeignFuture rsObject;

    // Create the vtable from the js callbacks.
    rsObject.handle = uniffi_jsi::Bridging<uint64_t>::fromJs(
        rt, callInvoker, jsObject.getProperty(rt, "handle"));
    rsObject.free = uniffi::fedimint_client_uniffi::st::foreignfuture::
        foreignfuture::free::makeCallbackFunction(
            rt, callInvoker, jsObject.getProperty(rt, "free"));

    return rsObject;
  }
};

} // namespace uniffi::fedimint_client_uniffi
namespace uniffi::fedimint_client_uniffi {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureStructU8> {
  static UniffiForeignFutureStructU8
  fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
         const jsi::Value &jsValue) {
    // Check if the input is an object
    if (!jsValue.isObject()) {
      throw jsi::JSError(rt,
                         "Expected an object for UniffiForeignFutureStructU8");
    }

    // Get the object from the jsi::Value
    auto jsObject = jsValue.getObject(rt);

    // Create the vtable struct
    UniffiForeignFutureStructU8 rsObject;

    // Create the vtable from the js callbacks.
    rsObject.return_value = uniffi_jsi::Bridging<uint8_t>::fromJs(
        rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
    rsObject.call_status =
        uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::fromJs(
            rt, callInvoker, jsObject.getProperty(rt, "callStatus"));

    return rsObject;
  }
};

} // namespace uniffi::fedimint_client_uniffi
  // Implementation of callback function calling from JS to Rust
  // ForeignFutureCompleteU8, passed from Rust to JS as part of async callbacks.
namespace uniffi::fedimint_client_uniffi {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureCompleteU8> {
  static jsi::Value toJs(jsi::Runtime &rt,
                         std::shared_ptr<CallInvoker> callInvoker,
                         UniffiForeignFutureCompleteU8 rsCallback) {
    return jsi::Function::createFromHostFunction(
        rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU8"), 2,
        [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
                                  const jsi::Value *arguments,
                                  size_t count) -> jsi::Value {
          return intoRust(rt, callInvoker, thisValue, arguments, count,
                          rsCallback);
        });
  }

  static jsi::Value intoRust(jsi::Runtime &rt,
                             std::shared_ptr<CallInvoker> callInvoker,
                             const jsi::Value &thisValue,
                             const jsi::Value *args, size_t count,
                             UniffiForeignFutureCompleteU8 func) {
    // Convert the arguments into the Rust, with Bridging<T>::fromJs,
    // then call the rs_callback with those arguments.
    func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
         uniffi::fedimint_client_uniffi::Bridging<
             UniffiForeignFutureStructU8>::fromJs(rt, callInvoker, args[1]));

    return jsi::Value::undefined();
  }
};
} // namespace uniffi::fedimint_client_uniffi
namespace uniffi::fedimint_client_uniffi {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureStructI8> {
  static UniffiForeignFutureStructI8
  fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
         const jsi::Value &jsValue) {
    // Check if the input is an object
    if (!jsValue.isObject()) {
      throw jsi::JSError(rt,
                         "Expected an object for UniffiForeignFutureStructI8");
    }

    // Get the object from the jsi::Value
    auto jsObject = jsValue.getObject(rt);

    // Create the vtable struct
    UniffiForeignFutureStructI8 rsObject;

    // Create the vtable from the js callbacks.
    rsObject.return_value = uniffi_jsi::Bridging<int8_t>::fromJs(
        rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
    rsObject.call_status =
        uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::fromJs(
            rt, callInvoker, jsObject.getProperty(rt, "callStatus"));

    return rsObject;
  }
};

} // namespace uniffi::fedimint_client_uniffi
  // Implementation of callback function calling from JS to Rust
  // ForeignFutureCompleteI8, passed from Rust to JS as part of async callbacks.
namespace uniffi::fedimint_client_uniffi {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureCompleteI8> {
  static jsi::Value toJs(jsi::Runtime &rt,
                         std::shared_ptr<CallInvoker> callInvoker,
                         UniffiForeignFutureCompleteI8 rsCallback) {
    return jsi::Function::createFromHostFunction(
        rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI8"), 2,
        [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
                                  const jsi::Value *arguments,
                                  size_t count) -> jsi::Value {
          return intoRust(rt, callInvoker, thisValue, arguments, count,
                          rsCallback);
        });
  }

  static jsi::Value intoRust(jsi::Runtime &rt,
                             std::shared_ptr<CallInvoker> callInvoker,
                             const jsi::Value &thisValue,
                             const jsi::Value *args, size_t count,
                             UniffiForeignFutureCompleteI8 func) {
    // Convert the arguments into the Rust, with Bridging<T>::fromJs,
    // then call the rs_callback with those arguments.
    func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
         uniffi::fedimint_client_uniffi::Bridging<
             UniffiForeignFutureStructI8>::fromJs(rt, callInvoker, args[1]));

    return jsi::Value::undefined();
  }
};
} // namespace uniffi::fedimint_client_uniffi
namespace uniffi::fedimint_client_uniffi {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureStructU16> {
  static UniffiForeignFutureStructU16
  fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
         const jsi::Value &jsValue) {
    // Check if the input is an object
    if (!jsValue.isObject()) {
      throw jsi::JSError(rt,
                         "Expected an object for UniffiForeignFutureStructU16");
    }

    // Get the object from the jsi::Value
    auto jsObject = jsValue.getObject(rt);

    // Create the vtable struct
    UniffiForeignFutureStructU16 rsObject;

    // Create the vtable from the js callbacks.
    rsObject.return_value = uniffi_jsi::Bridging<uint16_t>::fromJs(
        rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
    rsObject.call_status =
        uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::fromJs(
            rt, callInvoker, jsObject.getProperty(rt, "callStatus"));

    return rsObject;
  }
};

} // namespace uniffi::fedimint_client_uniffi
  // Implementation of callback function calling from JS to Rust
  // ForeignFutureCompleteU16, passed from Rust to JS as part of async
  // callbacks.
namespace uniffi::fedimint_client_uniffi {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureCompleteU16> {
  static jsi::Value toJs(jsi::Runtime &rt,
                         std::shared_ptr<CallInvoker> callInvoker,
                         UniffiForeignFutureCompleteU16 rsCallback) {
    return jsi::Function::createFromHostFunction(
        rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU16"), 2,
        [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
                                  const jsi::Value *arguments,
                                  size_t count) -> jsi::Value {
          return intoRust(rt, callInvoker, thisValue, arguments, count,
                          rsCallback);
        });
  }

  static jsi::Value intoRust(jsi::Runtime &rt,
                             std::shared_ptr<CallInvoker> callInvoker,
                             const jsi::Value &thisValue,
                             const jsi::Value *args, size_t count,
                             UniffiForeignFutureCompleteU16 func) {
    // Convert the arguments into the Rust, with Bridging<T>::fromJs,
    // then call the rs_callback with those arguments.
    func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
         uniffi::fedimint_client_uniffi::Bridging<
             UniffiForeignFutureStructU16>::fromJs(rt, callInvoker, args[1]));

    return jsi::Value::undefined();
  }
};
} // namespace uniffi::fedimint_client_uniffi
namespace uniffi::fedimint_client_uniffi {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureStructI16> {
  static UniffiForeignFutureStructI16
  fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
         const jsi::Value &jsValue) {
    // Check if the input is an object
    if (!jsValue.isObject()) {
      throw jsi::JSError(rt,
                         "Expected an object for UniffiForeignFutureStructI16");
    }

    // Get the object from the jsi::Value
    auto jsObject = jsValue.getObject(rt);

    // Create the vtable struct
    UniffiForeignFutureStructI16 rsObject;

    // Create the vtable from the js callbacks.
    rsObject.return_value = uniffi_jsi::Bridging<int16_t>::fromJs(
        rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
    rsObject.call_status =
        uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::fromJs(
            rt, callInvoker, jsObject.getProperty(rt, "callStatus"));

    return rsObject;
  }
};

} // namespace uniffi::fedimint_client_uniffi
  // Implementation of callback function calling from JS to Rust
  // ForeignFutureCompleteI16, passed from Rust to JS as part of async
  // callbacks.
namespace uniffi::fedimint_client_uniffi {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureCompleteI16> {
  static jsi::Value toJs(jsi::Runtime &rt,
                         std::shared_ptr<CallInvoker> callInvoker,
                         UniffiForeignFutureCompleteI16 rsCallback) {
    return jsi::Function::createFromHostFunction(
        rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI16"), 2,
        [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
                                  const jsi::Value *arguments,
                                  size_t count) -> jsi::Value {
          return intoRust(rt, callInvoker, thisValue, arguments, count,
                          rsCallback);
        });
  }

  static jsi::Value intoRust(jsi::Runtime &rt,
                             std::shared_ptr<CallInvoker> callInvoker,
                             const jsi::Value &thisValue,
                             const jsi::Value *args, size_t count,
                             UniffiForeignFutureCompleteI16 func) {
    // Convert the arguments into the Rust, with Bridging<T>::fromJs,
    // then call the rs_callback with those arguments.
    func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
         uniffi::fedimint_client_uniffi::Bridging<
             UniffiForeignFutureStructI16>::fromJs(rt, callInvoker, args[1]));

    return jsi::Value::undefined();
  }
};
} // namespace uniffi::fedimint_client_uniffi
namespace uniffi::fedimint_client_uniffi {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureStructU32> {
  static UniffiForeignFutureStructU32
  fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
         const jsi::Value &jsValue) {
    // Check if the input is an object
    if (!jsValue.isObject()) {
      throw jsi::JSError(rt,
                         "Expected an object for UniffiForeignFutureStructU32");
    }

    // Get the object from the jsi::Value
    auto jsObject = jsValue.getObject(rt);

    // Create the vtable struct
    UniffiForeignFutureStructU32 rsObject;

    // Create the vtable from the js callbacks.
    rsObject.return_value = uniffi_jsi::Bridging<uint32_t>::fromJs(
        rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
    rsObject.call_status =
        uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::fromJs(
            rt, callInvoker, jsObject.getProperty(rt, "callStatus"));

    return rsObject;
  }
};

} // namespace uniffi::fedimint_client_uniffi
  // Implementation of callback function calling from JS to Rust
  // ForeignFutureCompleteU32, passed from Rust to JS as part of async
  // callbacks.
namespace uniffi::fedimint_client_uniffi {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureCompleteU32> {
  static jsi::Value toJs(jsi::Runtime &rt,
                         std::shared_ptr<CallInvoker> callInvoker,
                         UniffiForeignFutureCompleteU32 rsCallback) {
    return jsi::Function::createFromHostFunction(
        rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU32"), 2,
        [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
                                  const jsi::Value *arguments,
                                  size_t count) -> jsi::Value {
          return intoRust(rt, callInvoker, thisValue, arguments, count,
                          rsCallback);
        });
  }

  static jsi::Value intoRust(jsi::Runtime &rt,
                             std::shared_ptr<CallInvoker> callInvoker,
                             const jsi::Value &thisValue,
                             const jsi::Value *args, size_t count,
                             UniffiForeignFutureCompleteU32 func) {
    // Convert the arguments into the Rust, with Bridging<T>::fromJs,
    // then call the rs_callback with those arguments.
    func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
         uniffi::fedimint_client_uniffi::Bridging<
             UniffiForeignFutureStructU32>::fromJs(rt, callInvoker, args[1]));

    return jsi::Value::undefined();
  }
};
} // namespace uniffi::fedimint_client_uniffi
namespace uniffi::fedimint_client_uniffi {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureStructI32> {
  static UniffiForeignFutureStructI32
  fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
         const jsi::Value &jsValue) {
    // Check if the input is an object
    if (!jsValue.isObject()) {
      throw jsi::JSError(rt,
                         "Expected an object for UniffiForeignFutureStructI32");
    }

    // Get the object from the jsi::Value
    auto jsObject = jsValue.getObject(rt);

    // Create the vtable struct
    UniffiForeignFutureStructI32 rsObject;

    // Create the vtable from the js callbacks.
    rsObject.return_value = uniffi_jsi::Bridging<int32_t>::fromJs(
        rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
    rsObject.call_status =
        uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::fromJs(
            rt, callInvoker, jsObject.getProperty(rt, "callStatus"));

    return rsObject;
  }
};

} // namespace uniffi::fedimint_client_uniffi
  // Implementation of callback function calling from JS to Rust
  // ForeignFutureCompleteI32, passed from Rust to JS as part of async
  // callbacks.
namespace uniffi::fedimint_client_uniffi {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureCompleteI32> {
  static jsi::Value toJs(jsi::Runtime &rt,
                         std::shared_ptr<CallInvoker> callInvoker,
                         UniffiForeignFutureCompleteI32 rsCallback) {
    return jsi::Function::createFromHostFunction(
        rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI32"), 2,
        [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
                                  const jsi::Value *arguments,
                                  size_t count) -> jsi::Value {
          return intoRust(rt, callInvoker, thisValue, arguments, count,
                          rsCallback);
        });
  }

  static jsi::Value intoRust(jsi::Runtime &rt,
                             std::shared_ptr<CallInvoker> callInvoker,
                             const jsi::Value &thisValue,
                             const jsi::Value *args, size_t count,
                             UniffiForeignFutureCompleteI32 func) {
    // Convert the arguments into the Rust, with Bridging<T>::fromJs,
    // then call the rs_callback with those arguments.
    func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
         uniffi::fedimint_client_uniffi::Bridging<
             UniffiForeignFutureStructI32>::fromJs(rt, callInvoker, args[1]));

    return jsi::Value::undefined();
  }
};
} // namespace uniffi::fedimint_client_uniffi
namespace uniffi::fedimint_client_uniffi {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureStructU64> {
  static UniffiForeignFutureStructU64
  fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
         const jsi::Value &jsValue) {
    // Check if the input is an object
    if (!jsValue.isObject()) {
      throw jsi::JSError(rt,
                         "Expected an object for UniffiForeignFutureStructU64");
    }

    // Get the object from the jsi::Value
    auto jsObject = jsValue.getObject(rt);

    // Create the vtable struct
    UniffiForeignFutureStructU64 rsObject;

    // Create the vtable from the js callbacks.
    rsObject.return_value = uniffi_jsi::Bridging<uint64_t>::fromJs(
        rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
    rsObject.call_status =
        uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::fromJs(
            rt, callInvoker, jsObject.getProperty(rt, "callStatus"));

    return rsObject;
  }
};

} // namespace uniffi::fedimint_client_uniffi
  // Implementation of callback function calling from JS to Rust
  // ForeignFutureCompleteU64, passed from Rust to JS as part of async
  // callbacks.
namespace uniffi::fedimint_client_uniffi {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureCompleteU64> {
  static jsi::Value toJs(jsi::Runtime &rt,
                         std::shared_ptr<CallInvoker> callInvoker,
                         UniffiForeignFutureCompleteU64 rsCallback) {
    return jsi::Function::createFromHostFunction(
        rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU64"), 2,
        [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
                                  const jsi::Value *arguments,
                                  size_t count) -> jsi::Value {
          return intoRust(rt, callInvoker, thisValue, arguments, count,
                          rsCallback);
        });
  }

  static jsi::Value intoRust(jsi::Runtime &rt,
                             std::shared_ptr<CallInvoker> callInvoker,
                             const jsi::Value &thisValue,
                             const jsi::Value *args, size_t count,
                             UniffiForeignFutureCompleteU64 func) {
    // Convert the arguments into the Rust, with Bridging<T>::fromJs,
    // then call the rs_callback with those arguments.
    func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
         uniffi::fedimint_client_uniffi::Bridging<
             UniffiForeignFutureStructU64>::fromJs(rt, callInvoker, args[1]));

    return jsi::Value::undefined();
  }
};
} // namespace uniffi::fedimint_client_uniffi
namespace uniffi::fedimint_client_uniffi {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureStructI64> {
  static UniffiForeignFutureStructI64
  fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
         const jsi::Value &jsValue) {
    // Check if the input is an object
    if (!jsValue.isObject()) {
      throw jsi::JSError(rt,
                         "Expected an object for UniffiForeignFutureStructI64");
    }

    // Get the object from the jsi::Value
    auto jsObject = jsValue.getObject(rt);

    // Create the vtable struct
    UniffiForeignFutureStructI64 rsObject;

    // Create the vtable from the js callbacks.
    rsObject.return_value = uniffi_jsi::Bridging<int64_t>::fromJs(
        rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
    rsObject.call_status =
        uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::fromJs(
            rt, callInvoker, jsObject.getProperty(rt, "callStatus"));

    return rsObject;
  }
};

} // namespace uniffi::fedimint_client_uniffi
  // Implementation of callback function calling from JS to Rust
  // ForeignFutureCompleteI64, passed from Rust to JS as part of async
  // callbacks.
namespace uniffi::fedimint_client_uniffi {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureCompleteI64> {
  static jsi::Value toJs(jsi::Runtime &rt,
                         std::shared_ptr<CallInvoker> callInvoker,
                         UniffiForeignFutureCompleteI64 rsCallback) {
    return jsi::Function::createFromHostFunction(
        rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI64"), 2,
        [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
                                  const jsi::Value *arguments,
                                  size_t count) -> jsi::Value {
          return intoRust(rt, callInvoker, thisValue, arguments, count,
                          rsCallback);
        });
  }

  static jsi::Value intoRust(jsi::Runtime &rt,
                             std::shared_ptr<CallInvoker> callInvoker,
                             const jsi::Value &thisValue,
                             const jsi::Value *args, size_t count,
                             UniffiForeignFutureCompleteI64 func) {
    // Convert the arguments into the Rust, with Bridging<T>::fromJs,
    // then call the rs_callback with those arguments.
    func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
         uniffi::fedimint_client_uniffi::Bridging<
             UniffiForeignFutureStructI64>::fromJs(rt, callInvoker, args[1]));

    return jsi::Value::undefined();
  }
};
} // namespace uniffi::fedimint_client_uniffi
namespace uniffi::fedimint_client_uniffi {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureStructF32> {
  static UniffiForeignFutureStructF32
  fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
         const jsi::Value &jsValue) {
    // Check if the input is an object
    if (!jsValue.isObject()) {
      throw jsi::JSError(rt,
                         "Expected an object for UniffiForeignFutureStructF32");
    }

    // Get the object from the jsi::Value
    auto jsObject = jsValue.getObject(rt);

    // Create the vtable struct
    UniffiForeignFutureStructF32 rsObject;

    // Create the vtable from the js callbacks.
    rsObject.return_value = uniffi_jsi::Bridging<float>::fromJs(
        rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
    rsObject.call_status =
        uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::fromJs(
            rt, callInvoker, jsObject.getProperty(rt, "callStatus"));

    return rsObject;
  }
};

} // namespace uniffi::fedimint_client_uniffi
  // Implementation of callback function calling from JS to Rust
  // ForeignFutureCompleteF32, passed from Rust to JS as part of async
  // callbacks.
namespace uniffi::fedimint_client_uniffi {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureCompleteF32> {
  static jsi::Value toJs(jsi::Runtime &rt,
                         std::shared_ptr<CallInvoker> callInvoker,
                         UniffiForeignFutureCompleteF32 rsCallback) {
    return jsi::Function::createFromHostFunction(
        rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteF32"), 2,
        [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
                                  const jsi::Value *arguments,
                                  size_t count) -> jsi::Value {
          return intoRust(rt, callInvoker, thisValue, arguments, count,
                          rsCallback);
        });
  }

  static jsi::Value intoRust(jsi::Runtime &rt,
                             std::shared_ptr<CallInvoker> callInvoker,
                             const jsi::Value &thisValue,
                             const jsi::Value *args, size_t count,
                             UniffiForeignFutureCompleteF32 func) {
    // Convert the arguments into the Rust, with Bridging<T>::fromJs,
    // then call the rs_callback with those arguments.
    func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
         uniffi::fedimint_client_uniffi::Bridging<
             UniffiForeignFutureStructF32>::fromJs(rt, callInvoker, args[1]));

    return jsi::Value::undefined();
  }
};
} // namespace uniffi::fedimint_client_uniffi
namespace uniffi::fedimint_client_uniffi {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureStructF64> {
  static UniffiForeignFutureStructF64
  fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
         const jsi::Value &jsValue) {
    // Check if the input is an object
    if (!jsValue.isObject()) {
      throw jsi::JSError(rt,
                         "Expected an object for UniffiForeignFutureStructF64");
    }

    // Get the object from the jsi::Value
    auto jsObject = jsValue.getObject(rt);

    // Create the vtable struct
    UniffiForeignFutureStructF64 rsObject;

    // Create the vtable from the js callbacks.
    rsObject.return_value = uniffi_jsi::Bridging<double>::fromJs(
        rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
    rsObject.call_status =
        uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::fromJs(
            rt, callInvoker, jsObject.getProperty(rt, "callStatus"));

    return rsObject;
  }
};

} // namespace uniffi::fedimint_client_uniffi
  // Implementation of callback function calling from JS to Rust
  // ForeignFutureCompleteF64, passed from Rust to JS as part of async
  // callbacks.
namespace uniffi::fedimint_client_uniffi {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureCompleteF64> {
  static jsi::Value toJs(jsi::Runtime &rt,
                         std::shared_ptr<CallInvoker> callInvoker,
                         UniffiForeignFutureCompleteF64 rsCallback) {
    return jsi::Function::createFromHostFunction(
        rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteF64"), 2,
        [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
                                  const jsi::Value *arguments,
                                  size_t count) -> jsi::Value {
          return intoRust(rt, callInvoker, thisValue, arguments, count,
                          rsCallback);
        });
  }

  static jsi::Value intoRust(jsi::Runtime &rt,
                             std::shared_ptr<CallInvoker> callInvoker,
                             const jsi::Value &thisValue,
                             const jsi::Value *args, size_t count,
                             UniffiForeignFutureCompleteF64 func) {
    // Convert the arguments into the Rust, with Bridging<T>::fromJs,
    // then call the rs_callback with those arguments.
    func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
         uniffi::fedimint_client_uniffi::Bridging<
             UniffiForeignFutureStructF64>::fromJs(rt, callInvoker, args[1]));

    return jsi::Value::undefined();
  }
};
} // namespace uniffi::fedimint_client_uniffi
namespace uniffi::fedimint_client_uniffi {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureStructPointer> {
  static UniffiForeignFutureStructPointer
  fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
         const jsi::Value &jsValue) {
    // Check if the input is an object
    if (!jsValue.isObject()) {
      throw jsi::JSError(
          rt, "Expected an object for UniffiForeignFutureStructPointer");
    }

    // Get the object from the jsi::Value
    auto jsObject = jsValue.getObject(rt);

    // Create the vtable struct
    UniffiForeignFutureStructPointer rsObject;

    // Create the vtable from the js callbacks.
    rsObject.return_value = uniffi_jsi::Bridging<void *>::fromJs(
        rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
    rsObject.call_status =
        uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::fromJs(
            rt, callInvoker, jsObject.getProperty(rt, "callStatus"));

    return rsObject;
  }
};

} // namespace uniffi::fedimint_client_uniffi
  // Implementation of callback function calling from JS to Rust
  // ForeignFutureCompletePointer, passed from Rust to JS as part of async
  // callbacks.
namespace uniffi::fedimint_client_uniffi {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureCompletePointer> {
  static jsi::Value toJs(jsi::Runtime &rt,
                         std::shared_ptr<CallInvoker> callInvoker,
                         UniffiForeignFutureCompletePointer rsCallback) {
    return jsi::Function::createFromHostFunction(
        rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompletePointer"), 2,
        [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
                                  const jsi::Value *arguments,
                                  size_t count) -> jsi::Value {
          return intoRust(rt, callInvoker, thisValue, arguments, count,
                          rsCallback);
        });
  }

  static jsi::Value intoRust(jsi::Runtime &rt,
                             std::shared_ptr<CallInvoker> callInvoker,
                             const jsi::Value &thisValue,
                             const jsi::Value *args, size_t count,
                             UniffiForeignFutureCompletePointer func) {
    // Convert the arguments into the Rust, with Bridging<T>::fromJs,
    // then call the rs_callback with those arguments.
    func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
         uniffi::fedimint_client_uniffi::Bridging<
             UniffiForeignFutureStructPointer>::fromJs(rt, callInvoker,
                                                       args[1]));

    return jsi::Value::undefined();
  }
};
} // namespace uniffi::fedimint_client_uniffi
namespace uniffi::fedimint_client_uniffi {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureStructRustBuffer> {
  static UniffiForeignFutureStructRustBuffer
  fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
         const jsi::Value &jsValue) {
    // Check if the input is an object
    if (!jsValue.isObject()) {
      throw jsi::JSError(
          rt, "Expected an object for UniffiForeignFutureStructRustBuffer");
    }

    // Get the object from the jsi::Value
    auto jsObject = jsValue.getObject(rt);

    // Create the vtable struct
    UniffiForeignFutureStructRustBuffer rsObject;

    // Create the vtable from the js callbacks.
    rsObject.return_value =
        uniffi::fedimint_client_uniffi::Bridging<RustBuffer>::fromJs(
            rt, callInvoker, jsObject.getProperty(rt, "returnValue"));
    rsObject.call_status =
        uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::fromJs(
            rt, callInvoker, jsObject.getProperty(rt, "callStatus"));

    return rsObject;
  }
};

} // namespace uniffi::fedimint_client_uniffi
  // Implementation of callback function calling from JS to Rust
  // ForeignFutureCompleteRustBuffer, passed from Rust to JS as part of async
  // callbacks.
namespace uniffi::fedimint_client_uniffi {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureCompleteRustBuffer> {
  static jsi::Value toJs(jsi::Runtime &rt,
                         std::shared_ptr<CallInvoker> callInvoker,
                         UniffiForeignFutureCompleteRustBuffer rsCallback) {
    return jsi::Function::createFromHostFunction(
        rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteRustBuffer"),
        2,
        [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
                                  const jsi::Value *arguments,
                                  size_t count) -> jsi::Value {
          return intoRust(rt, callInvoker, thisValue, arguments, count,
                          rsCallback);
        });
  }

  static jsi::Value intoRust(jsi::Runtime &rt,
                             std::shared_ptr<CallInvoker> callInvoker,
                             const jsi::Value &thisValue,
                             const jsi::Value *args, size_t count,
                             UniffiForeignFutureCompleteRustBuffer func) {
    // Convert the arguments into the Rust, with Bridging<T>::fromJs,
    // then call the rs_callback with those arguments.
    func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
         uniffi::fedimint_client_uniffi::Bridging<
             UniffiForeignFutureStructRustBuffer>::fromJs(rt, callInvoker,
                                                          args[1]));

    return jsi::Value::undefined();
  }
};
} // namespace uniffi::fedimint_client_uniffi
namespace uniffi::fedimint_client_uniffi {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureStructVoid> {
  static UniffiForeignFutureStructVoid
  fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
         const jsi::Value &jsValue) {
    // Check if the input is an object
    if (!jsValue.isObject()) {
      throw jsi::JSError(
          rt, "Expected an object for UniffiForeignFutureStructVoid");
    }

    // Get the object from the jsi::Value
    auto jsObject = jsValue.getObject(rt);

    // Create the vtable struct
    UniffiForeignFutureStructVoid rsObject;

    // Create the vtable from the js callbacks.
    rsObject.call_status =
        uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::fromJs(
            rt, callInvoker, jsObject.getProperty(rt, "callStatus"));

    return rsObject;
  }
};

} // namespace uniffi::fedimint_client_uniffi
  // Implementation of callback function calling from JS to Rust
  // ForeignFutureCompleteVoid, passed from Rust to JS as part of async
  // callbacks.
namespace uniffi::fedimint_client_uniffi {
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiForeignFutureCompleteVoid> {
  static jsi::Value toJs(jsi::Runtime &rt,
                         std::shared_ptr<CallInvoker> callInvoker,
                         UniffiForeignFutureCompleteVoid rsCallback) {
    return jsi::Function::createFromHostFunction(
        rt, jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteVoid"), 2,
        [rsCallback, callInvoker](jsi::Runtime &rt, const jsi::Value &thisValue,
                                  const jsi::Value *arguments,
                                  size_t count) -> jsi::Value {
          return intoRust(rt, callInvoker, thisValue, arguments, count,
                          rsCallback);
        });
  }

  static jsi::Value intoRust(jsi::Runtime &rt,
                             std::shared_ptr<CallInvoker> callInvoker,
                             const jsi::Value &thisValue,
                             const jsi::Value *args, size_t count,
                             UniffiForeignFutureCompleteVoid func) {
    // Convert the arguments into the Rust, with Bridging<T>::fromJs,
    // then call the rs_callback with those arguments.
    func(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]),
         uniffi::fedimint_client_uniffi::Bridging<
             UniffiForeignFutureStructVoid>::fromJs(rt, callInvoker, args[1]));

    return jsi::Value::undefined();
  }
};
} // namespace uniffi::fedimint_client_uniffi
  // Implementation of callback function calling from Rust to JS
  // CallbackInterfaceRpcCallbackMethod0

// Callback function:
// uniffi::fedimint_client_uniffi::cb::callbackinterfacerpccallbackmethod0::UniffiCallbackInterfaceRpcCallbackMethod0
//
// We have the following constraints:
// - we need to pass a function pointer to Rust.
// - we need a jsi::Runtime and jsi::Function to call into JS.
// - function pointers can't store state, so we can't use a lamda.
//
// For this, we store a lambda as a global, as `rsLambda`. The `callback`
// function calls the lambda, which itself calls the `body` which then calls
// into JS.
//
// We then give the `callback` function pointer to Rust which will call the
// lambda sometime in the future.
namespace uniffi::fedimint_client_uniffi::cb::
    callbackinterfacerpccallbackmethod0 {
using namespace facebook;

// We need to store a lambda in a global so we can call it from
// a function pointer. The function pointer is passed to Rust.
static std::function<void(uint64_t, RustBuffer, void *, RustCallStatus *)>
    rsLambda = nullptr;

// This is the main body of the callback. It's called from the lambda,
// which itself is called from the callback function which is passed to Rust.
static void body(jsi::Runtime &rt,
                 std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
                 std::shared_ptr<jsi::Value> callbackValue,
                 uint64_t rs_uniffiHandle, RustBuffer rs_responseJson,
                 void *rs_uniffiOutReturn, RustCallStatus *uniffi_call_status) {

  // Convert the arguments from Rust, into jsi::Values.
  // We'll use the Bridging class to do this…
  auto js_uniffiHandle =
      uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_uniffiHandle);
  auto js_responseJson =
      uniffi::fedimint_client_uniffi::Bridging<RustBuffer>::toJs(
          rt, callInvoker, rs_responseJson);

  // Now we are ready to call the callback.
  // We are already on the JS thread, because this `body` function was
  // invoked from the CallInvoker.
  try {
    // Getting the callback function
    auto cb = callbackValue->asObject(rt).asFunction(rt);
    auto uniffiResult = cb.call(rt, js_uniffiHandle, js_responseJson);

    // Now copy the result back from JS into the RustCallStatus object.
    uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::copyFromJs(
        rt, callInvoker, uniffiResult, uniffi_call_status);

    if (uniffi_call_status->code != UNIFFI_CALL_STATUS_OK) {
      // The JS callback finished abnormally, so we cannot retrieve the return
      // value.
      return;
    }

  } catch (const jsi::JSError &error) {
    std::cout << "Error in callback UniffiCallbackInterfaceRpcCallbackMethod0: "
              << error.what() << std::endl;
    throw error;
  }
}

static void callback(uint64_t rs_uniffiHandle, RustBuffer rs_responseJson,
                     void *rs_uniffiOutReturn,
                     RustCallStatus *uniffi_call_status) {
  // If the runtime has shutdown, then there is no point in trying to
  // call into Javascript. BUT how do we tell if the runtime has shutdown?
  //
  // Answer: the module destructor calls into callback `cleanup` method,
  // which nulls out the rsLamda.
  //
  // If rsLamda is null, then there is no runtime to call into.
  if (rsLambda == nullptr) {
    // This only occurs when destructors are calling into Rust free/drop,
    // which causes the JS callback to be dropped.
    return;
  }

  // The runtime, the actual callback jsi::funtion, and the callInvoker
  // are all in the lambda.
  rsLambda(rs_uniffiHandle, rs_responseJson, rs_uniffiOutReturn,
           uniffi_call_status);
}

static UniffiCallbackInterfaceRpcCallbackMethod0
makeCallbackFunction( // uniffi::fedimint_client_uniffi::cb::callbackinterfacerpccallbackmethod0
    jsi::Runtime &rt,
    std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
    const jsi::Value &value) {
  if (rsLambda != nullptr) {
    // `makeCallbackFunction` is called in two circumstances:
    //
    // 1. at startup, when initializing callback interface vtables.
    // 2. when polling futures. This happens at least once per future that is
    //    exposed to Javascript. We know that this is always the same function,
    //    `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
    //
    // We can therefore return the callback function without making anything
    // new if we've been initialized already.
    return callback;
  }
  auto callbackFunction = value.asObject(rt).asFunction(rt);
  auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
  rsLambda = [&rt, callInvoker, callbackValue](
                 uint64_t rs_uniffiHandle, RustBuffer rs_responseJson,
                 void *rs_uniffiOutReturn, RustCallStatus *uniffi_call_status) {
    // We immediately make a lambda which will do the work of transforming the
    // arguments into JSI values and calling the callback.
    uniffi_runtime::UniffiCallFunc jsLambda =
        [callInvoker, callbackValue, rs_uniffiHandle, rs_responseJson,
         rs_uniffiOutReturn, uniffi_call_status](jsi::Runtime &rt) mutable {
          body(rt, callInvoker, callbackValue, rs_uniffiHandle, rs_responseJson,
               rs_uniffiOutReturn, uniffi_call_status);
        };
    // We'll then call that lambda from the callInvoker which will
    // look after calling it on the correct thread.
    callInvoker->invokeBlocking(rt, jsLambda);
  };
  return callback;
}

// This method is called from the destructor of NativeFedimintClientUniffi,
// which only happens when the jsi::Runtime is being destroyed.
static void cleanup() {
  // The lambda holds a reference to the the Runtime, so when this is nulled
  // out, then the pointer will no longer be left dangling.
  rsLambda = nullptr;
}
} // namespace
  // uniffi::fedimint_client_uniffi::cb::callbackinterfacerpccallbackmethod0
namespace uniffi::fedimint_client_uniffi {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiVTableCallbackInterfaceRpcCallback> {
  static UniffiVTableCallbackInterfaceRpcCallback
  fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
         const jsi::Value &jsValue) {
    // Check if the input is an object
    if (!jsValue.isObject()) {
      throw jsi::JSError(
          rt,
          "Expected an object for UniffiVTableCallbackInterfaceRpcCallback");
    }

    // Get the object from the jsi::Value
    auto jsObject = jsValue.getObject(rt);

    // Create the vtable struct
    UniffiVTableCallbackInterfaceRpcCallback rsObject;

    // Create the vtable from the js callbacks.
    rsObject.on_response = uniffi::fedimint_client_uniffi::cb::
        callbackinterfacerpccallbackmethod0::makeCallbackFunction(
            rt, callInvoker, jsObject.getProperty(rt, "onResponse"));
    rsObject.uniffi_free =
        uniffi::fedimint_client_uniffi::st::vtablecallbackinterfacerpccallback::
            vtablecallbackinterfacerpccallback::free::makeCallbackFunction(
                rt, callInvoker, jsObject.getProperty(rt, "uniffiFree"));

    return rsObject;
  }
};

} // namespace uniffi::fedimint_client_uniffi

namespace uniffi::fedimint_client_uniffi {
using namespace facebook;
using CallInvoker = uniffi_runtime::UniffiCallInvoker;

template <> struct Bridging<UniffiRustFutureContinuationCallback> {
  static UniffiRustFutureContinuationCallback
  fromJs(jsi::Runtime &rt, std::shared_ptr<CallInvoker> callInvoker,
         const jsi::Value &value) {
    try {
      return uniffi::fedimint_client_uniffi::cb::
          rustfuturecontinuationcallback::makeCallbackFunction(rt, callInvoker,
                                                               value);
    } catch (const std::logic_error &e) {
      throw jsi::JSError(rt, e.what());
    }
  }
};

} // namespace uniffi::fedimint_client_uniffi

NativeFedimintClientUniffi::NativeFedimintClientUniffi(
    jsi::Runtime &rt,
    std::shared_ptr<uniffi_runtime::UniffiCallInvoker> invoker)
    : callInvoker(invoker), props() {
  // Map from Javascript names to the cpp names
  props["ubrn_uniffi_internal_fn_func_ffi__string_to_byte_length"] =
      jsi::Function::createFromHostFunction(
          rt,
          jsi::PropNameID::forAscii(
              rt, "ubrn_uniffi_internal_fn_func_ffi__string_to_byte_length"),
          1,
          [this](jsi::Runtime &rt, const jsi::Value &thisVal,
                 const jsi::Value *args, size_t count) -> jsi::Value {
            return this->cpp_uniffi_internal_fn_func_ffi__string_to_byte_length(
                rt, thisVal, args, count);
          });
  props["ubrn_uniffi_internal_fn_func_ffi__string_to_arraybuffer"] =
      jsi::Function::createFromHostFunction(
          rt,
          jsi::PropNameID::forAscii(
              rt, "ubrn_uniffi_internal_fn_func_ffi__string_to_arraybuffer"),
          1,
          [this](jsi::Runtime &rt, const jsi::Value &thisVal,
                 const jsi::Value *args, size_t count) -> jsi::Value {
            return this->cpp_uniffi_internal_fn_func_ffi__string_to_arraybuffer(
                rt, thisVal, args, count);
          });
  props["ubrn_uniffi_internal_fn_func_ffi__arraybuffer_to_string"] =
      jsi::Function::createFromHostFunction(
          rt,
          jsi::PropNameID::forAscii(
              rt, "ubrn_uniffi_internal_fn_func_ffi__arraybuffer_to_string"),
          1,
          [this](jsi::Runtime &rt, const jsi::Value &thisVal,
                 const jsi::Value *args, size_t count) -> jsi::Value {
            return this->cpp_uniffi_internal_fn_func_ffi__arraybuffer_to_string(
                rt, thisVal, args, count);
          });
  props["ubrn_uniffi_fedimint_client_uniffi_fn_clone_rpchandler"] =
      jsi::Function::createFromHostFunction(
          rt,
          jsi::PropNameID::forAscii(
              rt, "ubrn_uniffi_fedimint_client_uniffi_fn_clone_rpchandler"),
          1,
          [this](jsi::Runtime &rt, const jsi::Value &thisVal,
                 const jsi::Value *args, size_t count) -> jsi::Value {
            return this->cpp_uniffi_fedimint_client_uniffi_fn_clone_rpchandler(
                rt, thisVal, args, count);
          });
  props["ubrn_uniffi_fedimint_client_uniffi_fn_free_rpchandler"] =
      jsi::Function::createFromHostFunction(
          rt,
          jsi::PropNameID::forAscii(
              rt, "ubrn_uniffi_fedimint_client_uniffi_fn_free_rpchandler"),
          1,
          [this](jsi::Runtime &rt, const jsi::Value &thisVal,
                 const jsi::Value *args, size_t count) -> jsi::Value {
            return this->cpp_uniffi_fedimint_client_uniffi_fn_free_rpchandler(
                rt, thisVal, args, count);
          });
  props["ubrn_uniffi_fedimint_client_uniffi_fn_constructor_rpchandler_new"] =
      jsi::Function::createFromHostFunction(
          rt,
          jsi::PropNameID::forAscii(rt, "ubrn_uniffi_fedimint_client_uniffi_fn_"
                                        "constructor_rpchandler_new"),
          1,
          [this](jsi::Runtime &rt, const jsi::Value &thisVal,
                 const jsi::Value *args, size_t count) -> jsi::Value {
            return this
                ->cpp_uniffi_fedimint_client_uniffi_fn_constructor_rpchandler_new(
                    rt, thisVal, args, count);
          });
  props["ubrn_uniffi_fedimint_client_uniffi_fn_method_rpchandler_rpc"] =
      jsi::Function::createFromHostFunction(
          rt,
          jsi::PropNameID::forAscii(
              rt,
              "ubrn_uniffi_fedimint_client_uniffi_fn_method_rpchandler_rpc"),
          3,
          [this](jsi::Runtime &rt, const jsi::Value &thisVal,
                 const jsi::Value *args, size_t count) -> jsi::Value {
            return this
                ->cpp_uniffi_fedimint_client_uniffi_fn_method_rpchandler_rpc(
                    rt, thisVal, args, count);
          });
  props["ubrn_uniffi_fedimint_client_uniffi_fn_init_callback_vtable_"
        "rpccallback"] = jsi::Function::createFromHostFunction(
      rt,
      jsi::PropNameID::forAscii(rt, "ubrn_uniffi_fedimint_client_uniffi_fn_"
                                    "init_callback_vtable_rpccallback"),
      1,
      [this](jsi::Runtime &rt, const jsi::Value &thisVal,
             const jsi::Value *args, size_t count) -> jsi::Value {
        return this
            ->cpp_uniffi_fedimint_client_uniffi_fn_init_callback_vtable_rpccallback(
                rt, thisVal, args, count);
      });
  props["ubrn_uniffi_fedimint_client_uniffi_checksum_method_rpchandler_rpc"] =
      jsi::Function::createFromHostFunction(
          rt,
          jsi::PropNameID::forAscii(rt, "ubrn_uniffi_fedimint_client_uniffi_"
                                        "checksum_method_rpchandler_rpc"),
          0,
          [this](jsi::Runtime &rt, const jsi::Value &thisVal,
                 const jsi::Value *args, size_t count) -> jsi::Value {
            return this
                ->cpp_uniffi_fedimint_client_uniffi_checksum_method_rpchandler_rpc(
                    rt, thisVal, args, count);
          });
  props["ubrn_uniffi_fedimint_client_uniffi_checksum_constructor_rpchandler_"
        "new"] = jsi::Function::createFromHostFunction(
      rt,
      jsi::PropNameID::forAscii(rt, "ubrn_uniffi_fedimint_client_uniffi_"
                                    "checksum_constructor_rpchandler_new"),
      0,
      [this](jsi::Runtime &rt, const jsi::Value &thisVal,
             const jsi::Value *args, size_t count) -> jsi::Value {
        return this
            ->cpp_uniffi_fedimint_client_uniffi_checksum_constructor_rpchandler_new(
                rt, thisVal, args, count);
      });
  props["ubrn_uniffi_fedimint_client_uniffi_checksum_method_rpccallback_on_"
        "response"] = jsi::Function::createFromHostFunction(
      rt,
      jsi::PropNameID::forAscii(rt, "ubrn_uniffi_fedimint_client_uniffi_"
                                    "checksum_method_rpccallback_on_response"),
      0,
      [this](jsi::Runtime &rt, const jsi::Value &thisVal,
             const jsi::Value *args, size_t count) -> jsi::Value {
        return this
            ->cpp_uniffi_fedimint_client_uniffi_checksum_method_rpccallback_on_response(
                rt, thisVal, args, count);
      });
  props["ubrn_ffi_fedimint_client_uniffi_uniffi_contract_version"] =
      jsi::Function::createFromHostFunction(
          rt,
          jsi::PropNameID::forAscii(
              rt, "ubrn_ffi_fedimint_client_uniffi_uniffi_contract_version"),
          0,
          [this](jsi::Runtime &rt, const jsi::Value &thisVal,
                 const jsi::Value *args, size_t count) -> jsi::Value {
            return this->cpp_ffi_fedimint_client_uniffi_uniffi_contract_version(
                rt, thisVal, args, count);
          });
  props["ubrn_uniffi_internal_fn_method_rpchandler_ffi__bless_pointer"] =
      jsi::Function::createFromHostFunction(
          rt,
          jsi::PropNameID::forAscii(
              rt,
              "ubrn_uniffi_internal_fn_method_rpchandler_ffi__bless_pointer"),
          1,
          [this](jsi::Runtime &rt, const jsi::Value &thisVal,
                 const jsi::Value *args, size_t count) -> jsi::Value {
            return this
                ->cpp_uniffi_internal_fn_method_rpchandler_ffi__bless_pointer(
                    rt, thisVal, args, count);
          });
}

void NativeFedimintClientUniffi::registerModule(
    jsi::Runtime &rt, std::shared_ptr<react::CallInvoker> callInvoker) {
  auto invoker =
      std::make_shared<uniffi_runtime::UniffiCallInvoker>(callInvoker);
  auto tm = std::make_shared<NativeFedimintClientUniffi>(rt, invoker);
  auto obj = rt.global().createFromHostObject(rt, tm);
  rt.global().setProperty(rt, "NativeFedimintClientUniffi", obj);
}

void NativeFedimintClientUniffi::unregisterModule(jsi::Runtime &rt) {
  uniffi::fedimint_client_uniffi::registry::clearRegistry();
}

jsi::Value NativeFedimintClientUniffi::get(jsi::Runtime &rt,
                                           const jsi::PropNameID &name) {
  try {
    return jsi::Value(rt, props.at(name.utf8(rt)));
  } catch (std::out_of_range &e) {
    return jsi::Value::undefined();
  }
}

std::vector<jsi::PropNameID>
NativeFedimintClientUniffi::getPropertyNames(jsi::Runtime &rt) {
  std::vector<jsi::PropNameID> rval;
  for (auto &[key, value] : props) {
    rval.push_back(jsi::PropNameID::forUtf8(rt, key));
  }
  return rval;
}

void NativeFedimintClientUniffi::set(jsi::Runtime &rt,
                                     const jsi::PropNameID &name,
                                     const jsi::Value &value) {
  props.insert_or_assign(name.utf8(rt), &value);
}

NativeFedimintClientUniffi::~NativeFedimintClientUniffi() {
  // Cleanup for callback function RustFutureContinuationCallback
  uniffi::fedimint_client_uniffi::cb::rustfuturecontinuationcallback::cleanup();
  // Cleanup for "free" callback function CallbackInterfaceFree
  uniffi::fedimint_client_uniffi::st::foreignfuture::foreignfuture::free::
      cleanup();
  uniffi::fedimint_client_uniffi::st::vtablecallbackinterfacerpccallback::
      vtablecallbackinterfacerpccallback::free::cleanup();
  // Cleanup for callback function CallbackInterfaceRpcCallbackMethod0
  uniffi::fedimint_client_uniffi::cb::callbackinterfacerpccallbackmethod0::
      cleanup();
}

// Utility functions for serialization/deserialization of strings.
jsi::Value NativeFedimintClientUniffi::
    cpp_uniffi_internal_fn_func_ffi__string_to_byte_length(
        jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
        size_t count) {
  return uniffi_jsi::Bridging<std::string>::string_to_bytelength(rt, args[0]);
}

jsi::Value NativeFedimintClientUniffi::
    cpp_uniffi_internal_fn_func_ffi__string_to_arraybuffer(
        jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
        size_t count) {
  return uniffi_jsi::Bridging<std::string>::string_to_arraybuffer(rt, args[0]);
}

jsi::Value NativeFedimintClientUniffi::
    cpp_uniffi_internal_fn_func_ffi__arraybuffer_to_string(
        jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
        size_t count) {
  return uniffi_jsi::Bridging<std::string>::arraybuffer_to_string(rt, args[0]);
}
jsi::Value NativeFedimintClientUniffi::
    cpp_uniffi_internal_fn_method_rpchandler_ffi__bless_pointer(
        jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
        size_t count) {
  auto pointer =
      uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]);
  auto static destructor = [](uint64_t p) {
    auto pointer = reinterpret_cast<void *>(static_cast<uintptr_t>(p));
    RustCallStatus status = {0};
    uniffi_fedimint_client_uniffi_fn_free_rpchandler(pointer, &status);
  };
  auto ptrObj =
      std::make_shared<uniffi_jsi::DestructibleObject>(pointer, destructor);
  auto obj = jsi::Object::createFromHostObject(rt, ptrObj);
  return jsi::Value(rt, obj);
}

// Methods calling directly into the uniffi generated C API of the Rust crate.
jsi::Value NativeFedimintClientUniffi::
    cpp_uniffi_fedimint_client_uniffi_fn_clone_rpchandler(
        jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
        size_t count) {
  RustCallStatus status =
      uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::rustSuccess(rt);
  auto value = uniffi_fedimint_client_uniffi_fn_clone_rpchandler(
      uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]), &status);
  uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::copyIntoJs(
      rt, callInvoker, status, args[count - 1]);

  return uniffi_jsi::Bridging<void *>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFedimintClientUniffi::
    cpp_uniffi_fedimint_client_uniffi_fn_free_rpchandler(
        jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
        size_t count) {
  RustCallStatus status =
      uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::rustSuccess(rt);
  uniffi_fedimint_client_uniffi_fn_free_rpchandler(
      uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]), &status);
  uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::copyIntoJs(
      rt, callInvoker, status, args[count - 1]);

  return jsi::Value::undefined();
}
jsi::Value NativeFedimintClientUniffi::
    cpp_uniffi_fedimint_client_uniffi_fn_constructor_rpchandler_new(
        jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
        size_t count) {
  RustCallStatus status =
      uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::rustSuccess(rt);
  auto value = uniffi_fedimint_client_uniffi_fn_constructor_rpchandler_new(
      uniffi::fedimint_client_uniffi::Bridging<RustBuffer>::fromJs(
          rt, callInvoker, args[0]),
      &status);
  uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::copyIntoJs(
      rt, callInvoker, status, args[count - 1]);

  return uniffi_jsi::Bridging<void *>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFedimintClientUniffi::
    cpp_uniffi_fedimint_client_uniffi_fn_method_rpchandler_rpc(
        jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
        size_t count) {
  RustCallStatus status =
      uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::rustSuccess(rt);
  uniffi_fedimint_client_uniffi_fn_method_rpchandler_rpc(
      uniffi_jsi::Bridging<void *>::fromJs(rt, callInvoker, args[0]),
      uniffi::fedimint_client_uniffi::Bridging<RustBuffer>::fromJs(
          rt, callInvoker, args[1]),
      uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[2]),
      &status);
  uniffi::fedimint_client_uniffi::Bridging<RustCallStatus>::copyIntoJs(
      rt, callInvoker, status, args[count - 1]);

  return jsi::Value::undefined();
}
jsi::Value NativeFedimintClientUniffi::
    cpp_uniffi_fedimint_client_uniffi_fn_init_callback_vtable_rpccallback(
        jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
        size_t count) {
  auto vtableInstance = uniffi::fedimint_client_uniffi::Bridging<
      UniffiVTableCallbackInterfaceRpcCallback>::fromJs(rt, callInvoker,
                                                        args[0]);

  std::lock_guard<std::mutex> lock(
      uniffi::fedimint_client_uniffi::registry::vtableMutex);
  uniffi_fedimint_client_uniffi_fn_init_callback_vtable_rpccallback(
      uniffi::fedimint_client_uniffi::registry::putTable(
          "UniffiVTableCallbackInterfaceRpcCallback", vtableInstance));
  return jsi::Value::undefined();
}
jsi::Value NativeFedimintClientUniffi::
    cpp_uniffi_fedimint_client_uniffi_checksum_method_rpchandler_rpc(
        jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
        size_t count) {
  auto value = uniffi_fedimint_client_uniffi_checksum_method_rpchandler_rpc();

  return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFedimintClientUniffi::
    cpp_uniffi_fedimint_client_uniffi_checksum_constructor_rpchandler_new(
        jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
        size_t count) {
  auto value =
      uniffi_fedimint_client_uniffi_checksum_constructor_rpchandler_new();

  return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFedimintClientUniffi::
    cpp_uniffi_fedimint_client_uniffi_checksum_method_rpccallback_on_response(
        jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
        size_t count) {
  auto value =
      uniffi_fedimint_client_uniffi_checksum_method_rpccallback_on_response();

  return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
}
jsi::Value NativeFedimintClientUniffi::
    cpp_ffi_fedimint_client_uniffi_uniffi_contract_version(
        jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
        size_t count) {
  auto value = ffi_fedimint_client_uniffi_uniffi_contract_version();

  return uniffi_jsi::Bridging<uint32_t>::toJs(rt, callInvoker, value);
}