Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
174afb7
feat: introduce Data Access Object
ethicnology Jan 6, 2026
1e258d0
refactor: move out labels from core
ethicnology Jan 7, 2026
56d1230
refactor(labels): integrate Labels DAO and barrel file
ethicnology Jan 7, 2026
458e5b6
refactor(labels): merge bip329_labels presentation into features/labels
ethicnology Jan 7, 2026
c6b4a4f
refactor(labels): replace LabelDatasource with LabelRepository and La…
ethicnology Jan 7, 2026
9bdef33
refactor: what if we drop our rawrapping (model) of the sqlite model …
ethicnology Jan 7, 2026
34d2629
refactor(labels): unify constructor in LabelsLocalDatasource
ethicnology Jan 7, 2026
21e3e41
refactor: move labels out from core and isolate the feature with a ce…
ethicnology Jan 8, 2026
f43be53
refactor(labels): hexagonal architecture
ethicnology Jan 14, 2026
ca8561c
refactor(labels): use LabelsFacade instead of individual label usecases
ethicnology Jan 15, 2026
92312e9
fix: the dataclass is supposed to be named Row instead of Model
ethicnology Jan 15, 2026
9a4901c
refactor(labels): simplify export success message
ethicnology Jan 15, 2026
fd7f307
refactor: suffix entity
ethicnology Jan 15, 2026
c695476
BREAKING CHANGE: restructure labels table schema (v11 to v12)
ethicnology Jan 15, 2026
fe2d820
feat: implement label entity validators
ethicnology Jan 15, 2026
b400b71
refactor: locator
ethicnology Jan 20, 2026
2c7a0eb
refactor: remove envelope suffix for public structure
ethicnology Jan 20, 2026
c33514f
refactor: remove spendable as it's tightly coupled to bip329 while not
ethicnology Jan 20, 2026
fadd877
docs: irrelevant comments
ethicnology Jan 20, 2026
24f9c12
refactor: the usecase shouldn't return an entity
ethicnology Jan 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/core/core_locator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:bb_mobile/core/blockchain/blockchain_locator.dart';
import 'package:bb_mobile/core/electrum/frameworks/di/electrum_locator.dart';
import 'package:bb_mobile/core/exchange/exchange_locator.dart';
import 'package:bb_mobile/core/fees/fees_locator.dart';
import 'package:bb_mobile/core/labels/labels_locator.dart';
import 'package:bb_mobile/features/labels/labels_facade.dart';
import 'package:bb_mobile/core/ledger/ledger_locator.dart';
import 'package:bb_mobile/core/mempool/mempool_locator.dart';
import 'package:bb_mobile/core/payjoin/payjoin_locator.dart';
Expand All @@ -24,7 +24,6 @@ class CoreLocator {
}

