diff --git a/.github/workflows/pr_test_build_android.yml b/.github/workflows/pr_test_build_android.yml index 6c72b587d..08a283467 100644 --- a/.github/workflows/pr_test_build_android.yml +++ b/.github/workflows/pr_test_build_android.yml @@ -9,7 +9,7 @@ jobs: PR_test_build: runs-on: linux-amd64 container: - image: ghcr.io/cake-tech/cake_wallet:3.27.4-linux + image: ghcr.io/cake-tech/cake_wallet:debian12-flutter3.27.4-go1.24.1 env: STORE_PASS: test@cake_wallet KEY_PASS: test@cake_wallet diff --git a/.github/workflows/pr_test_build_linux.yml b/.github/workflows/pr_test_build_linux.yml index 9317aab34..bf55134ad 100644 --- a/.github/workflows/pr_test_build_linux.yml +++ b/.github/workflows/pr_test_build_linux.yml @@ -9,7 +9,7 @@ jobs: PR_test_build: runs-on: linux-amd64 container: - image: ghcr.io/cake-tech/cake_wallet:3.27.4-linux + image: ghcr.io/cake-tech/cake_wallet:debian12-flutter3.27.4-go1.24.1 env: STORE_PASS: test@cake_wallet KEY_PASS: test@cake_wallet @@ -22,9 +22,6 @@ jobs: - /opt/cw_cache_linux/root/.pub-cache/:/root/.pub-cache - /opt/cw_cache_linux/root/go/pkg:/root/go/pkg - /opt/cw_cache_linux/opt/generic_cache:/opt/generic_cache - strategy: - matrix: - api-level: [29] steps: - name: Fix github actions messing up $HOME... diff --git a/.gitignore b/.gitignore index f57b19d82..a7619995e 100644 --- a/.gitignore +++ b/.gitignore @@ -186,6 +186,10 @@ ios/WowneroWallet.framework/WowneroWallet ios/ZanoWallet.framework/ZanoWallet *_libwallet2_api_c.dylib +.flatpak-builder +cake_wallet.flatpak +flatpak-build/ + # macOS **/Flutter/ephemeral/ **/Pods/ @@ -204,7 +208,3 @@ ios/ZanoWallet.framework/ZanoWallet **/linux/flutter/generated_plugin_registrant.cc **/linux/flutter/generated_plugin_registrant.h **/linux/flutter/generated_plugins.cmake - -cake_wallet.flatpak -flatpak-build/ -export/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 7fa47192e..84179d645 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ -# docker build . -f Dockerfile -t ghcr.io/cake-tech/cake_wallet:3.27.4-linux -# docker push ghcr.io/cake-tech/cake_wallet:3.27.4-linux +# docker buildx build --push --pull --platform linux/amd64,linux/arm64 . -f Dockerfile -t ghcr.io/cake-tech/cake_wallet:debian12-flutter3.27.4-go1.24.1 # Heavily inspired by cirrusci images # https://github.com/cirruslabs/docker-images-android/blob/master/sdk/tools/Dockerfile @@ -7,7 +6,7 @@ # https://github.com/cirruslabs/docker-images-android/blob/master/sdk/34-ndk/Dockerfile # https://github.com/cirruslabs/docker-images-flutter/blob/master/sdk/Dockerfile -FROM --platform=linux/amd64 docker.io/debian:12 +FROM docker.io/debian:12 LABEL org.opencontainers.image.source=https://github.com/cake-tech/cake_wallet @@ -60,11 +59,20 @@ RUN set -o xtrace \ ffmpeg network-manager x11-utils xvfb psmisc \ # aarch64-linux-gnu dependencies g++-aarch64-linux-gnu gcc-aarch64-linux-gnu \ + # x86_64-linux-gnu dependencies + g++-x86-64-linux-gnu gcc-x86-64-linux-gnu \ + # flatpak dependencies + flatpak flatpak-builder binutils elfutils patch unzip xz-utils zstd \ && apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ && sh -c 'echo "en_US.UTF-8 UTF-8" > /etc/locale.gen' \ && locale-gen \ && update-locale LANG=en_US.UTF-8 +ENV FLATPAK_RUNTIME_VERSION=24.08 +RUN flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo \ + && flatpak install -y flathub org.freedesktop.Platform//${FLATPAK_RUNTIME_VERSION} \ + && flatpak install -y flathub org.freedesktop.Sdk//${FLATPAK_RUNTIME_VERSION} + # Install nodejs for Github Actions RUN curl -fsSL https://deb.nodesource.com/setup_23.x | bash - && \ apt-get install -y --no-install-recommends nodejs && \ @@ -74,14 +82,28 @@ RUN curl -fsSL https://deb.nodesource.com/setup_23.x | bash - && \ ENV PATH=${PATH}:/usr/local/go/bin:${HOME}/go/bin ENV GOROOT=/usr/local/go ENV GOPATH=${HOME}/go -RUN wget https://go.dev/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz &&\ - rm -rf /usr/local/go &&\ - tar -C /usr/local -xzf go${GOLANG_VERSION}.linux-amd64.tar.gz && \ +RUN ARCH=$(uname -m) && \ + if [ "$ARCH" = "x86_64" ]; then \ + wget https://go.dev/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz -O go.tar.gz; \ + elif [ "$ARCH" = "aarch64" ]; then \ + wget https://go.dev/dl/go${GOLANG_VERSION}.linux-arm64.tar.gz -O go.tar.gz; \ + else \ + echo "Unsupported architecture: $ARCH"; exit 1; \ + fi && \ + rm -rf /usr/local/go && \ + tar -C /usr/local -xzf go.tar.gz && \ + rm go.tar.gz && \ go install golang.org/x/mobile/cmd/gomobile@latest && \ gomobile init +RUN git config --global user.email "czarek@cakewallet.com" \ + && git config --global user.name "CakeWallet CI" + + # Install Android SDK commandline tools and emulator -RUN wget -q https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS_VERSION}_latest.zip -O android-sdk-tools.zip \ +RUN ARCH=$(uname -m) && \ + if [ "$ARCH" != "x86_64" ]; then exit 0; fi \ + && wget -q https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS_VERSION}_latest.zip -O android-sdk-tools.zip \ && mkdir -p ${ANDROID_HOME}/cmdline-tools/ \ && unzip -q android-sdk-tools.zip -d ${ANDROID_HOME}/cmdline-tools/ \ && mv ${ANDROID_HOME}/cmdline-tools/cmdline-tools ${ANDROID_HOME}/cmdline-tools/latest \ @@ -94,14 +116,17 @@ RUN wget -q https://dl.google.com/android/repository/commandlinetools-linux-${AN && sdkmanager platform-tools \ && mkdir -p ${HOME}/.android \ && touch ${HOME}/.android/repositories.cfg \ - && git config --global user.email "czarek@cakewallet.com" \ - && git config --global user.name "CakeWallet CI" + # Handle emulator not being available on linux/arm64 (https://issuetracker.google.com/issues/227219818) -RUN if [ $(uname -m) == "x86_64" ]; then sdkmanager emulator ; fi +RUN ARCH=$(uname -m) && \ + if [ "$ARCH" != "x86_64" ]; then exit 0; fi \ + && sdkmanager emulator # Pre-install extra Android SDK dependencies in order to not have to download them for each build -RUN yes | sdkmanager \ +RUN ARCH=$(uname -m) && \ + if [ "$ARCH" != "x86_64" ]; then exit 0; fi \ + && yes | sdkmanager \ "platforms;android-$ANDROID_PLATFORM_VERSION" \ "build-tools;$ANDROID_BUILD_TOOLS_VERSION" \ "platforms;android-33" \ @@ -114,12 +139,16 @@ RUN yes | sdkmanager \ # Install extra NDK dependency for sp_scanner ENV ANDROID_NDK_VERSION=27.2.12479018 -RUN yes | sdkmanager "ndk;$ANDROID_NDK_VERSION" \ +RUN ARCH=$(uname -m) && \ + if [ "$ARCH" != "x86_64" ]; then exit 0; fi \ + && yes | sdkmanager "ndk;$ANDROID_NDK_VERSION" \ "ndk;27.0.12077973" # Install dependencies for tests # Comes from https://github.com/ReactiveCircus/android-emulator-runner -RUN yes | sdkmanager \ +RUN ARCH=$(uname -m) && \ + if [ "$ARCH" != "x86_64" ]; then exit 0; fi \ + && yes | sdkmanager \ "system-images;android-29;default;x86_64" \ "system-images;android-31;default;x86_64" \ "platforms;android-29" \ @@ -135,7 +164,7 @@ RUN (addgroup kvm || true) && \ ENV PATH=${HOME}/.cargo/bin:${PATH} RUN curl https://sh.rustup.rs -sSf | bash -s -- -y && \ cargo install cargo-ndk && \ - for target in aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android x86_64-unknown-linux-gnu; \ + for target in aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu aarch64-unknown-linux-gnu; \ do \ rustup target add --toolchain stable $target; \ done diff --git a/com.cakewallet.CakeWallet.yml b/com.cakewallet.CakeWallet.yml index 83efa1388..98ce19caf 100644 --- a/com.cakewallet.CakeWallet.yml +++ b/com.cakewallet.CakeWallet.yml @@ -1,6 +1,6 @@ app-id: com.cakewallet.CakeWallet runtime: org.freedesktop.Platform -runtime-version: '22.08' +runtime-version: '24.08' sdk: org.freedesktop.Sdk command: cake_wallet separate-locales: false @@ -15,8 +15,6 @@ finish-args: modules: - name: cake_wallet buildsystem: simple - only-arches: - - x86_64 build-commands: - "cp -R bundle /app/cake_wallet" - "chmod +x /app/cake_wallet/cake_wallet" @@ -28,7 +26,7 @@ modules: - "cp com.cakewallet.CakeWallet.desktop /app/share/applications" sources: - type: dir - path: build/linux/x64/release + path: build/linux/current/release - type: file path: assets/images/cakewallet_icon_180.png - type: file diff --git a/docs/builds/ANDROID.md b/docs/builds/ANDROID.md index 9e4e75685..226883679 100644 --- a/docs/builds/ANDROID.md +++ b/docs/builds/ANDROID.md @@ -8,8 +8,6 @@ You can find the latest instructions for installing Docker on your given OS on t - <https://docs.docker.com/engine/install/> -NOTE: If building on a Mac with an M-series CPU (arm64), you may encounter segmentation faults when building. If you do, simply retry the build. - ## Building Cake Wallet or Monero.com ### Using the pre-built builder image @@ -20,8 +18,8 @@ In order to build the latest version of Cake Wallet, simply run the following: git clone --branch main https://github.com/cake-tech/cake_wallet.git # NOTE: Replace `main` with the latest release tag available at https://github.com/cake-tech/cake_wallet/releases/latest. cd cake_wallet -# docker build -t ghcr.io/cake-tech/cake_wallet:main-linux . # Uncomment to build the docker image yourself instead of pulling it from the registry -docker run -v$(pwd):$(pwd) -w $(pwd) -i --rm ghcr.io/cake-tech/cake_wallet:main-linux bash -x << EOF +# docker build -t ghcr.io/cake-tech/cake_wallet:debian12-flutter3.27.4-go1.24.1 . # Uncomment to build the docker image yourself instead of pulling it from the registry +docker run -v$(pwd):$(pwd) -w $(pwd) -i --rm ghcr.io/cake-tech/cake_wallet:debian12-flutter3.27.4-go1.24.1 bash -x << EOF set -x -e pushd scripts/android source ./app_env.sh cakewallet diff --git a/docs/builds/LINUX.md b/docs/builds/LINUX.md index cd8466e6d..a97a269a5 100644 --- a/docs/builds/LINUX.md +++ b/docs/builds/LINUX.md @@ -20,8 +20,8 @@ In order to build the latest version of Cake Wallet, simply run the following: git clone --branch main https://github.com/cake-tech/cake_wallet.git # NOTE: Replace `main` with the latest release tag available at https://github.com/cake-tech/cake_wallet/releases/latest. cd cake_wallet -# docker build -t ghcr.io/cake-tech/cake_wallet:main-linux . # Uncomment to build the docker image yourself instead of pulling it from the registry -docker run -v$(pwd):$(pwd) -w $(pwd) -i --rm ghcr.io/cake-tech/cake_wallet:main-linux bash -x << EOF +# docker build -t ghcr.io/cake-tech/cake_wallet:debian12-flutter3.27.4-go1.24.1 . # Uncomment to build the docker image yourself instead of pulling it from the registry +docker run --privileged -v$(pwd):$(pwd) -w $(pwd) -i --rm ghcr.io/cake-tech/cake_wallet:debian12-flutter3.27.4-go1.24.1 bash -x << EOF set -x -e pushd scripts ./gen_android_manifest.sh @@ -37,6 +37,13 @@ flutter clean dart run tool/generate_localization.dart dart run tool/generate_new_secrets.dart flutter build linux +cp -r build/linux/x64 build/linux/current +# use line below if you are building on arm64 +# cp -r build/linux/arm64 build/linux/current +# If you want to build flatpak you need --privileged flag +flatpak-builder --force-clean flatpak-build com.cakewallet.CakeWallet.yml +flatpak build-export export flatpak-build +flatpak build-bundle export build/linux/current/cake_wallet.flatpak com.cakewallet.CakeWallet EOF ``` @@ -51,46 +58,11 @@ Building Linux application... ✓ Built build/linux/x64/release/bundle/cake_wallet ``` -Final builds can be found in `build/linux/x64/release/bundle/` as seen above. +Final builds can be found in `build/linux/current/release/bundle/` as seen above. -## Flatpak (optional) - -To package the built binaries as a flatpak, you need first to install `flatpak` and `flatpak-builder`: - -```bash -sudo apt install flatpak flatpak-builder -``` - -Add the necessary Flathub: - -```bash -flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo -``` - -Then need to install freedesktop runtime and sdk: - -```bash -flatpak install flathub org.freedesktop.Platform//22.08 org.freedesktop.Sdk//22.08 -``` - -Next, build the flatpak bundle: - -```bash -flatpak-builder --force-clean flatpak-build com.cakewallet.CakeWallet.yml -``` - -And then export bundle: - -```bash -flatpak build-export export flatpak-build -flatpak build-bundle export cake_wallet.flatpak com.cakewallet.CakeWallet -``` - -The Flatpak file, `cake_wallet.flatpak`, should be generated in the current directory. - To install the newly built Flatpak, run: ```bash -flatpak --user install cake_wallet.flatpak +flatpak --user install build/linux/current/cake_wallet.flatpak ``` diff --git a/lib/view_model/send/output.dart b/lib/view_model/send/output.dart index a59bf5852..23efe8c1a 100644 --- a/lib/view_model/send/output.dart +++ b/lib/view_model/send/output.dart @@ -294,37 +294,26 @@ abstract class OutputBase with Store { switch (_wallet.type) { case WalletType.monero: + case WalletType.ethereum: + case WalletType.polygon: + case WalletType.solana: + case WalletType.tron: + case WalletType.haven: + case WalletType.zano: + case WalletType.nano: + case WalletType.decred: maximumFractionDigits = 12; break; case WalletType.bitcoin: - maximumFractionDigits = 8; - break; case WalletType.litecoin: - maximumFractionDigits = 8; - break; case WalletType.bitcoinCash: maximumFractionDigits = 8; break; - case WalletType.haven: - maximumFractionDigits = 12; - break; - case WalletType.ethereum: - case WalletType.polygon: - maximumFractionDigits = 12; - break; - case WalletType.solana: - maximumFractionDigits = 12; - break; - case WalletType.tron: - maximumFractionDigits = 12; - break; case WalletType.wownero: maximumFractionDigits = 11; break; - case WalletType.zano: - maximumFractionDigits = 12; - break; - default: + case WalletType.none: + case WalletType.banano: break; } diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt index a87e938f3..b551d629d 100644 --- a/linux/CMakeLists.txt +++ b/linux/CMakeLists.txt @@ -107,7 +107,7 @@ install(CODE " set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") -if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") +if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") set(LIB_TRIPLET "aarch64-linux-gnu") else() set(LIB_TRIPLET "x86_64-linux-gnu") diff --git a/scripts/linux/build_cake_release.sh b/scripts/linux/build_cake_release.sh new file mode 100755 index 000000000..e8ad6fc54 --- /dev/null +++ b/scripts/linux/build_cake_release.sh @@ -0,0 +1,98 @@ +#!/bin/bash + +# build_cake_release.sh - Script to build Cake Wallet for Linux +# Usage: ./build_cake_release.sh --amd64 [--arm64] [--app=cakewallet|monero.com] + +set -e + + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd "$SCRIPT_DIR" + + +# Default values +BUILD_AMD64=false +BUILD_ARM64=false +APP_TYPE="cakewallet" +DOCKER_IMAGE="ghcr.io/cake-tech/cake_wallet:debian12-flutter3.27.4-go1.24.1" + +# Parse arguments +for arg in "$@" +do + case $arg in + --amd64) + BUILD_AMD64=true + shift + ;; + --arm64) + BUILD_ARM64=true + shift + ;; + --app=*) + APP_TYPE="${arg#*=}" + shift + ;; + *) + echo "Unknown argument: $arg" + echo "Usage: ./build_cake_release.sh --amd64 [--arm64] [--app=cakewallet|monero.com]" + exit 1 + ;; + esac +done + +cd ../.. + +# Validate arguments +if [[ "$BUILD_AMD64" == "false" && "$BUILD_ARM64" == "false" ]]; then + echo "Error: At least one architecture (--amd64 or --arm64) must be specified." + echo "Usage: ./build_cake_release.sh --amd64 [--arm64] [--app=cakewallet|monero.com]" + exit 1 +fi + +if [[ "$APP_TYPE" != "cakewallet" && "$APP_TYPE" != "monero.com" ]]; then + echo "Error: App type must be either 'cakewallet' or 'monero.com'" + echo "Usage: ./build_cake_release.sh --amd64 [--arm64] [--app=cakewallet|monero.com]" + exit 1 +fi + +# Function to build for a specific architecture +build_for_arch() { + local arch=$1 + local flutter_arch=$2 + echo "Building $APP_TYPE for Linux ($arch)" + + docker run --privileged -v$(pwd):$(pwd) -w $(pwd) -i --rm --platform linux/$arch $DOCKER_IMAGE bash -x << EOF +set -x -e +pushd scripts + ./gen_android_manifest.sh +popd +pushd scripts/linux + source ./app_env.sh $APP_TYPE + ./app_config.sh + ./build_monero_all.sh +popd +flutter clean +./model_generator.sh +dart run tool/generate_localization.dart +flutter build linux +rm -rf build/linux/current +cp -r build/linux/$flutter_arch build/linux/current +rm -rf .flatpak-builder +flatpak-builder --force-clean flatpak-build com.cakewallet.CakeWallet.yml +flatpak build-export export flatpak-build +flatpak build-bundle export build/linux/current/cake_wallet.flatpak com.cakewallet.CakeWallet +cp build/linux/current/cake_wallet.flatpak build/linux/$flutter_arch/ +EOF +} + +# Build for specified architectures +echo "Building $APP_TYPE for Linux" +if [[ "$BUILD_AMD64" == "true" ]]; then + build_for_arch "amd64" "x64" +fi + +if [[ "$BUILD_ARM64" == "true" ]]; then + build_for_arch "arm64" "arm64" +fi + +echo "Build process completed." diff --git a/scripts/linux/build_monero_all.sh b/scripts/linux/build_monero_all.sh index 7948d87a1..6c901052f 100755 --- a/scripts/linux/build_monero_all.sh +++ b/scripts/linux/build_monero_all.sh @@ -10,15 +10,19 @@ cd "$(dirname "$0")" for COIN in monero wownero; do pushd ../monero_c - for target in x86_64-linux-gnu # aarch64-linux-gnu - do - if [[ -f "release/${COIN}/${target}_libwallet2_api_c.so" ]]; - then - echo "file exist, not building monero_c for ${COIN}/$target."; - else - ./build_single.sh ${COIN} $target -j$MAKE_JOB_COUNT - unxz -f ../monero_c/release/${COIN}/${target}_libwallet2_api_c.so.xz - fi - done + # Determine target architecture based on system architecture + if [[ $(uname -m) == "arm64" || $(uname -m) == "aarch64" ]]; then + target="aarch64-linux-gnu" + else + target="x86_64-linux-gnu" + fi + + if [[ -f "release/${COIN}/${target}_libwallet2_api_c.so" ]]; + then + echo "file exist, not building monero_c for ${COIN}/$target."; + else + ./build_single.sh ${COIN} $target -j$MAKE_JOB_COUNT + unxz -f ../monero_c/release/${COIN}/${target}_libwallet2_api_c.so.xz + fi popd done \ No newline at end of file