refactor of money utils with new money2 package
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
import 'package:pshared/data/dto/wallet/chain_asset.dart';
|
||||
import 'package:pshared/data/mapper/payment/enums.dart';
|
||||
import 'package:pshared/models/wallet/chain_asset.dart';
|
||||
|
||||
|
||||
extension ChainAssetDTOMapper on ChainAssetDTO {
|
||||
ChainAsset toDomain() => ChainAsset(
|
||||
chain: chainNetworkFromValue(chain),
|
||||
tokenSymbol: tokenSymbol,
|
||||
);
|
||||
}
|
||||
|
||||
extension ChainAssetMapper on ChainAsset {
|
||||
ChainAssetDTO toDTO() => ChainAssetDTO(
|
||||
chain: chainNetworkToValue(chain),
|
||||
tokenSymbol: tokenSymbol,
|
||||
);
|
||||
}
|
||||
@@ -1,16 +1,13 @@
|
||||
import 'package:pshared/models/wallet/wallet.dart' as domain;
|
||||
import 'package:pshared/models/payment/wallet.dart';
|
||||
import 'package:pshared/utils/currency.dart';
|
||||
import 'package:pshared/utils/money.dart';
|
||||
|
||||
|
||||
extension WalletUiMapper on domain.WalletModel {
|
||||
Wallet toUi() => Wallet(
|
||||
id: walletRef,
|
||||
walletUserID: walletRef,
|
||||
balance: parseMoneyAmount(
|
||||
availableMoney?.amount ?? balance?.available?.amount,
|
||||
),
|
||||
balance: availableMoney?.toDouble() ?? balance?.available?.toDouble() ?? 0,
|
||||
currency: currencyStringToCode(asset.tokenSymbol),
|
||||
calculatedAt: balance?.calculatedAt ?? DateTime.now(),
|
||||
depositAddress: depositAddress,
|
||||
|
||||
@@ -16,15 +16,19 @@ extension WalletDTOMapper on WalletDTO {
|
||||
depositAddress: depositAddress,
|
||||
status: status,
|
||||
metadata: metadata,
|
||||
createdAt: (createdAt == null || createdAt!.isEmpty) ? null : DateTime.tryParse(createdAt!),
|
||||
updatedAt: (updatedAt == null || updatedAt!.isEmpty) ? null : DateTime.tryParse(updatedAt!),
|
||||
createdAt: (createdAt == null || createdAt!.isEmpty)
|
||||
? null
|
||||
: DateTime.tryParse(createdAt!),
|
||||
updatedAt: (updatedAt == null || updatedAt!.isEmpty)
|
||||
? null
|
||||
: DateTime.tryParse(updatedAt!),
|
||||
balance: balance?.toDomain(),
|
||||
availableMoney: balance?.available?.toDomain(),
|
||||
describable: newDescribable(
|
||||
name: name.isNotEmpty ? name : (metadata?['name']?.toString() ?? ''),
|
||||
description: (description != null && description!.isNotEmpty)
|
||||
? description
|
||||
: metadata?['description'],
|
||||
? description
|
||||
: metadata?['description'],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user