refactor of money utils with new money2 package

This commit is contained in:
Arseni
2026-03-13 03:17:29 +03:00
parent b4eb1437f6
commit 0091191d97
72 changed files with 453 additions and 982 deletions

View File

@@ -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,
);
}

View File

@@ -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,

View File

@@ -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'],
),
);
}