deepScanRefusalMessage function

String deepScanRefusalMessage(
  1. WalletLocalizations l10n,
  2. WalletApiError e
)

Map a typed WalletApiError from the deep scan to its honest copy: the two refusal reasons get distinct guidance; anything else is the neutral "couldn't start" (nothing changed).

Implementation

String deepScanRefusalMessage(WalletLocalizations l10n, WalletApiError e) {
  final kind = e.kind;
  if (kind is WalletErrorKind_SwapAddressCheckRefused) {
    return switch (kind.reason) {
      SwapAddressCheckRefusal.swapDisabled =>
        l10n.walletDeepScanRefusedDisabled,
      SwapAddressCheckRefusal.checkOutstanding =>
        l10n.walletDeepScanRefusedOutstanding,
      SwapAddressCheckRefusal.unknown => l10n.walletDeepScanFailed,
    };
  }
  return l10n.walletDeepScanFailed;
}