Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ jobs:
- run: dart run tool/generate_localization.dart
- run: dart run tool/generate_release_info.dart
- run: flutter pub run build_runner build
- run: flutter analyze
- run: flutter analyze --fatal-warnings
# Excludes the `golden` tag: visual-regression tests live under
# `test/goldens/` and are validated on the dfx01 self-hosted runner
# in the parallel `golden-tests` job (Hardware-Determinismus, see
# `docs/visual-regression-tests.md`). Running them here too would
# both duplicate work and erroneously red this job on macos-latest
# where the Skia/font-rendering does not match the committed
# baselines.
- run: flutter test --coverage --exclude-tags golden
- run: ulimit -n 16384 && flutter test --coverage --exclude-tags golden

# Narrow the coverage report to the README-defined activated surface:
# lib/packages/** — services, repositories, signers, utils
Expand Down
12 changes: 12 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,21 @@ formatter:
page_width: 100
trailing_commas: preserve

analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true

linter:
rules:
annotate_overrides: true
avoid_print: true
prefer_const_constructors: true
prefer_single_quotes: true
unawaited_futures: true
avoid_dynamic_calls: true
cast_nullable_to_non_nullable: true
null_check_on_nullable_type_parameter: true
unnecessary_null_checks: true
prefer_final_locals: true
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Future<void> _initialize() async {
Future<void> _initializeWithSplashDuration() async {
await Future.wait([
_initialize(),
Future.delayed(const Duration(seconds: 3)),
Future<void>.delayed(const Duration(seconds: 3)),
]);
}

Expand Down
3 changes: 2 additions & 1 deletion lib/packages/repository/supported_fiat_repository.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:developer' as developer;

import 'package:realunit_wallet/packages/service/dfx/dfx_fiat_service.dart';
import 'package:realunit_wallet/packages/service/dfx/models/fiat/dto/dfx_fiat_dto.dart';
import 'package:realunit_wallet/styles/currency.dart';

/// Translates the backend's per-user fiat list into the local [Currency]
Expand All @@ -23,7 +24,7 @@ class SupportedFiatRepository {

Future<List<Currency>> getAll() => _resolve((_) => true);

Future<List<Currency>> _resolve(bool Function(dynamic) filter) async {
Future<List<Currency>> _resolve(bool Function(DfxFiatDto) filter) async {
final fiats = await _fiatService.getAllFiats();
final result = <Currency>[];
for (final fiat in fiats) {
Expand Down
2 changes: 1 addition & 1 deletion lib/packages/service/balance_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BalanceService {
final response = await _appStore.httpClient.get(uri);

if (response.statusCode == 200) {
final json = jsonDecode(response.body);
final json = jsonDecode(response.body) as Map<String, dynamic>;
final balanceString = json['balance'] as String?;

if (balanceString != null) {
Expand Down
2 changes: 1 addition & 1 deletion lib/packages/service/debug_auth_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DebugAuthService {
);

if (response.statusCode == 200) {
final body = jsonDecode(response.body);
final body = jsonDecode(response.body) as Map<String, dynamic>;
return body['message'] as String;
}
throw Exception('Failed to fetch sign message (${response.statusCode})');
Expand Down
5 changes: 3 additions & 2 deletions lib/packages/service/dfx/dfx_auth_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ abstract class DFXAuthService {
final responseBody = jsonDecode(response.body);
return responseBody as Map<String, dynamic>;
} else if (response.statusCode == 403) {
final responseBody = jsonDecode(response.body);
final message = responseBody['message'] ?? 'Service unavailable in your country';
final responseBody = jsonDecode(response.body) as Map<String, dynamic>;
final message =
responseBody['message'] ?? 'Service unavailable in your country';
throw Exception(message);
} else {
throw Exception('Failed to sign up. Status: ${response.statusCode} ${response.body}');
Expand Down
9 changes: 5 additions & 4 deletions lib/packages/service/dfx/dfx_bank_account_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ class DfxBankAccountService extends DFXAuthService {
throw ApiException.fromJson(errorJson, httpStatusCode: response.statusCode);
}

final List<dynamic> jsonList = jsonDecode(response.body);
final bankAccounts = jsonList.map((json) => BankAccountDto.fromJson(json)).toList();
final jsonList = jsonDecode(response.body) as List<dynamic>;
final bankAccounts =
jsonList.map((json) => BankAccountDto.fromJson(json as Map<String, dynamic>)).toList();
return bankAccounts;
}

Expand All @@ -47,7 +48,7 @@ class DfxBankAccountService extends DFXAuthService {
throw ApiException.fromJson(errorJson, httpStatusCode: response.statusCode);
}

return BankAccountDto.fromJson(jsonDecode(response.body));
return BankAccountDto.fromJson(jsonDecode(response.body) as Map<String, dynamic>);
}

Future<BankAccountDto> updateBankAccount({
Expand All @@ -74,6 +75,6 @@ class DfxBankAccountService extends DFXAuthService {
throw ApiException.fromJson(errorJson, httpStatusCode: response.statusCode);
}

return BankAccountDto.fromJson(jsonDecode(response.body));
return BankAccountDto.fromJson(jsonDecode(response.body) as Map<String, dynamic>);
}
}
8 changes: 4 additions & 4 deletions lib/packages/service/dfx/dfx_brokerbot_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DfxBrokerbotService extends DFXAuthService {
throw Exception('BuyPrice request failed: ${res.body}');
}

return BrokerbotBuyPriceDto.fromJson(jsonDecode(res.body));
return BrokerbotBuyPriceDto.fromJson(jsonDecode(res.body) as Map<String, dynamic>);
}

/// Convert CHF → REALU shares
Expand All @@ -54,7 +54,7 @@ class DfxBrokerbotService extends DFXAuthService {
throw Exception('Shares request failed: ${res.body}');
}

return BrokerbotBuySharesDto.fromJson(jsonDecode(res.body));
return BrokerbotBuySharesDto.fromJson(jsonDecode(res.body) as Map<String, dynamic>);
}

/// Convert REALU shares → CHF (with fees)
Expand All @@ -75,7 +75,7 @@ class DfxBrokerbotService extends DFXAuthService {
throw ApiException.fromJson(errorJson, httpStatusCode: res.statusCode);
}

return BrokerbotSellPriceDto.fromJson(jsonDecode(res.body));
return BrokerbotSellPriceDto.fromJson(jsonDecode(res.body) as Map<String, dynamic>);
}

/// Convert CHF → REALU shares (with fees)
Expand All @@ -96,6 +96,6 @@ class DfxBrokerbotService extends DFXAuthService {
throw ApiException.fromJson(errorJson, httpStatusCode: res.statusCode);
}

return BrokerbotSellSharesDto.fromJson(jsonDecode(res.body));
return BrokerbotSellSharesDto.fromJson(jsonDecode(res.body) as Map<String, dynamic>);
}
}
4 changes: 2 additions & 2 deletions lib/packages/service/dfx/dfx_country_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class DfxCountryService {
final response = await _appStore.httpClient.get(uri);

if (response.statusCode == 200) {
final List<dynamic> jsonList = jsonDecode(response.body);
final jsonList = jsonDecode(response.body) as List<dynamic>;
final countries = jsonList
.map((json) => DfxCountryDto.fromJson(json))
.map((json) => DfxCountryDto.fromJson(json as Map<String, dynamic>))
.map((dto) => dto.toCountry())
.toList();
cachedCountries = countries;
Expand Down
5 changes: 3 additions & 2 deletions lib/packages/service/dfx/dfx_fiat_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ class DfxFiatService {
throw Exception('Failed to fetch fiats: ${response.statusCode}');
}

final List<dynamic> jsonList = jsonDecode(response.body);
final fiats = jsonList.map((json) => DfxFiatDto.fromJson(json)).toList();
final jsonList = jsonDecode(response.body) as List<dynamic>;
final fiats =
jsonList.map((json) => DfxFiatDto.fromJson(json as Map<String, dynamic>)).toList();
_cachedFiats = fiats;
_cachedAt = clock.now();
return fiats;
Expand Down
6 changes: 3 additions & 3 deletions lib/packages/service/dfx/dfx_kyc_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class DfxKycService extends DFXAuthService {
throw ApiException.fromJson(errorJson, httpStatusCode: response.statusCode);
}

final json = jsonDecode(response.body);
final json = jsonDecode(response.body) as Map<String, dynamic>;
return KycLevelDto.fromJson(json);
}

Expand All @@ -76,7 +76,7 @@ class DfxKycService extends DFXAuthService {
throw ApiException.fromJson(errorJson, httpStatusCode: response.statusCode);
}

final json = jsonDecode(response.body);
final json = jsonDecode(response.body) as Map<String, dynamic>;
return KycSessionDto.fromJson(json);
}

Expand All @@ -98,7 +98,7 @@ class DfxKycService extends DFXAuthService {
throw ApiException.fromJson(errorJson, httpStatusCode: response.statusCode);
}

final json = jsonDecode(response.body);
final json = jsonDecode(response.body) as Map<String, dynamic>;
return KycSessionDto.fromJson(json);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/packages/service/dfx/dfx_language_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class DfxLanguageService {
throw Exception('Failed to fetch languages: ${response.statusCode}');
}

final List<dynamic> jsonList = jsonDecode(response.body);
final jsonList = jsonDecode(response.body) as List<dynamic>;
final languages = jsonList
.map((json) => DfxLanguageDto.fromJson(json))
.map((json) => DfxLanguageDto.fromJson(json as Map<String, dynamic>))
.toList();
_cachedLanguages = languages;
_cachedAt = clock.now();
Expand Down
19 changes: 10 additions & 9 deletions lib/packages/service/dfx/dfx_price_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,26 @@ class DFXPriceService extends APriceService {

if (response.statusCode != 200) throw Exception(response.body);

final body = jsonDecode(response.body) as List;
final body = jsonDecode(response.body) as List<dynamic>;

final result = <PricePoint>[];

for (final entry in body) {
for (final raw in body) {
final entry = raw as Map<String, dynamic>;
BigInt price;
switch (currency) {
case Currency.eur:
price = BigInt.from(entry['eur'] * 100);
price = BigInt.from((entry['eur'] as num) * 100);
break;
case Currency.chf:
price = BigInt.from(entry['chf'] * 100);
price = BigInt.from((entry['chf'] as num) * 100);
break;
}
result.add(
PricePoint(
asset: asset,
price: price,
time: DateTime.parse(entry['timestamp']),
time: DateTime.parse(entry['timestamp'] as String),
),
);
}
Expand All @@ -57,13 +58,13 @@ class DFXPriceService extends APriceService {

if (response.statusCode != 200) throw Exception(response.body);

final body = jsonDecode(response.body);
final body = jsonDecode(response.body) as Map<String, dynamic>;

switch (currency) {
case Currency.eur:
return BigInt.from(body['eur'] * 100);
return BigInt.from((body['eur'] as num) * 100);
case Currency.chf:
return BigInt.from(body['chf'] * 100);
return BigInt.from((body['chf'] as num) * 100);
}
}

Expand All @@ -74,7 +75,7 @@ class DFXPriceService extends APriceService {

if (response.statusCode != 200) throw Exception(response.body);

final body = jsonDecode(response.body);
final body = jsonDecode(response.body) as Map<String, dynamic>;
final chf = (body['chf'] as num).toDouble();
final eur = (body['eur'] as num).toDouble();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class RealUnitBuyPaymentInfoService extends DFXAuthService {
);

if (response.statusCode == 200) {
final json = jsonDecode(response.body);
final json = jsonDecode(response.body) as Map<String, dynamic>;
final responseDto = RealUnitBuyPaymentInfoDto.fromJson(json);

return BuyPaymentInfo(
Expand Down
6 changes: 3 additions & 3 deletions lib/packages/service/dfx/real_unit_pdf_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class RealUnitPdfService extends DFXAuthService {
throw ApiException.fromJson(errorJson, httpStatusCode: response.statusCode);
}

return PdfDto.fromJson(jsonDecode(response.body));
return PdfDto.fromJson(jsonDecode(response.body) as Map<String, dynamic>);
}

Future<PdfDto> getTransactionsReceipt(
Expand All @@ -64,7 +64,7 @@ class RealUnitPdfService extends DFXAuthService {
throw ApiException.fromJson(errorJson, httpStatusCode: response.statusCode);
}

return PdfDto.fromJson(jsonDecode(response.body));
return PdfDto.fromJson(jsonDecode(response.body) as Map<String, dynamic>);
}

Future<PdfDto> getTransactionReceipt(String id, {Currency currency = Currency.chf}) async {
Expand All @@ -82,6 +82,6 @@ class RealUnitPdfService extends DFXAuthService {
throw ApiException.fromJson(errorJson, httpStatusCode: response.statusCode);
}

return PdfDto.fromJson(jsonDecode(response.body));
return PdfDto.fromJson(jsonDecode(response.body) as Map<String, dynamic>);
}
}
11 changes: 7 additions & 4 deletions lib/packages/service/dfx/real_unit_registration_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class RealUnitRegistrationService extends DFXAuthService {
throw ApiException.fromJson(errorJson, httpStatusCode: response.statusCode);
}

return RealUnitRegistrationInfoDto.fromJson(jsonDecode(response.body));
return RealUnitRegistrationInfoDto.fromJson(jsonDecode(response.body) as Map<String, dynamic>);
}

/// registers an email on the wallet. Should always be called first when registering
Expand All @@ -67,7 +67,8 @@ class RealUnitRegistrationService extends DFXAuthService {
final errorJson = jsonDecode(response.body) as Map<String, dynamic>;
throw ApiException.fromJson(errorJson, httpStatusCode: response.statusCode);
}
final responseDto = RealUnitRegistrationEmailResponseDto.fromJson(jsonDecode(response.body));
final responseDto =
RealUnitRegistrationEmailResponseDto.fromJson(jsonDecode(response.body) as Map<String, dynamic>);
return responseDto.status;
}

Expand Down Expand Up @@ -166,7 +167,8 @@ class RealUnitRegistrationService extends DFXAuthService {
throw ApiException.fromJson(errorJson, httpStatusCode: response.statusCode);
}

final responseDto = RealUnitRegistrationResponseDto.fromJson(jsonDecode(response.body));
final responseDto =
RealUnitRegistrationResponseDto.fromJson(jsonDecode(response.body) as Map<String, dynamic>);
return responseDto.status;
}

Expand Down Expand Up @@ -223,7 +225,8 @@ class RealUnitRegistrationService extends DFXAuthService {
throw ApiException.fromJson(errorJson, httpStatusCode: response.statusCode);
}

final responseDto = RealUnitRegistrationResponseDto.fromJson(jsonDecode(response.body));
final responseDto =
RealUnitRegistrationResponseDto.fromJson(jsonDecode(response.body) as Map<String, dynamic>);
return responseDto.status;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class RealUnitSellPaymentInfoService extends DFXAuthService {
);

if (response.statusCode == 200) {
final json = jsonDecode(response.body);
final json = jsonDecode(response.body) as Map<String, dynamic>;
final responseDto = RealUnitSellPaymentInfoDto.fromJson(json);

return SellPaymentInfo(
Expand Down
6 changes: 3 additions & 3 deletions lib/packages/service/transaction_history_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TransactionHistoryService extends DFXAuthService {
]);

final accountHistory = results.elementAt(0) as AccountHistoryDto?;
final transactions = results.elementAt(1) as List<TransactionDto>;
final transactions = results.elementAt(1)! as List<TransactionDto>;

if (accountHistory == null) return;

Expand Down Expand Up @@ -105,7 +105,7 @@ class TransactionHistoryService extends DFXAuthService {
final response = await appStore.httpClient.get(uri);
if (response.statusCode != 200) return [];

final List<dynamic> json = jsonDecode(response.body);
final json = jsonDecode(response.body) as List<dynamic>;
return json.map((e) => TransactionDto.fromJson(e as Map<String, dynamic>)).toList();
}

Expand All @@ -115,7 +115,7 @@ class TransactionHistoryService extends DFXAuthService {

if (response.statusCode != 200) return [];

final List<dynamic> json = jsonDecode(response.body);
final json = jsonDecode(response.body) as List<dynamic>;
final transactions = json
.map((e) => TransactionDto.fromJson(e as Map<String, dynamic>))
.toList();
Expand Down
Loading
Loading