@novastera-oss/nitro-metamask 0.7.2 → 0.7.5
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
CHANGED
|
@@ -57,7 +57,7 @@ No extra Android configuration is required for consumers of this package.
|
|
|
57
57
|
- The package ships prebuilt `libecies.so` binaries per ABI under `android/src/main/jniLibs`.
|
|
58
58
|
- Included ABIs: `arm64-v8a`, `armeabi-v7a`, `x86_64`, `x86`.
|
|
59
59
|
- Consumers do **not** need Rust or Cargo installed.
|
|
60
|
-
-
|
|
60
|
+
- ECIES: the **npm package always** ships all four prebuilt `libecies.so` under `android/src/main/jniLibs/{arm64-v8a,armeabi-v7a,x86_64,x86}/` (CI normalizes to that path before `npm publish`). Installs use **only** those prebuilts — no Rust. Bare git worktrees without that folder, or maintainers passing `-PNitroMetamask_buildEciesFromSource=true`, build from `rust/ecies-jni` only; Gradle never merges prebuilts and Rust output (avoids duplicate `libecies.so` / `mergeDebugJniLibFolders` failures).
|
|
61
61
|
- CI verifies 16 KB ELF LOAD alignment for release native libraries before publish.
|
|
62
62
|
|
|
63
63
|
For app developers, the expected upgrade path is:
|
package/android/build.gradle
CHANGED
|
@@ -18,6 +18,34 @@ def isNewArchitectureEnabled() {
|
|
|
18
18
|
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/** True when the maintainer forces a Rust build even if prebuilts exist (CI). */
|
|
22
|
+
ext.nitroMetamaskBuildEciesFromSource = {
|
|
23
|
+
return rootProject.hasProperty("NitroMetamask_buildEciesFromSource") &&
|
|
24
|
+
rootProject.getProperty("NitroMetamask_buildEciesFromSource").toString() == "true"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** ABIs published in npm at android/src/main/jniLibs/<abi>/libecies.so (see scripts/ensure-npm-ecies-jni-layout.sh). */
|
|
28
|
+
ext.nitroMetamaskEciesPrebuiltAbis = ["arm64-v8a", "armeabi-v7a", "x86_64", "x86"]
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* True when all shipped prebuilts are present (typical npm install). Partial trees use Rust for missing ABIs
|
|
32
|
+
* only when the force flag is not set — we require the full set to match published tarball and avoid mixed jniLibs+Rust duplicate .so.
|
|
33
|
+
*/
|
|
34
|
+
ext.nitroMetamaskHasFullPrebuiltEciesJniLibs = {
|
|
35
|
+
def base = file("${projectDir}/src/main/jniLibs")
|
|
36
|
+
if (!base.isDirectory()) return false
|
|
37
|
+
return nitroMetamaskEciesPrebuiltAbis.every { abi -> new File(base, "${abi}/libecies.so").isFile() }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Use rust-ecies-jni (+ cargo) when: maintainer -P, OR full prebuilts missing (e.g. git without jniLibs).
|
|
42
|
+
* Published npm always includes full prebuilts at android/src/main/jniLibs — consumers never compile Rust.
|
|
43
|
+
*/
|
|
44
|
+
ext.nitroMetamaskUseEciesFromRustBuild = {
|
|
45
|
+
if (nitroMetamaskBuildEciesFromSource()) return true
|
|
46
|
+
return !nitroMetamaskHasFullPrebuiltEciesJniLibs()
|
|
47
|
+
}
|
|
48
|
+
|
|
21
49
|
// Nitro hybrid module: native bindings come from nitrogen/generated (NitroMetamask+autolinking.gradle + CMake).
|
|
22
50
|
// Do not apply com.facebook.react / react { libraryName } here — that registers RN New-Arch Codegen (react_codegen_*)
|
|
23
51
|
// and breaks consumers (CMake expects android/build/generated/source/codegen/jni/ which this package never ships).
|
|
@@ -117,9 +145,12 @@ android {
|
|
|
117
145
|
|
|
118
146
|
sourceSets {
|
|
119
147
|
main {
|
|
120
|
-
//
|
|
121
|
-
|
|
122
|
-
|
|
148
|
+
// Never both trees: duplicate libecies.so breaks mergeDebugJniLibFolders (see README).
|
|
149
|
+
if (nitroMetamaskUseEciesFromRustBuild()) {
|
|
150
|
+
jniLibs.srcDirs += ["${buildDir}/intermediates/rust-ecies-jni"]
|
|
151
|
+
} else {
|
|
152
|
+
jniLibs.srcDirs += ["src/main/jniLibs"]
|
|
153
|
+
}
|
|
123
154
|
aidl.srcDirs += ["src/main/aidl"]
|
|
124
155
|
}
|
|
125
156
|
}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
//
|
|
7
7
|
// The built .so files land in:
|
|
8
8
|
// android/build/intermediates/rust-ecies-jni/<abi>/libecies.so
|
|
9
|
-
//
|
|
9
|
+
// When jniLibs use rust-ecies-jni: all four prebuilts missing under src/main/jniLibs (e.g. git dev), or
|
|
10
|
+
// -PNitroMetamask_buildEciesFromSource=true. Published npm has android/src/main/jniLibs/<4 ABIs>/libecies.so only — no cargo.
|
|
10
11
|
// ──────────────────────────────────────────────────────────────────────────────
|
|
11
12
|
|
|
12
13
|
def eciesRustDir = file("${projectDir}/../rust/ecies-jni")
|
|
@@ -47,10 +48,17 @@ def findBin = { String name ->
|
|
|
47
48
|
return null
|
|
48
49
|
}
|
|
49
50
|
|
|
51
|
+
// Eager (configuration-time) — do not use `project` inside Task.onlyIf { } or Gradle 9+ configuration
|
|
52
|
+
// cache fails: "invocation of 'project' references a Gradle script object from a Groovy closure at execution time".
|
|
53
|
+
def cargoNdkBuildEciesShouldRun = project.nitroMetamaskUseEciesFromRustBuild() &&
|
|
54
|
+
eciesRustDir.isDirectory() &&
|
|
55
|
+
eciesCargoToml.isFile()
|
|
56
|
+
|
|
50
57
|
tasks.register("cargoNdkBuildEcies", Exec) {
|
|
51
58
|
group = "build"
|
|
52
|
-
description = "Build libecies.so from Rust
|
|
53
|
-
onlyIf
|
|
59
|
+
description = "Build libecies.so from Rust when jniLibs use rust-ecies-jni (see build.gradle)"
|
|
60
|
+
// Set `enabled` at configuration time (not `onlyIf { project... }`) for Gradle 9 configuration cache.
|
|
61
|
+
enabled = cargoNdkBuildEciesShouldRun
|
|
54
62
|
workingDir eciesRustDir
|
|
55
63
|
standardOutput System.out
|
|
56
64
|
errorOutput System.err
|
|
@@ -89,7 +97,9 @@ afterEvaluate {
|
|
|
89
97
|
}
|
|
90
98
|
}
|
|
91
99
|
|
|
92
|
-
|
|
93
|
-
|
|
100
|
+
if (cargoNdkBuildEciesShouldRun) {
|
|
101
|
+
tasks.matching { it.name.startsWith("preBuild") }.configureEach {
|
|
102
|
+
dependsOn("cargoNdkBuildEcies")
|
|
103
|
+
}
|
|
94
104
|
}
|
|
95
105
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
#include <fbjni/fbjni.h>
|
|
1
2
|
#include <jni.h>
|
|
3
|
+
|
|
2
4
|
#include "NitroMetamaskOnLoad.hpp"
|
|
3
5
|
|
|
4
6
|
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
|
5
|
-
return margelo::nitro::nitrometamask::
|
|
7
|
+
return facebook::jni::initialize(vm, []() { margelo::nitro::nitrometamask::registerAllNatives(); });
|
|
6
8
|
}
|
|
@@ -37,10 +37,9 @@ class NitroMetamaskPackage : BaseReactPackage() {
|
|
|
37
37
|
"NitroMetamaskPackage",
|
|
38
38
|
false, // canOverrideExistingModule
|
|
39
39
|
true, // needsEagerInit
|
|
40
|
-
true, // hasConstants
|
|
41
40
|
false, // isCxxModule
|
|
42
|
-
true // isTurboModule
|
|
43
|
-
)
|
|
41
|
+
true, // isTurboModule
|
|
42
|
+
),
|
|
44
43
|
)
|
|
45
44
|
}
|
|
46
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novastera-oss/nitro-metamask",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"description": "Native mobile MetaMask wallet integration for React Native. Part of Novastera CRM/ERP platform ecosystem. Provides secure authentication and message signing for Web3 mobile applications.",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/module/index.js",
|
|
@@ -47,7 +47,10 @@
|
|
|
47
47
|
"android/CMakeLists.txt",
|
|
48
48
|
"android/proguard-rules.pro",
|
|
49
49
|
"android/src",
|
|
50
|
-
"android/src/main/jniLibs",
|
|
50
|
+
"android/src/main/jniLibs/arm64-v8a/libecies.so",
|
|
51
|
+
"android/src/main/jniLibs/armeabi-v7a/libecies.so",
|
|
52
|
+
"android/src/main/jniLibs/x86_64/libecies.so",
|
|
53
|
+
"android/src/main/jniLibs/x86/libecies.so",
|
|
51
54
|
"android/src/main/java/io/metamask/**",
|
|
52
55
|
"android/src/main/aidl/**",
|
|
53
56
|
"ios/metamask-ios-sdk/**",
|