Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .docker/komodo-wallet-android.dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM komodo/android-sdk:35 AS final

ENV FLUTTER_VERSION="3.35.3"
ENV FLUTTER_VERSION="3.41.4"
ENV HOME="/home/komodo"
ENV USER="komodo"
ENV PATH=$PATH:$HOME/flutter/bin
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/flutter-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ runs:
uses: subosito/flutter-action@v2
with:
# NB! Keep up-to-date with the flutter version used for development
flutter-version: "3.35.3"
flutter-version: "3.41.4"
channel: "stable"

- name: Prepare build directory
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/roll-sdk-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
uses: subosito/flutter-action@v2
with:
# NB! Keep up-to-date with the flutter version used for development
flutter-version: "3.35.3"
flutter-version: "3.41.4"
channel: "stable"

- name: Determine configuration
Expand Down
2 changes: 1 addition & 1 deletion app_theme/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ resolution: workspace

environment:
sdk: ">=3.8.1 <4.0.0"
flutter: ">=3.41.3 <4.0.0"
flutter: ">=3.41.4 <4.0.0"

dependencies:
flutter:
Expand Down
6 changes: 3 additions & 3 deletions docs/FLUTTER_VERSION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Supported Flutter Version

This project supports Flutter `3.41.3`. We aim to keep the project up-to-date with the most recent stable Flutter versions.
This project supports Flutter `3.41.4`. We aim to keep the project up-to-date with the most recent stable Flutter versions.

## Recommended Approach: Multiple Flutter Versions

Expand All @@ -15,14 +15,14 @@ See our guide on [Multiple Flutter Versions](MULTIPLE_FLUTTER_VERSIONS.md) for d
While it's possible to pin your global Flutter installation to a specific version, **this approach is not recommended** due to:

- Lack of isolation between projects
- Known issues with `flutter pub get` when using Flutter 3.41.3
- Known issues with `flutter pub get` when using Flutter 3.41.4
- Difficulty switching between versions for different projects

If you still choose to use this method, you can run:

```bash
cd ~/flutter
git checkout 3.41.3
git checkout 3.41.4
flutter doctor
```

Expand Down
16 changes: 8 additions & 8 deletions docs/MULTIPLE_FLUTTER_VERSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ sudo pacman -R flutter # for Arch

2. Launch Flutter Sidekick

3. Click on "Versions" in the sidebar and download Flutter version `3.41.3`
3. Click on "Versions" in the sidebar and download Flutter version `3.41.4`

4. Set this version as the global default by clicking the "Set as Global" button

Expand Down Expand Up @@ -92,11 +92,11 @@ sudo pacman -R flutter # for Arch
curl -fsSL https://fvm.app/install.sh | bash
```

2. Install and use Flutter 3.41.3:
2. Install and use Flutter 3.41.4:

```bash
fvm install 3.41.3
fvm global 3.41.3
fvm install 3.41.4
fvm global 3.41.4
```

3. Add FVM's default Flutter version to your PATH by adding the following to your `~/.bashrc`, `~/.zshrc`, or equivalent:
Expand Down Expand Up @@ -131,11 +131,11 @@ sudo pacman -R flutter # for Arch
choco install fvm
```

3. Install and use Flutter 3.41.3:
3. Install and use Flutter 3.41.4:

```powershell
fvm install 3.41.3
fvm global 3.41.3
fvm install 3.41.4
fvm global 3.41.4
```

4. Add FVM's Flutter version to your PATH:
Expand All @@ -158,7 +158,7 @@ To use a specific Flutter version for a project:
2. Run:

```bash
fvm use 3.41.3
fvm use 3.41.4
```

This will create a `.fvmrc` file in your project, which specifies the Flutter version to use for this project.
Expand Down
30 changes: 29 additions & 1 deletion lib/bloc/auth_bloc/auth_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,13 @@ class AuthBloc extends Bloc<AuthBlocEvent, AuthBlocState> with TrezorAuthMixin {
allowWeakPassword: weakPasswordsAllowed,
),
);
final KdfUser? currentUser = await _kdfSdk.auth.currentUser;
KdfUser? currentUser = await _kdfSdk.auth.currentUser;
if (currentUser == null) {
return emit(AuthBlocState.error(AuthException.notSignedIn()));
}

