Skip to content
Snippets Groups Projects
Commit d9c30d33 authored by poka's avatar poka
Browse files

refacto: username is nullable

parent 9f014480
Branches
Tags
No related merge requests found
Pipeline #34469 waiting for manual action
Showing with 30 additions and 35 deletions
...@@ -5,7 +5,7 @@ services: ...@@ -5,7 +5,7 @@ services:
container_name: duniter-v2s-gecko-tests container_name: duniter-v2s-gecko-tests
# image: duniter/duniter-v2s:debug-sha-4d5e08be # image: duniter/duniter-v2s:debug-sha-4d5e08be
image: duniter/duniter-v2s:debug-sha-44b09061 image: duniter/duniter-v2s:debug-sha-44b09061
command: --alice --sealing=manual command: --alice --sealing=manual --force-authoring --reserved-only --no-mdns
ports: ports:
- "127.0.0.1:9615:9615" - "127.0.0.1:9615:9615"
- "127.0.0.1:9933:9933" - "127.0.0.1:9933:9933"
......
...@@ -54,8 +54,9 @@ Future payTest2() async { ...@@ -54,8 +54,9 @@ Future payTest2() async {
spawnBlock(duration: 500); spawnBlock(duration: 500);
await tester.pump(const Duration(seconds: 2)); await tester.pump(const Duration(seconds: 2));
await waitFor('sending'.tr(), await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20)); reverse: true, timeout: const Duration(seconds: 20));
await waitFor('extrinsicValidated'.tr(args: ['transaction'.tr()]),
timeout: const Duration(seconds: 12));
await tapKey(keyCloseTransactionScreen, duration: 0); await tapKey(keyCloseTransactionScreen, duration: 0);
await waitFor('12.14'); await waitFor('12.14');
spawnBlock(duration: 500); spawnBlock(duration: 500);
...@@ -71,7 +72,9 @@ Future certifyTest5() async { ...@@ -71,7 +72,9 @@ Future certifyTest5() async {
spawnBlock(duration: 1000); spawnBlock(duration: 1000);
await pump(number: 3); await pump(number: 3);
await waitFor('sending'.tr(), await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20)); reverse: true, timeout: const Duration(seconds: 20));
await waitFor('extrinsicValidated'.tr(args: ['certification'.tr()]),
timeout: const Duration(seconds: 6));
await tapKey(keyCloseTransactionScreen); await tapKey(keyCloseTransactionScreen);
await waitFor('identityCreated'.tr()); await waitFor('identityCreated'.tr());
...@@ -86,7 +89,7 @@ Future certifyTest5() async { ...@@ -86,7 +89,7 @@ Future certifyTest5() async {
spawnBlock(duration: 1000); spawnBlock(duration: 1000);
await pump(number: 3); await pump(number: 3);
await waitFor('sending'.tr(), await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20)); reverse: true, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen); await tapKey(keyCloseTransactionScreen);
await waitFor('identityConfirmed'.tr()); await waitFor('identityConfirmed'.tr());
humanRead(2); humanRead(2);
......
...@@ -52,7 +52,7 @@ class SubstrateSdk with ChangeNotifier { ...@@ -52,7 +52,7 @@ class SubstrateSdk with ChangeNotifier {
///////////////////////////////////// /////////////////////////////////////
////////// 1: API METHODS /////////// ////////// 1: API METHODS ///////////
///////////////////////////////////// /////////////////////////////////////3
Future<String> _executeCall(TxInfoData txInfo, txOptions, String password, Future<String> _executeCall(TxInfoData txInfo, txOptions, String password,
[String? rawParams]) async { [String? rawParams]) async {
...@@ -71,10 +71,10 @@ class SubstrateSdk with ChangeNotifier { ...@@ -71,10 +71,10 @@ class SubstrateSdk with ChangeNotifier {
); );
log.d(hash); log.d(hash);
if (hash.isEmpty) { if (hash.isEmpty) {
transactionStatus = 'timeout'; transactionStatus = 'Exception: timeout';
notifyListeners(); notifyListeners();
return 'timeout'; return 'Exception: timeout';
} else { } else {
// Success ! // Success !
transactionStatus = hash.toString(); transactionStatus = hash.toString();
......
...@@ -161,7 +161,6 @@ class WalletOptionsProvider with ChangeNotifier { ...@@ -161,7 +161,6 @@ class WalletOptionsProvider with ChangeNotifier {
!await isIdtyExist(idtyName.text) && !await isIdtyExist(idtyName.text) &&
idtyName.text.length >= 2 && idtyName.text.length >= 2 &&
idtyName.text.length <= 32; idtyName.text.length <= 32;
log.d('aaaaaaaaaa: $canValidate');
notifyListeners(); notifyListeners();
}, },
......
...@@ -45,7 +45,7 @@ class WalletsProfilesProvider with ChangeNotifier { ...@@ -45,7 +45,7 @@ class WalletsProfilesProvider with ChangeNotifier {
MaterialPageRoute(builder: (context) { MaterialPageRoute(builder: (context) {
return WalletViewScreen( return WalletViewScreen(
address: barcode!.rawContent, address: barcode!.rawContent,
username: '', username: null,
); );
}), }),
); );
......
...@@ -172,7 +172,7 @@ class _SearchScreenState extends State<SearchScreen> { ...@@ -172,7 +172,7 @@ class _SearchScreenState extends State<SearchScreen> {
context, context,
MaterialPageRoute(builder: (context) { MaterialPageRoute(builder: (context) {
return WalletViewScreen( return WalletViewScreen(
address: pastedAddress, username: ''); address: pastedAddress, username: null);
}), }),
); );
} }
......
...@@ -36,6 +36,7 @@ class TransactionInProgress extends StatelessWidget { ...@@ -36,6 +36,7 @@ class TransactionInProgress extends StatelessWidget {
.get(myWalletProvider.getDefaultWallet().address) .get(myWalletProvider.getDefaultWallet().address)
?.username ?? ?.username ??
myWalletProvider.getDefaultWallet().name!; myWalletProvider.getDefaultWallet().name!;
String to = toAddress ?? walletProfiles.address; String to = toAddress ?? walletProfiles.address;
to = to =
myWalletProvider.getWalletDataByAddress(to)?.name ?? getShortPubkey(to); myWalletProvider.getWalletDataByAddress(to)?.name ?? getShortPubkey(to);
...@@ -64,7 +65,7 @@ class TransactionInProgress extends StatelessWidget { ...@@ -64,7 +65,7 @@ class TransactionInProgress extends StatelessWidget {
'1010: Invalid Transaction: Inability to pay some fees , e.g. account balance too low': '1010: Invalid Transaction: Inability to pay some fees , e.g. account balance too low':
'youHaveToFeedThisAccountBeforeUsing'.tr(), 'youHaveToFeedThisAccountBeforeUsing'.tr(),
'Token.FundsUnavailable': 'fundsUnavailable'.tr(), 'Token.FundsUnavailable': 'fundsUnavailable'.tr(),
'timeout': 'execTimeoutOver'.tr(), 'Exception: timeout': 'execTimeoutOver'.tr(),
}; };
if (result.contains('blockHash: ')) { if (result.contains('blockHash: ')) {
...@@ -73,17 +74,10 @@ class TransactionInProgress extends StatelessWidget { ...@@ -73,17 +74,10 @@ class TransactionInProgress extends StatelessWidget {
.tr(args: [actionMap[transType] ?? 'strangeTransaction'.tr()]); .tr(args: [actionMap[transType] ?? 'strangeTransaction'.tr()]);
log.i('Bloc of last transaction: ${sub.blocNumber} --- $result'); log.i('Bloc of last transaction: ${sub.blocNumber} --- $result');
} else if (result.contains('Exception: ')) { } else if (result.contains('Exception: ')) {
isValid = false;
resultText = "${"anErrorOccurred".tr()}:\n"; resultText = "${"anErrorOccurred".tr()}:\n";
final List exceptionSplit = result.split('Exception: '); final String exception = result.split('Exception: ')[1];
String exception;
if (exceptionSplit.length > 1) {
exception = exceptionSplit[1];
} else {
exception = exceptionSplit[0];
}
resultText = resultMap[exception] ?? "$resultText\n$exception"; resultText = resultMap[exception] ?? "$resultText\n$exception";
log.d('expection: $exceptionSplit'); log.d('Error: $exception');
} else { } else {
isLoading = true; isLoading = true;
resultText = resultMap[result] ?? 'unknown status...'; resultText = resultMap[result] ?? 'unknown status...';
......
...@@ -29,7 +29,7 @@ class WalletViewScreen extends StatelessWidget { ...@@ -29,7 +29,7 @@ class WalletViewScreen extends StatelessWidget {
{required this.address, required this.username, this.avatar, Key? key}) {required this.address, required this.username, this.avatar, Key? key})
: super(key: key); : super(key: key);
final String address; final String address;
final String username; final String? username;
final Image? avatar; final Image? avatar;
final double buttonSize = 100; final double buttonSize = 100;
final double buttonFontSize = 18; final double buttonFontSize = 18;
......
...@@ -88,9 +88,8 @@ class ContactsList extends StatelessWidget { ...@@ -88,9 +88,8 @@ class ContactsList extends StatelessWidget {
walletsProfilesClass.address = g1Wallet.address; walletsProfilesClass.address = g1Wallet.address;
return WalletViewScreen( return WalletViewScreen(
address: g1Wallet.address, address: g1Wallet.address,
username: duniterIndexer.walletNameIndexer[ username: duniterIndexer
g1Wallet.address] ?? .walletNameIndexer[g1Wallet.address],
'',
avatar: g1WalletsBox avatar: g1WalletsBox
.get(g1Wallet.address) .get(g1Wallet.address)
?.avatar, ?.avatar,
......
...@@ -112,7 +112,7 @@ class HistoryView extends StatelessWidget { ...@@ -112,7 +112,7 @@ class HistoryView extends StatelessWidget {
PageNoTransit(builder: (context) { PageNoTransit(builder: (context) {
return WalletViewScreen( return WalletViewScreen(
address: sub.oldOwnerKeys[address]![0], address: sub.oldOwnerKeys[address]![0],
username: '', username: null,
); );
}), }),
), ),
......
...@@ -17,7 +17,7 @@ import 'package:gecko/widgets/name_by_address.dart'; ...@@ -17,7 +17,7 @@ import 'package:gecko/widgets/name_by_address.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
void paymentPopup(BuildContext context, String toAddress, String username) { void paymentPopup(BuildContext context, String toAddress, String? username) {
final walletViewProvider = final walletViewProvider =
Provider.of<WalletsProfilesProvider>(context, listen: false); Provider.of<WalletsProfilesProvider>(context, listen: false);
final myWalletProvider = final myWalletProvider =
...@@ -229,9 +229,7 @@ void paymentPopup(BuildContext context, String toAddress, String username) { ...@@ -229,9 +229,7 @@ void paymentPopup(BuildContext context, String toAddress, String username) {
children: [ children: [
const SizedBox(height: 2), const SizedBox(height: 2),
Text( Text(
username == '' username ?? getShortPubkey(toAddress),
? getShortPubkey(toAddress)
: username,
style: const TextStyle( style: const TextStyle(
fontSize: 21, fontSize: 21,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
......
...@@ -124,7 +124,7 @@ class SearchIdentityQuery extends StatelessWidget { ...@@ -124,7 +124,7 @@ class SearchIdentityQuery extends StatelessWidget {
walletsProfiles.address = profile['pubkey']; walletsProfiles.address = profile['pubkey'];
return WalletViewScreen( return WalletViewScreen(
address: profile['pubkey'], address: profile['pubkey'],
username: profile['name'] ?? '', username: profile['name'],
avatar: avatar:
g1WalletsBox.get(profile['pubkey'])?.avatar, g1WalletsBox.get(profile['pubkey'])?.avatar,
); );
......
...@@ -100,7 +100,7 @@ class SearchResult extends StatelessWidget { ...@@ -100,7 +100,7 @@ class SearchResult extends StatelessWidget {
walletsProfilesClass.address = g1Wallet.address; walletsProfilesClass.address = g1Wallet.address;
return WalletViewScreen( return WalletViewScreen(
address: g1Wallet.address, address: g1Wallet.address,
username: g1Wallet.username ?? '', username: g1Wallet.username,
avatar: g1Wallet.avatar, avatar: g1Wallet.avatar,
); );
}), }),
......
...@@ -29,6 +29,8 @@ class TransactionTile extends StatelessWidget { ...@@ -29,6 +29,8 @@ class TransactionTile extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final newKey = keyID + 1; final newKey = keyID + 1;
final String? username = repository[2] == '' ? null : repository[2];
return Padding( return Padding(
padding: const EdgeInsets.only(right: 0), padding: const EdgeInsets.only(right: 0),
child: ListTile( child: ListTile(
...@@ -53,7 +55,7 @@ class TransactionTile extends StatelessWidget { ...@@ -53,7 +55,7 @@ class TransactionTile extends StatelessWidget {
TextSpan( TextSpan(
text: dateForm, text: dateForm,
), ),
if (repository[2] != '') if (username != null)
TextSpan( TextSpan(
text: ' · ', text: ' · ',
style: TextStyle( style: TextStyle(
...@@ -62,7 +64,7 @@ class TransactionTile extends StatelessWidget { ...@@ -62,7 +64,7 @@ class TransactionTile extends StatelessWidget {
), ),
), ),
TextSpan( TextSpan(
text: repository[2], text: username,
style: TextStyle( style: TextStyle(
fontStyle: FontStyle.italic, fontStyle: FontStyle.italic,
color: Colors.grey[600], color: Colors.grey[600],
...@@ -87,7 +89,7 @@ class TransactionTile extends StatelessWidget { ...@@ -87,7 +89,7 @@ class TransactionTile extends StatelessWidget {
PageNoTransit(builder: (context) { PageNoTransit(builder: (context) {
return WalletViewScreen( return WalletViewScreen(
address: repository[1], address: repository[1],
username: repository[2] ?? '', username: username,
); );
}), }),
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment