Skip to content

Commit 068a89a

Browse files
authoredFeb 27, 2024··
Seed Vault React Native Lib (#140)
* Seed Vault react native lib, pull to new clean branch * pr feeback pass 1: bob build and cleanup * remove rollup config from root, not used * pr feedback * align versions * adapt ci conditions
1 parent 67672f6 commit 068a89a

30 files changed

+10865
-0
lines changed
 

‎.github/workflows/android.yml

+2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ name: Android CI
33
on:
44
push:
55
branches: [ main ]
6+
paths: [ '.github/**', 'android/**' ]
67
pull_request:
78
branches: [ main ]
9+
paths: [ '.github/**', 'android/**' ]
810
release:
911
types: [ published ]
1012

‎js/.eslintrc

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": [
5+
"@typescript-eslint",
6+
"react-hooks",
7+
"require-extensions",
8+
"simple-import-sort"
9+
],
10+
"extends": [
11+
"eslint:recommended",
12+
"plugin:@typescript-eslint/recommended",
13+
"plugin:react-hooks/recommended",
14+
"plugin:require-extensions/recommended"
15+
],
16+
"rules": {
17+
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
18+
"simple-import-sort/imports": "error",
19+
"react-hooks/rules-of-hooks": "error",
20+
"react-hooks/exhaustive-deps": "warn"
21+
}
22+
}

‎js/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

‎js/.prettierrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"printWidth": 120,
3+
"singleQuote": true,
4+
"tabWidth": 4,
5+
"trailingComma": "all"
6+
}

‎js/lerna.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"npmClient": "yarn",
3+
"packages": [
4+
"packages/*"
5+
],
6+
"useWorkspaces": true,
7+
"version": "0.1.0"
8+
}

‎js/package.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "root",
3+
"private": true,
4+
"scripts": {
5+
"install": "lerna bootstrap",
6+
"build": "lerna run build",
7+
"clean": "lerna run clean"
8+
},
9+
"devDependencies": {
10+
"@rollup/plugin-alias": "^3.1.9",
11+
"@rollup/plugin-commonjs": "^22.0.0",
12+
"@rollup/plugin-node-resolve": "^13.3.0",
13+
"@rollup/plugin-replace": "^4.0.0",
14+
"@types/node": "17.0.35",
15+
"@types/node-fetch": "^2.6.1",
16+
"@typescript-eslint/eslint-plugin": "^5.27.0",
17+
"@typescript-eslint/parser": "^5.27.0",
18+
"eslint": "^8.17.0",
19+
"eslint-plugin-react-hooks": "^4.6.0",
20+
"eslint-plugin-require-extensions": "^0.1.1",
21+
"eslint-plugin-simple-import-sort": "^7.0.0",
22+
"lerna": "^5.1.8",
23+
"rollup": "^2.75.6",
24+
"rollup-plugin-node-externals": "^4.0.0",
25+
"rollup-plugin-ts": "^3.0.2",
26+
"shx": "^0.3.4",
27+
"typescript": "^4.7.3",
28+
"typescript-esm": "^2.0.0"
29+
},
30+
"workspaces": [
31+
"packages/*"
32+
]
33+
}

‎js/packages/seed-vault/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lib/
2+
android/build

‎js/packages/seed-vault/LICENSE

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2022 Solana Mobile Inc.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

