What changed, and why it matters
This commit is almost entirely about adding and fixing an automated iOS build pipeline (CI) for the Cake Wallet app. It introduces GitHub Actions workflows, Docker images for building native libraries, scripts to sign and upload the app to Apple's TestFlight, and small app tweaks to support CI builds. There is no obvious malicious code, but the CI pipeline handles signing certificates and App Store API keys, so a compromise of the CI system or a pull request from a malicious branch could in theory lead to a tampered app being signed and uploaded. The commit itself does not show such an attack; it is a build-infrastructure change.
Treat this as a build-hygiene review, not a vulnerability patch. Reviewers should verify that the `pull_request` trigger is appropriately scoped, that required reviewers and branch protection are enabled, that secrets are scoped to the `testflight` environment with required approvals, and that the macOS runner is not accessible to untrusted PR authors. Consider whether writing plaintext API keys into compiled `.secrets.g.dart` files is acceptable for CI artifacts. No immediate code fix is required based on the diff alone.
Security signals we found
CI/CD pipeline added with access to signing certificates and App Store Connect API keys
Workflow triggered on pull_request but gated to non-fork repositories
Third-party GitHub Actions pinned to specific commit hashes (good supply-chain practice)
Secrets embedded into compiled source files at build time (API keys for PolygonScan, Etherscan, Moralis, etc.)
TestFlight upload uses base64-decoded distribution certificate and provisioning profile
App Store Connect JWT generated from environment-supplied key with ES256 signing
No code review or branch protection rules visible in the commit
Debug/CI overlay and support email replacement for CI builds
Evidence from the diff
The commit adds .github/workflows/pr_test_build_ios.yml, a multi-job GitHub Actions workflow that builds iOS dependencies in Docker on Linux runners (torch, monero_c), then builds, signs, and uploads an iOS IPA to TestFlight on a macOS runner. It also adds helper scripts and Dockerfiles under scripts/ios/docker/, modifies scripts/ios/build_monero_all.sh, scripts/ios/build_torch.sh, scripts/ios/gen_framework.sh, scripts/ios/build_mwebd.sh, and related Android/Linux Docker scripts for consistency. A small Dart file tool/set_testflight_changelog.dart posts changelogs via App Store Connect API. App-side changes include an override of window in ios/Runner/AppDelegate.swift and skipping the changelog popup on CI builds in lib/new-ui/new_dashboard.dart. The workflow reads many secrets (distribution certificate, provisioning profile, App Store Connect key, various API keys) and uses pull_request triggers, but restricts runs to non-fork PRs. The workflow pins third-party actions to commit hashes.
Changed components
.github/workflows/pr_test_build_ios.ymlios/Runner/AppDelegate.swiftlib/new-ui/new_dashboard.dartscripts/ios/docker/Dockerfile.basescripts/ios/docker/Dockerfile.moneroscripts/ios/docker/Dockerfile.torchscripts/ios/docker/build.shscripts/ios/build_monero_all.shscripts/ios/build_torch.shscripts/ios/gen_framework.shscripts/ios/build_mwebd.shscripts/build_bitbox_flutter.shscripts/prepare_reown.shscripts/prepare_torch.shscripts/android/docker/Dockerfile.reownscripts/android/docker/build.shscripts/linux/docker/Dockerfile.reownscripts/linux/docker/build.shtool/download_moneroc_prebuilds.darttool/set_testflight_changelog.dartInspect captured patch +1227 / −62
### .github/workflows/pr_test_build_ios.yml
@@ -0,0 +1,483 @@
+name: Cake Wallet iOS
+
+on:
+ pull_request:
+
+permissions:
+ contents: read
+ packages: read
+
+concurrency:
+ group: ios-${{ github.head_ref || github.ref_name }}
+ cancel-in-progress: true
+
+defaults:
+ run:
+ shell: bash
+
+jobs:
+ # these are separate linux runners that put torch and monero in cache
+ # otherwise the macos build wouldn't finish withing the 6 hour gh time limit
+ torch:
+ if: github.event.pull_request.head.repo.fork == false
+ runs-on: puzl-ubuntu-latest
+ timeout-minutes: 360
+ permissions:
+ contents: read
+ packages: write
+ env:
+ CW_DOCKER_REGISTRY: ghcr.io/cake-tech/cake_wallet
+ CW_DOCKER_USE_CLOUD: "true"
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
+ with:
+ ref: ${{ github.event.pull_request.head.sha }}
+ - name: Docker sock permissions
+ run: sudo chmod 666 /var/run/docker.sock || true
+ - name: Log in to GitHub Container Registry
+ uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+ - name: Build torch
+ run: ./scripts/ios/docker/build.sh --only torch
+
+ monero:
+ if: github.event.pull_request.head.repo.fork == false
+ runs-on: puzl-ubuntu-latest
+ timeout-minutes: 360
+ permissions:
+ contents: read
+ packages: write
+ env:
+ CW_DOCKER_REGISTRY: ghcr.io/cake-tech/cake_wallet
+ CW_DOCKER_USE_CLOUD: "true"
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
+ with:
+ ref: ${{ github.event.pull_request.head.sha }}
+ - name: Docker sock permissions
+ run: sudo chmod 666 /var/run/docker.sock || true
+ - name: Log in to GitHub Container Registry
+ uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+ - name: Build monero_c
+ run: |
+ ./scripts/ios/docker/build.sh --only monero
+ ./scripts/ios/docker/build.sh --only monero --merge
+
+ build:
+ needs: [torch, monero]
+ if: github.event.pull_request.head.repo.fork == false
+ runs-on: macos-26
+
+ outputs:
+ build_number: ${{ steps.config.outputs.build_number }}
+ app_version: ${{ steps.config.outputs.app_version }}
+
+ env:
+ BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
+ FLUTTER_VERSION: "3.41.9"
+ GO_VERSION: "1.24.1"
+
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
+ with:
+ ref: ${{ github.event.pull_request.head.sha }}
+
+ - name: Configure git
+ run: |
+ git config --global user.email "ci@cakewallet.com"
+ git config --global user.name "CakeWallet CI"
+
+ - name: Authenticate git for GitHub clones
+ run: |
+ git config --global --unset-all credential.helper || true
+ git config --global url."https://x-access-token:${{ github.token }}@github.com/".insteadOf "https://github.com/"
+
+
+ - name: Identify the build
+ run: |
+ BRANCH="${BRANCH_NAME#origin/}"
+ # cw-1234-something -> 1234
+ TICKET="$(printf '%s' "$BRANCH" | tr 'A-Z' 'a-z' \
+ | grep -oE '(^|[^a-z0-9])cw-?[0-9]+' | head -1 | grep -oE '[0-9]+' || true)"
+
+ if [[ -n "$TICKET" ]]; then
+ TICKET=$((10#$TICKET)) # drop leading zeros, Apple dislikes them
+ echo "APP_DISPLAY_NAME=CW-$TICKET" >> $GITHUB_ENV
+ echo "APP_VERSION=6.$TICKET" >> $GITHUB_ENV
+ else
+ echo "APP_DISPLAY_NAME=Cake (CI)" >> $GITHUB_ENV
+ echo "APP_VERSION=" >> $GITHUB_ENV
+ fi
+ echo "BUILD_NUMBER=${{ github.run_number }}" >> $GITHUB_ENV
+
+ - uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 # v2.23.0
+ with:
+ flutter-version: ${{ env.FLUTTER_VERSION }}
+ channel: stable
+
+ - uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
+ with:
+ go-version: ${{ env.GO_VERSION }}
+
+ - name: Add Rust iOS target
+ run: |
+ rustup target add aarch64-apple-ios
+
+ - name: Install protoc
+ env:
+ PROTOC_VERSION: "35.1"
+ run: |
+ set -euo pipefail
+ curl -sSL --retry 3 --retry-delay 5 -o "$RUNNER_TEMP/protoc.zip" \
+ "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-osx-universal_binary.zip"
+ unzip -q -o "$RUNNER_TEMP/protoc.zip" -d "$RUNNER_TEMP/protoc"
+ rm -f "$RUNNER_TEMP/protoc.zip"
+ echo "$RUNNER_TEMP/protoc/bin" >> $GITHUB_PATH
+ "$RUNNER_TEMP/protoc/bin/protoc" --version
+
+ - name: Add secrets
+ run: |
+ touch cw_bitcoin/lib/.secrets.g.dart
+ touch cw_evm/lib/.secrets.g.dart
+ touch cw_solana/lib/.secrets.g.dart
+ touch cw_core/lib/.secrets.g.dart
+ touch cw_nano/lib/.secrets.g.dart
+ touch cw_tron/lib/.secrets.g.dart
+
+ echo "const polygonScanApiKey = '${{ secrets.POLYGON_SCAN_API_KEY }}';" >> cw_evm/lib/.secrets.g.dart
+ echo "const etherScanApiKey = '${{ secrets.ETHER_SCAN_API_KEY }}';" >> cw_evm/lib/.secrets.g.dart
+ echo "const moralisApiKey = '${{ secrets.MORALIS_API_KEY }}';" >> cw_evm/lib/.secrets.g.dart
+ echo "const nowNodesApiKey = '${{ secrets.EVM_NOWNODES_API_KEY }}';" >> cw_evm/lib/.secrets.g.dart
+ echo "const blinkApiKey = '${{ secrets.BLINK_API_KEY }}';" >> cw_evm/lib/.secrets.g.dart
+ echo "const ankrApiKey = '${{ secrets.ANKR_API_KEY }}';" >> cw_solana/lib/.secrets.g.dart
+ echo "const chainStackApiKey = '${{ secrets.CHAIN_STACK_API_KEY }}';" >> cw_solana/lib/.secrets.g.dart
+ echo "const moralisApiKey = '${{ secrets.MORALIS_API_KEY }}';" >> cw_solana/lib/.secrets.g.dart
+
+ echo "const nano2ApiKey = '${{ secrets.NANO2_API_KEY }}';" >> cw_nano/lib/.secrets.g.dart
+ echo "const nanoNowNodesApiKey = '${{ secrets.NANO_NOW_NODES_API_KEY }}';" >> cw_nano/lib/.secrets.g.dart
+
+ echo "const tronGridApiKey = '${{ secrets.TRON_GRID_API_KEY }}';" >> cw_tron/lib/.secrets.g.dart
+ echo "const tronNowNodesApiKey = '${{ secrets.TRON_NOW_NODES_API_KEY }}';" >> cw_tron/lib/.secrets.g.dart
+
+ echo "const breezApiKey = '${{ secrets.BREEZ_API_KEY }}';" >> cw_bitcoin/lib/.secrets.g.dart
+
+ echo "${{ secrets.MAIN_SECRETS_FILE }}" | base64 --decode > lib/.secrets.g.dart
+
+ - name: Set up crane
+ run: |
+ set -euo pipefail
+ echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
+ export PATH="$PATH:$(go env GOPATH)/bin"
+ command -v crane >/dev/null || go install github.com/google/go-containerregistry/cmd/crane@v0.22.1
+ echo "${{ secrets.GITHUB_TOKEN }}" \
+ | crane auth login ghcr.io -u "${{ github.actor }}" --password-stdin
+
+ - name: Fetch prebuilt torch xcframework
+ env:
+ CW_DOCKER_REGISTRY: ghcr.io/cake-tech/cake_wallet
+ run: |
+ set -euo pipefail
+ IMAGE="$(./scripts/ios/docker/build.sh --image torch)"
+
+ TMP="$(mktemp -d)"
+ crane export "$IMAGE" - | tar -x -C "$TMP"
+ rsync -a "$TMP/w/" .
+ rm -rf "$TMP"
+
+ test -d scripts/torch_dart/ios/LibTorch.xcframework/ios-arm64 \
+ || { echo "restored xcframework has no ios-arm64 slice" >&2; exit 1; }
+
+ - name: Fetch prebuilt monero_c and generate xcframeworks
+ env:
+ CW_DOCKER_REGISTRY: ghcr.io/cake-tech/cake_wallet
+ run: |
+ set -euo pipefail
+ IMAGE="$(./scripts/ios/docker/build.sh --image monero)"
+
+ TMP="$(mktemp -d)"
+ crane export "$IMAGE" - | tar -x -C "$TMP"
+ rsync -a "$TMP/w/" .
+ rm -rf "$TMP"
+
+ MONEROC_TAG="$(ls scripts/monero_c/release)"
+ pushd scripts/ios
+ MONEROC_TAG="$MONEROC_TAG" ./gen_framework.sh
+ popd
+
+ test -f ios/MoneroWallet.xcframework/ios-arm64/MoneroWallet.framework/MoneroWallet \
+ || { echo "MoneroWallet.xcframework has no ios-arm64 slice" >&2; exit 1; }
+
+ # wownero and zano aren't built, their wallets fail to open instead of the build failing
+ sed -i '' \
+ -e '/WowneroWallet\.xcframework/d' \
+ -e '/ZanoWallet\.xcframework/d' \
+ ios/Runner.xcodeproj/project.pbxproj
+
+ - name: Prepare bitbox_flutter
+ run: |
+ pushd scripts
+ ./build_bitbox_flutter.sh clone-only
+ popd
+
+ - name: Prepare reown_flutter
+ run: ./scripts/prepare_reown.sh
+
+
+ - name: Execute Build and Setup Commands
+ id: config
+ run: |
+ pushd scripts/ios
+ source ./app_env.sh cakewallet
+ export APP_IOS_BUNDLE_ID="${{ vars.IOS_BUNDLE_ID }}"
+ export APP_IOS_NAME="$APP_DISPLAY_NAME"
+ export APP_IOS_BUILD_NUMBER="$BUILD_NUMBER"
+ if [[ -n "$APP_VERSION" ]]; then
+ export APP_IOS_VERSION="$APP_VERSION"
+ fi
+ ./app_config.sh
+ popd
+
+ for key in CFBundleDisplayName CFBundleIdentifier CFBundleShortVersionString CFBundleVersion; do
+ echo "$key = $(/usr/libexec/PlistBuddy -c "Print :$key" ios/Runner/Info.plist)"
+ done
+
+ {
+ echo "app_version=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' ios/Runner/Info.plist)"
+ echo "build_number=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' ios/Runner/Info.plist)"
+ } >> $GITHUB_OUTPUT
+
+ - name: Install Flutter dependencies
+ run: flutter pub get
+
+ - name: Build mwebd
+ run: |
+ pushd cw_mweb
+ flutter pub get
+ popd
+ pushd scripts/ios
+ ./build_mwebd.sh
+ popd
+
+ - name: Build decred
+ run: |
+ pushd cw_decred
+ flutter pub get
+ popd
+ pushd scripts/ios
+ ./build_decred.sh
+ popd
+
+ - name: Build generated code
+ run: ./model_generator.sh
+
+ - name: Generate localization
+ run: dart run tool/generate_localization.dart
+
+ - name: Compile graphics
+ run: ./compile_graphics.sh
+
+ - name: Replace email address
+ run: |
+ PATTERN1="support@cakewallet.com"
+ PATTERN1REP="dev.testflight.cakewallet@mrcyjanek.net"
+ for file in lib/utils/exception_handler.dart lib/view_model/support_view_model.dart; do
+ sed -i.bak -e "s|$PATTERN1|$PATTERN1REP|g" "$file"
+ rm -f "$file.bak"
+ done
+
+ - name: Build unsigned archive
+ run: |
+ flutter build ipa \
+ --release \
+ --no-codesign \
+ --dart-define=CI_COMMIT="$(git rev-parse HEAD)" \
+ --dart-define=CI_BRANCH="$BRANCH_NAME" \
+ --dart-define=hasDevOptions=true
+
+ - name: Pack archive
+ run: tar -cf "$RUNNER_TEMP/Runner.xcarchive.tar" -C build/ios/archive Runner.xcarchive
+
+ - name: Upload unsigned archive
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
+ with:
+ name: ios-xcarchive
+ path: ${{ runner.temp }}/Runner.xcarchive.tar
+ retention-days: 1
+ if-no-files-found: error
+
+ testflight:
+ needs: build
+ runs-on: macos-26
+ environment: testflight
+
+ steps:
+ - name: Download unsigned archive
+ uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
+ with:
+ name: ios-xcarchive
+
+ - name: Unpack archive
+ run: |
+ tar -xf Runner.xcarchive.tar
+ rm Runner.xcarchive.tar
+
+ - name: Install signing certificate and provisioning profile
+ env:
+ DIST_CERT_P12: ${{ secrets.IOS_DIST_CERT_P12 }}
+ DIST_CERT_PASSWORD: ${{ secrets.IOS_DIST_CERT_PASSWORD }}
+ PROVISIONING_PROFILE: ${{ secrets.IOS_PROVISIONING_PROFILE }}
+ run: |
+ set -euo pipefail
+
+ KEYCHAIN_PATH="$RUNNER_TEMP/cw-ios.keychain-db"
+ KEYCHAIN_PASSWORD="$(uuidgen)"
+ echo "KEYCHAIN_PATH=$KEYCHAIN_PATH" >> $GITHUB_ENV
+
+ echo -n "$DIST_CERT_P12" | base64 --decode > "$RUNNER_TEMP/dist.p12"
+ echo -n "$PROVISIONING_PROFILE" | base64 --decode > "$RUNNER_TEMP/profile.mobileprovision"
+
+ security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
+ security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
+ security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
+
+ security import "$RUNNER_TEMP/dist.p12" \
+ -P "$DIST_CERT_PASSWORD" \
+ -x -T /usr/bin/codesign -t cert -f pkcs12 -k "$KEYCHAIN_PATH"
+
+ security set-key-partition-list \
+ -S apple-tool:,apple:,codesign: \
+ -s -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH" >/dev/null
+
+ security list-keychain -d user -s "$KEYCHAIN_PATH" login.keychain-db
+
+ PROFILE_NAME="$(security cms -D -i "$RUNNER_TEMP/profile.mobileprovision" | plutil -extract Name raw -)"
+ PROFILE_UUID="$(security cms -D -i "$RUNNER_TEMP/profile.mobileprovision" | plutil -extract UUID raw -)"
+ echo "PROFILE_NAME=$PROFILE_NAME" >> $GITHUB_ENV
+
+ mkdir -p "$HOME/Library/MobileDevice/Provisioning Profiles"
+ cp "$RUNNER_TEMP/profile.mobileprovision" \
+ "$HOME/Library/MobileDevice/Provisioning Profiles/$PROFILE_UUID.mobileprovision"
+
+ rm -f "$RUNNER_TEMP/dist.p12"
+ security find-identity -v -p codesigning "$KEYCHAIN_PATH"
+
+ - name: Write ExportOptions.plist
+ run: |
+ cat > ExportOptions.plist <<PLIST
+ <?xml version="1.0" encoding="UTF-8"?>
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+ <plist version="1.0">
+ <dict>
+ <key>method</key>
+ <string>app-store</string>
+ <key>teamID</key>
+ <string>${{ vars.APPLE_TEAM_ID }}</string>
+ <key>signingStyle</key>
+ <string>manual</string>
+ <key>signingCertificate</key>
+ <string>Apple Distribution</string>
+ <key>provisioningProfiles</key>
+ <dict>
+ <key>${{ vars.IOS_BUNDLE_ID }}</key>
+ <string>$PROFILE_NAME</string>
+ </dict>
+ <key>uploadSymbols</key>
+ <true/>
+ <key>stripSwiftSymbols</key>
+ <true/>
+ </dict>
+ </plist>
+ PLIST
+ cat ExportOptions.plist
+
+ - name: Sign IPA
+ run: |
+ xcodebuild -exportArchive \
+ -archivePath Runner.xcarchive \
+ -exportOptionsPlist ExportOptions.plist \
+ -exportPath ipa
+
+ - name: Locate IPA
+ run: |
+ IPA_PATH="$(ls ipa/*.ipa 2>/dev/null | head -1 || true)"
+ echo "IPA_PATH=$IPA_PATH" >> $GITHUB_ENV
+ ls -lh "$IPA_PATH"
+
+ - name: Upload to TestFlight
+ env:
+ ASC_KEY_ID: ${{ secrets.ASC_KEY_ID }}
+ ASC_ISSUER_ID: ${{ secrets.ASC_ISSUER_ID }}
+ ASC_KEY_P8: ${{ secrets.ASC_KEY_P8 }}
+ run: |
+ set -euo pipefail
+
+ mkdir -p "$HOME/.appstoreconnect/private_keys"
+ echo -n "$ASC_KEY_P8" | base64 --decode \
+ > "$HOME/.appstoreconnect/private_keys/AuthKey_${ASC_KEY_ID}.p8"
+
+ xcrun altool --upload-app \
+ --type ios \
+ --file "$IPA_PATH" \
+ --apiKey "$ASC_KEY_ID" \
+ --apiIssuer "$ASC_ISSUER_ID" \
+ --api-key-subject user
+
+ rm -f "$HOME/.appstoreconnect/private_keys/AuthKey_${ASC_KEY_ID}.p8"
+
+ - name: Upload IPA artifact to GitHub
+ if: always()
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
+ with:
+ name: ios-ipa
+ path: ipa/*.ipa
+
+ - name: Clean up keychain and profiles
+ if: always()
+ run: |
+ security delete-keychain "$KEYCHAIN_PATH" || true
+ rm -rf "$HOME/Library/MobileDevice/Provisioning Profiles" || true
+ rm -rf "$HOME/.appstoreconnect/private_keys" || true
+
+ # posts the changelog to testflight
+ # this is a separate runner as the script waits for ocasionally 20+ minutes for the build to appear
+ changelog:
+ needs: [build, testflight]
+ runs-on: ubuntu-24.04
+ environment: testflight
+
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
+ with:
+ ref: ${{ github.event.pull_request.head.sha }}
+
+ - uses: dart-lang/setup-dart@6afc89df92d6eb3834022f73cd65adc8cdfcb92d # v1.8.1
+
+ - name: Set TestFlight changelog
+ env:
+ ASC_KEY_ID: ${{ secrets.ASC_KEY_ID }}
+ ASC_KEY_P8: ${{ secrets.ASC_KEY_P8 }}
+ IOS_BUNDLE_ID: ${{ vars.IOS_BUNDLE_ID }}
+ BUILD_NUMBER: ${{ needs.build.outputs.build_number }}
+ APP_VERSION: ${{ needs.build.outputs.app_version }}
+ BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
+ run: |
+ set -euo pipefail
+ export ASC_KEY_PATH="$RUNNER_TEMP/AuthKey_${ASC_KEY_ID}.p8"
+ trap 'rm -f "$ASC_KEY_PATH"' EXIT
+ echo -n "$ASC_KEY_P8" | base64 --decode > "$ASC_KEY_PATH"
+
+ {
+ printf '%s @ %s (PR #%s, build %s)\n\n' \
+ "$BRANCH_NAME" \
+ "$(git rev-parse --short=8 HEAD)" \
+ "${{ github.event.pull_request.number }}" \
+ "$BUILD_NUMBER"
+ git log -1 --pretty=%B
+ } | dart run tool/set_testflight_changelog.dart
### ios/Runner/AppDelegate.swift
@@ -122,6 +122,11 @@ private func keyWindow() -> UIWindow? {
.first { $0.isKeyWindow }
}
+override var window: UIWindow? {
+ get { super.window ?? keyWindow() }
+ set { super.window = newValue }
+}
+
private func makeSecure() {
guard let window = self.window ?? keyWindow() else { return }
### lib/new-ui/new_dashboard.dart
@@ -1,5 +1,6 @@
import 'dart:io';
+import "package:cake_wallet/ci_build_overlay.dart";
import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/entities/preferences_key.dart';
import "package:cake_wallet/new-ui/page_open_listener.dart";
@@ -137,6 +138,10 @@ class _NewDashboardState extends State<NewDashboard> {
}
void _showChangelog(BuildContext context) async {
+ if(CiBuildOverlay.isCiBuild) {
+ return;
+ }
+
final sharedPrefs = await SharedPreferences.getInstance();
final currentAppVersion = VersionComparator.getExtendedVersionNumber(
widget.dashboardViewModel.settingsStore.appVersion);
### scripts/android/docker/Dockerfile.reown
@@ -2,6 +2,7 @@ ARG BASE_IMAGE
FROM --platform=linux/amd64 ${BASE_IMAGE} AS build
RUN mkdir -p /w/scripts/android
+COPY scripts/functions.sh /w/scripts/functions.sh
COPY scripts/prepare_reown.sh /w/scripts/prepare_reown.sh
COPY scripts/android/build_reown_deps.sh /w/scripts/android/build_reown_deps.sh
RUN cd $(dirname $(which flutter)) && git checkout 3.32.0
### scripts/android/docker/build.sh
@@ -235,7 +235,7 @@ merge_slices() {
base_ver="latest"
torch_ver="$(tinysha $SCRIPT_DIR/Dockerfile.torch $REPO_ROOT/scripts/prepare_torch.sh $REPO_ROOT/scripts/android/build_torch.sh)"
-reown_ver=$(tinysha $SCRIPT_DIR/Dockerfile.reown $REPO_ROOT/scripts/prepare_reown.sh $REPO_ROOT/scripts/android/build_reown_deps.sh)
+reown_ver=$(tinysha $SCRIPT_DIR/Dockerfile.reown $REPO_ROOT/scripts/functions.sh $REPO_ROOT/scripts/prepare_reown.sh $REPO_ROOT/scripts/android/build_reown_deps.sh)
bitbox_ver=$(tinysha $SCRIPT_DIR/Dockerfile.bitbox $REPO_ROOT/scripts/build_bitbox_flutter.sh)
monero_ver=$(tinysha $SCRIPT_DIR/Dockerfile.monero $REPO_ROOT/scripts/prepare_moneroc.sh $REPO_ROOT/scripts/android/build_monero_all.sh)
mwebd_ver=$(tinysha $SCRIPT_DIR/Dockerfile.mwebd $REPO_ROOT/pubspec_overrides.yaml $(find $REPO_ROOT/cw_mweb/go -type f | sort))
### scripts/build_bitbox_flutter.sh
@@ -12,6 +12,11 @@ git reset --hard
git checkout 5a6e6dd388ef64003f86094af80d5453518b601d
git reset --hard
+if [[ "$1" == "clone-only" ]];
+then
+ exit 0
+fi
+
bash ./build_bindings.sh --dont-install
FILE=api.aar
### scripts/ios/build_monero_all.sh
@@ -1,26 +1,35 @@
-#!/bin/sh
-source "$(cd "$(dirname "$0")/.." && pwd)/functions.sh"
-
-. ./config.sh
-# ./install_missing_headers.sh
-# ./build_openssl.sh
-# ./build_boost.sh
-# ./build_sodium.sh
-# ./build_zmq.sh
-# ./build_unbound.sh
+#!/bin/bash
+source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/functions.sh"
set -x -e
cd "$(dirname "$0")"
../prepare_moneroc.sh
-for COIN in monero wownero zano;
+if [[ -n "${COIN:-}" ]]; then
+ COINS=("$COIN")
+else
+ COINS=(monero wownero zano)
+fi
+
+if [[ -n "${TARGET:-}" ]]; then
+ TARGETS=("$TARGET")
+else
+ TARGETS=(aarch64-apple-ios aarch64-apple-ios-simulator)
+fi
+
+for COIN in "${COINS[@]}";
do
pushd ../monero_c
- ./build_single.sh ${COIN} aarch64-apple-ios -j$MAKE_JOB_COUNT
- ./build_single.sh ${COIN} aarch64-apple-ios-simulator -j$MAKE_JOB_COUNT
+ for target in "${TARGETS[@]}"
+ do
+ ./build_single.sh ${COIN} $target -j$MAKE_JOB_COUNT
+ done
popd
done
-./gen_framework.sh
+# needs xcodebuild, on linux (ci cache) only the dylibs are produced
+if [[ "$(uname)" == "Darwin" ]]; then
+ ./gen_framework.sh
+fi
### scripts/ios/build_mwebd.sh
@@ -248,16 +248,17 @@ echo " iOS XCFramework: ${IOS_XCFRAMEWORK}"
echo ""
FFIGEN_CONFIG="${BASE_DIR}/../../cw_mweb/ffigen_config.yaml"
-if [[ -f "$FFIGEN_CONFIG" ]]; then
- echo "Updating ffigen configuration..."
- sed -i.bak "s|android/src/main/jniLibs/arm64-v8a/mweb.h|ios/${FRAMEWORK_NAME}.xcframework/ios-arm64/${FRAMEWORK_NAME}.framework/Headers/${FRAMEWORK_NAME}.h|g" "$FFIGEN_CONFIG"
- mv "$FFIGEN_CONFIG.bak" "$FFIGEN_CONFIG"
- echo "Updated ffigen config to use XCFramework header"
-fi
+IOS_FFIGEN_CONFIG="${BASE_DIR}/../../cw_mweb/.ffigen_config.ios.yaml"
+IOS_HEADER="ios/${FRAMEWORK_NAME}.xcframework/ios-arm64/${FRAMEWORK_NAME}.framework/Headers/${FRAMEWORK_NAME}.h"
+trap 'rm -f "$IOS_FFIGEN_CONFIG"' EXIT
+sed "s|android/src/main/jniLibs/arm64-v8a/libmweb.h|${IOS_HEADER}|g" "$FFIGEN_CONFIG" > "$IOS_FFIGEN_CONFIG"
+grep -qF "$IOS_HEADER" "$IOS_FFIGEN_CONFIG"
cd "${BASE_DIR}/../../cw_mweb"
+
echo "Generating Dart FFI bindings..."
-dart run ffigen --config ffigen_config.yaml
+dart run ffigen --config .ffigen_config.ios.yaml
+
echo "Build completed successfully!"
### scripts/ios/build_torch.sh
@@ -2,9 +2,21 @@
set -x -e
cd "$(dirname "$0")"
+DEFAULT_TARGETS=(
+ "aarch64-apple-ios-simulator"
+ "aarch64-apple-ios"
+ "aarch64-apple-darwin"
+ "x86_64-apple-darwin"
+)
+
+if [ "$#" -gt 0 ]; then
+ TARGETS=("$@")
+else
+ TARGETS=("${DEFAULT_TARGETS[@]}")
+fi
+
../prepare_torch.sh
cd ../torch_dart
-# Need to build all platforms to get .xcframework
-./build.sh aarch64-apple-ios-simulator aarch64-apple-ios aarch64-apple-darwin x86_64-apple-darwin
\ No newline at end of file
+./build.sh "${TARGETS[@]}"
### scripts/ios/docker/Dockerfile.base
@@ -0,0 +1,7 @@
+FROM --platform=linux/amd64 ghcr.io/cake-tech/cake_wallet:debian13-flutter3.41.9-ndkr28-go1.24.1-ruststablenightly
+
+RUN apt-get update \
+ && apt-get install -y --no-install-recommends libxml2-dev \
+ && rm -rf /var/lib/apt/lists/*
+
+WORKDIR /w
### scripts/ios/docker/Dockerfile.monero
@@ -0,0 +1,26 @@
+ARG BASE_IMAGE
+
+FROM --platform=linux/amd64 ${BASE_IMAGE} AS build
+
+COPY scripts/functions.sh /w/scripts/functions.sh
+COPY scripts/prepare_moneroc.sh /w/scripts/prepare_moneroc.sh
+COPY scripts/ios/build_monero_all.sh /w/scripts/ios/build_monero_all.sh
+
+ARG UID=10001
+ARG GID=10001
+ARG USER=builder
+RUN groupadd -g "$GID" "$USER" && \
+ useradd -m -u "$UID" -g "$GID" -s /bin/bash "$USER"
+
+RUN sudo chown $UID:$GID -R /w /root
+USER builder
+
+ARG COIN
+ARG TARGET
+ENV COIN=$COIN
+ENV TARGET=$TARGET
+RUN /w/scripts/ios/build_monero_all.sh \
+ && ls /w/scripts/monero_c/release/*/${TARGET}/lib${COIN}_wallet2_api_c.dylib
+
+FROM --platform=linux/amd64 alpine
+COPY --from=build /w/scripts/monero_c/release /w/scripts/monero_c/release
### scripts/ios/docker/Dockerfile.torch
@@ -0,0 +1,23 @@
+ARG BASE_IMAGE
+
+FROM --platform=linux/amd64 ${BASE_IMAGE} AS build
+
+COPY scripts/prepare_torch.sh /w/scripts/prepare_torch.sh
+COPY scripts/ios/build_torch.sh /w/scripts/ios/build_torch.sh
+ARG UID=10001
+ARG GID=10001
+ARG USER=builder
+RUN groupadd -g "$GID" "$USER" && \
+ useradd -m -u "$UID" -g "$GID" -s /bin/bash "$USER"
+
+RUN sudo chown $UID:$GID -R /w /root
+USER builder
+
+# simulator builds omitted for build time, idk why you'd need them on ci but you can add a target here
+RUN /w/scripts/ios/build_torch.sh aarch64-apple-ios \
+ && test -f /w/scripts/torch_dart/ios/LibTorch.xcframework/ios-arm64/LibTorch.framework/LibTorch \
+ && grep -q ios-arm64 /w/scripts/torch_dart/ios/LibTorch.xcframework/Info.plist \
+ && rm -rf /w/scripts/torch_dart/simplybs
+
+FROM --platform=linux/amd64 alpine
+COPY --from=build /w /w
### scripts/ios/docker/build.sh
@@ -0,0 +1,269 @@
+#!/usr/bin/env bash
+set -euo pipefail
+cd "$(dirname $0)"
+
+CW_DOCKER_REGISTRY="${CW_DOCKER_REGISTRY:-localhost/cake-tech/cake_wallet}"
+CW_DOCKER_USE_CLOUD="${CW_DOCKER_USE_CLOUD:-}"
+IMAGE_PREFIX="ios-deps"
+
+SCRIPT_DIR="$(pwd)"
+REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
+
+ONLY=""
+TARGET=""
+COIN=""
+MERGE=false
+IMAGE=""
+
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ --only)
+ ONLY="$2"
+ shift 2
+ ;;
+ --target)
+ TARGET="$2"
+ shift 2
+ ;;
+ --coin)
+ COIN="$2"
+ shift 2
+ ;;
+ --merge)
+ MERGE=true
+ shift
+ ;;
+ --image)
+ IMAGE="$2"
+ shift 2
+ ;;
+ -h|--help)
+ echo "Usage: $0 [--only base|torch|monero] [--coin COIN] [--target TRIPLE] [--merge] [--image base|torch|monero]"
+ exit 0
+ ;;
+ *)
+ echo "Unknown argument: $1" >&2
+ exit 1
+ ;;
+ esac
+done
+
+MONERO_COINS=(monero)
+# simulator builds omitted for build time, add aarch64-apple-ios-simulator here if you need them
+MONERO_TARGETS=(aarch64-apple-ios)
+
+image_exists() {
+ docker image inspect "$1" &>/dev/null
+}
+
+tinysha() {
+ if command -v sha256sum >/dev/null 2>&1; then
+ cat "$@" | sha256sum | cut -c1-6
+ else
+ cat "$@" | shasum -a 256 | cut -c1-6
+ fi
+}
+
+monero_assembled_extra() {
+ local tmp coin t
+ tmp="$(mktemp)"
+ for coin in "${MONERO_COINS[@]}"; do
+ for t in "${MONERO_TARGETS[@]}"; do
+ echo "-${coin}-${t}" >> "$tmp"
+ done
+ done
+ echo "-merged-$(tinysha "$tmp")"
+ rm -f "$tmp"
+}
+
+img() {
+ local name="$1"
+ local version="$2"
+ local extra="${3:-}"
+ echo "$CW_DOCKER_REGISTRY:${IMAGE_PREFIX}-${name}-$(tinysha "$SCRIPT_DIR/Dockerfile.${name}")-${version}${extra}"
+}
+
+remote_exists() {
+ local tag="$1"
+ if docker buildx version >/dev/null 2>&1; then
+ docker buildx imagetools inspect "$tag" >/dev/null 2>&1
+ return
+ fi
+ DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect "$tag" >/dev/null 2>&1
+}
+
+cached() {
+ local tag="$1"
+ if image_exists "$tag"; then
+ return 0
+ fi
+ if [[ "x$CW_DOCKER_USE_CLOUD" == "xtrue" ]] && remote_exists "$tag"; then
+ return 0
+ fi
+ return 1
+}
+
+maybe_push() {
+ local tag="$1"
+ if [[ "x$CW_DOCKER_USE_CLOUD" == "xtrue" ]]; then
+ docker push "$tag"
+ fi
+}
+
+build() {
+ local name="$1"; shift
+ local version="$1"; shift
+ local extra="$1"; shift
+ local tag
+ tag="$(img "$name" "$version" "$extra")"
+ if cached "$tag"; then
+ echo "==> skipping $name${extra} (cached: $tag)"
+ return 0
+ fi
+ echo "==> building $name${extra}"
+ docker build \
+ --platform linux/amd64 \
+ --file "$SCRIPT_DIR/Dockerfile.${name}" \
+ --tag "$tag" \
+ "$@" \
+ "$REPO_ROOT"
+ maybe_push "$tag"
+}
+
+merge_slices() {
+ local name="$1"
+ local version="$2"
+ local extra="$3"
+ shift 3
+ local dest
+ dest="$(img "$name" "$version" "$extra")"
+ if cached "$dest"; then
+ echo "==> skipping merge $name (cached: $dest)"
+ return 0
+ fi
+
+ local slices=("$@")
+ local dockerfile
+ dockerfile="$(mktemp)"
+ local build_args=()
+ local i=0
+ for slice in "${slices[@]}"; do
+ echo "ARG SRC${i}" >> "$dockerfile"
+ i=$((i + 1))
+ done
+ i=0
+ for slice in "${slices[@]}"; do
+ if ! cached "$slice"; then
+ echo "merge_slices: missing slice $slice" >&2
+ rm -f "$dockerfile"
+ exit 1
+ fi
+ echo "FROM --platform=linux/amd64 \${SRC${i}} AS s${i}" >> "$dockerfile"
+ build_args+=(--build-arg "SRC${i}=$slice")
+ i=$((i + 1))
+ done
+ echo "FROM --platform=linux/amd64 alpine" >> "$dockerfile"
+ i=0
+ for slice in "${slices[@]}"; do
+ echo "COPY --from=s${i} /w /w" >> "$dockerfile"
+ i=$((i + 1))
+ done
+
+ echo "==> merging $name from ${#slices[@]} slices -> $dest"
+ docker build \
+ --platform linux/amd64 \
+ --file "$dockerfile" \
+ --tag "$dest" \
+ "${build_args[@]}" \
+ "$SCRIPT_DIR"
+ rm -f "$dockerfile"
+ maybe_push "$dest"
+}
+
+base_ver="latest"
+torch_ver="$(tinysha $SCRIPT_DIR/Dockerfile.torch $REPO_ROOT/scripts/prepare_torch.sh $REPO_ROOT/scripts/ios/build_torch.sh)"
+monero_ver="$(tinysha $SCRIPT_DIR/Dockerfile.monero $REPO_ROOT/scripts/functions.sh $REPO_ROOT/scripts/prepare_moneroc.sh $REPO_ROOT/scripts/ios/build_monero_all.sh)"
+
+# `./build.sh --image torch` prints the ref without touching docker, so the
+# macOS runner can resolve the same tag before pulling it with crane.
+if [[ -n "$IMAGE" ]]; then
+ case "$IMAGE" in
+ base) img base "$base_ver" ;;
+ torch) img torch "$torch_ver" ;;
+ monero) img monero "$monero_ver" "$(monero_assembled_extra)" ;;
+ *) echo "usage: $0 --image base|torch|monero" >&2; exit 1 ;;
+ esac
+ exit 0
+fi
+
+build_base() {
+ build base "$base_ver" ""
+}
+
+build_torch() {
+ build torch "$torch_ver" "" --build-arg BASE_IMAGE="$(img base "$base_ver")"
+ echo "done: $(img torch $torch_ver)"
+ echo $(img torch $torch_ver) > /tmp/cakewallet_ios_torch
+}
+
+build_monero_slice() {
+ local coin="$1"
+ local target="$2"
+ build monero "$monero_ver" "-${coin}-${target}" \
+ --build-arg BASE_IMAGE="$(img base "$base_ver")" \
+ --build-arg COIN="$coin" \
+ --build-arg TARGET="$target"
+}
+
+build_monero() {
+ local coins=("${MONERO_COINS[@]}")
+ local targets=("${MONERO_TARGETS[@]}")
+ local coin t
+ [[ -n "$COIN" ]] && coins=("$COIN")
+ [[ -n "$TARGET" ]] && targets=("$TARGET")
+ for coin in "${coins[@]}"; do
+ for t in "${targets[@]}"; do
+ build_monero_slice "$coin" "$t"
+ done
+ done
+}
+
+merge_monero() {
+ local slices=()
+ local coin t
+ for coin in "${MONERO_COINS[@]}"; do
+ for t in "${MONERO_TARGETS[@]}"; do
+ slices+=("$(img monero "$monero_ver" "-${coin}-${t}")")
+ done
+ done
+ merge_slices monero "$monero_ver" "$(monero_assembled_extra)" "${slices[@]}"
+ echo "done: $(img monero "$monero_ver" "$(monero_assembled_extra)")"
+}
+
+case "$ONLY" in
+ "")
+ build_base
+ build_torch
+ build_monero
+ merge_monero
+ ;;
+ base)
+ build_base
+ ;;
+ torch)
+ build_base
+ build_torch
+ ;;
+ monero)
+ if [[ "$MERGE" == true ]]; then
+ merge_monero
+ else
+ build_base
+ build_monero
+ fi
+ ;;
+ *)
+ echo "Unknown component: $ONLY" >&2
+ exit 1
+ ;;
+esac
### scripts/ios/gen_framework.sh
@@ -2,7 +2,7 @@
set -e
IOS_DIR="$(pwd)/../../ios"
-monero_c_tag=$(cd $(pwd)/../../scripts/monero_c/; git describe --tags)
+monero_c_tag="${MONEROC_TAG:-$(cd "$(pwd)/../../scripts/monero_c/" && git describe --tags)}"
DYLIB_PATH="$(pwd)/../../scripts/monero_c/release/${monero_c_tag}/"
TMP_DIR="${IOS_DIR}/tmp"
@@ -115,18 +115,18 @@ create_framework() {
}
create_xcframework() {
- framework_name="$1"
- device_framework="$2"
- simulator_framework="$3"
- xcframework_output="$4"
+ xcframework_output="$1"
+ shift
echo "Creating ${xcframework_output} by bundling:"
- echo " Device framework: ${device_framework}"
- echo " Simulator framework: ${simulator_framework}"
+ args=()
+ for framework in "$@"; do
+ echo " ${framework}"
+ args+=(-framework "$framework")
+ done
xcodebuild -create-xcframework \
- -framework "$device_framework" \
- -framework "$simulator_framework" \
+ "${args[@]}" \
-output "$xcframework_output"
echo "Created XCFramework: ${xcframework_output}"
@@ -139,20 +139,29 @@ for i in "${!wallets[@]}"; do
wallet="${wallets[$i]}"
framework_name="${framework_names[$i]}"
+ if [[ ! -f "${DYLIB_PATH}/aarch64-apple-ios/lib${wallet}_wallet2_api_c.dylib" ]]; then
+ echo "Skipping ${framework_name}.xcframework, no ${wallet} dylib"
+ continue
+ fi
+
device_out="${TMP_DIR}/${framework_name}_device"
simulator_out="${TMP_DIR}/${framework_name}_simulator"
rm -rf "$device_out" "$simulator_out"
mkdir -p "$device_out" "$simulator_out"
create_framework "$wallet" "$framework_name" "ios" "$device_out"
- create_framework "$wallet" "$framework_name" "ios-simulator" "$simulator_out"
+ frameworks=("${device_out}/${framework_name}.framework")
+
+ # ci only builds the device slice
+ if [[ -f "${DYLIB_PATH}/aarch64-apple-ios-simulator/lib${wallet}_wallet2_api_c.dylib" ]]; then
+ create_framework "$wallet" "$framework_name" "ios-simulator" "$simulator_out"
+ frameworks+=("${simulator_out}/${framework_name}.framework")
+ fi
- device_framework="${device_out}/${framework_name}.framework"
- simulator_framework="${simulator_out}/${framework_name}.framework"
xcframework_output="${IOS_DIR}/${framework_name}.xcframework"
rm -rf "$xcframework_output"
- create_xcframework "$framework_name" "$device_framework" "$simulator_framework" "$xcframework_output"
+ create_xcframework "$xcframework_output" "${frameworks[@]}"
done
echo "All XCFrameworks created successfully."
### scripts/linux/docker/Dockerfile.reown
@@ -2,6 +2,7 @@ ARG BASE_IMAGE
FROM --platform=linux/amd64 ${BASE_IMAGE} AS build
RUN mkdir -p /w/scripts/android
+COPY scripts/functions.sh /w/scripts/functions.sh
COPY scripts/prepare_reown.sh /w/scripts/prepare_reown.sh
COPY scripts/android/build_reown_deps.sh /w/scripts/android/build_reown_deps.sh
RUN cd $(dirname $(which flutter)) && git checkout 3.32.0
### scripts/linux/docker/build.sh
@@ -216,7 +216,7 @@ merge_slices() {
base_ver="latest"
torch_ver="$(tinysha $SCRIPT_DIR/Dockerfile.torch $REPO_ROOT/scripts/prepare_torch.sh $REPO_ROOT/scripts/linux/build_torch.sh)"
-reown_ver=$(tinysha $SCRIPT_DIR/Dockerfile.reown $REPO_ROOT/scripts/prepare_reown.sh $REPO_ROOT/scripts/android/build_reown_deps.sh)
+reown_ver=$(tinysha $SCRIPT_DIR/Dockerfile.reown $REPO_ROOT/scripts/functions.sh $REPO_ROOT/scripts/prepare_reown.sh $REPO_ROOT/scripts/android/build_reown_deps.sh)
bitbox_ver=$(tinysha $SCRIPT_DIR/Dockerfile.bitbox $REPO_ROOT/scripts/build_bitbox_flutter.sh)
monero_ver=$(tinysha $SCRIPT_DIR/Dockerfile.monero $REPO_ROOT/scripts/prepare_moneroc.sh $REPO_ROOT/scripts/linux/build_monero_all.sh)
mwebd_ver=$(tinysha $SCRIPT_DIR/Dockerfile.mwebd $REPO_ROOT/pubspec_overrides.yaml $(find $REPO_ROOT/cw_mweb/go -type f | sort))
### scripts/prepare_reown.sh
@@ -1,4 +1,5 @@
#!/bin/bash
+source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/functions.sh"
set -x -e
cd "$(dirname "$0")"
@@ -23,4 +24,31 @@ git reset --hard
git checkout $HASH
git reset --hard
+# this abomination of seds is needed because the version of reown we use has old dependencies that fail to properly run the codegen on 3.41
+# should we ever upgrade reown this won't be needed
+
+
+for pkg in reown_appkit reown_core reown_sign reown_walletkit reown_yttrium; do
+ universal_sed '
+s|^ freezed: \^2\.5\.7$| freezed: ^2.5.8|
+s|^ dependency_validator: \^4\.1\.2$| dependency_validator: ^5.1.0|
+' "packages/$pkg/pubspec.yaml"
+done
+
+# disables codegen/resolving for the examples. i really could not care less about them
+for gen in packages/reown_appkit/generate_files.sh packages/reown_walletkit/generate_files.sh; do
+ universal_sed '
+1,/^cd example/ s|^flutter pub get$|flutter pub get --no-example|
+/^cd example/,$ {
+ s|^flutter clean$|#flutter clean|
+ s|^flutter pub get$|#flutter pub get|
+ s|^dart run build_runner build --delete-conflicting-outputs$|#dart run build_runner build --delete-conflicting-outputs|
+ s|^cd ios$|#cd ios|
+ s|^rm Podfile\.lock$|#rm Podfile.lock|
+ /^pod install$/ { s|^|#|; n; s|^cd \.\.$|#cd ..|; }
+}
+' "$gen"
+done
+
+
./scripts/generate_all.sh
\ No newline at end of file
### scripts/prepare_torch.sh
@@ -7,7 +7,7 @@ cd "$(dirname "$0")"
# - .github/workflows/pr_test_build_linux.yml
# https://github.com/MrCyjaneK/torch_dart/releases/download/v1.0.17/torch_dart-v1.0.17.tar.gz
-HASH=a8601eaef00ac4a9465a0979b7d7a16df90bc364
+HASH=0aa029e4dce8162d0650918f1ac5ada6df87f991
if [[ ! -d "torch_dart/.git" ]];
then
### tool/download_moneroc_prebuilds.dart
@@ -1,6 +1,5 @@
import 'dart:io';
-import './print_verbose_dummy.dart';
import 'package:dio/dio.dart';
import 'package:archive/archive_io.dart';
@@ -27,36 +26,59 @@ final List<String> triplets = [
"aarch64-apple-ios-simulator",
];
+const _maxAttempts = 4;
+
+Future<T> _withRetry<T>(String what, Future<T> Function() operation) async {
+ for (var attempt = 1;; attempt++) {
+ try {
+ return await operation();
+ } catch (error) {
+ if (attempt >= _maxAttempts) {
+ rethrow;
+ }
+ final wait = Duration(seconds: 5 * attempt);
+ print(" $what failed (attempt $attempt/$_maxAttempts): $error");
+ print(" retrying in ${wait.inSeconds}s");
+ await Future.delayed(wait);
+ }
+ }
+}
+
Future<void> main() async {
- final resp = await _dio.get("https://api.github.com/repos/mrcyjanek/monero_c/releases");
+ final resp = await _withRetry(
+ "release list",
+ () => _dio.get("https://api.github.com/repos/mrcyjanek/monero_c/releases"),
+ );
final data = resp.data[0];
final tagName = data['tag_name'];
print("Downloading artifacts for: ${tagName}");
final assets = data['assets'] as List<dynamic>;
- for (var i = 0; i < assets.length; i++) {
- for (var triplet in triplets) {
- final asset = assets[i];
- final filename = asset["name"] as String;
- if (!filename.contains(triplet)) continue;
- final coin = filename.split("_")[0];
- String localFilename = filename.replaceAll("${coin}_${triplet}_", "");
- localFilename = "scripts/monero_c/release/${coin}/${triplet}_${localFilename}";
- final url = asset["browser_download_url"] as String;
- print("- downloading $localFilename");
- await _dio.download(url, localFilename);
- if (localFilename.endsWith(".xz")) {
- print(" extracting $localFilename");
- final inputStream = InputFileStream(localFilename);
- final archive = XZDecoder().decodeBytes(inputStream.toUint8List());
- final outputStream = OutputFileStream(localFilename.replaceAll(".xz", ""));
- outputStream.writeBytes(archive);
- }
- }
+ final bundle = assets.firstWhere((asset) => asset["name"] == "release-bundle.zip");
+ const bundlePath = "scripts/monero_c/release-bundle.zip";
+ print("- downloading $bundlePath");
+ await _withRetry(
+ "release-bundle.zip",
+ () => _dio.download(bundle["browser_download_url"] as String, bundlePath),
+ );
+ final archive = ZipDecoder().decodeStream(InputFileStream(bundlePath));
+ for (final file in archive) {
+ final parts = file.name.split("/");
+ if (!file.isFile || parts.length != 3 || !triplets.contains(parts[1])) continue;
+ final localFilename = "scripts/monero_c/release/${file.name}";
+ print(" extracting $localFilename");
+ Directory(File(localFilename).parent.path).createSync(recursive: true);
+ final outputStream = OutputFileStream(localFilename);
+ file.writeContent(outputStream);
+ outputStream.closeSync();
}
+ File(bundlePath).deleteSync();
if (Platform.isMacOS) {
print("Generating ios framework");
- final result =
- Process.runSync("bash", ["-c", "cd scripts/ios && ./gen_framework.sh && cd ../.."]);
+ final result = Process.runSync(
+ "bash",
+ ["-c", "cd scripts/ios && ./gen_framework.sh && cd ../.."],
+ environment: {"MONEROC_TAG": tagName as String},
+ );
print((result.stdout + result.stderr).toString().trim());
}
}
### tool/set_testflight_changelog.dart
@@ -0,0 +1,259 @@
+import 'dart:async';
+import 'dart:convert';
+import 'dart:io';
+import 'dart:typed_data';
+
+// posts app changelog to testflight using appstore connect api
+// mostly for use in ios ci, you can see how it's called there.
+// dart: only, no packages - runs on a bare linux checkout with no pub get,
+// which is how the wait for apple stays off the macos runner.
+
+final String _api = Platform.environment["ASC_API_BASE"] ?? "https://api.appstoreconnect.apple.com";
+
+const _locale = "en-US";
+const _whatsNewLimit = 4000;
+const _pollInterval = Duration(seconds: 15);
+const _maxAttempts = 4;
+const _tokenLifetime = Duration(minutes: 15);
+const _tokenMargin = Duration(minutes: 2);
+
+final Duration _pollTimeout =
+ Duration(seconds: int.tryParse(Platform.environment["ASC_POLL_TIMEOUT"] ?? "") ?? 1000);
+
+const _requestTimeout = Duration(seconds: 60);
+
+final _client = HttpClient()..connectionTimeout = const Duration(seconds: 30);
+
+class _ApiException implements Exception {
+ _ApiException(this.status, this.body);
+
+ final int status;
+ final String body;
+
+ @override
+ String toString() => "HTTP $status\n$body";
+}
+
+Never _fail(String message) {
+ stderr.writeln(message);
+ exit(1);
+}
+
+String _env(String name) => Platform.environment[name]!;
+
+String _b64(List<int> bytes) => base64Url.encode(bytes).replaceAll("=", "");
+
+Uint8List _derToRaw(Uint8List der, {int size = 32}) {
+ if (der[0] != 0x30) {
+ throw const FormatException("signature is not a DER sequence");
+ }
+ if (der[1] & 0x80 != 0) {
+ throw const FormatException("unexpected long-form DER length");
+ }
+ final out = BytesBuilder();
+ var i = 2;
+ for (var member = 0; member < 2; member++) {
+ if (der[i] != 0x02) {
+ throw const FormatException("signature member is not a DER integer");
+ }
+ final length = der[i + 1];
+ var value = der.sublist(i + 2, i + 2 + length);
+ i += 2 + length;
+ var start = 0;
+ while (start < value.length - 1 && value[start] == 0) {
+ start++;
+ }
+ value = value.sublist(start);
+ if (value.length > size) {
+ throw const FormatException("signature member is too large for P-256");
+ }
+ out.add(Uint8List(size - value.length)); // left pad
+ out.add(value);
+ }
+ return out.takeBytes();
+}
+
+Future<Uint8List> _sign(List<int> input, String keyPath) async {
+ final process = await Process.start("openssl", ["dgst", "-sha256", "-sign", keyPath]);
+ final stdoutBytes = process.stdout.fold<BytesBuilder>(BytesBuilder(), (b, d) => b..add(d));
+ final stderrText = systemEncoding.decodeStream(process.stderr);
+ process.stdin.add(input);
+ await process.stdin.close();
+ if (await process.exitCode != 0) {
+ _fail("openssl could not sign with $keyPath: ${(await stderrText).trim()}");
+ }
+ return (await stdoutBytes).takeBytes();
+}
+
+String? _jwt;
+DateTime _jwtExpiry = DateTime.fromMillisecondsSinceEpoch(0);
+
+// generates jwt from our
+Future<String> _token() async {
+ final now = DateTime.now();
+ final cached = _jwt;
+ if (cached != null && now.isBefore(_jwtExpiry.subtract(_tokenMargin))) {
+ return cached;
+ }
+
+ final expiry = now.add(_tokenLifetime);
+ final header = {"alg": "ES256", "kid": _env("ASC_KEY_ID"), "typ": "JWT"};
+ final claims = {
+ "sub": "user", // individual key, those take no iss
+ "iat": now.millisecondsSinceEpoch ~/ 1000,
+ "exp": expiry.millisecondsSinceEpoch ~/ 1000,
+ "aud": "appstoreconnect-v1",
+ };
+ final signingInput = utf8.encode(
+ "${_b64(utf8.encode(json.encode(header)))}.${_b64(utf8.encode(json.encode(claims)))}",
+ );
+
+ final signature = _derToRaw(await _sign(signingInput, _env("ASC_KEY_PATH")));
+ _jwt = "${utf8.decode(signingInput)}.${_b64(signature)}";
+ _jwtExpiry = expiry;
+ return _jwt!;
+}
+
+bool _isTransient(Object error) {
+ if (error is _ApiException) {
+ return error.status >= 500 || error.status == 429;
+ }
+ return error is SocketException || error is TimeoutException || error is HttpException;
+}
+
+Future<T> _withRetry<T>(String what, Future<T> Function() operation) async {
+ for (var attempt = 1;; attempt++) {
+ try {
+ return await operation();
+ } catch (error) {
+ if (attempt >= _maxAttempts || !_isTransient(error)) {
+ rethrow;
+ }
+ final wait = Duration(seconds: 5 * attempt);
+ print(" $what failed (attempt $attempt/$_maxAttempts): $error");
+ print(" retrying in ${wait.inSeconds}s");
+ await Future.delayed(wait);
+ }
+ }
+}
+
+Future<Map<String, dynamic>> _send(String method, Uri uri, Map<String, dynamic>? body) async {
+ final request = await _client.openUrl(method, uri);
+ // minted per attempt, so a long backoff cannot send one that expired waiting
+ request.headers.set(HttpHeaders.authorizationHeader, "Bearer ${await _token()}");
+ if (body != null) {
+ final payload = utf8.encode(json.encode(body));
+ request.headers.contentType = ContentType.json;
+ // without this dart sends the body chunked, which not every server accepts
+ request.contentLength = payload.length;
+ request.add(payload);
+ }
+
+ final response = await request.close().timeout(_requestTimeout);
+ final text = await utf8.decodeStream(response).timeout(_requestTimeout);
+ if (response.statusCode >= 300) {
+ throw _ApiException(response.statusCode, text);
+ }
+ return text.isEmpty ? <String, dynamic>{} : json.decode(text) as Map<String, dynamic>;
+}
+
+Future<Map<String, dynamic>> _call(String method, Uri uri, {Map<String, dynamic>? body}) async {
+ try {
+ return await _withRetry("$method ${uri.path}", () => _send(method, uri, body));
+ } catch (error) {
+ _fail("$method $uri\n$error");
+ }
+}
+
+Future<void> main() async {
+ final bundleId = _env("IOS_BUNDLE_ID");
+ final buildNumber = _env("BUILD_NUMBER");
+
+ final message = (await utf8.decodeStream(stdin)).trim();
+ final whatsNew = message.length > _whatsNewLimit ? message.substring(0, _whatsNewLimit) : message;
+
+ final apps = await _call(
+ "GET",
+ Uri.parse("$_api/v1/apps").replace(queryParameters: {"filter[bundleId]": bundleId}),
+ );
+ final matches = apps["data"] as List<dynamic>;
+ final appId = matches.first["id"] as String;
+
+ final filters = {
+ "filter[app]": appId,
+ "filter[version]": buildNumber,
+ "sort": "-uploadedDate",
+ "limit": "1",
+ };
+ final appVersion = Platform.environment["APP_VERSION"];
+ if (appVersion != null && appVersion.isNotEmpty) {
+ filters["filter[preReleaseVersion.version]"] = appVersion;
+ }
+ final buildsUri = Uri.parse("$_api/v1/builds").replace(queryParameters: filters);
+
+ final deadline = DateTime.now().add(_pollTimeout);
+ String buildId;
+ while (true) {
+ final builds = await _call("GET", buildsUri);
+ final found = builds["data"] as List<dynamic>;
+ if (found.isNotEmpty) {
+ buildId = found.first["id"] as String;
+ break;
+ }
+ if (!DateTime.now().isBefore(deadline)) {
+ _fail("build $buildNumber never appeared in App Store Connect within "
+ "${_pollTimeout.inSeconds}s.\nThe upload itself succeeded - only the changelog is "
+ "missing; you can paste it into TestFlight by hand.");
+ }
+ print("waiting for App Store Connect to register build $buildNumber");
+ await Future.delayed(_pollInterval);
+ }
+
+ print("build $buildNumber is $buildId");
+
+ // Apple creates an empty localization on its own once processing starts, so
+ // this has to update in place as often as it creates.
+ final existing = await _call(
+ "GET",
+ Uri.parse("$_api/v1/builds/$buildId/betaBuildLocalizations"),
+ );
+ final mine = (existing["data"] as List<dynamic>)
+ .where((localization) => localization["attributes"]["locale"] == _locale)
+ .toList();
+
+ if (mine.isNotEmpty) {
+ final id = mine.first["id"] as String;
+ await _call(
+ "PATCH",
+ Uri.parse("$_api/v1/betaBuildLocalizations/$id"),
+ body: {
+ "data": {
+ "type": "betaBuildLocalizations",
+ "id": id,
+ "attributes": {"whatsNew": whatsNew},
+ },
+ },
+ );
+ } else {
+ await _call(
+ "POST",
+ Uri.parse("$_api/v1/betaBuildLocalizations"),
+ body: {
+ "data": {
+ "type": "betaBuildLocalizations",
+ "attributes": {"locale": _locale, "whatsNew": whatsNew},
+ "relationships": {
+ "build": {
+ "data": {"type": "builds", "id": buildId},
+ },
+ },
+ },
+ },
+ );
+ }
+
+ _client.close(); // a kept-alive connection would hold the vm open
+
+ print("changelog set:");
+ print(whatsNew.split("\n").map((line) => " $line").join("\n"));
+}Why this scored 20/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.