Merge branch 'dev' into 'master'

Dev

See merge request clients/gecko!42
This commit is contained in:
pokapow 2022-12-03 00:22:00 +01:00
commit 5b89f661ed
17 changed files with 194 additions and 108 deletions

View File

@ -136,7 +136,7 @@ Future<void> waitFor(String text,
Finder finder = exactMatch ? find.text(text) : find.textContaining(text);
log.d('INTEGRATION TEST: Wait for: $text');
final String searchType = reverse ? 'reversed text' : 'text';
final searchType = reverse ? 'reversed text' : 'text';
do {
if (DateTime.now().isAfter(end)) {

View File

@ -79,3 +79,11 @@ query ($address: String!) {
}
}
''';
const String isIdtyExistQ = r'''
query ($name: String!) {
identity(where: {name: {_eq: $name}}) {
name
}
}
''';

View File

@ -4,7 +4,6 @@ import 'dart:io';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/g1_wallets_list.dart';
import 'package:gecko/models/queries_indexer.dart';
@ -368,8 +367,8 @@ class DuniterIndexer with ChangeNotifier {
transBC.add(i);
transBC[i] = [];
transBC[i].add(DateTime.parse(transaction['created_at']));
final int amountBrut = transaction['amount'];
final double amount = removeDecimalZero(amountBrut / 100);
final amountBrut = transaction['amount'];
final amount = removeDecimalZero(amountBrut / 100);
if (direction == "RECEIVED") {
transBC[i].add(transaction['issuer_pubkey']);
transBC[i].add(transaction['issuer']['identity']?['name'] ?? '');
@ -446,3 +445,25 @@ class DuniterIndexer with ChangeNotifier {
// checkHistoryResult(
// QueryResult<Object?> result, FetchMoreOptions options, String address) {}
}
Future<bool> isIdtyExist(String name) async {
final httpLink = HttpLink(
'$indexerEndpoint/v1/graphql',
);
final GraphQLClient client = GraphQLClient(
cache: GraphQLCache(),
link: httpLink,
);
final QueryOptions options = QueryOptions(
document: gql(isIdtyExistQ),
variables: <String, dynamic>{
'name': name,
},
);
final QueryResult result = await client.query(options);
return result.data!['identity']?.isEmpty ?? false ? false : true;
}

View File

@ -1,6 +1,7 @@
// ignore_for_file: use_build_context_synchronously
import 'package:easy_localization/easy_localization.dart';
import 'package:fast_base58/fast_base58.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
@ -10,6 +11,7 @@ import 'package:gecko/providers/home.dart';
import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/providers/wallet_options.dart';
import 'package:gecko/providers/wallets_profiles.dart';
import 'package:pinenacl/ed25519.dart';
import 'package:polkawallet_sdk/api/apiKeyring.dart';
import 'package:polkawallet_sdk/api/types/networkParams.dart';
import 'package:polkawallet_sdk/api/types/txInfoData.dart';
@ -39,6 +41,7 @@ class SubstrateSdk with ChangeNotifier {
TextEditingController csSalt = TextEditingController();
TextEditingController csPassword = TextEditingController();
String g1V1NewAddress = '';
String g1V1OldPubkey = '';
bool isCesiumIDVisible = false;
bool isCesiumAddresLoading = false;
late int udValue;
@ -679,6 +682,9 @@ class SubstrateSdk with ChangeNotifier {
cryptoType: CryptoType.ed25519,
rawSeed: rawSeedHex);
SigningKey rootKey = SigningKey(seed: rawSeed);
g1V1OldPubkey = Base58Encode(rootKey.publicKey);
g1V1NewAddress = newAddress.address!;
notifyListeners();
return g1V1NewAddress;

View File

@ -139,7 +139,7 @@ class WalletOptionsProvider with ChangeNotifier {
showText(String text,
[double size = 18, bool bold = false, bool smooth = true]) {
log.d('$address $text');
// log.d('$address $text');
return AnimatedFadeOutIn<String>(
data: text,
duration: Duration(milliseconds: smooth ? 200 : 0),
@ -224,6 +224,9 @@ class WalletOptionsProvider with ChangeNotifier {
final myWalletProvider =
Provider.of<MyWalletsProvider>(context, listen: false);
bool canValidate = false;
bool idtyExist = false;
return showDialog<String>(
context: context,
barrierDismissible: true, // user must tap button!
@ -240,7 +243,16 @@ class WalletOptionsProvider with ChangeNotifier {
const SizedBox(height: 20),
TextField(
key: keyEnterIdentityUsername,
onChanged: (_) => notifyListeners(),
onChanged: (_) async {
idtyExist = await isIdtyExist(idtyName.text);
canValidate = !idtyExist &&
!await isIdtyExist(idtyName.text) &&
idtyName.text.length >= 2 &&
idtyName.text.length <= 32;
log.d('aaaaaaaaaa: $canValidate');
notifyListeners();
},
inputFormatters: <TextInputFormatter>[
// FilteringTextInputFormatter.allow(RegExp("[0-9a-zA-Z]")),
FilteringTextInputFormatter.deny(RegExp(r'^ ')),
@ -250,7 +262,12 @@ class WalletOptionsProvider with ChangeNotifier {
autofocus: true,
controller: idtyName,
style: const TextStyle(fontSize: 19),
)
),
const SizedBox(height: 10),
Consumer<WalletOptionsProvider>(builder: (context, wOptions, _) {
return Text(idtyExist ? 'Cette identité existe déjà' : '',
style: TextStyle(color: Colors.red[500]));
})
]),
),
actions: <Widget>[
@ -261,61 +278,66 @@ class WalletOptionsProvider with ChangeNotifier {
builder: (context, wOptions, _) {
return TextButton(
key: keyConfirm,
onPressed: canValidate
? () async {
idtyName.text =
idtyName.text.trim().replaceAll(' ', '');
if (idtyName.text.length.clamp(3, 32) ==
idtyName.text.length) {
WalletData? defaultWallet =
myWalletProvider.getDefaultWallet();
String? pin;
if (myWalletProvider.pinCode == '') {
pin = await Navigator.push(
context,
MaterialPageRoute(
builder: (homeContext) {
return UnlockingWallet(
wallet: defaultWallet);
},
),
);
}
if (pin != null ||
myWalletProvider.pinCode != '') {
final wallet = myWalletProvider
.getWalletDataByAddress(address.text);
await sub.setCurrentWallet(wallet!);
sub.confirmIdentity(walletOptions.address.text,
idtyName.text, myWalletProvider.pinCode);
Navigator.pop(context);
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return TransactionInProgress(
transType: 'comfirmIdty',
fromAddress:
getShortPubkey(wallet.address!),
toAddress:
getShortPubkey(wallet.address!),
);
}),
);
}
}
}
: null,
child: Text(
"validate".tr(),
style: TextStyle(
fontSize: 21,
color: idtyName.text.length.clamp(3, 64) ==
idtyName.text.length
? const Color(0xffD80000)
: Colors.grey,
),
fontSize: 21,
color: canValidate
? const Color(0xffD80000)
: Colors.grey[500]),
),
onPressed: () async {
idtyName.text = idtyName.text.trim().replaceAll(' ', '');
if (idtyName.text.length.clamp(3, 64) ==
idtyName.text.length) {
WalletData? defaultWallet =
myWalletProvider.getDefaultWallet();
String? pin;
if (myWalletProvider.pinCode == '') {
pin = await Navigator.push(
context,
MaterialPageRoute(
builder: (homeContext) {
return UnlockingWallet(wallet: defaultWallet);
},
),
);
}
if (pin != null || myWalletProvider.pinCode != '') {
final wallet = myWalletProvider
.getWalletDataByAddress(address.text);
await sub.setCurrentWallet(wallet!);
sub.confirmIdentity(walletOptions.address.text,
idtyName.text, myWalletProvider.pinCode);
Navigator.pop(context);
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return TransactionInProgress(
transType: 'comfirmIdty',
fromAddress: getShortPubkey(wallet.address!),
toAddress: getShortPubkey(wallet.address!),
);
}),
);
}
}
},
);
})
],
),
const SizedBox(height: 20)
const SizedBox(height: 5)
],
);
},

View File

@ -160,7 +160,7 @@ class CommonElements {
}
Widget offlineInfo(BuildContext context) {
final double screenWidth = MediaQuery.of(homeContext).size.width;
final screenWidth = MediaQuery.of(homeContext).size.width;
return Consumer<SubstrateSdk>(builder: (context, sub, _) {
return Visibility(
visible: !sub.nodeConnected,

View File

@ -187,7 +187,7 @@ Widget geckHome(context) {
WalletsProfilesProvider historyProvider =
Provider.of<WalletsProfilesProvider>(context);
final double statusBarHeight = MediaQuery.of(context).padding.top;
final statusBarHeight = MediaQuery.of(context).padding.top;
return Container(
decoration: const BoxDecoration(
image: DecorationImage(
@ -433,7 +433,7 @@ Widget geckHome(context) {
}
Widget welcomeHome(context) {
final double statusBarHeight = MediaQuery.of(context).padding.top;
final statusBarHeight = MediaQuery.of(context).padding.top;
return Container(
decoration: const BoxDecoration(

View File

@ -95,7 +95,7 @@ class ChooseWalletScreen extends StatelessWidget {
}
List listWallets = myWalletProvider.listWallets;
final double screenWidth = MediaQuery.of(context).size.width;
final screenWidth = MediaQuery.of(context).size.width;
int nTule = 2;
if (screenWidth >= 900) {

View File

@ -185,13 +185,13 @@ class ImportG1v1 extends StatelessWidget {
key: keyCopyAddress,
onTap: () {
Clipboard.setData(
ClipboardData(text: sub.g1V1NewAddress));
ClipboardData(text: sub.g1V1OldPubkey));
snackCopyKey(context);
},
child: Text(
getShortPubkey(sub.g1V1NewAddress),
sub.g1V1OldPubkey,
style: const TextStyle(
fontSize: 20,
fontSize: 16,
fontWeight: FontWeight.w600,
),
),

View File

@ -45,7 +45,7 @@ class WalletOptions extends StatelessWidget {
log.d(walletOptions.address.text);
final int currentChest = myWalletProvider.getCurrentChest();
final currentChest = myWalletProvider.getCurrentChest();
// final currentWallet = _myWalletProvider.getDefaultWallet();
// log.d(_walletOptions.getAddress(_currentChest, 3));
@ -325,7 +325,7 @@ class WalletOptions extends StatelessWidget {
foregroundColor: Colors.white, elevation: 4,
backgroundColor: orangeC, // foreground
),
onPressed: () {
onPressed: () async {
walletProvider.confirmIdentityPopup(context);
// Navigator.push(
// context,
@ -360,7 +360,7 @@ class WalletOptions extends StatelessWidget {
}
Widget pubkeyWidget(WalletOptionsProvider walletProvider, BuildContext ctx) {
final String shortPubkey = getShortPubkey(walletProvider.address.text);
final shortPubkey = getShortPubkey(walletProvider.address.text);
return GestureDetector(
key: keyCopyAddress,
onTap: () {

View File

@ -23,6 +23,7 @@ import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
import 'package:gecko/screens/myWallets/wallet_options.dart';
import 'package:gecko/screens/wallet_view.dart';
import 'package:provider/provider.dart';
import 'package:flutter_svg/flutter_svg.dart';
class WalletsHome extends StatelessWidget {
const WalletsHome({Key? key}) : super(key: key);
@ -33,7 +34,7 @@ class WalletsHome extends StatelessWidget {
HomeProvider homeProvider =
Provider.of<HomeProvider>(context, listen: false);
final int currentChestNumber = myWalletProvider.getCurrentChest();
final currentChestNumber = myWalletProvider.getCurrentChest();
final ChestData currentChest = chestBox.get(currentChestNumber)!;
myWalletProvider.listWallets =
myWalletProvider.readAllWallets(currentChestNumber);
@ -88,7 +89,7 @@ class WalletsHome extends StatelessWidget {
final bool isSameAddress =
myWalletProvider.dragAddress == myWalletProvider.lastFlyBy;
final double screenWidth = MediaQuery.of(homeContext).size.width;
final screenWidth = MediaQuery.of(homeContext).size.width;
return Container(
color: yellowC,
width: screenWidth,
@ -138,28 +139,39 @@ class WalletsHome extends StatelessWidget {
),
)),
const SizedBox(height: 30),
InkWell(
key: keyImportG1v1,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return const ImportG1v1();
}),
);
},
child: SizedBox(
width: 400,
height: 60,
child: Center(
child: Text('importG1v1'.tr(),
style: TextStyle(
fontSize: 22,
color: Colors.blue[900],
fontWeight: FontWeight.w500))),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
'assets/cesium_bw2.svg',
semanticsLabel: 'CS',
height: 50,
),
const SizedBox(width: 5),
InkWell(
key: keyImportG1v1,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return const ImportG1v1();
}),
);
},
child: SizedBox(
width: 350,
height: 60,
child: Center(
child: Text('importG1v1'.tr(),
style: TextStyle(
fontSize: 22,
color: Colors.blue[900],
fontWeight: FontWeight.w500))),
),
),
],
),
const SizedBox(height: 5),
const SizedBox(height: 20),
InkWell(
key: keyChangeChest,
onTap: () {
@ -209,7 +221,7 @@ class WalletsHome extends StatelessWidget {
List listWallets = myWalletProvider.listWallets;
WalletData? defaultWallet = myWalletProvider.getDefaultWallet();
final double screenWidth = MediaQuery.of(context).size.width;
final screenWidth = MediaQuery.of(context).size.width;
int nTule = 2;
if (screenWidth >= 900) {

View File

@ -33,7 +33,7 @@ class OnboardingStepTen extends StatelessWidget {
Provider.of<GenerateWalletsProvider>(context);
final walletOptions = Provider.of<WalletOptionsProvider>(context);
CommonElements common = CommonElements();
final int pinLenght = generateWalletProvider.pin.text.length;
final pinLenght = generateWalletProvider.pin.text.length;
return Scaffold(
backgroundColor: backgroundColor,
@ -142,7 +142,7 @@ class OnboardingStepTen extends StatelessWidget {
Provider.of<GenerateWalletsProvider>(context);
final sub = Provider.of<SubstrateSdk>(context, listen: false);
final int currentChest = myWalletProvider.getCurrentChest();
final currentChest = myWalletProvider.getCurrentChest();
return Form(
key: formKey,

View File

@ -69,13 +69,13 @@ Widget finishButton(BuildContext context) {
// Navigator.pushNamed(homeContext, '/mywallets');
final tmpConext = homeContext;
Navigator.pushNamedAndRemoveUntil(
context, '/mywallets', (route) => route.isFirst)
.then((value) => homeContext = tmpConext);
// final tmpConext = homeContext;
// Navigator.pushNamedAndRemoveUntil(
// homeContext, '/mywallets', ModalRoute.withName('/'));
// context, '/mywallets', (route) => route.isFirst);
// .then((value) => homeContext = tmpConext);
Navigator.pushNamedAndRemoveUntil(
homeContext, '/mywallets', ModalRoute.withName('/'));
},
child: Text("accessMyChest".tr(),
style:

View File

@ -17,7 +17,7 @@ class SearchScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final searchProvider = Provider.of<SearchProvider>(context);
final double screenHeight = MediaQuery.of(context).size.height;
final screenHeight = MediaQuery.of(context).size.height;
// final _homeProvider =
// Provider.of<HomeProvider>(context, listen: false);

View File

@ -161,8 +161,8 @@ class WalletViewScreen extends StatelessWidget {
final Duration durationSeconds = Duration(
seconds: snapshot.data!['certDelay'] ??
snapshot.data!['certRenewable']!);
final int seconds = durationSeconds.inSeconds;
final int minutes = durationSeconds.inMinutes;
final seconds = durationSeconds.inSeconds;
final minutes = durationSeconds.inMinutes;
if (seconds <= 0) {
duration = 'seconds'.tr(args: ['0']);
@ -171,8 +171,8 @@ class WalletViewScreen extends StatelessWidget {
} else if (seconds <= 3600) {
duration = 'minutes'.tr(args: [minutes.toString()]);
} else if (seconds <= 86400) {
final int hours = durationSeconds.inHours;
final int minutesLeft = minutes - hours * 60;
final hours = durationSeconds.inHours;
final minutesLeft = minutes - hours * 60;
String showMinutes = '';
if (minutesLeft < 60) {}
showMinutes =
@ -180,11 +180,10 @@ class WalletViewScreen extends StatelessWidget {
duration =
'hours'.tr(args: [hours.toString(), showMinutes]);
} else if (seconds <= 2592000) {
final int days = durationSeconds.inDays;
final days = durationSeconds.inDays;
duration = 'days'.tr(args: [days.toString()]);
} else {
final int months =
(durationSeconds.inDays / 30).round();
final months = (durationSeconds.inDays / 30).round();
duration = 'months'.tr(args: [months.toString()]);
}
}

View File

@ -338,7 +338,7 @@ packages:
source: hosted
version: "1.3.1"
fast_base58:
dependency: transitive
dependency: "direct main"
description:
name: fast_base58
url: "https://pub.dartlang.org"
@ -429,6 +429,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.7"
flutter_svg:
dependency: "direct main"
description:
name: flutter_svg
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
flutter_test:
dependency: "direct dev"
description: flutter
@ -522,7 +529,7 @@ packages:
source: hosted
version: "0.2.2+1"
graphql:
dependency: transitive
dependency: "direct main"
description:
name: graphql
url: "https://pub.dartlang.org"
@ -841,6 +848,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
path_drawing:
dependency: transitive
description:
name: path_drawing
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
path_parsing:
dependency: transitive
description:
@ -961,7 +975,7 @@ packages:
source: hosted
version: "7.4.0"
pinenacl:
dependency: transitive
dependency: "direct main"
description:
name: pinenacl
url: "https://pub.dartlang.org"

View File

@ -18,7 +18,7 @@ dependencies:
bubble: ^1.2.1
carousel_slider: ^4.0.0
flutter_lints: ^2.0.1
graphql_flutter: ^5.1.1-beta.3
graphql_flutter: ^5.1.1-beta.4
hive_flutter: ^1.1.0
image_picker: ^0.8.4
jdenticon_dart: ^2.0.0
@ -58,6 +58,10 @@ dependencies:
hex: ^0.2.0
flutter_dotenv: ^5.0.2
accordion: ^2.5.1
flutter_svg: ^1.1.6
pinenacl: ^0.3.3
fast_base58: ^0.2.1
graphql: ^5.1.1
dev_dependencies:
# flutter_launcher_icons: ^0.9.2