Skip to content

Commit

Permalink
Merge branch 'adr/api_endpoints' of github.com:input-output-hk/cataly…
Browse files Browse the repository at this point in the history
…st-voices into adr/api_endpoints
  • Loading branch information
stevenj committed Oct 18, 2024
2 parents 8978c1a + ff9db40 commit 09aeab3
Show file tree
Hide file tree
Showing 49 changed files with 1,826 additions and 518 deletions.
1 change: 1 addition & 0 deletions .config/dictionaries/project.dic
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,4 @@ xctestrun
xcworkspace
xvfb
yoroi
Pbkdf2
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ jobs:
ci:
uses: input-output-hk/catalyst-forge/.github/workflows/ci.yml@ci/v1.1.0
with:
forge_version: 0.2.1
forge_version: 0.2.1

test_reporting:
if: always()
needs: ci
uses: input-output-hk/catalyst-voices/.github/workflows/generate-allure-report.yml@main
55 changes: 14 additions & 41 deletions .github/workflows/generate-allure-report.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
name: Allure Report Generation

on:
pull_request:
push:
branches: "main"
tags: ["*"]
workflow_call:

permissions:
contents: write
Expand All @@ -16,10 +13,6 @@ concurrency:
cancel-in-progress: true

env:
AWS_REGION: eu-central-1
AWS_ROLE_ARN: arn:aws:iam::332405224602:role/ci
EARTHLY_TARGET: docker
ECR_REGISTRY: 332405224602.dkr.ecr.eu-central-1.amazonaws.com
ALLURE_REPORT_PATH: allure-report
COVERAGE_REPORT_PATH: coverage-report
REPORT_EXT: .junit-report.xml
Expand All @@ -32,60 +25,40 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install Forge
uses: input-output-hk/catalyst-forge/actions/install@ci/v1.1.0
if: always()

- name: Setup CI
uses: input-output-hk/catalyst-ci/actions/setup@master
with:
aws_role_arn: ${{ env.AWS_ROLE_ARN }}
aws_region: ${{ env.AWS_REGION }}
earthly_runner_secret: ${{ secrets.EARTHLY_RUNNER_SECRET }}
uses: input-output-hk/catalyst-forge/actions/setup@master

- name: Get catalyst gateway unit test report
uses: input-output-hk/catalyst-ci/actions/run@master
uses: input-output-hk/catalyst-forge/actions/run@master
if: always()
continue-on-error: true
with:
earthfile: ./catalyst-gateway/
flags:
targets: build
target_flags:
runner_address: ${{ secrets.EARTHLY_SATELLITE_ADDRESS }}
artifact: "false"
path: ./catalyst-gateway+build

- name: Get schemathesis test report
uses: input-output-hk/catalyst-ci/actions/run@master
uses: input-output-hk/catalyst-forge/actions/run@master
if: always()
continue-on-error: true
with:
earthfile: ./catalyst-gateway/tests/schemathesis_tests
flags: --allow-privileged
targets: test-fuzzer-api
target_flags:
runner_address: ${{ secrets.EARTHLY_SATELLITE_ADDRESS }}
artifact: "false"
path: ./catalyst-gateway/tests/schemathesis_tests+test-fuzzer-api

- name: Get flutter unit test report
uses: input-output-hk/catalyst-ci/actions/run@master
uses: input-output-hk/catalyst-forge/actions/run@master
if: always()
continue-on-error: true
with:
earthfile: ./catalyst_voices/
flags:
targets: test-unit
target_flags:
runner_address: ${{ secrets.EARTHLY_SATELLITE_ADDRESS }}
artifact: "false"
path: ./catalyst_voices+test-unit

- name: Get python api test report
uses: input-output-hk/catalyst-ci/actions/run@master
uses: input-output-hk/catalyst-forge/actions/run@master
if: always()
continue-on-error: true
with:
earthfile: ./catalyst-gateway/tests/api_tests/
flags: --allow-privileged
targets: test
target_flags:
runner_address: ${{ secrets.EARTHLY_SATELLITE_ADDRESS }}
artifact: "false"
path: ./catalyst-gateway/tests/api_tests+test

- name: Collect and upload test reports
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion catalyst-gateway/bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repository.workspace = true
workspace = true

[dependencies]
cardano-chain-follower = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "v0.0.3" }
cardano-chain-follower = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "2024-10-15-01" }
c509-certificate = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "v0.0.3" }