static Future<void> registerDatasources(GetIt locator) async {
LabelsLocator.registerDatasources(locator);
await TorLocator.registerDatasources(locator);
BlockchainLocator.registerDatasources(locator);
await ElectrumLocator.registerDatasources(locator);
Expand All @@ -49,10 +48,10 @@ class CoreLocator {
MempoolLocator.registerPorts(locator);
SwapsLocator.registerPorts(locator);
WalletLocator.registerPorts(locator);
LabelsLocator.registerPorts(locator);
}

static Future<void> registerRepositories(GetIt locator) async {
LabelsLocator.registerRepositories(locator);
await TorLocator.registerRepositories(locator);
BlockchainLocator.registerRepositories(locator);
ElectrumLocator.registerRepositories(locator);
Expand Down Expand Up @@ -96,4 +95,12 @@ class CoreLocator {
LedgerLocator.registerUsecases(locator);
BitBoxCoreLocator.registerUsecases(locator);
}

static void registerFacades(GetIt locator) {
LabelsLocator.registerFacade(locator);
}

static void registerFrameworks(GetIt locator) {
LabelsLocator.registerFrameworks(locator);
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
import 'package:bb_mobile/core/exchange/domain/entity/order.dart';
import 'package:bb_mobile/core/exchange/domain/usecases/list_all_orders_usecase.dart';
import 'package:bb_mobile/core/labels/data/label_datasource.dart';
import 'package:bb_mobile/core/labels/domain/batch_labels_usecase.dart';
import 'package:bb_mobile/core/labels/domain/label.dart';
import 'package:bb_mobile/core/labels/label_system.dart';
import 'package:bb_mobile/core/utils/logger.dart';
import 'package:bb_mobile/features/labels/labels_facade.dart';

class LabelExchangeOrdersUsecase {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not a good usecase, this labeling should be part of the usecase that creates the orders.
But I don't know if we should refactor that when we apply the new architecture guidelines to the exchange features and we should focus on the labels feature here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The labeling is already part of the usecase that creates orders. This usecase is executed once the first time the user connect to the exchange to ensure it is labeling the orders that might have been created before the app was supporting the exchange.

The day we attack the exchange folder, let's rename it better!

LabelExistingExchangeOrdersUsecase ?

@kumulynja kumulynja Jan 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking some more about this and I actually don't even think this should be done from the exchange feature. In the end it is the labels feature that needs a migration of the labels, or a seeding in some sense of missed values. So I was thinking that we should actually remove this usecase and let the labels feature use the core BBX api client directly to fetch the orders and seed the labels in a real db migration/seeding in the labels feature. It is a pure migration (framework) thing from the labels, no usecase needed and certainly not in exchange features.

final LabelDatasource _labelDatasource;
final BatchLabelsUsecase _batchLabelsUsecase;
final LabelsFacade _labelsFacade;

@kumulynja kumulynja Jan 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not directly import a Facade here, as this tightly couples the "what" (adding a label) with the "how" (through the labels feature). A usecase should only get Ports injected, not concrete implementations, so you should create an ExchangeLabelsPort and implement that Port with the LabelsFacade. You could make the interface of the port something like addLabelsForOrder and then just pass the order to it, so in the concrete implementation of the ExchangeLabelsPort you can check the order type etc and decide which labels to add based on that. I would also move the system labels check and everything to it, as those are implementation details, the usecase just wants to make sure the order is labeled, it shouldn't know how exactly this is done.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This usecase is out of the scope as it belongs to the exchange feature. This PR focus on refactoring the labels folder

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This usecase is out of the scope as it belongs to the exchange feature. This PR focus on refactoring the labels folder

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok, just wrote another comment saying the same and only now see you responded haha.
Will focus only on the labels feature code itself.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will refactor this usecase in when we attack the exchange feature

final ListAllOrdersUsecase _listAllOrdersUsecase;

LabelExchangeOrdersUsecase({
required LabelDatasource labelDatasource,
required BatchLabelsUsecase batchLabelsUsecase,
required LabelsFacade labelsFacade,
required ListAllOrdersUsecase listAllOrdersUsecase,
}) : _labelDatasource = labelDatasource,
_batchLabelsUsecase = batchLabelsUsecase,
}) : _labelsFacade = labelsFacade,
_listAllOrdersUsecase = listAllOrdersUsecase;

Future<void> execute() async {
Expand Down Expand Up @@ -59,7 +53,7 @@ class LabelExchangeOrdersUsecase {
}
}

await _batchLabelsUsecase.execute(labels);
await _labelsFacade.store(labels);

log.fine(
'$LabelExchangeOrdersUsecase labeled ${orders.length} exchange orders',
Expand All @@ -71,11 +65,11 @@ class LabelExchangeOrdersUsecase {

Future<bool> _hasExistingExchangeSystemLabels() async {
try {
final allLabels = await _labelDatasource.fetchAll();
final allLabels = await _labelsFacade.fetch();
return allLabels.any(
(label) =>
label.label == LabelSystem.exchangeBuy.label ||
label.label == LabelSystem.exchangeSell.label,
LabelSystem.isSystemLabel(label) &&
LabelSystem.fromLabel(label).isExchangeRelated(),
);
} catch (e) {
log.warning('$LabelExchangeOrdersUsecase: $e');
Expand Down
9 changes: 3 additions & 6 deletions lib/core/exchange/exchange_locator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ import 'package:bb_mobile/core/exchange/domain/usecases/refresh_price_history_us
import 'package:bb_mobile/core/exchange/domain/usecases/save_exchange_api_key_usecase.dart';
import 'package:bb_mobile/core/exchange/domain/usecases/send_support_chat_message_usecase.dart';
import 'package:bb_mobile/core/exchange/domain/usecases/save_user_preferences_usecase.dart';
import 'package:bb_mobile/core/labels/data/label_datasource.dart';
import 'package:bb_mobile/core/labels/data/label_repository.dart';
import 'package:bb_mobile/core/labels/domain/batch_labels_usecase.dart';
import 'package:bb_mobile/features/labels/labels_facade.dart';
import 'package:bb_mobile/core/settings/data/settings_repository.dart';
import 'package:bb_mobile/core/storage/data/datasources/key_value_storage/key_value_storage_datasource.dart';
import 'package:bb_mobile/core/storage/sqlite_database.dart';
Expand Down Expand Up @@ -340,7 +338,7 @@ class ExchangeLocator {
instanceName: 'testnetExchangeOrderRepository',
),
settingsRepository: locator<SettingsRepository>(),
labelsRepository: locator<LabelRepository>(),
labelsFacade: locator<LabelsFacade>(),
),
);

Expand Down Expand Up @@ -482,8 +480,7 @@ class ExchangeLocator {

locator.registerFactory<LabelExchangeOrdersUsecase>(
() => LabelExchangeOrdersUsecase(
labelDatasource: locator<LabelDatasource>(),
batchLabelsUsecase: locator<BatchLabelsUsecase>(),
labelsFacade: locator<LabelsFacade>(),
listAllOrdersUsecase: locator<ListAllOrdersUsecase>(),
),
);
Expand Down
98 changes: 0 additions & 98 deletions lib/core/labels/data/label_datasource.dart

This file was deleted.

80 changes: 0 additions & 80 deletions lib/core/labels/data/label_model.dart

This file was deleted.

48 changes: 0 additions & 48 deletions lib/core/labels/data/label_repository.dart

This file was deleted.

20 changes: 0 additions & 20 deletions lib/core/labels/domain/batch_labels_usecase.dart

This file was deleted.

20 changes: 0 additions & 20 deletions lib/core/labels/domain/delete_label_usecase.dart

This file was deleted.

Loading