Skip to content

Commit

Permalink
Merge branch 'master' into UX-for-new-feature--secure-your-wallet-dur…
Browse files Browse the repository at this point in the history
…ing-sign-up
  • Loading branch information
azackmatoff committed Jun 29, 2023
2 parents 9f6249b + 8f34c62 commit 6868eae
Show file tree
Hide file tree
Showing 63 changed files with 715 additions and 757 deletions.
22 changes: 22 additions & 0 deletions app/lib/config/biometiric_auth_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
enum BiometricAuthState {
enabled,
deviceNotSupported,
disabled;

factory BiometricAuthState.fromString(String value) {
return switch (value) {
'enabled' => BiometricAuthState.enabled,
'deviceNotSupported' => BiometricAuthState.deviceNotSupported,
'disabled' => BiometricAuthState.disabled,
_ => throw Exception(),
};
}

String get name {
return switch (this) {
BiometricAuthState.enabled => 'enabled',
BiometricAuthState.deviceNotSupported => 'deviceNotSupported',
BiometricAuthState.disabled => 'disabled',
};
}
}
8 changes: 7 additions & 1 deletion app/lib/l10n/arb/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"bazaarNew": "Neu im Bazaar",
"bazaarTitle": "Der Bazaar",
"biometricAuth": "Biometrische Authentifizierung",
"biometricAuthDescription": "Die biometrische Authentifizierung verwendet die auf deinem Telefon gespeicherten biometrischen Informationen, um dich zu authentifizieren, anstatt deinen PIN zu verwenden. Du kannst die biometrische Authentifizierung jederzeit in den Einstellungen aktivieren und deaktivieren.",
"biometricAuthEnableDisableDescription": "Gib deinen PIN ein, um die biometrische Authentifizierung zu aktivieren oder zu deaktivieren.",
"block": "Block",
"bootstrapperContent": "Wenn Du noch Endorsement-Tickets übrig hast, vergiss nicht Newbies zu als vertrauenswürdig zu bestätigen.",
"bootstrapperTitle": "Als Bootstrapper registriert - Dein Platz ist garantiert.",
Expand Down Expand Up @@ -123,8 +125,10 @@
"detail": "Detail",
"detailsEnter": "Gib deine Details ein.",
"developer": "Entwickler-Modus",
"disable": "Deaktivieren",
"done": "Erledigt",
"doYouAlreadyHaveAnAccount": "Hast du bereits ein Konto?",
"enable": "Aktivieren",
"enableBazaar": "Bazaar aktivieren",
"endorseeContent": "Du wurdest von einem Bootstrapper als vertrauenswürdiges Mitglied bestätigt. Deswegen ist dein Sitz garantiert.",
"endorseeTitle": "Als Endorsee registriert - Dein Platz is garantiert.",
Expand Down Expand Up @@ -216,6 +220,7 @@
"noInvoice": "Ohne Rechnung",
"noItems": "Keine Items Gefunden",
"noMnemonicFound": "Keine Mnemonik gefunden",
"notNow": "Nicht jetzt",
"notifications": "Benachrichtigungen",
"notifySubmittedQueued": "Die Transaktion in der Warteschlange wurde eingereicht",
"noTransactions": "Keine Transaktionen",
Expand Down Expand Up @@ -452,5 +457,6 @@
"example": "LEU"
}
}
}
},
"verifyAuthTitle": "{useBioAuth, select, true{deine Identität} false{deine PIN} other{}} überprüfen, um die Transaktion abzuschließen."
}
14 changes: 14 additions & 0 deletions app/lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"bazaarNew": "New in Bazaar",
"bazaarTitle": "The Bazaar",
"biometricAuth": "Biometric authentication",
"biometricAuthDescription": "Biometric authentication uses the biometric information stored on your phone to authenticate you, instead of using your pin. You can enable and disable biometric authentication anytime in the settings.",
"biometricAuthEnableDisableDescription": "Enter your PIN to enable or disable biometric authentication.",
"block": "Block",
"bootstrapperContent": "If you have endorsement tickets left, please consider endorsing newbies to help the community grow.",
"bootstrapperTitle": "Registered as bootstrapper - your seat is guaranteed.",
Expand Down Expand Up @@ -123,8 +125,10 @@
"detail": "Detail",
"detailsEnter": "Enter your details.",
"developer": "Developer mode",
"disable": "Disable",
"done": "done",
"doYouAlreadyHaveAnAccount": "Do you already have an account?",
"enable": "Enable",
"enableBazaar": "Enable Bazaar",
"endorseeContent": "You have been endorsed as a trustworthy community member. Hence, you are guaranteed to be assigned to a gathering this cycle.",
"endorseeTitle": "Registered as endorsee - your seat is guaranteed",
Expand Down Expand Up @@ -216,6 +220,7 @@
"noInvoice": "No invoice",
"noItems": "No items found",
"noMnemonicFound": "No Mnemonic found",
"notNow": "Not now",
"notifications": "Notifications",
"notifySubmittedQueued": "Queued transaction Submitted",
"noTransactions": "No Transactions",
Expand Down Expand Up @@ -588,5 +593,14 @@
"example": "LEU"
}
}
},
"verifyAuthTitle": "Verify the {useBioAuth, select, true{your identity} false{the PIN code} other{ }} to complete the transaction.",
"@verifyAuthTitle": {
"placeholders": {
"useBioAuth": {
"type": "String",
"example": "true"
}
}
}
}
8 changes: 7 additions & 1 deletion app/lib/l10n/arb/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"bazaarNew": "Nouveau au Bazaar",
"bazaarTitle": "Le Bazaar",
"biometricAuth": "Authentification biométrique",
"biometricAuthDescription": "L'authentification biométrique utilise les informations biométriques stockées sur ton téléphone pour t'authentifier au lieu d'utiliser ton code PIN. Tu peux activer ou désactiver l'authentification biométrique à tout moment dans les paramètres.",
"biometricAuthEnableDisableDescription": "Entres ton code PIN pour activer ou désactiver l'authentification biométrique.",
"block": "Bloc",
"bootstrapperContent": "S'il te reste des tickets d'endossement, n'oublie pas de confirmer Novice comme digne de confiance.",
"bootstrapperTitle": "Enregistré comme Bootstrapper - ta place est garantie.",
Expand Down Expand Up @@ -123,8 +125,10 @@
"detail": "Détail",
"detailsEnter": "Entre tes détails.",
"developer": "Mode développeur",
"disable": "Désactiver",
"done": "Finit",
"doYouAlreadyHaveAnAccount": "Tu as déjà un compte?",
"enable": "Activer",
"enableBazaar": "Activer le Bazaar",
"endorseeContent": "Tu as été confirmé comme membre de confiance par un Bootstrapper. Ta place est donc garantie.",
"endorseeTitle": "Enregistré comme Endosser - Ta place est garantie.",
Expand Down Expand Up @@ -216,6 +220,7 @@
"noInvoice": "Sans facture",
"noItems": "Aucun objet trouvé",
"noMnemonicFound": "Aucun mnémonique trouvé",
"notNow": "Pas maintenant",
"notifications": "Notifications",
"notifySubmittedQueued": "La transaction dans la file d'attente a été soumise",
"noTransactions": "Aucune transaction",
Expand Down Expand Up @@ -452,5 +457,6 @@
"example": "LEU"
}
}
}
},
"verifyAuthTitle": "Veuillez vérifier {useBioAuth, select, true{ta identité} false{le NIP} other{}} pour finaliser la transaction."
}
8 changes: 7 additions & 1 deletion app/lib/l10n/arb/app_ru.arb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"bazaarNew": "Новое на Базаре",
"bazaarTitle": "Базар",
"biometricAuth": "Биометрическая аутентификация",
"biometricAuthDescription": "Биометрическая аутентификация использует биометрическую информацию, хранящуюся на вашем телефоне, для аутентификации вас, вместо использования пин-кода. Вы можете включать и отключать биометрическую аутентификацию в любое время в настройках.",
"biometricAuthEnableDisableDescription": "Введите свой PIN-код, чтобы включить или отключить биометрическую аутентификацию.",
"block": "Блокировать",
"bootstrapperContent": "Рассмотрите возможность одобрения новичков, если у вас есть билеты на одобрение,это поможет сообществу расти.",
"bootstrapperTitle": "Зарегистрирован в качестве Бутсреппера - место гарантировано.",
Expand Down Expand Up @@ -123,8 +125,10 @@
"detail": "Детали",
"detailsEnter": "Введите свои данные",
"developer": "Режим разработчика",
"disable": "Выключить",
"done": "Выполнено",
"doYouAlreadyHaveAnAccount": "У вас уже есть аккаунт?",
"enable": "Включить",
"enableBazaar": "Включить Базар",
"endorseeContent": "Вы былы одобрены, как заслуживающий доверия член общины. Следовательно, Вы гарантированно будете назначены на этот цикл.",
"endorseeTitle": "Зарегистрирован в качестве Индоссанта - ваше место гарантировано",
Expand Down Expand Up @@ -216,6 +220,7 @@
"noInvoice": "Без счета-фактуры",
"noItems": "Элементы не найдены",
"noMnemonicFound": "Мнемоника не найдена",
"notNow": "Не сейчас",
"notifications": "Уведомления",
"notifySubmittedQueued": "Транзакция, в очереди, отправлена",
"noTransactions": "Нет транзакций",
Expand Down Expand Up @@ -452,5 +457,6 @@
"example": "LEU"
}
}
}
},
"verifyAuthTitle": "Для завершения транзакции {useBioAuth, select, true{подтвердите вашу личность} false{введите PIN-код} other{}}."
}
11 changes: 8 additions & 3 deletions app/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import 'dart:io';

