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
# image: duniter/duniter-v2s:debug-sha-4d5e08be
image: duniter/duniter-v2s:debug-sha-44b09061
command: --alice --sealing=manual
command: --alice --sealing=manual --force-authoring --reserved-only --no-mdns
ports:
- "127.0.0.1:9615:9615"
- "127.0.0.1:9933:9933"

View File

@ -54,8 +54,9 @@ Future payTest2() async {
spawnBlock(duration: 500);
await tester.pump(const Duration(seconds: 2));
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 waitFor('12.14');
spawnBlock(duration: 500);
@ -71,7 +72,9 @@ Future certifyTest5() async {
spawnBlock(duration: 1000);
await pump(number: 3);
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 waitFor('identityCreated'.tr());
@ -86,7 +89,7 @@ Future certifyTest5() async {
spawnBlock(duration: 1000);
await pump(number: 3);
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
reverse: true, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen);
await waitFor('identityConfirmed'.tr());
humanRead(2);

View File

@ -52,7 +52,7 @@ class SubstrateSdk with ChangeNotifier {
/////////////////////////////////////
////////// 1: API METHODS ///////////
/////////////////////////////////////
/////////////////////////////////////3
Future<String> _executeCall(TxInfoData txInfo, txOptions, String password,
[String? rawParams]) async {
@ -71,10 +71,10 @@ class SubstrateSdk with ChangeNotifier {
);
log.d(hash);
if (hash.isEmpty) {
transactionStatus = 'timeout';
transactionStatus = 'Exception: timeout';
notifyListeners();
return 'timeout';
return 'Exception: timeout';
} else {
// Success !
transactionStatus = hash.toString();

View File

@ -161,7 +161,6 @@ class WalletOptionsProvider with ChangeNotifier {
!await isIdtyExist(idtyName.text) &&
idtyName.text.length >= 2 &&
idtyName.text.length <= 32;
log.d('aaaaaaaaaa: $canValidate');
notifyListeners();
},

View File

@ -45,7 +45,7 @@ class WalletsProfilesProvider with ChangeNotifier {
MaterialPageRoute(builder: (context) {
return WalletViewScreen(
address: barcode!.rawContent,
username: '',
username: null,
);
}),
);

View File

@ -172,7 +172,7 @@ class _SearchScreenState extends State<SearchScreen> {
context,
MaterialPageRoute(builder: (context) {
return WalletViewScreen(
address: pastedAddress, username: '');
address: pastedAddress, username: null);
}),
);
}

View File

@ -36,6 +36,7 @@ class TransactionInProgress extends StatelessWidget {
.get(myWalletProvider.getDefaultWallet().address)
?.username ??
myWalletProvider.getDefaultWallet().name!;
String to = toAddress ?? walletProfiles.address;
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':
'youHaveToFeedThisAccountBeforeUsing'.tr(),
'Token.FundsUnavailable': 'fundsUnavailable'.tr(),
'timeout': 'execTimeoutOver'.tr(),
'Exception: timeout': 'execTimeoutOver'.tr(),
};
if (result.contains('blockHash: ')) {
@ -73,17 +74,10 @@ class TransactionInProgress extends StatelessWidget {
.tr(args: [actionMap[transType] ?? 'strangeTransaction'.tr()]);
log.i('Bloc of last transaction: ${sub.blocNumber} --- $result');
} else if (result.contains('Exception: ')) {
isValid = false;
resultText = "${"anErrorOccurred".tr()}:\n";
final List exceptionSplit = result.split('Exception: ');
String exception;
if (exceptionSplit.length > 1) {
exception = exceptionSplit[1];
} else {
exception = exceptionSplit[0];
}
final String exception = result.split('Exception: ')[1];
resultText = resultMap[exception] ?? "$resultText\n$exception";
log.d('expection: $exceptionSplit');
log.d('Error: $exception');
} else {
isLoading = true;
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})
: super(key: key);
final String address;
final String username;
final String? username;
final Image? avatar;
final double buttonSize = 100;
final double buttonFontSize = 18;

View File

@ -88,9 +88,8 @@ class ContactsList extends StatelessWidget {
walletsProfilesClass.address = g1Wallet.address;
return WalletViewScreen(
address: g1Wallet.address,
username: duniterIndexer.walletNameIndexer[
g1Wallet.address] ??
'',
username: duniterIndexer
.walletNameIndexer[g1Wallet.address],
avatar: g1WalletsBox
.get(g1Wallet.address)
?.avatar,

View File

@ -112,7 +112,7 @@ class HistoryView extends StatelessWidget {
PageNoTransit(builder: (context) {
return WalletViewScreen(
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:url_launcher/url_launcher.dart';
void paymentPopup(BuildContext context, String toAddress, String username) {
void paymentPopup(BuildContext context, String toAddress, String? username) {
final walletViewProvider =
Provider.of<WalletsProfilesProvider>(context, listen: false);
final myWalletProvider =
@ -229,9 +229,7 @@ void paymentPopup(BuildContext context, String toAddress, String username) {
children: [
const SizedBox(height: 2),
Text(
username == ''
? getShortPubkey(toAddress)
: username,
username ?? getShortPubkey(toAddress),
style: const TextStyle(
fontSize: 21,
fontWeight: FontWeight.w600,

View File

@ -124,7 +124,7 @@ class SearchIdentityQuery extends StatelessWidget {
walletsProfiles.address = profile['pubkey'];
return WalletViewScreen(
address: profile['pubkey'],
username: profile['name'] ?? '',
username: profile['name'],
avatar:
g1WalletsBox.get(profile['pubkey'])?.avatar,
);

View File

@ -100,7 +100,7 @@ class SearchResult extends StatelessWidget {
walletsProfilesClass.address = g1Wallet.address;
return WalletViewScreen(
address: g1Wallet.address,
username: g1Wallet.username ?? '',
username: g1Wallet.username,
avatar: g1Wallet.avatar,
);
}),

View File

@ -29,6 +29,8 @@ class TransactionTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
final newKey = keyID + 1;
final String? username = repository[2] == '' ? null : repository[2];
return Padding(
padding: const EdgeInsets.only(right: 0),
child: ListTile(
@ -53,7 +55,7 @@ class TransactionTile extends StatelessWidget {
TextSpan(
text: dateForm,
),
if (repository[2] != '')
if (username != null)
TextSpan(
text: ' · ',
style: TextStyle(
@ -62,7 +64,7 @@ class TransactionTile extends StatelessWidget {
),
),
TextSpan(
text: repository[2],
text: username,
style: TextStyle(
fontStyle: FontStyle.italic,
color: Colors.grey[600],
@ -87,7 +89,7 @@ class TransactionTile extends StatelessWidget {
PageNoTransit(builder: (context) {
return WalletViewScreen(
address: repository[1],
username: repository[2] ?? '',
username: username,
);
}),
);