What changed, and why it matters
This commit fixes a small but meaningful bug in the Nanswap cryptocurrency exchange integration. A trade object was being created with the wrong 'direction' field—it was accidentally copying the 'rateType' value instead of the actual trade direction. This could cause trade records to show incorrect buy/sell direction, potentially confusing users or downstream trade tracking. The rest of the change is just code formatting.
Review whether any persisted trades or cached data contain the incorrect direction value and consider a migration or warning. Otherwise, no urgent security action is needed; treat as a normal bug-fix release.
Security signals we found
Incorrect field mapping in trade model construction
Potential data integrity issue in exchange trade records
No input validation, crypto, or authentication changes observed
Evidence from the diff
In lib/services/exchange/nanswap/nanswap_exchange.dart, the patch corrects a field assignment when mapping a Nanswap API trade response to the internal Trade model. Previously, the Trade object’s direction field was set to trade.rateType (an enum such as fixed/estimated), which is semantically wrong. The fix assigns trade.direction instead. The other hunk is purely whitespace/indentation reformatting of a Currency list mapping and contains no functional change.
Changed components
lib/services/exchange/nanswap/nanswap_exchange.dartNanswap exchange trade mapping logicInternal Trade model direction fieldInspect captured patch +18 / −19
diff --git a/lib/services/exchange/nanswap/nanswap_exchange.dart b/lib/services/exchange/nanswap/nanswap_exchange.dart
index 2392199..a26a35c 100644
--- a/lib/services/exchange/nanswap/nanswap_exchange.dart
+++ b/lib/services/exchange/nanswap/nanswap_exchange.dart
@@ -138,24 +138,23 @@ class NanswapExchange extends Exchange {
}
return ExchangeResponse(
- value:
- response.value!
- .where((e) => filter.contains(e.id))
- .map(
- (e) => Currency(
- exchangeName: exchangeName,
- ticker: e.id,
- name: e.name,
- network: e.network,
- image: e.image,
- isFiat: false,
- rateType: SupportedRateType.estimated,
- isStackCoin: AppConfig.isStackCoin(e.id),
- tokenContract: null,
- isAvailable: true,
- ),
- )
- .toList(),
+ value: response.value!
+ .where((e) => filter.contains(e.id))
+ .map(
+ (e) => Currency(
+ exchangeName: exchangeName,
+ ticker: e.id,
+ name: e.name,
+ network: e.network,
+ image: e.image,
+ isFiat: false,
+ rateType: SupportedRateType.estimated,
+ isStackCoin: AppConfig.isStackCoin(e.id),
+ tokenContract: null,
+ isAvailable: true,
+ ),
+ )
+ .toList(),
);
} on ExchangeException catch (e) {
return ExchangeResponse(exception: e);
@@ -391,7 +390,7 @@ class NanswapExchange extends Exchange {
uuid: trade.uuid,
tradeId: t.id,
rateType: trade.rateType,
- direction: trade.rateType,
+ direction: trade.direction,
timestamp: trade.timestamp,
updatedAt: DateTime.now(),
payInCurrency: t.from,
Why this scored 29/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.