‎js/packages/seed-vault/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `@solana-mobile/seedvaultlib`
2+
3+
A React Native wrapper of the Seed Vault SDK.
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Android/IJ
6+
#
7+
.classpath
8+
.cxx
9+
.gradle
10+
.idea
11+
.project
12+
.settings
13+
local.properties
14+
android.iml
+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
buildscript {
2+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
3+
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['SolanaMobileSeedVaultLibModule_kotlinVersion']
4+
5+
repositories {
6+
google()
7+
mavenCentral()
8+
}
9+
10+
dependencies {
11+
classpath 'com.android.tools.build:gradle:7.4.2'
12+
// noinspection DifferentKotlinGradleVersion
13+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14+
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
15+
}
16+
}
17+
18+
def isNewArchitectureEnabled() {
19+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
20+
}
21+
22+
apply plugin: 'com.android.library'
23+
apply plugin: 'kotlin-android'
24+
apply plugin: 'kotlinx-serialization'
25+
26+
if (isNewArchitectureEnabled()) {
27+
apply plugin: 'com.facebook.react'
28+
}
29+
30+
def getExtOrDefault(name) {
31+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['SolanaMobileSeedVaultLibModule_' + name]
32+
}
33+
34+
def getExtOrIntegerDefault(name) {
35+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['SolanaMobileSeedVaultLibModule_' + name]).toInteger()
36+
}
37+
38+
android {
39+
namespace "com.solanamobile.seedvault.reactnative"
40+
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
41+
42+
defaultConfig {
43+
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
44+
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
45+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
46+
}
47+
buildTypes {
48+
release {
49+
minifyEnabled false
50+
}
51+
}
52+
53+
lintOptions {
54+
disable 'GradleCompatible'
55+
}
56+
57+
compileOptions {
58+
sourceCompatibility JavaVersion.VERSION_1_8
59+
targetCompatibility JavaVersion.VERSION_1_8
60+
}
61+
}
62+
63+
repositories {
64+
mavenCentral()
65+
google()
66+
67+
def found = false
68+
def defaultDir = null
69+
def androidSourcesName = 'React Native sources'
70+
71+
if (rootProject.ext.has('reactNativeAndroidRoot')) {
72+
defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
73+
} else {
74+
defaultDir = new File(
75+
projectDir,
76+
'/../../../node_modules/react-native/android'
77+
)
78+
}
79+
80+
if (defaultDir.exists()) {
81+
maven {
82+
url defaultDir.toString()
83+
name androidSourcesName
84+
}
85+
86+
logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
87+
found = true
88+
} else {
89+
def parentDir = rootProject.projectDir
90+
91+
1.upto(5, {
92+
if (found) return true
93+
parentDir = parentDir.parentFile
94+
95+
def androidSourcesDir = new File(
96+
parentDir,
97+
'node_modules/react-native'
98+
)
99+
100+
def androidPrebuiltBinaryDir = new File(
101+
parentDir,
102+
'node_modules/react-native/android'
103+
)
104+
105+
if (androidPrebuiltBinaryDir.exists()) {
106+
maven {
107+
url androidPrebuiltBinaryDir.toString()
108+
name androidSourcesName
109+
}
110+
111+
logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
112+
found = true
113+
} else if (androidSourcesDir.exists()) {
114+
maven {
115+
url androidSourcesDir.toString()
116+
name androidSourcesName
117+
}
118+
119+
logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
120+
found = true
121+
}
122+
})
123+
}
124+
125+
if (!found) {
126+
throw new GradleException(
127+
"${project.name}: unable to locate React Native android sources. " +
128+
"Ensure you have you installed React Native as a dependency in your project and try again."
129+
)
130+
}
131+
}
132+
133+
def kotlin_version = getExtOrDefault('kotlinVersion')
134+
135+
dependencies {
136+
//noinspection GradleDynamicVersion
137+
implementation "com.facebook.react:react-native:+" // From node_modules
138+
implementation 'com.solanamobile:seedvault-wallet-sdk:0.2.8'
139+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
140+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
141+
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1"
142+
}
143+
144+
if (isNewArchitectureEnabled()) {
145+
react {
146+
jsRootDir = file("../src/")
147+
libraryName = "SolanaMobileWSeedVaultLibModule"
148+
codegenJavaPackageName = "com.solanamobile.SeedVault.reactnative"
149+
}
150+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SolanaMobileSeedVaultLibModule_kotlinVersion=1.7.0
2+
SolanaMobileSeedVaultLibModule_minSdkVersion=21
3+
SolanaMobileSeedVaultLibModule_targetSdkVersion=33
4+
SolanaMobileSeedVaultLibModule_compileSdkVersion=33
5+
SolanaMobileSeedVaultLibModule_ndkversion=21.4.7075529
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)
Please sign in to comment.