refacto: username is nullable

This commit is contained in:
poka 2023-11-26 21:07:17 +01:00
parent 9f0144803f
commit d9c30d337a
14 changed files with 30 additions and 35 deletions

View File

@ -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"

View File

@ -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 {
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 {
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);

View File

@ -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 {
); );
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();

View File

@ -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();
}, },

View File

@ -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,
); );
}), }),
); );

View File

@ -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);
}), }),
); );
} }

View File

@ -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 {
'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 {
.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...';

View File

@ -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;

View File

@ -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,

View File

@ -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,
); );
}), }),
), ),

View File

@ -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) {
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,

View File

@ -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,
); );

View File

@ -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,
); );
}), }),

View File

@ -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 {
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 {
), ),
), ),
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 {
PageNoTransit(builder: (context) { PageNoTransit(builder: (context) {
return WalletViewScreen( return WalletViewScreen(
address: repository[1], address: repository[1],
username: repository[2] ?? '', username: username,
); );
}), }),
); );