Filter out spam transactions for Polygon (#2543)

* fix: Polygon transactions not coming up in transactions history page * fix: Filter out polygon spam transactions

David Adegoke committed Sep 26, 2025 at 09:16 UTC 2f3ec951e0265930f05b9124f2b5c8767c894042
2 files changed +32 -25
cw_polygon/lib/polygon_client.dart
+6 -2
@@ -24,7 +24,7 @@ class PolygonClient extends EVMChainClient {
24 // If we have EIP-1559 parameters but no legacy gasPrice, then use maxFeePerGas as gasPrice
25 finalGasPrice = maxFeePerGas;
26 }
27 -
27 +
28 return Transaction(
29 from: from,
30 to: to,
@@ -59,7 +59,11 @@ class PolygonClient extends EVMChainClient {
59 final jsonResponse = json.decode(response.body) as Map<String, dynamic>;
60
61 if (response.statusCode >= 200 && response.statusCode < 300 && jsonResponse['status'] != 0) {
62 - return (jsonResponse['result'] as List)
62 + final res = (jsonResponse['result'] as List);
63 +
64 + res.removeWhere((e) => e['value'] == '0');
65 +
66 + return res
67 .map(
68 (e) => EVMChainTransactionModel.fromJson(e as Map<String, dynamic>, 'MATIC'),
69 )
lib/src/screens/dashboard/pages/transactions_page.dart
+26 -23
@@ -90,6 +90,8 @@ class TransactionsPage extends StatelessWidget {
90 return Container();
91 }
92
93 + if (item.transaction.amount == 0.0) return Container();
94 +
95 final transaction = item.transaction;
96 final transactionType =
97 dashboardViewModel.getTransactionType(transaction);
@@ -193,30 +195,31 @@ class TransactionsPage extends StatelessWidget {
195 final order = item.order;
196 return Observer(
197 builder: (_) {
196 -
198 // TODO: Refactor Amount Hiding Logic it is not working properly for Orders and Trades
198 - final hide = dashboardViewModel.balanceViewModel.displayMode ==
199 - BalanceDisplayMode.hiddenBalance;
200 -
201 - final formattedAmount = hide ? '---' : order.amountFormatted();
202 - final formattedReceiveAmount = hide ? '---' : order.receiveAmount;
203 -
204 - return OrderRow(
205 - key: item.key,
206 - onTap: () => Navigator.of(context)
207 - .pushNamed(Routes.orderDetails, arguments: order),
208 - providerTitle: order.providerTitle,
209 - providerIconPath: order.providerIcon,
210 - from: order.from ?? '',
211 - to: order.to ?? '',
212 - createdAtFormattedDate: DateFormat('HH:mm').format(order.createdAt),
213 - formattedAmount: formattedAmount,
214 - formattedReceiveAmount: dashboardViewModel.balanceViewModel.isFiatDisabled &&
215 - order.source == OrderSourceDescription.order
216 - ? ''
217 - : formattedReceiveAmount,
218 - );
219 - }
199 + final hide = dashboardViewModel.balanceViewModel.displayMode ==
200 + BalanceDisplayMode.hiddenBalance;
201 +
202 + final formattedAmount = hide ? '---' : order.amountFormatted();
203 + final formattedReceiveAmount = hide ? '---' : order.receiveAmount;
204 +
205 + return OrderRow(
206 + key: item.key,
207 + onTap: () => Navigator.of(context)
208 + .pushNamed(Routes.orderDetails, arguments: order),
209 + providerTitle: order.providerTitle,
210 + providerIconPath: order.providerIcon,
211 + from: order.from ?? '',
212 + to: order.to ?? '',
213 + createdAtFormattedDate:
214 + DateFormat('HH:mm').format(order.createdAt),
215 + formattedAmount: formattedAmount,
216 + formattedReceiveAmount:
217 + dashboardViewModel.balanceViewModel.isFiatDisabled &&
218 + order.source == OrderSourceDescription.order
219 + ? ''
220 + : formattedReceiveAmount,
221 + );
222 + },
223 );
224 }
225 return Container(color: Colors.transparent, height: 1);