From 360a31fabe770f20f0edd96a5c8722c31148fb0e Mon Sep 17 00:00:00 2001 From: Julian Date: Wed, 9 Sep 2026 16:08:30 -0600 Subject: [PATCH 1/6] native assets migration --- .github/workflows/release.yml | 214 ----------- .gitignore | 20 -- .metadata | 42 --- README.md | 88 +---- analysis_options.yaml | 3 + android/.gitignore | 9 - android/build.gradle | 66 ---- android/settings.gradle | 1 - android/src/main/AndroidManifest.xml | 7 - .../flutter_libmwc/FlutterLibmwcPlugin.kt | 35 -- example/analysis_options.yaml | 8 + example/android/app/build.gradle | 2 +- example/android/gradle.properties | 6 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- example/android/settings.gradle.kts | 4 +- example/ios/Flutter/AppFrameworkInfo.plist | 2 - example/ios/Podfile | 41 --- example/ios/Podfile.lock | 35 -- example/ios/Runner.xcodeproj/project.pbxproj | 106 ++---- .../xcshareddata/xcschemes/Runner.xcscheme | 20 ++ example/ios/Runner/AppDelegate.swift | 11 +- example/ios/Runner/Info.plist | 29 +- example/ios/Runner/Runner-Bridging-Header.h | 1 - example/linux/CMakeLists.txt | 12 +- .../flutter/generated_plugin_registrant.cc | 8 - example/linux/flutter/generated_plugins.cmake | 2 - .../Flutter/GeneratedPluginRegistrant.swift | 4 - example/macos/Podfile | 43 --- example/macos/Podfile.lock | 35 -- .../macos/Runner.xcodeproj/project.pbxproj | 117 ++---- .../xcshareddata/xcschemes/Runner.xcscheme | 18 + example/pubspec.lock | 183 ++++++---- example/pubspec.yaml | 6 +- example/test/widget_test.dart | 10 - example/windows/CMakeLists.txt | 7 +- .../flutter/generated_plugin_registrant.cc | 6 - .../windows/flutter/generated_plugins.cmake | 2 - hook/build.dart | 64 ++++ ios/.gitignore | 38 -- ios/Assets/.gitkeep | 0 ios/Classes/FlutterLibmwcPlugin.h | 95 ----- ios/Classes/FlutterLibmwcPlugin.m | 15 - ios/Classes/SwiftFlutterLibmwcPlugin.swift | 61 ---- ios/flutter_libmwc.podspec | 27 -- lib/flutter_libmwc.dart | 8 - lib/flutter_libmwc_method_channel.dart | 17 - lib/flutter_libmwc_platform_interface.dart | 29 -- lib/git_versions_example.dart | 23 -- lib/mwc.dart | 333 ++++++++++-------- linux/CMakeLists.txt | 47 --- linux/flutter_libmwc_plugin.cc | 70 ---- .../flutter_libmwc/flutter_libmwc_plugin.h | 26 -- macos/Classes/FlutterLibmwcPlugin.h | 85 ----- macos/Classes/FlutterLibmwcPlugin.swift | 65 ---- macos/flutter_libmwc.podspec | 28 -- pubspec.yaml | 73 +--- rust/Cargo.toml | 1 + rust/rust-toolchain.toml | 16 + scripts/android/build_all.sh | 28 -- scripts/android/build_openssl.sh | 22 -- scripts/android/config.sh | 12 - scripts/android/download.sh | 38 -- scripts/android/install_ndk.sh | 12 - scripts/android/publish.sh | 40 --- scripts/ios/build_all.sh | 40 --- scripts/ios/download.sh | 32 -- scripts/ios/publish.sh | 44 --- scripts/linux/build_all.sh | 26 -- scripts/linux/download.sh | 34 -- scripts/linux/publish.sh | 40 --- scripts/macos/build_all.sh | 33 -- scripts/macos/download.sh | 31 -- scripts/windows/README.md | 14 - scripts/windows/build_all.ps1 | 42 --- scripts/windows/build_all.sh | 32 -- scripts/windows/deps.sh | 7 - scripts/windows/download.sh | 36 -- test/flutter_libmwc_method_channel_test.dart | 24 -- test/flutter_libmwc_test.dart | 29 -- test/native_assets_test.dart | 8 + windows/.gitignore | 17 - windows/CMakeLists.txt | 69 ---- windows/flutter_libmwc_plugin.cpp | 59 ---- windows/flutter_libmwc_plugin.h | 32 -- windows/flutter_libmwc_plugin_c_api.cpp | 12 - .../flutter_libmwc_plugin_c_api.h | 23 -- 86 files changed, 566 insertions(+), 2596 deletions(-) delete mode 100644 .github/workflows/release.yml delete mode 100644 .metadata delete mode 100644 android/.gitignore delete mode 100644 android/build.gradle delete mode 100644 android/settings.gradle delete mode 100644 android/src/main/AndroidManifest.xml delete mode 100644 android/src/main/kotlin/com/example/flutter_libmwc/FlutterLibmwcPlugin.kt delete mode 100644 example/ios/Podfile delete mode 100644 example/ios/Podfile.lock delete mode 100644 example/macos/Podfile delete mode 100644 example/macos/Podfile.lock create mode 100644 hook/build.dart delete mode 100644 ios/.gitignore delete mode 100644 ios/Assets/.gitkeep delete mode 100644 ios/Classes/FlutterLibmwcPlugin.h delete mode 100644 ios/Classes/FlutterLibmwcPlugin.m delete mode 100644 ios/Classes/SwiftFlutterLibmwcPlugin.swift delete mode 100644 ios/flutter_libmwc.podspec delete mode 100644 lib/flutter_libmwc.dart delete mode 100644 lib/flutter_libmwc_method_channel.dart delete mode 100644 lib/flutter_libmwc_platform_interface.dart delete mode 100644 lib/git_versions_example.dart delete mode 100644 linux/CMakeLists.txt delete mode 100644 linux/flutter_libmwc_plugin.cc delete mode 100644 linux/include/flutter_libmwc/flutter_libmwc_plugin.h delete mode 100644 macos/Classes/FlutterLibmwcPlugin.h delete mode 100644 macos/Classes/FlutterLibmwcPlugin.swift delete mode 100644 macos/flutter_libmwc.podspec create mode 100644 rust/rust-toolchain.toml delete mode 100755 scripts/android/build_all.sh delete mode 100755 scripts/android/build_openssl.sh delete mode 100755 scripts/android/config.sh delete mode 100755 scripts/android/download.sh delete mode 100755 scripts/android/install_ndk.sh delete mode 100755 scripts/android/publish.sh delete mode 100755 scripts/ios/build_all.sh delete mode 100755 scripts/ios/download.sh delete mode 100755 scripts/ios/publish.sh delete mode 100755 scripts/linux/build_all.sh delete mode 100755 scripts/linux/download.sh delete mode 100755 scripts/linux/publish.sh delete mode 100755 scripts/macos/build_all.sh delete mode 100755 scripts/macos/download.sh delete mode 100644 scripts/windows/README.md delete mode 100644 scripts/windows/build_all.ps1 delete mode 100755 scripts/windows/build_all.sh delete mode 100755 scripts/windows/deps.sh delete mode 100755 scripts/windows/download.sh delete mode 100644 test/flutter_libmwc_method_channel_test.dart delete mode 100644 test/flutter_libmwc_test.dart create mode 100644 test/native_assets_test.dart delete mode 100644 windows/.gitignore delete mode 100644 windows/CMakeLists.txt delete mode 100644 windows/flutter_libmwc_plugin.cpp delete mode 100644 windows/flutter_libmwc_plugin.h delete mode 100644 windows/flutter_libmwc_plugin_c_api.cpp delete mode 100644 windows/include/flutter_libmwc/flutter_libmwc_plugin_c_api.h diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 7d9ad274..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,214 +0,0 @@ -name: Build and Release - -on: - push: - tags: - - 'v[0-9]+.[0-9]+.[0-9]+' - workflow_dispatch: - -jobs: - - build-linux: - runs-on: ubuntu-24.04 - container: - image: stackwallet/stackwallet-ci:latest - strategy: - matrix: - include: - - target: x86_64-unknown-linux-gnu - asset: libmwc_wallet-linux-x86_64.so - - target: aarch64-unknown-linux-gnu - asset: libmwc_wallet-linux-aarch64.so - steps: - - uses: actions/checkout@v6 - - - name: Add Rust target - run: rustup target add ${{ matrix.target }} - - - uses: Swatinem/rust-cache@v2 - with: - workspaces: rust - key: linux-${{ matrix.target }} - - - name: Build - env: - CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc - run: | - cd rust - cargo build --target ${{ matrix.target }} --release --lib - cp target/${{ matrix.target }}/release/libmwc_wallet.so ${{ matrix.asset }} - - - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.asset }} - path: rust/${{ matrix.asset }} - - build-android: - runs-on: ubuntu-24.04 - container: - image: stackwallet/stackwallet-ci:latest - strategy: - matrix: - include: - - target: aarch64-linux-android - abi: arm64-v8a - - target: armv7-linux-androideabi - abi: armeabi-v7a - - target: x86_64-linux-android - abi: x86_64 - steps: - - uses: actions/checkout@v6 - - - name: Add Rust target - run: rustup target add ${{ matrix.target }} - - - uses: Swatinem/rust-cache@v2 - with: - workspaces: rust - key: android-${{ matrix.abi }} - - - name: Build - env: - ANDROID_NDK_ROOT: /opt/android-ndk-r28 - run: | - cd rust - cargo ndk --target ${{ matrix.target }} --platform 21 build --release - cp target/${{ matrix.target }}/release/libmwc_wallet.so \ - libmwc_wallet-android-${{ matrix.abi }}.so - - - uses: actions/upload-artifact@v4 - with: - name: libmwc_wallet-android-${{ matrix.abi }}.so - path: rust/libmwc_wallet-android-${{ matrix.abi }}.so - - build-ios: - runs-on: macos-latest - steps: - - uses: actions/checkout@v6 - - - uses: dtolnay/rust-toolchain@master - with: - toolchain: '1.85.1' - targets: aarch64-apple-ios - - - uses: Swatinem/rust-cache@v2 - with: - workspaces: rust - - - name: Install cbindgen - run: cargo install cbindgen --version 0.24.3 - - - name: Build - run: | - cd rust - export IPHONEOS_DEPLOYMENT_TARGET=15.0 - export RUSTFLAGS="-C link-arg=-mios-version-min=15.0" - cargo build --release --target aarch64-apple-ios --lib - cp target/aarch64-apple-ios/release/libmwc_wallet.a libmwc_wallet-ios-aarch64.a - cbindgen src/lib.rs -l c > libmwc_wallet.h - - - uses: actions/upload-artifact@v4 - with: - name: libmwc_wallet-ios-aarch64.a - path: rust/libmwc_wallet-ios-aarch64.a - - - uses: actions/upload-artifact@v4 - with: - name: libmwc_wallet.h - path: rust/libmwc_wallet.h - - build-macos: - runs-on: macos-latest - steps: - - uses: actions/checkout@v6 - - - uses: dtolnay/rust-toolchain@master - with: - toolchain: '1.85.1' - targets: aarch64-apple-darwin - - - uses: Swatinem/rust-cache@v2 - with: - workspaces: rust - - - name: Install cbindgen - run: cargo install cbindgen --version 0.24.3 - - - name: Build - run: | - cd rust - cbindgen src/lib.rs -l c > libmwc_wallet.h - cargo build --target aarch64-apple-darwin --release --lib - - mkdir -p Headers - cp libmwc_wallet.h Headers/ - - xcodebuild -create-xcframework \ - -library target/aarch64-apple-darwin/release/libmwc_wallet.a \ - -headers Headers/libmwc_wallet.h \ - -output MWCWallet.xcframework - zip -r MWCWallet.xcframework.zip MWCWallet.xcframework - - - uses: actions/upload-artifact@v4 - with: - name: MWCWallet.xcframework.zip - path: rust/MWCWallet.xcframework.zip - - build-windows: - runs-on: ubuntu-24.04 - container: - image: stackwallet/stackwallet-ci:latest - steps: - - uses: actions/checkout@v6 - - - name: Add Rust target - run: rustup target add x86_64-pc-windows-gnu - - - uses: Swatinem/rust-cache@v2 - with: - workspaces: rust - - - name: Build - run: | - cd rust - cargo build --target x86_64-pc-windows-gnu --release --lib - cp target/x86_64-pc-windows-gnu/release/mwc_wallet.dll \ - libmwc_wallet-windows-x86_64.dll - cp "$(x86_64-w64-mingw32-gcc -print-file-name=libstdc++-6.dll)" libstdc++-6.dll - cp "$(x86_64-w64-mingw32-gcc -print-file-name=libgcc_s_seh-1.dll)" libgcc_s_seh-1.dll - - - uses: actions/upload-artifact@v4 - with: - name: libmwc_wallet-windows-x86_64.dll - path: rust/libmwc_wallet-windows-x86_64.dll - - - uses: actions/upload-artifact@v4 - with: - name: libstdc++-6.dll - path: rust/libstdc++-6.dll - - - uses: actions/upload-artifact@v4 - with: - name: libgcc_s_seh-1.dll - path: rust/libgcc_s_seh-1.dll - - release: - needs: [build-linux, build-android, build-ios, build-macos, build-windows] - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/download-artifact@v4 - with: - path: artifacts - merge-multiple: true - - - name: Generate checksums - run: | - cd artifacts - sha256sum * > checksums.txt - - - uses: softprops/action-gh-release@v2 - with: - generate_release_notes: true - files: artifacts/* diff --git a/.gitignore b/.gitignore index 8d1914e6..96486fd9 100644 --- a/.gitignore +++ b/.gitignore @@ -28,23 +28,3 @@ migrate_working_dir/ .dart_tool/ .packages build/ -rust/src/bin -android/src/main/jniLibs/ -rust/default/ -ios/include/ -ios/libs/ -macos/framework/ -rust/libepic_cash_wallet.h -lib/git_versions.dart - -scripts/windows/vcpkg/ -scripts/linux/flutter_libmwc_bins/ -scripts/ios/flutter_libmwc_bins/ -scripts/android/flutter_libmwc_bins/ -scripts/windows/flutter_libmwc_bins/ -scripts/macos/flutter_libmwc_bins/ -scripts/android/cache/ -scripts/android/build/openssl/ - -linux/bin/ - diff --git a/.metadata b/.metadata deleted file mode 100644 index 542e116a..00000000 --- a/.metadata +++ /dev/null @@ -1,42 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled. - -version: - revision: bcea432bce54a83306b3c00a7ad0ed98f777348d - channel: beta - -project_type: plugin - -# Tracks metadata for the flutter migrate command -migration: - platforms: - - platform: root - create_revision: bcea432bce54a83306b3c00a7ad0ed98f777348d - base_revision: bcea432bce54a83306b3c00a7ad0ed98f777348d - - platform: android - create_revision: bcea432bce54a83306b3c00a7ad0ed98f777348d - base_revision: bcea432bce54a83306b3c00a7ad0ed98f777348d - - platform: ios - create_revision: bcea432bce54a83306b3c00a7ad0ed98f777348d - base_revision: bcea432bce54a83306b3c00a7ad0ed98f777348d - - platform: linux - create_revision: bcea432bce54a83306b3c00a7ad0ed98f777348d - base_revision: bcea432bce54a83306b3c00a7ad0ed98f777348d - - platform: macos - create_revision: bcea432bce54a83306b3c00a7ad0ed98f777348d - base_revision: bcea432bce54a83306b3c00a7ad0ed98f777348d - - platform: windows - create_revision: bcea432bce54a83306b3c00a7ad0ed98f777348d - base_revision: bcea432bce54a83306b3c00a7ad0ed98f777348d - - # User provided section - - # List of Local paths (relative to this file) that should be - # ignored by the migrate tool. - # - # Files that are not part of the templates will be ignored by default. - unmanaged_files: - - 'lib/main.dart' - - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/README.md b/README.md index 0a9f24be..3de1ad7c 100644 --- a/README.md +++ b/README.md @@ -1,78 +1,28 @@ # `flutter_libmwc` -## Dependencies -### Rust -Install Rust: https://www.rust-lang.org/tools/install -### `cargo-ndk` -```sh -cargo install cargo-ndk -``` - -# Android -## Add targets to rust -```sh -rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android -``` +Requires Dart 3.13+, Flutter 3.47+, and Rust 1.90.0 (pinned in +`rust/rust-toolchain.toml`). Install Rust with [rustup](https://rustup.rs/) +and make sure `rustup`, `cargo`, and `rustc` are on `PATH`. -## Install dependencies -```sh -# https://github.com/mwcproject/mwc-node/blob/master/doc/build.md#requirements -sudo apt install build-essential \ - cmake \ - git \ - libgit2-dev \ - clang \ - debhelper \ - libclang-dev \ - libncurses5-dev \ - libncursesw5-dev \ - zlib1g-dev \ - pkg-config \ - llvm \ - cargo \ - rustc \ - opencl-headers \ - libssl-dev \ - ocl-icd-opencl-dev \ - libc6-dev-i386 -``` +The [build hook](https://dart.dev/tools/hooks) compiles `rust/` with +[native_toolchain_rust](https://pub.dev/packages/native_toolchain_rust). +Flutter bundles the resulting native asset, and `lib/mwc.dart` resolves its +symbols using `@Native`. No manual library copying or build scripts are needed. -## Build -```sh -cd scripts/android -./install_ndk.sh -./build_all.sh -``` +Install the native build tools required by the Rust dependencies: a C/C++ +compiler, CMake, libclang, pkg-config, Perl (for vendored OpenSSL), and `protoc`. +Use Xcode for Apple targets, Android SDK/NDK r27+ for Android, and Visual Studio's +Desktop development with C++ workload and NASM for Windows (MSVC). -# iOS -## Add targets to rust ```sh -rustup target add aarch64-apple-ios x86_64-apple-ios aarch64-apple-ios-sim +flutter pub get +cd example +flutter run ``` -## Install dependencies -```sh -cargo install cargo-lipo -cargo install cbindgen -``` - -## Build -```sh -cd scripts/ios -./build_all -``` - -# Windows -## Dependencies -Run `scripts/windows/deps.sh` (may need to alter permissions like with `chmod +x *.sh`) to install x86_64-w64-mingw32-gcc and clang or run -```sh -sudo apt-get install clang gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 -``` - -## Building for Windows -Run `scripts/windows/build_all.sh` - -Libraries will be output to `scripts/windows/build` +The first build downloads Rust targets and Cargo dependencies. Later builds +reuse the build cache. `flutter test` also runs the hook and needs the native +build tools. -## 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 +Wallet APIs remain in `lib/lib.dart` and `lib/mwc.dart`. The generated +`FlutterLibmwc.getPlatformVersion()` API and platform plugin scaffolding are removed. diff --git a/analysis_options.yaml b/analysis_options.yaml index a5744c1c..e46654b9 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,3 +1,6 @@ +analyzer: + exclude: + - build/** include: package:flutter_lints/flutter.yaml # Additional information about this file can be found at diff --git a/android/.gitignore b/android/.gitignore deleted file mode 100644 index 161bdcda..00000000 --- a/android/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -*.iml -.gradle -/local.properties -/.idea/workspace.xml -/.idea/libraries -.DS_Store -/build -/captures -.cxx diff --git a/android/build.gradle b/android/build.gradle deleted file mode 100644 index d6404015..00000000 --- a/android/build.gradle +++ /dev/null @@ -1,66 +0,0 @@ -group 'com.example.flutter_libmwc' -version = "1.0-SNAPSHOT" - -buildscript { - ext.kotlin_version = "1.8.22" - repositories { - google() - mavenCentral() - } - - dependencies { - classpath("com.android.tools.build:gradle:8.7.0") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version") - } -} - -allprojects { - repositories { - google() - mavenCentral() - } -} - -apply plugin: "com.android.library" -apply plugin: "kotlin-android" - -android { - namespace = "com.example.flutter_libmwc" - - compileSdk = 34 - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } - - kotlinOptions { - jvmTarget = JavaVersion.VERSION_11 - } - - sourceSets { - main.java.srcDirs += "src/main/kotlin" - test.java.srcDirs += "src/test/kotlin" - } - - defaultConfig { - minSdk = 21 - } - - dependencies { - testImplementation("org.jetbrains.kotlin:kotlin-test") - testImplementation("org.mockito:mockito-core:5.0.0") - } - - testOptions { - unitTests.all { - useJUnitPlatform() - - testLogging { - events "passed", "skipped", "failed", "standardOut", "standardError" - outputs.upToDateWhen {false} - showStandardStreams = true - } - } - } -} \ No newline at end of file diff --git a/android/settings.gradle b/android/settings.gradle deleted file mode 100644 index 65e853c7..00000000 --- a/android/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'flutter_libmwc' diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml deleted file mode 100644 index 72973a0f..00000000 --- a/android/src/main/AndroidManifest.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - diff --git a/android/src/main/kotlin/com/example/flutter_libmwc/FlutterLibmwcPlugin.kt b/android/src/main/kotlin/com/example/flutter_libmwc/FlutterLibmwcPlugin.kt deleted file mode 100644 index 3d84eed0..00000000 --- a/android/src/main/kotlin/com/example/flutter_libmwc/FlutterLibmwcPlugin.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.example.flutter_libmwc - -import androidx.annotation.NonNull - -import io.flutter.embedding.engine.plugins.FlutterPlugin -import io.flutter.plugin.common.MethodCall -import io.flutter.plugin.common.MethodChannel -import io.flutter.plugin.common.MethodChannel.MethodCallHandler -import io.flutter.plugin.common.MethodChannel.Result - -/** FlutterLibmwcPlugin */ -class FlutterLibmwcPlugin: FlutterPlugin, MethodCallHandler { - /// The MethodChannel that will the communication between Flutter and native Android - /// - /// This local reference serves to register the plugin with the Flutter Engine and unregister it - /// when the Flutter Engine is detached from the Activity - private lateinit var channel : MethodChannel - - override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { - channel = MethodChannel(flutterPluginBinding.binaryMessenger, "flutter_libmwc") - channel.setMethodCallHandler(this) - } - - override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { - if (call.method == "getPlatformVersion") { - result.success("Android ${android.os.Build.VERSION.RELEASE}") - } else { - result.notImplemented() - } - } - - override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { - channel.setMethodCallHandler(null) - } -} diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml index 61b6c4de..641939dc 100644 --- a/example/analysis_options.yaml +++ b/example/analysis_options.yaml @@ -7,6 +7,14 @@ # The following line activates a set of recommended lints for Flutter apps, # packages, and plugins designed to encourage good coding practices. +analyzer: + exclude: + - build/** + - android/** + - ios/** + - windows/** + - macos/** + - linux/** include: package:flutter_lints/flutter.yaml linter: diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index afb47436..a225b37e 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -7,7 +7,7 @@ plugins { android { namespace = "com.example.flutter_libmwc_example" compileSdkVersion flutter.compileSdkVersion - ndkVersion = "28.0.13004108" + ndkVersion = flutter.ndkVersion compileOptions { sourceCompatibility = JavaVersion.VERSION_11 diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 24863d21..475a6280 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,3 +1,7 @@ org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true -android.enableJetifier=true \ No newline at end of file +android.enableJetifier=true +# This builtInKotlin flag was added automatically by Flutter migrator +android.builtInKotlin=false +# This newDsl flag was added automatically by Flutter migrator +android.newDsl=false diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index afa1e8eb..a20f2c46 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-all.zip diff --git a/example/android/settings.gradle.kts b/example/android/settings.gradle.kts index a439442c..9d5a6fef 100644 --- a/example/android/settings.gradle.kts +++ b/example/android/settings.gradle.kts @@ -18,8 +18,8 @@ pluginManagement { plugins { id("dev.flutter.flutter-plugin-loader") version "1.0.0" - id("com.android.application") version "8.7.0" apply false - id("org.jetbrains.kotlin.android") version "1.8.22" apply false + id("com.android.application") version "9.1.0" apply false + id("org.jetbrains.kotlin.android") version "2.4.0" apply false } include(":app") diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 7c569640..391a902b 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -20,7 +20,5 @@ ???? CFBundleVersion 1.0 - MinimumOSVersion - 12.0 diff --git a/example/ios/Podfile b/example/ios/Podfile deleted file mode 100644 index 279576f3..00000000 --- a/example/ios/Podfile +++ /dev/null @@ -1,41 +0,0 @@ -# Uncomment this line to define a global platform for your project -# platform :ios, '12.0' - -# CocoaPods analytics sends network stats synchronously affecting flutter build latency. -ENV['COCOAPODS_DISABLE_STATS'] = 'true' - -project 'Runner', { - 'Debug' => :debug, - 'Profile' => :release, - 'Release' => :release, -} - -def flutter_root - generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) - unless File.exist?(generated_xcode_build_settings_path) - raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" - end - - File.foreach(generated_xcode_build_settings_path) do |line| - matches = line.match(/FLUTTER_ROOT\=(.*)/) - return matches[1].strip if matches - end - raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" -end - -require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) - -flutter_ios_podfile_setup - -target 'Runner' do - use_frameworks! - use_modular_headers! - - flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) -end - -post_install do |installer| - installer.pods_project.targets.each do |target| - flutter_additional_ios_build_settings(target) - end -end diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock deleted file mode 100644 index 7d59cd16..00000000 --- a/example/ios/Podfile.lock +++ /dev/null @@ -1,35 +0,0 @@ -PODS: - - Flutter (1.0.0) - - flutter_libmwc (0.0.1): - - Flutter - - flutter_secure_storage (6.0.0): - - Flutter - - path_provider_foundation (0.0.1): - - Flutter - - FlutterMacOS - -DEPENDENCIES: - - Flutter (from `Flutter`) - - flutter_libmwc (from `.symlinks/plugins/flutter_libmwc/ios`) - - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) - - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) - -EXTERNAL SOURCES: - Flutter: - :path: Flutter - flutter_libmwc: - :path: ".symlinks/plugins/flutter_libmwc/ios" - flutter_secure_storage: - :path: ".symlinks/plugins/flutter_secure_storage/ios" - path_provider_foundation: - :path: ".symlinks/plugins/path_provider_foundation/darwin" - -SPEC CHECKSUMS: - Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 - flutter_libmwc: f4da999f066aca84a1cf36ee7a07783d6fd60bd0 - flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be - path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 - -PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011 - -COCOAPODS: 1.16.2 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 5984781e..3c022a2a 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,15 +3,15 @@ archiveVersion = 1; classes = { }; - objectVersion = 54; + objectVersion = 60; objects = { /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; - 691380758CC22DC9D3F277D6 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5122E5E8914BCA0A2C2F4799 /* Pods_Runner.framework */; }; + 691380758CC22DC9D3F277D6 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; - 7E21C418286CCA2000AAD51C /* libmwc_wallet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E21C417286CC9D300AAD51C /* libmwc_wallet.a */; }; + 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; @@ -31,16 +31,13 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 00CFD668A28E7015400EB5AB /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 5122E5E8914BCA0A2C2F4799 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 695833138848C959BF0519F2 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; - 7E21C417286CC9D300AAD51C /* libmwc_wallet.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmwc_wallet.a; path = ../../ios/libs/libmwc_wallet.a; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -48,7 +45,6 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - AED36B0C7C730D9CD7248626 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -56,26 +52,18 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 7E21C418286CCA2000AAD51C /* libmwc_wallet.a in Frameworks */, - 691380758CC22DC9D3F277D6 /* Pods_Runner.framework in Frameworks */, + 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */, + 691380758CC22DC9D3F277D6 /* BuildFile in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 7E21C416286CC9D300AAD51C /* Frameworks */ = { - isa = PBXGroup; - children = ( - 7E21C417286CC9D300AAD51C /* libmwc_wallet.a */, - 5122E5E8914BCA0A2C2F4799 /* Pods_Runner.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( + 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */, 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 9740EEB21CF90195004384FC /* Debug.xcconfig */, 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, @@ -90,7 +78,6 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, - 7E21C416286CC9D300AAD51C /* Frameworks */, F34876B28F009223BCE9EE80 /* Pods */, ); sourceTree = ""; @@ -121,9 +108,6 @@ F34876B28F009223BCE9EE80 /* Pods */ = { isa = PBXGroup; children = ( - AED36B0C7C730D9CD7248626 /* Pods-Runner.debug.xcconfig */, - 695833138848C959BF0519F2 /* Pods-Runner.release.xcconfig */, - 00CFD668A28E7015400EB5AB /* Pods-Runner.profile.xcconfig */, ); path = Pods; sourceTree = ""; @@ -135,20 +119,21 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( - 52B17A7EEF2E0D2A36E64159 /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - E41D75C4B591BFB514DD6999 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); dependencies = ( ); name = Runner; + packageProductDependencies = ( + 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */, + ); productName = Runner; productReference = 97C146EE1CF9000F007C117D /* Runner.app */; productType = "com.apple.product-type.application"; @@ -177,6 +162,9 @@ Base, ); mainGroup = 97C146E51CF9000F007C117D; + packageReferences = ( + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */, + ); productRefGroup = 97C146EF1CF9000F007C117D /* Products */; projectDirPath = ""; projectRoot = ""; @@ -217,28 +205,6 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; - 52B17A7EEF2E0D2A36E64159 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; @@ -254,23 +220,6 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; - E41D75C4B591BFB514DD6999 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -346,7 +295,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -364,14 +313,11 @@ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = 4DQKUWSG6C; ENABLE_BITCODE = NO; - HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/../../ios/include/"; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/../../ios/libs/"; - ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterLibmwcExample; PRODUCT_NAME = "$(TARGET_NAME)"; STRIP_INSTALLED_PRODUCT = NO; @@ -429,7 +375,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -478,7 +424,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -498,14 +444,11 @@ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = 4DQKUWSG6C; ENABLE_BITCODE = NO; - HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/../../ios/include/"; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/../../ios/libs/"; - ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterLibmwcExample; PRODUCT_NAME = "$(TARGET_NAME)"; STRIP_INSTALLED_PRODUCT = NO; @@ -526,14 +469,11 @@ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = 4DQKUWSG6C; ENABLE_BITCODE = NO; - HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/../../ios/include/"; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/../../ios/libs/"; - ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterLibmwcExample; PRODUCT_NAME = "$(TARGET_NAME)"; STRIP_INSTALLED_PRODUCT = NO; @@ -568,6 +508,20 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = { + isa = XCSwiftPackageProductDependency; + productName = FlutterGeneratedPluginSwiftPackage; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = 97C146E61CF9000F007C117D /* Project object */; } diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index c53e2b31..5db441f5 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -5,6 +5,24 @@ + + + + + + + + + + Bool { - let dummy = get_mnemonic() - print(dummy) - GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } + + func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) { + GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry) + } } diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index 9f02d664..c1ff03ef 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -4,6 +4,8 @@ + CADisableMinimumFrameDurationOnPhone + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName @@ -26,6 +28,29 @@ $(FLUTTER_BUILD_NUMBER) LSRequiresIPhoneOS + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneClassName + UIWindowScene + UISceneConfigurationName + flutter + UISceneDelegateClassName + FlutterSceneDelegate + UISceneStoryboardFile + Main + + + + + UIApplicationSupportsIndirectInputEvents + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile @@ -45,9 +70,5 @@ UIViewControllerBasedStatusBarAppearance - CADisableMinimumFrameDurationOnPhone - - UIApplicationSupportsIndirectInputEvents - diff --git a/example/ios/Runner/Runner-Bridging-Header.h b/example/ios/Runner/Runner-Bridging-Header.h index f606b6c1..308a2a56 100644 --- a/example/ios/Runner/Runner-Bridging-Header.h +++ b/example/ios/Runner/Runner-Bridging-Header.h @@ -1,2 +1 @@ #import "GeneratedPluginRegistrant.h" -#import "libmwc_wallet.h" \ No newline at end of file diff --git a/example/linux/CMakeLists.txt b/example/linux/CMakeLists.txt index 882b6676..3963d8b9 100644 --- a/example/linux/CMakeLists.txt +++ b/example/linux/CMakeLists.txt @@ -116,13 +116,11 @@ install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR} install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) -if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm") - install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../../linux/bin/aarch64-unknown-linux-gnu/release/libmwc_wallet.so" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) -else() - install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../../linux/bin/x86_64-unknown-linux-gnu/release/libmwc_wallet.so" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) -endif() +# Copy the native assets provided by build hooks. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" diff --git a/example/linux/flutter/generated_plugin_registrant.cc b/example/linux/flutter/generated_plugin_registrant.cc index 7d5778bc..e71a16d2 100644 --- a/example/linux/flutter/generated_plugin_registrant.cc +++ b/example/linux/flutter/generated_plugin_registrant.cc @@ -6,14 +6,6 @@ #include "generated_plugin_registrant.h" -#include -#include void fl_register_plugins(FlPluginRegistry* registry) { - g_autoptr(FlPluginRegistrar) flutter_libmwc_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterLibmwcPlugin"); - flutter_libmwc_plugin_register_with_registrar(flutter_libmwc_registrar); - g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin"); - flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar); } diff --git a/example/linux/flutter/generated_plugins.cmake b/example/linux/flutter/generated_plugins.cmake index d783b01e..2e1de87a 100644 --- a/example/linux/flutter/generated_plugins.cmake +++ b/example/linux/flutter/generated_plugins.cmake @@ -3,8 +3,6 @@ # list(APPEND FLUTTER_PLUGIN_LIST - flutter_libmwc - flutter_secure_storage_linux ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/example/macos/Flutter/GeneratedPluginRegistrant.swift b/example/macos/Flutter/GeneratedPluginRegistrant.swift index a751210f..e777c67d 100644 --- a/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,12 +5,8 @@ import FlutterMacOS import Foundation -import flutter_libmwc -import flutter_secure_storage_macos import path_provider_foundation func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { - FlutterLibmwcPlugin.register(with: registry.registrar(forPlugin: "FlutterLibmwcPlugin")) - FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) } diff --git a/example/macos/Podfile b/example/macos/Podfile deleted file mode 100644 index b52666a1..00000000 --- a/example/macos/Podfile +++ /dev/null @@ -1,43 +0,0 @@ -platform :osx, '10.15' - -# CocoaPods analytics sends network stats synchronously affecting flutter build latency. -ENV['COCOAPODS_DISABLE_STATS'] = 'true' - -project 'Runner', { - 'Debug' => :debug, - 'Profile' => :release, - 'Release' => :release, -} - -def flutter_root - generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) - unless File.exist?(generated_xcode_build_settings_path) - raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" - end - - File.foreach(generated_xcode_build_settings_path) do |line| - matches = line.match(/FLUTTER_ROOT\=(.*)/) - return matches[1].strip if matches - end - raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" -end - -require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) - -flutter_macos_podfile_setup - -target 'Runner' do - use_frameworks! - use_modular_headers! - - flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) - target 'RunnerTests' do - inherit! :search_paths - end -end - -post_install do |installer| - installer.pods_project.targets.each do |target| - flutter_additional_macos_build_settings(target) - end -end diff --git a/example/macos/Podfile.lock b/example/macos/Podfile.lock deleted file mode 100644 index 70e7e365..00000000 --- a/example/macos/Podfile.lock +++ /dev/null @@ -1,35 +0,0 @@ -PODS: - - flutter_libmwc (0.0.1): - - FlutterMacOS - - flutter_secure_storage_macos (6.1.1): - - FlutterMacOS - - FlutterMacOS (1.0.0) - - path_provider_foundation (0.0.1): - - Flutter - - FlutterMacOS - -DEPENDENCIES: - - flutter_libmwc (from `Flutter/ephemeral/.symlinks/plugins/flutter_libmwc/macos`) - - flutter_secure_storage_macos (from `Flutter/ephemeral/.symlinks/plugins/flutter_secure_storage_macos/macos`) - - FlutterMacOS (from `Flutter/ephemeral`) - - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) - -EXTERNAL SOURCES: - flutter_libmwc: - :path: Flutter/ephemeral/.symlinks/plugins/flutter_libmwc/macos - flutter_secure_storage_macos: - :path: Flutter/ephemeral/.symlinks/plugins/flutter_secure_storage_macos/macos - FlutterMacOS: - :path: Flutter/ephemeral - path_provider_foundation: - :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin - -SPEC CHECKSUMS: - flutter_libmwc: 4b7ab10c2a3f56427321c59522f4510077e9ce80 - flutter_secure_storage_macos: 59459653abe1adb92abbc8ea747d79f8d19866c9 - FlutterMacOS: d0db08ddef1a9af05a5ec4b724367152bb0500b1 - path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 - -PODFILE CHECKSUM: 9ebaf0ce3d369aaa26a9ea0e159195ed94724cf3 - -COCOAPODS: 1.16.2 diff --git a/example/macos/Runner.xcodeproj/project.pbxproj b/example/macos/Runner.xcodeproj/project.pbxproj index 1d5ce6ec..2b441c76 100644 --- a/example/macos/Runner.xcodeproj/project.pbxproj +++ b/example/macos/Runner.xcodeproj/project.pbxproj @@ -21,15 +21,14 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ - 15FC616BF051A40AB25C1736 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B90493CF6A8F2641DAD6133 /* Pods_RunnerTests.framework */; }; 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; - 45F7B46D4DA546C53EA3E564 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 68D9B63D1C14310DFEF4C3E8 /* Pods_Runner.framework */; }; 597997492A66C4E9005C8118 /* libsqlite3.0.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 597997482A66C4E9005C8118 /* libsqlite3.0.tbd */; }; + 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -63,9 +62,6 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 0B600740C319EDC7F276DA34 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; - 2E01FB27E01C30C56C0F95FF /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; - 2EC423808221639C81EDCF81 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; @@ -82,14 +78,10 @@ 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; - 3B90493CF6A8F2641DAD6133 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 597997482A66C4E9005C8118 /* libsqlite3.0.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.0.tbd; path = usr/lib/libsqlite3.0.tbd; sourceTree = SDKROOT; }; - 68D9B63D1C14310DFEF4C3E8 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; - 84C178BB559C075464A94ADD /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; - 9A1902DBCC9F3E0F13C4DF3E /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; - A9D4558C220FA10BA9691490 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -97,7 +89,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 15FC616BF051A40AB25C1736 /* Pods_RunnerTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -105,8 +96,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */, 597997492A66C4E9005C8118 /* libsqlite3.0.tbd in Frameworks */, - 45F7B46D4DA546C53EA3E564 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -167,6 +158,7 @@ 33CEB47122A05771004F2AC0 /* Flutter */ = { isa = PBXGroup; children = ( + 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */, 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, @@ -191,12 +183,6 @@ 99B0AC85F8162C4683418BEB /* Pods */ = { isa = PBXGroup; children = ( - 0B600740C319EDC7F276DA34 /* Pods-Runner.debug.xcconfig */, - A9D4558C220FA10BA9691490 /* Pods-Runner.release.xcconfig */, - 9A1902DBCC9F3E0F13C4DF3E /* Pods-Runner.profile.xcconfig */, - 84C178BB559C075464A94ADD /* Pods-RunnerTests.debug.xcconfig */, - 2E01FB27E01C30C56C0F95FF /* Pods-RunnerTests.release.xcconfig */, - 2EC423808221639C81EDCF81 /* Pods-RunnerTests.profile.xcconfig */, ); path = Pods; sourceTree = ""; @@ -205,8 +191,6 @@ isa = PBXGroup; children = ( 597997482A66C4E9005C8118 /* libsqlite3.0.tbd */, - 68D9B63D1C14310DFEF4C3E8 /* Pods_Runner.framework */, - 3B90493CF6A8F2641DAD6133 /* Pods_RunnerTests.framework */, ); name = Frameworks; sourceTree = ""; @@ -218,7 +202,6 @@ isa = PBXNativeTarget; buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; buildPhases = ( - FD91C6B4D07B03B7FF77F8FD /* [CP] Check Pods Manifest.lock */, 331C80D1294CF70F00263BE5 /* Sources */, 331C80D2294CF70F00263BE5 /* Frameworks */, 331C80D3294CF70F00263BE5 /* Resources */, @@ -237,13 +220,11 @@ isa = PBXNativeTarget; buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( - 67A4BDB3DFF1B24C53725CE4 /* [CP] Check Pods Manifest.lock */, 33CC10E92044A3C60003C045 /* Sources */, 33CC10EA2044A3C60003C045 /* Frameworks */, 33CC10EB2044A3C60003C045 /* Resources */, 33CC110E2044A8840003C045 /* Bundle Framework */, 3399D490228B24CF009A79C7 /* ShellScript */, - 823272A914EAD7788A8EB6B2 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -251,6 +232,9 @@ 33CC11202044C79F0003C045 /* PBXTargetDependency */, ); name = Runner; + packageProductDependencies = ( + 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */, + ); productName = Runner; productReference = 33CC10ED2044A3C60003C045 /* example.app */; productType = "com.apple.product-type.application"; @@ -294,6 +278,9 @@ Base, ); mainGroup = 33CC10E42044A3C60003C045; + packageReferences = ( + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */, + ); productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; projectDirPath = ""; projectRoot = ""; @@ -363,67 +350,6 @@ shellPath = /bin/sh; shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; }; - 67A4BDB3DFF1B24C53725CE4 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 823272A914EAD7788A8EB6B2 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - FD91C6B4D07B03B7FF77F8FD /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -475,7 +401,6 @@ /* Begin XCBuildConfiguration section */ 331C80DB294CF71000263BE5 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 84C178BB559C075464A94ADD /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CURRENT_PROJECT_VERSION = 1; @@ -490,7 +415,6 @@ }; 331C80DC294CF71000263BE5 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 2E01FB27E01C30C56C0F95FF /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CURRENT_PROJECT_VERSION = 1; @@ -505,7 +429,6 @@ }; 331C80DD294CF71000263BE5 /* Profile */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 2EC423808221639C81EDCF81 /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CURRENT_PROJECT_VERSION = 1; @@ -556,7 +479,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.15; + MACOSX_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -635,7 +558,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.15; + MACOSX_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -682,7 +605,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.15; + MACOSX_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -789,6 +712,20 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = { + isa = XCSwiftPackageProductDependency; + productName = FlutterGeneratedPluginSwiftPackage; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = 33CC10E52044A3C60003C045 /* Project object */; } diff --git a/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index ac78810c..ee5d00fc 100644 --- a/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -5,6 +5,24 @@ + + + + + + + + + + =3.8.0-0 <4.0.0" - flutter: ">=3.24.0" + dart: ">=3.13.0 <4.0.0" + flutter: ">=3.47.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 495a3a83..5b7ccc2f 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,12 +1,13 @@ name: flutter_libmwc_example description: Demonstrates how to use the flutter_libmwc plugin. +version: 1.0.0 # The following line prevents the package from being accidentally published to # pub.dev using `flutter pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.13.0 <4.0.0" # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions @@ -17,7 +18,7 @@ environment: dependencies: flutter: sdk: flutter - path_provider: ^2.0.15 + path_provider: ^2.1.6 flutter_libmwc: # When depending on this package from a real application you should use: @@ -29,7 +30,6 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - flutter_secure_storage: ^8.0.0 numeric_keyboard: ^1.1.0 dev_dependencies: diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index 89937fe4..02a1f273 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -1,19 +1,9 @@ -import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import '../lib/main.dart'; void main() { testWidgets('FFI Test App starts up', (WidgetTester tester) async { - // Mock the MethodChannel for the test - TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler( - const MethodChannel('flutter_libmwc'), - (MethodCall methodCall) async { - // Return empty string for any method call during testing - return ''; - }, - ); - // Build our app and trigger a frame. await tester.pumpWidget(const FFITestApp()); diff --git a/example/windows/CMakeLists.txt b/example/windows/CMakeLists.txt index 1153d978..4ab092af 100644 --- a/example/windows/CMakeLists.txt +++ b/example/windows/CMakeLists.txt @@ -80,8 +80,11 @@ install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR} install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) -install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/windows/build/libmwc_wallet.dll" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) +# Copy the native assets provided by build hooks. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" diff --git a/example/windows/flutter/generated_plugin_registrant.cc b/example/windows/flutter/generated_plugin_registrant.cc index 76ddde48..8b6d4680 100644 --- a/example/windows/flutter/generated_plugin_registrant.cc +++ b/example/windows/flutter/generated_plugin_registrant.cc @@ -6,12 +6,6 @@ #include "generated_plugin_registrant.h" -#include -#include void RegisterPlugins(flutter::PluginRegistry* registry) { - FlutterLibmwcPluginCApiRegisterWithRegistrar( - registry->GetRegistrarForPlugin("FlutterLibmwcPluginCApi")); - FlutterSecureStorageWindowsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin")); } diff --git a/example/windows/flutter/generated_plugins.cmake b/example/windows/flutter/generated_plugins.cmake index 37d3f3f8..b93c4c30 100644 --- a/example/windows/flutter/generated_plugins.cmake +++ b/example/windows/flutter/generated_plugins.cmake @@ -3,8 +3,6 @@ # list(APPEND FLUTTER_PLUGIN_LIST - flutter_libmwc - flutter_secure_storage_windows ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/hook/build.dart b/hook/build.dart new file mode 100644 index 00000000..da29be2b --- /dev/null +++ b/hook/build.dart @@ -0,0 +1,64 @@ +import 'dart:io'; + +import 'package:code_assets/code_assets.dart'; +import 'package:hooks/hooks.dart'; +import 'package:native_toolchain_rust/native_toolchain_rust.dart'; + +void main(List args) async { + await build(args, (input, output) async { + if (!input.config.buildCodeAssets) return; + + final code = input.config.code; + final environment = { + if (code.targetOS == OS.iOS) + 'IPHONEOS_DEPLOYMENT_TARGET': '${code.iOS.targetVersion}.0', + if (code.targetOS == OS.macOS) + 'MACOSX_DEPLOYMENT_TARGET': '${code.macOS.targetVersion}.0', + }; + if (code.targetOS == OS.android) { + // native_toolchain_rust 1.0.6 defaults to API 35. Honor Flutter's minimum. + final (rustTarget, clangTarget) = switch (code.targetArchitecture) { + Architecture.arm => ( + 'armv7-linux-androideabi', + 'armv7a-linux-androideabi', + ), + Architecture.arm64 => ( + 'aarch64-linux-android', + 'aarch64-linux-android', + ), + Architecture.x64 => ('x86_64-linux-android', 'x86_64-linux-android'), + _ => throw UnsupportedError('Unsupported Android architecture'), + }; + final bin = code.cCompiler!.compiler.resolve('.'); + final suffix = Platform.isWindows ? '.cmd' : ''; + final ndkTarget = '$clangTarget${code.android.targetNdkApi}'; + final compiler = '$ndkTarget-clang'; + final cc = bin.resolve('$compiler$suffix').toFilePath(); + final target = rustTarget.replaceAll('-', '_'); + environment.addAll({ + 'CC_$target': cc, + 'CXX_$target': bin.resolve('$compiler++$suffix').toFilePath(), + // cc also supplies --target; keep the API level on the final argument. + 'CFLAGS_$target': '--target=$ndkTarget', + 'CXXFLAGS_$target': '--target=$ndkTarget', + // The NDK's libc++.a linker script includes libc++abi as well. + // Defer it to the final link instead of bundling the script in an rlib. + 'CXXSTDLIB_$target': 'static:-bundle=c++', + 'CARGO_TARGET_${target.toUpperCase()}_LINKER': cc, + }); + } + + await RustBuilder( + assetName: 'mwc.dart', + extraCargoBuildArgs: ['--lib'], + extraCargoEnvironmentVariables: environment, + ).run(input: input, output: output); + output.dependencies.addAll( + [ + 'rust/Cargo.toml', + 'rust/Cargo.lock', + 'rust/rust-toolchain.toml', + ].map(input.packageRoot.resolve), + ); + }); +} diff --git a/ios/.gitignore b/ios/.gitignore deleted file mode 100644 index 0c885071..00000000 --- a/ios/.gitignore +++ /dev/null @@ -1,38 +0,0 @@ -.idea/ -.vagrant/ -.sconsign.dblite -.svn/ - -.DS_Store -*.swp -profile - -DerivedData/ -build/ -GeneratedPluginRegistrant.h -GeneratedPluginRegistrant.m - -.generated/ - -*.pbxuser -*.mode1v3 -*.mode2v3 -*.perspectivev3 - -!default.pbxuser -!default.mode1v3 -!default.mode2v3 -!default.perspectivev3 - -xcuserdata - -*.moved-aside - -*.pyc -*sync/ -Icon? -.tags* - -/Flutter/Generated.xcconfig -/Flutter/ephemeral/ -/Flutter/flutter_export_environment.sh \ No newline at end of file diff --git a/ios/Assets/.gitkeep b/ios/Assets/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/ios/Classes/FlutterLibmwcPlugin.h b/ios/Classes/FlutterLibmwcPlugin.h deleted file mode 100644 index d65124b2..00000000 --- a/ios/Classes/FlutterLibmwcPlugin.h +++ /dev/null @@ -1,95 +0,0 @@ -#import -#include -#include -#include -#include - - -@interface FlutterLibmwcPlugin : NSObject -@end - -// NOTE: put the lines from the include here whenever new api functions are added. - -const char *mwc_wallet_init(const char *config, - const char *mnemonic, - const char *password, - const char *name); - -const char *mwc_get_mnemonic(void); - -const char *mwc_rust_open_wallet(const char *config, - const char *password); - -const char *mwc_rust_wallet_balances(const char *wallet, - const char *refresh, - const char *min_confirmations); - -const char *mwc_rust_recover_from_mnemonic(const char *config, - const char *password, - const char *mnemonic, - const char *name); - -const char *mwc_rust_wallet_scan_outputs(const char *wallet, - const char *start_height, - const char *number_of_blocks); - -const char *mwc_rust_create_tx(const char *wallet, - const char *amount, - const char *to_address, - const char *secret_key_index, - const char *mwcmqs_config, - const char *minimum_confirmations, - const char *note); - -const char *mwc_rust_txs_get(const char *wallet, const char *refresh_from_node); - -const char *mwc_rust_tx_cancel(const char *wallet, const char *tx_id); - -const char *mwc_rust_get_chain_height(const char *config); - -const char *mwc_rust_delete_wallet(const char *wallet, - const char *mwcmqs_config); - -const char *mwc_rust_get_wallet_address(const char *wallet, - const char *index, - const char *mwcmqs_config); - -const char *mwc_rust_validate_address(const char *address); - -const char *mwc_rust_get_tx_fees(const char *wallet, - const char *c_amount, - const char *min_confirmations); - -const char *mwc_rust_tx_send_http(const char *wallet, - const char *selection_strategy_is_use_all, - const char *minimum_confirmations, - const char *message, - const char *amount, - const char *address); - -const char *mwc_rust_init_logs(const char *config); - -const char *mwc_rust_encode_slatepack(const char *slate_json, const char *recipient_address); - -const char *mwc_rust_encode_slatepack_enhanced(const char *wallet, - const char *slate_json, - const char *recipient_address); - -const char *mwc_rust_decode_slatepack(const char *slatepack_str); - -const char *mwc_rust_decode_slatepack_enhanced(const char *wallet, const char *slatepack_str); - -const char *mwc_rust_tx_receive(const char *wallet, const char *slate_json); - -const char *mwc_rust_tx_finalize(const char *wallet, const char *slate_json); - -const char *mwc_rust_tx_init(const char *wallet, - const char *selection_strategy_is_use_all, - const char *minimum_confirmations, - const char *message, - const char *amount); - -void *mwc_rust_mwcmqs_listener_start(const char *wallet, - const char *mwcmqs_config); - -const char *mwc_listener_cancel(const char *handler); diff --git a/ios/Classes/FlutterLibmwcPlugin.m b/ios/Classes/FlutterLibmwcPlugin.m deleted file mode 100644 index 2e7f1c5a..00000000 --- a/ios/Classes/FlutterLibmwcPlugin.m +++ /dev/null @@ -1,15 +0,0 @@ -#import "FlutterLibmwcPlugin.h" -#if __has_include() -#import -#else -// Support project import fallback if the generated compatibility header -// is not copied when this plugin is created as a library. -// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 -#import "flutter_libmwc-Swift.h" -#endif - -@implementation FlutterLibmwcPlugin -+ (void)registerWithRegistrar:(NSObject*)registrar { - [SwiftFlutterLibmwcPlugin registerWithRegistrar:registrar]; -} -@end diff --git a/ios/Classes/SwiftFlutterLibmwcPlugin.swift b/ios/Classes/SwiftFlutterLibmwcPlugin.swift deleted file mode 100644 index a6a22080..00000000 --- a/ios/Classes/SwiftFlutterLibmwcPlugin.swift +++ /dev/null @@ -1,61 +0,0 @@ -import Flutter -import UIKit - -public class SwiftFlutterLibmwcPlugin: NSObject, FlutterPlugin { - public static func register(with registrar: FlutterPluginRegistrar) { - let channel = FlutterMethodChannel(name: "flutter_libmwc", binaryMessenger: registrar.messenger()) - let instance = SwiftFlutterLibmwcPlugin() - registrar.addMethodCallDelegate(instance, channel: channel) - } - - public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { - result("iOS " + UIDevice.current.systemVersion) - } - -// TODO whenever mwc is updated with new functions, they need to be dummy called here. - public func dummyMethodToEnforceBundling() { - mwc_wallet_init("const char *config", - "const char *mnemonic", - "const char *password", - "const char *name"); - mwc_get_mnemonic(); - mwc_rust_open_wallet("const char *config", - "const char *password"); - mwc_rust_wallet_balances("const char *wallet", "const char *refresh", "const char *min_confirmations"); - mwc_rust_recover_from_mnemonic("const char *config", - "const char *password", - "const char *mnemonic", - "const char *name"); - - mwc_rust_wallet_scan_outputs("const char *wallet", - "const char *start_height", "onst char *number_of_blocks"); - - mwc_rust_create_tx("const char *wallet", - "const char *amount", - "const char *to_address", - "const char *secret_key_index", "const char *mwcmqs_config", - "const char *minimum_confirmations", "const char *note"); - mwc_rust_txs_get("const char *wallet", - "const char *refresh_from_node"); - mwc_rust_tx_cancel("const char *wallet", "const char *tx_id"); - - mwc_rust_get_chain_height("const char *config"); - mwc_rust_delete_wallet("const char *wallet", - "const char *mwcmqs_config"); - mwc_rust_get_wallet_address("const char *wallet", "const char *index", "const char *mwcmqs_config"); - mwc_rust_validate_address("const char *address"); - mwc_rust_get_tx_fees("const char *wallet", "const char *c_amount", "const char *min_confirmations"); - - mwc_rust_tx_send_http("const char *wallet", "const char *selection_strategy_is_use_all","const char *minimum_confirmations", - "const char *message", - "const char *amount", - "const char *address"); - - mwc_rust_mwcmqs_listener_start("const char *wallet", - "const char *mwcmqs_config"); - - mwc_listener_cancel("const char *handler"); - // ... - // This code will force the bundler to use these functions, but will never be called - } -} diff --git a/ios/flutter_libmwc.podspec b/ios/flutter_libmwc.podspec deleted file mode 100644 index 383294b6..00000000 --- a/ios/flutter_libmwc.podspec +++ /dev/null @@ -1,27 +0,0 @@ -# -# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. -# Run `pod lib lint flutter_libmwc.podspec` to validate before publishing. -# -Pod::Spec.new do |s| - s.name = 'flutter_libmwc' - s.version = '0.0.1' - s.summary = 'A new Flutter plugin project.' - s.description = <<-DESC -A new Flutter plugin project. - DESC - s.homepage = 'http://example.com' - s.license = { :file => '../LICENSE' } - s.author = { 'Your Company' => 'email@example.com' } - s.source = { :path => '.' } - s.public_header_files = 'Classes**/*.h' - s.source_files = 'Classes/**/*' - s.static_framework = true - s.vendored_libraries = "**/*.a" - s.dependency 'Flutter' - s.platform = :ios, '9.0' - - # Flutter.framework does not contain a i386 slice. - s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } - s.swift_version = '5.0' - s.libraries = 'resolv' -end diff --git a/lib/flutter_libmwc.dart b/lib/flutter_libmwc.dart deleted file mode 100644 index 8847b132..00000000 --- a/lib/flutter_libmwc.dart +++ /dev/null @@ -1,8 +0,0 @@ - -import 'flutter_libmwc_platform_interface.dart'; - -class FlutterLibmwc { - Future getPlatformVersion() { - return FlutterLibmwcPlatform.instance.getPlatformVersion(); - } -} diff --git a/lib/flutter_libmwc_method_channel.dart b/lib/flutter_libmwc_method_channel.dart deleted file mode 100644 index 0508660c..00000000 --- a/lib/flutter_libmwc_method_channel.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter/services.dart'; - -import 'flutter_libmwc_platform_interface.dart'; - -/// An implementation of [FlutterLibmwcPlatform] that uses method channels. -class MethodChannelFlutterLibmwc extends FlutterLibmwcPlatform { - /// The method channel used to interact with the native platform. - @visibleForTesting - final methodChannel = const MethodChannel('flutter_libmwc'); - - @override - Future getPlatformVersion() async { - final version = await methodChannel.invokeMethod('getPlatformVersion'); - return version; - } -} diff --git a/lib/flutter_libmwc_platform_interface.dart b/lib/flutter_libmwc_platform_interface.dart deleted file mode 100644 index f1d072af..00000000 --- a/lib/flutter_libmwc_platform_interface.dart +++ /dev/null @@ -1,29 +0,0 @@ -import 'package:plugin_platform_interface/plugin_platform_interface.dart'; - -import 'flutter_libmwc_method_channel.dart'; - -abstract class FlutterLibmwcPlatform extends PlatformInterface { - /// Constructs a FlutterLibmwcPlatform. - FlutterLibmwcPlatform() : super(token: _token); - - static final Object _token = Object(); - - static FlutterLibmwcPlatform _instance = MethodChannelFlutterLibmwc(); - - /// The default instance of [FlutterLibmwcPlatform] to use. - /// - /// Defaults to [MethodChannelFlutterLibmwc]. - static FlutterLibmwcPlatform get instance => _instance; - - /// Platform-specific implementations should set this with their own - /// platform-specific class that extends [FlutterLibmwcPlatform] when - /// they register themselves. - static set instance(FlutterLibmwcPlatform instance) { - PlatformInterface.verifyToken(instance, _token); - _instance = instance; - } - - Future getPlatformVersion() { - throw UnimplementedError('platformVersion() has not been implemented.'); - } -} diff --git a/lib/git_versions_example.dart b/lib/git_versions_example.dart deleted file mode 100644 index f94e3773..00000000 --- a/lib/git_versions_example.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'dart:io'; - -/*ANDROID_VERSION*/ const ANDROID_VERSION = ""; -/*IOS_VERSION*/ const IOS_VERSION = ""; -/*MACOS_VERSION*/ const MACOS_VERSION = ""; -/*LINUX_VERSION*/ const LINUX_VERSION = ""; -/*WINDOWS_VERSION*/ const WINDOWS_VERSION = ""; - -String getPluginVersion() { - if (Platform.isAndroid) { - return ANDROID_VERSION; - } else if (Platform.isIOS) { - return IOS_VERSION; - } else if (Platform.isMacOS) { - return MACOS_VERSION; - } else if (Platform.isLinux) { - return LINUX_VERSION; - } else if (Platform.isWindows) { - return WINDOWS_VERSION; - } else { - return "Unknown version"; - } -} diff --git a/lib/mwc.dart b/lib/mwc.dart index 70324e49..0a3a33fd 100644 --- a/lib/mwc.dart +++ b/lib/mwc.dart @@ -1,21 +1,10 @@ import 'dart:ffi'; -import 'dart:io' as io; import 'package:ffi/ffi.dart'; -final DynamicLibrary mwcNative = io.Platform.isWindows - ? DynamicLibrary.open("libmwc_wallet.dll") - : io.Platform.environment.containsKey('FLUTTER_TEST') - ? DynamicLibrary.open( - 'crypto_plugins/flutter_libmwc/scripts/linux/build/libmwc_wallet.so') - : io.Platform.isAndroid || io.Platform.isLinux - ? DynamicLibrary.open('libmwc_wallet.so') - : DynamicLibrary.process(); - typedef WalletMnemonic = Pointer Function(); typedef WalletMnemonicFFI = Pointer Function(); - typedef InitLogs = Pointer Function(Pointer); typedef InitLogsFFI = Pointer Function(Pointer); @@ -44,8 +33,13 @@ typedef ScanOutPutsFFI = Pointer Function( typedef CreateTransaction = Pointer Function(Pointer, Pointer, Pointer, Pointer, Pointer, Pointer, Pointer); -typedef CreateTransactionFFI = Pointer Function(Pointer, - Pointer, Pointer, Pointer, Pointer, Pointer, +typedef CreateTransactionFFI = Pointer Function( + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, Pointer); typedef MwcMqsListenerStart = Pointer Function( @@ -68,10 +62,8 @@ typedef CancelTransactionFFI = Pointer Function( typedef GetChainHeight = Pointer Function(Pointer); typedef GetChainHeightFFI = Pointer Function(Pointer); -typedef AddressInfo = Pointer Function( - Pointer, Pointer); -typedef AddressInfoFFI = Pointer Function( - Pointer, Pointer); +typedef AddressInfo = Pointer Function(Pointer, Pointer); +typedef AddressInfoFFI = Pointer Function(Pointer, Pointer); typedef ValidateAddress = Pointer Function(Pointer); typedef ValidateAddressFFI = Pointer Function(Pointer); @@ -93,7 +85,8 @@ typedef TxHttpSendFFI = Pointer Function(Pointer, Pointer, Pointer, Pointer, Pointer, Pointer); typedef EncodeSlatepack = Pointer Function(Pointer, Pointer); -typedef EncodeSlatepackFFI = Pointer Function(Pointer, Pointer); +typedef EncodeSlatepackFFI = Pointer Function( + Pointer, Pointer); typedef EncodeSlatepackEnhanced = Pointer Function( Pointer, Pointer, Pointer); @@ -103,8 +96,10 @@ typedef EncodeSlatepackEnhancedFFI = Pointer Function( typedef DecodeSlatepack = Pointer Function(Pointer); typedef DecodeSlatepackFFI = Pointer Function(Pointer); -typedef DecodeSlatepackEnhanced = Pointer Function(Pointer, Pointer); -typedef DecodeSlatepackEnhancedFFI = Pointer Function(Pointer, Pointer); +typedef DecodeSlatepackEnhanced = Pointer Function( + Pointer, Pointer); +typedef DecodeSlatepackEnhancedFFI = Pointer Function( + Pointer, Pointer); typedef TxReceive = Pointer Function(Pointer, Pointer); typedef TxReceiveFFI = Pointer Function(Pointer, Pointer); @@ -117,62 +112,72 @@ typedef TxInit = Pointer Function( typedef TxInitFFI = Pointer Function( Pointer, Pointer, Pointer, Pointer, Pointer); -final WalletMnemonic _walletMnemonic = mwcNative - .lookup>("mwc_get_mnemonic") - .asFunction(); +@Native(symbol: 'mwc_get_mnemonic') +external Pointer _walletMnemonic(); String walletMnemonic() { return _walletMnemonic().toDartString(); } +@Native(symbol: 'mwc_rust_init_logs') +external Pointer _initLogs(Pointer config); -final InitLogs _initLogs = mwcNative - .lookup>("mwc_rust_init_logs") - .asFunction(); - -String initLogs( String config) { - return _initLogs(config.toNativeUtf8()) - .toDartString(); +String initLogs(String config) { + return _initLogs(config.toNativeUtf8()).toDartString(); } -final WalletInit _initWallet = mwcNative - .lookup>("mwc_wallet_init") - .asFunction(); +@Native(symbol: 'mwc_wallet_init') +external Pointer _initWallet( + Pointer config, + Pointer mnemonic, + Pointer password, + Pointer name, +); String initWallet( String config, String mnemonic, String password, String name) { return _initWallet(config.toNativeUtf8(), mnemonic.toNativeUtf8(), - password.toNativeUtf8(), name.toNativeUtf8()) + password.toNativeUtf8(), name.toNativeUtf8()) .toDartString(); } -final WalletInfo _walletInfo = mwcNative - .lookup>("mwc_rust_wallet_balances") - .asFunction(); +@Native(symbol: 'mwc_rust_wallet_balances') +external Pointer _walletInfo( + Pointer wallet, + Pointer refresh, + Pointer min_confirmations, +); Future getWalletInfo( String wallet, int refreshFromNode, int min_confirmations) async { return _walletInfo( - wallet.toNativeUtf8(), - refreshFromNode.toString().toNativeUtf8().cast(), - min_confirmations.toString().toNativeUtf8().cast()) + wallet.toNativeUtf8(), + refreshFromNode.toString().toNativeUtf8().cast(), + min_confirmations.toString().toNativeUtf8().cast()) .toDartString(); } -final RecoverWallet _recoverWallet = mwcNative - .lookup>("mwc_rust_recover_from_mnemonic") - .asFunction(); +@Native(symbol: 'mwc_rust_recover_from_mnemonic') +external Pointer _recoverWallet( + Pointer config, + Pointer password, + Pointer mnemonic, + Pointer name, +); String recoverWallet( String config, String password, String mnemonic, String name) { return _recoverWallet(config.toNativeUtf8(), password.toNativeUtf8(), - mnemonic.toNativeUtf8(), name.toNativeUtf8()) + mnemonic.toNativeUtf8(), name.toNativeUtf8()) .toDartString(); } -final ScanOutPuts _scanOutPuts = mwcNative - .lookup>("mwc_rust_wallet_scan_outputs") - .asFunction(); +@Native(symbol: 'mwc_rust_wallet_scan_outputs') +external Pointer _scanOutPuts( + Pointer wallet, + Pointer start_height, + Pointer number_of_blocks, +); Future scanOutPuts( String wallet, int startHeight, int numberOfBlocks) async { @@ -183,10 +188,11 @@ Future scanOutPuts( ).toDartString(); } -final MwcMqsListenerStart _MwcMqsListenerStart = mwcNative - .lookup>( - "mwc_rust_mwcmqs_listener_start") - .asFunction(); +@Native(symbol: 'mwc_rust_mwcmqs_listener_start') +external Pointer _MwcMqsListenerStart( + Pointer wallet, + Pointer mwcmqs_config, +); Pointer mwcMqsListenerStart(String wallet, String MWCMQSConfig) { return _MwcMqsListenerStart( @@ -195,9 +201,8 @@ Pointer mwcMqsListenerStart(String wallet, String MWCMQSConfig) { ); } -final MwcMqsListenerStop _MwcMqsListenerStop = mwcNative - .lookup>("mwc_listener_cancel") - .asFunction(); +@Native(symbol: 'mwc_listener_cancel') +external Pointer _MwcMqsListenerStop(Pointer handler); String mwcMqsListenerStop(Pointer handler) { return _MwcMqsListenerStop( @@ -205,12 +210,25 @@ String mwcMqsListenerStop(Pointer handler) { ).toDartString(); } -final CreateTransaction _createTransaction = mwcNative - .lookup>("mwc_rust_create_tx") - .asFunction(); - -Future createTransaction(String wallet, int amount, String address, - int secretKey, String MWCMQSConfig, int minimumConfirmations, String note) async { +@Native(symbol: 'mwc_rust_create_tx') +external Pointer _createTransaction( + Pointer wallet, + Pointer amount, + Pointer to_address, + Pointer secret_key_index, + Pointer mwcmqs_config, + Pointer confirmations, + Pointer note, +); + +Future createTransaction( + String wallet, + int amount, + String address, + int secretKey, + String MWCMQSConfig, + int minimumConfirmations, + String note) async { return _createTransaction( wallet.toNativeUtf8(), amount.toString().toNativeUtf8().cast(), @@ -222,78 +240,85 @@ Future createTransaction(String wallet, int amount, String address, ).toDartString(); } -final GetTransactions _getTransactions = mwcNative - .lookup>("mwc_rust_txs_get") - .asFunction(); +@Native(symbol: 'mwc_rust_txs_get') +external Pointer _getTransactions( + Pointer wallet, + Pointer refresh_from_node, +); Future getTransactions(String wallet, int refreshFromNode) async { return _getTransactions(wallet.toNativeUtf8(), - refreshFromNode.toString().toNativeUtf8().cast()) + refreshFromNode.toString().toNativeUtf8().cast()) .toDartString(); } -final CancelTransaction _cancelTransaction = mwcNative - .lookup>("mwc_rust_tx_cancel") - .asFunction(); +@Native(symbol: 'mwc_rust_tx_cancel') +external Pointer _cancelTransaction( + Pointer wallet, + Pointer tx_id, +); String cancelTransaction(String wallet, String transactionId) { return _cancelTransaction(wallet.toNativeUtf8(), transactionId.toNativeUtf8()) .toDartString(); } -final GetChainHeight _getChainHeight = mwcNative - .lookup>("mwc_rust_get_chain_height") - .asFunction(); +@Native(symbol: 'mwc_rust_get_chain_height') +external Pointer _getChainHeight(Pointer config); int getChainHeight(String config) { String latestHeight = _getChainHeight(config.toNativeUtf8()).toDartString(); return int.parse(latestHeight); } -final AddressInfo _addressInfo = mwcNative - .lookup>("mwc_rust_get_wallet_address") - .asFunction(); +@Native(symbol: 'mwc_rust_get_wallet_address') +external Pointer _addressInfo(Pointer wallet, Pointer index); String getAddressInfo(String wallet, int index) { return _addressInfo( - wallet.toNativeUtf8(), - index.toString().toNativeUtf8().cast()) + wallet.toNativeUtf8(), index.toString().toNativeUtf8().cast()) .toDartString(); } -final ValidateAddress _validateSendAddress = mwcNative - .lookup>("mwc_rust_validate_address") - .asFunction(); +@Native(symbol: 'mwc_rust_validate_address') +external Pointer _validateSendAddress(Pointer address); String validateSendAddress(String address) { return _validateSendAddress(address.toNativeUtf8()).toDartString(); } -final TransactionFees _transactionFees = mwcNative - .lookup>("mwc_rust_get_tx_fees") - .asFunction(); +@Native(symbol: 'mwc_rust_get_tx_fees') +external Pointer _transactionFees( + Pointer wallet, + Pointer c_amount, + Pointer min_confirmations, +); Future getTransactionFees( String wallet, int amount, int minimumConfirmations) async { return _transactionFees( - wallet.toNativeUtf8(), - amount.toString().toNativeUtf8().cast(), - minimumConfirmations.toString().toNativeUtf8().cast()) + wallet.toNativeUtf8(), + amount.toString().toNativeUtf8().cast(), + minimumConfirmations.toString().toNativeUtf8().cast()) .toDartString(); } -final DeleteWallet _deleteWallet = mwcNative - .lookup>("mwc_rust_delete_wallet") - .asFunction(); +@Native(symbol: 'mwc_rust_delete_wallet') +external Pointer _deleteWallet( + Pointer _wallet, + Pointer config, +); Future deleteWallet(String wallet, String config) async { return _deleteWallet(wallet.toNativeUtf8(), config.toNativeUtf8()) .toDartString(); } -final OpenWallet _openWallet = mwcNative - .lookup>("mwc_rust_open_wallet") - .asFunction(); +@Native(symbol: 'mwc_rust_open_wallet') +external Pointer _openWallet( + Pointer config, + Pointer password, +); String openWallet(String config, String password) { final configPointer = config.toNativeUtf8(); @@ -324,9 +349,15 @@ String openWallet(String config, String password) { } } -final TxHttpSend _txHttpSend = mwcNative - .lookup>("mwc_rust_tx_send_http") - .asFunction(); +@Native(symbol: 'mwc_rust_tx_send_http') +external Pointer _txHttpSend( + Pointer wallet, + Pointer selection_strategy_is_use_all, + Pointer minimum_confirmations, + Pointer message, + Pointer amount, + Pointer address, +); Future txHttpSend( String wallet, @@ -336,99 +367,101 @@ Future txHttpSend( int amount, String address) async { return _txHttpSend( - wallet.toNativeUtf8(), - selectionStrategyIsAll.toString().toNativeUtf8().cast(), - minimumConfirmations.toString().toNativeUtf8().cast(), - message.toNativeUtf8(), - amount.toString().toNativeUtf8().cast(), - address.toNativeUtf8()) + wallet.toNativeUtf8(), + selectionStrategyIsAll.toString().toNativeUtf8().cast(), + minimumConfirmations.toString().toNativeUtf8().cast(), + message.toNativeUtf8(), + amount.toString().toNativeUtf8().cast(), + address.toNativeUtf8()) .toDartString(); } -final EncodeSlatepack _encodeSlatepack = mwcNative - .lookup>("mwc_rust_encode_slatepack") - .asFunction(); +@Native(symbol: 'mwc_rust_encode_slatepack') +external Pointer _encodeSlatepack( + Pointer slate_json, + Pointer recipient_address, +); Future encodeSlatepack( - String slateJson, - String? recipientAddress) async { + String slateJson, String? recipientAddress) async { return _encodeSlatepack( - slateJson.toNativeUtf8(), - (recipientAddress ?? "").toNativeUtf8()) + slateJson.toNativeUtf8(), (recipientAddress ?? "").toNativeUtf8()) .toDartString(); } -final EncodeSlatepackEnhanced _encodeSlatepackEnhanced = mwcNative - .lookup>("mwc_rust_encode_slatepack_enhanced") - .asFunction(); +@Native( + symbol: 'mwc_rust_encode_slatepack_enhanced') +external Pointer _encodeSlatepackEnhanced( + Pointer wallet, + Pointer slate_json, + Pointer recipient_address, +); Future encodeSlatepackEnhanced( - String wallet, - String slateJson, - String recipientAddress) async { - return _encodeSlatepackEnhanced( - wallet.toNativeUtf8(), - slateJson.toNativeUtf8(), - recipientAddress.toNativeUtf8()) + String wallet, String slateJson, String recipientAddress) async { + return _encodeSlatepackEnhanced(wallet.toNativeUtf8(), + slateJson.toNativeUtf8(), recipientAddress.toNativeUtf8()) .toDartString(); } -final DecodeSlatepack _decodeSlatepack = mwcNative - .lookup>("mwc_rust_decode_slatepack") - .asFunction(); +@Native(symbol: 'mwc_rust_decode_slatepack') +external Pointer _decodeSlatepack(Pointer slatepack_str); Future decodeSlatepack(String slatepack) async { - return _decodeSlatepack(slatepack.toNativeUtf8()) - .toDartString(); + return _decodeSlatepack(slatepack.toNativeUtf8()).toDartString(); } -final DecodeSlatepackEnhanced _decodeSlatepackEnhanced = mwcNative - .lookup>("mwc_rust_decode_slatepack_enhanced") - .asFunction(); +@Native( + symbol: 'mwc_rust_decode_slatepack_enhanced') +external Pointer _decodeSlatepackEnhanced( + Pointer wallet, + Pointer slatepack_str, +); Future decodeSlatepackEnhanced(String wallet, String slatepack) async { return _decodeSlatepackEnhanced( - wallet.toNativeUtf8(), - slatepack.toNativeUtf8()) + wallet.toNativeUtf8(), slatepack.toNativeUtf8()) .toDartString(); } -final TxReceive _txReceive = mwcNative - .lookup>("mwc_rust_tx_receive") - .asFunction(); +@Native(symbol: 'mwc_rust_tx_receive') +external Pointer _txReceive( + Pointer wallet, + Pointer slate_json, +); String txReceive(String wallet, String slateJson) { return _txReceive(wallet.toNativeUtf8(), slateJson.toNativeUtf8()) .toDartString(); } -final TxFinalize _txFinalize = mwcNative - .lookup>("mwc_rust_tx_finalize") - .asFunction(); +@Native(symbol: 'mwc_rust_tx_finalize') +external Pointer _txFinalize( + Pointer wallet, + Pointer slate_json, +); String txFinalize(String wallet, String slateJson) { return _txFinalize(wallet.toNativeUtf8(), slateJson.toNativeUtf8()) .toDartString(); } -final TxInit _txInit = mwcNative - .lookup>("mwc_rust_tx_init") - .asFunction(); - -Future txInit( - String wallet, - int selectionStrategyIsAll, - int minimumConfirmations, - String message, - int amount) async { +@Native(symbol: 'mwc_rust_tx_init') +external Pointer _txInit( + Pointer wallet, + Pointer selection_strategy_is_use_all, + Pointer minimum_confirmations, + Pointer message, + Pointer amount, +); + +Future txInit(String wallet, int selectionStrategyIsAll, + int minimumConfirmations, String message, int amount) async { return _txInit( - wallet.toNativeUtf8(), - selectionStrategyIsAll.toString().toNativeUtf8().cast(), - minimumConfirmations.toString().toNativeUtf8().cast(), - message.toNativeUtf8(), - amount.toString().toNativeUtf8().cast()) + wallet.toNativeUtf8(), + selectionStrategyIsAll.toString().toNativeUtf8().cast(), + minimumConfirmations.toString().toNativeUtf8().cast(), + message.toNativeUtf8(), + amount.toString().toNativeUtf8().cast()) .toDartString(); } - - - diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt deleted file mode 100644 index ac819c5e..00000000 --- a/linux/CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -# The Flutter tooling requires that developers have CMake 3.10 or later -# installed. You should not increase this version, as doing so will cause -# the plugin to fail to compile for some customers of the plugin. -cmake_minimum_required(VERSION 3.10) - -# Project-level configuration. -set(PROJECT_NAME "flutter_libmwc") -project(${PROJECT_NAME} LANGUAGES CXX) - -# This value is used when generating builds using this plugin, so it must -# not be changed. -set(PLUGIN_NAME "flutter_libmwc_plugin") - -# Define the plugin library target. Its name must not be changed (see comment -# on PLUGIN_NAME above). -# -# Any new source files that you add to the plugin should be added here. -add_library(${PLUGIN_NAME} SHARED - "flutter_libmwc_plugin.cc" -) - -# Apply a standard set of build settings that are configured in the -# application-level CMakeLists.txt. This can be removed for plugins that want -# full control over build settings. -apply_standard_settings(${PLUGIN_NAME}) - -# Symbols are hidden by default to reduce the chance of accidental conflicts -# between plugins. This should not be removed; any symbols that should be -# exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro. -set_target_properties(${PLUGIN_NAME} PROPERTIES - CXX_VISIBILITY_PRESET hidden) -target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) - -# Source include directories and library dependencies. Add any plugin-specific -# dependencies here. -target_include_directories(${PLUGIN_NAME} INTERFACE - "${CMAKE_CURRENT_SOURCE_DIR}/include") -target_link_libraries(${PLUGIN_NAME} PRIVATE flutter) -target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK) - -# List of absolute paths to libraries that should be bundled with the plugin. -# This list could contain prebuilt libraries, or libraries created by an -# external build triggered from this build file. -set(flutter_libmwc_bundled_libraries - "" - PARENT_SCOPE -) diff --git a/linux/flutter_libmwc_plugin.cc b/linux/flutter_libmwc_plugin.cc deleted file mode 100644 index 0c148f21..00000000 --- a/linux/flutter_libmwc_plugin.cc +++ /dev/null @@ -1,70 +0,0 @@ -#include "include/flutter_libmwc/flutter_libmwc_plugin.h" - -#include -#include -#include - -#include - -#define FLUTTER_LIBmwc_PLUGIN(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), flutter_libmwc_plugin_get_type(), \ - FlutterLibmwcPlugin)) - -struct _FlutterLibmwcPlugin { - GObject parent_instance; -}; - -G_DEFINE_TYPE(FlutterLibmwcPlugin, flutter_libmwc_plugin, g_object_get_type()) - -// Called when a method call is received from Flutter. -static void flutter_libmwc_plugin_handle_method_call( - FlutterLibmwcPlugin* self, - FlMethodCall* method_call) { - g_autoptr(FlMethodResponse) response = nullptr; - - const gchar* method = fl_method_call_get_name(method_call); - - if (strcmp(method, "getPlatformVersion") == 0) { - struct utsname uname_data = {}; - uname(&uname_data); - g_autofree gchar *version = g_strdup_printf("Linux %s", uname_data.version); - g_autoptr(FlValue) result = fl_value_new_string(version); - response = FL_METHOD_RESPONSE(fl_method_success_response_new(result)); - } else { - response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new()); - } - - fl_method_call_respond(method_call, response, nullptr); -} - -static void flutter_libmwc_plugin_dispose(GObject* object) { - G_OBJECT_CLASS(flutter_libmwc_plugin_parent_class)->dispose(object); -} - -static void flutter_libmwc_plugin_class_init(FlutterLibmwcPluginClass* klass) { - G_OBJECT_CLASS(klass)->dispose = flutter_libmwc_plugin_dispose; -} - -static void flutter_libmwc_plugin_init(FlutterLibmwcPlugin* self) {} - -static void method_call_cb(FlMethodChannel* channel, FlMethodCall* method_call, - gpointer user_data) { - FlutterLibmwcPlugin* plugin = FLUTTER_LIBmwc_PLUGIN(user_data); - flutter_libmwc_plugin_handle_method_call(plugin, method_call); -} - -void flutter_libmwc_plugin_register_with_registrar(FlPluginRegistrar* registrar) { - FlutterLibmwcPlugin* plugin = FLUTTER_LIBmwc_PLUGIN( - g_object_new(flutter_libmwc_plugin_get_type(), nullptr)); - - g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new(); - g_autoptr(FlMethodChannel) channel = - fl_method_channel_new(fl_plugin_registrar_get_messenger(registrar), - "flutter_libmwc", - FL_METHOD_CODEC(codec)); - fl_method_channel_set_method_call_handler(channel, method_call_cb, - g_object_ref(plugin), - g_object_unref); - - g_object_unref(plugin); -} diff --git a/linux/include/flutter_libmwc/flutter_libmwc_plugin.h b/linux/include/flutter_libmwc/flutter_libmwc_plugin.h deleted file mode 100644 index fd52087c..00000000 --- a/linux/include/flutter_libmwc/flutter_libmwc_plugin.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef FLUTTER_PLUGIN_FLUTTER_LIBMWC_PLUGIN_H_ -#define FLUTTER_PLUGIN_FLUTTER_LIBMWC_PLUGIN_H_ - -#include - -G_BEGIN_DECLS - -#ifdef FLUTTER_PLUGIN_IMPL -#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default"))) -#else -#define FLUTTER_PLUGIN_EXPORT -#endif - -typedef struct _FlutterLibmwcPlugin FlutterLibmwcPlugin; -typedef struct { - GObjectClass parent_class; -} FlutterLibmwcPluginClass; - -FLUTTER_PLUGIN_EXPORT GType flutter_libmwc_plugin_get_type(); - -FLUTTER_PLUGIN_EXPORT void flutter_libmwc_plugin_register_with_registrar( - FlPluginRegistrar* registrar); - -G_END_DECLS - -#endif // FLUTTER_PLUGIN_FLUTTER_LIBMWC_PLUGIN_H_ diff --git a/macos/Classes/FlutterLibmwcPlugin.h b/macos/Classes/FlutterLibmwcPlugin.h deleted file mode 100644 index 8a3c7dc1..00000000 --- a/macos/Classes/FlutterLibmwcPlugin.h +++ /dev/null @@ -1,85 +0,0 @@ -#include -#include -#include -#include - -const char *mwc_wallet_init(const char *config, - const char *mnemonic, - const char *password, - const char *name); - -const char *mwc_get_mnemonic(void); - -const char *mwc_rust_open_wallet(const char *config, const char *password); - -const char *mwc_rust_wallet_balances(const char *wallet, - const char *refresh, - const char *min_confirmations); - -const char *mwc_rust_recover_from_mnemonic(const char *config, - const char *password, - const char *mnemonic, - const char *name); - -const char *mwc_rust_wallet_scan_outputs(const char *wallet, - const char *start_height, - const char *number_of_blocks); - -const char *mwc_rust_create_tx(const char *wallet, - const char *amount, - const char *to_address, - const char *secret_key_index, - const char *mwcmqs_config, - const char *confirmations, - const char *note); - -const char *mwc_rust_txs_get(const char *wallet, const char *refresh_from_node); - -const char *mwc_rust_tx_cancel(const char *wallet, const char *tx_id); - -const char *mwc_rust_get_chain_height(const char *config); - -const char *mwc_rust_delete_wallet(const char *_wallet, const char *config); - -const char *mwc_rust_tx_send_http(const char *wallet, - const char *selection_strategy_is_use_all, - const char *minimum_confirmations, - const char *message, - const char *amount, - const char *address); - -const char *mwc_rust_get_wallet_address(const char *wallet, - const char *index, - const char *mwcmqs_config); - -const char *mwc_rust_validate_address(const char *address); - -const char *mwc_rust_get_tx_fees(const char *wallet, - const char *c_amount, - const char *min_confirmations); - -const char *mwc_rust_init_logs(const char *config); - -const char *mwc_rust_encode_slatepack(const char *slate_json, const char *recipient_address); - -const char *mwc_rust_encode_slatepack_enhanced(const char *wallet, - const char *slate_json, - const char *recipient_address); - -const char *mwc_rust_decode_slatepack(const char *slatepack_str); - -const char *mwc_rust_decode_slatepack_enhanced(const char *wallet, const char *slatepack_str); - -const char *mwc_rust_tx_receive(const char *wallet, const char *slate_json); - -const char *mwc_rust_tx_finalize(const char *wallet, const char *slate_json); - -const char *mwc_rust_tx_init(const char *wallet, - const char *selection_strategy_is_use_all, - const char *minimum_confirmations, - const char *message, - const char *amount); - -void *mwc_rust_mwcmqs_listener_start(const char *wallet, const char *mwcmqs_config); - -const char *mwc_listener_cancel(void *handler); diff --git a/macos/Classes/FlutterLibmwcPlugin.swift b/macos/Classes/FlutterLibmwcPlugin.swift deleted file mode 100644 index 61998f35..00000000 --- a/macos/Classes/FlutterLibmwcPlugin.swift +++ /dev/null @@ -1,65 +0,0 @@ -import Cocoa -import FlutterMacOS - -public class FlutterLibmwcPlugin: NSObject, FlutterPlugin { - public static func register(with registrar: FlutterPluginRegistrar) { - let channel = FlutterMethodChannel(name: "flutter_libmwc", binaryMessenger: registrar.messenger) - let instance = FlutterLibmwcPlugin() - registrar.addMethodCallDelegate(instance, channel: channel) - } - - public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { - switch call.method { - case "getPlatformVersion": - result("macOS " + ProcessInfo.processInfo.operatingSystemVersionString) - default: - result(FlutterMethodNotImplemented) - } - } - - public func dummyMethodToEnforceBundling() { - mwc_wallet_init("const char *config", - "const char *mnemonic", - "const char *password", - "const char *name"); - mwc_get_mnemonic(); - mwc_rust_open_wallet("const char *config", - "const char *password"); - mwc_rust_wallet_balances("const char *wallet", "const char *refresh", "const char *min_confirmations"); - mwc_rust_recover_from_mnemonic("const char *config", - "const char *password", - "const char *mnemonic", - "const char *name"); - - mwc_rust_wallet_scan_outputs("const char *wallet", - "const char *start_height", "onst char *number_of_blocks"); - - mwc_rust_create_tx("const char *wallet", - "const char *amount", - "const char *to_address", - "const char *secret_key_index", "const char *mwcmqs_config", - "const char *minimum_confirmations", "const char *note"); - mwc_rust_txs_get("const char *wallet", - "const char *refresh_from_node"); - mwc_rust_tx_cancel("const char *wallet", "const char *tx_id"); - - mwc_rust_get_chain_height("const char *config"); - mwc_rust_delete_wallet("const char *wallet", - "const char *mwcmqs_config"); - mwc_rust_get_wallet_address("const char *wallet", "const char *index", "const char *mwcmqs_config"); - mwc_rust_validate_address("const char *address"); - mwc_rust_get_tx_fees("const char *wallet", "const char *c_amount", "const char *min_confirmations"); - - mwc_rust_tx_send_http("const char *wallet", "const char *selection_strategy_is_use_all","const char *minimum_confirmations", - "const char *message", - "const char *amount", - "const char *address"); - mwc_rust_mwcmqs_listener_start("const char *wallet", - "const char *mwcmqs_config"); - - let handler = UnsafeMutablePointer.allocate(capacity: 1); - mwc_listener_cancel(handler); - // ... - // This code will force the bundler to use these functions, but will never be called - } -} diff --git a/macos/flutter_libmwc.podspec b/macos/flutter_libmwc.podspec deleted file mode 100644 index 2b649c8f..00000000 --- a/macos/flutter_libmwc.podspec +++ /dev/null @@ -1,28 +0,0 @@ -# -# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. -# Run `pod lib lint flutter_libmimblewimblecoin.podspec` to validate before publishing. -# -Pod::Spec.new do |s| - s.name = 'flutter_libmwc' - s.version = '0.0.1' - s.summary = 'A new Flutter plugin project.' - s.description = <<-DESC -A new Flutter plugin project. - DESC - s.homepage = 'http://example.com' - s.license = { :file => '../LICENSE' } - s.author = { 'Your Company' => 'email@example.com' } - - s.source = { :path => '.' } - s.source_files = 'Classes/**/*' - s.vendored_frameworks = 'framework/MWCWallet.xcframework' - s.dependency 'FlutterMacOS' - - s.platform = :osx, '10.11' - s.pod_target_xcconfig = { - 'DEFINES_MODULE' => 'YES', - 'EXCLUDED_ARCHS[sdk=macosx*]' => 'x86_64' - } - s.swift_version = '5.0' - s.libraries = 'resolv' -end diff --git a/pubspec.yaml b/pubspec.yaml index d45cc9bd..8df76939 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,82 +1,23 @@ name: flutter_libmwc -description: A new Flutter plugin project. -version: 0.0.1 -homepage: +description: Dart bindings for the MWC wallet. +version: 0.1.0 environment: - sdk: ">=3.0.0 <4.0.0" - flutter: ">=3.10.3" + sdk: ">=3.13.0 <4.0.0" + flutter: ">=3.47.0" dependencies: flutter: sdk: flutter - plugin_platform_interface: ^2.0.2 ffi: ^2.0.2 decimal: ^2.1.0 mutex: ^3.0.0 + code_assets: ^1.2.1 + hooks: ^2.2.0 + native_toolchain_rust: ^1.0.6 dev_dependencies: flutter_test: sdk: flutter # flutter_lints: ^2.0.0 - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. -flutter: - # This section identifies this Flutter project as a plugin project. - # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.) - # which should be registered in the plugin registry. This is required for - # using method channels. - # The Android 'package' specifies package in which the registered class is. - # This is required for using method channels on Android. - # The 'ffiPlugin' specifies that native code should be built and bundled. - # This is required for using `dart:ffi`. - # All these are used by the tooling to maintain consistency when - # adding or updating assets for this project. - plugin: - platforms: - android: - package: com.example.flutter_libmwc - pluginClass: FlutterLibmwcPlugin - ios: - pluginClass: FlutterLibmwcPlugin - linux: - pluginClass: FlutterLibmwcPlugin - macos: - pluginClass: FlutterLibmwcPlugin - windows: - pluginClass: FlutterLibmwcPluginCApi - - # To add assets to your plugin package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # To add custom fonts to your plugin package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 6bf01698..c6156e04 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -2,6 +2,7 @@ name = "mwc-wallet" version = "0.1.0" edition = '2021' +rust-version = "1.90" [dependencies] clap = { version = "2.31", features = ["yaml"] } diff --git a/rust/rust-toolchain.toml b/rust/rust-toolchain.toml new file mode 100644 index 00000000..49004c25 --- /dev/null +++ b/rust/rust-toolchain.toml @@ -0,0 +1,16 @@ +[toolchain] +channel = "1.90.0" +profile = "minimal" +targets = [ + "armv7-linux-androideabi", + "aarch64-linux-android", + "x86_64-linux-android", + "aarch64-apple-ios", + "aarch64-apple-ios-sim", + "x86_64-apple-ios", + "aarch64-apple-darwin", + "x86_64-apple-darwin", + "aarch64-unknown-linux-gnu", + "x86_64-unknown-linux-gnu", + "x86_64-pc-windows-msvc", +] diff --git a/scripts/android/build_all.sh b/scripts/android/build_all.sh deleted file mode 100755 index d10d00e3..00000000 --- a/scripts/android/build_all.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -. ./install_ndk.sh -. ./build_openssl.sh -. ./config.sh - -# shellcheck disable=SC2164 -cd "${WORKDIR}" -echo "${WORKDIR}" - -rm -r ../../../android/src/main/jniLibs/ -echo ''$(git log -1 --pretty=format:"%H")' '$(date) >> git_commit_version.txt -VERSIONS_FILE=../../../lib/git_versions.dart -EXAMPLE_VERSIONS_FILE=../../../lib/git_versions_example.dart -if [ ! -f "$VERSIONS_FILE" ]; then - cp $EXAMPLE_VERSIONS_FILE $VERSIONS_FILE -fi -COMMIT=$(git log -1 --pretty=format:"%H") -OS="ANDROID" -sed -i "/\/\*${OS}_VERSION/c\\/\*${OS}_VERSION\*\/ const ${OS}_VERSION = \"$COMMIT\";" $VERSIONS_FILE - -cp -r ../../../rust rust -# shellcheck disable=SC2164 -cd rust -rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android - -# TODO Investigate why x86 does not build -cargo ndk -t armeabi-v7a -t arm64-v8a -t x86_64 -o ../../../../android/src/main/jniLibs build --release diff --git a/scripts/android/build_openssl.sh b/scripts/android/build_openssl.sh deleted file mode 100755 index 2d937b98..00000000 --- a/scripts/android/build_openssl.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -. ./config.sh -OPENSSL_VERSION="1.1.1q" -OPENSSL_SHA256="d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca" -OPENSSL_DIR=${WORKDIR}/openssl -OPENSSL_GZIP=${CACHEDIR}/openssl-${OPENSSL_VERSION}.tar.gz - -# shellcheck disable=SC2164 -cd "${WORKDIR}" -if [ ! -e "$OPENSSL_GZIP" ]; then - curl -L https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz -o "${OPENSSL_GZIP}" -fi -echo $OPENSSL_SHA256 "$OPENSSL_GZIP" | sha256sum -c || exit 1 -mkdir -p "${OPENSSL_DIR}" -tar -xvzf "$OPENSSL_GZIP" -C "${OPENSSL_DIR}" - -# needed for when rust tries to build openssl-sys -export PATH=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin:$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:$PATH - -# shellcheck disable=SC2164 -cd "${WORKDIR}"/.. diff --git a/scripts/android/config.sh b/scripts/android/config.sh deleted file mode 100755 index 7fe7ecfe..00000000 --- a/scripts/android/config.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -export WORKDIR="$(pwd)/"build -export CACHEDIR="$(pwd)/"cache -ANDROID_NDK_API=28 - -export ANDROID_NDK_SHA256="a186b67e8810cb949514925e4f7a2255548fb55f5e9b0824a6430d012c1b695b" -export ANDROID_NDK_URL=https://dl.google.com/android/repository/android-ndk-r${ANDROID_NDK_API}-linux.zip -# Some NDK versions end in -linux.zip, some in -linux_x86_64.zip. -export ANDROID_NDK_ZIP=${CACHEDIR}/android-ndk-r${ANDROID_NDK_API}-linux.zip -export ANDROID_NDK_ROOT=${WORKDIR}/android-ndk-r${ANDROID_NDK_API} -export ANDROID_NDK_HOME=$ANDROID_NDK_ROOT diff --git a/scripts/android/download.sh b/scripts/android/download.sh deleted file mode 100755 index ea3acf14..00000000 --- a/scripts/android/download.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -set -e - -LIB_ROOT=../.. -REPO="cypherstack/flutter_libmwc" -BASE_URL="https://github.com/${REPO}/releases/download" - -TAG=$(git -C "$LIB_ROOT" describe --tags --exact-match HEAD 2>/dev/null) || { - echo "Error: flutter_libmwc is not at a tagged commit." - echo "Pin the submodule to a release tag to use download mode." - echo "Current commit: $(git -C "$LIB_ROOT" rev-parse HEAD)" - exit 1 -} - -TMPDIR=$(mktemp -d) -trap 'rm -rf "$TMPDIR"' EXIT - -curl -fSL "${BASE_URL}/${TAG}/checksums.txt" -o "$TMPDIR/checksums.txt" - -download_and_verify() { - local asset="$1" - curl -fSL "${BASE_URL}/${TAG}/${asset}" -o "$TMPDIR/${asset}" - grep "^[0-9a-f]* ${asset}$" "$TMPDIR/checksums.txt" | (cd "$TMPDIR" && sha256sum -c) -} - -JNILIBS="$LIB_ROOT/android/src/main/jniLibs" - -download_and_verify "libmwc_wallet-android-arm64-v8a.so" -mkdir -p "$JNILIBS/arm64-v8a" -cp "$TMPDIR/libmwc_wallet-android-arm64-v8a.so" "$JNILIBS/arm64-v8a/libmwc_wallet.so" - -download_and_verify "libmwc_wallet-android-armeabi-v7a.so" -mkdir -p "$JNILIBS/armeabi-v7a" -cp "$TMPDIR/libmwc_wallet-android-armeabi-v7a.so" "$JNILIBS/armeabi-v7a/libmwc_wallet.so" - -download_and_verify "libmwc_wallet-android-x86_64.so" -mkdir -p "$JNILIBS/x86_64" -cp "$TMPDIR/libmwc_wallet-android-x86_64.so" "$JNILIBS/x86_64/libmwc_wallet.so" diff --git a/scripts/android/install_ndk.sh b/scripts/android/install_ndk.sh deleted file mode 100755 index 725784e0..00000000 --- a/scripts/android/install_ndk.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -mkdir -p build -. ./config.sh - -if [ ! -e "${ANDROID_NDK_ZIP}" ]; then - mkdir -p cache - # curl https://dl.google.com/android/repository/android-ndk-r${ANDROID_NDK_API}-linux.zip -o ${ANDROID_NDK_ZIP} - curl "${ANDROID_NDK_URL}" -o "${ANDROID_NDK_ZIP}" -fi -echo "${ANDROID_NDK_SHA256}" "${ANDROID_NDK_ZIP}" | sha256sum -c || exit 1 -unzip "${ANDROID_NDK_ZIP}" -d "${WORKDIR}" diff --git a/scripts/android/publish.sh b/scripts/android/publish.sh deleted file mode 100755 index ebb46ee1..00000000 --- a/scripts/android/publish.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -OS=android -TAG_COMMIT=$(git log -1 --pretty=format:"%H") - -rm -rf flutter_libmwc_bins -git clone https://git.cypherstack.com/stackwallet/flutter_libmwc_bins -if [ -d flutter_libmwc_bins ]; then - cd flutter_libmwc_bins -else - echo "Failed to clone flutter_libmwc_bins" - exit 1 -fi - -TARGET_PATH=../../../android/src/main/jniLibs -BIN=libmwc_wallet.so - -for TARGET in arm64-v8a armeabi-v7a x86_64 -do - if [ $(git tag -l "${OS}_${TARGET}_${TAG_COMMIT}") ]; then - echo "Tag ${OS}_${TARGET}_${TAG_COMMIT} already exists!" - else - ARCH_PATH=$TARGET - - if [ -f "$TARGET_PATH/$ARCH_PATH/$BIN" ]; then - git checkout $OS/$TARGET || git checkout -b $OS/$TARGET - if [ ! -d $OS/$ARCH_PATH ]; then - mkdir -p $OS/$ARCH_PATH - fi - cp -rf $TARGET_PATH/$ARCH_PATH/$BIN $OS/$ARCH_PATH/$BIN - git add . - git commit -m "$TARGET commit for $TAG_COMMIT" - git push origin $OS/$TARGET - git tag "${OS}_${TARGET}_${TAG_COMMIT}" - git push --tags - else - echo "$TARGET not found at $TARGET_PATH/$ARCH_PATH/$BIN!" - fi - fi -done diff --git a/scripts/ios/build_all.sh b/scripts/ios/build_all.sh deleted file mode 100755 index c6f7cf33..00000000 --- a/scripts/ios/build_all.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env bash -set -e -rm -rf build -mkdir build -echo ''$(git log -1 --pretty=format:"%H")' '$(date) >> build/git_commit_version.txt -VERSIONS_FILE=../../lib/git_versions.dart -EXAMPLE_VERSIONS_FILE=../../lib/git_versions_example.dart -if [ ! -f "$VERSIONS_FILE" ]; then - cp $EXAMPLE_VERSIONS_FILE $VERSIONS_FILE -fi -COMMIT=$(git log -1 --pretty=format:"%H") -OS="IOS" -sed -i '' '/\/\*${OS}_VERSION/c\'$'\n''/\*${OS}_VERSION\*\/ const ${OS}_VERSION = "'"$COMMIT"'";' "$VERSIONS_FILE" -cp -r ../../rust build/rust -cd build/rust - -rustup target add aarch64-apple-ios x86_64-apple-ios - -# some people need this apparently -export PROTOC=/opt/homebrew/bin/protoc - -# building -cbindgen src/lib.rs -l c > libmwc_wallet.h - -export IPHONEOS_DEPLOYMENT_TARGET=15.0 -export RUSTFLAGS="-C link-arg=-mios-version-min=15.0" -cargo build --release --target aarch64-apple-ios -#cargo lipo --release - -# moving files to the ios project -inc=../../../../ios/include -libs=../../../../ios/libs - -rm -rf ${inc} ${libs} - -mkdir ${inc} -mkdir ${libs} - -cp libmwc_wallet.h ${inc} -cp target/aarch64-apple-ios/release/libmwc_wallet.a ${libs} \ No newline at end of file diff --git a/scripts/ios/download.sh b/scripts/ios/download.sh deleted file mode 100755 index 1168046a..00000000 --- a/scripts/ios/download.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -set -e - -LIB_ROOT=../.. -REPO="cypherstack/flutter_libmwc" -BASE_URL="https://github.com/${REPO}/releases/download" - -TAG=$(git -C "$LIB_ROOT" describe --tags --exact-match HEAD 2>/dev/null) || { - echo "Error: flutter_libmwc is not at a tagged commit." - echo "Pin the submodule to a release tag to use download mode." - echo "Current commit: $(git -C "$LIB_ROOT" rev-parse HEAD)" - exit 1 -} - -TMPDIR=$(mktemp -d) -trap 'rm -rf "$TMPDIR"' EXIT - -curl -fSL "${BASE_URL}/${TAG}/checksums.txt" -o "$TMPDIR/checksums.txt" - -download_and_verify() { - local asset="$1" - curl -fSL "${BASE_URL}/${TAG}/${asset}" -o "$TMPDIR/${asset}" - grep "^[0-9a-f]* ${asset}$" "$TMPDIR/checksums.txt" | (cd "$TMPDIR" && shasum -a 256 -c) -} - -download_and_verify "libmwc_wallet-ios-aarch64.a" -mkdir -p "$LIB_ROOT/ios/libs" -cp "$TMPDIR/libmwc_wallet-ios-aarch64.a" "$LIB_ROOT/ios/libs/libmwc_wallet.a" - -download_and_verify "libmwc_wallet.h" -mkdir -p "$LIB_ROOT/ios/include" -cp "$TMPDIR/libmwc_wallet.h" "$LIB_ROOT/ios/include/libmwc_wallet.h" diff --git a/scripts/ios/publish.sh b/scripts/ios/publish.sh deleted file mode 100755 index 6d259caf..00000000 --- a/scripts/ios/publish.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -# IOS publish script WIP; doublecheck that they follow patterns in linux/android scripts before running - -OS=ios -TAG_COMMIT=$(git log -1 --pretty=format:"%H") - -rm -rf flutter_libmwc_bins -git clone https://git.cypherstack.com/stackwallet/flutter_libmwc_bins -if [ -d flutter_libmwc_bins ]; then - cd flutter_libmwc_bins -else - echo "Failed to clone flutter_libmwc_bins" - exit 1 -fi - -TARGET_PATH=../build/rust/target -BIN=libmwc_wallet.a -HEADER=libmwc_wallet.h - -for TARGET in aarch64-apple-ios x86_64-apple-ios -do - if [ $(git tag -l "${TARGET}_${TAG_COMMIT}") ]; then - echo "Tag ${TARGET}_${TAG_COMMIT} already exists!" - else - ARCH_PATH=$TARGET/release - - if [ -f "$TARGET_PATH/$ARCH_PATH/$BIN" ]; then - git checkout $OS/$TARGET || git checkout -b $OS/$TARGET - if [ ! -d $OS/$ARCH_PATH ]; then - mkdir -p $OS/$ARCH_PATH - fi - cp -rf $TARGET_PATH/$ARCH_PATH/$BIN $OS/$ARCH_PATH/$BIN - cp -rf $TARGET_PATH/../$HEADER $OS/$ARCH_PATH/$HEADER - git add . - git commit -m "$TARGET commit for $TAG_COMMIT" - git push origin $OS/$TARGET - git tag $TARGET"_$TAG_COMMIT" - git push --tags - else - echo "$TARGET not found!" - fi - fi -done diff --git a/scripts/linux/build_all.sh b/scripts/linux/build_all.sh deleted file mode 100755 index 669606c8..00000000 --- a/scripts/linux/build_all.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -mkdir build -echo ''$(git log -1 --pretty=format:"%H")' '$(date) >> build/git_commit_version.txt -VERSIONS_FILE=../../lib/git_versions.dart -EXAMPLE_VERSIONS_FILE=../../lib/git_versions_example.dart -if [ ! -f "$VERSIONS_FILE" ]; then - cp $EXAMPLE_VERSIONS_FILE $VERSIONS_FILE -fi -COMMIT=$(git log -1 --pretty=format:"%H") -OS="LINUX" -sed -i "/\/\*${OS}_VERSION/c\\/\*${OS}_VERSION\*\/ const ${OS}_VERSION = \"$COMMIT\";" $VERSIONS_FILE -#rm -rf build/rust -rsync -av --exclude='target' ../../rust/ build/rust/ -cd build/rust -if [ "$IS_ARM" = true ] ; then - echo "Building arm version" - cargo build --target aarch64-unknown-linux-gnu --release --lib - mkdir -p ../../../../linux/bin/aarch64-unknown-linux-gnu/release - cp target/aarch64-unknown-linux-gnu/release/libmwc_wallet.so ../../../../linux/bin/aarch64-unknown-linux-gnu/release/ -else - echo "Building x86_64 version" - cargo build --target x86_64-unknown-linux-gnu --release --lib - mkdir -p ../../../../linux/bin/x86_64-unknown-linux-gnu/release - cp target/x86_64-unknown-linux-gnu/release/libmwc_wallet.so ../../../../linux/bin/x86_64-unknown-linux-gnu/release/ -fi diff --git a/scripts/linux/download.sh b/scripts/linux/download.sh deleted file mode 100755 index a77a7dcf..00000000 --- a/scripts/linux/download.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -set -e - -LIB_ROOT=../.. -REPO="cypherstack/flutter_libmwc" -BASE_URL="https://github.com/${REPO}/releases/download" - -TAG=$(git -C "$LIB_ROOT" describe --tags --exact-match HEAD 2>/dev/null) || { - echo "Error: flutter_libmwc is not at a tagged commit." - echo "Pin the submodule to a release tag to use download mode." - echo "Current commit: $(git -C "$LIB_ROOT" rev-parse HEAD)" - exit 1 -} - -TMPDIR=$(mktemp -d) -trap 'rm -rf "$TMPDIR"' EXIT - -curl -fSL "${BASE_URL}/${TAG}/checksums.txt" -o "$TMPDIR/checksums.txt" - -download_and_verify() { - local asset="$1" - curl -fSL "${BASE_URL}/${TAG}/${asset}" -o "$TMPDIR/${asset}" - grep "^[0-9a-f]* ${asset}$" "$TMPDIR/checksums.txt" | (cd "$TMPDIR" && sha256sum -c) -} - -download_and_verify "libmwc_wallet-linux-x86_64.so" -mkdir -p "$LIB_ROOT/linux/bin/x86_64-unknown-linux-gnu/release" -cp "$TMPDIR/libmwc_wallet-linux-x86_64.so" \ - "$LIB_ROOT/linux/bin/x86_64-unknown-linux-gnu/release/libmwc_wallet.so" - -download_and_verify "libmwc_wallet-linux-aarch64.so" -mkdir -p "$LIB_ROOT/linux/bin/aarch64-unknown-linux-gnu/release" -cp "$TMPDIR/libmwc_wallet-linux-aarch64.so" \ - "$LIB_ROOT/linux/bin/aarch64-unknown-linux-gnu/release/libmwc_wallet.so" diff --git a/scripts/linux/publish.sh b/scripts/linux/publish.sh deleted file mode 100755 index 509d81aa..00000000 --- a/scripts/linux/publish.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -OS=linux -TAG_COMMIT=$(git log -1 --pretty=format:"%H") - -rm -rf flutter_libmwc_bins -git clone https://git.cypherstack.com/stackwallet/flutter_libmwc_bins -if [ -d flutter_libmwc_bins ]; then - cd flutter_libmwc_bins -else - echo "Failed to clone flutter_libmwc_bins" - exit 1 -fi - -TARGET_PATH=../build/rust/target -BIN=libmwc_wallet.so - -for TARGET in aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu -do - if [ $(git tag -l "${OS}_${TARGET}_${TAG_COMMIT}") ]; then - echo "Tag ${OS}_${TARGET}_${TAG_COMMIT} already exists!" - else - ARCH_PATH=$TARGET/release - - if [ -f "$TARGET_PATH/$ARCH_PATH/$BIN" ]; then - git checkout $OS/$TARGET || git checkout -b $OS/$TARGET - if [ ! -d $OS/$ARCH_PATH ]; then - mkdir -p $OS/$ARCH_PATH - fi - cp -rf $TARGET_PATH/$ARCH_PATH/$BIN $OS/$ARCH_PATH/$BIN - git add . - git commit -m "$TARGET commit for $TAG_COMMIT" - git push origin $OS/$TARGET - git tag "${OS}_${TARGET}_${TAG_COMMIT}" - git push --tags - else - echo "$TARGET not found at $TARGET_PATH/$ARCH_PATH/$BIN!" - fi - fi -done diff --git a/scripts/macos/build_all.sh b/scripts/macos/build_all.sh deleted file mode 100755 index f85d9029..00000000 --- a/scripts/macos/build_all.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash -set -e -rm -rf build -mkdir build -echo ''$(git log -1 --pretty=format:"%H")' '$(date) >> build/git_commit_version.txt -VERSIONS_FILE=../../lib/git_versions.dart -EXAMPLE_VERSIONS_FILE=../../lib/git_versions_example.dart -if [ ! -f "$VERSIONS_FILE" ]; then - cp $EXAMPLE_VERSIONS_FILE $VERSIONS_FILE -fi -COMMIT=$(git log -1 --pretty=format:"%H") -OSX="OSX" -sed -i '' '/\/\*${OS}_VERSION/c\'$'\n''/\*${OS}_VERSION\*\/ const ${OS}_VERSION = "'"$COMMIT"'";' "$VERSIONS_FILE" -cp -r ../../rust build/rust -cd build/rust - -# some people need this apparently -export PROTOC=/opt/homebrew/bin/protoc - -# building -cbindgen src/lib.rs -l c > libmwc_wallet.h -cargo lipo --release --targets aarch64-apple-darwin - -xcodebuild -create-xcframework \ - -library target/aarch64-apple-darwin/release/libmwc_wallet.a \ - -headers libmwc_wallet.h \ - -output ../MWCWallet.xcframework - -# moving files to the macos project -fwk=../../../../macos/framework/ -rm -rf ${fwk} -mkdir ${fwk} -mv ../MWCWallet.xcframework ${fwk} diff --git a/scripts/macos/download.sh b/scripts/macos/download.sh deleted file mode 100755 index 191111b2..00000000 --- a/scripts/macos/download.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -set -e - -LIB_ROOT=../.. -REPO="cypherstack/flutter_libmwc" -BASE_URL="https://github.com/${REPO}/releases/download" - -TAG=$(git -C "$LIB_ROOT" describe --tags --exact-match HEAD 2>/dev/null) || { - echo "Error: flutter_libmwc is not at a tagged commit." - echo "Pin the submodule to a release tag to use download mode." - echo "Current commit: $(git -C "$LIB_ROOT" rev-parse HEAD)" - exit 1 -} - -TMPDIR=$(mktemp -d) -trap 'rm -rf "$TMPDIR"' EXIT - -curl -fSL "${BASE_URL}/${TAG}/checksums.txt" -o "$TMPDIR/checksums.txt" - -download_and_verify() { - local asset="$1" - curl -fSL "${BASE_URL}/${TAG}/${asset}" -o "$TMPDIR/${asset}" - grep "^[0-9a-f]* ${asset}$" "$TMPDIR/checksums.txt" | (cd "$TMPDIR" && shasum -a 256 -c) -} - -download_and_verify "MWCWallet.xcframework.zip" - -mkdir -p "$LIB_ROOT/macos/framework" -rm -rf "$LIB_ROOT/macos/framework/MWCWallet.xcframework" -unzip -q "$TMPDIR/MWCWallet.xcframework.zip" -d "$TMPDIR/xcfw" -cp -r "$TMPDIR/xcfw/MWCWallet.xcframework" "$LIB_ROOT/macos/framework/MWCWallet.xcframework" diff --git a/scripts/windows/README.md b/scripts/windows/README.md deleted file mode 100644 index a5058f92..00000000 --- a/scripts/windows/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# `flutter_libmwc` -## Dependencies -Run `deps.sh` (may need to alter permissions like with `chmod +x *.sh`) to install x86_64-w64-mingw32-gcc or run -```sh -sudo apt-get install clang gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 -``` - -## Building for Windows -Run `build_all.sh` - -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 diff --git a/scripts/windows/build_all.ps1 b/scripts/windows/build_all.ps1 deleted file mode 100644 index e653b232..00000000 --- a/scripts/windows/build_all.ps1 +++ /dev/null @@ -1,42 +0,0 @@ -# !/bin/pwsh - -Write-Output "WARNING: building from Windows not confirmed working." - -rustup target add x86_64-pc-windows-msvc - -git clone https://github.com/Microsoft/vcpkg.git -cd vcpkg -.\bootstrap-vcpkg.bat -.\vcpkg.exe install openssl:x64-windows-static -cd .. - -$env:OPENSSL_DIR = "${pwd}\installed\x64-windows-static" -$env:OPENSSL_STATIC = 'Yes' -[System.Environment]::SetEnvironmentVariable('OPENSSL_DIR', $env:OPENSSL_DIR, [System.EnvironmentVariableTarget]::User) -[System.Environment]::SetEnvironmentVariable('OPENSSL_STATIC', $env:OPENSSL_STATIC, [System.EnvironmentVariableTarget]::User) - -New-Item -ItemType Directory -Force -Path build -$env:COMMIT = $(git log -1 --pretty=format:"%H") -$env:VERSIONS_FILE = "..\..\lib\git_versions.dart" -$env:EXAMPLE_VERSIONS_FILE = "..\..\lib\git_versions_example.dart" -Copy-Item $env:EXAMPLE_VERSIONS_FILE -Destination $env:VERSIONS_FILE -Force -$env:OS = "WINDOWS" -(Get-Content $env:VERSIONS_FILE).replace('WINDOWS_VERSION = ""', "WINDOWS_VERSION = ""${env:COMMIT}""") | Set-Content $env:VERSIONS_FILE -Copy-Item "..\..\rust\*" -Destination "build\rust" -Force -Recurse -cd build\rust -if (Test-Path 'env:IS_ARM ') { - Write-Output "Building arm version" - cargo build --target aarch64-pc-windows-msvc --release --lib - - New-Item -ItemType Directory -Force -Path target\aarch64-pc-windows-msvc\release - Copy-Item "target\aarch64-pc-windows-msvc\release\libmwc_wallet.so" -Destination "target\aarch64-pc-windows-gnu\release\" -Force -} else { - Write-Output "Building x86_64 version" - New-Item -ItemType Directory -Force -Path target\x86_64-pc-windows-msvc\release - - cargo build --target x86_64-pc-windows-msvc --release --lib -} - -# Return to /scripts/windows -cd .. -cd .. diff --git a/scripts/windows/build_all.sh b/scripts/windows/build_all.sh deleted file mode 100755 index 7e156428..00000000 --- a/scripts/windows/build_all.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -rustup target add x86_64-pc-windows-gnu - -mkdir build -echo ''$(git log -1 --pretty=format:"%H")' '$(date) >> build/git_commit_version.txt -VERSIONS_FILE=../../lib/git_versions.dart -EXAMPLE_VERSIONS_FILE=../../lib/git_versions_example.dart -if [ ! -f "$VERSIONS_FILE" ]; then - cp $EXAMPLE_VERSIONS_FILE $VERSIONS_FILE -fi -COMMIT=$(git log -1 --pretty=format:"%H") -OS="WINDOWS" -sed -i "/\/\*${OS}_VERSION/c\\/\*${OS}_VERSION\*\/ const ${OS}_VERSION = \"$COMMIT\";" $VERSIONS_FILE -cp -r ../../rust build/rust -cd build/rust -if [ "$IS_ARM" = true ] ; then - echo "Building arm version" - cargo build --target aarch64-pc-windows-gnu --release --lib - - mkdir -p target/x86_64-pc-windows-gnu/release - cp target/aarch64-pc-windows-gnu/release/libmwc_wallet.so target/x86_64-pc-windows-gnu/release/ -else - echo "Building x86_64 version" - cargo build --target x86_64-pc-windows-gnu --release --lib -fi - -cp target/x86_64-pc-windows-gnu/release/mwc_wallet.dll ../libmwc_wallet.dll - -# Copy MinGW runtime DLLs required by libmwc_wallet.dll. -cp "$(x86_64-w64-mingw32-gcc -print-file-name=libstdc++-6.dll)" ../ -cp "$(x86_64-w64-mingw32-gcc -print-file-name=libgcc_s_seh-1.dll)" ../ diff --git a/scripts/windows/deps.sh b/scripts/windows/deps.sh deleted file mode 100755 index 142af396..00000000 --- a/scripts/windows/deps.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -# MinGW64 dependencies -sudo apt-get install -y \ - clang \ - gcc-mingw-w64-x86-64 \ - g++-mingw-w64-x86-64 diff --git a/scripts/windows/download.sh b/scripts/windows/download.sh deleted file mode 100755 index fd50eec4..00000000 --- a/scripts/windows/download.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -set -e - -LIB_ROOT=../.. -REPO="cypherstack/flutter_libmwc" -BASE_URL="https://github.com/${REPO}/releases/download" - -TAG=$(git -C "$LIB_ROOT" describe --tags --exact-match HEAD 2>/dev/null) || { - echo "Error: flutter_libmwc is not at a tagged commit." - echo "Pin the submodule to a release tag to use download mode." - echo "Current commit: $(git -C "$LIB_ROOT" rev-parse HEAD)" - exit 1 -} - -TMPDIR=$(mktemp -d) -trap 'rm -rf "$TMPDIR"' EXIT - -curl -fSL "${BASE_URL}/${TAG}/checksums.txt" -o "$TMPDIR/checksums.txt" - -download_and_verify() { - local asset="$1" - curl -fSL "${BASE_URL}/${TAG}/${asset}" -o "$TMPDIR/${asset}" - grep "^[0-9a-f]* ${asset}$" "$TMPDIR/checksums.txt" | (cd "$TMPDIR" && sha256sum -c) -} - -WINLIBS="$LIB_ROOT/scripts/windows/build" -mkdir -p "$WINLIBS" - -download_and_verify "libmwc_wallet-windows-x86_64.dll" -cp "$TMPDIR/libmwc_wallet-windows-x86_64.dll" "$WINLIBS/libmwc_wallet.dll" - -download_and_verify "libstdc++-6.dll" -cp "$TMPDIR/libstdc++-6.dll" "$WINLIBS/libstdc++-6.dll" - -download_and_verify "libgcc_s_seh-1.dll" -cp "$TMPDIR/libgcc_s_seh-1.dll" "$WINLIBS/libgcc_s_seh-1.dll" diff --git a/test/flutter_libmwc_method_channel_test.dart b/test/flutter_libmwc_method_channel_test.dart deleted file mode 100644 index c810a41e..00000000 --- a/test/flutter_libmwc_method_channel_test.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:flutter/services.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:flutter_libmwc/flutter_libmwc_method_channel.dart'; - -void main() { - MethodChannelFlutterLibmwc platform = MethodChannelFlutterLibmwc(); - const MethodChannel channel = MethodChannel('flutter_libmwc'); - - TestWidgetsFlutterBinding.ensureInitialized(); - - setUp(() { - channel.setMockMethodCallHandler((MethodCall methodCall) async { - return '42'; - }); - }); - - tearDown(() { - channel.setMockMethodCallHandler(null); - }); - - test('getPlatformVersion', () async { - expect(await platform.getPlatformVersion(), '42'); - }); -} diff --git a/test/flutter_libmwc_test.dart b/test/flutter_libmwc_test.dart deleted file mode 100644 index 3b1c9388..00000000 --- a/test/flutter_libmwc_test.dart +++ /dev/null @@ -1,29 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:flutter_libmwc/flutter_libmwc.dart'; -import 'package:flutter_libmwc/flutter_libmwc_platform_interface.dart'; -import 'package:flutter_libmwc/flutter_libmwc_method_channel.dart'; -import 'package:plugin_platform_interface/plugin_platform_interface.dart'; - -class MockFlutterLibmwcPlatform - with MockPlatformInterfaceMixin - implements FlutterLibmwcPlatform { - - @override - Future getPlatformVersion() => Future.value('42'); -} - -void main() { - final FlutterLibmwcPlatform initialPlatform = FlutterLibmwcPlatform.instance; - - test('$MethodChannelFlutterLibmwc is the default instance', () { - expect(initialPlatform, isInstanceOf()); - }); - - test('getPlatformVersion', () async { - FlutterLibmwc flutterLibmwcPlugin = FlutterLibmwc(); - MockFlutterLibmwcPlatform fakePlatform = MockFlutterLibmwcPlatform(); - FlutterLibmwcPlatform.instance = fakePlatform; - - expect(await flutterLibmwcPlugin.getPlatformVersion(), '42'); - }); -} diff --git a/test/native_assets_test.dart b/test/native_assets_test.dart new file mode 100644 index 00000000..f88d22e7 --- /dev/null +++ b/test/native_assets_test.dart @@ -0,0 +1,8 @@ +import 'package:flutter_libmwc/mwc.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + test('calls Rust through the bundled native asset', () { + expect(walletMnemonic().trim().split(RegExp(r'\s+')), hasLength(24)); + }); +} diff --git a/windows/.gitignore b/windows/.gitignore deleted file mode 100644 index b3eb2be1..00000000 --- a/windows/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -flutter/ - -# Visual Studio user-specific files. -*.suo -*.user -*.userosscache -*.sln.docstates - -# Visual Studio build-related files. -x64/ -x86/ - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt deleted file mode 100644 index 08297b84..00000000 --- a/windows/CMakeLists.txt +++ /dev/null @@ -1,69 +0,0 @@ -# The Flutter tooling requires that developers have a version of Visual Studio -# installed that includes CMake 3.14 or later. You should not increase this -# version, as doing so will cause the plugin to fail to compile for some -# customers of the plugin. -cmake_minimum_required(VERSION 3.14) - -# Project-level configuration. -set(PROJECT_NAME "flutter_libmwc") -project(${PROJECT_NAME} LANGUAGES CXX) - -# This value is used when generating builds using this plugin, so it must -# not be changed -set(PLUGIN_NAME "flutter_libmwc_plugin") - -# Any new source files that you add to the plugin should be added here. -list(APPEND PLUGIN_SOURCES - "flutter_libmwc_plugin.cpp" - "flutter_libmwc_plugin.h" -) - -# Define the plugin library target. Its name must not be changed (see comment -# on PLUGIN_NAME above). -add_library(${PLUGIN_NAME} SHARED - "include/flutter_libmwc/flutter_libmwc_plugin_c_api.h" - "flutter_libmwc_plugin_c_api.cpp" - ${PLUGIN_SOURCES} -) - -# Ensure .lib file is generated alongside .dll -set_target_properties(${PLUGIN_NAME} PROPERTIES - WINDOWS_EXPORT_ALL_SYMBOLS ON -) - -# Apply a standard set of build settings that are configured in the -# application-level CMakeLists.txt. This can be removed for plugins that want -# full control over build settings. -apply_standard_settings(${PLUGIN_NAME}) - -# Symbols are hidden by default to reduce the chance of accidental conflicts -# between plugins. This should not be removed; any symbols that should be -# exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro. -set_target_properties(${PLUGIN_NAME} PROPERTIES - CXX_VISIBILITY_PRESET hidden) -target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) - -# Source include directories and library dependencies. Add any plugin-specific -# dependencies here. -target_include_directories(${PLUGIN_NAME} INTERFACE - "${CMAKE_CURRENT_SOURCE_DIR}/include") -target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) - -set(MY_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/windows/build") - -# List of absolute paths to libraries that should be bundled with the plugin. -# This list could contain prebuilt libraries, or libraries created by an -# external build triggered from this build file. -if (EXISTS "${MY_BUILD_DIR}/libstdc++-6.dll") - set(flutter_libmwc_bundled_libraries - "" - "${MY_BUILD_DIR}/libstdc++-6.dll" - "${MY_BUILD_DIR}/libgcc_s_seh-1.dll" - PARENT_SCOPE - ) -else () - set(flutter_libmwc_bundled_libraries - "" - PARENT_SCOPE - ) -endif () diff --git a/windows/flutter_libmwc_plugin.cpp b/windows/flutter_libmwc_plugin.cpp deleted file mode 100644 index ec2e078b..00000000 --- a/windows/flutter_libmwc_plugin.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "flutter_libmwc_plugin.h" - -// This must be included before many other Windows headers. -#include - -// For getPlatformVersion; remove unless needed for your plugin implementation. -#include - -#include -#include -#include - -#include -#include - -namespace flutter_libmwc { - -// static -void FlutterLibmwcPlugin::RegisterWithRegistrar( - flutter::PluginRegistrarWindows *registrar) { - auto channel = - std::make_unique>( - registrar->messenger(), "flutter_libmwc", - &flutter::StandardMethodCodec::GetInstance()); - - auto plugin = std::make_unique(); - - channel->SetMethodCallHandler( - [plugin_pointer = plugin.get()](const auto &call, auto result) { - plugin_pointer->HandleMethodCall(call, std::move(result)); - }); - - registrar->AddPlugin(std::move(plugin)); -} - -FlutterLibmwcPlugin::FlutterLibmwcPlugin() {} - -FlutterLibmwcPlugin::~FlutterLibmwcPlugin() {} - -void FlutterLibmwcPlugin::HandleMethodCall( - const flutter::MethodCall &method_call, - std::unique_ptr> result) { - if (method_call.method_name().compare("getPlatformVersion") == 0) { - std::ostringstream version_stream; - version_stream << "Windows "; - if (IsWindows10OrGreater()) { - version_stream << "10+"; - } else if (IsWindows8OrGreater()) { - version_stream << "8"; - } else if (IsWindows7OrGreater()) { - version_stream << "7"; - } - result->Success(flutter::EncodableValue(version_stream.str())); - } else { - result->NotImplemented(); - } -} - -} // namespace flutter_libmwc diff --git a/windows/flutter_libmwc_plugin.h b/windows/flutter_libmwc_plugin.h deleted file mode 100644 index 32bd296c..00000000 --- a/windows/flutter_libmwc_plugin.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef FLUTTER_PLUGIN_FLUTTER_LIBMWC_PLUGIN_H_ -#define FLUTTER_PLUGIN_FLUTTER_LIBMWC_PLUGIN_H_ - -#include -#include - -#include - -namespace flutter_libmwc { - -class FlutterLibmwcPlugin : public flutter::Plugin { - public: - static void RegisterWithRegistrar(flutter::PluginRegistrarWindows *registrar); - - FlutterLibmwcPlugin(); - - virtual ~FlutterLibmwcPlugin(); - - // Disallow copy and assign. - FlutterLibmwcPlugin(const FlutterLibmwcPlugin&) = delete; - FlutterLibmwcPlugin& operator=(const FlutterLibmwcPlugin&) = delete; - - private: - // Called when a method is called on this plugin's channel from Dart. - void HandleMethodCall( - const flutter::MethodCall &method_call, - std::unique_ptr> result); -}; - -} // namespace flutter_libmwc - -#endif // FLUTTER_PLUGIN_FLUTTER_LIBmwc_PLUGIN_H_ diff --git a/windows/flutter_libmwc_plugin_c_api.cpp b/windows/flutter_libmwc_plugin_c_api.cpp deleted file mode 100644 index 52d86274..00000000 --- a/windows/flutter_libmwc_plugin_c_api.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "include/flutter_libmwc/flutter_libmwc_plugin_c_api.h" - -#include - -#include "flutter_libmwc_plugin.h" - -void FlutterLibmwcPluginCApiRegisterWithRegistrar( - FlutterDesktopPluginRegistrarRef registrar) { - flutter_libmwc::FlutterLibmwcPlugin::RegisterWithRegistrar( - flutter::PluginRegistrarManager::GetInstance() - ->GetRegistrar(registrar)); -} diff --git a/windows/include/flutter_libmwc/flutter_libmwc_plugin_c_api.h b/windows/include/flutter_libmwc/flutter_libmwc_plugin_c_api.h deleted file mode 100644 index 66359601..00000000 --- a/windows/include/flutter_libmwc/flutter_libmwc_plugin_c_api.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef FLUTTER_PLUGIN_FLUTTER_LIBMWC_PLUGIN_C_API_H_ -#define FLUTTER_PLUGIN_FLUTTER_LIBMWC_PLUGIN_C_API_H_ - -#include - -#ifdef FLUTTER_PLUGIN_IMPL -#define FLUTTER_PLUGIN_EXPORT __declspec(dllexport) -#else -#define FLUTTER_PLUGIN_EXPORT __declspec(dllimport) -#endif - -#if defined(__cplusplus) -extern "C" { -#endif - -FLUTTER_PLUGIN_EXPORT void FlutterLibmwcPluginCApiRegisterWithRegistrar( - FlutterDesktopPluginRegistrarRef registrar); - -#if defined(__cplusplus) -} // extern "C" -#endif - -#endif // FLUTTER_PLUGIN_FLUTTER_LIBMWC_PLUGIN_C_API_H_ From 2da8927a21bcfaedf8f5e49db3689287bb772a3e Mon Sep 17 00:00:00 2001 From: sneurlax Date: Thu, 10 Sep 2026 15:38:35 -0500 Subject: [PATCH 2/6] fix: stop logging raw transaction slates --- lib/lib.dart | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/lib/lib.dart b/lib/lib.dart index 1893a0ba..ceaca44e 100644 --- a/lib/lib.dart +++ b/lib/lib.dart @@ -714,11 +714,6 @@ abstract class Libmwc { return await m.protect(() async { try { final String result = lib_mwc.txReceive(wallet, slateJson); - // Debug logging for shape inspection - // ignore: avoid_print - final _rlen = result.length; - final _rprefix = result.substring(0, _rlen > 512 ? 512 : _rlen); - print('[WALLET][DEBUG] txReceive raw result: ' + _rprefix + (_rlen > 512 ? '…' : '')); if (result.toUpperCase().contains("ERROR")) { throw Exception("Error receiving transaction $result"); } @@ -726,27 +721,17 @@ abstract class Libmwc { // Robustly extract the updated slate JSON from the nested tuple. final outer = jsonDecode(result); if (outer is! List || outer.isEmpty) { - // ignore: avoid_print - print('[WALLET][DEBUG] Unexpected receive result shape: ' + result); throw Exception('Unexpected receive result shape'); } final first = outer[0]; if (first == null || first is! String) { - // ignore: avoid_print - print('[WALLET][DEBUG] Unexpected inner type: ' + first.toString()); throw Exception('Unexpected receive tuple inner type'); } final inner = jsonDecode(first); if (inner is! List || inner.length < 2 || inner[1] == null || inner[1] is! String) { - // ignore: avoid_print - print('[WALLET][DEBUG] Unexpected inner pair: ' + inner.toString()); throw Exception('Unexpected receive inner pair shape'); } final updatedSlateJson = inner[1] as String; - // ignore: avoid_print - final _ulen = updatedSlateJson.length; - final _uprefix = updatedSlateJson.substring(0, _ulen > 256 ? 256 : _ulen); - print('[WALLET][DEBUG] Updated slate json (prefix): ' + _uprefix + (_ulen > 256 ? '…' : '')); final updatedSlate = jsonDecode(updatedSlateJson); final List outputs = @@ -775,10 +760,6 @@ abstract class Libmwc { return await m.protect(() async { try { final String result = lib_mwc.txReceive(wallet, slateJson); - // ignore: avoid_print - final _r2len = result.length; - final _r2prefix = result.substring(0, _r2len > 512 ? 512 : _r2len); - print('[WALLET][DEBUG] txReceiveDetailed raw result: ' + _r2prefix + (_r2len > 512 ? '…' : '')); if (result.toUpperCase().contains("ERROR")) { throw Exception("Error receiving transaction $result"); } @@ -787,17 +768,9 @@ abstract class Libmwc { // where json_pair is a JSON-encoded array: [ txs_json, updated_slate_json ] final outer = jsonDecode(result); final jsonPairEncoded = outer[0] as String; - // ignore: avoid_print - final _jlen = jsonPairEncoded.length; - final _jprefix = jsonPairEncoded.substring(0, _jlen > 256 ? 256 : _jlen); - print('[WALLET][DEBUG] jsonPairEncoded (prefix): ' + _jprefix + (_jlen > 256 ? '…' : '')); final pair = jsonDecode(jsonPairEncoded); // Extract updated slate JSON (second element) final updatedSlateJson = pair[1] as String; - // ignore: avoid_print - final _ul2 = updatedSlateJson.length; - final _up2 = updatedSlateJson.substring(0, _ul2 > 256 ? 256 : _ul2); - print('[WALLET][DEBUG] updatedSlateJson (prefix): ' + _up2 + (_ul2 > 256 ? '…' : '')); // Parse to fetch ids for convenience from the updated slate final updatedSlate = jsonDecode(updatedSlateJson); From 99f2c3a1aac81ebbea4ff9d8999848aa6464449f Mon Sep 17 00:00:00 2001 From: sneurlax Date: Thu, 10 Sep 2026 15:38:55 -0500 Subject: [PATCH 3/6] fix: remove unused patches that destabilize Cargo.lock --- rust/Cargo.lock | 15 --------------- rust/Cargo.toml | 5 ----- 2 files changed, 20 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 5201f599..b44bcf43 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -7581,18 +7581,3 @@ dependencies = [ "crc32fast", "thiserror", ] - -[[patch.unused]] -name = "mwc_config" -version = "5.3.7" -source = "git+https://github.com/cypherstack/mwc-node?tag=5.3.7#0dae1d5a4a1a8665bad432f774ca0f0f5277ec7e" - -[[patch.unused]] -name = "mwc_servers" -version = "5.3.7" -source = "git+https://github.com/cypherstack/mwc-node?tag=5.3.7#0dae1d5a4a1a8665bad432f774ca0f0f5277ec7e" - -[[patch.unused]] -name = "mwc-bitcoin" -version = "0.26.0" -source = "git+https://github.com/cypherstack/rust-bitcoin#e3ca094ce0f130f06014d3895d0b4c4249400f63" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index c6156e04..831c02ff 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -65,9 +65,6 @@ mwc-wagyu-ethereum = { git = "https://github.com/cypherstack/wagyu-ethereum" } [patch."https://github.com/mwcproject/rust-bch"] mwc-bch = { git = "https://github.com/cypherstack/rust-bch" } -[patch."https://github.com/mwcproject/rust-bitcoin"] -mwc-bitcoin = { git = "https://github.com/cypherstack/rust-bitcoin" } - [patch."https://github.com/mwcproject/wagyu-model"] mwc-wagyu-model = { git = "https://github.com/cypherstack/wagyu-model" } @@ -85,6 +82,4 @@ mwc_keychain = { git = "https://github.com/cypherstack/mwc-node", subdir = "keyc mwc_p2p = { git = "https://github.com/cypherstack/mwc-node", subdir = "p2p", tag = "5.3.7", features = ["libp2p"] } mwc_store = { git = "https://github.com/cypherstack/mwc-node", subdir = "store", tag = "5.3.7" } mwc_util = { git = "https://github.com/cypherstack/mwc-node", subdir = "util", tag = "5.3.7" } -mwc_config = { git = "https://github.com/cypherstack/mwc-node", subdir = "config", tag = "5.3.7" } mwc_pool = { git = "https://github.com/cypherstack/mwc-node", subdir = "pool", tag = "5.3.7" } -mwc_servers = { git = "https://github.com/cypherstack/mwc-node", subdir = "servers", tag = "5.3.7" } \ No newline at end of file From 0b7af23a96087657a825c39947bcb7de2d5c7b91 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Thu, 10 Sep 2026 15:44:46 -0500 Subject: [PATCH 4/6] fix: release Rust wallet strings through the native asset --- lib/mwc.dart | 30 +++++++++++++++++------------- rust/src/lib.rs | 9 +++------ rust/src/strings.rs | 33 +++++++++++++++++++++++++++++++++ test/native_assets_test.dart | 23 +++++++++++++++++++++++ 4 files changed, 76 insertions(+), 19 deletions(-) create mode 100644 rust/src/strings.rs diff --git a/lib/mwc.dart b/lib/mwc.dart index 0a3a33fd..49abbef0 100644 --- a/lib/mwc.dart +++ b/lib/mwc.dart @@ -320,20 +320,24 @@ external Pointer _openWallet( Pointer password, ); -String openWallet(String config, String password) { - final configPointer = config.toNativeUtf8(); - final passwordPointer = password.toNativeUtf8(); - - final handlePointer = _openWallet(configPointer, passwordPointer); - malloc.free(configPointer); - malloc.free(passwordPointer); - - if (handlePointer == nullptr) { - throw Exception("Failed to open wallet: Received null pointer from rust!"); - } +@Native)>(symbol: 'mwc_string_free') +external void _freeWalletString(Pointer value); - final handle = handlePointer.toDartString().trim(); - malloc.free(handlePointer); +String openWallet(String config, String password) { + final handle = using((arena) { + final handlePointer = _openWallet( + config.toNativeUtf8(allocator: arena), + password.toNativeUtf8(allocator: arena), + ); + if (handlePointer == nullptr) { + throw Exception("Failed to open wallet: Received null pointer from rust!"); + } + try { + return handlePointer.toDartString().trim(); + } finally { + _freeWalletString(handlePointer); + } + }); if (handle.startsWith("[") && handle.endsWith("]")) { final parts = handle.split(","); diff --git a/rust/src/lib.rs b/rust/src/lib.rs index d72173e0..a0b92365 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -35,6 +35,7 @@ use android_logger::FilterBuilder; use mwc_wallet_impls::Subscriber; mod slatepack; +mod strings; /// Fix slate for MWCQT compatibility by ensuring proper version and TTL settings. /// This function modifies the slate JSON to: @@ -340,9 +341,7 @@ pub unsafe extern "C" fn mwc_rust_open_wallet( }, Err(e ) => { let error_msg = format!("Error {}", &e.to_string()); let error_msg_ptr = CString::new(error_msg).unwrap(); - let ptr = error_msg_ptr.as_ptr(); // Get a pointer to the underlaying memory for s - std::mem::forget(error_msg_ptr); - ptr + error_msg_ptr.into_raw() } }; result @@ -374,9 +373,7 @@ fn _open_wallet( }; let s = CString::new(result).unwrap(); - let p = s.as_ptr(); // Get a pointer to the underlaying memory for s - std::mem::forget(s); // Give up the responsibility of cleaning up/freeing s - Ok(p) + Ok(s.into_raw()) } diff --git a/rust/src/strings.rs b/rust/src/strings.rs new file mode 100644 index 00000000..1c1e1deb --- /dev/null +++ b/rust/src/strings.rs @@ -0,0 +1,33 @@ +use std::ffi::CString; +use std::os::raw::c_char; + +/// Release the string returned by `mwc_rust_open_wallet`, including errors. +/// +/// # Safety +/// `value` must be null or an unmodified pointer returned by that function. +/// A non-null pointer must be released exactly once and never used afterwards. +/// This frees the serialized string, not the wallet it describes. +#[no_mangle] +pub unsafe extern "C" fn mwc_string_free(value: *mut c_char) { + if !value.is_null() { + drop(CString::from_raw(value)); + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn releases_empty_unicode_and_large_strings() { + for text in [String::new(), "wallet é 🔑".to_string(), "x".repeat(65536)] { + let value = CString::new(text).unwrap().into_raw(); + unsafe { mwc_string_free(value) }; + } + } + + #[test] + fn accepts_null() { + unsafe { mwc_string_free(std::ptr::null_mut()) }; + } +} diff --git a/test/native_assets_test.dart b/test/native_assets_test.dart index f88d22e7..41db5e76 100644 --- a/test/native_assets_test.dart +++ b/test/native_assets_test.dart @@ -1,8 +1,31 @@ import 'package:flutter_libmwc/mwc.dart'; +import 'package:flutter_libmwc/lib.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { test('calls Rust through the bundled native asset', () { expect(walletMnemonic().trim().split(RegExp(r'\s+')), hasLength(24)); }); + test('releases Rust-owned open-wallet error strings', () { + for (var i = 0; i < 100; i++) { + expect( + () => openWallet('{}', 'unused'), + throwsA( + isA().having( + (error) => error.toString(), + 'message', + contains('Unable to get wallet config'), + ), + ), + ); + } + }); + + test('resolves native assets in a compute isolate', () async { + // openWallet uses Flutter compute(), as real wallet consumers do. + await expectLater( + Libmwc.openWallet(config: '{}', password: 'unused'), + throwsA(anything), + ); + }); } From bac5839e7d0d260c7c548a32319a565432f4f5ce Mon Sep 17 00:00:00 2001 From: sneurlax Date: Thu, 10 Sep 2026 15:47:10 -0500 Subject: [PATCH 5/6] test: require the Rust error from the compute-isolate smoke test --- test/native_assets_test.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/native_assets_test.dart b/test/native_assets_test.dart index 41db5e76..2c6dad93 100644 --- a/test/native_assets_test.dart +++ b/test/native_assets_test.dart @@ -25,7 +25,13 @@ void main() { // openWallet uses Flutter compute(), as real wallet consumers do. await expectLater( Libmwc.openWallet(config: '{}', password: 'unused'), - throwsA(anything), + throwsA( + isA().having( + (error) => error.toString(), + 'message', + contains('Unable to get wallet config'), + ), + ), ); }); } From 7db71d0b457181a1d3c0d491818eb3156c2a6e99 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Thu, 10 Sep 2026 22:08:25 -0800 Subject: [PATCH 6/6] fix(windows): drop vendored OpenSSL from the Windows target Its build paths under .dart_tool exceed MAX_PATH, breaking every Windows build. openssl is unused here and has no other Windows consumer (native-tls uses SChannel); other targets are unchanged. The hook now fails fast on Windows to Unix cross-compiles, which OpenSSL's Configure rejects anyway. --- README.md | 2 +- hook/build.dart | 8 ++++++++ rust/Cargo.toml | 8 +++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3de1ad7c..1a31294b 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ symbols using `@Native`. No manual library copying or build scripts are needed. Install the native build tools required by the Rust dependencies: a C/C++ compiler, CMake, libclang, pkg-config, Perl (for vendored OpenSSL), and `protoc`. Use Xcode for Apple targets, Android SDK/NDK r27+ for Android, and Visual Studio's -Desktop development with C++ workload and NASM for Windows (MSVC). +Desktop development with C++ workload for Windows (MSVC). ```sh flutter pub get diff --git a/hook/build.dart b/hook/build.dart index da29be2b..e365d1d2 100644 --- a/hook/build.dart +++ b/hook/build.dart @@ -9,6 +9,14 @@ void main(List args) async { if (!input.config.buildCodeAssets) return; final code = input.config.code; + + // OpenSSL refuses to build for a non-Windows target using Windows' perl. + if (Platform.isWindows && code.targetOS != OS.windows) { + throw UnsupportedError( + 'Cannot build ${code.targetOS} from Windows; use Linux, macOS, or WSL.', + ); + } + final environment = { if (code.targetOS == OS.iOS) 'IPHONEOS_DEPLOYMENT_TARGET': '${code.iOS.targetVersion}.0', diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 831c02ff..63c065a7 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -18,7 +18,6 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1" serde_derive = "1" simplelog = "^0.7.4" -openssl = { version = "0.10", features = ["vendored"] } zeroize = { version = "1.1.0", features = ["derive"] } rand = "0.6" reqwest = { version = "0.11", features = ["blocking", "json"] } @@ -49,6 +48,13 @@ ffi_helpers = "0.3.0" anyhow = "1.0.69" +# We never call openssl ourselves. This makes native-tls build OpenSSL from +# source instead of looking for a system copy, which is what lets Android and +# iOS cross-compile. Windows is excluded because native-tls uses SChannel +# there, and building OpenSSL produces paths past Windows' 260-character limit. +[target.'cfg(not(target_os = "windows"))'.dependencies] +openssl = { version = "0.10", features = ["vendored"] } + [lib] name = "mwc_wallet" crate-type = ["staticlib", "cdylib"]