@fedimint/react-native-bindings 0.0.0-canary-ecde932b329972ca4c9b8b6c8a28f709edb957c0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +60 -0
  3. package/ReactNativeBindings.podspec +45 -0
  4. package/android/CMakeLists.txt +76 -0
  5. package/android/build.gradle +144 -0
  6. package/android/cpp-adapter.cpp +51 -0
  7. package/android/cpp-adapter.cpp.rej +57 -0
  8. package/android/generated/java/com/fedimint/reactnative/NativeReactNativeBindingsSpec.java +41 -0
  9. package/android/generated/jni/CMakeLists.txt +28 -0
  10. package/android/generated/jni/ReactNativeBindingsSpec-generated.cpp +38 -0
  11. package/android/generated/jni/ReactNativeBindingsSpec.h +31 -0
  12. package/android/generated/jni/react/renderer/components/ReactNativeBindingsSpec/ComponentDescriptors.cpp +22 -0
  13. package/android/generated/jni/react/renderer/components/ReactNativeBindingsSpec/ComponentDescriptors.h +24 -0
  14. package/android/generated/jni/react/renderer/components/ReactNativeBindingsSpec/EventEmitters.cpp +16 -0
  15. package/android/generated/jni/react/renderer/components/ReactNativeBindingsSpec/EventEmitters.h +17 -0
  16. package/android/generated/jni/react/renderer/components/ReactNativeBindingsSpec/Props.cpp +19 -0
  17. package/android/generated/jni/react/renderer/components/ReactNativeBindingsSpec/Props.h +18 -0
  18. package/android/generated/jni/react/renderer/components/ReactNativeBindingsSpec/ReactNativeBindingsSpecJSI.h +45 -0
  19. package/android/generated/jni/react/renderer/components/ReactNativeBindingsSpec/ShadowNodes.cpp +17 -0
  20. package/android/generated/jni/react/renderer/components/ReactNativeBindingsSpec/ShadowNodes.h +23 -0
  21. package/android/generated/jni/react/renderer/components/ReactNativeBindingsSpec/States.cpp +16 -0
  22. package/android/generated/jni/react/renderer/components/ReactNativeBindingsSpec/States.h +20 -0
  23. package/android/src/main/AndroidManifest.xml +5 -0
  24. package/android/src/main/java/com/fedimint/reactnative/ReactNativeBindingsModule.kt +43 -0
  25. package/android/src/main/java/com/fedimint/reactnative/ReactNativeBindingsPackage.kt +34 -0
  26. package/app.plugin.js +1 -0
  27. package/cpp/fedimint-react-native-bindings.cpp +16 -0
  28. package/cpp/fedimint-react-native-bindings.h +15 -0
  29. package/cpp/generated/fedimint_client_uniffi.cpp +2281 -0
  30. package/cpp/generated/fedimint_client_uniffi.hpp +95 -0
  31. package/ios/ReactNativeBindings.h +16 -0
  32. package/ios/ReactNativeBindings.mm +66 -0
  33. package/ios/generated/ReactCodegen/ReactNativeBindingsSpec/ComponentDescriptors.cpp +22 -0
  34. package/ios/generated/ReactCodegen/ReactNativeBindingsSpec/ComponentDescriptors.h +24 -0
  35. package/ios/generated/ReactCodegen/ReactNativeBindingsSpec/EventEmitters.cpp +16 -0
  36. package/ios/generated/ReactCodegen/ReactNativeBindingsSpec/EventEmitters.h +17 -0
  37. package/ios/generated/ReactCodegen/ReactNativeBindingsSpec/Props.cpp +19 -0
  38. package/ios/generated/ReactCodegen/ReactNativeBindingsSpec/Props.h +18 -0
  39. package/ios/generated/ReactCodegen/ReactNativeBindingsSpec/RCTComponentViewHelpers.h +18 -0
  40. package/ios/generated/ReactCodegen/ReactNativeBindingsSpec/ReactNativeBindingsSpec-generated.mm +46 -0
  41. package/ios/generated/ReactCodegen/ReactNativeBindingsSpec/ReactNativeBindingsSpec.h +63 -0
  42. package/ios/generated/ReactCodegen/ReactNativeBindingsSpec/ShadowNodes.cpp +17 -0
  43. package/ios/generated/ReactCodegen/ReactNativeBindingsSpec/ShadowNodes.h +23 -0
  44. package/ios/generated/ReactCodegen/ReactNativeBindingsSpec/States.cpp +16 -0
  45. package/ios/generated/ReactCodegen/ReactNativeBindingsSpec/States.h +20 -0
  46. package/ios/generated/ReactCodegen/ReactNativeBindingsSpecJSI.h +45 -0
  47. package/lib/commonjs/NativeReactNativeBindings.js +10 -0
  48. package/lib/commonjs/NativeReactNativeBindings.js.map +1 -0
  49. package/lib/commonjs/generated/fedimint_client_uniffi-ffi.js +44 -0
  50. package/lib/commonjs/generated/fedimint_client_uniffi-ffi.js.map +1 -0
  51. package/lib/commonjs/generated/fedimint_client_uniffi.js +426 -0
  52. package/lib/commonjs/generated/fedimint_client_uniffi.js.map +1 -0
  53. package/lib/commonjs/index.js +63 -0
  54. package/lib/commonjs/index.js.map +1 -0
  55. package/lib/commonjs/package.json +1 -0
  56. package/lib/module/NativeReactNativeBindings.js +7 -0
  57. package/lib/module/NativeReactNativeBindings.js.map +1 -0
  58. package/lib/module/generated/fedimint_client_uniffi-ffi.js +43 -0
  59. package/lib/module/generated/fedimint_client_uniffi-ffi.js.map +1 -0
  60. package/lib/module/generated/fedimint_client_uniffi.js +420 -0
  61. package/lib/module/generated/fedimint_client_uniffi.js.map +1 -0
  62. package/lib/module/index.js +43 -0
  63. package/lib/module/index.js.map +1 -0
  64. package/lib/module/package.json +1 -0
  65. package/lib/typescript/commonjs/package.json +1 -0
  66. package/lib/typescript/commonjs/src/NativeReactNativeBindings.d.ts +8 -0
  67. package/lib/typescript/commonjs/src/NativeReactNativeBindings.d.ts.map +1 -0
  68. package/lib/typescript/commonjs/src/generated/fedimint_client_uniffi-ffi.d.ts +95 -0
  69. package/lib/typescript/commonjs/src/generated/fedimint_client_uniffi-ffi.d.ts.map +1 -0
  70. package/lib/typescript/commonjs/src/generated/fedimint_client_uniffi.d.ts +501 -0
  71. package/lib/typescript/commonjs/src/generated/fedimint_client_uniffi.d.ts.map +1 -0
  72. package/lib/typescript/commonjs/src/index.d.ts +8 -0
  73. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  74. package/lib/typescript/module/package.json +1 -0
  75. package/lib/typescript/module/src/NativeReactNativeBindings.d.ts +8 -0
  76. package/lib/typescript/module/src/NativeReactNativeBindings.d.ts.map +1 -0
  77. package/lib/typescript/module/src/generated/fedimint_client_uniffi-ffi.d.ts +95 -0
  78. package/lib/typescript/module/src/generated/fedimint_client_uniffi-ffi.d.ts.map +1 -0
  79. package/lib/typescript/module/src/generated/fedimint_client_uniffi.d.ts +501 -0
  80. package/lib/typescript/module/src/generated/fedimint_client_uniffi.d.ts.map +1 -0
  81. package/lib/typescript/module/src/index.d.ts +8 -0
  82. package/lib/typescript/module/src/index.d.ts.map +1 -0
  83. package/package.json +154 -0
  84. package/patches/add_ios_frameworks.patch +18 -0
  85. package/patches/rn083_callinvoker.patch +57 -0
  86. package/patches/snapshot_version.patch +11 -0
  87. package/plugin/build/index.d.ts +10 -0
  88. package/plugin/build/index.js +19 -0
  89. package/plugin/build/tsconfig.tsbuildinfo +1 -0
  90. package/plugin/build/utils.d.ts +8 -0
  91. package/plugin/build/utils.js +4 -0
  92. package/plugin/build/withAndroid.d.ts +5 -0
  93. package/plugin/build/withAndroid.js +36 -0
  94. package/plugin/build/withBinaryArtifacts.d.ts +6 -0
  95. package/plugin/build/withBinaryArtifacts.js +158 -0
  96. package/plugin/build/withIOS.d.ts +6 -0
  97. package/plugin/build/withIOS.js +13 -0
  98. package/plugin/src/index.ts +39 -0
  99. package/plugin/src/utils.ts +9 -0
  100. package/plugin/src/withAndroid.ts +41 -0
  101. package/plugin/src/withBinaryArtifacts.ts +154 -0
  102. package/plugin/src/withIOS.ts +11 -0
  103. package/plugin/tsconfig.json +8 -0
  104. package/react-native.config.js +15 -0
  105. package/scripts/download-binaries.js +113 -0
  106. package/src/NativeReactNativeBindings.ts +10 -0
  107. package/src/generated/fedimint_client_uniffi-ffi.ts +221 -0
  108. package/src/generated/fedimint_client_uniffi.ts +651 -0
  109. package/src/index.tsx +41 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 fedimint
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # @fedimint/react-native-bindings
2
+
3
+ Low-level React Native bindings for Fedimint client SDK.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @fedimint/react-native-bindings
9
+ # or
10
+ yarn add @fedimint/react-native-bindings
11
+ # or
12
+ pnpm add @fedimint/react-native-bindings
13
+ ```
14
+
15
+ Binary artifacts for Android and iOS are automatically downloaded during installation.
16
+
17
+ ### Skipping Binary Downloads
18
+
19
+ To skip automatic binary download (useful for local development or custom builds):
20
+
21
+ ```bash
22
+ FEDIMINT_SKIP_BINARY_DOWNLOAD=true npm install @fedimint/react-native-bindings
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ For most use cases, we recommend using the higher-level `@fedimint/react-native` package which provides a simpler API built on top of these bindings.
28
+
29
+ ```typescript
30
+ // Direct low-level usage
31
+ import { rpcHandler } from '@fedimint/react-native-bindings';
32
+ ```
33
+
34
+ ## For Higher-Level API
35
+
36
+ Use the `@fedimint/react-native` package which wraps these bindings with a more convenient API:
37
+
38
+ ```bash
39
+ npm install @fedimint/react-native
40
+ ```
41
+
42
+ ## Supported Platforms
43
+
44
+ The `@fedimint/react-native-bindings` package contains pre-compiled native Rust binaries. It explicitly supports the following architectures, which cover the vast majority of modern devices and simulators needed for React Native development:
45
+
46
+ ### Android
47
+ *(Minimum Supported Version: Android 7.0 / API Level 24)*
48
+ * **`arm64-v8a`**: Required for all modern 64-bit physical Android devices (e.g., Samsung Galaxy S-series, Google Pixel).
49
+ * **`x86_64`**: Required for running the app on Android Emulators running on modern Mac/PC laptops.
50
+
51
+
52
+
53
+ ### iOS
54
+ *(Minimum Supported Version: iOS 15.0)*
55
+ * **`aarch64-apple-ios`**: Required for all physical iOS devices (iPhone, iPad).
56
+ * **`x86_64-apple-ios`**: Required for running the app on the iOS Simulator on Intel-based Macs.
57
+
58
+ ## Credit
59
+
60
+ Used the [bdk-rn](https://github.com/bitcoindevkit/bdk-rn) and [spark-sdk](https://github.com/breez/spark-sdk/tree/main) libraries as a reference.
@@ -0,0 +1,45 @@
1
+ # Generated by uniffi-bindgen-react-native
2
+ require "json"
3
+
4
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
5
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
6
+
7
+ Pod::Spec.new do |s|
8
+ s.name = "ReactNativeBindings"
9
+ s.version = package["version"]
10
+ s.summary = package["description"]
11
+ s.homepage = package["homepage"]
12
+ s.license = package["license"]
13
+ s.authors = package["author"]
14
+
15
+ s.platforms = { :ios => min_ios_version_supported }
16
+ s.source = { :git => "https://github.com/fedimint/fedimint-sdk.git", :tag => "#{s.version}" }
17
+
18
+ s.source_files = "ios/**/*.{h,m,mm,swift}", "ios/generated/**/*.{h,m,mm}", "cpp/**/*.{hpp,cpp,c,h}", "cpp/generated/**/*.{hpp,cpp,c,h}"
19
+ s.vendored_frameworks = "FedimintReactNativeBindingsFramework.xcframework"
20
+ s.frameworks = "SystemConfiguration", "Security"
21
+ s.dependency "uniffi-bindgen-react-native", "0.29.3-1"
22
+
23
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
24
+ # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
25
+ if respond_to?(:install_modules_dependencies, true)
26
+ install_modules_dependencies(s)
27
+ else
28
+ s.dependency "React-Core"
29
+
30
+ # Don't install the dependencies when we run `pod install` in the old architecture.
31
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
32
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
33
+ s.pod_target_xcconfig = {
34
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
35
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
36
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
37
+ }
38
+ s.dependency "React-Codegen"
39
+ s.dependency "RCT-Folly"
40
+ s.dependency "RCTRequired"
41
+ s.dependency "RCTTypeSafety"
42
+ s.dependency "ReactCommon/turbomodule/core"
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,76 @@
1
+ # Generated by uniffi-bindgen-react-native
2
+ cmake_minimum_required(VERSION 3.9.0)
3
+ project(ReactNativeBindings)
4
+
5
+ set (CMAKE_VERBOSE_MAKEFILE ON)
6
+ set (CMAKE_CXX_STANDARD 17)
7
+
8
+ # Resolve the path to the uniffi-bindgen-react-native package
9
+ execute_process(
10
+ COMMAND node -p "require.resolve('uniffi-bindgen-react-native/package.json')"
11
+ OUTPUT_VARIABLE UNIFFI_BINDGEN_PATH
12
+ OUTPUT_STRIP_TRAILING_WHITESPACE
13
+ )
14
+ # Get the directory; get_filename_component and cmake_path will normalize
15
+ # paths with Windows path separators.
16
+ get_filename_component(UNIFFI_BINDGEN_PATH "${UNIFFI_BINDGEN_PATH}" DIRECTORY)
17
+
18
+ # Specifies a path to native header files.
19
+ include_directories(
20
+ ../cpp
21
+ ../cpp/generated
22
+
23
+ ${UNIFFI_BINDGEN_PATH}/cpp/includes
24
+ )
25
+
26
+ add_library(fedimint-react-native-bindings SHARED
27
+ ../cpp/fedimint-react-native-bindings.cpp
28
+ ../cpp/generated/fedimint_client_uniffi.cpp
29
+ cpp-adapter.cpp
30
+ )
31
+
32
+ # Set C++ compiler flags
33
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
34
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
35
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti")
36
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all")
37
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
38
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
39
+
40
+ cmake_path(
41
+ SET MY_RUST_LIB
42
+ ${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libfedimint_client_uniffi.so
43
+ NORMALIZE
44
+ )
45
+ add_library(my_rust_lib SHARED IMPORTED)
46
+ set_target_properties(my_rust_lib PROPERTIES IMPORTED_LOCATION ${MY_RUST_LIB} IMPORTED_NO_SONAME ON)
47
+
48
+ # Add ReactAndroid libraries, being careful to account for different versions.
49
+ find_package(ReactAndroid REQUIRED CONFIG)
50
+ find_library(LOGCAT log)
51
+
52
+ # REACTNATIVE_MERGED_SO seems to be only be set in a build.gradle.kt file,
53
+ # which we don't use. Thus falling back to version number sniffing.
54
+ if (ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
55
+ set(REACTNATIVE_MERGED_SO true)
56
+ endif()
57
+
58
+ # https://github.com/react-native-community/discussions-and-proposals/discussions/816
59
+ # This if-then-else can be removed once this library does not support version below 0.76
60
+ if (REACTNATIVE_MERGED_SO)
61
+ target_link_libraries(fedimint-react-native-bindings ReactAndroid::reactnative)
62
+ else()
63
+ target_link_libraries(fedimint-react-native-bindings
64
+ ReactAndroid::turbomodulejsijni
65
+ ReactAndroid::react_nativemodule_core
66
+ )
67
+ endif()
68
+
69
+ find_package(fbjni REQUIRED CONFIG)
70
+ target_link_libraries(
71
+ fedimint-react-native-bindings
72
+ fbjni::fbjni
73
+ ReactAndroid::jsi
74
+ ${LOGCAT}
75
+ my_rust_lib
76
+ )
@@ -0,0 +1,144 @@
1
+ // Generated by uniffi-bindgen-react-native
2
+
3
+ buildscript {
4
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
5
+ def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["DummyLibForAndroid_kotlinVersion"]
6
+
7
+ repositories {
8
+ google()
9
+ mavenCentral()
10
+ }
11
+
12
+ dependencies {
13
+ classpath "com.android.tools.build:gradle:7.2.1"
14
+ // noinspection DifferentKotlinGradleVersion
15
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
16
+ }
17
+ }
18
+
19
+ def reactNativeArchitectures() {
20
+ def value = rootProject.getProperties().get("reactNativeArchitectures")
21
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
22
+ }
23
+
24
+ def isNewArchitectureEnabled() {
25
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
26
+ }
27
+
28
+ apply plugin: "com.android.library"
29
+ apply plugin: "kotlin-android"
30
+
31
+ if (isNewArchitectureEnabled()) {
32
+ apply plugin: "com.facebook.react"
33
+ }
34
+
35
+ def getExtOrDefault(name) {
36
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["ReactNativeBindings_" + name]
37
+ }
38
+
39
+ def getExtOrIntegerDefault(name) {
40
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ReactNativeBindings_" + name]).toInteger()
41
+ }
42
+
43
+ def supportsNamespace() {
44
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
45
+ def major = parsed[0].toInteger()
46
+ def minor = parsed[1].toInteger()
47
+
48
+ // Namespace support was added in 7.3.0
49
+ return (major == 7 && minor >= 3) || major >= 8
50
+ }
51
+
52
+ android {
53
+ if (supportsNamespace()) {
54
+ namespace "com.fedimint.reactnative"
55
+
56
+ sourceSets {
57
+ main {
58
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
59
+ }
60
+ }
61
+ }
62
+
63
+ ndkVersion getExtOrDefault("ndkVersion")
64
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
65
+
66
+ defaultConfig {
67
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
68
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
69
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
70
+ consumerProguardFiles 'proguard-rules.pro'
71
+
72
+ buildFeatures {
73
+ prefab true
74
+ }
75
+ externalNativeBuild {
76
+ cmake {
77
+ arguments '-DANDROID_STL=c++_shared'
78
+ abiFilters (*reactNativeArchitectures())
79
+ }
80
+ }
81
+ ndk {
82
+ abiFilters "arm64-v8a", "x86_64"
83
+ }
84
+ }
85
+
86
+ externalNativeBuild {
87
+ cmake {
88
+ path "CMakeLists.txt"
89
+ }
90
+ }
91
+
92
+ buildFeatures {
93
+ buildConfig true
94
+ }
95
+
96
+ buildTypes {
97
+ release {
98
+ minifyEnabled false
99
+ }
100
+ }
101
+
102
+ lintOptions {
103
+ disable "GradleCompatible"
104
+ }
105
+
106
+ compileOptions {
107
+ sourceCompatibility JavaVersion.VERSION_1_8
108
+ targetCompatibility JavaVersion.VERSION_1_8
109
+ }
110
+
111
+ sourceSets {
112
+ main {
113
+ if (isNewArchitectureEnabled()) {
114
+ java.srcDirs += [
115
+ "generated/java",
116
+ "generated/jni"
117
+ ]
118
+ }
119
+ }
120
+ }
121
+ }
122
+
123
+ repositories {
124
+ mavenCentral()
125
+ google()
126
+ }
127
+
128
+ def kotlin_version = getExtOrDefault("kotlinVersion")
129
+
130
+ dependencies {
131
+ // For < 0.71, this will be from the local maven repo
132
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
133
+ //noinspection GradleDynamicVersion
134
+ implementation "com.facebook.react:react-native:+"
135
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
136
+ }
137
+
138
+ if (isNewArchitectureEnabled()) {
139
+ react {
140
+ jsRootDir = file("../src/")
141
+ libraryName = "ReactNativeBindings"
142
+ codegenJavaPackageName = "com.fedimint.reactnative"
143
+ }
144
+ }
@@ -0,0 +1,51 @@
1
+ // Generated by uniffi-bindgen-react-native
2
+ #include <jni.h>
3
+ #include <jsi/jsi.h>
4
+ #include <fbjni/fbjni.h>
5
+ #include <ReactCommon/CallInvokerHolder.h>
6
+ #include "fedimint-react-native-bindings.h"
7
+
8
+ namespace jsi = facebook::jsi;
9
+ namespace react = facebook::react;
10
+
11
+ // Automated testing checks Java_com_fedimint_reactnative_ReactNativeBindingsModule and fedimint_reactnativebindings
12
+ // by comparing the whole line here.
13
+ /*
14
+ Java_com_fedimint_reactnative_ReactNativeBindingsModule_nativeMultiply(JNIEnv *env, jclass type, jdouble a, jdouble b) {
15
+ return fedimint_reactnativebindings::multiply(a, b);
16
+ }
17
+ */
18
+
19
+ // Installer coming from ReactNativeBindingsModule
20
+ extern "C"
21
+ JNIEXPORT jboolean JNICALL
22
+ Java_com_fedimint_reactnative_ReactNativeBindingsModule_nativeInstallRustCrate(
23
+ JNIEnv *env,
24
+ jclass type,
25
+ jlong rtPtr,
26
+ jobject callInvokerHolderJavaObj
27
+ ) {
28
+ // WHY THIS PATCH IS NEEDED:
29
+ // The uniffi-bindgen-react-native generator outputs C++ code that manually attempts to
30
+ // extract the CallInvoker from the Java CallInvokerHolder object using JNI reflection.
31
+ // However, in React Native 0.77+ (and the new architecture), the memory layout and standard
32
+ // approaches for hybrid objects changed. The manual reflection approach fails sometimes
33
+ // and causes crashes. Instead, we use the proper fbjni API `facebook::jni::wrap_alias`
34
+ // which is the officially supported way to extract the C++ HybridClass from the Java
35
+ // representation.
36
+ // Reference: https://github.com/realm/realm-js/issues/7011
37
+ auto callInvokerHolder = facebook::jni::wrap_alias(
38
+ reinterpret_cast<facebook::react::CallInvokerHolder::javaobject>(callInvokerHolderJavaObj)
39
+ )->cthis();
40
+ auto jsCallInvoker = callInvokerHolder->getCallInvoker();
41
+
42
+ auto runtime = reinterpret_cast<jsi::Runtime *>(rtPtr);
43
+ return fedimint_reactnativebindings::installRustCrate(*runtime, jsCallInvoker);
44
+ }
45
+
46
+ extern "C"
47
+ JNIEXPORT jboolean JNICALL
48
+ Java_com_fedimint_reactnative_ReactNativeBindingsModule_nativeCleanupRustCrate(JNIEnv *env, jclass type, jlong rtPtr) {
49
+ auto runtime = reinterpret_cast<jsi::Runtime *>(rtPtr);
50
+ return fedimint_reactnativebindings::cleanupRustCrate(*runtime);
51
+ }
@@ -0,0 +1,57 @@
1
+ --- android/cpp-adapter.cpp 2026-03-04 02:29:41
2
+ +++ android/cpp-adapter.cpp 2026-03-04 02:30:03
3
+ @@ -1,6 +1,7 @@
4
+ // Generated by uniffi-bindgen-react-native
5
+ #include <jni.h>
6
+ #include <jsi/jsi.h>
7
+ +#include <fbjni/fbjni.h>
8
+ #include <ReactCommon/CallInvokerHolder.h>
9
+ #include "fedimint-react-native-bindings.h"
10
+
11
+ @@ -24,33 +25,20 @@
12
+ jlong rtPtr,
13
+ jobject callInvokerHolderJavaObj
14
+ ) {
15
+ - // https://github.com/realm/realm-js/blob/main/packages/realm/binding/android/src/main/cpp/io_realm_react_RealmReactModule.cpp#L122-L145
16
+ - // React Native uses the fbjni library for handling JNI, which has the concept of "hybrid objects",
17
+ - // which are Java objects containing a pointer to a C++ object. The CallInvokerHolder, which has the
18
+ - // invokeAsync method we want access to, is one such hybrid object.
19
+ - // Rather than reworking our code to use fbjni throughout, this code unpacks the C++ object from the Java
20
+ - // object `callInvokerHolderJavaObj` manually, based on reverse engineering the fbjni code.
21
+ + // WHY THIS PATCH IS NEEDED:
22
+ + // The uniffi-bindgen-react-native generator outputs C++ code that manually attempts to
23
+ + // extract the CallInvoker from the Java CallInvokerHolder object using JNI reflection.
24
+ + // However, in React Native 0.77+ (and the new architecture), the memory layout and standard
25
+ + // approaches for hybrid objects changed. The manual reflection approach fails sometimes
26
+ + // and causes crashes. Instead, we use the proper fbjni API `facebook::jni::wrap_alias`
27
+ + // which is the officially supported way to extract the C++ HybridClass from the Java
28
+ + // representation.
29
+ + // Reference: https://github.com/realm/realm-js/issues/7011
30
+ + auto callInvokerHolder = facebook::jni::wrap_alias(
31
+ + reinterpret_cast<facebook::react::CallInvokerHolder::javaobject>(callInvokerHolderJavaObj)
32
+ + )->cthis();
33
+ + auto jsCallInvoker = callInvokerHolder->getCallInvoker();
34
+
35
+ - // 1. Get the Java object referred to by the mHybridData field of the Java holder object
36
+ - auto callInvokerHolderClass = env->GetObjectClass(callInvokerHolderJavaObj);
37
+ - auto hybridDataField = env->GetFieldID(callInvokerHolderClass, "mHybridData", "Lcom/facebook/jni/HybridData;");
38
+ - auto hybridDataObj = env->GetObjectField(callInvokerHolderJavaObj, hybridDataField);
39
+ -
40
+ - // 2. Get the destructor Java object referred to by the mDestructor field from the myHybridData Java object
41
+ - auto hybridDataClass = env->FindClass("com/facebook/jni/HybridData");
42
+ - auto destructorField =
43
+ - env->GetFieldID(hybridDataClass, "mDestructor", "Lcom/facebook/jni/HybridData$Destructor;");
44
+ - auto destructorObj = env->GetObjectField(hybridDataObj, destructorField);
45
+ -
46
+ - // 3. Get the mNativePointer field from the mDestructor Java object
47
+ - auto destructorClass = env->FindClass("com/facebook/jni/HybridData$Destructor");
48
+ - auto nativePointerField = env->GetFieldID(destructorClass, "mNativePointer", "J");
49
+ - auto nativePointerValue = env->GetLongField(destructorObj, nativePointerField);
50
+ -
51
+ - // 4. Cast the mNativePointer back to its C++ type
52
+ - auto nativePointer = reinterpret_cast<facebook::react::CallInvokerHolder*>(nativePointerValue);
53
+ - auto jsCallInvoker = nativePointer->getCallInvoker();
54
+ -
55
+ auto runtime = reinterpret_cast<jsi::Runtime *>(rtPtr);
56
+ return fedimint_reactnativebindings::installRustCrate(*runtime, jsCallInvoker);
57
+ }
@@ -0,0 +1,41 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJavaSpec.js
9
+ *
10
+ * @nolint
11
+ */
12
+
13
+ package com.fedimint.reactnative;
14
+
15
+ import com.facebook.proguard.annotations.DoNotStrip;
16
+ import com.facebook.react.bridge.ReactApplicationContext;
17
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
18
+ import com.facebook.react.bridge.ReactMethod;
19
+ import com.facebook.react.turbomodule.core.interfaces.TurboModule;
20
+ import javax.annotation.Nonnull;
21
+
22
+ public abstract class NativeReactNativeBindingsSpec extends ReactContextBaseJavaModule implements TurboModule {
23
+ public static final String NAME = "ReactNativeBindings";
24
+
25
+ public NativeReactNativeBindingsSpec(ReactApplicationContext reactContext) {
26
+ super(reactContext);
27
+ }
28
+
29
+ @Override
30
+ public @Nonnull String getName() {
31
+ return NAME;
32
+ }
33
+
34
+ @ReactMethod(isBlockingSynchronousMethod = true)
35
+ @DoNotStrip
36
+ public abstract boolean installRustCrate();
37
+
38
+ @ReactMethod(isBlockingSynchronousMethod = true)
39
+ @DoNotStrip
40
+ public abstract boolean cleanupRustCrate();
41
+ }
@@ -0,0 +1,28 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ cmake_minimum_required(VERSION 3.13)
7
+ set(CMAKE_VERBOSE_MAKEFILE on)
8
+
9
+ file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/ReactNativeBindingsSpec/*.cpp)
10
+
11
+ add_library(
12
+ react_codegen_ReactNativeBindingsSpec
13
+ OBJECT
14
+ ${react_codegen_SRCS}
15
+ )
16
+
17
+ target_include_directories(react_codegen_ReactNativeBindingsSpec PUBLIC . react/renderer/components/ReactNativeBindingsSpec)
18
+
19
+ target_link_libraries(
20
+ react_codegen_ReactNativeBindingsSpec
21
+ fbjni
22
+ jsi
23
+ # We need to link different libraries based on whether we are building rncore or not, that's necessary
24
+ # because we want to break a circular dependency between react_codegen_rncore and reactnative
25
+ reactnative
26
+ )
27
+
28
+ target_compile_reactnative_options(react_codegen_ReactNativeBindingsSpec PRIVATE)
@@ -0,0 +1,38 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJniCpp.js
9
+ */
10
+
11
+ #include "ReactNativeBindingsSpec.h"
12
+
13
+ namespace facebook::react {
14
+
15
+ static facebook::jsi::Value __hostFunction_NativeReactNativeBindingsSpecJSI_installRustCrate(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
16
+ static jmethodID cachedMethodId = nullptr;
17
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, BooleanKind, "installRustCrate", "()Z", args, count, cachedMethodId);
18
+ }
19
+
20
+ static facebook::jsi::Value __hostFunction_NativeReactNativeBindingsSpecJSI_cleanupRustCrate(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
21
+ static jmethodID cachedMethodId = nullptr;
22
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, BooleanKind, "cleanupRustCrate", "()Z", args, count, cachedMethodId);
23
+ }
24
+
25
+ NativeReactNativeBindingsSpecJSI::NativeReactNativeBindingsSpecJSI(const JavaTurboModule::InitParams &params)
26
+ : JavaTurboModule(params) {
27
+ methodMap_["installRustCrate"] = MethodMetadata {0, __hostFunction_NativeReactNativeBindingsSpecJSI_installRustCrate};
28
+ methodMap_["cleanupRustCrate"] = MethodMetadata {0, __hostFunction_NativeReactNativeBindingsSpecJSI_cleanupRustCrate};
29
+ }
30
+
31
+ std::shared_ptr<TurboModule> ReactNativeBindingsSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
32
+ if (moduleName == "ReactNativeBindings") {
33
+ return std::make_shared<NativeReactNativeBindingsSpecJSI>(params);
34
+ }
35
+ return nullptr;
36
+ }
37
+
38
+ } // namespace facebook::react
@@ -0,0 +1,31 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJniH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include <ReactCommon/JavaTurboModule.h>
14
+ #include <ReactCommon/TurboModule.h>
15
+ #include <jsi/jsi.h>
16
+
17
+ namespace facebook::react {
18
+
19
+ /**
20
+ * JNI C++ class for module 'NativeReactNativeBindings'
21
+ */
22
+ class JSI_EXPORT NativeReactNativeBindingsSpecJSI : public JavaTurboModule {
23
+ public:
24
+ NativeReactNativeBindingsSpecJSI(const JavaTurboModule::InitParams &params);
25
+ };
26
+
27
+
28
+ JSI_EXPORT
29
+ std::shared_ptr<TurboModule> ReactNativeBindingsSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
30
+
31
+ } // namespace facebook::react
@@ -0,0 +1,22 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateComponentDescriptorCpp.js
9
+ */
10
+
11
+ #include "ComponentDescriptors.h"
12
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
13
+ #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
14
+
15
+ namespace facebook::react {
16
+
17
+ void ReactNativeBindingsSpec_registerComponentDescriptorsFromCodegen(
18
+ std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
19
+
20
+ }
21
+
22
+ } // namespace facebook::react
@@ -0,0 +1,24 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateComponentDescriptorH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include "ShadowNodes.h"
14
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
+ #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
16
+
17
+ namespace facebook::react {
18
+
19
+
20
+
21
+ void ReactNativeBindingsSpec_registerComponentDescriptorsFromCodegen(
22
+ std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
23
+
24
+ } // namespace facebook::react
@@ -0,0 +1,16 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateEventEmitterCpp.js
9
+ */
10
+
11
+ #include "EventEmitters.h"
12
+
13
+
14
+ namespace facebook::react {
15
+
16
+ } // namespace facebook::react