diff --git a/.gitignore b/.gitignore
index a23406b..2e5e330 100644
--- a/.gitignore
+++ b/.gitignore
@@ -79,8 +79,14 @@ android/keystores/debug.keystore
lib/
# React Native Codegen
-ios/generated
-android/generated
+RustNostrNostrSdkReactNativeFramework.xcframework/
+ios/
+android/
+cpp/
+src/
+!example/ios/
+!example/android/
+!example/src/
# React Native Nitro Modules
nitrogen/
diff --git a/RustNostrNostrSdkReactNativeFramework.xcframework/Info.plist b/RustNostrNostrSdkReactNativeFramework.xcframework/Info.plist
deleted file mode 100644
index 654f039..0000000
--- a/RustNostrNostrSdkReactNativeFramework.xcframework/Info.plist
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
- AvailableLibraries
-
-
- BinaryPath
- libnostr_sdk_ffi.a
- LibraryIdentifier
- ios-arm64-simulator
- LibraryPath
- libnostr_sdk_ffi.a
- SupportedArchitectures
-
- arm64
-
- SupportedPlatform
- ios
- SupportedPlatformVariant
- simulator
-
-
- BinaryPath
- libnostr_sdk_ffi.a
- LibraryIdentifier
- ios-arm64
- LibraryPath
- libnostr_sdk_ffi.a
- SupportedArchitectures
-
- arm64
-
- SupportedPlatform
- ios
-
-
- CFBundlePackageType
- XFWK
- XCFrameworkFormatVersion
- 1.0
-
-
diff --git a/android/CMakeLists.txt b/android/CMakeLists.txt
deleted file mode 100644
index 61e4cff..0000000
--- a/android/CMakeLists.txt
+++ /dev/null
@@ -1,77 +0,0 @@
-# Generated by uniffi-bindgen-react-native
-cmake_minimum_required(VERSION 3.9.0)
-project(NostrSdkReactNative)
-
-set (CMAKE_VERBOSE_MAKEFILE ON)
-set (CMAKE_CXX_STANDARD 17)
-
-# Resolve the path to the uniffi-bindgen-react-native package
-execute_process(
- COMMAND node -p "require.resolve('uniffi-bindgen-react-native/package.json')"
- OUTPUT_VARIABLE UNIFFI_BINDGEN_PATH
- OUTPUT_STRIP_TRAILING_WHITESPACE
-)
-string(REGEX
- REPLACE "/package\\.json$" ""
- UNIFFI_BINDGEN_PATH ${UNIFFI_BINDGEN_PATH}
-)
-
-# Specifies a path to native header files.
-include_directories(
- ../cpp
- ../cpp/generated
-
- ${UNIFFI_BINDGEN_PATH}/cpp/includes
-)
-
-add_library(rust-nostr-nostr-sdk-react-native SHARED
- ../cpp/rust-nostr-nostr-sdk-react-native.cpp
- ../cpp/generated/nostr_sdk.cpp
- cpp-adapter.cpp
-)
-
-# Set C++ compiler flags
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
-
-cmake_path(
- SET MY_RUST_LIB
- ${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libnostr_sdk_ffi.a
- NORMALIZE
-)
-add_library(my_rust_lib STATIC IMPORTED)
-set_target_properties(my_rust_lib PROPERTIES IMPORTED_LOCATION ${MY_RUST_LIB})
-
-# Add ReactAndroid libraries, being careful to account for different versions.
-find_package(ReactAndroid REQUIRED CONFIG)
-find_library(LOGCAT log)
-
-# REACTNATIVE_MERGED_SO seems to be only be set in a build.gradle.kt file,
-# which we don't use. Thus falling back to version number sniffing.
-if (ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
- set(REACTNATIVE_MERGED_SO true)
-endif()
-
-# https://github.com/react-native-community/discussions-and-proposals/discussions/816
-# This if-then-else can be removed once this library does not support version below 0.76
-if (REACTNATIVE_MERGED_SO)
- target_link_libraries(rust-nostr-nostr-sdk-react-native ReactAndroid::reactnative)
-else()
- target_link_libraries(rust-nostr-nostr-sdk-react-native
- ReactAndroid::turbomodulejsijni
- ReactAndroid::react_nativemodule_core
- )
-endif()
-
-find_package(fbjni REQUIRED CONFIG)
-target_link_libraries(
- rust-nostr-nostr-sdk-react-native
- fbjni::fbjni
- ReactAndroid::jsi
- ${LOGCAT}
- my_rust_lib
-)
diff --git a/android/build.gradle b/android/build.gradle
deleted file mode 100644
index 8deb6d1..0000000
--- a/android/build.gradle
+++ /dev/null
@@ -1,143 +0,0 @@
-// Generated by uniffi-bindgen-react-native
-
-buildscript {
- // Buildscript is evaluated before everything else so we can't use getExtOrDefault
- def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["DummyLibForAndroid_kotlinVersion"]
-
- repositories {
- google()
- mavenCentral()
- }
-
- dependencies {
- classpath "com.android.tools.build:gradle:7.2.1"
- // noinspection DifferentKotlinGradleVersion
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
- }
-}
-
-def reactNativeArchitectures() {
- def value = rootProject.getProperties().get("reactNativeArchitectures")
- return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
-}
-
-def isNewArchitectureEnabled() {
- return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
-}
-
-apply plugin: "com.android.library"
-apply plugin: "kotlin-android"
-
-if (isNewArchitectureEnabled()) {
- apply plugin: "com.facebook.react"
-}
-
-def getExtOrDefault(name) {
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["NostrSdkReactNative_" + name]
-}
-
-def getExtOrIntegerDefault(name) {
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["NostrSdkReactNative_" + name]).toInteger()
-}
-
-def supportsNamespace() {
- def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
- def major = parsed[0].toInteger()
- def minor = parsed[1].toInteger()
-
- // Namespace support was added in 7.3.0
- return (major == 7 && minor >= 3) || major >= 8
-}
-
-android {
- if (supportsNamespace()) {
- namespace "com.nostrsdkreactnative"
-
- sourceSets {
- main {
- manifest.srcFile "src/main/AndroidManifestNew.xml"
- }
- }
- }
-
- ndkVersion getExtOrDefault("ndkVersion")
- compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
-
- defaultConfig {
- minSdkVersion getExtOrIntegerDefault("minSdkVersion")
- targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
- buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
-
- buildFeatures {
- prefab true
- }
- externalNativeBuild {
- cmake {
- arguments '-DANDROID_STL=c++_shared'
- abiFilters (*reactNativeArchitectures())
- }
- }
- ndk {
- abiFilters "arm64-v8a", "armeabi-v7a", "x86", "x86_64"
- }
- }
-
- externalNativeBuild {
- cmake {
- path "CMakeLists.txt"
- }
- }
-
- buildFeatures {
- buildConfig true
- }
-
- buildTypes {
- release {
- minifyEnabled false
- }
- }
-
- lintOptions {
- disable "GradleCompatible"
- }
-
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
-
- sourceSets {
- main {
- if (isNewArchitectureEnabled()) {
- java.srcDirs += [
- "generated/java",
- "generated/jni"
- ]
- }
- }
- }
-}
-
-repositories {
- mavenCentral()
- google()
-}
-
-def kotlin_version = getExtOrDefault("kotlinVersion")
-
-dependencies {
- // For < 0.71, this will be from the local maven repo
- // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
- //noinspection GradleDynamicVersion
- implementation "com.facebook.react:react-native:+"
- implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
-}
-
-if (isNewArchitectureEnabled()) {
- react {
- jsRootDir = file("../src/")
- libraryName = "NostrSdkReactNative"
- codegenJavaPackageName = "com.nostrsdkreactnative"
- }
-}
diff --git a/android/cpp-adapter.cpp b/android/cpp-adapter.cpp
deleted file mode 100644
index 5c9fddf..0000000
--- a/android/cpp-adapter.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-// Generated by uniffi-bindgen-react-native
-#include
-#include
-#include
-#include "rust-nostr-nostr-sdk-react-native.h"
-
-namespace jsi = facebook::jsi;
-namespace react = facebook::react;
-
-// Automated testing checks Java_com_nostrsdkreactnative_NostrSdkReactNativeModule and rustnostr_nostrsdkreactnative
-// by comparing the whole line here.
-/*
-Java_com_nostrsdkreactnative_NostrSdkReactNativeModule_nativeMultiply(JNIEnv *env, jclass type, jdouble a, jdouble b) {
- return rustnostr_nostrsdkreactnative::multiply(a, b);
-}
-*/
-
-// Installer coming from NostrSdkReactNativeModule
-extern "C"
-JNIEXPORT jboolean JNICALL
-Java_com_nostrsdkreactnative_NostrSdkReactNativeModule_nativeInstallRustCrate(
- JNIEnv *env,
- jclass type,
- jlong rtPtr,
- jobject callInvokerHolderJavaObj
-) {
- // https://github.com/realm/realm-js/blob/main/packages/realm/binding/android/src/main/cpp/io_realm_react_RealmReactModule.cpp#L122-L145
- // React Native uses the fbjni library for handling JNI, which has the concept of "hybrid objects",
- // which are Java objects containing a pointer to a C++ object. The CallInvokerHolder, which has the
- // invokeAsync method we want access to, is one such hybrid object.
- // Rather than reworking our code to use fbjni throughout, this code unpacks the C++ object from the Java
- // object `callInvokerHolderJavaObj` manually, based on reverse engineering the fbjni code.
-
- // 1. Get the Java object referred to by the mHybridData field of the Java holder object
- auto callInvokerHolderClass = env->GetObjectClass(callInvokerHolderJavaObj);
- auto hybridDataField = env->GetFieldID(callInvokerHolderClass, "mHybridData", "Lcom/facebook/jni/HybridData;");
- auto hybridDataObj = env->GetObjectField(callInvokerHolderJavaObj, hybridDataField);
-
- // 2. Get the destructor Java object referred to by the mDestructor field from the myHybridData Java object
- auto hybridDataClass = env->FindClass("com/facebook/jni/HybridData");
- auto destructorField =
- env->GetFieldID(hybridDataClass, "mDestructor", "Lcom/facebook/jni/HybridData$Destructor;");
- auto destructorObj = env->GetObjectField(hybridDataObj, destructorField);
-
- // 3. Get the mNativePointer field from the mDestructor Java object
- auto destructorClass = env->FindClass("com/facebook/jni/HybridData$Destructor");
- auto nativePointerField = env->GetFieldID(destructorClass, "mNativePointer", "J");
- auto nativePointerValue = env->GetLongField(destructorObj, nativePointerField);
-
- // 4. Cast the mNativePointer back to its C++ type
- auto nativePointer = reinterpret_cast(nativePointerValue);
- auto jsCallInvoker = nativePointer->getCallInvoker();
-
- auto runtime = reinterpret_cast(rtPtr);
- return rustnostr_nostrsdkreactnative::installRustCrate(*runtime, jsCallInvoker);
-}
-
-extern "C"
-JNIEXPORT jboolean JNICALL
-Java_com_nostrsdkreactnative_NostrSdkReactNativeModule_nativeCleanupRustCrate(JNIEnv *env, jclass type, jlong rtPtr) {
- auto runtime = reinterpret_cast(rtPtr);
- return rustnostr_nostrsdkreactnative::cleanupRustCrate(*runtime);
-}
\ No newline at end of file
diff --git a/android/gradle.properties b/android/gradle.properties
deleted file mode 100644
index 4726a1f..0000000
--- a/android/gradle.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-NostrSdkReactNative_kotlinVersion=2.0.21
-NostrSdkReactNative_minSdkVersion=24
-NostrSdkReactNative_targetSdkVersion=34
-NostrSdkReactNative_compileSdkVersion=35
-NostrSdkReactNative_ndkVersion=27.1.12297006
diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml
deleted file mode 100644
index 13a360c..0000000
--- a/android/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/android/src/main/AndroidManifestNew.xml b/android/src/main/AndroidManifestNew.xml
deleted file mode 100644
index a2f47b6..0000000
--- a/android/src/main/AndroidManifestNew.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
diff --git a/android/src/main/java/com/nostrsdkreactnative/NostrSdkReactNativeModule.kt b/android/src/main/java/com/nostrsdkreactnative/NostrSdkReactNativeModule.kt
deleted file mode 100644
index d472770..0000000
--- a/android/src/main/java/com/nostrsdkreactnative/NostrSdkReactNativeModule.kt
+++ /dev/null
@@ -1,43 +0,0 @@
-// Generated by uniffi-bindgen-react-native
-package com.nostrsdkreactnative
-
-import com.facebook.react.bridge.ReactApplicationContext
-import com.facebook.react.module.annotations.ReactModule
-import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder
-
-@ReactModule(name = NostrSdkReactNativeModule.NAME)
-class NostrSdkReactNativeModule(reactContext: ReactApplicationContext) :
- NativeNostrSdkReactNativeSpec(reactContext) {
-
- override fun getName(): String {
- return NAME
- }
-
- // Two native methods implemented in cpp-adapter.cpp, and ultimately
- // rust-nostr-nostr-sdk-react-native.cpp
-
- external fun nativeInstallRustCrate(runtimePointer: Long, callInvoker: CallInvokerHolder): Boolean
- external fun nativeCleanupRustCrate(runtimePointer: Long): Boolean
-
- override fun installRustCrate(): Boolean {
- val context = this.reactApplicationContext
- return nativeInstallRustCrate(
- context.javaScriptContextHolder!!.get(),
- context.jsCallInvokerHolder!!
- )
- }
-
- override fun cleanupRustCrate(): Boolean {
- return nativeCleanupRustCrate(
- this.reactApplicationContext.javaScriptContextHolder!!.get()
- )
- }
-
- companion object {
- const val NAME = "NostrSdkReactNative"
-
- init {
- System.loadLibrary("rust-nostr-nostr-sdk-react-native")
- }
- }
-}
\ No newline at end of file
diff --git a/android/src/main/java/com/nostrsdkreactnative/NostrSdkReactNativePackage.kt b/android/src/main/java/com/nostrsdkreactnative/NostrSdkReactNativePackage.kt
deleted file mode 100644
index 066b1f5..0000000
--- a/android/src/main/java/com/nostrsdkreactnative/NostrSdkReactNativePackage.kt
+++ /dev/null
@@ -1,34 +0,0 @@
-// Generated by uniffi-bindgen-react-native
-package com.nostrsdkreactnative
-
-import com.facebook.react.TurboReactPackage
-import com.facebook.react.bridge.NativeModule
-import com.facebook.react.bridge.ReactApplicationContext
-import com.facebook.react.module.model.ReactModuleInfo
-import com.facebook.react.module.model.ReactModuleInfoProvider
-import java.util.HashMap
-
-class NostrSdkReactNativePackage : TurboReactPackage() {
- override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
- return if (name == NostrSdkReactNativeModule.NAME) {
- NostrSdkReactNativeModule(reactContext)
- } else {
- null
- }
- }
-
- override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
- return ReactModuleInfoProvider {
- val moduleInfos: MutableMap = HashMap()
- moduleInfos[NostrSdkReactNativeModule.NAME] = ReactModuleInfo(
- NostrSdkReactNativeModule.NAME,
- NostrSdkReactNativeModule.NAME,
- false, // canOverrideExistingModule
- false, // needsEagerInit
- false, // isCxxModule
- true // isTurboModule
- )
- moduleInfos
- }
- }
-}
\ No newline at end of file
diff --git a/cpp/generated/nostr_sdk.cpp b/cpp/generated/nostr_sdk.cpp
deleted file mode 100644
index 1e2c04a..0000000
--- a/cpp/generated/nostr_sdk.cpp
+++ /dev/null
@@ -1,43617 +0,0 @@
-// 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 "nostr_sdk.hpp"
-
-#include "UniffiJsiTypes.h"
-#include
-#include