import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:encointer_wallet/service/substrate_api/core/dart_api.dart';
import 'package:ew_storage/ew_storage.dart';
import 'package:ew_http/ew_http.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:local_auth/local_auth.dart';
import 'package:provider/provider.dart';

import 'package:encointer_wallet/app.dart';
Expand All @@ -15,6 +15,7 @@ import 'package:encointer_wallet/utils/repository_provider.dart';
import 'package:encointer_wallet/modules/modules.dart';
import 'package:encointer_wallet/service/notification/lib/notification.dart';
import 'package:encointer_wallet/store/connectivity/connectivity_store.dart';
import 'package:encointer_wallet/service/substrate_api/core/dart_api.dart';
import 'package:encointer_wallet/service/http_overrides.dart';
import 'package:encointer_wallet/store/app.dart';
import 'package:encointer_wallet/utils/local_storage.dart' as util;
Expand All @@ -30,8 +31,9 @@ Future<void> main({AppConfig? appConfig, AppSettings? settings}) async {
}

HttpOverrides.global = MyHttpOverrides();
final pref = await SharedPreferences.getInstance();

appSettings = settings ?? AppSettings(AppService(await SharedPreferences.getInstance()));
appSettings = settings ?? AppSettings(AppService(pref));

runApp(
MultiRepositoryProvider(
Expand All @@ -44,7 +46,10 @@ Future<void> main({AppConfig? appConfig, AppSettings? settings}) async {
providers: [
Provider<AppSettings>(create: (context) => appSettings..init()),
Provider<ConnectivityStore>(create: (context) => ConnectivityStore(Connectivity())..listen()),
Provider<AppStore>(create: (context) => AppStore(util.LocalStorage(), const SecureStorage()))
Provider<AppStore>(create: (context) => AppStore(util.LocalStorage())),
Provider<LoginStore>(
create: (context) => LoginStore(LoginService(LocalAuthentication(), pref, const SecureStorage())),
)
],
child: const WalletApp(),
),
Expand Down
18 changes: 18 additions & 0 deletions app/lib/models/transfer/transfer_history.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:json_annotation/json_annotation.dart';

import 'package:encointer_wallet/utils/extensions/double/double_extension.dart';
import 'package:encointer_wallet/store/account/types/account_data.dart';
import 'package:encointer_wallet/l10n/l10.dart';

Expand Down Expand Up @@ -29,6 +30,7 @@ class Transaction {
final String counterParty;

/// The amount of the transaction.
@ShortenedDouble()
final double amount;

/// Determines the type of this [Transaction] based on its amount.
Expand Down Expand Up @@ -66,3 +68,19 @@ enum TransactionType {
};
}
}

class ShortenedDouble implements JsonConverter<double, num> {
const ShortenedDouble();

@override
double fromJson(num val) {
if (val is int) {
return val.toDouble();
} else {
return (val as double).shortenBigNumber(val, 4);
}
}

@override
num toJson(num val) => val;
}
4 changes: 2 additions & 2 deletions app/lib/models/transfer/transfer_history.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 14 additions & 10 deletions app/lib/modules/account/logic/new_account_store.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// ignore_for_file: library_private_types_in_public_api
import 'package:flutter/material.dart';
import 'package:mobx/mobx.dart';

import 'package:encointer_wallet/modules/modules.dart';
import 'package:encointer_wallet/service/log/log_service.dart';
import 'package:encointer_wallet/service/substrate_api/api.dart';
import 'package:encointer_wallet/store/app.dart';
import 'package:encointer_wallet/utils/format.dart';
import 'package:provider/provider.dart';

part 'new_account_store.g.dart';

Expand Down Expand Up @@ -40,31 +42,32 @@ abstract class _NewAccountStoreBase with Store {
void setKeyType(KeyType value) => keyType = value;

@action
Future<NewAccountResult> generateAccount(AppStore appStore, Api webApi) async {
final pin = password ?? appStore.settings.cachedPin;
Future<NewAccountResult> generateAccount(BuildContext context, Api webApi) async {
final pin = password ?? context.read<AppStore>().settings.cachedPin;
if (pin.isEmpty) return const NewAccountResult(NewAccountResultType.emptyPassword);
return _generateAccount(appStore, webApi, pin);
return _generateAccount(context, webApi, pin);
}

@action
Future<NewAccountResult> importAccount(AppStore appStore, Api webApi) async {
final pin = password ?? appStore.settings.cachedPin;
Future<NewAccountResult> importAccount(BuildContext context, Api webApi) async {
final pin = password ?? context.read<AppStore>().settings.cachedPin;
if (pin.isEmpty) return const NewAccountResult(NewAccountResultType.emptyPassword);
return _importAccount(appStore, webApi, pin);
return _importAccount(context, webApi, pin);
}

@action
Future<NewAccountResult> _generateAccount(AppStore appStore, Api webApi, String pin) async {
Future<NewAccountResult> _generateAccount(BuildContext context, Api webApi, String pin) async {
try {
_loading = true;
await appStore.settings.setPin(pin);
final key = await webApi.account.generateAccount();
final acc = await webApi.account.importAccount(key: key, password: pin);
if (acc['error'] != null) {
_loading = false;
return const NewAccountResult(NewAccountResultType.error);
}

await context.read<LoginStore>().setPin(pin);
final appStore = context.read<AppStore>()..settings.cachedPin = pin;
acc['address'] = Fmt.ss58Encode(acc['pubKey'] as String, prefix: appStore.settings.endpoint.ss58!);
return saveAccount(webApi, appStore, acc, pin);
} catch (e, s) {
Expand All @@ -75,10 +78,9 @@ abstract class _NewAccountStoreBase with Store {
}

@action
Future<NewAccountResult> _importAccount(AppStore appStore, Api webApi, String pin) async {
Future<NewAccountResult> _importAccount(BuildContext context, Api webApi, String pin) async {
try {
_loading = true;
await appStore.settings.setPin(pin);
assert(accountKey != null && accountKey!.isNotEmpty, 'accountKey can not be null or empty');
final acc = await webApi.account.importAccount(
key: accountKey!,
Expand All @@ -89,6 +91,8 @@ abstract class _NewAccountStoreBase with Store {
_loading = false;
return const NewAccountResult(NewAccountResultType.error);
} else {
await context.read<LoginStore>().setPin(pin);
final appStore = context.read<AppStore>()..settings.cachedPin = pin;
acc['address'] = Fmt.ss58Encode(acc['pubKey'] as String, prefix: appStore.settings.endpoint.ss58!);
final index = appStore.account.accountList.indexWhere((i) => i.pubKey == acc['pubKey']);
if (index > -1) {
Expand Down
16 changes: 8 additions & 8 deletions app/lib/modules/account/logic/new_account_store.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions app/lib/modules/account/view/add_account_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,9 @@ class AddAcccountForm extends StatelessWidget with HandleNewAccountResultMixin {
key: const Key('create-account-confirm'),
onPressed: () async {
final newAccount = context.read<NewAccountStore>();
final appStore = context.read<AppStore>();
if (_formKey.currentState!.validate() && !newAccount.loading) {
newAccount.setName(_nameCtrl.text.trim());
final res = await newAccount.generateAccount(appStore, webApi);
final res = await newAccount.generateAccount(context, webApi);
await navigate(
context: context,
type: res.operationResult,
Expand Down
Loading

0 comments on commit 6868eae

Please sign in to comment.