Some checks failed
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
ci/woodpecker/push/bump_version Pipeline failed
27 lines
902 B
Dart
27 lines
902 B
Dart
import 'package:pshared/models/wallet/wallet.dart' as domain;
|
|
|
|
import 'package:pweb/models/currency.dart';
|
|
import 'package:pweb/models/wallet.dart';
|
|
|
|
|
|
extension WalletUiMapper on domain.WalletModel {
|
|
Wallet toUi() {
|
|
final amountStr = availableMoney?.amount ?? balance?.available?.amount ?? '0';
|
|
final currencyStr = availableMoney?.currency ?? balance?.available?.currency ?? Currency.usd.toString().toUpperCase();
|
|
final parsedAmount = double.tryParse(amountStr) ?? 0;
|
|
final currency = Currency.values.firstWhere(
|
|
(c) => c.name.toUpperCase() == currencyStr.toUpperCase(),
|
|
orElse: () => Currency.usd,
|
|
);
|
|
return Wallet(
|
|
id: walletRef,
|
|
walletUserID: walletRef,
|
|
name: metadata?['name'] ?? walletRef,
|
|
balance: parsedAmount,
|
|
currency: currency,
|
|
isHidden: true,
|
|
calculatedAt: balance?.calculatedAt ?? DateTime.now(),
|
|
);
|
|
}
|
|
}
|