Files
jwinterm 04ed46aca3 Deep Cake scrub: gut user-visible refs, swap SVG asset contents
URL replacements throughout lib/:
- support_view_model.dart: removed Cake's own support channels (email,
  website, forum, Telegram, Telegram bot). Only GitHub Issues + Releases
  remain. Third-party provider support links (ChangeNow, SideShift,
  SimpleSwap, Exolix, Trocador, Onramper, DFX, MoonPay, Robinhood,
  Kryptonim) kept — genuinely useful when a swap goes sideways.
- transaction_details_view_model.dart + payjoin_details_view_model.dart:
  mempool.cakewallet.com -> mempool.space (canonical free public mempool,
  no affiliate).
- services_updates_widget.dart: status.cakewallet.com -> our GH issues.
- 8 widget/screen files: docs.cakewallet.com / blog / cakewallet.com help
  URLs repointed to github.com/Such-Software/hash-wallet (placeholder
  until we have our own docs; better than dead-linking to Cake's docs).

User-facing text changes:
- walletkit_service.dart: WalletKit metadata (name/description/url/icon/
  redirect) all -> Hash Wallet / Such Software repo / hashwallet:// scheme.
- di.dart: TrezorConnect callback URL + appName -> Hash Wallet.
- vulnerable_seeds_popup.dart + haven_wallet_removal_popup.dart: copy
  rewritten to say 'Hash Wallet' instead of 'Cake Wallet', and point to
  GH issues instead of Cake's support email.
- swap_provider_initial_preference_modal.dart: trailing 'Cake Wallet.'
  -> 'Hash Wallet.'

Deep-link URL scheme cakewallet:// -> hashwallet:// in:
- lib/main.dart, lib/src/screens/root/root.dart, lib/view_model/link_view_model.dart
  Means any cakewallet:// link from a payment QR / Trezor callback /
  shortcut now routes via hashwallet://. No existing user base so no
  migration needed.

SVG asset swaps (content replaced, filenames kept so call-sites compile
without rewriting):
- assets/new-ui/cake_squircle_icon.svg -> hash_wallet/02_app_icon.svg
- assets/new-ui/cakewallet-wordmark-light.svg -> hash_wallet/03_lockup_horizontal.svg
  (dark text for light backgrounds)
- assets/new-ui/cakewallet-wordmark.svg -> hash_wallet/03_lockup_horizontal_dark.svg
  (light text for dark backgrounds)
- apps_widget.dart: the conditional cakelabs-icon render became a SizedBox()
  no-op. The Apps tab is gutted anyway (placeholder content); this widget
  is also used elsewhere where the Cake Labs attribution badge is unwanted.
2026-05-16 11:54:49 -04:00

163 lines
4.2 KiB
Dart

import 'dart:async';
import 'package:hash_wallet/generated/i18n.dart';
import 'package:hash_wallet/reactions/wallet_connect.dart';
import 'package:hash_wallet/routes.dart';
import 'package:hash_wallet/store/app_store.dart';
import 'package:hash_wallet/store/authentication_store.dart';
import 'package:hash_wallet/store/settings_store.dart';
import 'package:hash_wallet/utils/payment_request.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
class LinkViewModel {
LinkViewModel({
required this.settingsStore,
required this.appStore,
required this.authenticationStore,
required this.navigatorKey,
});
final SettingsStore settingsStore;
final AppStore appStore;
final AuthenticationStore authenticationStore;
final GlobalKey<NavigatorState> navigatorKey;
Uri? currentLink;
bool readyToOpenPage = false;
bool get _isValidPaymentUri => currentLink?.path.isNotEmpty ?? false;
bool get isWalletConnectLink => currentLink?.authority == 'wc';
bool get isNanoGptLink => currentLink?.scheme == 'nano-gpt';
bool get isQuickActionLink =>
currentLink?.scheme == 'hashwallet' && currentLink?.host == 'quickaction';
String? getRouteToGo() {
if (isWalletConnectLink) {
if (!isWalletConnectCompatibleChain(appStore.wallet!.type)) {
_errorToast(S.current.switchToEVMCompatibleWallet);
return null;
}
return Routes.walletConnectConnectionsListing;
}
// Check for a quick action first.
if (isQuickActionLink) {
final action = currentLink!.pathSegments.isNotEmpty ? currentLink!.pathSegments.first : null;
switch (action) {
case 'send':
return Routes.send;
case 'receive':
return Routes.addressPage;
default:
return null;
}
}
if (authenticationStore.state == AuthenticationState.uninitialized) {
return null;
}
if (isNanoGptLink) {
switch (currentLink?.authority ?? '') {
case "exchange":
return Routes.exchange;
case "send":
return Routes.send;
case "buy":
return Routes.buySellPage;
}
}
if (_isValidPaymentUri) {
return Routes.send;
}
return null;
}
dynamic getRouteArgs() {
if (isWalletConnectLink) {
return currentLink;
}
if (isQuickActionLink) {
return null;
}
if (isNanoGptLink) {
switch (currentLink?.authority ?? '') {
case "exchange":
return PaymentRequest.fromUri(currentLink);
case "send":
return {"paymentRequest": PaymentRequest.fromUri(currentLink)};
case "buy":
return true;
}
}
if (_isValidPaymentUri) {
return {"paymentRequest": PaymentRequest.fromUri(currentLink)};
}
return null;
}
Future<void> _errorToast(String message, {double fontSize = 16}) async {
try {
await Fluttertoast.showToast(
msg: message,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.SNACKBAR,
backgroundColor: Colors.black,
textColor: Colors.white,
fontSize: fontSize,
);
} catch (_) {}
}
Future<void> markReadyToOpenPage() async {
readyToOpenPage = true;
await handleLink();
}
Future<void> handleLink() async {
if (!readyToOpenPage) {
return;
}
String? route = getRouteToGo();
dynamic args = getRouteArgs();
if (route != null) {
if (appStore.wallet == null) {
return;
}
// Prevent navigating to the same route again.
if (appStore.currentRouteName == route) {
return;
}
if (isNanoGptLink) {
if (route == Routes.buySellPage || route == Routes.exchange) {
await _errorToast(S.current.nano_gpt_thanks_message, fontSize: 14);
}
}
// Quick actions must reset navigation to Dashboard → TargetPage
if (isQuickActionLink) {
currentLink = null;
navigatorKey.currentState?.pushNamedAndRemoveUntil(
route,
ModalRoute.withName(Routes.dashboard),
arguments: args,
);
return;
}
// Normal navigation flow
currentLink = null;
navigatorKey.currentState?.pushNamed(route, arguments: args);
}
}
}