await _repairMissingWalletMetadata(currentUser);
currentUser = await _kdfSdk.auth.currentUser;
if (currentUser == null) {
return emit(AuthBlocState.error(AuthException.notSignedIn()));
}
Expand Down Expand Up @@ -499,4 +505,26 @@ class AuthBloc extends Bloc<AuthBlocEvent, AuthBlocState> with TrezorAuthMixin {

return supportedAssets.toList();
}

Future<void> _repairMissingWalletMetadata(KdfUser user) async {
if (_isMissingMetadataStringValue(user.metadata['type'])) {
final walletType = user.walletId.isHd
? WalletType.hdwallet
: WalletType.iguana;
await _kdfSdk.setWalletType(walletType);
}

if (_isMissingMetadataStringValue(user.metadata['wallet_provenance'])) {
final isImported = user.metadata['isImported'];
if (isImported is bool) {
await _kdfSdk.setWalletProvenance(
isImported ? WalletProvenance.imported : WalletProvenance.generated,
);
}
}
}

bool _isMissingMetadataStringValue(dynamic value) {
return value == null || value is String && value.trim().isEmpty;
}
}
11 changes: 11 additions & 0 deletions lib/bloc/cex_market_data/cache_constants.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Hive typeIds 500-504 are reserved for app-local market-data caches.
const int profitLossCacheAdapterTypeId = 500;
const int profitLossAdapterTypeId = 501;
const int fiatValueAdapterTypeId = 502;
const int graphCacheAdapterTypeId = 503;
const int pointAdapterTypeId = 504;

const String profitLossCacheBoxName = 'profit_loss_v2';
const String mockProfitLossCacheBoxName = 'mock_profit_loss_v2';
const String balanceGrowthCacheBoxName = 'balance_growth_v2';
const String mockBalanceGrowthCacheBoxName = 'mock_balance_growth_v2';
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:komodo_persistence_layer/komodo_persistence_layer.dart';
import 'package:web_dex/bloc/cex_market_data/cache_constants.dart';
import 'package:web_dex/bloc/cex_market_data/mockup/generator.dart';
import 'package:web_dex/bloc/cex_market_data/mockup/mock_transaction_history_repository.dart';
import 'package:web_dex/bloc/cex_market_data/mockup/performance_mode.dart';
import 'package:web_dex/bloc/cex_market_data/models/graph_cache.dart';
import 'package:web_dex/bloc/cex_market_data/models/graph_type.dart';
import 'package:web_dex/bloc/cex_market_data/portfolio_growth/portfolio_growth_repository.dart';

