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/models/currency.dart';
import 'package:pshared/utils/currency.dart';
class Asset {
final Currency currency;
final double amount;
const Asset({
required this.currency,
required this.amount,
});
}
Asset createAsset(String currencyCode, String amount) => Asset(
currency: currencyStringToCode(currencyCode),
amount: double.parse(amount),
);

View File

@@ -1 +1 @@
enum Currency {usd, eur, rub, usdt, usdc}
enum CurrencyCode {usd, eur, rub, usdt, usdc}

View File

@@ -1,4 +1,4 @@
import 'package:pshared/models/money.dart';
import 'package:money2/money2.dart';
class LedgerBalance {

View File

@@ -1,9 +0,0 @@
class Money {
final String amount;
final String currency;
const Money({
required this.amount,
required this.currency,
});
}

View File

@@ -1,4 +1,4 @@
import 'package:pshared/models/money.dart';
import 'package:money2/money2.dart';
class PaymentExecutionOperation {

View File

@@ -1,4 +1,4 @@
import 'package:pshared/models/money.dart';
import 'package:money2/money2.dart';
class FeeLine {

View File

@@ -1,4 +1,5 @@
import 'package:pshared/models/money.dart';
import 'package:money2/money2.dart';
class FxQuote {
final String? quoteRef;

View File

@@ -1,11 +1,13 @@
import 'package:money2/money2.dart';
import 'package:pshared/models/payment/fees/treatment.dart';
import 'package:pshared/models/payment/fx/intent.dart';
import 'package:pshared/models/payment/kind.dart';
import 'package:pshared/models/payment/customer.dart';
import 'package:pshared/models/payment/methods/data.dart';
import 'package:pshared/models/money.dart';
import 'package:pshared/models/payment/settlement_mode.dart';
class PaymentIntent {
final PaymentKind kind;
final String? sourceRef;

View File

@@ -1,4 +1,5 @@
import 'package:pshared/models/money.dart';
import 'package:money2/money2.dart';
class QuoteAmounts {
final Money? sourcePrincipal;

View File

@@ -7,7 +7,7 @@ class Wallet implements Describable {
final String id;
final String walletUserID; // ID or number that we show the user
final double balance;
final Currency currency;
final CurrencyCode currency;
final DateTime calculatedAt;
final String? depositAddress;
final ChainNetwork? network;

View File

@@ -1,12 +1,14 @@
import 'package:pshared/models/wallet/chain_asset.dart';
import 'package:pshared/models/payment/chain_network.dart';
class WalletAsset extends ChainAsset {
class WalletAsset {
final ChainNetwork chain;
final String tokenSymbol;
final String contractAddress;
const WalletAsset({
required super.chain,
required super.tokenSymbol,
required this.chain,
required this.tokenSymbol,
required this.contractAddress,
});
}

View File

@@ -1,4 +1,4 @@
import 'package:pshared/models/money.dart';
import 'package:money2/money2.dart';
class WalletBalance {

View File

@@ -1,12 +0,0 @@
import 'package:pshared/models/payment/chain_network.dart';
class ChainAsset {
final ChainNetwork chain;
final String tokenSymbol;
const ChainAsset({
required this.chain,
required this.tokenSymbol,
});
}

View File

@@ -1,5 +1,5 @@
import 'package:pshared/models/describable.dart';
import 'package:pshared/models/money.dart';
import 'package:money2/money2.dart';
import 'package:pshared/models/wallet/asset.dart';
import 'package:pshared/models/wallet/balance.dart';
@@ -39,9 +39,7 @@ class WalletModel implements Describable {
required this.describable,
});
WalletModel copyWith({
Describable? describable,
}) => WalletModel(
WalletModel copyWith({Describable? describable}) => WalletModel(
walletRef: walletRef,
organizationRef: organizationRef,
ownerRef: ownerRef,