Skip to content

Commit

Permalink
feat(rn): add alpha react native signer impl (#1128)
Browse files Browse the repository at this point in the history
* chore(rn): create example from template

* feat(rn-signer): add key pair generation in android

* feat(rn): add bundle injection logic

* feat(rn): add stamping logic to android stamper

* fix(rn): get login working e2e

* refactor(rn): clean things up so they're more digestable

* chore: update github actions for rn

* feat: add a global polyfill for react-native-mmkv (#1159)

# Pull Request Checklist

- [ ] Did you add new tests and confirm existing tests pass? (`yarn test`)
- [ ] Did you update relevant docs? (docs are found in the `site` folder, and guidelines for updating/adding docs can be found in the [contribution guide](https://github.com/alchemyplatform/aa-sdk/blob/main/CONTRIBUTING.md))
- [x] Do your commits follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard?
- [x] Does your PR title also follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard?
- [x] If you have a breaking change, is it [correctly reflected in your commit message](https://www.conventionalcommits.org/en/v1.0.0/#examples)? (e.g. `feat!: breaking change`)
- [x] Did you run lint (`yarn lint:check`) and fix any issues? (`yarn lint:write`)
- [x] Did you follow the [contribution guidelines](https://github.com/alchemyplatform/aa-sdk/blob/main/CONTRIBUTING.md)?

* feat: implement signer `create` and `disconnect` methods (#1152)

* feat: implement RNSigner class (#1161)

* feat: update type definitions for consistency

* feat: update client constructor to parse params based on schema

* chore: add example app to rn-base (#1171)

* fix: fix linting and spacing issues

* feat: remove package hoisting from example project

* fix: fix linting and spacing issues

* feat: add signer authentication sample implementation in example app

* feat: add tsx to handle server instantiation

* feat: update peer-dependencies for signer package

---------

Co-authored-by: Iyk Azorji <[email protected]>

* chore: update the gh action cache for yarn

* feat: update rn-signer readme to contain additional setup information (#1172)

---------

Co-authored-by: Iyk Azorji <[email protected]>
  • Loading branch information
moldy530 and iykazrji authored Dec 2, 2024
1 parent 18d0827 commit d87499e
Show file tree
Hide file tree
Showing 105 changed files with 9,105 additions and 1,145 deletions.
7 changes: 6 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ site/.vitepress/cache/**/*
!/examples/ui-demo
/examples/ui-demo/.next/*

**/.turbo/*
**/.turbo/*
account-kit/rn-signer/lib/*
**/android/generated/*
**/ios/generated/*
**/build/*
**/.cxx/*
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
site/**/*/reference/**/*.mdx linguist-generated
site/sidebar/**/*.ts linguist-generated
account-kit/smart-contracts/src/msca/plugins/**/plugin.ts linguist-generated

*.pbxproj -text
# specific for windows script files
*.bat text eol=crlf
14 changes: 14 additions & 0 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ runs:
node-version: ${{ inputs.node-version }}
cache: yarn

- name: Cache dependencies
id: yarn-cache
uses: actions/cache@v3
with:
path: |
**/node_modules
!examples/embedded-accounts-quickstart
.yarn/install-state.gz
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }}
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
${{ runner.os }}-yarn-
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
shell: bash
63 changes: 62 additions & 1 deletion .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ jobs:
name: Enforce PR Title Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: "0"
submodules: "recursive"

- name: Setup Node
uses: ./.github/actions/setup-node
Expand All @@ -33,6 +36,7 @@ jobs:
with:
token: ${{ secrets.ALCHEMY_BOT_PAT }}
fetch-depth: "0"
submodules: "recursive"

- name: Setup Node
uses: ./.github/actions/setup-node
Expand Down Expand Up @@ -94,3 +98,60 @@ jobs:

- name: Unit Test
run: yarn test:ci

build_android:
name: Build Android
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
steps:
- name: "Checkout files"
uses: actions/checkout@v3
with:
fetch-depth: "0"
submodules: "recursive"

- name: Setup Node
uses: ./.github/actions/setup-node

- name: Check turborepo cache for Android
run: |
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --dry=json | sed '1,2d;$d')).tasks.find(t => t.task === 'build:android').cache.status")
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
echo "turbo_cache_hit=1" >> $GITHUB_ENV
fi
- name: Install JDK
if: env.turbo_cache_hit != 1
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "17"

- name: Finalize Android SDK
if: env.turbo_cache_hit != 1
run: |
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
- name: Cache Gradle
if: env.turbo_cache_hit != 1
uses: actions/cache@v3
with:
path: |
~/.gradle/wrapper
~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build RN Library
run: yarn prepare

- name: Build example for Android
env:
JAVA_OPTS: "-XX:MaxHeapSize=6g"
run: |
yarn turbo run build:android
86 changes: 86 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dist
node_modules
tsconfig*.tsbuildinfo
.idea/
.nx

# local env files
.env
Expand Down Expand Up @@ -39,3 +40,88 @@ bin

# Turborepo
.turbo

### React Native .gitignore
# OSX
#
.DS_Store

# XDE
.expo/

# VSCode
.vscode/
jsconfig.json

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IJ
#
.classpath
.cxx
.gradle
.idea
.project
.settings
local.properties
android.iml

# Cocoapods
#
example/ios/Pods

# Ruby
example/vendor/

# node.js
#
node_modules/
npm-debug.log
yarn-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
android/app/libs
android/keystores/debug.keystore

# Yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Expo
.expo/

# Turborepo
.turbo/

# generated by bob
lib/

# React Native Codegen
**/ios/generated
**/android/generated

57 changes: 57 additions & 0 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/sh

if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then
set -x
fi

if [ "$LEFTHOOK" = "0" ]; then
exit 0
fi

call_lefthook()
{
if test -n "$LEFTHOOK_BIN"
then
"$LEFTHOOK_BIN" "$@"
elif lefthook -h >/dev/null 2>&1
then
lefthook "$@"
else
dir="$(git rev-parse --show-toplevel)"
osArch=$(uname | tr '[:upper:]' '[:lower:]')
cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/')
if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook"
then
"$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook" "$@"
elif test -f "$dir/node_modules/lefthook/bin/index.js"
then
"$dir/node_modules/lefthook/bin/index.js" "$@"

elif bundle exec lefthook -h >/dev/null 2>&1
then
bundle exec lefthook "$@"
elif yarn lefthook -h >/dev/null 2>&1
then
yarn lefthook "$@"
elif pnpm lefthook -h >/dev/null 2>&1
then
pnpm lefthook "$@"
elif swift package plugin lefthook >/dev/null 2>&1
then
swift package --disable-sandbox plugin lefthook "$@"
elif command -v mint >/dev/null 2>&1
then
mint run csjones/lefthook-plugin "$@"
else
echo "Can't find lefthook in PATH"
fi
fi
}

call_lefthook run "prepare-commit-msg" "$@"
2 changes: 1 addition & 1 deletion aa-sdk/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"registry": "https://registry.npmjs.org/"
},
"scripts": {
"prebuild": "npx tsx ./inject-version.ts",
"prebuild": "tsx ./inject-version.ts",
"build": "yarn clean && yarn build:esm && yarn build:types",
"build:esm": "tsc --project tsconfig.build.json --outDir ./dist/esm",
"build:types": "tsc --project tsconfig.build.json --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
Expand Down
2 changes: 1 addition & 1 deletion account-kit/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"./package.json": "./package.json"
},
"scripts": {
"prebuild": "npx tsx ./inject-version.ts",
"prebuild": "tsx ./inject-version.ts",
"build": "yarn clean && yarn build:esm && yarn build:types",
"build:esm": "tsc --project tsconfig.build.json --outDir ./dist/esm",
"build:types": "tsc --project tsconfig.build.json --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
Expand Down
2 changes: 1 addition & 1 deletion account-kit/infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"./package.json": "./package.json"
},
"scripts": {
"prebuild": "npx tsx ./inject-version.ts",
"prebuild": "tsx ./inject-version.ts",
"build": "yarn clean && yarn build:esm && yarn build:types",
"build:esm": "tsc --project tsconfig.build.json --outDir ./dist/esm",
"build:types": "tsc --project tsconfig.build.json --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
Expand Down
4 changes: 2 additions & 2 deletions account-kit/logging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
"./package.json": "./package.json"
},
"scripts": {
"prebuild": "npx tsx ./prebuild.ts",
"prebuild": "tsx ./prebuild.ts",
"build": "yarn clean && yarn build:esm && yarn build:types",
"build:esm": "tsc --project tsconfig.build.json --outDir ./dist/esm",
"build:types": "tsc --project tsconfig.build.json --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
"postbuild": "npx tsx ./postbuild.ts",
"postbuild": "tsx ./postbuild.ts",
"clean": "rm -rf ./dist",
"test": "vitest --passWithNoTests",
"test:run": "vitest run --passWithNoTests"
Expand Down
2 changes: 1 addition & 1 deletion account-kit/plugingen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"plugingen": "./dist/esm/cli.js"
},
"scripts": {
"prebuild": "npx tsx ./inject-version.ts",
"prebuild": "tsx ./inject-version.ts",
"build": "yarn clean && yarn build:esm && yarn build:types",
"build:esm": "tsc --project tsconfig.build.json --outDir ./dist/esm",
"build:types": "tsc --project tsconfig.build.json --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
Expand Down
2 changes: 1 addition & 1 deletion account-kit/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"./package.json": "./package.json"
},
"scripts": {
"prebuild": "npx tsx ./inject-version.ts",
"prebuild": "tsx ./inject-version.ts",
"dev": "storybook dev",
"build": "yarn clean && yarn build:esm && yarn build:types",
"build:esm": "tsc --project tsconfig.build.json --outDir ./dist/esm",
Expand Down
27 changes: 27 additions & 0 deletions account-kit/rn-signer/.github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Setup
description: Setup Node.js and install dependencies

runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc

- name: Cache dependencies
id: yarn-cache
uses: actions/cache@v3
with:
path: |
**/node_modules
.yarn/install-state.gz
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }}
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
${{ runner.os }}-yarn-
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
shell: bash
Loading

0 comments on commit d87499e

Please sign in to comment.