diff --git a/.github/workflows/android-release.yml b/.github/workflows/android-release.yml index 94e849b..3eaaeb6 100644 --- a/.github/workflows/android-release.yml +++ b/.github/workflows/android-release.yml @@ -36,7 +36,7 @@ on: contents: write env: - FLUTTER_VERSION: '3.24.0' + FLUTTER_VERSION: '3.35.5' jobs: build-android: diff --git a/.github/workflows/flutter-desktop.yml b/.github/workflows/flutter-desktop.yml index 99c8715..45f94e7 100644 --- a/.github/workflows/flutter-desktop.yml +++ b/.github/workflows/flutter-desktop.yml @@ -38,14 +38,29 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Cache Flutter SDK + uses: actions/cache@v4 + with: + path: ~/flutter + key: ${{ runner.os }}-flutter-sdk-${{ hashFiles('**/pubspec.lock') }} + restore-keys: | + ${{ runner.os }}-flutter-sdk- + - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: '3.24.0' + flutter-version: '3.35.5' channel: 'stable' + cache: true - - name: Enable macOS desktop support - run: flutter config --enable-macos-desktop + - name: Install macOS dependencies + run: | + # Install Xcode command line tools + sudo xcode-select --install || true + # Install CocoaPods + sudo gem install cocoapods + # Enable macOS desktop support + flutter config --enable-macos-desktop - name: Download xfg-stark-cli run: | @@ -53,12 +68,55 @@ jobs: chmod +x xfg-stark-cli-macos mkdir -p assets/bin mv xfg-stark-cli-macos assets/bin/ + # Verify download + if [ ! -f "assets/bin/xfg-stark-cli-macos" ]; then + echo "Failed to download xfg-stark-cli for macOS" + exit 1 + fi + echo "xfg-stark-cli downloaded successfully" + + - name: Clean previous builds + run: flutter clean + + - name: Cache Flutter dependencies + uses: actions/cache@v4 + with: + path: | + ~/.pub-cache + **/.packages + **/.flutter-plugins + **/.flutter-plugins-dependencies + **/.dart_tool/package_config.json + key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }} + restore-keys: | + ${{ runner.os }}-flutter- - name: Install dependencies run: flutter pub get + - name: Validate Flutter setup + run: | + flutter doctor -v + flutter analyze + + - name: Verify assets + run: | + if [ ! -d "assets/bin" ]; then + echo "Assets directory not found" + exit 1 + fi + echo "Assets directory verified" + - name: Build macOS desktop app - run: flutter build macos --release + run: timeout 1800 flutter build macos --release + + - name: Verify macOS build + run: | + if [ ! -d "build/macos/Build/Products/Release/fuego_wallet.app" ]; then + echo "macOS build failed - app bundle not found" + exit 1 + fi + echo "macOS build successful" - name: Create app archive run: | @@ -88,11 +146,20 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Cache Flutter SDK + uses: actions/cache@v4 + with: + path: ~/flutter + key: ${{ runner.os }}-flutter-sdk-${{ hashFiles('**/pubspec.lock') }} + restore-keys: | + ${{ runner.os }}-flutter-sdk- + - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: '3.24.0' + flutter-version: '3.35.5' channel: 'stable' + cache: true - name: Enable Windows desktop support run: flutter config --enable-windows-desktop @@ -102,12 +169,66 @@ jobs: curl -L -o xfg-stark-cli-windows.exe "https://github.com/ColinRitman/xfgwin/releases/download/v0.8.8/xfg-stark-cli-windows.exe" New-Item -ItemType Directory -Force -Path assets\bin Move-Item xfg-stark-cli-windows.exe assets\bin\xfg-stark-cli.exe + # Verify download + if (-not (Test-Path "assets\bin\xfg-stark-cli.exe")) { + Write-Error "Failed to download xfg-stark-cli for Windows" + exit 1 + } + Write-Host "xfg-stark-cli downloaded successfully" + + - name: Clean previous builds + run: flutter clean + + - name: Cache Flutter dependencies + uses: actions/cache@v4 + with: + path: | + ~/.pub-cache + **/.packages + **/.flutter-plugins + **/.flutter-plugins-dependencies + **/.dart_tool/package_config.json + key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }} + restore-keys: | + ${{ runner.os }}-flutter- - name: Install dependencies run: flutter pub get + - name: Validate Flutter setup + run: | + flutter doctor -v + flutter analyze + + - name: Verify assets + run: | + if [ ! -d "assets/bin" ]; then + echo "Assets directory not found" + exit 1 + fi + echo "Assets directory verified" + - name: Build Windows desktop app - run: flutter build windows --release + run: | + $timeout = 1800 + $job = Start-Job -ScriptBlock { flutter build windows --release } + $job | Wait-Job -Timeout $timeout + if ($job.State -eq "Running") { + Stop-Job $job + Remove-Job $job + Write-Error "Build timed out after $timeout seconds" + exit 1 + } + Receive-Job $job + Remove-Job $job + + - name: Verify Windows build + run: | + if (-not (Test-Path "build\windows\runner\Release\fuego_wallet.exe") -and -not (Test-Path "build\windows\x64\runner\Release\fuego_wallet.exe")) { + Write-Error "Windows build failed - executable not found" + exit 1 + } + Write-Host "Windows build successful" - name: Create app archive run: | @@ -137,18 +258,27 @@ jobs: files: Fuego-Wallet-Windows.zip build-linux-compat: - name: Build XF₲ Wallet (Linux - GLIBC 2.35) + name: Build XF₲ Wallet (Linux - GLIBC 2.31) runs-on: ubuntu-22.04 steps: - name: Checkout code uses: actions/checkout@v4 + - name: Cache Flutter SDK + uses: actions/cache@v4 + with: + path: ~/flutter + key: ${{ runner.os }}-flutter-sdk-${{ hashFiles('**/pubspec.lock') }} + restore-keys: | + ${{ runner.os }}-flutter-sdk- + - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: '3.24.0' + flutter-version: '3.35.5' channel: 'stable' + cache: true - name: Download xfg-stark-cli run: | @@ -156,19 +286,60 @@ jobs: chmod +x xfg-stark-cli-linux mkdir -p assets/bin mv xfg-stark-cli-linux assets/bin/ + # Verify download + if [ ! -f "assets/bin/xfg-stark-cli-linux" ]; then + echo "Failed to download xfg-stark-cli for Linux" + exit 1 + fi + echo "xfg-stark-cli downloaded successfully" - name: Enable Linux desktop support run: | sudo apt-get update - sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libsecret-1-dev + sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libsecret-1-dev libblkid-dev libudev-dev flutter config --enable-linux-desktop + - name: Clean previous builds + run: flutter clean + + - name: Cache Flutter dependencies + uses: actions/cache@v4 + with: + path: | + ~/.pub-cache + **/.packages + **/.flutter-plugins + **/.flutter-plugins-dependencies + **/.dart_tool/package_config.json + key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }} + restore-keys: | + ${{ runner.os }}-flutter- + - name: Install dependencies run: flutter pub get - - name: Build Linux desktop app (GLIBC 2.35) + - name: Validate Flutter setup + run: | + flutter doctor -v + flutter analyze + + - name: Verify assets run: | - flutter build linux --release + if [ ! -d "assets/bin" ]; then + echo "Assets directory not found" + exit 1 + fi + echo "Assets directory verified" + + - name: Build Linux desktop app (GLIBC 2.31) + run: | + timeout 1800 flutter build linux --release + # Verify build + if [ ! -f "build/linux/x64/release/bundle/fuego_wallet" ]; then + echo "Linux build failed - executable not found" + exit 1 + fi + echo "Linux build successful" # Create a portable build by copying required libraries cd build/linux/x64/release/bundle mkdir -p lib @@ -202,12 +373,14 @@ jobs: files: build/linux/x64/release/bundle/XF₲-Wallet-Linux-GLIBC-2.31.tar.gz name: XF₲-Wallet-Linux-GLIBC-2.31.tar.gz - - name: Create AppImage (GLIBC 2.35) + - name: Create AppImage (GLIBC 2.31) run: | cd build/linux/x64/release/bundle # Download appimagetool curl -LO https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage chmod +x appimagetool-x86_64.AppImage + # Copy icon file for AppImage + cp ../../../../../app_icon_256.png fuego_wallet.png # Create desktop file for AppImage cat > XF₲-Wallet.desktop << 'EOF' [Desktop Entry] @@ -218,27 +391,26 @@ jobs: Icon=fuego_wallet Categories=Finance; EOF - # Copy icon file - cp ../../../../../app_icon_256.png fuego_wallet.png # Create AppImage (using extraction to avoid FUSE) ./appimagetool-x86_64.AppImage --appimage-extract - ./squashfs-root/AppRun . XF₲-Wallet-Linux-GLIBC-2.35.AppImage + ./squashfs-root/AppRun . XF₲-Wallet-Linux-GLIBC-2.31.AppImage # Clean up rm -f appimagetool-x86_64.AppImage + rm -rf squashfs-root - name: Upload AppImage artifacts uses: actions/upload-artifact@v4 with: - name: xfg-wallet-linux-glibc-235-appimage - path: build/linux/x64/release/bundle/XF₲-Wallet-Linux-GLIBC-2.35.AppImage + name: xfg-wallet-linux-glibc-231-appimage + path: build/linux/x64/release/bundle/XF₲-Wallet-Linux-GLIBC-2.31.AppImage retention-days: 30 - name: Upload AppImage to Release if: github.event_name == 'release' uses: softprops/action-gh-release@v1 with: - files: build/linux/x64/release/bundle/XF₲-Wallet-Linux-GLIBC-2.35.AppImage - name: XF₲-Wallet-Linux-GLIBC-2.35.AppImage + files: build/linux/x64/release/bundle/XF₲-Wallet-Linux-GLIBC-2.31.AppImage + name: XF₲-Wallet-Linux-GLIBC-2.31.AppImage build-linux-latest: @@ -249,11 +421,20 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Cache Flutter SDK + uses: actions/cache@v4 + with: + path: ~/flutter + key: ${{ runner.os }}-flutter-sdk-${{ hashFiles('**/pubspec.lock') }} + restore-keys: | + ${{ runner.os }}-flutter-sdk- + - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: '3.24.0' + flutter-version: '3.35.5' channel: 'stable' + cache: true - name: Download xfg-stark-cli run: | @@ -261,18 +442,60 @@ jobs: chmod +x xfg-stark-cli-linux mkdir -p assets/bin mv xfg-stark-cli-linux assets/bin/ + # Verify download + if [ ! -f "assets/bin/xfg-stark-cli-linux" ]; then + echo "Failed to download xfg-stark-cli for Linux" + exit 1 + fi + echo "xfg-stark-cli downloaded successfully" - name: Enable Linux desktop support run: | sudo apt-get update - sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libsecret-1-dev + sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libsecret-1-dev libblkid-dev libudev-dev flutter config --enable-linux-desktop + - name: Clean previous builds + run: flutter clean + + - name: Cache Flutter dependencies + uses: actions/cache@v4 + with: + path: | + ~/.pub-cache + **/.packages + **/.flutter-plugins + **/.flutter-plugins-dependencies + **/.dart_tool/package_config.json + key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }} + restore-keys: | + ${{ runner.os }}-flutter- + - name: Install dependencies run: flutter pub get + - name: Validate Flutter setup + run: | + flutter doctor -v + flutter analyze + + - name: Verify assets + run: | + if [ ! -d "assets/bin" ]; then + echo "Assets directory not found" + exit 1 + fi + echo "Assets directory verified" + - name: Build Linux desktop app (Latest) - run: flutter build linux --release + run: | + timeout 1800 flutter build linux --release + # Verify build + if [ ! -f "build/linux/x64/release/bundle/fuego_wallet" ]; then + echo "Linux build failed - executable not found" + exit 1 + fi + echo "Linux build successful" - name: Create app archive run: | diff --git a/.github/workflows/xfg-wallet-desktop.yml b/.github/workflows/xfg-wallet-desktop.yml deleted file mode 100644 index 951baca..0000000 --- a/.github/workflows/xfg-wallet-desktop.yml +++ /dev/null @@ -1,295 +0,0 @@ -name: XF₲ Wallet Desktop Build & Release - -on: - push: - branches: [ main, master ] - paths: - - 'lib/**' - - 'android/**' - - 'ios/**' - - 'macos/**' - - 'windows/**' - - 'linux/**' - - 'pubspec.yaml' - - '.github/workflows/flutter-desktop.yml' - pull_request: - branches: [ main, master ] - paths: - - 'lib/**' - - 'android/**' - - 'ios/**' - - 'macos/**' - - 'windows/**' - - 'linux/**' - - 'pubspec.yaml' - - '.github/workflows/flutter-desktop.yml' - workflow_dispatch: - release: - types: [published] - permissions: - contents: write - -jobs: - build-macos: - name: Build XF₲ Wallet (macOS) - runs-on: macos-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Flutter - uses: subosito/flutter-action@v2 - with: - flutter-version: '3.24.0' - channel: 'stable' - - - name: Enable macOS desktop support - run: flutter config --enable-macos-desktop - - - name: Download xfg-stark-cli - run: | - curl -L -o xfg-stark-cli-macos "https://github.com/ColinRitman/xfgwin/releases/download/v0.8.8/xfg-stark-cli-macos" - chmod +x xfg-stark-cli-macos - mkdir -p assets/bin - mv xfg-stark-cli-macos assets/bin/ - - - name: Install dependencies - run: flutter pub get - - - name: Build macOS desktop app - run: flutter build macos --release - - - name: Create app archive - run: | - cd build/macos/Build/Products/Release - zip -r Fuego-Wallet-macOS.zip "fuego_wallet.app" - - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: fuego-wallet-macos - path: build/macos/Build/Products/Release/Fuego-Wallet-macOS.zip - retention-days: 30 - - - name: Upload to Release - if: github.event_name == 'release' - uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - files: build/macos/Build/Products/Release/Fuego-Wallet-macOS.zip - - build-windows: - name: Build XF₲ Wallet (Windows) - runs-on: windows-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Flutter - uses: subosito/flutter-action@v2 - with: - flutter-version: '3.24.0' - channel: 'stable' - - - name: Enable Windows desktop support - run: flutter config --enable-windows-desktop - - - name: Download xfg-stark-cli - run: | - curl -L -o xfg-stark-cli-windows.exe "https://github.com/ColinRitman/xfgwin/releases/download/v0.8.8/xfg-stark-cli-windows.exe" - New-Item -ItemType Directory -Force -Path assets\bin - Move-Item xfg-stark-cli-windows.exe assets\bin\xfg-stark-cli.exe - - - name: Install dependencies - run: flutter pub get - - - name: Build Windows desktop app - run: flutter build windows --release - - - name: Create app archive - run: | - if (Test-Path "build\windows\runner\Release") { - cd build\windows\runner\Release - Compress-Archive -Path * -DestinationPath ..\..\..\..\Fuego-Wallet-Windows.zip - } elseif (Test-Path "build\windows\x64\runner\Release") { - cd build\windows\x64\runner\Release - Compress-Archive -Path * -DestinationPath ..\..\..\..\..\Fuego-Wallet-Windows.zip - } else { - Get-ChildItem build -Recurse | Where-Object { $_.Name -like "*.exe" } | Select-Object -First 1 | ForEach-Object { Compress-Archive -Path $_.DirectoryName -DestinationPath "Fuego-Wallet-Windows.zip" } - } - - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: fuego-wallet-windows - path: Fuego-Wallet-Windows.zip - retention-days: 30 - - - name: Upload to Release - if: github.event_name == 'release' - uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - files: Fuego-Wallet-Windows.zip - - build-linux-compat: - name: Build XF₲ Wallet (Linux - GLIBC 2.35) - runs-on: ubuntu-22.04 - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Flutter - uses: subosito/flutter-action@v2 - with: - flutter-version: '3.24.0' - channel: 'stable' - - - name: Download xfg-stark-cli - run: | - curl -L -o xfg-stark-cli-linux "https://github.com/ColinRitman/xfgwin/releases/download/v0.8.8/xfg-stark-cli-linux" - chmod +x xfg-stark-cli-linux - mkdir -p assets/bin - mv xfg-stark-cli-linux assets/bin/ - - - name: Enable Linux desktop support - run: | - sudo apt-get update - sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libsecret-1-dev - flutter config --enable-linux-desktop - - - name: Install dependencies - run: flutter pub get - - - name: Build Linux desktop app (GLIBC 2.35) - run: | - flutter build linux --release - # Create a portable build by copying required libraries - cd build/linux/x64/release/bundle - mkdir -p lib - # Copy system libraries for better compatibility - cp /lib/x86_64-linux-gnu/libc.so.6 lib/ 2>/dev/null || echo "libc.so.6 not found" - cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 lib/ 2>/dev/null || echo "libstdc++.so.6 not found" - # Create a wrapper script that uses bundled libraries - cat > run_xfg_wallet.sh << 'EOF' - #!/bin/bash - export LD_LIBRARY_PATH="$(dirname "$0")/lib:$LD_LIBRARY_PATH" - exec "$(dirname "$0")/fuego_wallet" "$@" - EOF - chmod +x run_xfg_wallet.sh - - - name: Create app archive - run: | - cd build/linux/x64/release/bundle - tar -czf XF₲-Wallet-Linux-GLIBC-2.31.tar.gz * - - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: xfg-wallet-linux-glibc-231 - path: build/linux/x64/release/bundle/XF₲-Wallet-Linux-GLIBC-2.31.tar.gz - retention-days: 30 - - - name: Upload to Release - if: github.event_name == 'release' - uses: softprops/action-gh-release@v1 - with: - files: build/linux/x64/release/bundle/XF₲-Wallet-Linux-GLIBC-2.31.tar.gz - name: XF₲-Wallet-Linux-GLIBC-2.31.tar.gz - - - name: Create AppImage (GLIBC 2.35) - run: | - cd build/linux/x64/release/bundle - # Download appimagetool - curl -LO https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage - chmod +x appimagetool-x86_64.AppImage - # Copy icon file for AppImage - cp ../../../../app_icon_256.png fuego_wallet.png - # Create AppImage (using extraction to avoid FUSE) - ./appimagetool-x86_64.AppImage --appimage-extract - # Create desktop file for AppImage - cat > XF₲-Wallet.desktop << 'EOF' - [Desktop Entry] - Type=Application - Name=XF₲ Wallet - Comment=Privacy-focused cryptocurrency wallet - Exec=fuego_wallet - Icon=fuego_wallet - Categories=Finance; EOF - ./squashfs-root/AppRun . XF₲-Wallet-Linux-GLIBC-2.35.AppImage - # Clean up - rm -f appimagetool-x86_64.AppImage - # Clean up extracted files - rm -rf squashfs-root - - - name: Upload AppImage artifacts - uses: actions/upload-artifact@v4 - with: - name: xfg-wallet-linux-glibc-235-appimage - path: build/linux/x64/release/bundle/XF₲-Wallet-Linux-GLIBC-2.35.AppImage - retention-days: 30 - - - name: Upload AppImage to Release - if: github.event_name == 'release' - uses: softprops/action-gh-release@v1 - with: - files: build/linux/x64/release/bundle/XF₲-Wallet-Linux-GLIBC-2.35.AppImage - name: XF₲-Wallet-Linux-GLIBC-2.35.AppImage - - - build-linux-latest: - name: Build XF₲ Wallet (Linux - Latest) - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Flutter - uses: subosito/flutter-action@v2 - with: - flutter-version: '3.24.0' - channel: 'stable' - - - name: Download xfg-stark-cli - run: | - curl -L -o xfg-stark-cli-linux "https://github.com/ColinRitman/xfgwin/releases/download/v0.8.8/xfg-stark-cli-linux" - chmod +x xfg-stark-cli-linux - mkdir -p assets/bin - mv xfg-stark-cli-linux assets/bin/ - - - name: Enable Linux desktop support - run: | - sudo apt-get update - sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libsecret-1-dev - flutter config --enable-linux-desktop - - - name: Install dependencies - run: flutter pub get - - - name: Build Linux desktop app (Latest) - run: flutter build linux --release - - - name: Create app archive - run: | - cd build/linux/x64/release/bundle - tar -czf XF₲-Wallet-Linux-Latest.tar.gz * - - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: xfg-wallet-linux-latest - path: build/linux/x64/release/bundle/XF₲-Wallet-Linux-Latest.tar.gz - retention-days: 30 - - - name: Upload to Release - if: github.event_name == 'release' - uses: softprops/action-gh-release@v1 - with: - files: build/linux/x64/release/bundle/XF₲-Wallet-Linux-Latest.tar.gz - name: XF₲-Wallet-Linux-Latest.tar.gz diff --git a/lib/main.dart b/lib/main.dart index 1d7fadd..1ee1f58 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -54,4 +54,7 @@ class XFGWalletApp extends StatelessWidget { ), ); } -} \ No newline at end of file +} + +// Alias for backward compatibility +typedef FuegoWalletApp = XFGWalletApp; \ No newline at end of file diff --git a/lib/models/transaction_model.dart b/lib/models/transaction_model.dart new file mode 100644 index 0000000..b56f7f0 --- /dev/null +++ b/lib/models/transaction_model.dart @@ -0,0 +1,92 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'transaction_model.g.dart'; + +@JsonSerializable() +class TransactionModel { + final String id; + final String fromAddress; + final String toAddress; + final double amount; + final String status; + final DateTime timestamp; + final String? transactionHash; + final bool isBurnTransaction; + final String? privateKey; + final DateTime? date; + + const TransactionModel({ + required this.id, + required this.fromAddress, + required this.toAddress, + required this.amount, + required this.status, + required this.timestamp, + this.transactionHash, + this.isBurnTransaction = false, + this.privateKey, + this.date, + }); + + factory TransactionModel.fromJson(Map json) => + _$TransactionModelFromJson(json); + + Map toJson() => _$TransactionModelToJson(this); + + TransactionModel copyWith({ + String? id, + String? fromAddress, + String? toAddress, + double? amount, + String? status, + DateTime? timestamp, + String? transactionHash, + bool? isBurnTransaction, + String? privateKey, + DateTime? date, + }) { + return TransactionModel( + id: id ?? this.id, + fromAddress: fromAddress ?? this.fromAddress, + toAddress: toAddress ?? this.toAddress, + amount: amount ?? this.amount, + status: status ?? this.status, + timestamp: timestamp ?? this.timestamp, + transactionHash: transactionHash ?? this.transactionHash, + isBurnTransaction: isBurnTransaction ?? this.isBurnTransaction, + privateKey: privateKey ?? this.privateKey, + date: date ?? this.date, + ); + } + + @override + String toString() { + return 'TransactionModel(id: $id, fromAddress: $fromAddress, toAddress: $toAddress, amount: $amount, status: $status, timestamp: $timestamp, transactionHash: $transactionHash, isBurnTransaction: $isBurnTransaction)'; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + return other is TransactionModel && + other.id == id && + other.fromAddress == fromAddress && + other.toAddress == toAddress && + other.amount == amount && + other.status == status && + other.timestamp == timestamp && + other.transactionHash == transactionHash && + other.isBurnTransaction == isBurnTransaction; + } + + @override + int get hashCode { + return id.hashCode ^ + fromAddress.hashCode ^ + toAddress.hashCode ^ + amount.hashCode ^ + status.hashCode ^ + timestamp.hashCode ^ + transactionHash.hashCode ^ + isBurnTransaction.hashCode; + } +} \ No newline at end of file diff --git a/lib/models/transaction_model.g.dart b/lib/models/transaction_model.g.dart new file mode 100644 index 0000000..28103c0 --- /dev/null +++ b/lib/models/transaction_model.g.dart @@ -0,0 +1,35 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'transaction_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +TransactionModel _$TransactionModelFromJson(Map json) => + TransactionModel( + id: json['id'] as String, + fromAddress: json['fromAddress'] as String, + toAddress: json['toAddress'] as String, + amount: (json['amount'] as num).toDouble(), + status: json['status'] as String, + timestamp: DateTime.parse(json['timestamp'] as String), + transactionHash: json['transactionHash'] as String?, + isBurnTransaction: json['isBurnTransaction'] as bool? ?? false, + privateKey: json['privateKey'] as String?, + date: json['date'] == null ? null : DateTime.parse(json['date'] as String), + ); + +Map _$TransactionModelToJson(TransactionModel instance) => + { + 'id': instance.id, + 'fromAddress': instance.fromAddress, + 'toAddress': instance.toAddress, + 'amount': instance.amount, + 'status': instance.status, + 'timestamp': instance.timestamp.toIso8601String(), + 'transactionHash': instance.transactionHash, + 'isBurnTransaction': instance.isBurnTransaction, + 'privateKey': instance.privateKey, + 'date': instance.date?.toIso8601String(), + }; \ No newline at end of file diff --git a/lib/screens/banking/banking_screen.dart b/lib/screens/banking/banking_screen.dart index 9334148..ae5a4c8 100644 --- a/lib/screens/banking/banking_screen.dart +++ b/lib/screens/banking/banking_screen.dart @@ -1,4 +1,4 @@ --import 'package:flutter/material.dart'; +import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../providers/wallet_provider.dart'; import '../../utils/theme.dart'; @@ -57,7 +57,7 @@ class _BankingScreenState extends State try { // Get wallet provider for private key - final walletProvider = Provider.of(context, listen: false); + // final walletProvider = Provider.of(context, listen: false); // For now, use a placeholder private key - in real implementation, // this would come from the wallet's private key @@ -65,16 +65,16 @@ class _BankingScreenState extends State const String recipientAddress = '0x0000000000000000000000000000000000000000'; // Generate STARK proof using CLI - final Map result = await CLIService.generateBurnProof( - privateKey: privateKey, - burnAmount: burnAmount, + final result = await CLIService.generateBurnProof( + transactionHash: 'placeholder_hash_${DateTime.now().millisecondsSinceEpoch}', + burnAmount: burnAmount.toInt(), recipientAddress: recipientAddress, ); // Close loading dialog Navigator.of(context).pop(); - if (result['success']) { + if (result.proofHash.isNotEmpty) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text('Successfully burned $burnAmount XFG to mint $heatAmount Ξmbers'), @@ -84,7 +84,7 @@ class _BankingScreenState extends State } else { ScaffoldMessenger.of(context).showSnackBar( SnackBar( - content: Text('Burn failed: ${result['error']}'), + content: Text('Burn failed: Unable to generate proof'), backgroundColor: Colors.red, ), ); diff --git a/lib/screens/banking/burn_deposits_screen.dart b/lib/screens/banking/burn_deposits_screen.dart index 185506f..378d4d5 100644 --- a/lib/screens/banking/burn_deposits_screen.dart +++ b/lib/screens/banking/burn_deposits_screen.dart @@ -28,7 +28,7 @@ class _BurnDepositsScreenState extends State { Future _fetchLastBurnTransaction() async { try { // Fetch the last burn transaction from wallet history - final List transactions = await WalletService.getTransactions(); + final List transactions = await WalletService.getTransactions('default_address'); final burnTransactions = transactions.where((tx) => tx.isBurnTransaction).toList(); if (burnTransactions.isNotEmpty) { @@ -75,7 +75,7 @@ class _BurnDepositsScreenState extends State { final int heatTokens = CLIService.calculateHeatTokens(burnAmount); // Use the last burn transaction's hash - final String transactionHash = _lastBurnTransaction!.hash; + final String transactionHash = _lastBurnTransaction!.transactionHash ?? 'default_hash'; // Generate burn proof final BurnProofResult proofResult = await CLIService.generateBurnProof( @@ -125,7 +125,7 @@ class _BurnDepositsScreenState extends State { style: TextStyle(fontWeight: FontWeight.bold), ), if (_lastBurnTransaction != null) ...[ - Text('Transaction Hash: ${_lastBurnTransaction!.hash}'), + Text('Transaction Hash: ${_lastBurnTransaction!.transactionHash ?? 'N/A'}'), Text('Amount: ${_lastBurnTransaction!.amount} XFG'), Text('Date: ${_lastBurnTransaction!.date}'), ], @@ -258,7 +258,7 @@ class _BurnDepositsScreenState extends State { style: TextStyle(fontWeight: FontWeight.bold), ), const SizedBox(height: 8), - Text('Hash: ${_lastBurnTransaction!.hash}'), + Text('Hash: ${_lastBurnTransaction!.transactionHash ?? 'N/A'}'), Text('Amount: ${_lastBurnTransaction!.amount} XFG'), Text('Date: ${_lastBurnTransaction!.date}'), ], diff --git a/lib/services/wallet_service.dart b/lib/services/wallet_service.dart new file mode 100644 index 0000000..d7ad597 --- /dev/null +++ b/lib/services/wallet_service.dart @@ -0,0 +1,130 @@ +import 'dart:convert'; +import 'package:flutter/foundation.dart'; +import 'package:http/http.dart' as http; +import '../models/wallet.dart'; +import '../models/transaction_model.dart'; + +class WalletService { + static const String _baseUrl = 'https://api.fuego.org'; + + /// Get wallet balance + static Future getBalance(String address) async { + try { + final response = await http.get( + Uri.parse('$_baseUrl/balance/$address'), + headers: {'Content-Type': 'application/json'}, + ); + + if (response.statusCode == 200) { + final data = json.decode(response.body); + return (data['balance'] as num).toDouble(); + } else { + throw Exception('Failed to get balance: ${response.statusCode}'); + } + } catch (e) { + if (kDebugMode) { + print('Error getting balance: $e'); + } + return 0.0; + } + } + + /// Send transaction + static Future> sendTransaction({ + required String fromAddress, + required String toAddress, + required double amount, + required String privateKey, + }) async { + try { + final response = await http.post( + Uri.parse('$_baseUrl/send'), + headers: {'Content-Type': 'application/json'}, + body: json.encode({ + 'from': fromAddress, + 'to': toAddress, + 'amount': amount, + 'privateKey': privateKey, + }), + ); + + if (response.statusCode == 200) { + return json.decode(response.body); + } else { + throw Exception('Failed to send transaction: ${response.statusCode}'); + } + } catch (e) { + if (kDebugMode) { + print('Error sending transaction: $e'); + } + rethrow; + } + } + + /// Get transaction history + static Future>> getTransactionHistory(String address) async { + try { + final response = await http.get( + Uri.parse('$_baseUrl/transactions/$address'), + headers: {'Content-Type': 'application/json'}, + ); + + if (response.statusCode == 200) { + final data = json.decode(response.body); + return List>.from(data['transactions']); + } else { + throw Exception('Failed to get transaction history: ${response.statusCode}'); + } + } catch (e) { + if (kDebugMode) { + print('Error getting transaction history: $e'); + } + return []; + } + } + + /// Create new wallet + static Future createWallet() async { + try { + final response = await http.post( + Uri.parse('$_baseUrl/wallet/create'), + headers: {'Content-Type': 'application/json'}, + ); + + if (response.statusCode == 200) { + final data = json.decode(response.body); + return Wallet.fromJson(data); + } else { + throw Exception('Failed to create wallet: ${response.statusCode}'); + } + } catch (e) { + if (kDebugMode) { + print('Error creating wallet: $e'); + } + rethrow; + } + } + + /// Get transactions for burn deposits + static Future> getTransactions(String address) async { + try { + final response = await http.get( + Uri.parse('$_baseUrl/transactions/$address'), + headers: {'Content-Type': 'application/json'}, + ); + + if (response.statusCode == 200) { + final data = json.decode(response.body); + final transactions = List>.from(data['transactions']); + return transactions.map((json) => TransactionModel.fromJson(json)).toList(); + } else { + throw Exception('Failed to get transactions: ${response.statusCode}'); + } + } catch (e) { + if (kDebugMode) { + print('Error getting transactions: $e'); + } + return []; + } + } +} \ No newline at end of file diff --git a/lib/utils/theme.dart b/lib/utils/theme.dart index 36583b7..4879948 100644 --- a/lib/utils/theme.dart +++ b/lib/utils/theme.dart @@ -48,7 +48,7 @@ class AppTheme { ), iconTheme: IconThemeData(color: textPrimary), ), - cardTheme: CardTheme( + cardTheme: CardThemeData( color: cardColor, elevation: 2, shape: RoundedRectangleBorder( @@ -129,7 +129,7 @@ class AppTheme { type: BottomNavigationBarType.fixed, elevation: 8, ), - tabBarTheme: const TabBarTheme( + tabBarTheme: const TabBarThemeData( labelColor: primaryColor, unselectedLabelColor: textMuted, indicatorColor: primaryColor, @@ -210,7 +210,7 @@ class AppTheme { ), iconTheme: IconThemeData(color: Colors.black87), ), - cardTheme: CardTheme( + cardTheme: CardThemeData( color: Colors.white, elevation: 2, shape: RoundedRectangleBorder( diff --git a/pubspec.yaml b/pubspec.yaml index 0e72460..703763a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -88,9 +88,6 @@ flutter: - assets/icons/ - assets/logo/ - assets/bin/ - - assets/bin/xfg-stark-cli-linux - - assets/bin/xfg-stark-cli-macos - - assets/bin/xfg-stark-cli-windows.exe # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware diff --git a/test/rpc_service_test.dart b/test/rpc_service_test.dart index fc33b86..9d35142 100644 --- a/test/rpc_service_test.dart +++ b/test/rpc_service_test.dart @@ -1,14 +1,14 @@ // Unit tests for FuegoRPCService import 'package:flutter_test/flutter_test.dart'; -import 'package:fuego_wallet/services/fuego_rpc_service.dart'; +import '../lib/services/fuego_rpc_service.dart'; void main() { group('FuegoRPCService', () { test('should initialize with default remote node', () { final service = FuegoRPCService(); - expect(service.defaultRemoteNodes.isNotEmpty, true); - expect(service.defaultRemoteNodes.first, 'node1.usexfg.org'); + expect(FuegoRPCService.defaultRemoteNodes.isNotEmpty, true); + expect(FuegoRPCService.defaultRemoteNodes.first, 'node1.usexfg.org'); }); test('should update node correctly', () { diff --git a/test/widget_test.dart b/test/widget_test.dart index f4be4e9..02acd9f 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:fuego_wallet/main.dart'; +import '../lib/main.dart'; void main() { testWidgets('Fuego Wallet app smoke test', (WidgetTester tester) async {