Skip to content

Commit

Permalink
feat!: new structure and tests (#19)
Browse files Browse the repository at this point in the history
Signed-off-by: blu3beri <[email protected]>
  • Loading branch information
berendsliedrecht authored Apr 11, 2022
1 parent 1325f21 commit fb67b58
Show file tree
Hide file tree
Showing 63 changed files with 1,692 additions and 3,277 deletions.
37 changes: 36 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,45 @@ jobs:
- name: Prettier
run: yarn check-format

- name: Check typescript
run: yarn check-types
native-tests:
runs-on: ubuntu-20.04
steps:
- name: Checkout ffi-bbs-signatures
uses: actions/checkout@v3
with:
repository: mattrglobal/ffi-bbs-signatures
path: ffi-bbs-signatures

- name: Checkout react-native-bbs-signatures
uses: actions/checkout@v3
with:
path: react-native-bbs-signatures
- name: Build ffi-bbs-signatures
uses: actions-rs/cargo@v1
with:
command: build
args: --release --manifest-path ffi-bbs-signatures/Cargo.toml
- name: Setup tests
run: |
mkdir react-native-bbs-signatures/cpp/tests/libs
mv ffi-bbs-signatures/target/release/libbbs.so react-native-bbs-signatures/cpp/tests/libs/libbbs.so
- name: Run native tests
run: |
cd react-native-bbs-signatures/cpp/tests
mkdir build
cd build
cmake ..
make
echo "Running BBS tests"
./bbs_test
echo "Tests exited with $?"
release:
runs-on: ubuntu-20.04
name: Release
needs: [validate]
needs: [validate, native-tests]
# Only run on workflow dispatch to main branch
if: github.ref == 'refs/heads/main' && github.repository == 'animo/react-native-bbs-signatures' && github.event_name == 'workflow_dispatch'
steps:
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ yarn-error.log
# BUCK
buck-out/
\.buckd/
android/app/libs
android/gradle*
android/keystores/debug.keystore

build
.expo/*
*.tgz
lib
cpp/tests/libs/*.dylib
cpp/tests/libs/
196 changes: 0 additions & 196 deletions CONTRIBUTING.md

This file was deleted.

85 changes: 5 additions & 80 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# React Native BBS Signatures

Wrapper for React Native around [ffi-bbs-signatures](https://github.com/mattrglobal/ffi-bbs-signatures). It matches the interface from the [BBS Signatures](https://github.com/mattrglobal/bbs-signatures) library so it can be used with the [JSON-LD Signatures BBS](https://github.com/mattrglobal/jsonld-signatures-bbs) library.
This library uses the new TurboModule for increased performance, however this may causes issues when something other than `React Native 0.66.4` is used.
Most versions above `0.64.x` should work, however the library has been tested extensively with `0.66.4` and it is garanteed to work.
This library uses the new TurboModule for increased performance. `React Native >=66` is required for this library to work.

## Functionality

Expand All @@ -22,91 +21,17 @@ To use this library in your React Native project run the following command:
yarn add @animo-id/react-native-bbs-signatures
```

Since autolinking is disabled for both iOS and Android the following steps also have to be done:

### iOS

We need to install the pod manually so apply the following diff:

```diff
# <PROJECT>/ios/Podfile

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '12.0'

target 'PROJECT' do
config = use_native_modules!

use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => true
)

+ pod 'react-native-bbs-signatures', :path => "../node_modules/@animo-id/react-native-bbs-signatures"

post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
```

After this run `pod install --project-directory=ios` from the root of your project and the installation
is complete.
On iOS you still need to run `pod install --project-directory=ios` in the root of your project to setup the native dependencies.

### Android

For Android we have to edit some more files in order for everything to work.

```diff
# <PROJECT>/android/settings.gradle

+ include ':reactnativebbssignatures'
+ project(':reactnativebbssignatures').projectDir = new File(rootProject.projectDir, '../node_modules/@animo-id/react-native-bbs-signatures/android')
```

```diff
# <PROJECT>/android/app/build.gradle
Since autolinking can handle everything on the Android side, no additional steps are required.

## Contributing

android {
...

+ packagingOptions {
+ pickFirst '**/*.so'
+ }
}

dependencies {
...


+ implementation (project(':reactnativebbssignatures')) {
+ exclude group:'com.facebook.fbjni'
+ }

}

```

```diff
# <PROJECT>/android/src/main/java/.../MainApplication.java

+ import com.reactnativebbssignatures.BbsSignaturesPackage;

@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
+ packages.add(new BbsSignaturesPackage());
return packages;
}

```

After these changes to your application everything is ready for usage.
If you want to add functionality to this library please make sure to run the tests in the `cpp/tests` folder with your added functionality add run the React Native tests inside the `example/` app.

## Credits

Expand Down
Loading

0 comments on commit fb67b58

Please sign in to comment.