@baerae/zkap-zkp-react-native 0.1.4 → 0.1.6
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.
- package/README.md +24 -1
- package/ZkapReactNative.podspec +42 -0
- package/android/CMakeLists.txt +81 -0
- package/android/build.gradle +111 -14
- package/android/cpp-adapter.cpp +43 -0
- package/android/libs/arm64-v8a/libzkap_uniffi_bindings.so +0 -0
- package/android/libs/x86_64/libzkap_uniffi_bindings.so +0 -0
- package/android/proguard-rules.pro +2 -0
- package/android/src/main/AndroidManifest.xml +5 -0
- package/android/src/main/java/com/baerae/zkapreactnative/ZkapReactNativeModule.kt +51 -0
- package/android/src/main/java/com/baerae/zkapreactnative/ZkapReactNativePackage.kt +34 -0
- package/cpp/baerae-zkap-react-native.cpp +17 -0
- package/cpp/baerae-zkap-react-native.h +15 -0
- package/cpp/generated/zkap_uniffi_bindings.cpp +2154 -0
- package/cpp/generated/zkap_uniffi_bindings.hpp +66 -0
- package/ios/ZkapReactNative.h +16 -0
- package/ios/ZkapReactNative.mm +412 -0
- package/ios/ZkapZkp.xcframework/Info.plist +5 -5
- package/ios/ZkapZkp.xcframework/ios-arm64/libzkap_uniffi_bindings.a +0 -0
- package/ios/ZkapZkp.xcframework/ios-arm64_x86_64-simulator/libzkap_uniffi_bindings.a +0 -0
- package/package.json +37 -14
- package/src/NativeZkapReactNative.ts +11 -0
- package/src/generated/zkap_uniffi_bindings-ffi.ts +150 -0
- package/src/generated/zkap_uniffi_bindings.ts +1015 -0
- package/src/index.ts +250 -46
- package/ubrn.config.yaml +13 -0
- package/android/libs/armeabi-v7a/libzkap_uniffi_bindings.so +0 -0
- package/android/src/main/java/expo/modules/zkap/ZkapSdkModule.kt +0 -153
- package/android/src/main/java/uniffi/zkap_uniffi_bindings/zkap_uniffi_bindings.kt +0 -1566
- package/expo-module.config.json +0 -9
- package/ios/ZkapSdkModule.podspec +0 -35
- package/ios/ZkapSdkModule.swift +0 -147
- package/ios/uniffi/zkap_uniffi_bindings.swift +0 -1174
- package/ios/uniffi/zkap_uniffi_bindingsFFI.h +0 -567
- package/ios/uniffi/zkap_uniffi_bindingsFFI.modulemap +0 -7
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ React Native SDK for zkap-zkp with Expo modules integration.
|
|
|
5
5
|
Install:
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
8
|
+
npx expo install @baerae/zkap-zkp-react-native
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
Requires Expo New Architecture and the following peer dependencies:
|
|
@@ -22,3 +22,26 @@ const anchor = await generateAnchor(config, secrets)
|
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
The npm package bundles the iOS XCFramework and Android `.so` libraries produced by CI.
|
|
25
|
+
|
|
26
|
+
This direct runtime package exposes the React Native UniFFI API and keeps the
|
|
27
|
+
historical snake_case request/config shape. Use `@baerae/zkap-zkp` with this
|
|
28
|
+
package when you need the camelCase compatibility facade plus helpers such as
|
|
29
|
+
`downloadRelease()` and `loadCircuitConfig()`.
|
|
30
|
+
|
|
31
|
+
`prove()` expects a downloaded zkap-circuit release bundle that includes
|
|
32
|
+
`manifest.json`, `pk.bin`, `circuit.ar1cs`, and `witness_gen.wasm` from the same
|
|
33
|
+
circuit release. The package does not bundle `witness_gen.wasm`.
|
|
34
|
+
|
|
35
|
+
On iOS-family targets, `witness_gen.wasm` runs inside a headless `WKWebView`.
|
|
36
|
+
The witness output is transferred back to native code with chunked base64,
|
|
37
|
+
validated by sha256/length, written to a temp file, and then consumed by the
|
|
38
|
+
native proof pipeline. The iOS native binary does not link Wasmtime, Cranelift,
|
|
39
|
+
Pulley, or Wasmi.
|
|
40
|
+
|
|
41
|
+
Android and other non-iOS native targets keep the Wasmtime-backed witness
|
|
42
|
+
runtime and pass witness bytes directly into the native proof pipeline without a
|
|
43
|
+
React Native bridge transfer.
|
|
44
|
+
|
|
45
|
+
For App Store submissions, keep the zkap-circuit release URL immutable and pin
|
|
46
|
+
the expected release artifact hashes. The SDK validates the release bundle before
|
|
47
|
+
proving, but App Review approval is still the host app's responsibility.
|
|
@@ -0,0 +1,42 @@
|
|
|
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 = "ZkapReactNative"
|
|
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/baerae-zkap/zkap-zkp-sdk.git", :tag => "#{s.version}" }
|
|
17
|
+
|
|
18
|
+
s.source_files = "ios/ZkapReactNative.{h,mm}", "cpp/**/*.{hpp,cpp,c,h}"
|
|
19
|
+
s.vendored_frameworks = "ios/ZkapZkp.xcframework"
|
|
20
|
+
s.frameworks = "WebKit"
|
|
21
|
+
s.dependency "uniffi-bindgen-react-native", "0.31.0-2"
|
|
22
|
+
|
|
23
|
+
if respond_to?(:install_modules_dependencies, true)
|
|
24
|
+
install_modules_dependencies(s)
|
|
25
|
+
else
|
|
26
|
+
s.dependency "React-Core"
|
|
27
|
+
|
|
28
|
+
if ENV["RCT_NEW_ARCH_ENABLED"] == "1" then
|
|
29
|
+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
|
30
|
+
s.pod_target_xcconfig = {
|
|
31
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
|
32
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
|
|
33
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
34
|
+
}
|
|
35
|
+
s.dependency "React-Codegen"
|
|
36
|
+
s.dependency "RCT-Folly"
|
|
37
|
+
s.dependency "RCTRequired"
|
|
38
|
+
s.dependency "RCTTypeSafety"
|
|
39
|
+
s.dependency "ReactCommon/turbomodule/core"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Generated by uniffi-bindgen-react-native
|
|
2
|
+
cmake_minimum_required(VERSION 3.9.0)
|
|
3
|
+
project(ZkapReactNative)
|
|
4
|
+
|
|
5
|
+
set (CMAKE_VERBOSE_MAKEFILE ON)
|
|
6
|
+
set (CMAKE_CXX_STANDARD 17)
|
|
7
|
+
|
|
8
|
+
if(NOT DEFINED NODE_MODULES_DIR)
|
|
9
|
+
set(NODE_MODULES_DIR "${CMAKE_SOURCE_DIR}/../../node_modules")
|
|
10
|
+
endif()
|
|
11
|
+
|
|
12
|
+
# Resolve the path to the uniffi-bindgen-react-native package. When this
|
|
13
|
+
# package is consumed through a local file dependency, Gradle follows the
|
|
14
|
+
# symlink into this repo, so Node's default lookup does not reach the app's
|
|
15
|
+
# node_modules unless we pass it explicitly.
|
|
16
|
+
execute_process(
|
|
17
|
+
COMMAND node -p "require.resolve('uniffi-bindgen-react-native/package.json', { paths: [process.cwd(), '${NODE_MODULES_DIR}'] })"
|
|
18
|
+
OUTPUT_VARIABLE UNIFFI_BINDGEN_PATH
|
|
19
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
20
|
+
)
|
|
21
|
+
# Get the directory; get_filename_component and cmake_path will normalize
|
|
22
|
+
# paths with Windows path separators.
|
|
23
|
+
get_filename_component(UNIFFI_BINDGEN_PATH "${UNIFFI_BINDGEN_PATH}" DIRECTORY)
|
|
24
|
+
|
|
25
|
+
# Specifies a path to native header files.
|
|
26
|
+
include_directories(
|
|
27
|
+
../cpp
|
|
28
|
+
../cpp/generated
|
|
29
|
+
|
|
30
|
+
${UNIFFI_BINDGEN_PATH}/cpp/includes
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
add_library(baerae-zkap-react-native SHARED
|
|
34
|
+
../cpp/baerae-zkap-react-native.cpp
|
|
35
|
+
../cpp/generated/zkap_uniffi_bindings.cpp
|
|
36
|
+
cpp-adapter.cpp
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
# Set C++ compiler flags
|
|
40
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
|
41
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
|
|
42
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti")
|
|
43
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all")
|
|
44
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
|
45
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
|
46
|
+
|
|
47
|
+
# Set linker flags for 16KB page size alignment (required for Android 15+)
|
|
48
|
+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,max-page-size=16384")
|
|
49
|
+
|
|
50
|
+
set(MY_RUST_LIB_DIR "${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}")
|
|
51
|
+
target_link_directories(baerae-zkap-react-native PRIVATE "${MY_RUST_LIB_DIR}")
|
|
52
|
+
|
|
53
|
+
# Add ReactAndroid libraries, being careful to account for different versions.
|
|
54
|
+
find_package(ReactAndroid REQUIRED CONFIG)
|
|
55
|
+
find_library(LOGCAT log)
|
|
56
|
+
|
|
57
|
+
# REACTNATIVE_MERGED_SO seems to be only be set in a build.gradle.kt file,
|
|
58
|
+
# which we don't use. Thus falling back to version number sniffing.
|
|
59
|
+
if (ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
60
|
+
set(REACTNATIVE_MERGED_SO true)
|
|
61
|
+
endif()
|
|
62
|
+
|
|
63
|
+
# https://github.com/react-native-community/discussions-and-proposals/discussions/816
|
|
64
|
+
# This if-then-else can be removed once this library does not support version below 0.76
|
|
65
|
+
if (REACTNATIVE_MERGED_SO)
|
|
66
|
+
target_link_libraries(baerae-zkap-react-native ReactAndroid::reactnative)
|
|
67
|
+
else()
|
|
68
|
+
target_link_libraries(baerae-zkap-react-native
|
|
69
|
+
ReactAndroid::turbomodulejsijni
|
|
70
|
+
ReactAndroid::react_nativemodule_core
|
|
71
|
+
)
|
|
72
|
+
endif()
|
|
73
|
+
|
|
74
|
+
find_package(fbjni REQUIRED CONFIG)
|
|
75
|
+
target_link_libraries(
|
|
76
|
+
baerae-zkap-react-native
|
|
77
|
+
fbjni::fbjni
|
|
78
|
+
ReactAndroid::jsi
|
|
79
|
+
${LOGCAT}
|
|
80
|
+
zkap_uniffi_bindings
|
|
81
|
+
)
|
package/android/build.gradle
CHANGED
|
@@ -1,32 +1,129 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
|
|
3
|
+
buildscript {
|
|
4
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : (project.properties["ZkapReactNative_kotlinVersion"] ?: "1.9.24")
|
|
5
|
+
|
|
6
|
+
repositories {
|
|
7
|
+
google()
|
|
8
|
+
mavenCentral()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
dependencies {
|
|
12
|
+
classpath "com.android.tools.build:gradle:7.2.1"
|
|
13
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
def reactNativeArchitectures() {
|
|
18
|
+
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
19
|
+
def supported = ["x86_64", "arm64-v8a"]
|
|
20
|
+
return value ? value.split(",").findAll { supported.contains(it) } : supported
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
def isNewArchitectureEnabled() {
|
|
24
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
apply plugin: "com.android.library"
|
|
28
|
+
apply plugin: "kotlin-android"
|
|
29
|
+
|
|
30
|
+
if (isNewArchitectureEnabled()) {
|
|
31
|
+
apply plugin: "com.facebook.react"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
def getExtOrDefault(name) {
|
|
35
|
+
def defaults = [
|
|
36
|
+
kotlinVersion: "1.9.24",
|
|
37
|
+
ndkVersion: "27.1.12297006",
|
|
38
|
+
]
|
|
39
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ZkapReactNative_" + name] ?: defaults[name])
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
def getExtOrIntegerDefault(name) {
|
|
43
|
+
def defaults = [
|
|
44
|
+
compileSdkVersion: 35,
|
|
45
|
+
minSdkVersion: 24,
|
|
46
|
+
targetSdkVersion: 35,
|
|
47
|
+
]
|
|
48
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ZkapReactNative_" + name] ?: defaults[name]).toInteger()
|
|
49
|
+
}
|
|
3
50
|
|
|
4
51
|
android {
|
|
5
|
-
|
|
6
|
-
|
|
52
|
+
namespace "com.baerae.zkapreactnative"
|
|
53
|
+
ndkVersion getExtOrDefault("ndkVersion")
|
|
54
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
7
55
|
|
|
8
56
|
defaultConfig {
|
|
9
|
-
minSdkVersion
|
|
10
|
-
targetSdkVersion
|
|
57
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
58
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
59
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
60
|
+
consumerProguardFiles "proguard-rules.pro"
|
|
61
|
+
|
|
62
|
+
buildFeatures {
|
|
63
|
+
prefab true
|
|
64
|
+
}
|
|
65
|
+
externalNativeBuild {
|
|
66
|
+
cmake {
|
|
67
|
+
arguments "-DANDROID_STL=c++_shared",
|
|
68
|
+
"-DNODE_MODULES_DIR=${rootProject.projectDir}/../node_modules"
|
|
69
|
+
abiFilters (*reactNativeArchitectures())
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
ndk {
|
|
73
|
+
abiFilters "arm64-v8a", "x86_64"
|
|
74
|
+
}
|
|
11
75
|
}
|
|
12
76
|
|
|
13
77
|
sourceSets {
|
|
14
78
|
main {
|
|
15
|
-
java.srcDirs
|
|
16
|
-
|
|
79
|
+
java.srcDirs = ["src/main/java/com/baerae/zkapreactnative"]
|
|
80
|
+
kotlin.srcDirs = ["src/main/java/com/baerae/zkapreactnative"]
|
|
81
|
+
jniLibs.srcDirs = ["libs"]
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
externalNativeBuild {
|
|
86
|
+
cmake {
|
|
87
|
+
path "CMakeLists.txt"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
buildFeatures {
|
|
92
|
+
buildConfig true
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
buildTypes {
|
|
96
|
+
release {
|
|
97
|
+
minifyEnabled false
|
|
17
98
|
}
|
|
18
99
|
}
|
|
100
|
+
|
|
101
|
+
lintOptions {
|
|
102
|
+
disable "GradleCompatible"
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
compileOptions {
|
|
106
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
107
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
108
|
+
}
|
|
19
109
|
}
|
|
20
110
|
|
|
21
111
|
repositories {
|
|
22
112
|
mavenCentral()
|
|
113
|
+
google()
|
|
23
114
|
}
|
|
24
115
|
|
|
116
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
117
|
+
|
|
25
118
|
dependencies {
|
|
26
|
-
implementation "
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
119
|
+
implementation "com.facebook.react:react-native:+"
|
|
120
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (isNewArchitectureEnabled()) {
|
|
124
|
+
react {
|
|
125
|
+
jsRootDir = file("../src/")
|
|
126
|
+
libraryName = "ZkapReactNative"
|
|
127
|
+
codegenJavaPackageName = "com.baerae.zkapreactnative"
|
|
128
|
+
}
|
|
32
129
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
#include <jni.h>
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <ReactCommon/CallInvokerHolder.h>
|
|
5
|
+
#include "baerae-zkap-react-native.h"
|
|
6
|
+
|
|
7
|
+
namespace jsi = facebook::jsi;
|
|
8
|
+
namespace react = facebook::react;
|
|
9
|
+
|
|
10
|
+
// Automated testing checks Java_com_baerae_zkapreactnative_ZkapReactNativeModule and baerae_zkapreactnative
|
|
11
|
+
// by comparing the whole line here.
|
|
12
|
+
/*
|
|
13
|
+
Java_com_baerae_zkapreactnative_ZkapReactNativeModule_nativeMultiply(JNIEnv *env, jclass type, jdouble a, jdouble b) {
|
|
14
|
+
return baerae_zkapreactnative::multiply(a, b);
|
|
15
|
+
}
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
// Installer coming from ZkapReactNativeModule
|
|
19
|
+
extern "C"
|
|
20
|
+
JNIEXPORT jboolean JNICALL
|
|
21
|
+
Java_com_baerae_zkapreactnative_ZkapReactNativeModule_nativeInstallRustCrate(
|
|
22
|
+
JNIEnv *env,
|
|
23
|
+
jclass type,
|
|
24
|
+
jlong rtPtr,
|
|
25
|
+
jobject callInvokerHolderJavaObj
|
|
26
|
+
) {
|
|
27
|
+
using JCallInvokerHolder = facebook::react::CallInvokerHolder;
|
|
28
|
+
|
|
29
|
+
auto holderLocal = facebook::jni::make_local(callInvokerHolderJavaObj);
|
|
30
|
+
auto holderRef = facebook::jni::static_ref_cast<JCallInvokerHolder::javaobject>(holderLocal);
|
|
31
|
+
auto* holderCxx = holderRef->cthis();
|
|
32
|
+
auto jsCallInvoker = holderCxx->getCallInvoker();
|
|
33
|
+
auto runtime = reinterpret_cast<jsi::Runtime *>(rtPtr);
|
|
34
|
+
|
|
35
|
+
return baerae_zkapreactnative::installRustCrate(*runtime, jsCallInvoker);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
extern "C"
|
|
39
|
+
JNIEXPORT jboolean JNICALL
|
|
40
|
+
Java_com_baerae_zkapreactnative_ZkapReactNativeModule_nativeCleanupRustCrate(JNIEnv *env, jclass type, jlong rtPtr) {
|
|
41
|
+
auto runtime = reinterpret_cast<jsi::Runtime *>(rtPtr);
|
|
42
|
+
return baerae_zkapreactnative::cleanupRustCrate(*runtime);
|
|
43
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
package com.baerae.zkapreactnative
|
|
3
|
+
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.Promise
|
|
6
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
7
|
+
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder
|
|
8
|
+
|
|
9
|
+
@ReactModule(name = ZkapReactNativeModule.NAME)
|
|
10
|
+
class ZkapReactNativeModule(reactContext: ReactApplicationContext) :
|
|
11
|
+
NativeZkapReactNativeSpec(reactContext) {
|
|
12
|
+
|
|
13
|
+
override fun getName(): String {
|
|
14
|
+
return NAME
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Two native methods implemented in cpp-adapter.cpp, and ultimately
|
|
18
|
+
// baerae-zkap-react-native.cpp
|
|
19
|
+
|
|
20
|
+
external fun nativeInstallRustCrate(runtimePointer: Long, callInvoker: CallInvokerHolder): Boolean
|
|
21
|
+
external fun nativeCleanupRustCrate(runtimePointer: Long): Boolean
|
|
22
|
+
|
|
23
|
+
override fun installRustCrate(): Boolean {
|
|
24
|
+
val context = this.reactApplicationContext
|
|
25
|
+
return nativeInstallRustCrate(
|
|
26
|
+
context.javaScriptContextHolder!!.get(),
|
|
27
|
+
context.jsCallInvokerHolder!!
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
override fun cleanupRustCrate(): Boolean {
|
|
32
|
+
return nativeCleanupRustCrate(
|
|
33
|
+
this.reactApplicationContext.javaScriptContextHolder!!.get()
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
override fun runWitnessInWkWebView(inputJson: String, promise: Promise) {
|
|
38
|
+
promise.reject(
|
|
39
|
+
"zkap-witness-webview-unsupported",
|
|
40
|
+
"runWitnessInWkWebView is only available on iOS"
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
companion object {
|
|
45
|
+
const val NAME = "ZkapReactNative"
|
|
46
|
+
|
|
47
|
+
init {
|
|
48
|
+
System.loadLibrary("baerae-zkap-react-native")
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
package com.baerae.zkapreactnative
|
|
3
|
+
|
|
4
|
+
import com.facebook.react.TurboReactPackage
|
|
5
|
+
import com.facebook.react.bridge.NativeModule
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
8
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
9
|
+
import java.util.HashMap
|
|
10
|
+
|
|
11
|
+
class ZkapReactNativePackage : TurboReactPackage() {
|
|
12
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
13
|
+
return if (name == ZkapReactNativeModule.NAME) {
|
|
14
|
+
ZkapReactNativeModule(reactContext)
|
|
15
|
+
} else {
|
|
16
|
+
null
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
21
|
+
return ReactModuleInfoProvider {
|
|
22
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
23
|
+
moduleInfos[ZkapReactNativeModule.NAME] = ReactModuleInfo(
|
|
24
|
+
ZkapReactNativeModule.NAME,
|
|
25
|
+
ZkapReactNativeModule.NAME,
|
|
26
|
+
false, // canOverrideExistingModule
|
|
27
|
+
false, // needsEagerInit
|
|
28
|
+
false, // isCxxModule
|
|
29
|
+
true // isTurboModule
|
|
30
|
+
)
|
|
31
|
+
moduleInfos
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
#include "baerae-zkap-react-native.h"
|
|
3
|
+
#include "generated/zkap_uniffi_bindings.hpp"
|
|
4
|
+
|
|
5
|
+
namespace baerae_zkapreactnative {
|
|
6
|
+
using namespace facebook;
|
|
7
|
+
|
|
8
|
+
uint8_t installRustCrate(jsi::Runtime &runtime, std::shared_ptr<react::CallInvoker> callInvoker) {
|
|
9
|
+
NativeZkapUniffiBindings::registerModule(runtime, callInvoker);
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
uint8_t cleanupRustCrate(jsi::Runtime &runtime) {
|
|
14
|
+
NativeZkapUniffiBindings::unregisterModule(runtime);
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#ifndef BAERAE_ZKAPREACTNATIVE_H
|
|
2
|
+
#define BAERAE_ZKAPREACTNATIVE_H
|
|
3
|
+
// Generated by uniffi-bindgen-react-native
|
|
4
|
+
#include <cstdint>
|
|
5
|
+
#include <jsi/jsi.h>
|
|
6
|
+
#include <ReactCommon/CallInvoker.h>
|
|
7
|
+
|
|
8
|
+
namespace baerae_zkapreactnative {
|
|
9
|
+
using namespace facebook;
|
|
10
|
+
|
|
11
|
+
uint8_t installRustCrate(jsi::Runtime &runtime, std::shared_ptr<react::CallInvoker> callInvoker);
|
|
12
|
+
uint8_t cleanupRustCrate(jsi::Runtime &runtime);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
#endif /* BAERAE_ZKAPREACTNATIVE_H */
|