Files
sendico/frontend/pshared/lib/service/payment/wallets.dart
Stephan D 218c4e20b3
All checks were successful
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/discovery Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/gateway_mntx Pipeline was successful
ci/woodpecker/push/gateway_chain Pipeline was successful
ci/woodpecker/push/gateway_tgsettle 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
accounts creation
2026-01-23 00:13:43 +01:00

49 lines
1.5 KiB
Dart

import 'package:pshared/data/mapper/wallet/ui.dart';
import 'package:pshared/models/describable.dart';
import 'package:pshared/models/payment/wallet.dart';
import 'package:pshared/models/wallet/chain_asset.dart';
import 'package:pshared/service/wallet.dart' as shared_wallet_service;
abstract class WalletsService {
Future<List<Wallet>> getWallets(String organizationRef);
Future<double> getBalance(String organizationRef, String walletRef);
Future<void> create({
required String organizationRef,
required Describable describable,
required ChainAsset asset,
required String? ownerRef,
});
}
class ApiWalletsService implements WalletsService {
@override
Future<List<Wallet>> getWallets(String organizationRef) async {
final models = await shared_wallet_service.WalletService.list(organizationRef);
return models.map((m) => m.toUi()).toList();
}
@override
Future<double> getBalance(String organizationRef, String walletRef) async {
final balance = await shared_wallet_service.WalletService.getBalance(
organizationRef: organizationRef,
walletRef: walletRef,
);
final amount = balance.available?.amount;
return amount == null ? 0 : double.tryParse(amount) ?? 0;
}
@override
Future<void> create({
required String organizationRef,
required Describable describable,
required ChainAsset asset,
required String? ownerRef,
}) => shared_wallet_service.WalletService.create(
organizationRef: organizationRef,
describable: describable,
asset: asset,
ownerRef: ownerRef,
);
}