Skip to content

Use cargokit for builds, generate Rust->C FFI bindings, and use official sources #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 55 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
98392ee
test: create_seed()
sneurlax Feb 6, 2025
ff106fc
test: mnemonic()
sneurlax Feb 6, 2025
3e220da
test: _get_mnemonic
sneurlax Feb 6, 2025
ab8cd00
test: test mnemonic uniqueness and reversibility
sneurlax Feb 6, 2025
f049095
test: specific known mnemonic->seed vector
sneurlax Feb 6, 2025
dad8727
chore: initial & WIP library refactor/reorganization
sneurlax Feb 6, 2025
b9fc4f1
chore: remove unused imports
sneurlax Feb 6, 2025
af703f0
test: add mnemonic tests
sneurlax Feb 7, 2025
d8d1e72
chore: WIP library refactor/reorganization, split wallet.rs out
sneurlax Feb 7, 2025
443f379
chore: WIP library refactor/reorganization, split listener.rs out
sneurlax Feb 7, 2025
e0c24d5
chore: WIP library refactor/reorganization, split wallet.rs out
sneurlax Feb 7, 2025
c3ca9b4
feat: library refactor/reorganization, split fns into separate files
sneurlax Feb 7, 2025
7e088fb
test: add more tests
sneurlax Feb 11, 2025
dabcab7
docs: comments throughout
sneurlax Feb 11, 2025
803a9e5
chore: import/clippy-cleanup (warning suppression)
sneurlax Feb 11, 2025
0613327
test: add more tests
sneurlax Feb 11, 2025
6bbae78
feat: add and navigate to wallet info view in example app as appropriate
sneurlax Feb 11, 2025
a7b69ca
feat: add wallet deletion icon and functionality to example app
sneurlax Feb 11, 2025
e4cf5df
feat: fix various bugs surrounding navigating while creating a wallet
sneurlax Feb 12, 2025
7f8a861
feat: move advanced functions view into wallet info view
sneurlax Feb 12, 2025
fd5e2d9
build!: remove lib link in linux example app cmakelists
sneurlax Feb 18, 2025
0e80393
Squashed 'cargokit/' content from commit 918f280
sneurlax Feb 18, 2025
4f3942a
Merge commit '0e8039303c9c7f3b0a9161bd3b4af378ac7cecfd' as 'cargokit'
sneurlax Feb 18, 2025
f592db4
docs: document cargokit updates
sneurlax Feb 18, 2025
cd45c83
build: WIP macos cargokit integration
sneurlax Feb 18, 2025
70ebb12
build: WIP ios cargokit integration
sneurlax Feb 18, 2025
98e6c6c
build: WIP linux cargokit integration
sneurlax Feb 18, 2025
a94d893
build: WIP windows cargokit integration
sneurlax Feb 18, 2025
0f499f2
build: WIP android cargokit integration
sneurlax Feb 18, 2025
a1d6e7f
fix: standardize crate and lib names
sneurlax Feb 18, 2025
ab843e9
Removed submodule rust/epic-wallet
sneurlax Mar 2, 2025
2b8c2a6
feat!: Remove /rust
sneurlax Mar 2, 2025
df9855e
Squashed 'rust/' content from commit f4bd572
sneurlax Mar 2, 2025
0ff9a6e
Merge commit 'df9855e0289922ac2fc77bf770523b9b7445d51b' as 'rust'
sneurlax Mar 2, 2025
af91dce
feat: add blacktyger/epic-wallet-rust-lib
sneurlax Mar 2, 2025
e55b1cb
Squashed 'rust/epic-wallet/' content from commit 03fc4944
sneurlax Mar 11, 2025
42f24ae
Merge commit 'e55b1cbe8cb83095945ab07782acca8bef809551' as 'rust/epic…
sneurlax Mar 11, 2025
2b7f01c
docs: credit Likho
sneurlax Mar 11, 2025
0489298
feat: use epic-wallet subtree
sneurlax Mar 11, 2025
9cad101
Squashed 'rust/epic/' content from commit 07fa6e3c1
sneurlax Mar 11, 2025
d1bcfb2
Merge commit '9cad101e61d49c2ee01e006594ae5c500c028cfb' as 'rust/epic'
sneurlax Mar 11, 2025
e1f8426
feat: use epic subtree
sneurlax Mar 11, 2025
a09f6df
feat: use epic subtree
sneurlax Mar 11, 2025
aa21f54
Squashed 'rust/epicbox/' content from commit 9ab9409fc
sneurlax Mar 12, 2025
c5bc692
Merge commit 'aa21f5435e9378a1f00c24c4ef225c1e68bb4220' as 'rust/epic…
sneurlax Mar 12, 2025
ca63922
feat: use epicbox subtree
sneurlax Mar 12, 2025
1d45e45
feat: use epic and epic-wallet subtrees
sneurlax Mar 12, 2025
026a6a2
feat: remove epic subtree
sneurlax Mar 14, 2025
80a51cc
feat: remove epic-wallet subtree
sneurlax Mar 14, 2025
a0324f4
feat: add epic-wallet submodule
sneurlax Mar 14, 2025
f7635f3
feat: remove epicbox subtree
sneurlax Mar 14, 2025
a4c7514
feat: add epic submodule
sneurlax Mar 14, 2025
68ce2b6
fix: epic submodule to use cs_epic_* crates
sneurlax Mar 14, 2025
0ba8503
fix: epic-wallet submodule to use cs_epic_* crates
sneurlax Mar 14, 2025
47ae743
cs_epicbox 0.0.1 (WIP)
sneurlax Mar 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[submodule "rust/epic"]
path = rust/epic
url = https://github.com/cypherstack/epic
[submodule "rust/epic-wallet"]
path = rust/epic-wallet
url = https://github.com/cypherstack/epic-wallet
[submodule "rust/epicbox"]
path = rust/epicbox
url = https://github.com/cypherstack/epicbox
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,11 @@ Libraries will be output to `scripts/windows/build`

## Building on Windows
`build_all.ps1` is not confirmed working and may need work eg. may need some missing dependencies added but has been included as a starting point or example for Windows users

# Notes
## Cargokit
Cargokit may be updated using:
```sh
git subtree pull --prefix cargokit https://github.com/irondash/cargokit.git main --squash
```
in the plugin root.
26 changes: 26 additions & 0 deletions cargokit/.github/workflows/check_and_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
on:
pull_request:
push:
branches:
- main

name: Check and Lint

jobs:
Flutter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # 4.1.0
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # 2.16.0
- name: Pub Get
run: dart pub get --no-precompile
working-directory: build_tool
- name: Dart Format
run: dart format . --output=none --set-exit-if-changed
working-directory: build_tool
- name: Analyze
run: dart analyze
working-directory: build_tool
- name: Test
run: flutter test
working-directory: build_tool
86 changes: 86 additions & 0 deletions cargokit/.github/workflows/test_example_plugin_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
on:
pull_request:
push:
branches:
- main

name: Test Example Plugin

jobs:
Build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macOS-latest
- windows-latest
build_mode:
- debug
- profile
- release
env:
EXAMPLE_DIR: "a b/hello_rust_ffi_plugin/example"
CARGOKIT_VERBOSE: 1
steps:
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Setup Repository
shell: bash
run: |
mkdir "a b" # Space is intentional
cd "a b"
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
# "advanced" branch has extra iOS flavor and uses rust nightly for release builds
git clone -b advanced https://github.com/irondash/hello_rust_ffi_plugin
cd hello_rust_ffi_plugin
git subtree pull --prefix cargokit https://github.com/${{ github.event.pull_request.head.repo.full_name || github.repository }} ${{ steps.extract_branch.outputs.branch }} --squash
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # 2.16.0
with:
channel: "stable"
- name: Install GTK
if: (matrix.os == 'ubuntu-latest')
run: sudo apt-get update && sudo apt-get install libgtk-3-dev
- name: Install ninja-build
if: (matrix.os == 'ubuntu-latest')
run: sudo apt-get update && sudo apt-get install ninja-build
- name: Build Linux (${{ matrix.build_mode }})
if: matrix.os == 'ubuntu-latest'
shell: bash
working-directory: ${{ env.EXAMPLE_DIR }}
run: flutter build linux --${{ matrix.build_mode }} -v
- name: Build macOS (${{ matrix.build_mode }})
if: matrix.os == 'macos-latest'
shell: bash
working-directory: ${{ env.EXAMPLE_DIR }}
run: flutter build macos --${{ matrix.build_mode }} -v
- name: Build iOS (${{ matrix.build_mode }})
if: matrix.os == 'macos-latest'
shell: bash
working-directory: ${{ env.EXAMPLE_DIR }}
run: flutter build ios --${{ matrix.build_mode }} --no-codesign -v
- name: Build iOS (${{ matrix.build_mode }}) - flavor1
if: matrix.os == 'macos-latest'
shell: bash
working-directory: ${{ env.EXAMPLE_DIR }}
run: flutter build ios --flavor flavor1 --${{ matrix.build_mode }} --no-codesign -v
- name: Build Windows (${{ matrix.build_mode }})
if: matrix.os == 'windows-latest'
shell: bash
working-directory: ${{ env.EXAMPLE_DIR }}
run: flutter build windows --${{ matrix.build_mode }} -v
- name: Build Android (${{ matrix.build_mode }})
shell: bash
working-directory: ${{ env.EXAMPLE_DIR }}
run: |
if [[ $(sysctl hw.optional.arm64) == *"hw.optional.arm64: 1"* ]]; then
export JAVA_HOME=$JAVA_HOME_17_arm64
else
export JAVA_HOME=$JAVA_HOME_11_X64
fi
flutter build apk --${{ matrix.build_mode }} -v

4 changes: 4 additions & 0 deletions cargokit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target
.dart_tool
*.iml
!pubspec.lock
39 changes: 39 additions & 0 deletions cargokit/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Copyright 2022 Matej Knopp

================================================================================

MIT LICENSE

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

================================================================================

APACHE LICENSE, VERSION 2.0

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

8 changes: 8 additions & 0 deletions cargokit/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Experimental repository to provide glue for seamlessly integrating cargo build
with flutter plugins and packages.

See https://matejknopp.com/post/flutter_plugin_in_rust_with_no_prebuilt_binaries/
for a tutorial on how to use Cargokit.

Example plugin available at https://github.com/irondash/hello_rust_ffi_plugin.

58 changes: 58 additions & 0 deletions cargokit/build_pod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/sh
set -e

BASEDIR=$(dirname "$0")

# Workaround for https://github.com/dart-lang/pub/issues/4010
BASEDIR=$(cd "$BASEDIR" ; pwd -P)

# Remove XCode SDK from path. Otherwise this breaks tool compilation when building iOS project
NEW_PATH=`echo $PATH | tr ":" "\n" | grep -v "Contents/Developer/" | tr "\n" ":"`

export PATH=${NEW_PATH%?} # remove trailing :

env

# Platform name (macosx, iphoneos, iphonesimulator)
export CARGOKIT_DARWIN_PLATFORM_NAME=$PLATFORM_NAME

# Arctive architectures (arm64, armv7, x86_64), space separated.
export CARGOKIT_DARWIN_ARCHS=$ARCHS

# Current build configuration (Debug, Release)
export CARGOKIT_CONFIGURATION=$CONFIGURATION

# Path to directory containing Cargo.toml.
export CARGOKIT_MANIFEST_DIR=$PODS_TARGET_SRCROOT/$1

# Temporary directory for build artifacts.
export CARGOKIT_TARGET_TEMP_DIR=$TARGET_TEMP_DIR

# Output directory for final artifacts.
export CARGOKIT_OUTPUT_DIR=$PODS_CONFIGURATION_BUILD_DIR/$PRODUCT_NAME

# Directory to store built tool artifacts.
export CARGOKIT_TOOL_TEMP_DIR=$TARGET_TEMP_DIR/build_tool

# Directory inside root project. Not necessarily the top level directory of root project.
export CARGOKIT_ROOT_PROJECT_DIR=$SRCROOT

FLUTTER_EXPORT_BUILD_ENVIRONMENT=(
"$PODS_ROOT/../Flutter/ephemeral/flutter_export_environment.sh" # macOS
"$PODS_ROOT/../Flutter/flutter_export_environment.sh" # iOS
)

for path in "${FLUTTER_EXPORT_BUILD_ENVIRONMENT[@]}"
do
if [[ -f "$path" ]]; then
source "$path"
fi
done

sh "$BASEDIR/run_build_tool.sh" build-pod "$@"

# Make a symlink from built framework to phony file, which will be used as input to
# build script. This should force rebuild (podspec currently doesn't support alwaysOutOfDate
# attribute on custom build phase)
ln -fs "$OBJROOT/XCBuildData/build.db" "${BUILT_PRODUCTS_DIR}/cargokit_phony"
ln -fs "${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" "${BUILT_PRODUCTS_DIR}/cargokit_phony_out"
2 changes: 2 additions & 0 deletions cargokit/build_tool/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
A sample command-line application with an entrypoint in `bin/`, library code
in `lib/`, and example unit test in `test/`.
31 changes: 31 additions & 0 deletions cargokit/build_tool/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.

include: package:lints/recommended.yaml

# Uncomment the following section to specify additional rules.

linter:
rules:
- prefer_relative_imports
- directives_ordering

# analyzer:
# exclude:
# - path/to/excluded/files/**

# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints

# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options
5 changes: 5 additions & 0 deletions cargokit/build_tool/bin/build_tool.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'package:build_tool/build_tool.dart' as build_tool;

void main(List<String> arguments) {
build_tool.runMain(arguments);
}
5 changes: 5 additions & 0 deletions cargokit/build_tool/lib/build_tool.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'src/build_tool.dart' as build_tool;

Future<void> runMain(List<String> args) async {
return build_tool.runMain(args);
}
Loading