├── packages ├── flutter_fuels │ ├── ios │ │ ├── Frameworks │ │ │ └── .gitkeep │ │ ├── .gitignore │ │ ├── Classes │ │ │ ├── EnforceBundling.swift │ │ │ └── flutter_fuels.c │ │ └── flutter_fuels.podspec │ ├── macos │ │ ├── Frameworks │ │ │ └── .gitkeep │ │ ├── .gitignore │ │ ├── Classes │ │ │ ├── EnforceBundling.swift │ │ │ └── flutter_fuels.c │ │ └── flutter_fuels.podspec │ ├── example │ │ ├── linux │ │ │ ├── .gitignore │ │ │ ├── main.cc │ │ │ ├── flutter │ │ │ │ ├── generated_plugin_registrant.cc │ │ │ │ ├── generated_plugin_registrant.h │ │ │ │ ├── generated_plugins.cmake │ │ │ │ └── CMakeLists.txt │ │ │ ├── my_application.h │ │ │ └── my_application.cc │ │ ├── ios │ │ │ ├── Runner │ │ │ │ ├── Runner-Bridging-Header.h │ │ │ │ ├── Assets.xcassets │ │ │ │ │ ├── LaunchImage.imageset │ │ │ │ │ │ ├── LaunchImage.png │ │ │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ │ │ ├── README.md │ │ │ │ │ │ └── Contents.json │ │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ │ │ │ └── Contents.json │ │ │ │ ├── AppDelegate.swift │ │ │ │ ├── Base.lproj │ │ │ │ │ ├── Main.storyboard │ │ │ │ │ └── LaunchScreen.storyboard │ │ │ │ └── Info.plist │ │ │ ├── Flutter │ │ │ │ ├── Debug.xcconfig │ │ │ │ ├── Release.xcconfig │ │ │ │ └── AppFrameworkInfo.plist │ │ │ ├── Runner.xcodeproj │ │ │ │ ├── project.xcworkspace │ │ │ │ │ ├── contents.xcworkspacedata │ │ │ │ │ └── xcshareddata │ │ │ │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ │ └── xcshareddata │ │ │ │ │ └── xcschemes │ │ │ │ │ └── Runner.xcscheme │ │ │ ├── Runner.xcworkspace │ │ │ │ ├── contents.xcworkspacedata │ │ │ │ └── xcshareddata │ │ │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ ├── Podfile.lock │ │ │ ├── .gitignore │ │ │ └── Podfile │ │ ├── web │ │ │ ├── favicon.png │ │ │ ├── icons │ │ │ │ ├── Icon-192.png │ │ │ │ ├── Icon-512.png │ │ │ │ ├── Icon-maskable-192.png │ │ │ │ └── Icon-maskable-512.png │ │ │ ├── manifest.json │ │ │ └── index.html │ │ ├── android │ │ │ ├── gradle.properties │ │ │ ├── app │ │ │ │ ├── src │ │ │ │ │ ├── main │ │ │ │ │ │ ├── res │ │ │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ │ ├── drawable │ │ │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ │ │ ├── drawable-v21 │ │ │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ │ │ ├── values │ │ │ │ │ │ │ │ └── styles.xml │ │ │ │ │ │ │ └── values-night │ │ │ │ │ │ │ │ └── styles.xml │ │ │ │ │ │ ├── kotlin │ │ │ │ │ │ │ └── com │ │ │ │ │ │ │ │ └── fuelet │ │ │ │ │ │ │ │ └── flutter_fuels_example │ │ │ │ │ │ │ │ └── MainActivity.kt │ │ │ │ │ │ └── AndroidManifest.xml │ │ │ │ │ ├── debug │ │ │ │ │ │ └── AndroidManifest.xml │ │ │ │ │ └── profile │ │ │ │ │ │ └── AndroidManifest.xml │ │ │ │ └── build.gradle │ │ │ ├── gradle │ │ │ │ └── wrapper │ │ │ │ │ └── gradle-wrapper.properties │ │ │ ├── .gitignore │ │ │ ├── settings.gradle │ │ │ └── build.gradle │ │ ├── macos │ │ │ ├── Runner │ │ │ │ ├── Configs │ │ │ │ │ ├── Debug.xcconfig │ │ │ │ │ ├── Release.xcconfig │ │ │ │ │ ├── Warnings.xcconfig │ │ │ │ │ └── AppInfo.xcconfig │ │ │ │ ├── Assets.xcassets │ │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ │ ├── app_icon_128.png │ │ │ │ │ │ ├── app_icon_16.png │ │ │ │ │ │ ├── app_icon_256.png │ │ │ │ │ │ ├── app_icon_32.png │ │ │ │ │ │ ├── app_icon_512.png │ │ │ │ │ │ ├── app_icon_64.png │ │ │ │ │ │ ├── app_icon_1024.png │ │ │ │ │ │ └── Contents.json │ │ │ │ ├── AppDelegate.swift │ │ │ │ ├── Release.entitlements │ │ │ │ ├── DebugProfile.entitlements │ │ │ │ ├── MainFlutterWindow.swift │ │ │ │ └── Info.plist │ │ │ ├── .gitignore │ │ │ ├── Flutter │ │ │ │ ├── Flutter-Debug.xcconfig │ │ │ │ ├── Flutter-Release.xcconfig │ │ │ │ └── GeneratedPluginRegistrant.swift │ │ │ ├── Runner.xcworkspace │ │ │ │ ├── contents.xcworkspacedata │ │ │ │ └── xcshareddata │ │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ ├── Runner.xcodeproj │ │ │ │ ├── project.xcworkspace │ │ │ │ │ └── xcshareddata │ │ │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ │ └── xcshareddata │ │ │ │ │ └── xcschemes │ │ │ │ │ └── Runner.xcscheme │ │ │ └── Podfile │ │ ├── windows │ │ │ ├── runner │ │ │ │ ├── resources │ │ │ │ │ └── app_icon.ico │ │ │ │ ├── resource.h │ │ │ │ ├── utils.h │ │ │ │ ├── runner.exe.manifest │ │ │ │ ├── flutter_window.h │ │ │ │ ├── main.cpp │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── utils.cpp │ │ │ │ ├── flutter_window.cpp │ │ │ │ ├── Runner.rc │ │ │ │ └── win32_window.h │ │ │ ├── flutter │ │ │ │ ├── generated_plugin_registrant.cc │ │ │ │ ├── generated_plugin_registrant.h │ │ │ │ ├── generated_plugins.cmake │ │ │ │ └── CMakeLists.txt │ │ │ ├── .gitignore │ │ │ └── CMakeLists.txt │ │ ├── pubspec.yaml │ │ ├── README.md │ │ ├── .gitignore │ │ ├── .metadata │ │ └── analysis_options.yaml │ ├── android │ │ ├── src │ │ │ └── main │ │ │ │ └── AndroidManifest.xml │ │ ├── .gitignore │ │ ├── settings.gradle │ │ ├── build.gradle │ │ └── CMakeLists.txt │ ├── analysis_options.yaml │ ├── lib │ │ ├── utils │ │ │ ├── json_utils.dart │ │ │ ├── mnemonic_utils.dart │ │ │ └── hex_utils.dart │ │ ├── model │ │ │ ├── witness.dart │ │ │ ├── storage_slot.dart │ │ │ ├── tx_pointer.dart │ │ │ ├── utxo_id.dart │ │ │ ├── transaction_cost.dart │ │ │ ├── call_result.dart │ │ │ ├── fuel_address.dart │ │ │ ├── input.dart │ │ │ ├── transaction.dart │ │ │ └── output.dart │ │ ├── flutter_fuels.dart │ │ ├── fuel_utils │ │ │ ├── platform_impl │ │ │ │ ├── js_interop │ │ │ │ │ └── js_fuels_utils.dart │ │ │ │ ├── base_fuel_utils.dart │ │ │ │ ├── stub_fuel_utils.dart │ │ │ │ └── web_fuel_utils.dart │ │ │ └── fuel_utils.dart │ │ ├── js_wallet_injector.dart │ │ ├── wallet │ │ │ ├── platform_impl │ │ │ │ ├── base_wallet.dart │ │ │ │ ├── stub_wallet.dart │ │ │ │ └── js_interop │ │ │ │ │ └── js_fuels_wallet.dart │ │ │ └── dart_wallet_unlocked.dart │ │ ├── js │ │ │ └── wallet.js.LICENSE.txt │ │ ├── ffi │ │ │ └── mobile_wrapper.dart │ │ └── flutter_fuels_bindings_generated.dart │ ├── web │ │ ├── tsconfig.json │ │ ├── package.json │ │ └── webpack │ │ │ └── webpack.config.js │ ├── windows │ │ ├── .gitignore │ │ └── CMakeLists.txt │ ├── src │ │ ├── CMakeLists.txt │ │ ├── flutter_fuels.c │ │ └── flutter_fuels.h │ ├── ffigen.yaml │ ├── README.md │ ├── .gitignore │ ├── linux │ │ └── CMakeLists.txt │ ├── pubspec.yaml │ ├── .metadata │ └── test │ │ ├── fuel_utils │ │ └── fuel_utils_test.dart │ │ └── model │ │ └── fuel_address_test.dart └── fuels │ ├── lib │ ├── src │ │ └── fuels_base.dart │ └── fuels.dart │ ├── native │ ├── .gitignore │ ├── src │ │ ├── features.rs │ │ ├── model.rs │ │ ├── model │ │ │ ├── error.rs │ │ │ ├── witness.rs │ │ │ ├── output.rs │ │ │ ├── input.rs │ │ │ └── receipt.rs │ │ ├── lib.rs │ │ ├── features │ │ │ ├── crypto.rs │ │ │ └── wallet.rs │ │ └── api.rs │ └── Cargo.toml │ ├── analysis_options.yaml │ ├── .gitignore │ ├── README.md │ ├── pubspec.yaml │ ├── test │ ├── features │ │ ├── crypto_test.dart │ │ ├── transaction_test.dart │ │ └── wallet_test.dart │ └── test_utils.dart │ └── justfile ├── rust-toolchain.toml ├── Cargo.toml ├── .fvm └── fvm_config.json ├── pubspec.yaml ├── scripts ├── build-web.sh ├── version.sh ├── build-android.sh └── build-apple.sh ├── .github ├── workflows │ ├── publish-fuels-release.yml │ ├── publish-flutter_fuels-release.yml │ ├── publish-pub-dev-release.yml │ ├── create-release.yml │ ├── run_codegen.yml │ └── publish-github-release.yml └── actions │ ├── extract_package_version │ └── action.yaml │ └── initialize │ └── action.yaml ├── .cargo └── config.toml ├── .gitignore ├── melos.yaml ├── README.md └── analysis_options.yaml /packages/flutter_fuels/ios/Frameworks/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/flutter_fuels/macos/Frameworks/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "1.90.0" 3 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /packages/fuels/lib/src/fuels_base.dart: -------------------------------------------------------------------------------- 1 | export 'bridge_generated.dart'; 2 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = ["packages/fuels/native"] 4 | -------------------------------------------------------------------------------- /packages/fuels/native/.gitignore: -------------------------------------------------------------------------------- 1 | # Rust library related 2 | Cargo.lock 3 | target 4 | -------------------------------------------------------------------------------- /.fvm/fvm_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "flutterSdkVersion": "3.19.6", 3 | "flavors": {} 4 | } 5 | -------------------------------------------------------------------------------- /packages/flutter_fuels/macos/.gitignore: -------------------------------------------------------------------------------- 1 | Flutter/ 2 | Frameworks/* 3 | !Frameworks/.gitkeep 4 | -------------------------------------------------------------------------------- /packages/fuels/native/src/features.rs: -------------------------------------------------------------------------------- 1 | pub mod wallet; 2 | pub mod crypto; 3 | pub mod transaction; 4 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /packages/flutter_fuels/ios/.gitignore: -------------------------------------------------------------------------------- 1 | Flutter/ 2 | Runner/ 3 | Frameworks/* 4 | !Frameworks/.gitkeep 5 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: fuels_dart 2 | 3 | environment: 4 | sdk: '>=2.18.2 <4.0.0' 5 | 6 | dependencies: 7 | melos: ^6.2.0 8 | -------------------------------------------------------------------------------- /packages/fuels/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: ../../analysis_options.yaml 2 | 3 | analyzer: 4 | exclude: 5 | - '**/bridge_generated.*' -------------------------------------------------------------------------------- /packages/flutter_fuels/example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/web/favicon.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /packages/fuels/native/src/model.rs: -------------------------------------------------------------------------------- 1 | pub mod transaction; 2 | pub mod error; 3 | pub mod receipt; 4 | pub mod input; 5 | pub mod output; 6 | pub mod witness; 7 | -------------------------------------------------------------------------------- /scripts/build-web.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | npm --prefix packages/flutter_fuels/web install 6 | npm --prefix packages/flutter_fuels/web run build 7 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/fuels/lib/fuels.dart: -------------------------------------------------------------------------------- 1 | /// Support for doing something awesome. 2 | /// 3 | /// More dartdocs go here. 4 | library fuels; 5 | 6 | export 'src/fuels_base.dart'; 7 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /packages/flutter_fuels/android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/flutter_fuels/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | # Additional information about this file can be found at 4 | # https://dart.dev/guides/language/analysis-options -------------------------------------------------------------------------------- /packages/fuels/native/src/model/error.rs: -------------------------------------------------------------------------------- 1 | use std::error::Error; 2 | 3 | /// Result with error which can hold any type that implements the Error trait 4 | pub type CustomResult = Result>; 5 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/utils/json_utils.dart: -------------------------------------------------------------------------------- 1 | BigInt parseBigInt(String bn) { 2 | String withoutPrefix = bn.startsWith('0x') ? bn.substring(2) : bn; 3 | return BigInt.parse(withoutPrefix, radix: 16); 4 | } 5 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/flutter_fuels/ios/Classes/EnforceBundling.swift: -------------------------------------------------------------------------------- 1 | public func dummyMethodToEnforceBundling() -> Int64 { 2 | return dummy_method_to_enforce_bundling() 3 | } 4 | let dummyVar = dummyMethodToEnforceBundling(); 5 | -------------------------------------------------------------------------------- /packages/flutter_fuels/ios/Classes/flutter_fuels.c: -------------------------------------------------------------------------------- 1 | // Relative import to be able to reuse the C sources. 2 | // See the comment in ../{projectName}}.podspec for more information. 3 | #include "../../src/flutter_fuels.c" 4 | -------------------------------------------------------------------------------- /packages/flutter_fuels/macos/Classes/EnforceBundling.swift: -------------------------------------------------------------------------------- 1 | public func dummyMethodToEnforceBundling() -> Int64 { 2 | return dummy_method_to_enforce_bundling() 3 | } 4 | let dummyVar = dummyMethodToEnforceBundling(); 5 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/flutter_fuels/macos/Classes/flutter_fuels.c: -------------------------------------------------------------------------------- 1 | // Relative import to be able to reuse the C sources. 2 | // See the comment in ../{projectName}}.podspec for more information. 3 | #include "../../src/flutter_fuels.c" 4 | -------------------------------------------------------------------------------- /packages/fuels/native/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod bridge_generated; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */ 2 | mod api; 3 | mod model; 4 | mod features; 5 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuelet/fuels-dart/HEAD/packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /packages/flutter_fuels/android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .cxx 10 | 11 | # Ignore Rust binaries 12 | src/main/jniLibs/ 13 | *.tar.gz 14 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/android/app/src/main/kotlin/com/fuelet/flutter_fuels_example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.fuelet.flutter_fuels_example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | 9 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 10 | } 11 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/model/witness.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | class Witness { 4 | final String data; 5 | 6 | const Witness({required this.data}); 7 | 8 | factory Witness.fromJson(Map data) { 9 | return Witness(data: data['data']); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void fl_register_plugins(FlPluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void RegisterPlugins(flutter::PluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip 6 | -------------------------------------------------------------------------------- /packages/fuels/native/src/model/witness.rs: -------------------------------------------------------------------------------- 1 | pub struct Witness { 2 | pub data: Vec, 3 | } 4 | 5 | impl From<&fuel_tx::Witness> for Witness { 6 | fn from(model: &fuel_tx::Witness) -> Self { 7 | Witness { 8 | data: model.as_vec().clone(), 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/fuels/.gitignore: -------------------------------------------------------------------------------- 1 | # Files and directories created by pub. 2 | .dart_tool/ 3 | .packages 4 | 5 | # Conventional directory for build outputs. 6 | build/ 7 | 8 | # Omit committing pubspec.lock for library packages; see 9 | # https://dart.dev/guides/libraries/private-files#pubspeclock. 10 | pubspec.lock 11 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/utils/mnemonic_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:bip39_mnemonic/bip39_mnemonic.dart'; 2 | 3 | void validateMnemonicPhrase(String mnemonic) { 4 | // tries to construct mnemonic from sentence and throws exceptions 5 | // in case of any errors 6 | Mnemonic.fromSentence(mnemonic, Language.english); 7 | } 8 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/model/storage_slot.dart: -------------------------------------------------------------------------------- 1 | class StorageSlot { 2 | final String key; 3 | final String value; 4 | 5 | const StorageSlot({required this.key, required this.value}); 6 | 7 | factory StorageSlot.fromJson(Map data) { 8 | return StorageSlot(key: data['key'], value: data['value']); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/utils/hex_utils.dart: -------------------------------------------------------------------------------- 1 | String addHexPrefix(String hexString) { 2 | if (hexString.startsWith('0x')) { 3 | return hexString; 4 | } 5 | return '0x$hexString'; 6 | } 7 | 8 | String removeHexPrefix(String hexString) { 9 | if (hexString.startsWith('0x')) { 10 | return hexString.substring(2); 11 | } 12 | return hexString; 13 | } 14 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/model/tx_pointer.dart: -------------------------------------------------------------------------------- 1 | class TxPointer { 2 | final int blockHeight; 3 | final int txIndex; 4 | 5 | const TxPointer({required this.blockHeight, required this.txIndex}); 6 | 7 | factory TxPointer.fromJson(Map data) { 8 | return TxPointer( 9 | blockHeight: data['blockHeight'], txIndex: data['txIndex']); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/flutter_fuels/web/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strict": true, 4 | "module": "commonjs", 5 | "target": "es2015", 6 | "esModuleInterop": true, 7 | "sourceMap": true, 8 | "rootDir": "src", 9 | "outDir": "dist/js", 10 | "noEmitOnError": true, 11 | "typeRoots": [ 12 | "node_modules/@types" 13 | ] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/model/utxo_id.dart: -------------------------------------------------------------------------------- 1 | class UtxoId { 2 | final String transactionId; 3 | final int outputIndex; 4 | 5 | const UtxoId({required this.transactionId, required this.outputIndex}); 6 | 7 | factory UtxoId.fromJson(Map data) { 8 | return UtxoId( 9 | transactionId: data['transactionId'], outputIndex: data['outputIndex']); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/flutter_fuels/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/model/transaction_cost.dart: -------------------------------------------------------------------------------- 1 | class TransactionCost { 2 | final int fee; 3 | 4 | TransactionCost({ 5 | required this.fee, 6 | }); 7 | 8 | factory TransactionCost.fromJson(Map data) { 9 | return TransactionCost( 10 | fee: data['fee'], 11 | ); 12 | } 13 | 14 | Map toJson() => { 15 | 'fee': fee, 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /packages/flutter_fuels/android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | gradlePluginPortal() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 10 | repositories { 11 | google() 12 | mavenCentral() 13 | } 14 | } 15 | 16 | rootProject.name = "flutter_fuels" -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /.github/workflows/publish-fuels-release.yml: -------------------------------------------------------------------------------- 1 | name: Publish fuels package release 2 | 3 | on: 4 | push: 5 | tags: 6 | - "fuels-*" 7 | 8 | jobs: 9 | publish_github_release: 10 | uses: ./.github/workflows/publish-github-release.yml 11 | 12 | # publish_pub_dev_release: 13 | # needs: publish_github_release 14 | # uses: ./.github/workflows/publish-pub-dev-release.yml 15 | # with: 16 | # package_name: fuels 17 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /packages/fuels/README.md: -------------------------------------------------------------------------------- 1 | # fuels 2 | 3 | Dart SDK for Fuel. 4 | 5 | Essentially, this package is wrapper over [Rust fuels-rs SDK](https://github.com/FuelLabs/fuels-rs). 6 | 7 | For more info about SDK functionality and abilities, please check out fuels-rs SDK [documentation](https://fuellabs.github.io/fuels-rs/v0.34.0/index.html). 8 | 9 | ## Documentation 10 | Work on documentation for Dart/Flutter SDK is in progress. 11 | 12 | ## FAQ 13 | TBD -------------------------------------------------------------------------------- /.github/actions/extract_package_version/action.yaml: -------------------------------------------------------------------------------- 1 | name: Extract package version 2 | description: Extract package version from the git tag 3 | 4 | runs: 5 | using: composite 6 | steps: 7 | - name: Extract package version from the tag 8 | shell: bash 9 | run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV 10 | 11 | - name: Print the extracted version 12 | shell: bash 13 | run: echo $RELEASE_VERSION 14 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.github/workflows/publish-flutter_fuels-release.yml: -------------------------------------------------------------------------------- 1 | name: Publish flutter_fuels package release 2 | 3 | on: 4 | push: 5 | tags: 6 | - "flutter_fuels-*" 7 | 8 | jobs: 9 | publish_github_release: 10 | uses: ./.github/workflows/publish-github-release.yml 11 | 12 | # publish_pub_dev_release: 13 | # needs: publish_github_release 14 | # uses: ./.github/workflows/publish-pub-dev-release.yml 15 | # with: 16 | # package_name: flutter_fuels 17 | -------------------------------------------------------------------------------- /packages/fuels/native/src/features/crypto.rs: -------------------------------------------------------------------------------- 1 | use fuel_crypto::Message; 2 | use fuels::prelude::{Signer, Wallet}; 3 | use fuels_accounts::{signers::private_key::PrivateKeySigner, wallet::Unlocked}; 4 | 5 | use crate::model::error::CustomResult; 6 | 7 | pub async fn sign_message( 8 | wallet: &Wallet>, 9 | message: String, 10 | ) -> CustomResult { 11 | let signature = wallet.signer().sign(Message::new(message)).await?; 12 | Ok(signature.to_string()) 13 | } 14 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/model/call_result.dart: -------------------------------------------------------------------------------- 1 | import 'transaction_receipt.dart'; 2 | 3 | class CallResult { 4 | final List receipts; 5 | 6 | const CallResult({required this.receipts}); 7 | 8 | factory CallResult.fromJson(Map data) { 9 | List receiptsJsonList = data['receipts']; 10 | return CallResult( 11 | receipts: receiptsJsonList 12 | .map((e) => TransactionReceipt.fromJson(e)) 13 | .toList()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/flutter_fuels/web/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "build": "webpack --config webpack/webpack.config.js" 4 | }, 5 | "devDependencies": { 6 | "ts-loader": "^9.4.2", 7 | "typescript": "^5.6.2", 8 | "webpack": "^5.76.1", 9 | "webpack-cli": "^5.0.1" 10 | }, 11 | "dependencies": { 12 | "browserify-sign": ">=4.2.3", 13 | "fuels": "^0.101.3", 14 | "graphql": ">=16.9.0", 15 | "node-polyfill-webpack-plugin": "^2.0.1", 16 | "semver": ">=7.6.2" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/flutter_fuels.dart: -------------------------------------------------------------------------------- 1 | export 'fuel_utils/fuel_utils.dart'; 2 | 3 | // model 4 | export 'model/call_result.dart'; 5 | export 'model/fuel_address.dart'; 6 | export 'model/input.dart'; 7 | export 'model/output.dart'; 8 | export 'model/storage_slot.dart'; 9 | export 'model/transaction.dart'; 10 | export 'model/transaction_cost.dart'; 11 | export 'model/transaction_receipt.dart'; 12 | export 'model/tx_pointer.dart'; 13 | export 'model/utxo_id.dart'; 14 | export 'model/witness.dart'; 15 | export 'wallet/fuel_wallet.dart'; 16 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_fuels_example 2 | description: Demonstrates how to use the flutter_fuels plugin. 3 | 4 | publish_to: 'none' 5 | 6 | version: 1.0.0+1 7 | 8 | environment: 9 | sdk: '>=2.18.6 <3.0.0' 10 | 11 | dependencies: 12 | flutter: 13 | sdk: flutter 14 | 15 | flutter_fuels: 16 | path: ../ 17 | 18 | cupertino_icons: ^1.0.2 19 | 20 | dev_dependencies: 21 | flutter_test: 22 | sdk: flutter 23 | 24 | flutter_lints: ^2.0.0 25 | 26 | flutter: 27 | uses-material-design: true 28 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/fuel_utils/platform_impl/js_interop/js_fuels_utils.dart: -------------------------------------------------------------------------------- 1 | @JS('flutter_fuels_utils') 2 | library js_fuels_utils; 3 | 4 | import 'package:js/js.dart'; 5 | 6 | @JS('transformTxRequest') 7 | external String transformTxRequest(String transactionRequestJson); 8 | 9 | @JS('getTransactionCost') 10 | external Object getTransactionCost( 11 | String networkUrl, 12 | String transactionRequestJson, 13 | ); 14 | 15 | @JS('isUserAccount') 16 | external Object isUserAccount( 17 | String networkUrl, 18 | String address, 19 | ); 20 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/fuel_utils/platform_impl/base_fuel_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_fuels/model/transaction.dart'; 2 | import 'package:flutter_fuels/model/transaction_cost.dart'; 3 | 4 | abstract class BaseFuelUtils { 5 | Future transformTxRequest(dynamic transactionRequestHexOrJson); 6 | 7 | Future getTransactionCost( 8 | {required String networkUrl, 9 | required String transactionRequestHexOrJson}); 10 | 11 | Future isUserAccount( 12 | {required String network, required String address}); 13 | } 14 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/fuels/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: fuels 2 | description: Dart FFI bridge to Fuel Rust SDK 3 | version: 1.38.0 4 | homepage: https://github.com/Fuelet/fuels-dart/tree/main/packages/fuels 5 | 6 | environment: 7 | sdk: '>=3.0.0 <4.0.0' 8 | 9 | dependencies: 10 | ffi: ^2.0.1 11 | flutter_rust_bridge: 1.82.6 12 | uuid: ^4.2.1 # must be compatible with flutter_rust_bridge version 13 | freezed_annotation: ^2.2.0 14 | meta: ^1.8.0 15 | collection: ^1.17.0 16 | 17 | dev_dependencies: 18 | test: ^1.24.2 19 | lints: ^2.0.0 20 | ffigen: ^8.0.0 21 | freezed: ^2.3.2 22 | build_runner: ^2.3.2 23 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Flutter (1.0.0) 3 | - flutter_fuels (1.0.0) 4 | 5 | DEPENDENCIES: 6 | - Flutter (from `Flutter`) 7 | - flutter_fuels (from `.symlinks/plugins/flutter_fuels/ios`) 8 | 9 | EXTERNAL SOURCES: 10 | Flutter: 11 | :path: Flutter 12 | flutter_fuels: 13 | :path: ".symlinks/plugins/flutter_fuels/ios" 14 | 15 | SPEC CHECKSUMS: 16 | Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 17 | flutter_fuels: bf6e195e7c2bc6380a11f4d41f0aa8134238b7a8 18 | 19 | PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 20 | 21 | COCOAPODS: 1.12.1 22 | -------------------------------------------------------------------------------- /packages/flutter_fuels/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The Flutter tooling requires that developers have CMake 3.10 or later 2 | # installed. You should not increase this version, as doing so will cause 3 | # the plugin to fail to compile for some customers of the plugin. 4 | cmake_minimum_required(VERSION 3.10) 5 | 6 | project(flutter_fuels_library VERSION 0.0.1 LANGUAGES C) 7 | 8 | add_library(flutter_fuels SHARED 9 | "flutter_fuels.c" 10 | ) 11 | 12 | set_target_properties(flutter_fuels PROPERTIES 13 | PUBLIC_HEADER flutter_fuels.h 14 | OUTPUT_NAME "flutter_fuels" 15 | ) 16 | 17 | target_compile_definitions(flutter_fuels PUBLIC DART_SHARED_LIB) 18 | -------------------------------------------------------------------------------- /packages/fuels/test/features/crypto_test.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: avoid_print 2 | 3 | import 'package:fuels/fuels.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import '../test_utils.dart'; 7 | 8 | void main() { 9 | test('test signing a message', () async { 10 | WalletUnlocked testWallet = await importWalletWithPK(testWalletPrivateKey); 11 | final signature = 12 | await testWallet.signMessage(message: 'A random message to sign'); 13 | expect(signature, 14 | '3b3e392aee0f996186847194c8097481e3741a218e61cfe68f1714dd1dbe68b6d5775baf5095dba5454c6209cdca214622ba27601a82461b849f5093ec6f103f'); 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /packages/flutter_fuels/android/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.android.library" 3 | } 4 | 5 | group = "com.fuelet.flutter_fuels" 6 | version = "1.0" 7 | 8 | android { 9 | namespace = "com.fuelet.flutter_fuels" 10 | compileSdk = 35 11 | ndkVersion = "28.0.12433566" 12 | 13 | defaultConfig { 14 | minSdk = 23 15 | targetSdk = 35 16 | } 17 | 18 | compileOptions { 19 | sourceCompatibility = JavaVersion.VERSION_17 20 | targetCompatibility = JavaVersion.VERSION_17 21 | } 22 | 23 | externalNativeBuild { 24 | cmake { 25 | version "3.22.1" 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/flutter_fuels/ffigen.yaml: -------------------------------------------------------------------------------- 1 | # Run with `flutter pub run ffigen --config ffigen.yaml`. 2 | name: FlutterFuelsBindings 3 | description: | 4 | Bindings for `src/flutter_fuels.h`. 5 | 6 | Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. 7 | output: 'lib/flutter_fuels_bindings_generated.dart' 8 | headers: 9 | entry-points: 10 | - 'src/flutter_fuels.h' 11 | include-directives: 12 | - 'src/flutter_fuels.h' 13 | preamble: | 14 | // ignore_for_file: always_specify_types 15 | // ignore_for_file: camel_case_types 16 | // ignore_for_file: non_constant_identifier_names 17 | comments: 18 | style: any 19 | length: full 20 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/README.md: -------------------------------------------------------------------------------- 1 | # flutter_fuels_example 2 | 3 | Demonstrates how to use the flutter_fuels plugin. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /packages/flutter_fuels/README.md: -------------------------------------------------------------------------------- 1 | # flutter_fuels 2 | 3 | Flutter SDK for Fuel. 4 | 5 | Essentially, this Flutter plugin is a wrapper over [Dart fuels SDK](https://github.com/Fuelet/fuels-dart/tree/main/packages/fuels) which is a wrapper over [Rust fuels-rs SDK](https://github.com/FuelLabs/fuels-rs). 6 | 7 | For more info about SDK functionality and abilities, please check out fuels-rs SDK [documentation](https://fuellabs.github.io/fuels-rs/v0.34.0/index.html). 8 | 9 | ## Documentation 10 | Work on documentation for Dart/Flutter SDK is in progress. 11 | 12 | ## FAQ 13 | ### What platforms are supported? 14 | Currently, SDK supports Android and iOS/macOS platforms. Work on web support is in progress. -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/js_wallet_injector.dart: -------------------------------------------------------------------------------- 1 | @JS() 2 | library fuel_wallet; 3 | 4 | import 'dart:html'; 5 | 6 | import 'package:flutter_web_plugins/flutter_web_plugins.dart'; 7 | import 'package:js/js.dart'; 8 | 9 | class JsWalletInjector { 10 | static void registerWith(Registrar registrar) { 11 | _loadScript('assets/packages/flutter_fuels/js/wallet.js'); 12 | } 13 | 14 | static void _loadScript(String path) { 15 | // Create a new script element 16 | ScriptElement script = ScriptElement(); 17 | script.type = 'text/javascript'; 18 | script.src = path; 19 | 20 | // Add the script element to the document's head 21 | document.head!.append(script); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/wallet/platform_impl/base_wallet.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_fuels/wallet/dart_wallet_unlocked.dart'; 2 | 3 | abstract class BaseWallet { 4 | Future generateNewWallet({required String networkUrl}); 5 | 6 | Future newFromMnemonic({ 7 | required String networkUrl, 8 | required String mnemonic, 9 | }); 10 | 11 | Future newFromMnemonicAndPath( 12 | {required String networkUrl, 13 | required String mnemonic, 14 | required String derivationPath}); 15 | 16 | Future newFromPrivateKey({ 17 | required String networkUrl, 18 | required String privateKey, 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /packages/fuels/native/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fuels" 3 | version = "1.0.0" 4 | edition = "2021" 5 | 6 | [lib] 7 | crate-type = ["staticlib", "cdylib"] 8 | 9 | [build-dependencies] 10 | flutter_rust_bridge_codegen = "=1.82.6" 11 | 12 | [dependencies] 13 | fuels = "=0.75.1" 14 | fuels-accounts = "=0.75.1" # must be compatible with the fuels version 15 | fuel-crypto = { version = "0.62.0", features = ["random"] } # must be compatible with the fuels version 16 | fuel-tx = "0.62.0" # must be compatible with the fuels version 17 | tokio = { version = "1.14.0", features = ["rt-multi-thread"] } 18 | rand = { version = "0.8.4", default-features = false } 19 | flutter_rust_bridge = "=1.82.6" 20 | async-trait = "0.1.81" 21 | -------------------------------------------------------------------------------- /packages/flutter_fuels/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | /pubspec.lock 27 | **/doc/api/ 28 | .dart_tool/ 29 | .packages 30 | build/ 31 | 32 | node_modules/ 33 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = flutter_fuels_example 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.fuelet.flutterFuelsExample 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2023 com.fuelet. All rights reserved. 15 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/js/wallet.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | * The buffer module from node.js, for the browser. 3 | * 4 | * @author Feross Aboukhadijeh 5 | * @license MIT 6 | */ 7 | 8 | /*! 9 | * The buffer module from node.js, for the browser. 10 | * 11 | * @author Feross Aboukhadijeh 12 | * @license MIT 13 | */ 14 | 15 | /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ 16 | 17 | /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ 18 | 19 | /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ 20 | 21 | /*! safe-buffer. MIT License. Feross Aboukhadijeh */ 22 | -------------------------------------------------------------------------------- /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.aarch64-linux-android] 2 | # Force linker to align segments to 16 KiB pages (needed for new Android devices). 3 | rustflags = [ 4 | "-Clink-arg=-Wl,-z,common-page-size=16384", 5 | "-Clink-arg=-Wl,-z,max-page-size=16384", 6 | ] 7 | 8 | [target.armv7-linux-androideabi] 9 | rustflags = [ 10 | "-Clink-arg=-Wl,-z,common-page-size=16384", 11 | "-Clink-arg=-Wl,-z,max-page-size=16384", 12 | ] 13 | 14 | [target.x86_64-linux-android] 15 | rustflags = [ 16 | "-Clink-arg=-Wl,-z,common-page-size=16384", 17 | "-Clink-arg=-Wl,-z,max-page-size=16384", 18 | ] 19 | 20 | [target.i686-linux-android] 21 | rustflags = [ 22 | "-Clink-arg=-Wl,-z,common-page-size=16384", 23 | "-Clink-arg=-Wl,-z,max-page-size=16384", 24 | ] 25 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /.github/actions/initialize/action.yaml: -------------------------------------------------------------------------------- 1 | name: Initialize 2 | description: Common steps for initialization 3 | 4 | runs: 5 | using: composite 6 | steps: 7 | - name: Setup Flutter 8 | uses: subosito/flutter-action@v2 9 | with: 10 | flutter-version: 3.19.6 11 | 12 | - name: Setup Melos 13 | uses: bluefireteam/melos-action@v2 14 | with: 15 | melos-version: 3.1.0 16 | 17 | - name: Setup Zig 18 | uses: goto-bus-stop/setup-zig@v2 19 | 20 | - name: Install LLVM 21 | uses: KyleMayes/install-llvm-action@v1 22 | with: 23 | version: "15" 24 | 25 | - name: Setup Rust 26 | uses: dtolnay/rust-toolchain@stable 27 | with: 28 | toolchain: 1.90.0 29 | components: rustfmt 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | lcov.info 2 | 3 | # Miscellaneous 4 | *.class 5 | *.log 6 | *.pyc 7 | *.swp 8 | .DS_Store 9 | .atom/ 10 | .buildlog/ 11 | .history 12 | .svn/ 13 | 14 | # IntelliJ related 15 | *.iml 16 | *.ipr 17 | *.iws 18 | .idea/ 19 | 20 | # The .vscode folder contains launch configuration and tasks you configure in 21 | # VS Code which you may wish to be included in version control, so this line 22 | # is commented out by default. 23 | #.vscode/ 24 | 25 | # Flutter/Dart/Pub related 26 | pubspec.lock 27 | pubspec_overrides.yaml 28 | **/doc/api/ 29 | .dart_tool/ 30 | .packages 31 | build/ 32 | .pub-cache/ 33 | .pub/ 34 | .flutter-plugins 35 | .flutter-plugins-dependencies 36 | 37 | # Rust related 38 | /target/ 39 | /platform-build 40 | /llvm/ 41 | 42 | .fvm/flutter_sdk 43 | .fvmrc 44 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.6.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.1.2' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | tasks.register("clean", Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/fuel_utils/platform_impl/stub_fuel_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_fuels/model/transaction.dart'; 2 | import 'package:flutter_fuels/model/transaction_cost.dart'; 3 | 4 | import 'base_fuel_utils.dart'; 5 | 6 | class FuelUtilsImpl extends BaseFuelUtils { 7 | @override 8 | Future transformTxRequest(dynamic transactionRequestHexOrJson) { 9 | throw Exception('Stub implementation'); 10 | } 11 | 12 | @override 13 | Future getTransactionCost( 14 | {required String networkUrl, 15 | required String transactionRequestHexOrJson}) { 16 | throw Exception('Stub implementation'); 17 | } 18 | 19 | @override 20 | Future isUserAccount( 21 | {required String network, required String address}) { 22 | throw Exception('Stub implementation'); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /.github/workflows/publish-pub-dev-release.yml: -------------------------------------------------------------------------------- 1 | name: Publish pub.dev release 2 | # See https://dart.dev/tools/pub/automated-publishing 3 | 4 | on: 5 | workflow_call: 6 | inputs: 7 | package_name: 8 | description: 'Package to publish' 9 | required: true 10 | type: string 11 | 12 | jobs: 13 | publish_pub_dev_release: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v4 18 | - uses: subosito/flutter-action@v2 19 | - uses: bluefireteam/melos-action@v2 20 | with: 21 | melos-version: '3.1.0' 22 | - name: Dry-run publish to pub.dev 23 | run: melos publish -y --dry-run --no-published --scope=${{ inputs.package_name }} 24 | - name: Publish to pub.dev 25 | run: melos publish -y --no-dry-run --no-published --scope=${{ inputs.package_name }} 26 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/ffi/mobile_wrapper.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ffi'; 2 | import 'dart:io'; 3 | 4 | import 'package:fuels/fuels.dart'; 5 | 6 | typedef ExternalLibrary = DynamicLibrary; 7 | 8 | Fuels? _wrapper; 9 | const _base = 'fuels'; 10 | const _flutterLibName = 'flutter_$_base'; 11 | 12 | DynamicLibrary createLibraryImpl() { 13 | if (Platform.isIOS) { 14 | return DynamicLibrary.open('$_flutterLibName.framework/$_flutterLibName'); 15 | } 16 | if (Platform.isWindows) { 17 | return DynamicLibrary.open('$_base.dll'); 18 | } 19 | if (Platform.isMacOS) { 20 | return DynamicLibrary.executable(); 21 | } 22 | return DynamicLibrary.open('lib$_base.so'); 23 | } 24 | 25 | Fuels createWrapper(ExternalLibrary lib) { 26 | _wrapper ??= FuelsImpl(lib); 27 | return _wrapper!; 28 | } 29 | 30 | Fuels createLib() => createWrapper(createLibraryImpl()); 31 | -------------------------------------------------------------------------------- /scripts/version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CURR_VERSION=fuels-v`awk '/^version: /{print $2}' packages/fuels/pubspec.yaml` 4 | 5 | # iOS & macOS 6 | APPLE_HEADER="release_tag_name = '$CURR_VERSION' # generated; do not edit" 7 | sed -i.bak "1 s/.*/$APPLE_HEADER/" packages/flutter_fuels/ios/flutter_fuels.podspec 8 | sed -i.bak "1 s/.*/$APPLE_HEADER/" packages/flutter_fuels/macos/flutter_fuels.podspec 9 | rm packages/flutter_fuels/macos/*.bak packages/flutter_fuels/ios/*.bak 10 | 11 | # CMake platforms (Linux, Windows, and Android) 12 | CMAKE_HEADER="set(LibraryVersion \"$CURR_VERSION\") # generated; do not edit" 13 | for CMAKE_PLATFORM in android linux windows 14 | do 15 | sed -i.bak "1 s/.*/$CMAKE_HEADER/" packages/flutter_fuels/$CMAKE_PLATFORM/CMakeLists.txt 16 | rm packages/flutter_fuels/$CMAKE_PLATFORM/*.bak 17 | done 18 | 19 | git add packages/flutter_fuels/ 20 | -------------------------------------------------------------------------------- /packages/flutter_fuels/web/webpack/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const NodePolyfillPlugin = require("node-polyfill-webpack-plugin"); 3 | module.exports = { 4 | mode: "production", 5 | entry: { 6 | wallet: path.resolve(__dirname, "..", "src", "fuel_wallet.ts"), 7 | }, 8 | output: { 9 | path: path.join(__dirname, "../../lib/js"), 10 | filename: "[name].js", 11 | }, 12 | resolve: { 13 | extensions: [".ts", ".js"], 14 | }, 15 | module: { 16 | rules: [ 17 | { 18 | test: /\.tsx?$/, 19 | loader: "ts-loader", 20 | exclude: /node_modules/, 21 | options: { 22 | allowTsInNodeModules: true 23 | } 24 | }, 25 | ], 26 | }, 27 | plugins: [new NodePolyfillPlugin()], 28 | }; 29 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | flutter_fuels 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | flutter_fuels 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /packages/flutter_fuels/src/flutter_fuels.c: -------------------------------------------------------------------------------- 1 | #include "flutter_fuels.h" 2 | 3 | // A very short-lived native function. 4 | // 5 | // For very short-lived functions, it is fine to call them on the main isolate. 6 | // They will block the Dart execution while running the native function, so 7 | // only do this for native functions which are guaranteed to be short-lived. 8 | FFI_PLUGIN_EXPORT intptr_t sum(intptr_t a, intptr_t b) { return a + b; } 9 | 10 | // A longer-lived native function, which occupies the thread calling it. 11 | // 12 | // Do not call these kind of native functions in the main isolate. They will 13 | // block Dart execution. This will cause dropped frames in Flutter applications. 14 | // Instead, call these native functions on a separate isolate. 15 | FFI_PLUGIN_EXPORT intptr_t sum_long_running(intptr_t a, intptr_t b) { 16 | // Simulate work. 17 | #if _WIN32 18 | Sleep(5000); 19 | #else 20 | usleep(5000 * 1000); 21 | #endif 22 | return a + b; 23 | } 24 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/wallet/platform_impl/stub_wallet.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_fuels/wallet/dart_wallet_unlocked.dart'; 2 | 3 | import 'base_wallet.dart'; 4 | 5 | class FuelWalletImpl extends BaseWallet { 6 | @override 7 | Future generateNewWallet({required String networkUrl}) { 8 | throw Exception('Stub implementation'); 9 | } 10 | 11 | @override 12 | Future newFromMnemonic({ 13 | required String networkUrl, 14 | required String mnemonic, 15 | }) { 16 | throw Exception('Stub implementation'); 17 | } 18 | 19 | @override 20 | Future newFromMnemonicAndPath( 21 | {required String networkUrl, 22 | required String mnemonic, 23 | required String derivationPath}) { 24 | throw Exception('Stub implementation'); 25 | } 26 | 27 | @override 28 | Future newFromPrivateKey({ 29 | required String networkUrl, 30 | required String privateKey, 31 | }) { 32 | throw Exception('Stub implementation'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/flutter_fuels/linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LibraryVersion "fuels-v1.38.0") # generated; do not edit 2 | # installed. You should not increase this version, as doing so will cause 3 | # the plugin to fail to compile for some customers of the plugin. 4 | cmake_minimum_required(VERSION 3.10) 5 | 6 | # Project-level configuration. 7 | set(PROJECT_NAME "flutter_fuels") 8 | project(${PROJECT_NAME} LANGUAGES CXX) 9 | 10 | # Invoke the build for native code shared with the other target platforms. 11 | # This can be changed to accomodate different builds. 12 | add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/shared") 13 | 14 | # List of absolute paths to libraries that should be bundled with the plugin. 15 | # This list could contain prebuilt libraries, or libraries created by an 16 | # external build triggered from this build file. 17 | set(flutter_fuels_bundled_libraries 18 | # Defined in ../src/CMakeLists.txt. 19 | # This can be changed to accomodate different builds. 20 | $ 21 | PARENT_SCOPE 22 | ) 23 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72 8 | channel: stable 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72 17 | base_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72 18 | - platform: web 19 | create_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72 20 | base_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72 21 | 22 | # User provided section 23 | 24 | # List of Local paths (relative to this file) that should be 25 | # ignored by the migrate tool. 26 | # 27 | # Files that are not part of the templates will be ignored by default. 28 | unmanaged_files: 29 | - 'lib/main.dart' 30 | - 'ios/Runner.xcodeproj/project.pbxproj' 31 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/wallet/dart_wallet_unlocked.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_fuels/model/call_result.dart'; 2 | 3 | abstract class DartWalletUnlocked { 4 | String? get mnemonicPhrase; 5 | 6 | String get b256Address; 7 | 8 | String get privateKey; 9 | 10 | String get networkUrl; 11 | 12 | Future signMessage({required String message}); 13 | 14 | /// Takes hex string on mobile and json tx request on web 15 | Future sendTransaction({ 16 | required String transactionRequestHexOrJson, 17 | required bool returnTransactionResponse, 18 | }); 19 | 20 | // TODO: move to a platform independent implementation 21 | /// Takes hex string on mobile and json tx request on web 22 | Future simulateTransaction( 23 | {required String transactionRequestHexOrJson}); 24 | 25 | /// Returns hex string on mobile and json tx request on web 26 | Future<(String, String)> genTransferTransactionRequest({ 27 | required String destinationB256Address, 28 | required int fractionalAmount, 29 | required String assetId, 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "short_name": "example", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /packages/flutter_fuels/src/flutter_fuels.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #if _WIN32 6 | #include 7 | #else 8 | #include 9 | #include 10 | #endif 11 | 12 | #if _WIN32 13 | #define FFI_PLUGIN_EXPORT __declspec(dllexport) 14 | #else 15 | #define FFI_PLUGIN_EXPORT 16 | #endif 17 | 18 | // A very short-lived native function. 19 | // 20 | // For very short-lived functions, it is fine to call them on the main isolate. 21 | // They will block the Dart execution while running the native function, so 22 | // only do this for native functions which are guaranteed to be short-lived. 23 | FFI_PLUGIN_EXPORT intptr_t sum(intptr_t a, intptr_t b); 24 | 25 | // A longer lived native function, which occupies the thread calling it. 26 | // 27 | // Do not call these kind of native functions in the main isolate. They will 28 | // block Dart execution. This will cause dropped frames in Flutter applications. 29 | // Instead, call these native functions on a separate isolate. 30 | FFI_PLUGIN_EXPORT intptr_t sum_long_running(intptr_t a, intptr_t b); 31 | -------------------------------------------------------------------------------- /packages/flutter_fuels/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LibraryVersion "fuels-v1.38.0") # generated; do not edit 2 | # installed that includes CMake 3.14 or later. You should not increase this 3 | # version, as doing so will cause the plugin to fail to compile for some 4 | # customers of the plugin. 5 | cmake_minimum_required(VERSION 3.14) 6 | 7 | # Project-level configuration. 8 | set(PROJECT_NAME "flutter_fuels") 9 | project(${PROJECT_NAME} LANGUAGES CXX) 10 | 11 | # Invoke the build for native code shared with the other target platforms. 12 | # This can be changed to accomodate different builds. 13 | add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/shared") 14 | 15 | # List of absolute paths to libraries that should be bundled with the plugin. 16 | # This list could contain prebuilt libraries, or libraries created by an 17 | # external build triggered from this build file. 18 | set(flutter_fuels_bundled_libraries 19 | # Defined in ../src/CMakeLists.txt. 20 | # This can be changed to accomodate different builds. 21 | $ 22 | PARENT_SCOPE 23 | ) 24 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /packages/flutter_fuels/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_fuels 2 | description: Flutter Plugin for Fuel SDK 3 | version: 0.0.75 4 | homepage: https://github.com/Fuelet/fuels-dart/tree/main/packages/flutter_fuels 5 | 6 | environment: 7 | sdk: '>=3.0.0 <4.0.0' 8 | flutter: ">=2.11.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | flutter_web_plugins: 14 | sdk: flutter 15 | plugin_platform_interface: ^2.0.2 16 | fuels: ^1.38.0 17 | js: ^0.6.5 18 | bip39_mnemonic: ^3.0.6 19 | convert: ^3.1.1 20 | dart_bech32: ^2.0.0 21 | equatable: ^2.0.5 22 | dio: '>=5.0.0' 23 | crypto: ^3.0.3 24 | dev_dependencies: 25 | flutter_lints: ^2.0.0 26 | test: ^1.24.2 27 | 28 | flutter: 29 | assets: 30 | - packages/flutter_fuels/js/wallet.js 31 | plugin: 32 | platforms: 33 | android: 34 | ffiPlugin: true 35 | ios: 36 | ffiPlugin: true 37 | linux: 38 | ffiPlugin: true 39 | macos: 40 | ffiPlugin: true 41 | windows: 42 | ffiPlugin: true 43 | web: 44 | pluginClass: JsWalletInjector 45 | fileName: js_wallet_injector.dart 46 | -------------------------------------------------------------------------------- /scripts/build-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Setup 6 | BUILD_DIR=platform-build 7 | mkdir $BUILD_DIR 8 | cd $BUILD_DIR 9 | 10 | # Create the jniLibs build directory 11 | JNI_DIR=jniLibs 12 | mkdir -p $JNI_DIR 13 | 14 | # Set up cargo-ndk 15 | cargo install --version 3.5.4 cargo-ndk 16 | rustup target add \ 17 | aarch64-linux-android \ 18 | armv7-linux-androideabi \ 19 | x86_64-linux-android \ 20 | i686-linux-android 21 | 22 | # Build the android libraries in the jniLibs directory 23 | cargo ndk -o $JNI_DIR \ 24 | --manifest-path ../Cargo.toml \ 25 | -t armeabi-v7a \ 26 | -t arm64-v8a \ 27 | -t x86 \ 28 | -t x86_64 \ 29 | build --release 30 | 31 | # Archive the dynamic libs 32 | cd $JNI_DIR 33 | tar -czvf ../android.tar.gz * 34 | cd - 35 | 36 | # Cleanup 37 | rm -rf $JNI_DIR 38 | cd .. 39 | 40 | # Copy the binary to the needed location 41 | CURR_VERSION=fuels-v`awk '/^version: /{print $2}' packages/fuels/pubspec.yaml` 42 | cp platform-build/android.tar.gz packages/flutter_fuels/android/$CURR_VERSION.tar.gz 43 | echo "[android] Copied file!" -------------------------------------------------------------------------------- /.github/workflows/create-release.yml: -------------------------------------------------------------------------------- 1 | name: Create Release(s) 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | version_parameters: 7 | description: 'Parameters to pass to "melos version"' 8 | required: true 9 | default: ' ' 10 | type: choice 11 | options: 12 | - '--' 13 | - '--prerelease' 14 | - '--graduate' 15 | 16 | jobs: 17 | create_release: 18 | runs-on: ubuntu-latest 19 | 20 | steps: 21 | - uses: actions/checkout@v4 22 | with: 23 | token: ${{ secrets.BOT_ACCESS_TOKEN }} 24 | fetch-depth: 0 25 | - name: Setup git 26 | run: | 27 | git config user.name "Ilya Virnik" 28 | git config user.email "ilya.virnik@gmail.com" 29 | - uses: subosito/flutter-action@v2 30 | - uses: bluefireteam/melos-action@v2 31 | with: 32 | melos-version: '3.1.0' 33 | 34 | - name: Create the new version(s) 35 | run: melos version --yes ${{ inputs.version_parameters }} 36 | 37 | - name: Push created version commit 38 | run: git push 39 | - name: Push modified tags 40 | run: git push --tags 41 | -------------------------------------------------------------------------------- /packages/fuels/justfile: -------------------------------------------------------------------------------- 1 | default: clean gen 2 | 3 | clean: 4 | rm -f native/src/bridge_generated.rs 5 | rm -f native/src/bridge_generated.io.rs 6 | rm -f native/src/bridge_generated.web.rs 7 | sed -i '/mod bridge_generated;/d' native/src/lib.rs 8 | # sed -i '' '/mod bridge_generated;/d' native/src/lib.rs # Mac 9 | 10 | gen: 11 | cargo build --manifest-path=native/Cargo.toml 12 | flutter pub get 13 | # fvm flutter pub get 14 | MAX_RETRIES=3; ATTEMPT=1; while [ $ATTEMPT -le $MAX_RETRIES ]; do \ 15 | flutter_rust_bridge_codegen \ 16 | --rust-input native/src/api.rs \ 17 | --dart-output lib/src/bridge_generated.dart \ 18 | --c-output '../flutter_fuels/ios/Classes/frb.h' \ 19 | --extra-c-output-path '../flutter_fuels/macos/Classes/' \ 20 | --llvm-path /opt/homebrew/opt/llvm \ 21 | && break || ((ATTEMPT++)); echo 'Retrying...';\ 22 | done 23 | dart run build_runner build --delete-conflicting-outputs 24 | dart format . 25 | # fvm dart run build_runner build --delete-conflicting-outputs 26 | # fvm dart format . 27 | cargo build --manifest-path=native/Cargo.toml 28 | 29 | # vim:expandtab:sw=4:ts=4 30 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /.github/workflows/run_codegen.yml: -------------------------------------------------------------------------------- 1 | name: Run flutter_rust_bridge codegen 2 | 3 | on: workflow_dispatch 4 | 5 | permissions: 6 | contents: write 7 | 8 | jobs: 9 | codegen: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - name: Checkout the repository 14 | uses: actions/checkout@v4 15 | 16 | - uses: ./.github/actions/initialize 17 | 18 | - name: Setup Just 19 | uses: extractions/setup-just@v1 20 | with: 21 | just-version: 1.9.0 22 | 23 | - name: Install FRB 24 | run: cargo install --version 1.82.6 flutter_rust_bridge_codegen 25 | 26 | - name: Install cargo-expand 27 | run: cargo install cargo-expand 28 | 29 | - name: FRB codegen 30 | uses: nick-fields/retry@v2 31 | with: 32 | timeout_minutes: 10 33 | max_attempts: 2 34 | command: melos run frb-gen 35 | 36 | - name: Build web 37 | run: melos run build:web 38 | 39 | - name: Commit 40 | run: | 41 | git add -A 42 | git config --global user.name 'Github Actions' 43 | git config --global user.email 'actions@github.com' 44 | git commit -am "Codegen" || echo "Nothing to commit" 45 | git push || echo "Nothing to push" 46 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/wallet/platform_impl/js_interop/js_fuels_wallet.dart: -------------------------------------------------------------------------------- 1 | @JS('flutter_fuels_wallet') 2 | library js_fuels_wallet; 3 | 4 | import 'package:js/js.dart'; 5 | 6 | @JS('generateNewWallet') 7 | external Object generateNewWallet(); 8 | 9 | @JS('newWalletFromMnemonic') 10 | external Object newWalletFromMnemonic(String mnemonic); 11 | 12 | @JS('newWalletFromMnemonicAndPath') 13 | external Object newWalletFromMnemonicAndPath( 14 | String mnemonic, String path); 15 | 16 | @JS('newWalletFromPrivateKey') 17 | external Object newWalletFromPrivateKey(String privateKey); 18 | 19 | @JS('signMessage') 20 | external Object signMessage(String networkUrl, String message); 21 | 22 | @JS('sendTransaction') 23 | external Object sendTransaction( 24 | String privateKey, 25 | String networkUrl, 26 | String transactionRequestJson, 27 | bool returnTransactionResponse, 28 | ); 29 | 30 | @JS('simulateTransaction') 31 | external Object simulateTransaction( 32 | String privateKey, 33 | String networkUrl, 34 | String transactionRequestJson, 35 | ); 36 | 37 | @JS('genTransferTransactionRequest') 38 | external Object genTransferTransactionRequest( 39 | String privateKey, 40 | String networkUrl, 41 | String destinationB256Address, 42 | num fractionalAmount, 43 | String assetId, 44 | ); 45 | -------------------------------------------------------------------------------- /packages/flutter_fuels/ios/flutter_fuels.podspec: -------------------------------------------------------------------------------- 1 | release_tag_name = 'fuels-v1.38.0' # generated; do not edit 2 | 3 | # We cannot distribute the XCFramework alongside the library directly, 4 | # so we have to fetch the correct version here. 5 | framework_name = 'FlutterFuels.xcframework' 6 | remote_zip_name = "#{framework_name}.zip" 7 | url = "https://github.com/Fuelet/fuels-dart/releases/download/#{release_tag_name}/#{remote_zip_name}" 8 | local_zip_name = "#{release_tag_name}.zip" 9 | ` 10 | cd Frameworks 11 | rm -rf #{framework_name} 12 | 13 | if [ ! -f #{local_zip_name} ] 14 | then 15 | curl -L #{url} -o #{local_zip_name} 16 | fi 17 | 18 | unzip #{local_zip_name} 19 | cd - 20 | ` 21 | 22 | Pod::Spec.new do |spec| 23 | spec.name = 'flutter_fuels' 24 | spec.version = '1.0.0' 25 | spec.license = { :file => '../LICENSE' } 26 | spec.homepage = 'https://github.com/Fuelet/fuels-dart' 27 | spec.authors = { 'Ilya Virnik' => 'ilya.virnik@icloud.com' } 28 | spec.summary = 'iOS/macOS Flutter bindings for flutter_fuels' 29 | 30 | spec.source = { :path => '.' } 31 | spec.source_files = 'Classes/**/*' 32 | spec.public_header_files = 'Classes/**/*.h' 33 | spec.vendored_frameworks = "Frameworks/#{framework_name}" 34 | 35 | spec.ios.deployment_target = '11.0' 36 | spec.osx.deployment_target = '10.11' 37 | end 38 | -------------------------------------------------------------------------------- /packages/flutter_fuels/macos/flutter_fuels.podspec: -------------------------------------------------------------------------------- 1 | release_tag_name = 'fuels-v1.38.0' # generated; do not edit 2 | 3 | # We cannot distribute the XCFramework alongside the library directly, 4 | # so we have to fetch the correct version here. 5 | framework_name = 'FlutterFuels.xcframework' 6 | remote_zip_name = "#{framework_name}.zip" 7 | url = "https://github.com/Fuelet/fuels-dart/releases/download/#{release_tag_name}/#{remote_zip_name}" 8 | local_zip_name = "#{release_tag_name}.zip" 9 | ` 10 | cd Frameworks 11 | rm -rf #{framework_name} 12 | 13 | if [ ! -f #{local_zip_name} ] 14 | then 15 | curl -L #{url} -o #{local_zip_name} 16 | fi 17 | 18 | unzip #{local_zip_name} 19 | cd - 20 | ` 21 | 22 | Pod::Spec.new do |spec| 23 | spec.name = 'flutter_fuels' 24 | spec.version = '1.0.0' 25 | spec.license = { :file => '../LICENSE' } 26 | spec.homepage = 'https://github.com/Fuelet/fuels-dart' 27 | spec.authors = { 'Ilya Virnik' => 'ilya.virnik@icloud.com' } 28 | spec.summary = 'iOS/macOS Flutter bindings for flutter_fuels' 29 | 30 | spec.source = { :path => '.' } 31 | spec.source_files = 'Classes/**/*' 32 | spec.public_header_files = 'Classes/**/*.h' 33 | spec.vendored_frameworks = "Frameworks/#{framework_name}" 34 | 35 | spec.ios.deployment_target = '11.0' 36 | spec.osx.deployment_target = '10.11' 37 | end 38 | -------------------------------------------------------------------------------- /packages/flutter_fuels/android/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LibraryVersion "fuels-v1.38.0") # generated; do not edit 2 | 3 | # Unlike the Windows & Linux CMakeLists.txt, this Android equivalent is just here 4 | # to download the Android binaries into src/main/jniLibs/ and does not build anything. 5 | # The binary download/extraction is difficult to do concisely in Groovy/Gradle, 6 | # at least across host platforms, so we are just reusing our Linux/Windows logic. 7 | 8 | # The Flutter tooling requires that developers have CMake 3.10 or later 9 | # installed. You should not increase this version, as doing so will cause 10 | # the plugin to fail to compile for some customers of the plugin. 11 | cmake_minimum_required(VERSION 3.10) 12 | 13 | # Download the binaries if they are not already present. 14 | set(LibRoot "${CMAKE_CURRENT_SOURCE_DIR}/src/main/jniLibs") 15 | set(ArchivePath "${CMAKE_CURRENT_SOURCE_DIR}/${LibraryVersion}.tar.gz") 16 | if(NOT EXISTS ${ArchivePath}) 17 | file(DOWNLOAD 18 | "https://github.com/Fuelet/fuels-dart/releases/download/${LibraryVersion}/android.tar.gz" 19 | ${ArchivePath} 20 | TLS_VERIFY ON 21 | ) 22 | endif() 23 | 24 | # Extract the binaries, overriding any already present. 25 | file(REMOVE_RECURSE ${LibRoot}) 26 | file(MAKE_DIRECTORY ${LibRoot}) 27 | execute_process( 28 | COMMAND ${CMAKE_COMMAND} -E tar xzf ${ArchivePath} 29 | WORKING_DIRECTORY ${LibRoot} 30 | ) 31 | -------------------------------------------------------------------------------- /packages/fuels/native/src/model/output.rs: -------------------------------------------------------------------------------- 1 | pub enum Output { 2 | OutputCoin { 3 | to: String, 4 | amount: u64, 5 | asset_id: String, 6 | }, 7 | OutputContract { 8 | input_index: u16, 9 | }, 10 | OutputChange { 11 | to: String, 12 | amount: u64, 13 | asset_id: String, 14 | }, 15 | OutputVariable { 16 | to: String, 17 | amount: u64, 18 | asset_id: String, 19 | }, 20 | OutputContractCreated { 21 | contract_id: String, 22 | }, 23 | UnknownOutput, 24 | } 25 | 26 | impl From<&fuel_tx::Output> for Output { 27 | fn from(model: &fuel_tx::Output) -> Self { 28 | match model { 29 | fuel_tx::Output::Coin { to, amount, asset_id } => { Output::OutputCoin { to: to.to_string(), amount: *amount, asset_id: asset_id.to_string() } } 30 | fuel_tx::Output::Contract(contract) => { Output::OutputContract { input_index: contract.input_index } } 31 | fuel_tx::Output::Change { to, amount, asset_id } => { Output::OutputChange { to: to.to_string(), amount: *amount, asset_id: asset_id.to_string() } } 32 | fuel_tx::Output::Variable { to, amount, asset_id } => { Output::OutputVariable { to: to.to_string(), amount: *amount, asset_id: asset_id.to_string() } } 33 | fuel_tx::Output::ContractCreated { contract_id, state_root: _ } => { Output::OutputContractCreated { contract_id: contract_id.to_string() } } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.CreateAndShow(L"flutter_fuels_example", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.11' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | end 35 | 36 | post_install do |installer| 37 | installer.pods_project.targets.each do |target| 38 | flutter_additional_macos_build_settings(target) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '11.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/fuel_utils/platform_impl/web_fuel_utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter_fuels/model/transaction.dart'; 4 | import 'package:flutter_fuels/model/transaction_cost.dart'; 5 | import 'package:js/js_util.dart'; 6 | 7 | import 'base_fuel_utils.dart'; 8 | import 'js_interop/js_fuels_utils.dart' as js_utils; 9 | 10 | class FuelUtilsImpl extends BaseFuelUtils { 11 | @override 12 | Future transformTxRequest(dynamic transactionRequestHexOrJson) { 13 | String jsTransaction = 14 | js_utils.transformTxRequest(transactionRequestHexOrJson); 15 | try { 16 | Transaction dartTransaction = 17 | Transaction.fromJson(jsonDecode(jsTransaction)); 18 | return Future.value(dartTransaction); 19 | } catch (err) { 20 | return Future.error(err); 21 | } 22 | } 23 | 24 | @override 25 | Future getTransactionCost( 26 | {required String networkUrl, 27 | required String transactionRequestHexOrJson}) async { 28 | final txCostStr = await promiseToFuture( 29 | js_utils.getTransactionCost(networkUrl, transactionRequestHexOrJson)); 30 | final txCostJson = jsonDecode(txCostStr); 31 | try { 32 | return TransactionCost.fromJson(txCostJson); 33 | } catch (err) { 34 | return Future.error(err); 35 | } 36 | } 37 | 38 | @override 39 | Future isUserAccount( 40 | {required String network, required String address}) { 41 | return promiseToFuture(js_utils.isUserAccount(network, address)); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | -------------------------------------------------------------------------------- /packages/fuels/test/features/transaction_test.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: avoid_print 2 | 3 | import 'package:fuels/fuels.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | import '../test_utils.dart'; 7 | 8 | const _transferAmount = 1; 9 | 10 | // TODO: do not depend on external state 11 | void main() { 12 | test('test transfer tx gas estimation', () async { 13 | Provider provider = createProvider(); 14 | WalletUnlocked newWallet = await createRandomWallet(); 15 | WalletUnlocked testWallet = await importWalletWithPK(testWalletPrivateKey); 16 | 17 | final (requestBytes, _) = await testWallet.genTransferTxRequest( 18 | to: newWallet.b256Address, amount: _transferAmount, asset: baseAsset); 19 | final txCost = 20 | await provider.estimateTransactionCost(encodedTx: requestBytes); 21 | 22 | print( 23 | 'gasPrice: ${txCost.gasPrice}, meteredBytesSize: ${txCost.meteredBytesSize}, totalFee: ${txCost.totalFee}, scriptGas: ${txCost.scriptGas}, totalGas: ${txCost.totalGas}'); 24 | expect(txCost.gasPrice > 0, true); 25 | expect(txCost.totalFee > 0, true); 26 | }); 27 | 28 | test('test transfer eth request creation', () async { 29 | WalletUnlocked newWallet = await createRandomWallet(); 30 | WalletUnlocked testWallet = await importWalletWithPK(testWalletPrivateKey); 31 | 32 | final (requestBytes, _) = await testWallet.genTransferTxRequest( 33 | to: newWallet.b256Address, amount: _transferAmount, asset: baseAsset); 34 | final txId = await testWallet.sendTransaction(encodedTx: requestBytes); 35 | 36 | expect(txId.isNotEmpty, true); 37 | }, skip: 'Should be run manually'); 38 | } 39 | -------------------------------------------------------------------------------- /scripts/build-apple.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Setup 6 | BUILD_DIR=platform-build 7 | mkdir $BUILD_DIR 8 | cd $BUILD_DIR 9 | 10 | # Build static libs 11 | for TARGET in \ 12 | aarch64-apple-ios x86_64-apple-ios aarch64-apple-ios-sim \ 13 | x86_64-apple-darwin aarch64-apple-darwin 14 | do 15 | rustup target add $TARGET 16 | cargo build -r --target=$TARGET 17 | done 18 | 19 | # Create XCFramework zip 20 | FRAMEWORK="FlutterFuels.xcframework" 21 | LIBNAME=libfuels.a 22 | mkdir mac-lipo ios-sim-lipo 23 | IOS_SIM_LIPO=ios-sim-lipo/$LIBNAME 24 | MAC_LIPO=mac-lipo/$LIBNAME 25 | lipo -create -output $IOS_SIM_LIPO \ 26 | ../target/aarch64-apple-ios-sim/release/$LIBNAME \ 27 | ../target/x86_64-apple-ios/release/$LIBNAME 28 | lipo -create -output $MAC_LIPO \ 29 | ../target/aarch64-apple-darwin/release/$LIBNAME \ 30 | ../target/x86_64-apple-darwin/release/$LIBNAME 31 | xcodebuild -create-xcframework \ 32 | -library $IOS_SIM_LIPO \ 33 | -library $MAC_LIPO \ 34 | -library ../target/aarch64-apple-ios/release/$LIBNAME \ 35 | -output $FRAMEWORK 36 | zip -r $FRAMEWORK.zip $FRAMEWORK 37 | 38 | # Cleanup 39 | rm -rf ios-sim-lipo mac-lipo $FRAMEWORK 40 | 41 | cd .. 42 | 43 | # Copy the binaries to the needed location 44 | CURR_VERSION=fuels-v`awk '/^version: /{print $2}' packages/fuels/pubspec.yaml` 45 | 46 | cp platform-build/FlutterFuels.xcframework.zip packages/flutter_fuels/macos/Frameworks/$CURR_VERSION.zip 47 | echo "[macos] Copied file!" 48 | 49 | cp platform-build/FlutterFuels.xcframework.zip packages/flutter_fuels/ios/Frameworks/$CURR_VERSION.zip 50 | echo "[ios] Copied file!" 51 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /packages/fuels/test/test_utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; 4 | import 'package:fuels/fuels.dart'; 5 | 6 | const betaApiUrl = 'https://testnet.fuel.network'; 7 | const testWalletAddress = 8 | 'fe1177573a47310756f27ef25c7229b5da8d5109a7258b297f23a6768c78cb40'; 9 | const testWalletPrivateKey = 10 | 'e5e05a4ab2919dc01b97c90a48853fd4dfbd204e92e44327375702ab09bb184e'; 11 | const testWalletSeedPhrase = 12 | 'sorry suit fade strike crucial theory rubber sign scrub burden enough trash'; 13 | 14 | const baseAsset = 15 | '0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07'; 16 | 17 | String projectPath = Directory.current.parent.parent.path; 18 | var rustSdk = 19 | FuelsImpl(loadLibForFlutter('$projectPath/target/debug/libfuels.dylib')); 20 | 21 | Future createRandomWallet() { 22 | return WalletUnlocked.newRandom(bridge: rustSdk, nodeUrl: betaApiUrl); 23 | } 24 | 25 | Provider createProvider() { 26 | return Provider(bridge: rustSdk, nodeUrl: betaApiUrl); 27 | } 28 | 29 | Future importWalletWithPK(String privateKey) { 30 | return WalletUnlocked.newFromPrivateKey( 31 | bridge: rustSdk, privateKey: privateKey, nodeUrl: betaApiUrl); 32 | } 33 | 34 | Future importWalletWithMnemonics(String mnemonicPhrase) { 35 | return WalletUnlocked.newFromMnemonicPhrase( 36 | bridge: rustSdk, phrase: mnemonicPhrase, nodeUrl: betaApiUrl); 37 | } 38 | 39 | Future importWalletWithMnemonicsAndPath( 40 | String mnemonicPhrase, String path) { 41 | return WalletUnlocked.newFromMnemonicPhraseWithPath( 42 | bridge: rustSdk, phrase: mnemonicPhrase, path: path, nodeUrl: betaApiUrl); 43 | } 44 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /packages/flutter_fuels/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: 135454af32477f815a7525073027a3ff9eff1bfd 8 | channel: stable 9 | 10 | project_type: plugin_ffi 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 17 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 18 | - platform: android 19 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 20 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 21 | - platform: ios 22 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 23 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 24 | - platform: linux 25 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 26 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 27 | - platform: macos 28 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 29 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 30 | - platform: windows 31 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 32 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 33 | - platform: web 34 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd 35 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 37 | 38 | # Run the Flutter tool portions of the build. This must not be removed. 39 | add_dependencies(${BINARY_NAME} flutter_assemble) 40 | -------------------------------------------------------------------------------- /packages/fuels/native/src/model/input.rs: -------------------------------------------------------------------------------- 1 | pub enum Input { 2 | InputCoin { 3 | owner: String, 4 | amount: u64, 5 | asset_id: String, 6 | witness_index: Option, 7 | }, 8 | InputContract { 9 | contract_id: String, 10 | }, 11 | InputMessage { 12 | amount: u64, 13 | sender: String, 14 | recipient: String, 15 | witness_index: Option, 16 | }, 17 | UnknownInput, 18 | } 19 | 20 | impl From<&fuel_tx::Input> for Input { 21 | fn from(model: &fuel_tx::Input) -> Self { 22 | match model { 23 | fuel_tx::Input::CoinSigned(coin) => { Input::InputCoin { owner: coin.owner.to_string(), amount: coin.amount, asset_id: coin.asset_id.to_string(), witness_index: Some(coin.witness_index) } } 24 | fuel_tx::Input::CoinPredicate(coin) => { Input::InputCoin { owner: coin.owner.to_string(), amount: coin.amount, asset_id: coin.asset_id.to_string(), witness_index: None } } 25 | fuel_tx::Input::Contract(contract) => { Input::InputContract { contract_id: contract.contract_id.to_string() } } 26 | fuel_tx::Input::MessageCoinSigned(msg) => { Input::InputMessage { amount: msg.amount, sender: msg.sender.to_string(), recipient: msg.recipient.to_string(), witness_index: Some(msg.witness_index) } } 27 | fuel_tx::Input::MessageCoinPredicate(msg) => { Input::InputMessage { amount: msg.amount, sender: msg.sender.to_string(), recipient: msg.recipient.to_string(), witness_index: None } } 28 | fuel_tx::Input::MessageDataSigned(msg) => { Input::InputMessage { amount: msg.amount, sender: msg.sender.to_string(), recipient: msg.recipient.to_string(), witness_index: Some(msg.witness_index) } } 29 | fuel_tx::Input::MessageDataPredicate(msg) => { Input::InputMessage { amount: msg.amount, sender: msg.sender.to_string(), recipient: msg.recipient.to_string(), witness_index: None } } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Flutter Fuels 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | flutter_fuels_example 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | UIApplicationSupportsIndirectInputEvents 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | std::string utf8_string; 52 | if (target_length == 0 || target_length > utf8_string.max_size()) { 53 | return utf8_string; 54 | } 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /.github/workflows/publish-github-release.yml: -------------------------------------------------------------------------------- 1 | name: Publish Github release 2 | 3 | on: workflow_call 4 | 5 | jobs: 6 | build_apple: 7 | runs-on: macos-14 8 | 9 | steps: 10 | - name: Checkout the repository 11 | uses: actions/checkout@v4 12 | 13 | - uses: ./.github/actions/initialize 14 | 15 | - uses: ./.github/actions/extract_package_version 16 | 17 | - name: Build apple binary 18 | run: melos run build:apple 19 | 20 | - name: Uploading artifact 21 | uses: actions/upload-artifact@v4 22 | with: 23 | name: apple_binary 24 | path: platform-build/FlutterFuels.xcframework.zip 25 | 26 | build_android: 27 | runs-on: ubuntu-latest 28 | 29 | steps: 30 | - name: Checkout the repository 31 | uses: actions/checkout@v4 32 | 33 | - uses: ./.github/actions/initialize 34 | 35 | - uses: ./.github/actions/extract_package_version 36 | 37 | - name: Setup NDK 38 | uses: nttld/setup-ndk@v1 39 | with: 40 | ndk-version: r25b 41 | 42 | - name: Build android binary 43 | run: melos run build:android 44 | 45 | - name: Uploading artifact 46 | uses: actions/upload-artifact@v4 47 | with: 48 | name: android_binary 49 | path: platform-build/android.tar.gz 50 | 51 | publish_github_release: 52 | runs-on: ubuntu-latest 53 | needs: [ build_apple, build_android ] 54 | steps: 55 | - uses: actions/checkout@v4 56 | 57 | - name: Download apple binary 58 | uses: actions/download-artifact@v4 59 | with: 60 | name: apple_binary 61 | path: platform-build 62 | 63 | - name: Download android binary 64 | uses: actions/download-artifact@v4 65 | with: 66 | name: android_binary 67 | path: platform-build 68 | 69 | - name: Create GitHub release 70 | uses: softprops/action-gh-release@v1 71 | with: 72 | name: ${{env.RELEASE_VERSION}} 73 | files: platform-build/* 74 | -------------------------------------------------------------------------------- /melos.yaml: -------------------------------------------------------------------------------- 1 | name: fuels 2 | 3 | repository: https://github.com/Fuelet/fuels-dart 4 | 5 | packages: 6 | - packages/** 7 | 8 | command: 9 | version: 10 | hooks: 11 | preCommit: bash scripts/version.sh 12 | 13 | scripts: 14 | analyze: 15 | exec: flutter analyze . 16 | description: Analyze a specific package in this project. 17 | 18 | check-format: 19 | exec: flutter format --set-exit-if-changed . 20 | description: Check the format of a specific package in this project. 21 | 22 | format: 23 | exec: flutter format . 24 | description: Format a specific package in this project. 25 | 26 | build: 27 | run: melos run build:apple && melos run build:android && melos run build:web # && melos run build:other 28 | description: Build all native libraries for the project. 29 | 30 | build:apple: 31 | run: bash scripts/build-apple.sh 32 | description: Build the XCFramework for iOS and macOS. 33 | 34 | build:android: 35 | run: bash scripts/build-android.sh 36 | description: Build the .tar.gz for Android. 37 | 38 | build:web: 39 | run: bash scripts/build-web.sh 40 | description: Build web. 41 | 42 | # build:other: 43 | # run: bash scripts/build-other.sh 44 | # description: Build the .tar.gz for all other platforms. 45 | 46 | frb-gen: 47 | run: just --justfile packages/fuels/justfile 48 | description: Generate wrapper over the native Rust code 49 | 50 | test: 51 | run: melos run test:dart --no-select && melos run test:flutter --no-select 52 | description: Run all Dart & Flutter tests in this project. 53 | 54 | test:dart: 55 | run: melos exec -c 1 --fail-fast -- "dart test test" 56 | description: Run Dart tests for a specific package in this project. 57 | select-package: 58 | flutter: false 59 | dir-exists: test 60 | 61 | test:flutter: 62 | run: melos exec -c 1 --fail-fast -- "flutter test test" 63 | description: Run Flutter tests for a specific package in this project. 64 | select-package: 65 | flutter: true 66 | dir-exists: test -------------------------------------------------------------------------------- /packages/flutter_fuels/example/windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | return true; 30 | } 31 | 32 | void FlutterWindow::OnDestroy() { 33 | if (flutter_controller_) { 34 | flutter_controller_ = nullptr; 35 | } 36 | 37 | Win32Window::OnDestroy(); 38 | } 39 | 40 | LRESULT 41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 42 | WPARAM const wparam, 43 | LPARAM const lparam) noexcept { 44 | // Give Flutter, including plugins, an opportunity to handle window messages. 45 | if (flutter_controller_) { 46 | std::optional result = 47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 48 | lparam); 49 | if (result) { 50 | return *result; 51 | } 52 | } 53 | 54 | switch (message) { 55 | case WM_FONTCHANGE: 56 | flutter_controller_->engine()->ReloadSystemFonts(); 57 | break; 58 | } 59 | 60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 61 | } 62 | -------------------------------------------------------------------------------- /packages/flutter_fuels/test/fuel_utils/fuel_utils_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_fuels/flutter_fuels.dart'; 2 | import 'package:test/test.dart'; 3 | 4 | const String _mainnetUrl = 'https://mainnet.fuel.network'; 5 | const String _testnetUrl = 'https://testnet.fuel.network'; 6 | 7 | void main() { 8 | test('test asset id check', () async { 9 | final testCases = [ 10 | ( 11 | 'fuel1lcghw4e6gucsw4hj0me9cu3fkhdg65gf5ujck2tlywn8drrcedqq2htmt3', 12 | false, 13 | _mainnetUrl, 14 | ), 15 | ( 16 | 'fuel1dn4ew2a5kn9datj34npuyz63lztjhhfw6mzw6q9vqdtgu2t9y23q3u0tdc', 17 | false, 18 | _mainnetUrl, 19 | ), 20 | ( 21 | '0x3341d9F4ef079b62fED7D0797102905d5624375BC37831D3a1a0187531C5705E', 22 | false, 23 | _mainnetUrl, 24 | ), 25 | ( 26 | '0x6750ae4794d00e1e1C97a4FcCaA8c8E64F9DC79D0690E0dAE64B61e4Ef6bd3F3', 27 | false, 28 | _mainnetUrl, 29 | ), 30 | ( 31 | '0x6750ae4794d00e1e1C97a4FcCaA8c8E64F9DC79D0690E0dAE64B61e4Ef6bd3F3', 32 | false, 33 | _testnetUrl, 34 | ), 35 | ( 36 | '0x1d5d97005e41cae2187a895fd8eab0506111e0e2f3331cd3912c15c24e3c1d82', // fuel asset id on mainnet 37 | true, 38 | _mainnetUrl, 39 | ), 40 | ( 41 | '0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07', // eth asset id 42 | true, 43 | _mainnetUrl, 44 | ), 45 | ( 46 | '0x324d0c35a4299ef88138a656d5272c5a3a9ccde2630ae055dacaf9d13443d53b', // fuel asset id on testnet 47 | true, 48 | _testnetUrl, 49 | ), 50 | ( 51 | '0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07', // eth asset id 52 | true, 53 | _testnetUrl, 54 | ), 55 | ]; 56 | for (final (address, isUserAccount, network) in testCases) { 57 | final isUser = await FuelUtils.isAssetId( 58 | network: network, address: FuelAddress.fromString(address)); 59 | expect(isUser, isUserAccount); 60 | } 61 | }); 62 | } 63 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | example 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /packages/fuels/native/src/features/wallet.rs: -------------------------------------------------------------------------------- 1 | use std::str::FromStr; 2 | use std::string::String; 3 | 4 | use fuel_crypto::SecretKey; 5 | use fuel_tx::Address; 6 | use fuels::prelude::Provider; 7 | use fuels_accounts::signers::private_key::{PrivateKeySigner, generate_mnemonic_phrase}; 8 | 9 | use crate::api::{WalletUnlocked}; 10 | use crate::model::error::CustomResult; 11 | 12 | pub const DEFAULT_DERIVATION_PATH_PREFIX: &str = "m/44'/1179993420'"; 13 | 14 | pub fn new_random(node_url: String) -> CustomResult { 15 | let mut rng = rand::thread_rng(); 16 | let mnemonic_phrase = generate_mnemonic_phrase(&mut rng, 12)?; 17 | new_from_mnemonic_phrase(mnemonic_phrase, node_url) 18 | } 19 | 20 | pub fn new_from_private_key(private_key: String, node_url: String) -> CustomResult { 21 | let secret_key = SecretKey::from_str(private_key.as_str())?; 22 | Ok(WalletUnlocked { 23 | private_key: secret_key.to_string(), 24 | mnemonic_phrase: None, 25 | node_url, 26 | b256_address: get_public_address(secret_key).to_string(), 27 | }) 28 | } 29 | 30 | pub fn new_from_mnemonic_phrase(phrase: String, node_url: String) -> CustomResult { 31 | let path = format!("{}/0'/0/0", DEFAULT_DERIVATION_PATH_PREFIX); 32 | new_from_mnemonic_phrase_with_path(phrase, path, node_url) 33 | } 34 | 35 | pub fn new_from_mnemonic_phrase_with_path( 36 | phrase: String, 37 | path: String, 38 | node_url: String, 39 | ) -> CustomResult { 40 | let secret_key = SecretKey::new_from_mnemonic_phrase_with_path(&phrase, &path)?; 41 | Ok(WalletUnlocked { 42 | private_key: secret_key.to_string(), 43 | mnemonic_phrase: Some(phrase), 44 | node_url, 45 | b256_address: get_public_address(secret_key).to_string(), 46 | }) 47 | } 48 | 49 | fn get_public_address(private_key: SecretKey) -> Address { 50 | let signer = PrivateKeySigner::new(private_key); 51 | signer.address() 52 | } 53 | 54 | pub async fn is_user_account(provider: &Provider, address: Address) -> bool { 55 | provider 56 | .is_user_account(*address) 57 | .await 58 | .unwrap_or(false) 59 | } 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # fuels-dart 2 | Dart & Flutter SDK for Fuel Blockchain. Essentially, it's a wrapper over the [official Rust SDK](https://github.com/FuelLabs/fuels-rs) for mobile and [official TypeScript SDK](https://github.com/FuelLabs/fuels-ts) for web. It's implemented with the help of [flutter_rust_bridge](https://github.com/fzyzcjy/flutter_rust_bridge) library. 3 | 4 | For more information about SDK functionality and abilities, please check out fuels-rs SDK [documentation](https://fuellabs.github.io/fuels-rs/v0.34.0/index.html). 5 | 6 | The project tries to stick to the same interfaces as used in the Rust SDK wherever possible. 7 | 8 | The project structure explanation can be found in the [FRB documentation](https://cjycode.com/flutter_rust_bridge/library.html). 9 | 10 | ## Documentation 11 | 12 | Work on documentation for Dart/Flutter SDK is in progress. 13 | 14 | ## Implemented features 15 | 16 | - [x] Create wallet 17 | - [x] Get account balances 18 | - [x] Transfer tokens 19 | - [ ] Sign transactions 20 | 21 | ## Contributing 22 | 23 | [packages/fuels/native](https://github.com/Fuelet/fuels-dart/tree/main/packages/fuels/native) folder contains Rust files. [api.rs](https://github.com/Fuelet/fuels-dart/blob/main/packages/fuels/native/src/api.rs) is the main entrypoint of the Rust methods accessed from Dart. 24 | 25 | After changing any of the Rust files, you need to regenerate the wrapper. Just call: 26 | 27 | ```shell 28 | melos run frb-gen 29 | ``` 30 | 31 | All commits in the main branch must follow the [Conventional Commits](https://cheatography.com/albelop/cheat-sheets/conventional-commits/) format. 32 | 33 | ## Releasing 34 | 35 | To upgrade the library version before releasing, do: 36 | 37 | ```shell 38 | melos version 39 | ``` 40 | 41 | Then push the generated commit with tags: 42 | 43 | ```shell 44 | git push --follow-tags 45 | ``` 46 | Ths will start Github actions tasks for creating and publishing a release on Github. 47 | 48 | In order to publish a package to https://pub.dev/, you need to wait for the CI/CD tasks from the previous step to complete. 49 | Then call the following command from the corresponding package: 50 | 51 | ```shell 52 | cd packages/[needed package] 53 | flutter pub publish 54 | ``` 55 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/flutter_fuels_bindings_generated.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: always_specify_types 2 | // ignore_for_file: camel_case_types 3 | // ignore_for_file: non_constant_identifier_names 4 | 5 | // AUTO GENERATED FILE, DO NOT EDIT. 6 | // 7 | // Generated by `package:ffigen`. 8 | import 'dart:ffi' as ffi; 9 | 10 | /// Bindings for `src/flutter_fuels.h`. 11 | /// 12 | /// Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. 13 | /// 14 | class FlutterFuelsBindings { 15 | /// Holds the symbol lookup function. 16 | final ffi.Pointer Function(String symbolName) 17 | _lookup; 18 | 19 | /// The symbols are looked up in [dynamicLibrary]. 20 | FlutterFuelsBindings(ffi.DynamicLibrary dynamicLibrary) 21 | : _lookup = dynamicLibrary.lookup; 22 | 23 | /// The symbols are looked up with [lookup]. 24 | FlutterFuelsBindings.fromLookup( 25 | ffi.Pointer Function(String symbolName) 26 | lookup) 27 | : _lookup = lookup; 28 | 29 | /// A very short-lived native function. 30 | /// 31 | /// For very short-lived functions, it is fine to call them on the main isolate. 32 | /// They will block the Dart execution while running the native function, so 33 | /// only do this for native functions which are guaranteed to be short-lived. 34 | int sum( 35 | int a, 36 | int b, 37 | ) { 38 | return _sum( 39 | a, 40 | b, 41 | ); 42 | } 43 | 44 | late final _sumPtr = 45 | _lookup>( 46 | 'sum'); 47 | late final _sum = _sumPtr.asFunction(); 48 | 49 | /// A longer lived native function, which occupies the thread calling it. 50 | /// 51 | /// Do not call these kind of native functions in the main isolate. They will 52 | /// block Dart execution. This will cause dropped frames in Flutter applications. 53 | /// Instead, call these native functions on a separate isolate. 54 | int sum_long_running( 55 | int a, 56 | int b, 57 | ) { 58 | return _sum_long_running( 59 | a, 60 | b, 61 | ); 62 | } 63 | 64 | late final _sum_long_runningPtr = 65 | _lookup>( 66 | 'sum_long_running'); 67 | late final _sum_long_running = 68 | _sum_long_runningPtr.asFunction(); 69 | } 70 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion flutter.compileSdkVersion 30 | ndkVersion flutter.ndkVersion 31 | 32 | compileOptions { 33 | sourceCompatibility JavaVersion.VERSION_1_8 34 | targetCompatibility JavaVersion.VERSION_1_8 35 | } 36 | 37 | kotlinOptions { 38 | jvmTarget = '1.8' 39 | } 40 | 41 | sourceSets { 42 | main.java.srcDirs += 'src/main/kotlin' 43 | } 44 | 45 | defaultConfig { 46 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 47 | applicationId "com.fuelet.flutter_fuels_example" 48 | // You can update the following values to match your application needs. 49 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. 50 | minSdkVersion flutter.minSdkVersion 51 | targetSdkVersion flutter.targetSdkVersion 52 | versionCode flutterVersionCode.toInteger() 53 | versionName flutterVersionName 54 | } 55 | 56 | buildTypes { 57 | release { 58 | // TODO: Add your own signing config for the release build. 59 | // Signing with the debug keys for now, so `flutter run --release` works. 60 | signingConfig signingConfigs.debug 61 | } 62 | } 63 | } 64 | 65 | flutter { 66 | source '../..' 67 | } 68 | 69 | dependencies { 70 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 71 | } 72 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/model/fuel_address.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:typed_data'; 3 | 4 | import 'package:convert/convert.dart'; 5 | import 'package:crypto/crypto.dart'; 6 | import 'package:dart_bech32/dart_bech32.dart'; 7 | import 'package:equatable/equatable.dart'; 8 | import 'package:flutter_fuels/utils/hex_utils.dart'; 9 | 10 | const _hrp = 'fuel'; 11 | 12 | class FuelAddress with EquatableMixin { 13 | final String bech32Address; 14 | final String b256Address; 15 | 16 | FuelAddress({ 17 | required String bech32Address, 18 | required String b256Address, 19 | }) : bech32Address = _formatBechAddress(bech32Address), 20 | b256Address = _formatB256Address(b256Address); 21 | 22 | factory FuelAddress.fromString(String s) { 23 | try { 24 | if (s.startsWith(_hrp)) { 25 | final decoded = bech32m.decode(s); 26 | return FuelAddress( 27 | bech32Address: s, 28 | b256Address: hex.encode(bech32m.fromWords(decoded.words)), 29 | ); 30 | } else { 31 | final bytes = hex.decode(removeHexPrefix(s)); 32 | final words = bech32m.toWords(Uint8List.fromList(bytes)); 33 | return FuelAddress( 34 | bech32Address: bech32m.encode(Decoded(prefix: _hrp, words: words)), 35 | b256Address: s, 36 | ); 37 | } 38 | } catch (e) { 39 | throw Exception('Invalid Fuel address $s: $e'); 40 | } 41 | } 42 | 43 | @override 44 | List get props => [b256Address, bech32Address]; 45 | } 46 | 47 | String _toChecksum(String address) { 48 | address = address.toLowerCase(); 49 | if (address.startsWith('0x') || address.startsWith('0X')) { 50 | address = address.substring(2); 51 | } 52 | final checksum = sha256.convert(utf8.encode(address)).bytes; 53 | 54 | StringBuffer ret = StringBuffer('0x'); 55 | for (int i = 0; i < 32; ++i) { 56 | final byte = checksum[i]; 57 | final ha = address[i * 2]; 58 | final hb = address[i * 2 + 1]; 59 | ret.write((byte & 0xf0) >= 0x80 ? ha.toUpperCase() : ha); 60 | ret.write((byte & 0x0f) >= 0x08 ? hb.toUpperCase() : hb); 61 | } 62 | 63 | return ret.toString(); 64 | } 65 | 66 | String _formatB256Address(String b256Address) { 67 | final withPrefix = addHexPrefix(b256Address); 68 | if (withPrefix.length != 66) { 69 | throw Exception('b256Address must contain 64 hex symbols: $withPrefix'); 70 | } 71 | return addHexPrefix(_toChecksum(b256Address)); 72 | } 73 | 74 | String _formatBechAddress(String bechAddress) { 75 | return bechAddress.toLowerCase(); 76 | } 77 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/model/input.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_fuels/utils/hex_utils.dart'; 2 | import 'package:flutter_fuels/utils/json_utils.dart'; 3 | 4 | abstract class Input { 5 | const Input(); 6 | 7 | static Input fromJson(Map jsonInput) { 8 | try { 9 | int inputType = jsonInput['type']; 10 | switch (inputType) { 11 | case 0: 12 | return InputCoin.fromJson(jsonInput); 13 | case 1: 14 | return InputContract.fromJson(jsonInput); 15 | case 2: 16 | return InputMessage.fromJson(jsonInput); 17 | default: 18 | return UnknownInput(raw: jsonInput); 19 | } 20 | } catch (e) { 21 | return UnparsedInput(raw: jsonInput, err: e); 22 | } 23 | } 24 | } 25 | 26 | class UnknownInput extends Input { 27 | final Map raw; 28 | 29 | const UnknownInput({required this.raw}); 30 | } 31 | 32 | class UnparsedInput extends Input { 33 | final Map raw; 34 | final dynamic err; 35 | 36 | const UnparsedInput({required this.raw, required this.err}); 37 | } 38 | 39 | class InputCoin extends Input { 40 | final String owner; 41 | final BigInt amount; 42 | final String assetId; 43 | final int witnessIndex; 44 | 45 | const InputCoin( 46 | {required this.owner, 47 | required this.amount, 48 | required this.assetId, 49 | required this.witnessIndex}); 50 | 51 | factory InputCoin.fromJson(Map data) { 52 | return InputCoin( 53 | owner: addHexPrefix(data['owner']), 54 | amount: parseBigInt(data['amount']), 55 | assetId: addHexPrefix(data['assetId']), 56 | witnessIndex: data['witnessIndex'], 57 | ); 58 | } 59 | } 60 | 61 | class InputContract extends Input { 62 | final String contractID; 63 | 64 | const InputContract({required this.contractID}); 65 | 66 | factory InputContract.fromJson(Map data) { 67 | return InputContract(contractID: addHexPrefix(data['contractID'])); 68 | } 69 | } 70 | 71 | class InputMessage extends Input { 72 | final BigInt amount; 73 | final String sender; 74 | final String recipient; 75 | final int witnessIndex; 76 | 77 | const InputMessage({ 78 | required this.amount, 79 | required this.sender, 80 | required this.recipient, 81 | required this.witnessIndex, 82 | }); 83 | 84 | factory InputMessage.fromJson(Map data) { 85 | return InputMessage( 86 | amount: parseBigInt(data['amount']), 87 | sender: addHexPrefix(data['sender']), 88 | recipient: addHexPrefix(data['recipient']), 89 | witnessIndex: data['witnessIndex']); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/fuel_utils/fuel_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | import 'package:flutter_fuels/model/fuel_address.dart'; 3 | import 'package:flutter_fuels/model/transaction.dart'; 4 | import 'package:flutter_fuels/model/transaction_cost.dart'; 5 | 6 | import 'platform_impl/stub_fuel_utils.dart' 7 | if (dart.library.io) 'platform_impl/mobile_fuel_utils.dart' 8 | if (dart.library.html) 'platform_impl/web_fuel_utils.dart'; 9 | 10 | class FuelUtils { 11 | static final _utils = FuelUtilsImpl(); 12 | static final _dio = Dio(); 13 | 14 | static Future transformTxRequest( 15 | dynamic transactionRequestLike) { 16 | return _utils.transformTxRequest(transactionRequestLike); 17 | } 18 | 19 | /// Takes hex string on mobile and json tx request on web 20 | static Future getTransactionCost( 21 | {required String networkUrl, 22 | required String transactionRequestHexOrJson}) { 23 | return _utils.getTransactionCost( 24 | networkUrl: networkUrl, 25 | transactionRequestHexOrJson: transactionRequestHexOrJson); 26 | } 27 | 28 | static Future isUserAccount( 29 | {required String network, required String address}) async { 30 | try { 31 | final fuelAddress = FuelAddress.fromString(address); 32 | final isUserAccountFuture = _utils.isUserAccount( 33 | network: network, address: fuelAddress.b256Address); 34 | final isAssetIdFuture = isAssetId(network: network, address: fuelAddress); 35 | final [isUser, isAsset] = 36 | await Future.wait([isUserAccountFuture, isAssetIdFuture]); 37 | return isUser && !isAsset; 38 | } catch (e) { 39 | return Future.value(false); 40 | } 41 | } 42 | 43 | /// Returns bool representing if the provided address is an asset id. 44 | /// Returns false if there's not enough information to determine that. 45 | static Future isAssetId( 46 | {required String network, required FuelAddress address}) async { 47 | final fuelExplorerApi = _getFuelExplorerApiUrl(network); 48 | if (fuelExplorerApi == null) { 49 | return false; 50 | } 51 | try { 52 | final response = await _dio 53 | .get('$fuelExplorerApi/assets/${address.b256Address.toLowerCase()}'); 54 | final asset = response.data as Map; 55 | return asset['assetId'] != null; 56 | } catch (e) { 57 | return false; 58 | } 59 | } 60 | 61 | static String? _getFuelExplorerApiUrl(String network) { 62 | if (network.contains('mainnet')) { 63 | return 'https://mainnet-explorer.fuel.network'; 64 | } 65 | if (network.contains('testnet')) { 66 | return 'https://explorer-indexer-testnet.fuel.network'; 67 | } 68 | return null; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /packages/flutter_fuels/test/model/fuel_address_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_fuels/model/fuel_address.dart'; 2 | import 'package:test/test.dart'; 3 | 4 | void main() { 5 | test('test conversion between b256 and bech32 formats', () async { 6 | final testCases = [ 7 | ( 8 | 'fuel1lcghw4e6gucsw4hj0me9cu3fkhdg65gf5ujck2tlywn8drrcedqq2htmt3', 9 | '0xfE1177573a47310756f27eF25c7229B5DA8d5109a7258b297F23a6768C78cB40' 10 | ), 11 | ( 12 | 'fuel1dn4ew2a5kn9datj34npuyz63lztjhhfw6mzw6q9vqdtgu2t9y23q3u0tdc', 13 | '0x6CEb972bB4b4Cadeae51acc3C20b51F8972bDD2eD6c4ED00AC03568e296522a2' 14 | ), 15 | ( 16 | 'fuel1xdqana80q7dk9lkh6puhzq5st4tzgd6mcdurr5ap5qv82vw9wp0qp4dm2l', 17 | '0x3341d9f4ef079B62fEd7d0797102905D5624375bc37831D3a1a0187531c5705E' 18 | ), 19 | ( 20 | 'fuel1dgd3dfyh6j343nc8dgzsmv4r7qfnp06vmf5hgtx2js2kanktkf9qs0d053', 21 | '0x6A1B16a497D4A358cF076A050DB2A3f01330Bf4cDA69742Cca94156EcEcbb24a' 22 | ), 23 | ( 24 | 'fuel1vag2u3u56q8pu8yh5n7v42xgue8em3uaq6gwpkhxfds7fmmt60esuyjmc7', 25 | '0x6750ae4794D00e1e1c97A4Fccaa8C8E64F9dC79d0690E0DAe64b61e4Ef6bD3f3' 26 | ), 27 | ( 28 | 'fuel14sqjvuhp48u58592lqu7nnp69zw4sgtrha4v0ndny37n8tv00hfqtewg4x', 29 | '0xAc012672E1A9f943D0AaF839e9cC3a289D582163Bf6ac7CDb3247D33AD8f7dD2' 30 | ), 31 | ( 32 | 'fuel12ycqpn8cmxzdqg7t36jxnxy8m03g6qjuscf5gsdcryhptuywlpps532nhl', 33 | '0x513000CcF8d984d023cb8EA4699887Dbe28D025C86134441B8192e15F08eF843' 34 | ), 35 | ( 36 | 'fuel1vr6t6mczqhm55sx7c2x7x5fcjv47763zenea2lx87tg7lh6r03aqdm6y8g', 37 | '0x60F4bd6f0205f74a40DEc28dE35138932bEf6a22cCF3d57cC7f2D1EFDF437C7A' 38 | ), 39 | ( 40 | 'fuel16pvyhnn89z54j7zunwsufa0lwvsc9lgaf93rk6rl20tpt0pflc3sg78jmj', 41 | '0xD0584Bce6728A959785c9bA1C4f5fF732182Fd1d49623b687f53D615bc29Fe23' 42 | ), 43 | ( 44 | 'fuel155m4f0jd3753nady659wkff9n040w6aqtlsn6dkh30qawyjmp6rqdcqq53', 45 | '0xa53754be4d8fa919f5A4d50aeB25259BEAf76BA05fe13d36d78bC1d7125b0e86' 46 | ), 47 | ]; 48 | for (final (bech, b256) in testCases) { 49 | final fromBech = FuelAddress.fromString(bech); 50 | final fromB256 = FuelAddress.fromString(b256); 51 | final fromB256WithoutPrefix = FuelAddress.fromString(b256.substring(2)); 52 | expect(fromBech, fromB256); 53 | expect(fromB256, fromB256WithoutPrefix); 54 | expect(fromBech.bech32Address, bech); 55 | expect(fromBech.b256Address, b256); 56 | expect(fromB256.bech32Address, bech); 57 | expect(fromB256.b256Address, b256); 58 | expect(fromB256WithoutPrefix.bech32Address, bech); 59 | expect(fromB256WithoutPrefix.b256Address, b256); 60 | } 61 | }); 62 | } 63 | -------------------------------------------------------------------------------- /packages/fuels/test/features/wallet_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:fuels/fuels.dart'; 2 | import 'package:test/test.dart'; 3 | 4 | import '../test_utils.dart'; 5 | 6 | const _firstAccountDerivationPath = "m/44'/1179993420'/0'/0/0"; 7 | const _secondAccountDerivationPath = "m/44'/1179993420'/1'/0/0"; 8 | const _thirdAccountDerivationPath = "m/44'/1179993420'/2'/0/0"; 9 | 10 | void main() { 11 | test('test create a random wallet', () async { 12 | WalletUnlocked wallet = await createRandomWallet(); 13 | expect(wallet.b256Address.isNotEmpty, true); 14 | }); 15 | 16 | test('test import wallet with private key', () async { 17 | WalletUnlocked wallet = await importWalletWithPK(testWalletPrivateKey); 18 | expect(testWalletAddress, wallet.b256Address); 19 | }); 20 | 21 | test('test import wallet with mnemonics', () async { 22 | WalletUnlocked wallet = 23 | await importWalletWithMnemonics(testWalletSeedPhrase); 24 | expect(testWalletAddress, wallet.b256Address); 25 | }); 26 | 27 | test('test recreate wallet', () async { 28 | WalletUnlocked wallet = await createRandomWallet(); 29 | WalletUnlocked recreated = await importWalletWithPK(wallet.privateKey); 30 | expect(recreated.b256Address, wallet.b256Address); 31 | expect(recreated.privateKey, wallet.privateKey); 32 | }); 33 | 34 | test('test derive wallets from seed phrase', () async { 35 | WalletUnlocked first = await importWalletWithMnemonicsAndPath( 36 | testWalletSeedPhrase, _firstAccountDerivationPath); 37 | WalletUnlocked second = await importWalletWithMnemonicsAndPath( 38 | testWalletSeedPhrase, _secondAccountDerivationPath); 39 | WalletUnlocked third = await importWalletWithMnemonicsAndPath( 40 | testWalletSeedPhrase, _thirdAccountDerivationPath); 41 | 42 | expect(testWalletAddress, first.b256Address); 43 | expect('0b3a23496d1cd2c5be150c8af12566b2dc90c3e0fadd84df8158071f5faf87cd', 44 | second.b256Address); 45 | expect('3d65066a7e28b5bfdd6291debcdcd13ab57e7379beff998f10e9cad813521548', 46 | third.b256Address); 47 | }); 48 | 49 | test('test is user account', () async { 50 | Provider provider = createProvider(); 51 | 52 | expect(true, await provider.isUserAccount(address: testWalletAddress)); 53 | expect( 54 | true, 55 | await provider.isUserAccount( 56 | address: 57 | '0x0B3A23496D1CD2c5Be150c8aF12566B2dc90c3e0FadD84df8158071F5FaF87Cd')); 58 | // address of a deployed contract on testnet 59 | expect( 60 | false, 61 | await provider.isUserAccount( 62 | address: 63 | '0xb942Cd8440A4Fe2E2E7548CFcB1D1547881CfE02DB66a463b19E1E46Ae56F0CA')); 64 | // hash of a transaction on testnet 65 | expect( 66 | false, 67 | await provider.isUserAccount( 68 | address: 69 | '0x14ad1d2168f25ebc6b73a0ab83af2055acf8ac12bf1a953e754219d03f0885fd')); 70 | }); 71 | } 72 | -------------------------------------------------------------------------------- /packages/fuels/native/src/model/receipt.rs: -------------------------------------------------------------------------------- 1 | pub enum Receipt { 2 | Call { 3 | to: String, 4 | amount: u64, 5 | asset_id: String, 6 | }, 7 | 8 | // return is a keyword in dart, so we use ReturnReceipt instead 9 | ReturnReceipt, 10 | 11 | ReturnData, 12 | 13 | Panic, 14 | 15 | Revert, 16 | 17 | Log, 18 | 19 | LogData, 20 | 21 | Transfer { 22 | from: String, 23 | to: String, 24 | amount: u64, 25 | asset_id: String, 26 | }, 27 | 28 | TransferOut { 29 | from: String, 30 | to: String, 31 | amount: u64, 32 | asset_id: String, 33 | }, 34 | 35 | ScriptResult { 36 | gas_used: u64, 37 | }, 38 | 39 | MessageOut { 40 | sender: String, 41 | recipient: String, 42 | amount: u64, 43 | }, 44 | 45 | Mint { 46 | sub_id: String, 47 | contract_id: String, 48 | }, 49 | 50 | Burn { 51 | sub_id: String, 52 | contract_id: String, 53 | }, 54 | } 55 | 56 | impl From<&fuels::prelude::Receipt> for Receipt { 57 | fn from(model: &fuels::prelude::Receipt) -> Self { 58 | match model { 59 | fuels::prelude::Receipt::Call { id: _, to, amount, asset_id, gas: _, param1: _, param2: _, pc: _, is: _ } => { Receipt::Call { to: to.to_string(), amount: *amount, asset_id: asset_id.to_string() } } 60 | fuels::prelude::Receipt::Return { .. } => { Receipt::ReturnReceipt } 61 | fuels::prelude::Receipt::ReturnData { .. } => { Receipt::ReturnData } 62 | fuels::prelude::Receipt::Panic { .. } => { Receipt::Panic } 63 | fuels::prelude::Receipt::Revert { .. } => { Receipt::Revert } 64 | fuels::prelude::Receipt::Log { .. } => { Receipt::Log } 65 | fuels::prelude::Receipt::LogData { .. } => { Receipt::LogData } 66 | fuels::prelude::Receipt::Transfer { id, to, amount, asset_id, pc: _, is: _ } => { Receipt::Transfer { from: id.to_string(), to: to.to_string(), amount: *amount, asset_id: asset_id.to_string() } } 67 | fuels::prelude::Receipt::TransferOut { id, to, amount, asset_id, pc: _, is: _ } => { Receipt::TransferOut { from: id.to_string(), to: to.to_string(), amount: *amount, asset_id: asset_id.to_string() } } 68 | fuels::prelude::Receipt::ScriptResult { result: _, gas_used } => { Receipt::ScriptResult { gas_used: *gas_used } } 69 | fuels::prelude::Receipt::MessageOut { sender, recipient, amount, nonce: _, len: _, digest: _, data: _ } => { Receipt::MessageOut { sender: sender.to_string(), recipient: recipient.to_string(), amount: *amount } } 70 | fuels::prelude::Receipt::Mint { sub_id, contract_id, val: _, pc: _, is: _ } => { Receipt::Mint { sub_id: sub_id.to_string(), contract_id: contract_id.to_string() } } 71 | fuels::prelude::Receipt::Burn { sub_id, contract_id, val: _, pc: _, is: _ } => { Receipt::Burn { sub_id: sub_id.to_string(), contract_id: contract_id.to_string() } } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/model/transaction.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_fuels/model/input.dart'; 2 | import 'package:flutter_fuels/model/output.dart'; 3 | import 'package:flutter_fuels/model/storage_slot.dart'; 4 | import 'package:flutter_fuels/model/witness.dart'; 5 | 6 | abstract class Transaction { 7 | const Transaction(); 8 | 9 | static Transaction fromJson(Map jsonTransaction) { 10 | try { 11 | int txType = jsonTransaction['type']; 12 | switch (txType) { 13 | case 0: 14 | return TransactionScript.fromJson(jsonTransaction); 15 | case 1: 16 | return TransactionCreate.fromJson(jsonTransaction); 17 | case 2: 18 | return TransactionMint.fromJson(jsonTransaction); 19 | default: 20 | return UnknownTransaction(raw: jsonTransaction); 21 | } 22 | } catch (e) { 23 | return UnparsedTransaction(raw: jsonTransaction, err: e); 24 | } 25 | } 26 | } 27 | 28 | class UnknownTransaction extends Transaction { 29 | final Map raw; 30 | 31 | const UnknownTransaction({required this.raw}); 32 | } 33 | 34 | class UnparsedTransaction extends Transaction { 35 | final Map raw; 36 | final dynamic err; 37 | 38 | const UnparsedTransaction({required this.raw, required this.err}); 39 | } 40 | 41 | class TransactionScript extends Transaction { 42 | final List inputs; 43 | final List outputs; 44 | final List witnesses; 45 | 46 | const TransactionScript( 47 | {required this.inputs, required this.outputs, required this.witnesses}); 48 | 49 | factory TransactionScript.fromJson(Map data) { 50 | return TransactionScript( 51 | inputs: _parseInputs(data), 52 | outputs: _parseOutputs(data), 53 | witnesses: _parseWitnesses(data)); 54 | } 55 | } 56 | 57 | class TransactionCreate extends Transaction { 58 | final List inputs; 59 | final List outputs; 60 | final List witnesses; 61 | 62 | const TransactionCreate( 63 | {required this.inputs, required this.outputs, required this.witnesses}); 64 | 65 | factory TransactionCreate.fromJson(Map data) { 66 | return TransactionCreate( 67 | inputs: _parseInputs(data), 68 | outputs: _parseOutputs(data), 69 | witnesses: _parseWitnesses(data)); 70 | } 71 | } 72 | 73 | class TransactionMint extends Transaction { 74 | final List outputs; 75 | 76 | const TransactionMint({required this.outputs}); 77 | 78 | factory TransactionMint.fromJson(Map data) { 79 | return TransactionMint(outputs: _parseOutputs(data)); 80 | } 81 | } 82 | 83 | List _parseInputs(Map jsonData) { 84 | List jsonInputs = jsonData['inputs']; 85 | return jsonInputs.map((e) => Input.fromJson(e)).toList(); 86 | } 87 | 88 | List _parseOutputs(Map jsonData) { 89 | List jsonOutputs = jsonData['outputs']; 90 | return jsonOutputs.map((e) => Output.fromJson(e)).toList(); 91 | } 92 | 93 | List _parseWitnesses(Map jsonData) { 94 | List jsonWitnesses = jsonData['witnesses']; 95 | return jsonWitnesses.map((e) => Witness.fromJson(e)).toList(); 96 | } 97 | 98 | List _parseStorageSlots(Map jsonData) { 99 | List jsonSlots = jsonData['storageSlots']; 100 | return jsonSlots.map((e) => StorageSlot.fromJson(e)).toList(); 101 | } 102 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /packages/flutter_fuels/lib/model/output.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_fuels/utils/hex_utils.dart'; 2 | import 'package:flutter_fuels/utils/json_utils.dart'; 3 | 4 | abstract class Output { 5 | const Output(); 6 | 7 | static Output fromJson(Map jsonOutput) { 8 | try { 9 | int outputType = jsonOutput['type']; 10 | switch (outputType) { 11 | case 0: 12 | return OutputCoin.fromJson(jsonOutput); 13 | case 1: 14 | return OutputContract.fromJson(jsonOutput); 15 | case 2: 16 | return OutputChange.fromJson(jsonOutput); 17 | case 3: 18 | return OutputVariable.fromJson(jsonOutput); 19 | case 4: 20 | return OutputContractCreated.fromJson(jsonOutput); 21 | default: 22 | return UnknownOutput(raw: jsonOutput); 23 | } 24 | } catch (e) { 25 | return UnparsedOutput(raw: jsonOutput, err: e); 26 | } 27 | } 28 | } 29 | 30 | class UnknownOutput extends Output { 31 | final Map raw; 32 | 33 | const UnknownOutput({required this.raw}); 34 | } 35 | 36 | class UnparsedOutput extends Output { 37 | final Map raw; 38 | final dynamic err; 39 | 40 | const UnparsedOutput({required this.raw, required this.err}); 41 | } 42 | 43 | class OutputCoin extends Output { 44 | final String to; 45 | final BigInt amount; 46 | final String assetId; 47 | 48 | const OutputCoin( 49 | {required this.to, required this.amount, required this.assetId}); 50 | 51 | factory OutputCoin.fromJson(Map data) { 52 | return OutputCoin( 53 | to: addHexPrefix(data['to']), 54 | amount: parseBigInt(data['amount']), 55 | assetId: addHexPrefix(data['assetId']), 56 | ); 57 | } 58 | } 59 | 60 | class OutputContract extends Output { 61 | final int inputIndex; 62 | 63 | const OutputContract({required this.inputIndex}); 64 | 65 | factory OutputContract.fromJson(Map data) { 66 | return OutputContract( 67 | inputIndex: data['inputIndex'], 68 | ); 69 | } 70 | } 71 | 72 | class OutputChange extends Output { 73 | final String to; 74 | final BigInt? amount; 75 | final String assetId; 76 | 77 | const OutputChange( 78 | {required this.to, required this.amount, required this.assetId}); 79 | 80 | factory OutputChange.fromJson(Map data) { 81 | return OutputChange( 82 | to: addHexPrefix(data['to']), 83 | amount: data['amount'] == null ? null : parseBigInt(data['amount']), 84 | assetId: addHexPrefix(data['assetId'])); 85 | } 86 | } 87 | 88 | class OutputVariable extends Output { 89 | final String? to; 90 | final BigInt? amount; 91 | final String? assetId; 92 | 93 | const OutputVariable( 94 | {required this.to, required this.amount, required this.assetId}); 95 | 96 | factory OutputVariable.fromJson(Map data) { 97 | return OutputVariable( 98 | to: data['to'] == null ? null : addHexPrefix(data['to']), 99 | amount: data['amount'] == null ? null : parseBigInt(data['amount']), 100 | assetId: 101 | data['assetId'] == null ? null : addHexPrefix(data['assetId'])); 102 | } 103 | } 104 | 105 | class OutputContractCreated extends Output { 106 | final String contractId; 107 | 108 | const OutputContractCreated({required this.contractId}); 109 | 110 | factory OutputContractCreated.fromJson(Map data) { 111 | return OutputContractCreated(contractId: addHexPrefix(data['contractId'])); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.fuelet" "\0" 93 | VALUE "FileDescription", "flutter_fuels_example" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "flutter_fuels_example" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2023 com.fuelet. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "flutter_fuels_example.exe" "\0" 98 | VALUE "ProductName", "flutter_fuels_example" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates and shows a win32 window with |title| and position and size using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # === Flutter Library === 14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 15 | 16 | # Published to parent scope for install step. 17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 21 | 22 | list(APPEND FLUTTER_LIBRARY_HEADERS 23 | "flutter_export.h" 24 | "flutter_windows.h" 25 | "flutter_messenger.h" 26 | "flutter_plugin_registrar.h" 27 | "flutter_texture_registrar.h" 28 | ) 29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 30 | add_library(flutter INTERFACE) 31 | target_include_directories(flutter INTERFACE 32 | "${EPHEMERAL_DIR}" 33 | ) 34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 35 | add_dependencies(flutter flutter_assemble) 36 | 37 | # === Wrapper === 38 | list(APPEND CPP_WRAPPER_SOURCES_CORE 39 | "core_implementations.cc" 40 | "standard_codec.cc" 41 | ) 42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 44 | "plugin_registrar.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_APP 48 | "flutter_engine.cc" 49 | "flutter_view_controller.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 52 | 53 | # Wrapper sources needed for a plugin. 54 | add_library(flutter_wrapper_plugin STATIC 55 | ${CPP_WRAPPER_SOURCES_CORE} 56 | ${CPP_WRAPPER_SOURCES_PLUGIN} 57 | ) 58 | apply_standard_settings(flutter_wrapper_plugin) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | POSITION_INDEPENDENT_CODE ON) 61 | set_target_properties(flutter_wrapper_plugin PROPERTIES 62 | CXX_VISIBILITY_PRESET hidden) 63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 64 | target_include_directories(flutter_wrapper_plugin PUBLIC 65 | "${WRAPPER_ROOT}/include" 66 | ) 67 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 68 | 69 | # Wrapper sources needed for the runner. 70 | add_library(flutter_wrapper_app STATIC 71 | ${CPP_WRAPPER_SOURCES_CORE} 72 | ${CPP_WRAPPER_SOURCES_APP} 73 | ) 74 | apply_standard_settings(flutter_wrapper_app) 75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 76 | target_include_directories(flutter_wrapper_app PUBLIC 77 | "${WRAPPER_ROOT}/include" 78 | ) 79 | add_dependencies(flutter_wrapper_app flutter_assemble) 80 | 81 | # === Flutter tool backend === 82 | # _phony_ is a non-existent file to force this command to run every time, 83 | # since currently there's no way to get a full input/output list from the 84 | # flutter tool. 85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 87 | add_custom_command( 88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 90 | ${CPP_WRAPPER_SOURCES_APP} 91 | ${PHONY_OUTPUT} 92 | COMMAND ${CMAKE_COMMAND} -E env 93 | ${FLUTTER_TOOL_ENVIRONMENT} 94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 95 | windows-x64 $ 96 | VERBATIM 97 | ) 98 | add_custom_target(flutter_assemble DEPENDS 99 | "${FLUTTER_LIBRARY}" 100 | ${FLUTTER_LIBRARY_HEADERS} 101 | ${CPP_WRAPPER_SOURCES_CORE} 102 | ${CPP_WRAPPER_SOURCES_PLUGIN} 103 | ${CPP_WRAPPER_SOURCES_APP} 104 | ) 105 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # TODO change the below options/lints as you see fit 2 | analyzer: 3 | exclude: 4 | - '**.freezed.dart' 5 | - '**.g.dart' 6 | language: 7 | strict-inference: true 8 | strict-raw-types: true 9 | errors: 10 | invalid_annotation_target: ignore 11 | 12 | linter: 13 | rules: 14 | # Custom lints 15 | - prefer_single_quotes 16 | 17 | # Core Dart lints 18 | - avoid_empty_else 19 | - avoid_relative_lib_imports 20 | - avoid_shadowing_type_parameters 21 | - avoid_types_as_parameter_names 22 | - await_only_futures 23 | - camel_case_extensions 24 | - camel_case_types 25 | - curly_braces_in_flow_control_structures 26 | - depend_on_referenced_packages 27 | - empty_catches 28 | - file_names 29 | - hash_and_equals 30 | - iterable_contains_unrelated_type 31 | - list_remove_unrelated_type 32 | - no_duplicate_case_values 33 | - non_constant_identifier_names 34 | - null_check_on_nullable_type_parameter 35 | - package_prefixed_library_names 36 | - prefer_generic_function_type_aliases 37 | - prefer_is_empty 38 | - prefer_is_not_empty 39 | - prefer_iterable_whereType 40 | - prefer_typing_uninitialized_variables 41 | - provide_deprecation_message 42 | - unnecessary_overrides 43 | - unrelated_type_equality_checks 44 | - valid_regexps 45 | - void_checks 46 | 47 | # Recommended Dart lints 48 | - always_require_non_null_named_parameters 49 | - annotate_overrides 50 | - avoid_function_literals_in_foreach_calls 51 | - avoid_init_to_null 52 | - avoid_null_checks_in_equality_operators 53 | - avoid_renaming_method_parameters 54 | - avoid_return_types_on_setters 55 | - avoid_returning_null_for_void 56 | - avoid_single_cascade_in_expression_statements 57 | - constant_identifier_names 58 | - control_flow_in_finally 59 | - empty_constructor_bodies 60 | - empty_statements 61 | - exhaustive_cases 62 | - implementation_imports 63 | - library_names 64 | - library_prefixes 65 | - library_private_types_in_public_api 66 | - no_leading_underscores_for_library_prefixes 67 | - no_leading_underscores_for_local_identifiers 68 | - null_closures 69 | - overridden_fields 70 | - package_names 71 | - prefer_adjacent_string_concatenation 72 | - prefer_collection_literals 73 | - prefer_conditional_assignment 74 | - prefer_contains 75 | - prefer_equal_for_default_values 76 | - prefer_final_fields 77 | - prefer_for_elements_to_map_fromIterable 78 | - prefer_function_declarations_over_variables 79 | - prefer_if_null_operators 80 | - prefer_initializing_formals 81 | - prefer_inlined_adds 82 | - prefer_interpolation_to_compose_strings 83 | - prefer_is_not_operator 84 | - prefer_null_aware_operators 85 | - prefer_spread_collections 86 | - prefer_void_to_null 87 | - recursive_getters 88 | - slash_for_doc_comments 89 | - type_init_formals 90 | - unnecessary_brace_in_string_interps 91 | - unnecessary_const 92 | - unnecessary_constructor_name 93 | - unnecessary_getters_setters 94 | - unnecessary_late 95 | - unnecessary_new 96 | - unnecessary_null_aware_assignments 97 | - unnecessary_null_in_if_null_operators 98 | - unnecessary_nullable_for_final_variable_declarations 99 | - unnecessary_string_escapes 100 | - unnecessary_string_interpolations 101 | - unnecessary_this 102 | - use_function_type_syntax_for_parameters 103 | - use_rethrow_when_possible 104 | 105 | # Flutter lints 106 | - avoid_print 107 | - avoid_unnecessary_containers 108 | - avoid_web_libraries_in_flutter 109 | - no_logic_in_create_state 110 | - prefer_const_constructors 111 | - prefer_const_constructors_in_immutables 112 | - prefer_const_declarations 113 | - prefer_const_literals_to_create_immutables 114 | - sized_box_for_whitespace 115 | - sort_child_properties_last 116 | - use_build_context_synchronously 117 | - use_full_hex_values_for_flutter_colors 118 | - use_key_in_widget_constructors 119 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "flutter_fuels_example"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "flutter_fuels_example"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /packages/flutter_fuels/example/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(flutter_fuels_example LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "flutter_fuels_example") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(SET CMP0063 NEW) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | # Generated plugin build rules, which manage building the plugins and adding 56 | # them to the application. 57 | include(flutter/generated_plugins.cmake) 58 | 59 | 60 | # === Installation === 61 | # Support files are copied into place next to the executable, so that it can 62 | # run in place. This is done instead of making a separate bundle (as on Linux) 63 | # so that building and running from within Visual Studio will work. 64 | set(BUILD_BUNDLE_DIR "$") 65 | # Make the "install" step default, as it's required to run. 66 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 67 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 68 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 69 | endif() 70 | 71 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 72 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 73 | 74 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 75 | COMPONENT Runtime) 76 | 77 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 78 | COMPONENT Runtime) 79 | 80 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 81 | COMPONENT Runtime) 82 | 83 | if(PLUGIN_BUNDLED_LIBRARIES) 84 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 85 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 86 | COMPONENT Runtime) 87 | endif() 88 | 89 | # Fully re-copy the assets directory on each build to avoid having stale files 90 | # from a previous install. 91 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 92 | install(CODE " 93 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 94 | " COMPONENT Runtime) 95 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 96 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 97 | 98 | # Install the AOT library on non-Debug builds only. 99 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 100 | CONFIGURATIONS Profile;Release 101 | COMPONENT Runtime) 102 | -------------------------------------------------------------------------------- /packages/fuels/native/src/api.rs: -------------------------------------------------------------------------------- 1 | #![allow(dead_code)] 2 | 3 | use std::str::FromStr; 4 | 5 | use fuel_crypto::SecretKey; 6 | use fuels::prelude::TxPolicies; 7 | pub use fuels::prelude::{Address, Provider as NativeProvider, Wallet as NativeWallet}; 8 | use fuels_accounts::signers::private_key::PrivateKeySigner; 9 | use fuels_accounts::wallet::Unlocked; 10 | 11 | use crate::features::{crypto, transaction, wallet}; 12 | use crate::model::receipt::Receipt; 13 | use crate::model::transaction::{Transaction, TransactionCost}; 14 | 15 | async fn get_native_provider(node_url: &String) -> NativeProvider { 16 | NativeProvider::connect(node_url).await.unwrap() 17 | } 18 | 19 | pub struct WalletUnlocked { 20 | pub private_key: String, 21 | // Is present only when the wallet is created using a mnemonic phrase 22 | pub mnemonic_phrase: Option, 23 | pub node_url: String, 24 | pub b256_address: String, 25 | } 26 | 27 | impl WalletUnlocked { 28 | async fn get_native_wallet_unlocked(&self) -> NativeWallet> { 29 | let secret_key = SecretKey::from_str(self.private_key.as_str()).unwrap(); 30 | let native_provider = get_native_provider(&self.node_url).await; 31 | let signer = PrivateKeySigner::new(secret_key); 32 | NativeWallet::new(signer, native_provider) 33 | } 34 | 35 | pub fn new_random(node_url: String) -> WalletUnlocked { 36 | wallet::new_random(node_url).unwrap() 37 | } 38 | 39 | pub fn new_from_private_key(private_key: String, node_url: String) -> WalletUnlocked { 40 | wallet::new_from_private_key(private_key, node_url).unwrap() 41 | } 42 | 43 | pub fn new_from_mnemonic_phrase(phrase: String, node_url: String) -> WalletUnlocked { 44 | wallet::new_from_mnemonic_phrase(phrase, node_url).unwrap() 45 | } 46 | 47 | pub fn new_from_mnemonic_phrase_with_path(phrase: String, path: String, node_url: String) -> WalletUnlocked { 48 | wallet::new_from_mnemonic_phrase_with_path(phrase, path, node_url).unwrap() 49 | } 50 | 51 | #[tokio::main] 52 | pub async fn gen_transfer_tx_request( 53 | &self, 54 | to: String, 55 | amount: u64, 56 | asset: String, 57 | ) -> (Vec, Vec) { 58 | let native_wallet_unlocked = self.get_native_wallet_unlocked().await; 59 | transaction::gen_transfer_tx_request(&native_wallet_unlocked, &Address::from_str(to.as_str()).unwrap(), amount, asset, TxPolicies::default()).await.unwrap() 60 | } 61 | 62 | #[tokio::main] 63 | pub async fn send_transaction( 64 | &self, 65 | encoded_tx: Vec, 66 | ) -> String { 67 | let native_wallet_unlocked = self.get_native_wallet_unlocked().await; 68 | transaction::send_transaction(&native_wallet_unlocked, encoded_tx).await.unwrap() 69 | } 70 | 71 | #[tokio::main] 72 | pub async fn simulate_transaction( 73 | &self, 74 | encoded_tx: Vec, 75 | ) -> Vec { 76 | let native_wallet_unlocked = self.get_native_wallet_unlocked().await; 77 | let fuel_receipts = transaction::simulate_transaction(&native_wallet_unlocked, encoded_tx).await.unwrap(); 78 | fuel_receipts.into_iter().map(|receipt| (&receipt).into()).collect() 79 | } 80 | 81 | #[tokio::main] 82 | pub async fn sign_message( 83 | &self, 84 | message: String, 85 | ) -> String { 86 | let native_wallet_unlocked = self.get_native_wallet_unlocked().await; 87 | crypto::sign_message(&native_wallet_unlocked, message).await.unwrap() 88 | } 89 | } 90 | 91 | // Cannot move to another file, cause the methods won't be accessible in that case 92 | pub struct Provider { 93 | pub node_url: String, 94 | } 95 | 96 | impl Provider { 97 | #[tokio::main] 98 | pub async fn estimate_transaction_cost( 99 | &self, 100 | encoded_tx: Vec, 101 | ) -> TransactionCost { 102 | let native_provider = get_native_provider(&self.node_url).await; 103 | transaction::estimate_transaction_cost(&native_provider, encoded_tx, None, None).await.unwrap().into() 104 | } 105 | 106 | #[tokio::main] 107 | pub async fn is_user_account( 108 | &self, 109 | address: String, 110 | ) -> bool { 111 | let native_provider = get_native_provider(&self.node_url).await; 112 | wallet::is_user_account(&native_provider, Address::from_str(address.as_str()).unwrap()).await 113 | } 114 | } 115 | 116 | #[tokio::main] 117 | pub async fn transform_tx_request( 118 | encoded_tx: Vec, 119 | ) -> Transaction { 120 | (&transaction::transform_tx_request(encoded_tx).await.unwrap()).into() 121 | } 122 | --------------------------------------------------------------------------------