class MockPortfolioGrowthRepository extends PortfolioGrowthRepository {
Expand All @@ -25,7 +25,7 @@ class MockPortfolioGrowthRepository extends PortfolioGrowthRepository {
demoDataGenerator: DemoDataCache.withDefaults(sdk),
),
cacheProvider: HiveLazyBoxProvider<String, GraphCache>(
name: GraphType.balanceGrowth.tableName,
name: mockBalanceGrowthCacheBoxName,
),
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import 'dart:math';

import 'package:hive_ce/hive.dart';
import 'package:web_dex/bloc/cex_market_data/cache_constants.dart';
import 'package:web_dex/bloc/cex_market_data/models/graph_cache.dart';
import 'package:web_dex/bloc/cex_market_data/models/graph_type.dart';

class GraphCacheAdapter extends TypeAdapter<GraphCache> {
@override
final int typeId = 17;
final int typeId = graphCacheAdapterTypeId;

@override
GraphCache read(BinaryReader reader) {
Expand Down
3 changes: 2 additions & 1 deletion lib/bloc/cex_market_data/models/adapters/point_adapter.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'dart:math';

import 'package:hive_ce/hive.dart';
import 'package:web_dex/bloc/cex_market_data/cache_constants.dart';

class PointAdapter extends TypeAdapter<Point<double>> {
@override
final int typeId = 18;
final int typeId = pointAdapterTypeId;

@override
Point<double> read(BinaryReader reader) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:komodo_defi_sdk/komodo_defi_sdk.dart';
import 'package:komodo_defi_types/komodo_defi_types.dart';
import 'package:komodo_persistence_layer/komodo_persistence_layer.dart';
import 'package:logging/logging.dart';
import 'package:web_dex/bloc/cex_market_data/cache_constants.dart';
import 'package:web_dex/bloc/cex_market_data/charts.dart';
import 'package:web_dex/bloc/cex_market_data/mockup/mock_portfolio_growth_repository.dart';
import 'package:web_dex/bloc/cex_market_data/mockup/performance_mode.dart';
Expand Down Expand Up @@ -57,7 +58,7 @@ class PortfolioGrowthRepository {
return PortfolioGrowthRepository(
transactionHistoryRepo: transactionHistoryRepo,
cacheProvider: HiveLazyBoxProvider<String, GraphCache>(
name: GraphType.balanceGrowth.tableName,
name: balanceGrowthCacheBoxName,
),
coinsRepository: coinsRepository,
sdk: sdk,
Expand All @@ -79,9 +80,12 @@ class PortfolioGrowthRepository {
final _log = Logger('PortfolioGrowthRepository');

static Future<void> ensureInitialized() async {
Hive
..registerAdapter(GraphCacheAdapter())
..registerAdapter(PointAdapter());
if (!Hive.isAdapterRegistered(graphCacheAdapterTypeId)) {
Hive.registerAdapter(GraphCacheAdapter());
}
if (!Hive.isAdapterRegistered(pointAdapterTypeId)) {
Hive.registerAdapter(PointAdapter());
}
}

/// Get the growth chart for a coin based on the transactions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:komodo_defi_sdk/komodo_defi_sdk.dart';
import 'package:komodo_persistence_layer/komodo_persistence_layer.dart';
import 'package:web_dex/bloc/cex_market_data/cache_constants.dart';
import 'package:web_dex/bloc/cex_market_data/mockup/generator.dart';
import 'package:web_dex/bloc/cex_market_data/mockup/mock_transaction_history_repository.dart';
import 'package:web_dex/bloc/cex_market_data/mockup/performance_mode.dart';
Expand All @@ -19,7 +20,7 @@ class MockProfitLossRepository extends ProfitLossRepository {
factory MockProfitLossRepository.withDefaults({
required PerformanceMode performanceMode,
required KomodoDefiSdk sdk,
String cacheTableName = 'mock_profit_loss',
String cacheTableName = mockProfitLossCacheBoxName,
}) {
return MockProfitLossRepository(
profitLossCacheProvider: HiveLazyBoxProvider<String, ProfitLossCache>(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'package:hive_ce/hive.dart';
import 'package:web_dex/bloc/cex_market_data/cache_constants.dart';

import '../fiat_value.dart';

class FiatValueAdapter extends TypeAdapter<FiatValue> {
@override
final int typeId = 16;
final int typeId = fiatValueAdapterTypeId;

@override
FiatValue read(BinaryReader reader) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'package:hive_ce/hive.dart';
import 'package:web_dex/bloc/cex_market_data/cache_constants.dart';
import 'package:web_dex/bloc/cex_market_data/profit_loss/models/fiat_value.dart';
import 'package:web_dex/bloc/cex_market_data/profit_loss/models/profit_loss.dart';

class ProfitLossAdapter extends TypeAdapter<ProfitLoss> {
@override
final int typeId = 15;
final int typeId = profitLossAdapterTypeId;

@override
ProfitLoss read(BinaryReader reader) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'package:hive_ce/hive.dart';
import 'package:web_dex/bloc/cex_market_data/cache_constants.dart';
import 'package:web_dex/bloc/cex_market_data/profit_loss/models/profit_loss_cache.dart';

class ProfitLossCacheAdapter extends TypeAdapter<ProfitLossCache> {
@override
final int typeId = 14;
final int typeId = profitLossCacheAdapterTypeId;

@override
ProfitLossCache read(BinaryReader reader) {
Expand Down
16 changes: 11 additions & 5 deletions lib/bloc/cex_market_data/profit_loss/profit_loss_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:komodo_defi_sdk/komodo_defi_sdk.dart';
import 'package:komodo_defi_types/komodo_defi_types.dart';
import 'package:komodo_persistence_layer/komodo_persistence_layer.dart';
import 'package:logging/logging.dart';
import 'package:web_dex/bloc/cex_market_data/cache_constants.dart';
import 'package:web_dex/bloc/cex_market_data/charts.dart';
import 'package:web_dex/bloc/cex_market_data/mockup/performance_mode.dart';
import 'package:web_dex/bloc/cex_market_data/profit_loss/demo_profit_loss_repository.dart';
Expand Down Expand Up @@ -33,7 +34,7 @@ class ProfitLossRepository {
factory ProfitLossRepository.withDefaults({
required TransactionHistoryRepo transactionHistoryRepo,
required KomodoDefiSdk sdk,
String cacheTableName = 'profit_loss',
String cacheTableName = profitLossCacheBoxName,
PerformanceMode? demoMode,
}) {
if (demoMode != null) {
Expand Down Expand Up @@ -62,10 +63,15 @@ class ProfitLossRepository {
final _log = Logger('profit-loss-repository');

static Future<void> ensureInitialized() async {
Hive
..registerAdapter(FiatValueAdapter())
..registerAdapter(ProfitLossAdapter())
..registerAdapter(ProfitLossCacheAdapter());
if (!Hive.isAdapterRegistered(fiatValueAdapterTypeId)) {
Hive.registerAdapter(FiatValueAdapter());
}
if (!Hive.isAdapterRegistered(profitLossAdapterTypeId)) {
Hive.registerAdapter(ProfitLossAdapter());
}
if (!Hive.isAdapterRegistered(profitLossCacheAdapterTypeId)) {
Hive.registerAdapter(ProfitLossCacheAdapter());
}
}

Future<void> clearCache() async {
Expand Down
52 changes: 40 additions & 12 deletions lib/model/wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,9 @@ enum WalletProvenance {

extension KdfUserWalletExtension on KdfUser {
Wallet get wallet {
final walletType = WalletType.fromJson(
metadata['type'] as String? ?? 'iguana',
);
final provenance = WalletProvenance.fromJson(
metadata['wallet_provenance'] as String?,
);
final createdAtRaw = metadata['wallet_created_at'];
final createdAt = createdAtRaw is int
? DateTime.fromMillisecondsSinceEpoch(createdAtRaw)
: createdAtRaw is String && int.tryParse(createdAtRaw) != null
? DateTime.fromMillisecondsSinceEpoch(int.parse(createdAtRaw))
: null;
final walletType = _walletTypeFromMetadataOrAuth(this);
final provenance = _walletProvenanceFromMetadata(this);
final createdAt = _walletCreatedAtFromMetadata(this);
return Wallet(
id: walletId.name,
name: walletId.name,
Expand All @@ -260,3 +251,40 @@ extension KdfSdkWalletExtension on KomodoDefiSdk {
Future<Iterable<Wallet>> get wallets async =>
(await auth.getUsers()).map((user) => user.wallet);
}

WalletType _walletTypeFromMetadataOrAuth(KdfUser user) {
final metadataType = user.metadata['type'];
if (metadataType is String && metadataType.isNotEmpty) {
return WalletType.fromJson(metadataType);
}

return user.walletId.isHd ? WalletType.hdwallet : WalletType.iguana;
}

WalletProvenance _walletProvenanceFromMetadata(KdfUser user) {
final metadataProvenance = user.metadata['wallet_provenance'];
if (metadataProvenance is String && metadataProvenance.isNotEmpty) {
return WalletProvenance.fromJson(metadataProvenance);
}

final isImported = user.metadata['isImported'];
if (isImported is bool) {
return isImported ? WalletProvenance.imported : WalletProvenance.generated;
}

return WalletProvenance.unknown;
}

DateTime? _walletCreatedAtFromMetadata(KdfUser user) {
final createdAtRaw = user.metadata['wallet_created_at'];
if (createdAtRaw is int) {
return DateTime.fromMillisecondsSinceEpoch(createdAtRaw);
}
if (createdAtRaw is String) {
final createdAtMs = int.tryParse(createdAtRaw);
if (createdAtMs != null) {
return DateTime.fromMillisecondsSinceEpoch(createdAtMs);
}
}
return null;
}
Loading
Loading