pallas = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
Expand Down
5 changes: 4 additions & 1 deletion catalyst_voices/lib/app/view/app_content.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:catalyst_voices/app/view/app_precache_image_assets.dart';
import 'package:catalyst_voices/app/view/app_session_listener.dart';
import 'package:catalyst_voices_brands/catalyst_voices_brands.dart';
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -51,7 +52,9 @@ class AppContentState extends State<AppContent> {
),
builder: (context, child) {
return GlobalPrecacheImages(
child: child ?? const SizedBox.shrink(),
child: GlobalSessionListener(
child: child ?? const SizedBox.shrink(),
),
);
},
);
Expand Down
67 changes: 67 additions & 0 deletions catalyst_voices/lib/app/view/app_session_listener.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import 'package:catalyst_voices/widgets/snackbar/voices_snackbar.dart';
import 'package:catalyst_voices/widgets/snackbar/voices_snackbar_type.dart';
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart';
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart';
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

/// Listens globally to a session and can show different
/// snackBars when a session changes.
class GlobalSessionListener extends StatelessWidget {
final Widget child;

const GlobalSessionListener({
super.key,
required this.child,
});

@override
Widget build(BuildContext context) {
return BlocListener<SessionBloc, SessionState>(
listenWhen: _listenToSessionChangesWhen,
listener: _onSessionChanged,
child: child,
);
}

bool _listenToSessionChangesWhen(SessionState prev, SessionState next) {
// We deliberately check if previous was guest because we don't
// want to show the snackbar after the registration is completed.
final keychainUnlocked =
prev is GuestSessionState && next is ActiveUserSessionState;

final keychainLocked =
prev is ActiveUserSessionState && next is GuestSessionState;

return keychainUnlocked || keychainLocked;
}

void _onSessionChanged(BuildContext context, SessionState state) {
if (state is ActiveUserSessionState) {
_onUnlockedKeychain(context);
} else if (state is GuestSessionState) {
_onLockedKeychain(context);
}
}

void _onUnlockedKeychain(BuildContext context) {
VoicesSnackBar(
type: VoicesSnackBarType.success,
behavior: SnackBarBehavior.floating,
icon: VoicesAssets.icons.lockOpen.buildIcon(),
title: context.l10n.unlockSnackbarTitle,
message: context.l10n.unlockSnackbarMessage,
).show(context);
}

void _onLockedKeychain(BuildContext context) {
VoicesSnackBar(
type: VoicesSnackBarType.error,
behavior: SnackBarBehavior.floating,
icon: VoicesAssets.icons.lockClosed.buildIcon(),
title: context.l10n.lockSnackbarTitle,
message: context.l10n.lockSnackbarMessage,
).show(context);
}
}
40 changes: 36 additions & 4 deletions catalyst_voices/lib/common/error_handler.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,46 @@
//ignore_for_file: one_member_abstracts

import 'dart:async';

import 'package:catalyst_voices/widgets/snackbar/voices_snackbar.dart';
import 'package:catalyst_voices/widgets/snackbar/voices_snackbar_type.dart';
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart';
import 'package:catalyst_voices_view_models/catalyst_voices_view_models.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

/// An interface of an abstract error handler.
abstract interface class ErrorHandler {
void handleError(Object error);
}

mixin ErrorHandlerStateMixin<T extends StatefulWidget> on State<T>
implements ErrorHandler {
/// A convenient mixin that subscribes to the [ErrorEmitter]
/// obtained from the [errorEmitter] and calls the [handleError].
///
/// After the widget is disposed the error stream is disposed too.
mixin ErrorHandlerStateMixin<E extends ErrorEmitter, T extends StatefulWidget>
on State<T> implements ErrorHandler {
StreamSubscription<Object>? _errorSub;

@override
void initState() {
super.initState();
_errorSub = errorEmitter.errorStream.listen(handleError);
}

@override
void dispose() {
unawaited(_errorSub?.cancel());
_errorSub = null;
super.dispose();
}

/// A method that can be overridden to provide a custom error emitter.
///
/// If this method is not overriden then the emitter of type [E]
/// must be provided in a widget tree so that context.read can find it.
E get errorEmitter => context.read<E>();

@override
void handleError(Object error) {
if (error is LocalizedException) {
Expand All @@ -19,7 +49,9 @@ mixin ErrorHandlerStateMixin<T extends StatefulWidget> on State<T>
}

void handleLocalizedException(LocalizedException exception) {
// TODO(damian-molinski): VoicesSnackBar does not support custom text yet.
const VoicesSnackBar(type: VoicesSnackBarType.error).show(context);
VoicesSnackBar(
type: VoicesSnackBarType.error,
message: exception.message(context),
).show(context);
}
}
2 changes: 1 addition & 1 deletion catalyst_voices/lib/dependency/dependencies.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ final class Dependencies extends DependencyProvider {

void _registerServices() {
registerLazySingleton<Storage>(() => const SecureStorage());
registerLazySingleton<Vault>(() => const SecureStorageVault());
registerLazySingleton<Vault>(SecureStorageVault.new);
registerLazySingleton<DummyAuthStorage>(
() => const SecureDummyAuthStorage(),
);
Expand Down
Loading

0 comments on commit 09aeab3

Please sign in to comment.