Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class CexMarketDataManager implements MarketDataManager {
Future<void> init() async {
// Initialize any resources if needed
_knownTickers = UnmodifiableSetView(
(await _priceRepository.getCoinList()).map((e) => e.id).toSet(),
(await _priceRepository.getCoinList()).map((e) => e.symbol).toSet(),
);

// Start cache clearing timer
Expand Down Expand Up @@ -113,15 +113,19 @@ class CexMarketDataManager implements MarketDataManager {
DateTime? priceDate,
String fiatCurrency = 'usdt',
}) {
return '${assetId.id}_${fiatCurrency}_${priceDate?.millisecondsSinceEpoch ?? 'current'}';
return '${assetId.symbol.configSymbol}_${fiatCurrency}_${priceDate?.millisecondsSinceEpoch ?? 'current'}';
}

// Helper method to generate change cache keys
String _getChangeCacheKey(AssetId assetId, {String fiatCurrency = 'usdt'}) {
return '${assetId.id}_${fiatCurrency}_change24h';
return '${assetId.symbol.configSymbol}_${fiatCurrency}_change24h';
}


/// Gets the trading symbol to use for price lookups.
/// Prefers the binanceId if available, falls back to configSymbol
String _getTradingSymbol(AssetId assetId) {
return assetId.symbol.configSymbol;
}

@override
Decimal? priceIfKnown(
Expand Down Expand Up @@ -167,7 +171,7 @@ class CexMarketDataManager implements MarketDataManager {

try {
final priceDouble = await _priceRepository.getCoinFiatPrice(
assetId.id,
_getTradingSymbol(assetId),
priceDate: priceDate,
fiatCoinId: fiatCurrency,
);
Expand Down Expand Up @@ -204,10 +208,8 @@ class CexMarketDataManager implements MarketDataManager {
return cachedPrice;
}

final maybeKnownTicker =
assetId.symbol.binanceId ?? assetId.symbol.configSymbol;

final isKnownTicker = _knownTickers?.contains(maybeKnownTicker) ?? false;
final tradingSymbol = _getTradingSymbol(assetId);
final isKnownTicker = _knownTickers?.contains(tradingSymbol) ?? false;

if (!isKnownTicker) {
return null;
Expand Down Expand Up @@ -248,7 +250,7 @@ class CexMarketDataManager implements MarketDataManager {
final prices = await _komodoPriceRepository.getKomodoPrices();

// Find the price for the requested asset
final priceData = prices[assetId.id];
final priceData = prices[assetId.symbol.configSymbol];

if (priceData == null || priceData.change24h == null) {
return null;
Expand Down Expand Up @@ -281,7 +283,7 @@ class CexMarketDataManager implements MarketDataManager {

try {
final priceDoubleMap = await _priceRepository.getCoinFiatPrices(
assetId.id,
assetId.symbol.configSymbol,
dates,
fiatCoinId: fiatCurrency,
);
Expand Down
90 changes: 45 additions & 45 deletions packages/komodo_ui/lib/src/defi/withdraw/source_address_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ class SourceAddressField extends StatelessWidget {
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: theme.colorScheme.secondaryContainer.withOpacity(0.7),
color: theme.colorScheme.secondaryContainer.withValues(
alpha: 0.7,
),
borderRadius: BorderRadius.circular(12),
),
child: Text(
Expand All @@ -71,7 +73,30 @@ class SourceAddressField extends StatelessWidget {
],
),
const SizedBox(height: 8),
_buildAddressSelector(context),
AddressSelectInput(
addresses: pubkeys!.keys,
selectedAddress: selectedAddress,
onAddressSelected: onChanged,
assetName: asset.id.name,
hint: 'Choose source address',
onCopied: (address) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Row(
children: [
Icon(Icons.check_circle, color: Colors.white, size: 16),
SizedBox(width: 8),
Text('Address copied to clipboard'),
],
),
behavior: SnackBarBehavior.floating,
width: 280,
backgroundColor: theme.colorScheme.primary,
),
);
},
verified: _isAddressVerified,
),
if (selectedAddress != null && showBalanceIndicator) ...[
const SizedBox(height: 12),
_BalanceIndicator(
Expand All @@ -84,38 +109,8 @@ class SourceAddressField extends StatelessWidget {
);
}

Widget _buildAddressSelector(BuildContext context) {
final theme = Theme.of(context);

// Remove the Container wrapper that was causing the double border
return ClipRRect(
borderRadius: BorderRadius.circular(8),
child: AddressSelectInput(
addresses: pubkeys!.keys,
selectedAddress: selectedAddress,
onAddressSelected: onChanged,
assetName: asset.id.name,
hint: 'Choose source address',
onCopied: (address) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Row(
children: [
Icon(Icons.check_circle, color: Colors.white, size: 16),
SizedBox(width: 8),
Text('Address copied to clipboard'),
],
),
behavior: SnackBarBehavior.floating,
width: 280,
backgroundColor: theme.colorScheme.primary,
),
);
},
verified:
(address) => _getAddressStatus(address) == AddressStatus.available,
),
);
bool _isAddressVerified(PubkeyInfo address) {
return _getAddressStatus(address) == AddressStatus.available;
}

AddressStatus _getAddressStatus(PubkeyInfo address) {
Expand Down Expand Up @@ -146,7 +141,9 @@ class _LoadingState extends StatelessWidget {
color: theme.colorScheme.surface,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
side: BorderSide(color: theme.colorScheme.outline.withOpacity(0.2)),
side: BorderSide(
color: theme.colorScheme.outline.withValues(alpha: 0.2),
),
),
child: Padding(
padding: const EdgeInsets.all(24),
Expand All @@ -167,7 +164,7 @@ class _LoadingState extends StatelessWidget {
Text(
'Fetching your ${asset.id.name} addresses',
style: theme.textTheme.bodyMedium?.copyWith(
color: theme.colorScheme.onSurface.withOpacity(0.7),
color: theme.colorScheme.onSurface.withValues(alpha: 0.7),
),
),
],
Expand All @@ -189,7 +186,7 @@ class _ErrorState extends StatelessWidget {

return Card(
elevation: 0,
color: theme.colorScheme.errorContainer.withOpacity(0.8),
color: theme.colorScheme.errorContainer.withValues(alpha: 0.8),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: Padding(
padding: const EdgeInsets.all(16),
Expand Down Expand Up @@ -218,9 +215,12 @@ class _ErrorState extends StatelessWidget {
),
const SizedBox(height: 8),
Text(
"We couldn't load your wallet addresses. Please check your connection and try again.",
"We couldn't load your wallet addresses. "
'Please check your connection and try again.',
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onErrorContainer.withOpacity(0.8),
color: theme.colorScheme.onErrorContainer.withValues(
alpha: 0.8,
),
),
),
if (onRetry != null) ...[
Expand Down Expand Up @@ -282,10 +282,10 @@ class _BalanceIndicator extends StatelessWidget {

return Card(
elevation: 0,
color: statusColor.withOpacity(0.08),
color: statusColor.withValues(alpha: 0.08),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
side: BorderSide(color: statusColor.withOpacity(0.3)),
side: BorderSide(color: statusColor.withValues(alpha: 0.3)),
),
child: Padding(
padding: const EdgeInsets.all(16),
Expand All @@ -311,7 +311,7 @@ class _BalanceIndicator extends StatelessWidget {
vertical: 4,
),
decoration: BoxDecoration(
color: statusColor.withOpacity(0.15),
color: statusColor.withValues(alpha: 0.15),
borderRadius: BorderRadius.circular(16),
),
child: Text(
Expand Down Expand Up @@ -347,14 +347,14 @@ class _BalanceIndicator extends StatelessWidget {
Text(
'Locked:',
style: theme.textTheme.bodyMedium?.copyWith(
color: theme.colorScheme.onSurface.withOpacity(0.7),
color: theme.colorScheme.onSurface.withValues(alpha: 0.7),
),
),
Text(
'${balance.unspendable} $assetName',
style: theme.textTheme.bodyMedium?.copyWith(
fontStyle: FontStyle.italic,
color: theme.colorScheme.onSurface.withOpacity(0.7),
color: theme.colorScheme.onSurface.withValues(alpha: 0.7),
),
),
],
Expand All @@ -367,7 +367,7 @@ class _BalanceIndicator extends StatelessWidget {
width: double.infinity,
padding: const EdgeInsets.symmetric(vertical: 6),
decoration: BoxDecoration(
color: statusColor.withOpacity(0.1),
color: statusColor.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(4),
),
alignment: Alignment.center,
Expand Down
Loading
Loading