implemented backend wallet service connection
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
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
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pweb/models/wallet.dart';
|
||||
import 'package:pweb/services/wallets.dart';
|
||||
import 'package:pshared/provider/organizations.dart';
|
||||
import 'package:pshared/provider/resource.dart';
|
||||
import 'package:pshared/utils/exception.dart';
|
||||
|
||||
import 'package:pweb/models/wallet.dart';
|
||||
import 'package:pweb/services/wallets.dart';
|
||||
|
||||
|
||||
class WalletsProvider with ChangeNotifier {
|
||||
final WalletsService _service;
|
||||
late OrganizationsProvider _organizations;
|
||||
|
||||
WalletsProvider(this._service);
|
||||
|
||||
@@ -25,6 +29,15 @@ class WalletsProvider with ChangeNotifier {
|
||||
bool _isRefreshingBalances = false;
|
||||
bool get isRefreshingBalances => _isRefreshingBalances;
|
||||
|
||||
void update(OrganizationsProvider organizations) {
|
||||
_organizations = organizations;
|
||||
if (_organizations.isOrganizationSet) loadWalletsWithBalances();
|
||||
}
|
||||
|
||||
Future<Wallet> updateWallet(Wallet newWallet) {
|
||||
throw Exception('update wallet is not implemented');
|
||||
}
|
||||
|
||||
void selectWallet(Wallet wallet) {
|
||||
_selectedWallet = wallet;
|
||||
notifyListeners();
|
||||
@@ -33,11 +46,11 @@ class WalletsProvider with ChangeNotifier {
|
||||
Future<void> loadWalletsWithBalances() async {
|
||||
_setResource(_resource.copyWith(isLoading: true, error: null));
|
||||
try {
|
||||
final base = await _service.getWallets();
|
||||
final base = await _service.getWallets(_organizations.current.id);
|
||||
final withBalances = <Wallet>[];
|
||||
for (final wallet in base) {
|
||||
try {
|
||||
final balance = await _service.getBalance(wallet.id);
|
||||
final balance = await _service.getBalance(_organizations.current.id, wallet.id);
|
||||
withBalances.add(wallet.copyWith(balance: balance));
|
||||
} catch (e) {
|
||||
_setResource(_resource.copyWith(error: toException(e)));
|
||||
@@ -58,7 +71,7 @@ class WalletsProvider with ChangeNotifier {
|
||||
try {
|
||||
final updated = <Wallet>[];
|
||||
for (final wallet in wallets) {
|
||||
final balance = await _service.getBalance(wallet.id);
|
||||
final balance = await _service.getBalance(_organizations.current.id, wallet.id);
|
||||
updated.add(wallet.copyWith(balance: balance));
|
||||
}
|
||||
_setResource(_resource.copyWith(data: updated));
|
||||
|
||||
Reference in New Issue
Block a user