What changed, and why it matters
This commit fixes three user-facing bugs in a crypto wallet app: it prevents a token-selection bottom sheet from appearing for non-EVM wallets, makes sure BSC (Binance Smart Chain) transactions display fees in BNB instead of ETH, and avoids a crash when a swap currency has no icon image. These are correctness and UI fixes rather than obvious security vulnerabilities, but the fee-currency mix-up could confuse users about transaction costs.
Treat as a routine bug-fix commit. Review whether the new EVMChainUtils.getFeeCurrency helper covers all supported chain IDs and confirm that the non-EVM guard does not skip legitimate payment-request flows. No immediate security response is indicated.
Security signals we found
UI state/logic guard added to avoid incorrect bottom-sheet behavior on non-EVM wallets
Fee-currency mapping corrected for BSC (chain 56) to show BNB instead of defaulting to ETH
Null-safety fix for missing swap currency icon path
Evidence from the diff
The patch makes three changes: (1) In send_card.dart it adds guards (evm != null && isEVMCompatibleChain(…) && newResult.chainId != null) before comparing chain IDs, so non-EVM wallets no longer trigger EVM-specific compatibility checks. (2) In evm_chain_wallet.dart it replaces a hard-coded fee-currency switch (137 => POL, _ => ETH) with EVMChainUtils.getFeeCurrency(selectedChainId) and adds chain 56 (BNB) to the native-currency mapping, correcting fee display for BSC wallets. (3) In swap_confirmation_bottom_sheet.dart it changes detectedCurrency.iconPath! to detectedCurrency.iconPath ?? ‘’, preventing a null-dereference crash when an icon path is missing.
Changed components
cw_evm/lib/evm_chain_wallet.dartlib/src/screens/send/widgets/send_card.dartlib/src/widgets/bottom_sheet/swap_confirmation_bottom_sheet.dartInspect captured patch +24 / −16
diff --git a/cw_evm/lib/evm_chain_wallet.dart b/cw_evm/lib/evm_chain_wallet.dart
index 1649e796..ea1312e2 100644
--- a/cw_evm/lib/evm_chain_wallet.dart
+++ b/cw_evm/lib/evm_chain_wallet.dart
@@ -1020,7 +1020,7 @@ abstract class EVMChainWalletBase
gasFee: estimatedFeesForTransaction,
priority: _credentials.priority,
currency: transactionCurrency,
- feeCurrency: switch (selectedChainId) { 137 => "POL", _ => "ETH" },
+ feeCurrency: EVMChainUtils.getFeeCurrency(selectedChainId),
maxFeePerGas: maxFeePerGasForTransaction,
exponent: exponent,
contractAddress:
@@ -1051,6 +1051,7 @@ abstract class EVMChainWalletBase
final nativeCurrency = switch (selectedChainId) {
137 => CryptoCurrency.maticpoly,
+ 56 => CryptoCurrency.bnb,
8453 => CryptoCurrency.baseEth,
42161 => CryptoCurrency.arbEth,
_ => CryptoCurrency.eth,
diff --git a/lib/src/screens/send/widgets/send_card.dart b/lib/src/screens/send/widgets/send_card.dart
index 5c39e697..77a6e795 100644
--- a/lib/src/screens/send/widgets/send_card.dart
+++ b/lib/src/screens/send/widgets/send_card.dart
@@ -275,22 +275,29 @@ class SendCardState extends State<SendCard> with AutomaticKeepAliveClientMixin<S
paymentRequest: paymentRequest,
fixedNetwork: fixedNetwork,
onNext: (PaymentFlowResult newResult) {
- final selectedChainId = newResult.chainId;
- final isCompatible = selectedChainId == evm!.getSelectedChainId(sendViewModel.wallet);
+ final canCheckCompatibility = evm != null &&
+ isEVMCompatibleChain(sendViewModel.wallet.type) &&
+ newResult.chainId != null;
- if (isCompatible) {
- sendViewModel.setSelectedCryptoCurrency(
- newResult.addressDetectionResult!.detectedCurrency!.title,
- );
- _applyPaymentRequest(paymentRequest);
- } else {
- _showPaymentConfirmation(
- paymentViewModel,
- walletSwitcherViewModel,
- paymentRequest,
- newResult,
- );
+ if (canCheckCompatibility) {
+ final selectedChainId = newResult.chainId!;
+ final isCompatible = selectedChainId == evm!.getSelectedChainId(sendViewModel.wallet);
+
+ if (isCompatible) {
+ sendViewModel.setSelectedCryptoCurrency(
+ newResult.addressDetectionResult!.detectedCurrency!.title,
+ );
+ _applyPaymentRequest(paymentRequest);
+ return;
+ }
}
+
+ _showPaymentConfirmation(
+ paymentViewModel,
+ walletSwitcherViewModel,
+ paymentRequest,
+ newResult,
+ );
},
);
},
diff --git a/lib/src/widgets/bottom_sheet/swap_confirmation_bottom_sheet.dart b/lib/src/widgets/bottom_sheet/swap_confirmation_bottom_sheet.dart
index 224d1235..614a3394 100644
--- a/lib/src/widgets/bottom_sheet/swap_confirmation_bottom_sheet.dart
+++ b/lib/src/widgets/bottom_sheet/swap_confirmation_bottom_sheet.dart
@@ -163,7 +163,7 @@ class SwapConfirmationContentState extends State<SwapConfirmationContent> {
clipBehavior: Clip.none,
children: [
CakeImageWidget(
- imageUrl: detectedCurrency.iconPath!,
+ imageUrl: detectedCurrency.iconPath ?? '',
width: 32,
height: 32,
),
Why this scored 24/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.