Merge branch 'dev'

This commit is contained in:
poka 2023-11-26 21:38:07 +01:00
commit a1d8627443
61 changed files with 1924 additions and 1903 deletions

View File

@ -225,5 +225,7 @@
"feesExplanation": "To ensure network security, an execution fee is charged on each transaction.",
"feesExplanationDetails": "These fees are transferred to the common treasury account.",
"gotit": "Got it",
"moreInfo": "More information"
"moreInfo": "More information",
"keepThisPaperSafe": "Keep this sheet safe from prying lizards.\nIt will allow you to restore all your wallets at any time.",
"fundsUnavailable": "Insufficient funds"
}

View File

@ -226,5 +226,7 @@
"feesExplanation": "To ensure network security, an execution fee is charged on each transaction.",
"feesExplanationDetails": "These fees are transferred to the common treasury account.",
"gotit": "Got it",
"moreInfo": "More information"
"moreInfo": "More information",
"keepThisPaperSafe": "Keep this sheet safe from prying lizards.\nIt will allow you to restore all your wallets at any time.",
"fundsUnavailable": "Insufficient funds"
}

View File

@ -225,5 +225,7 @@
"feesExplanation": "Pour garantir la sécurité du réseau, des frais d'exécution sont prélevés sur chaque transaction.",
"feesExplanationDetails": "Ces frais sont transférés vers le compte de trésorerie commune.",
"gotit": "J'ai compris",
"moreInfo": "Plus d'info"
"moreInfo": "Plus d'info",
"keepThisPaperSafe": "Gardez cette feuille précieusement, à labri des lézards indiscrets.\nElle vous permettra de restaurer tous vos portefeuilles à tout moment.",
"fundsUnavailable": "Fonds insuffisants"
}

View File

@ -0,0 +1,38 @@
{
"ud": 1000,
"first_ud": 6000,
"first_ud_reeval": 600000,
"parameters": {
"babe_epoch_duration": 30,
"cert_period": 15,
"cert_max_by_issuer": 10,
"cert_min_received_cert_to_issue_cert": 2,
"cert_validity_period": 1000,
"idty_confirm_period": 40,
"idty_creation_period": 50,
"membership_period": 1000,
"pending_membership_period": 500,
"ud_creation_period": 10,
"ud_reeval_period": 50,
"smith_cert_period": 15,
"smith_cert_max_by_issuer": 8,
"smith_cert_min_received_cert_to_issue_cert": 2,
"smith_cert_validity_period": 1000,
"smith_membership_period": 1000,
"smith_pending_membership_period": 500,
"smith_wot_first_cert_issuable_on": 4,
"smith_wot_min_cert_for_membership": 3,
"wot_first_cert_issuable_on": 0,
"wot_min_cert_for_create_idty_right": 3,
"wot_min_cert_for_membership": 3
},
"clique_smiths": [
{ "name": "test1" },
{ "name": "test2" },
{ "name": "test3" },
{ "name": "test4" }
],
"sudo_key": "5FeggKqw2AbnGZF9Y9WPM2QTgzENS3Hit94Ewgmzdg5a3LNa",
"treasury_funder_address": "5FeggKqw2AbnGZF9Y9WPM2QTgzENS3Hit94Ewgmzdg5a3LNa",
"technical_committee": ["test1", "test2", "test3"]
}

View File

@ -0,0 +1,65 @@
{
"initial_monetary_mass": 50100,
"identities": {
"test1": {
"index": 0,
"balance": 10000,
"membership_expire_on": 1705509948,
"next_cert_issuable_on": 1668347505,
"certs_received": {
"test2": 1727758466,
"test3": 1727758466,
"test4": 1727758466
},
"owner_pubkey": "BgC76sdA6zxPSAMW6sZ1e3NEntLrkLT8DY3z2MEmJJgK"
},
"test2": {
"index": 1,
"balance": 10000,
"membership_expire_on": 1705509948,
"next_cert_issuable_on": 1668347505,
"certs_received": {
"test1": 1727758466,
"test3": 1727758466,
"test4": 1727758466
},
"owner_pubkey": "6xNFhRFHKyx9iZ3ucc3AFf5cjsWw5jH3p6EnFXw3D8T6"
},
"test3": {
"index": 2,
"balance": 10000,
"membership_expire_on": 1705509948,
"next_cert_issuable_on": 1668347505,
"certs_received": {
"test1": 1727758466,
"test2": 1727758466,
"test4": 1727758466
},
"owner_pubkey": "BpSSPEVE1yze9wrfjkU4wfnFa7WgKNysHxe3H9iT9fvx"
},
"test4": {
"index": 3,
"balance": 10000,
"membership_expire_on": 1705509948,
"next_cert_issuable_on": 1668347505,
"certs_received": {
"test1": 1727758466,
"test2": 1727758466,
"test3": 1727758466
},
"owner_pubkey": "5LqbvutJtRTHvnforyndwPbkC4Kf5cJtdRQaDcHoMi8S"
},
"testCesium1": {
"index": 4,
"balance": 10000,
"membership_expire_on": 1705509948,
"next_cert_issuable_on": 1668347505,
"certs_received": {
"test1": 1727758466,
"test2": 1727758466,
"test3": 1727758466
},
"owner_pubkey": "DCovzCEnQm9GUWe6mr8u42JR1JAuoj3HbQUGdCkfTzSr"
}
}
}

View File

@ -1,79 +0,0 @@
{
"first_ud": 10000,
"first_ud_reeval": 50,
"genesis_parameters": {
"genesis_certs_expire_on": 10,
"genesis_certs_min_received": 3,
"genesis_memberships_expire_on": 1051200,
"genesis_smith_certs_expire_on": 2102400,
"genesis_smith_certs_min_received": 3,
"genesis_smith_memberships_expire_on": 1051200
},
"identities": {
"test1": {
"balance": 10000,
"certs": ["test2", "test3", "test4"],
"pubkey": "5FeggKqw2AbnGZF9Y9WPM2QTgzENS3Hit94Ewgmzdg5a3LNa"
},
"test2": {
"balance": 10000,
"certs": ["test1", "test3", "test4"],
"pubkey": "5E4i8vcNjnrDp21Sbnp32WHm2gz8YP3GGFwmdpfg5bHd8Whb"
},
"test3": {
"balance": 10000,
"certs": ["test1", "test2", "test4"],
"pubkey": "5FhTLzXLNBPmtXtDBFECmD7fvKmTtTQDtvBTfVr97tachA1p"
},
"test4": {
"balance": 10000,
"certs": ["test1", "test2", "test3"],
"pubkey": "5DXJ4CusmCg8S1yF6JGVn4fxgk5oFx42WctXqHZ17mykgje5"
},
"testCesium1": {
"balance": 10000,
"certs": ["test1", "test2", "test3"],
"pubkey": "5GAT6CJW8yVKwUuQc7sM5Kk9GZVTpbZYk9PfjNXtvnNgAJZ1"
}
},
"parameters": {
"babe_epoch_duration": 30,
"cert_period": 15,
"cert_max_by_issuer": 10,
"cert_min_received_cert_to_issue_cert": 2,
"cert_validity_period": 1000,
"idty_confirm_period": 40,
"idty_creation_period": 50,
"membership_period": 1000,
"pending_membership_period": 500,
"ud_creation_period": 10,
"ud_reeval_period": 50,
"smith_cert_period": 15,
"smith_cert_max_by_issuer": 8,
"smith_cert_min_received_cert_to_issue_cert": 2,
"smith_cert_validity_period": 1000,
"smith_membership_period": 1000,
"smith_pending_membership_period": 500,
"smiths_wot_first_cert_issuable_on": 4,
"smiths_wot_min_cert_for_membership": 3,
"wot_first_cert_issuable_on": 0,
"wot_min_cert_for_create_idty_right": 3,
"wot_min_cert_for_membership": 3
},
"smiths": {
"test1": {
"certs": ["test2", "test3", "test4"]
},
"test2": {
"certs": ["test1", "test3", "test4"]
},
"test3": {
"certs": ["test1", "test2", "test4"]
},
"test4": {
"certs": ["test1", "test2", "test3"]
}
},
"sudo_key": "5FeggKqw2AbnGZF9Y9WPM2QTgzENS3Hit94Ewgmzdg5a3LNa",
"technical_committee": ["test1", "test2", "test3"]
}

View File

@ -3,8 +3,10 @@ version: "3.5"
services:
duniter-v2s-gecko-tests:
container_name: duniter-v2s-gecko-tests
image: duniter/duniter-v2s:debug-sha-4d5e08be
command: --sealing=manual
# image: duniter/duniter-v2s:debug-sha-4d5e08be
image: duniter/duniter-v2s:debug-sha-44b09061
command: --alice --force-authoring --reserved-only --no-mdns
#--sealing=manual
ports:
- "127.0.0.1:9615:9615"
- "127.0.0.1:9933:9933"
@ -12,7 +14,8 @@ services:
- "30333:30333"
environment:
DUNITER_INSTANCE_NAME: "gecko_tests"
DUNITER_CHAIN_NAME: "dev"
DUNITER_GENESIS_CONFIG: "/var/lib/duniter/gecko_tests.json"
DUNITER_CHAIN_NAME: "gdev_dev"
DUNITER_GENESIS_CONFIG: "/var/lib/duniter/gecko_config.json"
DUNITER_GENESIS_DATA: "/var/lib/duniter/gecko_data.json"
volumes:
- ./data:/var/lib/duniter

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);
@ -65,12 +66,15 @@ Future payTest2() async {
Future certifyTest5() async {
// Create identity with Test1 account
await pump(number: 8);
await tapKey(keyCertify);
await tapKey(keyConfirm);
spawnBlock(duration: 1000);
await tester.pump(const Duration(seconds: 2));
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());
@ -83,9 +87,9 @@ Future certifyTest5() async {
await enterText(keyEnterIdentityUsername, test5.name);
await tapKey(keyConfirm);
spawnBlock(duration: 1000);
await tester.pump(const Duration(seconds: 2));
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);
@ -111,7 +115,7 @@ Future certifyTest5() async {
await tapKey(keyCertify);
await tapKey(keyConfirm);
spawnBlock(duration: 1000);
await tester.pump(const Duration(seconds: 2));
await pump(number: 3);
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen);
@ -119,16 +123,16 @@ Future certifyTest5() async {
// Change default wallet to test3
await tapKey(keyPay);
await tapKey(keyChangeChest);
await tapKey(keyDropdownWallets);
await tapKey(keySelectThisWallet(test3.address));
await tapKey(keyConfirm);
await tapKey(keyPopButton);
await sleep();
// Certify with test3 account
await tapKey(keyCertify);
await tapKey(keyConfirm);
spawnBlock(duration: 1000);
await tester.pump(const Duration(seconds: 2));
await pump(number: 3);
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen);

View File

@ -19,6 +19,7 @@ void main() async {
await firstOpenChest();
// Go to test1 options and check if balance growup with UDs creations
await scrollUntil(keyAddDerivation);
await tapKey(keyAddDerivation);
await waitFor(' 6');
@ -44,15 +45,17 @@ void main() async {
await tapKey(keyConfirm);
spawnBlock(duration: 1000);
await tester.pump(const Duration(seconds: 2));
await tester.pump(const Duration(seconds: 1));
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen, duration: 0);
await tapKey(keyOpenWallet(test6.address), duration: 300);
await pump(number: 4);
await waitFor('3', exactMatch: true);
await waitFor('memberValidated'.tr());
await waitFor('99.98', exactMatch: true);
await waitFor('110.01', exactMatch: true);
}, timeout: testTimeout());
}

View File

@ -25,7 +25,7 @@ Future changeNode() async {
}
Future deleteAllWallets() async {
if (await isPresent('Rechercher')) {
if (await isPresent('searchWallet'.tr())) {
await tapKey(keyDrawerMenu);
await tapKey(keyParameters);
@ -65,15 +65,17 @@ Future restoreChest() async {
// Enter password
await enterText(keyPinForm, 'AAAAA', 0);
// pump a few frame
await pump(duration: const Duration(milliseconds: 500), number: 10);
// Check if string "Accéder à mon coffre" is present in screen
await waitFor('accessMyChest'.tr(), pumpDuration: 30);
await waitFor('accessMyChest'.tr(), settle: false);
// Go to wallets home
await tapKey(keyGoWalletsHome, duration: 0);
// Skip tutorial
await sleep(500);
await tapKey(keyDragAndDrop).timeout(const Duration(seconds: 3));
await skipWalletDragTutorial();
// Check if string "ĞD" is present in screen
await waitFor('ĞD');
@ -168,5 +170,15 @@ Future firstOpenChest() async {
final isCached = await isIconPresent(Icons.check_box);
if (!isCached) await tapKey(keyCachePassword, duration: 0);
await enterText(keyPinForm, 'AAAAA', 0);
await waitFor('100.0', exactMatch: true);
await skipWalletDragTutorial();
await waitFor(test1.name);
}
Future skipWalletDragTutorial() async {
await pump(duration: const Duration(milliseconds: 500), number: 6);
await pump(duration: const Duration(seconds: 2));
if (await isPresent('explainDraggableWallet'.tr().substring(0, 13),
timeout: const Duration(seconds: 5), settle: false)) {
await tapKey(keyDragAndDrop, duration: 0);
}
}

View File

@ -53,6 +53,15 @@ Future sleep([int time = 1000]) async {
await Future.delayed(Duration(milliseconds: time));
}
Future pump(
{Duration duration = const Duration(milliseconds: 300),
int number = 1}) async {
for (int i = 0; i < number; i++) {
log.d("pump $i");
await tester.pump(duration = duration);
}
}
Future<String> clipPaste() async =>
(await Clipboard.getData('text/plain'))?.text ?? '';
@ -146,7 +155,8 @@ Future<void> waitFor(String text,
}
if (settle) {
await tester.pumpAndSettle(Duration(milliseconds: pumpDuration));
await tester.pumpAndSettle(Duration(milliseconds: pumpDuration),
EnginePhase.sendSemanticsUpdate, timeout);
}
await Future.delayed(const Duration(milliseconds: 100));
} while (reverse ? finder.evaluate().isNotEmpty : finder.evaluate().isEmpty);
@ -155,9 +165,9 @@ Future<void> waitFor(String text,
// Test if text is visible on screen, return a boolean
Future<bool> isPresent(String text,
{Duration timeout = const Duration(seconds: 1)}) async {
{Duration timeout = const Duration(seconds: 1), bool settle = true}) async {
try {
await waitFor(text, timeout: timeout);
await waitFor(text, timeout: timeout, settle: settle);
humanRead();
return true;
} catch (exception) {
@ -278,8 +288,8 @@ Future<WalletData> _addImportAccount(
Future bkDeleteAllWallets() async {
final myWalletProvider =
Provider.of<MyWalletsProvider>(homeContext, listen: false);
final isWalletsPresents =
await isPresent('Scanner un', timeout: const Duration(milliseconds: 300));
final isWalletsPresents = await isPresent('scanQRCode'.tr(),
timeout: const Duration(milliseconds: 300));
if (isWalletsPresents) {
await walletBox.clear();
await chestBox.clear();

View File

@ -8,10 +8,11 @@ import 'package:hive_flutter/hive_flutter.dart';
import 'package:logger/logger.dart';
// Version of box data
const int dataVersion = 6;
const int dataVersion = 7;
late String appVersion;
const int pinLength = 5;
const int maxWalletsInSafe = 30;
const String appLang = 'english';
late Box<WalletData> walletBox;

View File

@ -68,6 +68,7 @@ Future<void> main() async {
Hive.registerAdapter(ChestDataAdapter());
Hive.registerAdapter(G1WalletsListAdapter());
Hive.registerAdapter(IdAdapter());
Hive.registerAdapter(IdtyStatusAdapter());
chestBox = await Hive.openBox<ChestData>("chestBox");
@ -165,9 +166,9 @@ class Gecko extends StatelessWidget {
colorScheme:
ColorScheme.fromSwatch().copyWith(secondary: Colors.grey[850]),
),
home: const HomeScreen(),
initialRoute: "/",
routes: {
'/': (context) => const HomeScreen(),
'/mywallets': (context) => const WalletsHome(),
'/search': (context) => const SearchScreen(),
'/searchResult': (context) => const SearchResultScreen(),

View File

@ -28,18 +28,27 @@ class WalletData extends HiveObject {
bool isOwned;
@HiveField(8)
bool isMember;
IdtyStatus identityStatus;
WalletData(
{required this.address,
this.chest,
this.number,
this.name,
this.derivation,
this.imageDefaultPath,
this.imageCustomPath,
this.isOwned = false,
this.isMember = false});
@HiveField(9)
double balance;
@HiveField(10)
List<int>? certs;
WalletData({
required this.address,
this.chest,
this.number,
this.name,
this.derivation,
this.imageDefaultPath,
this.imageCustomPath,
this.isOwned = false,
this.identityStatus = IdtyStatus.unknown,
this.balance = 0,
this.certs,
});
// representation of WalletData when debugging
@override
@ -52,15 +61,47 @@ class WalletData extends HiveObject {
return "$chest:$number:$name:$derivation:$imageDefaultPath";
}
bool hasIdentity() {
return identityStatus == IdtyStatus.created ||
identityStatus == IdtyStatus.confirmed ||
identityStatus == IdtyStatus.validated;
}
bool isMembre() {
return identityStatus == IdtyStatus.validated;
}
bool exist() {
return balance != 0;
}
bool hasCustomImage() {
return imageCustomPath != null;
}
// returns only the id part of the ':'-separated string
List<int?> id() {
return [chest, number];
}
}
class NewWallet {
final String address;
final String password;
@HiveType(typeId: 5)
enum IdtyStatus {
@HiveField(0)
none,
NewWallet._(this.address, this.password);
@HiveField(1)
created,
@HiveField(2)
confirmed,
@HiveField(3)
validated,
@HiveField(4)
expired,
@HiveField(5)
unknown
}

View File

@ -25,14 +25,16 @@ class WalletDataAdapter extends TypeAdapter<WalletData> {
imageDefaultPath: fields[5] as String?,
imageCustomPath: fields[6] as String?,
isOwned: fields[7] as bool,
isMember: fields[8] as bool,
identityStatus: fields[8] as IdtyStatus,
balance: fields[9] as double,
certs: (fields[10] as List?)?.cast<int>(),
);
}
@override
void write(BinaryWriter writer, WalletData obj) {
writer
..writeByte(9)
..writeByte(11)
..writeByte(0)
..write(obj.address)
..writeByte(1)
@ -50,7 +52,11 @@ class WalletDataAdapter extends TypeAdapter<WalletData> {
..writeByte(7)
..write(obj.isOwned)
..writeByte(8)
..write(obj.isMember);
..write(obj.identityStatus)
..writeByte(9)
..write(obj.balance)
..writeByte(10)
..write(obj.certs);
}
@override
@ -63,3 +69,62 @@ class WalletDataAdapter extends TypeAdapter<WalletData> {
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
class IdtyStatusAdapter extends TypeAdapter<IdtyStatus> {
@override
final int typeId = 5;
@override
IdtyStatus read(BinaryReader reader) {
switch (reader.readByte()) {
case 0:
return IdtyStatus.none;
case 1:
return IdtyStatus.created;
case 2:
return IdtyStatus.confirmed;
case 3:
return IdtyStatus.validated;
case 4:
return IdtyStatus.expired;
case 5:
return IdtyStatus.unknown;
default:
return IdtyStatus.none;
}
}
@override
void write(BinaryWriter writer, IdtyStatus obj) {
switch (obj) {
case IdtyStatus.none:
writer.writeByte(0);
break;
case IdtyStatus.created:
writer.writeByte(1);
break;
case IdtyStatus.confirmed:
writer.writeByte(2);
break;
case IdtyStatus.validated:
writer.writeByte(3);
break;
case IdtyStatus.expired:
writer.writeByte(4);
break;
case IdtyStatus.unknown:
writer.writeByte(5);
break;
}
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is IdtyStatusAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}

View File

@ -98,6 +98,8 @@ const keyCesiumPassword = Key('keyCesiumPassword');
const keySelectWallet = Key('keySelectWallet');
const keyCesiumIdVisible = Key('keyCesiumIdVisible');
const keyDropdownWallets = Key('keyDropdownKey');
// Items keys
Key keyTransaction(int keyId) => Key('keyTransaction$keyId');
Key keyMnemonicWord(String word) => Key('keyMnemonicWord$word');

View File

@ -16,7 +16,6 @@ class DuniterIndexer with ChangeNotifier {
List? transBC;
List listIndexerEndpoints = [];
bool isLoadingIndexer = false;
Map<String, String> idtyStatusCache = {};
void reload() {
notifyListeners();

View File

@ -9,23 +9,19 @@ import 'package:gecko/models/bip39_words.dart';
import 'package:gecko/models/chest_data.dart';
import 'package:gecko/models/wallet_data.dart';
import 'package:gecko/providers/substrate_sdk.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart' as pw;
import 'package:polkawallet_sdk/api/apiKeyring.dart';
import 'package:provider/provider.dart';
import "package:unorm_dart/unorm_dart.dart" as unorm;
class GenerateWalletsProvider with ChangeNotifier {
GenerateWalletsProvider();
// NewWallet generatedWallet;
durt.NewWallet? actualWallet;
final walletNameFocus = FocusNode();
Color? askedWordColor = Colors.black;
bool isAskedWordValid = false;
int scanedValidWalletNumber = -1;
int scanedWalletNumber = -1;
int numberScan = 20;
int numberScan = 60;
late int nbrWord;
String? nbrWordAlpha;
@ -151,77 +147,6 @@ class GenerateWalletsProvider with ChangeNotifier {
return pin.text;
}
Future<Uint8List> printWallet(AsyncSnapshot<List>? mnemoList) async {
final ByteData fontData =
await rootBundle.load("assets/OpenSans-Regular.ttf");
final pw.Font ttf = pw.Font.ttf(fontData.buffer.asByteData());
final pdf = pw.Document();
// const imageProvider = AssetImage('assets/icon/gecko_final.png');
// final geckoLogo = await flutterImageProvider(imageProvider);
pw.Widget arrayCell(dataWord) {
return pw.SizedBox(
width: 120,
child: pw.Column(children: <pw.Widget>[
pw.Text(
dataWord.split(':')[0],
style: pw.TextStyle(
fontSize: 15, color: const PdfColor(0.5, 0, 0), font: ttf),
),
pw.Text(
dataWord.split(':')[1],
style: pw.TextStyle(
fontSize: 20, color: const PdfColor(0, 0, 0), font: ttf),
),
pw.SizedBox(height: 10)
]),
);
}
pdf.addPage(
pw.Page(
pageFormat: PdfPageFormat.a4,
build: (context) {
return pw.Column(
// mainAxisAlignment: pw.MainAxisAlignment.center,
// mainAxisSize: pw.MainAxisSize.max,
// crossAxisAlignment: pw.CrossAxisAlignment.center,
children: <pw.Widget>[
pw.Row(children: <pw.Widget>[
arrayCell(mnemoList!.data![0]),
arrayCell(mnemoList.data![1]),
arrayCell(mnemoList.data![2]),
arrayCell(mnemoList.data![3]),
]),
pw.Row(children: <pw.Widget>[
arrayCell(mnemoList.data![4]),
arrayCell(mnemoList.data![5]),
arrayCell(mnemoList.data![6]),
arrayCell(mnemoList.data![7]),
]),
pw.Row(children: <pw.Widget>[
arrayCell(mnemoList.data![8]),
arrayCell(mnemoList.data![9]),
arrayCell(mnemoList.data![10]),
arrayCell(mnemoList.data![11])
]),
pw.Expanded(
child: pw.Align(
alignment: pw.Alignment.bottomCenter,
child: pw.Text(
"Gardez cette feuille préciseusement, à labri des lézards indiscrets.",
style: pw.TextStyle(fontSize: 15, font: ttf),
)))
],
);
},
),
);
return pdf.save();
}
Future<void> generateCesiumWalletPubkey(
String cesiumID, String cesiumPWD) async {
cesiumWallet = durt.CesiumWallet(cesiumID, cesiumPWD);
@ -244,7 +169,6 @@ class GenerateWalletsProvider with ChangeNotifier {
void resetCesiumImportView() {
cesiumID.text = cesiumPWD.text = cesiumPubkey.text = pin.text = '';
canImport = isCesiumIDVisible = isCesiumPWDVisible = false;
actualWallet = null;
notifyListeners();
}
@ -374,6 +298,7 @@ class GenerateWalletsProvider with ChangeNotifier {
bool isAlive = false;
scanedValidWalletNumber = 0;
scanedWalletNumber = 0;
Map<String, int> addressToScan = {};
notifyListeners();
if (!sub.nodeConnected) {
@ -388,37 +313,38 @@ class GenerateWalletsProvider with ChangeNotifier {
isAlive = true;
}
for (var derivationNbr in [for (var i = 0; i < numberScan; i += 1) i]) {
for (int derivationNbr in [for (var i = 0; i < numberScan; i += 1) i]) {
final addressData = await sub.sdk.api.keyring.addressFromMnemonic(
sub.currencyParameters['ss58']!,
cryptoType: CryptoType.sr25519,
mnemonic: generatedMnemonic!,
derivePath: '//$derivationNbr');
addressToScan.putIfAbsent(addressData.address!, () => derivationNbr);
}
final Map balance = await sub.getBalance(addressData.address!).timeout(
const Duration(seconds: 1),
onTimeout: () => {'transferableBalance': 0},
);
// const balance = 0;
final balanceList =
await sub.getBalanceMulti(addressToScan.keys.toList()).timeout(
const Duration(seconds: 20),
onTimeout: () => {},
);
log.d(
"${addressData.address!}: ${balance['transferableBalance']} $currencyName");
if (balance['transferableBalance'] != 0) {
for (String scannedWallet in balanceList.keys) {
if (balanceList[scannedWallet]!['transferableBalance'] != 0) {
isAlive = true;
String walletName = scanedValidWalletNumber == 0
? 'currentWallet'.tr()
: '${'wallet'.tr()} ${scanedValidWalletNumber + 1}';
await sub.importAccount(
mnemonic: generatedMnemonic!,
derivePath: '//$derivationNbr',
derivePath: "//${addressToScan[scannedWallet]}",
password: pin.text);
WalletData myWallet = WalletData(
chest: currentChestNumber,
address: addressData.address!,
address: scannedWallet,
number: scanedValidWalletNumber,
name: walletName,
derivation: derivationNbr,
derivation: addressToScan[scannedWallet],
imageDefaultPath: '${scanedValidWalletNumber % 4}.png',
isOwned: true);
await walletBox.put(myWallet.address, myWallet);
@ -427,6 +353,7 @@ class GenerateWalletsProvider with ChangeNotifier {
scanedWalletNumber = scanedWalletNumber + 1;
notifyListeners();
}
log.d(scanedWalletNumber);
scanedWalletNumber = -1;
scanedValidWalletNumber = -1;
@ -445,8 +372,6 @@ class GenerateWalletsProvider with ChangeNotifier {
onTimeout: () => {},
);
log.d(balance);
log.d(
"${addressData.address!}: ${balance['transferableBalance']} $currencyName");
if (balance['transferableBalance'] != 0) {

View File

@ -13,8 +13,8 @@ class MyWalletsProvider with ChangeNotifier {
late String mnemonic;
int? pinLenght;
bool isNewDerivationLoading = false;
String lastFlyBy = '';
String dragAddress = '';
WalletData? lastFlyBy;
WalletData? dragAddress;
bool isPinValid = false;
bool isPinLoading = true;
@ -35,14 +35,32 @@ class MyWalletsProvider with ChangeNotifier {
}
}
List<WalletData> readAllWallets([int? chest]) {
Future<List<WalletData>> readAllWallets([int? chest]) async {
final sub = Provider.of<SubstrateSdk>(homeContext, listen: false);
chest = chest ?? configBox.get('currentChest') ?? 0;
listWallets.clear();
walletBox.toMap().forEach((key, value) {
if (value.chest == chest) {
listWallets.add(value);
final wallets = walletBox.toMap().values.toList();
Map<String, WalletData> walletsToScan = {};
for (var walletFromBox in wallets) {
if (walletFromBox.chest == chest) {
if (walletFromBox.identityStatus == IdtyStatus.unknown) {
walletsToScan.putIfAbsent(
walletFromBox.address, (() => walletFromBox));
} else {
listWallets.add(walletFromBox);
}
}
});
}
// update all idty status in lists
int n = 0;
final idtyStatusList = await sub.idtyStatus(walletsToScan.keys.toList());
for (final wallet in walletsToScan.values) {
wallet.identityStatus = idtyStatusList[n];
walletBox.put(wallet.address, wallet);
listWallets.add(wallet);
n++;
}
return listWallets;
}
@ -104,10 +122,8 @@ class MyWalletsProvider with ChangeNotifier {
myWalletProvider.pinCode = '';
await Navigator.of(context).pushNamedAndRemoveUntil(
'/',
ModalRoute.withName('/'),
);
await Navigator.of(context)
.pushNamedAndRemoveUntil('/', (Route<dynamic> route) => false);
}
return 0;
} catch (e) {
@ -120,7 +136,7 @@ class MyWalletsProvider with ChangeNotifier {
isNewDerivationLoading = true;
notifyListeners();
final List idList = getNextWalletNumberAndDerivation();
final List idList = await getNextWalletNumberAndDerivation();
int newWalletNbr = idList[0];
int newDerivationNbr = number ?? idList[1];
@ -143,6 +159,7 @@ class MyWalletsProvider with ChangeNotifier {
isOwned: true);
await walletBox.put(newWallet.address, newWallet);
await readAllWallets();
isNewDerivationLoading = false;
notifyListeners();
@ -157,7 +174,7 @@ class MyWalletsProvider with ChangeNotifier {
int newWalletNbr;
int? chest = getCurrentChest();
List<WalletData> walletConfig = readAllWallets(chest);
List<WalletData> walletConfig = await readAllWallets(chest);
walletConfig.sort((p1, p2) {
return Comparable.compare(p1.number!, p2.number!);
});
@ -189,22 +206,21 @@ class MyWalletsProvider with ChangeNotifier {
notifyListeners();
}
List<int> getNextWalletNumberAndDerivation(
{int? chestNumber, bool isOneshoot = false}) {
Future<List<int>> getNextWalletNumberAndDerivation(
{int? chestNumber, bool isOneshoot = false}) async {
int newDerivationNbr = 0;
int newWalletNbr = 0;
chestNumber ??= getCurrentChest();
List<WalletData> walletConfig = readAllWallets(chestNumber);
walletConfig.sort((p1, p2) {
listWallets.sort((p1, p2) {
return Comparable.compare(p1.number!, p2.number!);
});
if (walletConfig.isEmpty) {
if (listWallets.isEmpty) {
newDerivationNbr = 2;
} else {
WalletData lastWallet = walletConfig.reduce(
WalletData lastWallet = listWallets.reduce(
(curr, next) => curr.derivation! > next.derivation! ? curr : next);
if (lastWallet.derivation == -1) {
@ -213,7 +229,7 @@ class MyWalletsProvider with ChangeNotifier {
newDerivationNbr = lastWallet.derivation! + (isOneshoot ? 1 : 2);
}
newWalletNbr = walletConfig.last.number! + 1;
newWalletNbr = listWallets.last.number! + 1;
}
return [newWalletNbr, newDerivationNbr];

View File

@ -1,5 +1,7 @@
// ignore_for_file: use_build_context_synchronously, body_might_complete_normally_catch_error
import 'dart:convert';
import 'package:easy_localization/easy_localization.dart';
import 'package:fast_base58/fast_base58.dart';
import 'package:flutter/foundation.dart';
@ -35,7 +37,6 @@ class SubstrateSdk with ChangeNotifier {
bool importIsLoading = false;
int blocNumber = 0;
bool isLoadingEndpoint = false;
String debugConnection = '';
String transactionStatus = '';
final int initSs58 = 42;
Map<String, int> currencyParameters = {};
@ -51,7 +52,7 @@ class SubstrateSdk with ChangeNotifier {
/////////////////////////////////////
////////// 1: API METHODS ///////////
/////////////////////////////////////
/////////////////////////////////////3
Future<String> _executeCall(TxInfoData txInfo, txOptions, String password,
[String? rawParams]) async {
@ -70,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();
@ -91,10 +92,11 @@ class SubstrateSdk with ChangeNotifier {
Future _getStorage(String call) async {
try {
// log.d(call);
return await sdk.webView!.evalJavascript('api.query.$call');
} catch (e) {
log.e("_getStorage error: $e");
return Future(() {});
throw Exception("_getStorage error: $e");
}
}
@ -138,12 +140,21 @@ class SubstrateSdk with ChangeNotifier {
////////// 2: GET ONCHAIN STORAGE //////////
////////////////////////////////////////////
Future<int> _getIdentityIndexOf(String address) async {
return await _getStorage('identity.identityIndexOf("$address")') ?? 0;
Future<int?> _getIdentityIndexOf(String address) async {
return await _getStorage('identity.identityIndexOf("$address")');
}
Future<List<int>> getCertsCounter(String address) async {
Future<List<int?>> _getIdentityIndexOfMulti(List<String> addresses) async {
String jsonString = jsonEncode(addresses);
return List<int?>.from(
await _getStorage('identity.identityIndexOf.multi($jsonString)'));
}
Future<List<int>?> getCertsCounter(String address) async {
final idtyIndex = await _getIdentityIndexOf(address);
if (idtyIndex == null) {
return null;
}
final certsReceiver =
await _getStorage('cert.storageIdtyCertMeta($idtyIndex)') ?? [];
@ -167,7 +178,7 @@ class SubstrateSdk with ChangeNotifier {
final idtyIndexFrom = await _getIdentityIndexOf(from);
final idtyIndexTo = await _getIdentityIndexOf(to);
if (idtyIndexFrom == 0 || idtyIndexTo == 0) return 0;
if (idtyIndexFrom == null || idtyIndexTo == null) return 0;
final List certData =
await _getStorage('cert.certsByReceiver($idtyIndexTo)') ?? [];
@ -200,14 +211,48 @@ class SubstrateSdk with ChangeNotifier {
return balanceRatio;
}
Future getBalanceMulti(List addresses) async {
Future<Map<String, Map<String, double>>> getBalanceMulti(
List<String> addresses) async {
List stringifyAddresses = [];
for (var element in addresses) {
stringifyAddresses.add('"$element"');
}
final List balanceGlobal =
await _getStorage('system.account.multi($stringifyAddresses)');
log.d('debug multi: $balanceGlobal');
// Get onchain storage values
final List<Map> balanceGlobalMulti =
(await _getStorage('system.account.multi($stringifyAddresses)') as List)
.map((dynamic e) => e as Map<String, dynamic>)
.toList();
final List<int?> idtyIndexList = (await _getStorage(
'identity.identityIndexOf.multi($stringifyAddresses)') as List)
.map((dynamic e) => e as int?)
.toList();
//FIXME: With local dev duniter node only, need to switch null values by unused init as index to have good idtyDataList...
final List<int> idtyIndexListNoNull =
idtyIndexList.map((item) => item ?? 99999999).toList();
final List<Map?> idtyDataList = (idtyIndexListNoNull.isEmpty
? []
: (await _getStorage(
'identity.identities.multi($idtyIndexListNoNull)')) as List)
.map((dynamic e) => e as Map<String, dynamic>?)
.toList();
final List pastReevals =
await _getStorage('universalDividend.pastReevals()');
int nbr = 0;
Map<String, Map<String, double>> finalBalancesList = {};
for (Map balanceGlobal in balanceGlobalMulti) {
final computedBalance =
await _computeBalance(idtyDataList[nbr], pastReevals, balanceGlobal);
finalBalancesList.putIfAbsent(addresses[nbr], () => computedBalance);
nbr++;
}
return finalBalancesList;
}
Future<Map<String, double>> getBalance(String address) async {
@ -230,6 +275,11 @@ class SubstrateSdk with ChangeNotifier {
final List pastReevals =
await _getStorage('universalDividend.pastReevals()');
return _computeBalance(idtyData, pastReevals, balanceGlobal);
}
Future<Map<String, double>> _computeBalance(
Map? idtyData, List pastReevals, Map balanceGlobal) async {
// Compute amount of claimable UDs
currentUdIndex = await getCurrentUdIndex();
final int unclaimedUds = _computeUnclaimUds(
@ -239,21 +289,13 @@ class SubstrateSdk with ChangeNotifier {
final int transferableBalance =
(balanceGlobal['data']['free'] + unclaimedUds);
// log.d('udValue: $udValue');
Map<String, double> finalBalances = {
return {
'transferableBalance': round((transferableBalance / balanceRatio) / 100),
'free': round((balanceGlobal['data']['free'] / balanceRatio) / 100),
'unclaimedUds': round((unclaimedUds / balanceRatio) / 100),
'reserved':
round((balanceGlobal['data']['reserved'] / balanceRatio) / 100),
};
// log.i(finalBalances);
log.d(
'${getShortPubkey(address)} --- BALANCE: ${finalBalances['transferableBalance']}');
return finalBalances;
}
int _computeUnclaimUds(int firstEligibleUd, List pastReevals) {
@ -283,33 +325,13 @@ class SubstrateSdk with ChangeNotifier {
return totalAmount;
}
Future<bool> isMember(String address) async {
final isMember = await idtyStatus(address) == 'Validated';
final walletData = walletBox.get(address) ?? WalletData(address: address);
walletData.isMember = isMember;
walletBox.put(address, walletData);
// notifyListeners();
return isMember;
}
Future<bool> isSmithGet(String address) async {
var idtyIndex = await _getIdentityIndexOf(address);
final Map smithExpireOn =
(await _getStorage('smithsMembership.membership($idtyIndex)')) ?? {};
if (smithExpireOn.isEmpty) {
return false;
} else {
return true;
}
}
Future<Map<String, int>> certState(String from, String to) async {
Map<String, int> result = {};
final toStatus = await idtyStatus(to);
final toStatus = (await idtyStatus([to])).first;
if (from != to && await isMember(from)) {
final myWallets = MyWalletsProvider();
if (from != to && myWallets.getWalletDataByAddress(from)!.isMembre()) {
final removableOn = await getCertValidityPeriod(from, to);
final certMeta = await getCertMeta(from);
final int nextIssuableOn = certMeta['nextIssuableOn'] ?? 0;
@ -322,9 +344,9 @@ class SubstrateSdk with ChangeNotifier {
} else if (nextIssuableOn > blocNumber) {
final certDelayDuration = (nextIssuableOn - blocNumber) * 6;
result.putIfAbsent('certDelay', () => certDelayDuration);
} else if (toStatus == 'Created') {
} else if (toStatus == IdtyStatus.created) {
result.putIfAbsent('toStatus', () => 1);
} else if (toStatus == 'noid') {
} else if (toStatus == IdtyStatus.none) {
result.putIfAbsent('toStatus', () => 2);
result.putIfAbsent('canCert', () => 0);
} else {
@ -332,8 +354,6 @@ class SubstrateSdk with ChangeNotifier {
}
}
// if (toStatus == 'Created') result.putIfAbsent('toStatus', () => 1);
return result;
}
@ -351,7 +371,7 @@ class SubstrateSdk with ChangeNotifier {
// Provider.of<WalletOptionsProvider>(homeContext, listen: false);
var idtyIndex = await _getIdentityIndexOf(address);
if (idtyIndex == 0) return [];
if (idtyIndex == null) return [];
final Map? idtyData = await _getStorage('identity.identities($idtyIndex)');
if (idtyData == null || idtyData['oldOwnerKey'] == null) return [];
@ -369,37 +389,43 @@ class SubstrateSdk with ChangeNotifier {
return startBlockchainTime.add(Duration(seconds: blocNumber * 6));
}
Future<String> idtyStatus(String address) async {
Future<List<IdtyStatus>> idtyStatus(List<String> addresses) async {
// final walletOptions =
// Provider.of<WalletOptionsProvider>(homeContext, listen: false);
var idtyIndex = await _getIdentityIndexOf(address);
final idtyIndexes = await _getIdentityIndexOfMulti(addresses);
if (idtyIndex == 0) {
return 'noid';
}
final idtyStatus = await _getStorage('identity.identities($idtyIndex)');
if (idtyStatus != null) {
final String status = idtyStatus['status'];
// if (address == walletOptions.address.text && status == 'Validated') {
// walletOptions.reloadBuild();
// }
return (status);
} else {
return 'expired';
//FIXME: should not have to replace null values by 99999999
final idtyIndexesFix = idtyIndexes.map((item) => item ?? 99999999).toList();
final jsonString = jsonEncode(idtyIndexesFix);
final List idtyStatusList =
await _getStorage('identity.identities.multi($jsonString)');
List<IdtyStatus> resultStatus = [];
final mapStatus = {
null: IdtyStatus.none,
'Created': IdtyStatus.created,
'ConfirmedByOwner': IdtyStatus.confirmed,
'Validated': IdtyStatus.validated,
'Expired': IdtyStatus.expired,
'unknown': IdtyStatus.unknown,
};
for (final idtyStatus in idtyStatusList) {
if (idtyStatus == null) {
resultStatus.add(IdtyStatus.none);
} else {
resultStatus.add(mapStatus[idtyStatus['status']] ?? IdtyStatus.unknown);
}
}
return resultStatus;
}
Future<bool> isSmith(String address) async {
var idtyIndex = await _getIdentityIndexOf(address);
if (idtyIndex == 0) return false;
if (idtyIndex == -1) return false;
final isSmith =
await _getStorage('smithsMembership.membership($idtyIndex)');
final isSmith = await _getStorage('smithMembership.membership($idtyIndex)');
return isSmith == null ? false : true;
}
@ -569,7 +595,7 @@ class SubstrateSdk with ChangeNotifier {
? [getDuniterCustomEndpoint()]
: getDuniterBootstrap();
int timeout = 10000;
int timeout = 15;
if (sdk.api.connectedNode?.endpoint != null) {
await sdk.api.setting.unsubscribeBestNumber();
@ -577,13 +603,13 @@ class SubstrateSdk with ChangeNotifier {
isLoadingEndpoint = true;
notifyListeners();
final res = await sdk.api.connectNode(keyring, listEndpoints).timeout(
Duration(milliseconds: timeout),
final resNode = await sdk.api.connectNode(keyring, listEndpoints).timeout(
Duration(seconds: timeout),
onTimeout: () => null,
);
isLoadingEndpoint = false;
notifyListeners();
if (res != null) {
if (resNode != null) {
nodeConnected = true;
// await getSs58Prefix();
@ -615,7 +641,6 @@ class SubstrateSdk with ChangeNotifier {
// snackNode(ctx, true);
} else {
nodeConnected = false;
debugConnection = res.toString();
notifyListeners();
homeProvider.changeMessage("noDuniterEndointAvailable".tr(), 0);
if (!myWalletProvider.checkIfWalletExist()) snackNode(homeContext, false);
@ -714,13 +739,12 @@ class SubstrateSdk with ChangeNotifier {
final seed = await sdk.api.keyring.getDecryptedSeed(keyring, pin);
String seedText;
if (seed == null) {
if (seed == null || seed.seed == null) {
seedText = '';
} else {
seedText = seed.seed!.split('//')[0];
}
log.d(seedText);
return seedText;
}
@ -858,11 +882,12 @@ class SubstrateSdk with ChangeNotifier {
final fromBalance = fromAddress == ''
? {'transferableBalance': 0}
: await getBalance(fromAddress);
final fromIdtyStatus =
fromAddress == '' ? 'noid' : await idtyStatus(fromAddress);
final statusList = await idtyStatus([fromAddress, toAddress]);
final fromIdtyStatus = statusList[0];
final fromHasConsumer =
fromAddress == '' ? false : await hasAccountConsumers(fromAddress);
final toIdtyStatus = await idtyStatus(toAddress);
final toIdtyStatus = statusList[1];
final isSmithData = await isSmith(fromAddress);
return [
@ -937,13 +962,16 @@ class SubstrateSdk with ChangeNotifier {
String fromAddress, String destAddress, String password) async {
transactionStatus = '';
final myIdtyStatus = await idtyStatus(fromAddress);
final toIdtyStatus = await idtyStatus(destAddress);
final statusList = await idtyStatus([fromAddress, destAddress]);
final myIdtyStatus = statusList[0];
final toIdtyStatus = statusList[1];
final fromIndex = await _getIdentityIndexOf(fromAddress);
final toIndex = await _getIdentityIndexOf(destAddress);
final idtyIndexList =
await _getIdentityIndexOfMulti([fromAddress, destAddress]);
final fromIndex = idtyIndexList[0];
final toIndex = idtyIndexList[1];
if (myIdtyStatus != 'Validated') {
if (myIdtyStatus != IdtyStatus.validated) {
transactionStatus = 'notMember';
notifyListeners();
return 'notMember';
@ -956,22 +984,20 @@ class SubstrateSdk with ChangeNotifier {
final toCerts = await getCertsCounter(destAddress);
// log.d('debug: ${currencyParameters['minCertForMembership']}');
log.d(
"debug toCert: ${toCerts[0]} --- ${currencyParameters['minCertForMembership']!} --- $toIdtyStatus");
"debug toCert: ${toCerts?[0]} --- ${currencyParameters['minCertForMembership']!} --- $toIdtyStatus");
if (toIdtyStatus == 'noid') {
if (toIdtyStatus == IdtyStatus.none) {
txInfo = TxInfoData(
'identity',
'createIdentity',
sender,
);
txOptions = [destAddress];
} else if (toIdtyStatus == 'Validated' ||
toIdtyStatus == 'ConfirmedByOwner') {
if (toCerts[0] >= currencyParameters['minCertForMembership']! - 1 &&
toIdtyStatus != 'Validated') {
} else if (toIdtyStatus == IdtyStatus.validated ||
toIdtyStatus == IdtyStatus.confirmed) {
if (toCerts![0] >= currencyParameters['minCertForMembership']! - 1 &&
toIdtyStatus != IdtyStatus.validated) {
log.i('Batch cert and membership validation');
txInfo = TxInfoData(
'utility',
@ -1031,13 +1057,14 @@ class SubstrateSdk with ChangeNotifier {
final prefix = 'icok'.codeUnits;
final genesisHashString = await getGenesisHash();
final genesisHash = HEX.decode(genesisHashString.substring(2)) as Uint8List;
final idtyIndex = _int32bytes(await _getIdentityIndexOf(fromAddress));
final idtyIndex = _int32bytes((await _getIdentityIndexOf(fromAddress))!);
final oldPubkey = await addressToPubkey(fromAddress);
final messageToSign =
Uint8List.fromList(prefix + genesisHash + idtyIndex + oldPubkey);
final messageToSignHex = HEX.encode(messageToSign);
final newKeySig =
await _signMessage(messageToSign, destAddress, destPassword);
final newKeySigType = '{"Sr25519": "$newKeySig"}';
// messageToSign: [105, 99, 111, 107, 7, 193, 18, 255, 106, 185, 215, 208, 213, 49, 235, 229, 159, 152, 179, 83, 24, 178, 129, 59, 22, 85, 87, 115, 128, 129, 157, 56, 214, 24, 45, 153, 21, 0, 0, 0, 181, 82, 178, 99, 198, 4, 156, 190, 78, 35, 102, 137, 255, 7, 162, 31, 16, 79, 255, 132, 130, 237, 230, 222, 176, 88, 245, 217, 237, 78, 196, 239]
@ -1053,7 +1080,7 @@ oldPubkey: $oldPubkey
messageToSign: $messageToSign
messageToSignHex: $messageToSignHex
newKeySig: $newKeySig""");
newKeySig: $newKeySigType""");
if (withBalance) {
txInfo = TxInfoData(
@ -1064,7 +1091,7 @@ newKeySig: $newKeySig""");
const tx1 = 'api.tx.universalDividend.claimUds()';
final tx2 =
'api.tx.identity.changeOwnerKey("$destAddress", "$newKeySig")';
'api.tx.identity.changeOwnerKey("$destAddress", $newKeySigType)';
final tx3 = 'api.tx.balances.transferAll("$destAddress", false)';
rawParams = fromBalance['unclaimedUds'] == 0
@ -1077,7 +1104,7 @@ newKeySig: $newKeySig""");
sender,
);
txOptions = [destAddress, newKeySig];
txOptions = [destAddress, newKeySigType];
}
return await _executeCall(txInfo, txOptions, fromPassword, rawParams);
@ -1090,7 +1117,7 @@ newKeySig: $newKeySig""");
final prefix = 'revo'.codeUnits;
final genesisHashString = await getGenesisHash();
final genesisHash = HEX.decode(genesisHashString.substring(2)) as Uint8List;
final idtyIndexBytes = _int32bytes(idtyIndex);
final idtyIndexBytes = _int32bytes(idtyIndex!);
final messageToSign =
Uint8List.fromList(prefix + genesisHash + idtyIndexBytes);
final revocationSig =
@ -1110,7 +1137,7 @@ newKeySig: $newKeySig""");
Future migrateCsToV2(String salt, String password, String destAddress,
{required destPassword,
required Map balance,
String idtyStatus = 'noid'}) async {
IdtyStatus idtyStatus = IdtyStatus.none}) async {
final scrypt = pc.KeyDerivator('scrypt');
scrypt.init(
@ -1141,7 +1168,7 @@ newKeySig: $newKeySig""");
);
log.d('g1migration idtyStatus: $idtyStatus');
if (idtyStatus != 'noid') {
if (idtyStatus != IdtyStatus.none) {
await migrateIdentity(
fromAddress: keypair.address!,
destAddress: destAddress,

View File

@ -29,7 +29,6 @@ class WalletOptionsProvider with ChangeNotifier {
TextEditingController nameController = TextEditingController();
late bool isDefaultWallet;
bool canValidateNameBool = false;
Future<NewWallet>? get badWallet => null;
Map<String, double> balanceCache = {};
int getPinLenght(walletNbr) {
@ -162,7 +161,6 @@ class WalletOptionsProvider with ChangeNotifier {
!await isIdtyExist(idtyName.text) &&
idtyName.text.length >= 2 &&
idtyName.text.length <= 32;
log.d('aaaaaaaaaa: $canValidate');
notifyListeners();
},
@ -370,18 +368,4 @@ class WalletOptionsProvider with ChangeNotifier {
await configBox.put('isCacheChecked', !isCacheChecked);
notifyListeners();
}
String? getAddress(int chest, int derivation) {
String? addressGet;
walletBox.toMap().forEach((key, value) {
if (value.chest == chest && value.derivation == derivation) {
addressGet = value.address;
return;
}
});
address.text = addressGet ?? '';
return addressGet;
}
}

View File

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

View File

@ -19,7 +19,7 @@ import 'package:gecko/widgets/commons/common_elements.dart';
import 'package:gecko/screens/myWallets/restore_chest.dart';
import 'package:gecko/screens/onBoarding/1.dart';
import 'package:gecko/widgets/drawer.dart';
import 'package:gecko/widgets/home_buttons.dart';
import 'package:gecko/widgets/buttons/home_buttons.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:provider/provider.dart';
@ -119,14 +119,6 @@ class _HomeScreenState extends State<HomeScreen> {
ratio = 1.125;
}
//TODO: finish to implement multiqueries
// final sub = Provider.of<SubstrateSdk>(context, listen: false);
// sub.getBalanceMulti([
// '5CQ8T4qpbYJq7uVsxGPQ5q2df7x3Wa4aRY6HUWMBYjfLZhnn',
// '5Dq8xjvkmbz7q4g2LbZgyExD26VSCutfEc6n4W4AfQeVHZqz'
// ]);
return Scaffold(
resizeToAvoidBottomInset: false,
drawer: MainDrawer(isWalletsExists: isWalletsExists),

View File

@ -10,7 +10,6 @@ import 'package:flutter/material.dart';
import 'package:gecko/screens/myWallets/restore_chest.dart';
import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:gecko/screens/myWallets/wallets_home.dart';
import 'package:gecko/screens/onBoarding/5.dart';
import 'package:provider/provider.dart';
@ -132,12 +131,7 @@ class _ChooseChestState extends State<ChooseChest> {
ModalRoute.withName('/'),
);
if (myWalletProvider.pinCode != '') {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return const WalletsHome();
}),
);
Navigator.pushNamed(context, '/mywallets');
}
},
child: Text(

View File

@ -1,237 +0,0 @@
// ignore_for_file: use_build_context_synchronously, must_be_immutable
import 'dart:io';
import 'package:easy_localization/easy_localization.dart';
import 'package:gecko/globals.dart';
import 'package:flutter/material.dart';
import 'package:gecko/models/wallet_data.dart';
import 'package:gecko/models/widgets_keys.dart';
import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/providers/substrate_sdk.dart';
import 'package:gecko/screens/myWallets/wallets_home.dart';
import 'package:gecko/widgets/balance.dart';
import 'package:provider/provider.dart';
// import 'package:gecko/models/home.dart';
// import 'package:provider/provider.dart';
class ChooseWalletScreen extends StatelessWidget {
ChooseWalletScreen({Key? key, required this.pin}) : super(key: key);
final String pin;
WalletData? selectedWallet;
@override
Widget build(BuildContext context) {
final sub = Provider.of<SubstrateSdk>(context, listen: false);
final int chest = configBox.get('currentChest');
return Scaffold(
backgroundColor: backgroundColor,
appBar: AppBar(
toolbarHeight: 60 * ratio,
title: SizedBox(
height: 22,
child: Text('choiceOfSourceWallet'.tr()),
)),
body: SafeArea(
child: Stack(children: [
myWalletsTiles(context, chest),
Positioned.fill(
bottom: 60,
child: Align(
alignment: Alignment.bottomCenter,
child: SizedBox(
width: 470,
height: 70,
child: ElevatedButton(
key: keyConfirm,
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white, elevation: 4,
backgroundColor: orangeC, // foreground
),
onPressed: () async {
await sub.setCurrentWallet(selectedWallet!);
sub.reload();
// Navigator.pop(context);
Navigator.pop(context);
Navigator.pop(context);
},
child: Text(
'chooseThisWallet'.tr(),
style: const TextStyle(
fontSize: 24, fontWeight: FontWeight.w600),
),
),
),
),
),
]),
));
}
Widget myWalletsTiles(BuildContext context, int currentChest) {
final myWalletProvider = Provider.of<MyWalletsProvider>(context);
final bool isWalletsExists = myWalletProvider.checkIfWalletExist();
WalletData? defaultWallet = myWalletProvider.getDefaultWallet();
selectedWallet ??= defaultWallet;
myWalletProvider.readAllWallets(currentChest);
if (!isWalletsExists) {
return const Text('');
}
if (myWalletProvider.listWallets.isEmpty) {
return const Column(children: <Widget>[
Center(
child: Text(
'Veuillez générer votre premier portefeuille',
style: TextStyle(fontSize: 17, fontWeight: FontWeight.w500),
)),
]);
}
List<WalletData> listWallets = myWalletProvider.listWallets;
listWallets.sort((p1, p2) {
return Comparable.compare(p1.number!, p2.number!);
});
final screenWidth = MediaQuery.of(context).size.width;
int nTule = 2;
if (screenWidth >= 900) {
nTule = 4;
} else if (screenWidth >= 650) {
nTule = 3;
}
return CustomScrollView(slivers: <Widget>[
const SliverToBoxAdapter(child: SizedBox(height: 20)),
SliverGrid.count(
key: keyListWallets,
crossAxisCount: nTule,
childAspectRatio: 1,
crossAxisSpacing: 0,
mainAxisSpacing: 0,
children: <Widget>[
for (WalletData repository in listWallets)
Padding(
padding: const EdgeInsets.all(16),
child: GestureDetector(
key: keySelectThisWallet(repository.address),
onTap: () {
selectedWallet = repository;
myWalletProvider.reload();
},
child: ClipOvalShadow(
shadow: const Shadow(
color: Colors.transparent,
offset: Offset(0, 0),
blurRadius: 5,
),
clipper: CustomClipperOval(),
child: ClipRRect(
borderRadius:
const BorderRadius.all(Radius.circular(12)),
child: Column(children: <Widget>[
Expanded(
child: Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
gradient: RadialGradient(
radius: 0.6,
colors: [
Colors.green[400]!,
const Color(0xFFE7E7A6),
],
)),
child: repository.imageCustomPath == null
? Image.asset(
'assets/avatars/${repository.imageDefaultPath}',
alignment: Alignment.bottomCenter,
scale: 0.5,
)
: Container(
width: 120,
height: 120,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.transparent,
image: DecorationImage(
fit: BoxFit.contain,
image: FileImage(
File(repository.imageCustomPath!),
),
),
),
),
)),
balanceBuilder(context, repository.address,
selectedWallet!.address == repository.address),
ListTile(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(12),
),
),
tileColor:
repository.address == selectedWallet!.address
? orangeC
: const Color(0xffFFD58D),
title: Center(
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 5),
child: Text(
repository.name!,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 17.0,
color: repository.address ==
selectedWallet!.address
? const Color(0xffF9F9F1)
: Colors.black,
fontStyle: FontStyle.italic),
),
),
),
onTap: () async {
selectedWallet = repository;
myWalletProvider.reload();
},
)
]),
),
),
)),
]),
]);
}
Widget balanceBuilder(context, String address, bool isDefault) {
return Container(
width: double.infinity,
color: isDefault ? orangeC : yellowC,
child: SizedBox(
height: 30,
child: Column(children: [
const Spacer(),
// Text(
// '0.0 gd',
// textAlign: TextAlign.center,
// style: TextStyle(color: isDefault ? Colors.white : Colors.black),
// ),
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Balance(
address: address,
size: 16,
color: isDefault ? Colors.white : Colors.black),
])
]),
),
);
}
}

View File

@ -35,9 +35,7 @@ class _CustomDerivationState extends State<CustomDerivation> {
for (var i = 0; i < 51; i += 1) i.toString()
];
final listWallets = myWalletProvider.readAllWallets();
for (WalletData wallet in listWallets) {
for (WalletData wallet in myWalletProvider.listWallets) {
derivationList.remove(wallet.derivation.toString());
if (wallet.derivation == -1) {
derivationList.remove('root');
@ -139,12 +137,6 @@ class _CustomDerivationState extends State<CustomDerivation> {
}
Navigator.pop(context);
Navigator.pop(context);
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) {
// return const WalletsHome();
// }),
// );
}
},
child: Text(

View File

@ -27,11 +27,13 @@ class ImportG1v1 extends StatelessWidget {
Provider.of<MyWalletsProvider>(context, listen: false);
Timer? debounce;
const int debouneTime = 300;
const int debouneTime = 600;
WalletData selectedWallet = myWalletProvider.getDefaultWallet();
bool canValidate = false;
String validationStatus = '';
log.d(myWalletProvider.listWallets);
return WillPopScope(
onWillPop: () {
resetScreen(context);
@ -58,8 +60,6 @@ class ImportG1v1 extends StatelessWidget {
future: sub.getBalanceAndIdtyStatus(
sub.g1V1NewAddress, selectedWallet.address),
builder: (BuildContext context, AsyncSnapshot<List> status) {
// log.d(_certs.data);
if (status.data == null) {
return const Column(children: [
SizedBox(height: 80),
@ -79,13 +79,11 @@ class ImportG1v1 extends StatelessWidget {
}
final Map balance = status.data?[0] ?? {};
final String idtyStatus = status.data?[1];
final String myIdtyStatus = status.data?[2];
final IdtyStatus idtyStatus = status.data?[1];
final IdtyStatus myIdtyStatus = status.data?[2];
final bool hasConsumer = status.data?[3] ?? false;
final bool isSmith = status.data?[4] ?? false;
// log.d('hasconsumer: $hasConsumer');
if (balance['transferableBalance'] != 0 && !hasConsumer) {
canValidate = true;
validationStatus = '';
@ -96,7 +94,8 @@ class ImportG1v1 extends StatelessWidget {
: 'thisAccountIsEmpty'.tr();
}
if (idtyStatus != 'noid' && myIdtyStatus != 'noid') {
if (idtyStatus != IdtyStatus.none &&
myIdtyStatus != IdtyStatus.none) {
canValidate = false;
validationStatus =
'youCannotMigrateIdentityToExistingIdentity'.tr();

View File

@ -43,7 +43,7 @@ class ManageMembership extends StatelessWidget {
migrateIdentity(context),
const SizedBox(height: 10),
FutureBuilder(
future: sub.isSmithGet(address),
future: sub.isSmith(address),
builder: (BuildContext context, AsyncSnapshot<bool> isSmith) {
if (isSmith.data ?? false) {
return SizedBox(

View File

@ -96,8 +96,8 @@ class MigrateIdentityScreen extends StatelessWidget {
// log.d('statusData: ${status.data}');
final Map balance = status.data?[0] ?? {};
final String idtyStatus = status.data?[1];
final String myIdtyStatus = status.data?[2];
final IdtyStatus idtyStatus = status.data?[1];
final IdtyStatus myIdtyStatus = status.data?[2];
final bool hasConsumer = status.data?[3] ?? false;
final bool isSmith = status.data?[4] ?? false;
@ -110,7 +110,8 @@ class MigrateIdentityScreen extends StatelessWidget {
!hasConsumer) {
canValidate = true;
validationStatus = '';
} else if (idtyStatus != 'noid' && myIdtyStatus != 'noid') {
} else if (idtyStatus != IdtyStatus.none &&
myIdtyStatus != IdtyStatus.none) {
canValidate = false;
validationStatus =
'youCannotMigrateIdentityToExistingIdentity'.tr();

View File

@ -25,7 +25,6 @@ class RestoreChest extends StatelessWidget {
final genW = Provider.of<GenerateWalletsProvider>(context, listen: false);
final sub = Provider.of<SubstrateSdk>(context, listen: false);
genW.actualWallet = null;
if (genW.isSentenceComplete(context)) {
genW.generatedMnemonic =
'${genW.cellController0.text} ${genW.cellController1.text} ${genW.cellController2.text} ${genW.cellController3.text} ${genW.cellController4.text} ${genW.cellController5.text} ${genW.cellController6.text} ${genW.cellController7.text} ${genW.cellController8.text} ${genW.cellController9.text} ${genW.cellController10.text} ${genW.cellController11.text}';
@ -141,12 +140,13 @@ class RestoreChest extends StatelessWidget {
genW.pasteMnemonic(context);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const Icon(
Icons.content_paste_go,
size: 25,
size: 27,
),
const SizedBox(width: 10),
// const SizedBox(width: 10),
Text(
'pasteFromClipboard'.tr(),
textAlign: TextAlign.center,

View File

@ -242,21 +242,19 @@ class PrintWallet extends StatelessWidget {
await rootBundle.load("assets/OpenSans-Regular.ttf");
final pw.Font ttf = pw.Font.ttf(fontData.buffer.asByteData());
final pdf = pw.Document();
int nbr = 1;
final seedList = seed.split(' ');
// const imageProvider = AssetImage('assets/icon/gecko_final.png');
// final geckoLogo = await flutterImageProvider(imageProvider);
pw.Widget arrayCell(String dataWord, int nbr) {
nbr++;
const imageProvider = AssetImage('assets/icon/gecko_final.png');
final geckoLogo = await flutterImageProvider(imageProvider);
pw.Widget arrayCell(int number, String dataWord) {
return pw.SizedBox(
width: 120,
height: 70,
child: pw.Column(children: <pw.Widget>[
pw.Text(
nbr.toString(),
number.toString(),
style: pw.TextStyle(
fontSize: 15, color: const PdfColor(0.5, 0, 0), font: ttf),
),
@ -274,38 +272,44 @@ class PrintWallet extends StatelessWidget {
pw.Page(
pageFormat: PdfPageFormat.a4,
build: (context) {
return pw.Column(
// mainAxisAlignment: pw.MainAxisAlignment.center,
// mainAxisSize: pw.MainAxisSize.max,
// crossAxisAlignment: pw.CrossAxisAlignment.center,
children: <pw.Widget>[
pw.Row(children: <pw.Widget>[
arrayCell(seedList[0], nbr),
arrayCell(seedList[1], nbr),
arrayCell(seedList[2], nbr),
arrayCell(seedList[3], nbr),
]),
pw.Row(children: <pw.Widget>[
arrayCell(seedList[4], nbr),
arrayCell(seedList[5], nbr),
arrayCell(seedList[6], nbr),
arrayCell(seedList[7], nbr),
]),
pw.Row(children: <pw.Widget>[
arrayCell(seedList[8], nbr),
arrayCell(seedList[9], nbr),
arrayCell(seedList[10], nbr),
arrayCell(seedList[11], nbr)
]),
pw.Expanded(
child: pw.Align(
alignment: pw.Alignment.bottomCenter,
child: pw.Text(
"Gardez cette feuille préciseusement, à labri des lézards indiscrets.",
style: pw.TextStyle(fontSize: 15, font: ttf),
)))
],
);
return pw.Stack(children: <pw.Widget>[
pw.Positioned(top: 217, child: pw.Text('-'.padRight(130, '-'))),
pw.Positioned(bottom: 217, child: pw.Text('-'.padRight(130, '-'))),
pw.Column(
// mainAxisAlignment: pw.MainAxisAlignment.center,
// mainAxisSize: pw.MainAxisSize.max,
// crossAxisAlignment: pw.CrossAxisAlignment.center,
children: <pw.Widget>[
pw.SizedBox(height: 10),
pw.Row(children: <pw.Widget>[
arrayCell(1, seedList[0]),
arrayCell(2, seedList[1]),
arrayCell(3, seedList[2]),
arrayCell(4, seedList[3]),
]),
pw.Row(children: <pw.Widget>[
arrayCell(5, seedList[4]),
arrayCell(6, seedList[5]),
arrayCell(7, seedList[6]),
arrayCell(8, seedList[7]),
]),
pw.Row(children: <pw.Widget>[
arrayCell(9, seedList[8]),
arrayCell(10, seedList[9]),
arrayCell(11, seedList[10]),
arrayCell(12, seedList[11])
]),
pw.SizedBox(height: 105),
pw.Image(geckoLogo, height: 80),
pw.SizedBox(height: 205),
pw.Text(
"keepThisPaperSafe".tr(),
textAlign: pw.TextAlign.center,
style: pw.TextStyle(fontSize: 15, font: ttf),
)
],
)
]);
},
),
);

View File

@ -42,17 +42,13 @@ class WalletOptions extends StatelessWidget {
final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false);
final sub = Provider.of<SubstrateSdk>(context, listen: false);
// sub.spawnBlock();
// sub.spawnBlock(0, 20);
log.d(walletOptions.address.text);
walletOptions.address.text = wallet.address;
final currentChest = myWalletProvider.getCurrentChest();
bool isWalletNameIndexed =
final isWalletNameIndexed =
duniterIndexer.walletNameIndexer[walletOptions.address.text] != null;
// final currentWallet = _myWalletProvider.getDefaultWallet();
// log.d(_walletOptions.getAddress(_currentChest, 3));
log.d("Wallet options: $currentChest:${wallet.derivation}");
return WillPopScope(
@ -147,7 +143,8 @@ class WalletOptions extends StatelessWidget {
wallet: wallet,
size: 29,
color: Colors.black,
fontWeight: wallet.isMember
fontWeight: wallet.identityStatus ==
IdtyStatus.validated
? FontWeight.w500
: FontWeight.w400,
fontStyle: FontStyle.normal);
@ -185,7 +182,9 @@ class WalletOptions extends StatelessWidget {
address: walletProvider.address.text, size: 24),
const SizedBox(width: 30),
InkWell(
onTap: () => isWalletNameIndexed
onTap: () => sub.certsCounterCache[
walletProvider.address.text] !=
null
? {
Navigator.push(
context,
@ -194,9 +193,10 @@ class WalletOptions extends StatelessWidget {
address:
walletProvider.address.text,
username: duniterIndexer
.walletNameIndexer[
walletProvider
.address.text]!);
.walletNameIndexer[
walletProvider
.address.text] ??
'');
}),
),
}
@ -263,28 +263,16 @@ class WalletOptions extends StatelessWidget {
walletOptions,
currentChest),
SizedBox(height: 17 * ratio),
// walletProvider.isMember(context, _walletOptions.address.text)
FutureBuilder(
future:
sub.isMember(walletOptions.address.text),
builder: (BuildContext context,
AsyncSnapshot<bool> isMember) {
if (isMember.connectionState !=
ConnectionState.done ||
isMember.hasError) {
return const Text('');
}
return Column(children: [
if (!walletProvider.isDefaultWallet &&
!isMember.data!)
deleteWallet(context, walletProvider,
currentChest)
else
const SizedBox(),
if (isMember.data!)
const ManageMembershipButton()
]);
}),
Column(children: [
if (!walletProvider.isDefaultWallet &&
!wallet.isMembre())
deleteWallet(
context, walletProvider, currentChest)
else
const SizedBox(),
if (wallet.isMembre())
const ManageMembershipButton()
])
]);
}),
]),
@ -352,10 +340,11 @@ class WalletOptions extends StatelessWidget {
Widget confirmIdentityButton(WalletOptionsProvider walletProvider) {
return Consumer<SubstrateSdk>(builder: (context, sub, _) {
return FutureBuilder(
future: sub.idtyStatus(walletProvider.address.text),
initialData: '',
builder: (context, snapshot) {
if (snapshot.data == 'Created') {
future: sub.idtyStatus([walletProvider.address.text]),
initialData: const [IdtyStatus.unknown],
builder:
(BuildContext context, AsyncSnapshot<List<IdtyStatus>> snapshot) {
if (snapshot.data!.first == IdtyStatus.created) {
return Column(children: [
SizedBox(
width: 320,
@ -554,7 +543,7 @@ class WalletOptions extends StatelessWidget {
// WalletData defaultWallet = _myWalletProvider.getDefaultWallet()!;
// defaultWallet = wallet;
await sub.setCurrentWallet(wallet);
myWalletProvider.readAllWallets(currentChest);
await myWalletProvider.readAllWallets(currentChest);
myWalletProvider.reload();
walletOptions.reload();
}
@ -587,9 +576,9 @@ class WalletOptions extends StatelessWidget {
onTap: canDelete
? () async {
await walletOptions.deleteWallet(context, wallet);
WidgetsBinding.instance.addPostFrameCallback((_) {
WidgetsBinding.instance.addPostFrameCallback((_) async {
myWalletProvider.listWallets =
myWalletProvider.readAllWallets(currentChest);
await myWalletProvider.readAllWallets(currentChest);
myWalletProvider.reload();
});
}

View File

@ -1,8 +1,6 @@
// ignore_for_file: use_build_context_synchronously
import 'dart:io';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/chest_data.dart';
import 'package:gecko/models/widgets_keys.dart';
@ -10,19 +8,15 @@ import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/models/wallet_data.dart';
import 'package:flutter/material.dart';
import 'package:gecko/providers/substrate_sdk.dart';
import 'package:gecko/providers/wallet_options.dart';
import 'package:gecko/screens/myWallets/chest_options.dart';
import 'package:gecko/screens/myWallets/import_g1_v1.dart';
import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
import 'package:gecko/screens/myWallets/wallet_options.dart';
import 'package:gecko/widgets/balance.dart';
import 'package:gecko/widgets/bottom_app_bar.dart';
import 'package:gecko/widgets/buttons/add_new_derivation_button.dart';
import 'package:gecko/widgets/buttons/chest_options_buttons.dart';
import 'package:gecko/widgets/commons/offline_info.dart';
import 'package:gecko/widgets/commons/smooth_transition.dart';
import 'package:gecko/widgets/name_by_address.dart';
import 'package:gecko/widgets/payment_popup.dart';
import 'package:gecko/widgets/drag_tule_action.dart';
import 'package:gecko/widgets/drag_wallets_info.dart';
import 'package:gecko/widgets/wallet_tile.dart';
import 'package:gecko/widgets/wallet_tile_membre.dart';
import 'package:provider/provider.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:tutorial_coach_mark/tutorial_coach_mark.dart';
class WalletsHome extends StatefulWidget {
@ -40,12 +34,11 @@ class _WalletsHomeState extends State<WalletsHome> {
@override
Widget build(BuildContext context) {
final myWalletProvider = Provider.of<MyWalletsProvider>(context);
final myWalletProvider =
Provider.of<MyWalletsProvider>(context, listen: false);
final currentChestNumber = myWalletProvider.getCurrentChest();
final ChestData currentChest = chestBox.get(currentChestNumber)!;
myWalletProvider.listWallets =
myWalletProvider.readAllWallets(currentChestNumber);
return WillPopScope(
onWillPop: () {
@ -81,147 +74,47 @@ class _WalletsHomeState extends State<WalletsHome> {
),
backgroundColor: const Color(0xffFFD58D),
),
bottomNavigationBar: myWalletProvider.lastFlyBy == ''
? const GeckoBottomAppBar(
actualRoute: 'safeHome',
)
: dragInfo(context),
body: SafeArea(
child: Stack(children: [
myWalletsTiles(context, currentChestNumber),
const OfflineInfo(),
]),
),
),
);
}
Widget dragInfo(BuildContext context) {
final myWalletProvider =
Provider.of<MyWalletsProvider>(context, listen: false);
final walletDataFrom =
myWalletProvider.getWalletDataByAddress(myWalletProvider.dragAddress);
final walletDataTo =
myWalletProvider.getWalletDataByAddress(myWalletProvider.lastFlyBy);
final bool isSameAddress =
myWalletProvider.dragAddress == myWalletProvider.lastFlyBy;
final screenWidth = MediaQuery.of(homeContext).size.width;
return Container(
color: yellowC,
width: screenWidth,
height: 80,
child: Center(
child: Column(
children: [
const SizedBox(height: 5),
Text('${'executeATransfer'.tr()}:'),
MarkdownBody(data: '${'from'.tr()} **${walletDataFrom!.name}**'),
if (isSameAddress) Text('chooseATargetWallet'.tr()),
if (!isSameAddress)
MarkdownBody(data: 'Vers: **${walletDataTo!.name}**'),
],
)),
);
}
Widget chestOptions(BuildContext context, final myWalletProvider) {
return Column(children: [
const SizedBox(height: 50),
SizedBox(
height: 80,
width: 420,
child: ElevatedButton.icon(
icon: Image.asset(
'assets/chests/config.png',
height: 60,
),
style: ElevatedButton.styleFrom(
foregroundColor: Colors.black, elevation: 2,
backgroundColor: floattingYellow, // foreground
),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return ChestOptions(walletProvider: myWalletProvider);
}),
),
label: Text(
" ${"manageChest".tr()}",
style: const TextStyle(
fontSize: 22,
fontWeight: FontWeight.w700,
color: Color(0xff8a3c0f),
),
),
)),
const SizedBox(height: 30),
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();
}),
bottomNavigationBar:
Consumer<MyWalletsProvider>(builder: (context, _, __) {
return myWalletProvider.lastFlyBy == null
? const GeckoBottomAppBar(
actualRoute: 'safeHome',
)
: DragWalletsInfo(
lastFlyBy: myWalletProvider.lastFlyBy!,
dragAddress: myWalletProvider.dragAddress!,
);
}),
body: FutureBuilder(
future: myWalletProvider.readAllWallets(currentChestNumber),
builder: (context, snapshot) {
if (snapshot.connectionState != ConnectionState.done ||
snapshot.hasError) {
return const Center(
child: SizedBox(
height: 50,
width: 50,
child: CircularProgressIndicator(
color: orangeC,
strokeWidth: 3,
),
),
);
}
return SafeArea(
child: Stack(children: [
myWalletsTiles(context, currentChestNumber),
const OfflineInfo(),
]),
);
},
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: 20),
InkWell(
key: keyChangeChest,
onTap: () {
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) {
// return const ChooseChest();
// }),
// );
},
child: SizedBox(
width: 400,
height: 60,
child: Center(
child: Text('changeChest'.tr(),
style: const TextStyle(
fontSize: 22,
color: Colors.grey, //orangeC
fontWeight: FontWeight.w500))),
),
),
const SizedBox(height: 30)
]);
);
}
Widget myWalletsTiles(BuildContext context, int currentChestNumber) {
final myWalletProvider = Provider.of<MyWalletsProvider>(context);
final walletOptions =
Provider.of<WalletOptionsProvider>(context, listen: false);
final bool isWalletsExists = myWalletProvider.checkIfWalletExist();
final sub = Provider.of<SubstrateSdk>(context, listen: false);
if (!isWalletsExists) {
return const Text('');
@ -244,7 +137,15 @@ class _WalletsHomeState extends State<WalletsHome> {
return Comparable.compare(p1.number!, p2.number!);
});
WalletData? defaultWallet = myWalletProvider.getDefaultWallet();
// Get first wallet with identity
final idtyWallet = listWallets.firstWhere(
(w) => w.hasIdentity(),
orElse: () => WalletData(address: ''),
);
List<WalletData> listWalletsWithoutIdty = listWallets.toList();
listWalletsWithoutIdty.removeWhere((w) => w.address == idtyWallet.address);
final screenWidth = MediaQuery.of(context).size.width;
int nTule;
@ -297,6 +198,13 @@ class _WalletsHomeState extends State<WalletsHome> {
return CustomScrollView(slivers: <Widget>[
const SliverToBoxAdapter(child: SizedBox(height: 20)),
if (idtyWallet.address != '')
SliverToBoxAdapter(
child: DragTuleAction(
wallet: idtyWallet,
child: WalletTileMembre(repository: idtyWallet),
),
),
SliverGrid.count(
key: keyListWallets,
crossAxisCount: nTule,
@ -304,327 +212,19 @@ class _WalletsHomeState extends State<WalletsHome> {
crossAxisSpacing: 0,
mainAxisSpacing: 0,
children: <Widget>[
for (WalletData repository in listWallets)
LongPressDraggable<String>(
delay: const Duration(milliseconds: 200),
data: repository.address,
dragAnchorStrategy:
(Draggable<Object> _, BuildContext __, Offset ___) =>
const Offset(0, 0),
// feedbackOffset: const Offset(-500, -500),
// dragAnchorStrategy: childDragAnchorStrategy,
onDragStarted: () =>
myWalletProvider.dragAddress = repository.address,
onDragEnd: (_) {
myWalletProvider.lastFlyBy = '';
myWalletProvider.dragAddress = '';
myWalletProvider.reload();
},
feedback: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
backgroundColor: orangeC,
shape: const CircleBorder(),
padding: const EdgeInsets.all(15),
),
child: const SizedBox(
height: 35,
child: Image(image: AssetImage('assets/vector_white.png')),
),
),
child: DragTarget<String>(
onAccept: (senderAddress) async {
log.d(
'INTERPAY: sender: $senderAddress --- receiver: ${repository.address}');
final walletData = myWalletProvider
.getWalletDataByAddress(senderAddress);
await sub.setCurrentWallet(walletData!);
sub.reload();
paymentPopup(
context,
repository.address,
g1WalletsBox.get(repository.address)!.username ??
repository.name!);
},
onMove: (details) {
if (repository.address != myWalletProvider.lastFlyBy) {
myWalletProvider.lastFlyBy = repository.address;
myWalletProvider.reload();
}
},
onWillAccept: (senderAddress) =>
senderAddress != repository.address,
builder: (
BuildContext context,
List<dynamic> accepted,
List<dynamic> rejected,
) {
return Padding(
padding: const EdgeInsets.all(16),
child: GestureDetector(
key: keyOpenWallet(repository.address),
onTap: () {
walletOptions.getAddress(
currentChestNumber, repository.derivation!);
Navigator.push(
context,
SmoothTransition(
page: WalletOptions(
wallet: repository,
),
),
);
},
child: SizedBox(
key: repository.number == 1
? keyDragAndDrop
: const Key('nothing'),
child: ClipOvalShadow(
shadow: const Shadow(
color: Colors.transparent,
offset: Offset(0, 0),
blurRadius: 5,
),
clipper: CustomClipperOval(),
child: ClipRRect(
borderRadius:
const BorderRadius.all(Radius.circular(12)),
child: Column(children: <Widget>[
Expanded(
child: Container(
width: double.infinity,
height: double.infinity,
decoration: const BoxDecoration(
gradient: RadialGradient(
radius: 0.8,
colors: [
Color.fromARGB(255, 255, 255, 211),
yellowC,
],
),
),
child:
// SvgPicture.asset('assets/chopp-gecko2.png',
// semanticsLabel: 'Gecko', height: 48),
repository.imageCustomPath == null ||
repository.imageCustomPath == ''
? Image.asset(
'assets/avatars/${repository.imageDefaultPath}',
alignment:
Alignment.bottomCenter,
scale: 0.5,
)
: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.transparent,
image: DecorationImage(
fit: BoxFit.fitHeight,
image: FileImage(
File(repository
.imageCustomPath!),
),
),
),
),
)),
Stack(children: <Widget>[
BalanceBuilder(
address: repository.address,
isDefault: repository.address ==
defaultWallet.address),
Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Column(
children: [
const SizedBox(height: 7),
Opacity(
opacity: 0.7,
child: NameByAddress(
wallet: repository,
size: 20,
color:
defaultWallet.address ==
repository.address
? Colors.white
: Colors.black,
fontWeight: FontWeight.w600,
fontStyle: FontStyle.normal,
))
],
),
],
),
]),
]),
),
),
),
),
);
}),
for (WalletData repository in listWalletsWithoutIdty)
DragTuleAction(
wallet: repository,
child: WalletTile(repository: repository),
),
Consumer<SubstrateSdk>(builder: (context, sub, _) {
return sub.nodeConnected
? addNewDerivation(context)
return sub.nodeConnected &&
myWalletProvider.listWallets.length < maxWalletsInSafe
? const AddNewDerivationButton()
: const Text('');
}),
]),
SliverToBoxAdapter(child: chestOptions(context, myWalletProvider)),
const SliverToBoxAdapter(child: ChestOptionsButtons()),
]);
}
Widget addNewDerivation(context) {
final myWalletProvider = Provider.of<MyWalletsProvider>(context);
String newDerivationName =
'${'wallet'.tr()} ${myWalletProvider.listWallets.last.number! + 2}';
return Padding(
padding: const EdgeInsets.all(16),
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(12)),
child: Column(children: <Widget>[
Expanded(
child: InkWell(
key: keyAddDerivation,
onTap: () async {
if (!myWalletProvider.isNewDerivationLoading) {
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 != '') {
await myWalletProvider.generateNewDerivation(
context, newDerivationName);
}
}
},
child: Container(
width: double.infinity,
height: double.infinity,
decoration: const BoxDecoration(color: floattingYellow),
child: Center(
child: myWalletProvider.isNewDerivationLoading
? const SizedBox(
height: 60,
width: 60,
child: CircularProgressIndicator(
color: orangeC,
strokeWidth: 7,
),
)
: const Text(
'+',
style: TextStyle(
fontSize: 150,
fontWeight: FontWeight.w700,
color: Color(0xFFFCB437)),
)),
)),
),
])));
}
}
class BalanceBuilder extends StatelessWidget {
const BalanceBuilder({
Key? key,
required this.address,
required this.isDefault,
}) : super(key: key);
final String address;
final bool isDefault;
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
color: isDefault ? orangeC : yellowC,
child: Padding(
padding:
const EdgeInsets.only(left: 5, right: 5, top: 38, bottom: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Opacity(
opacity: 0.7,
child: Balance(
address: address,
size: 16,
color: isDefault ? Colors.white : Colors.black,
loadingColor: isDefault ? yellowC : orangeC),
)
],
)),
);
}
}
class CustomClipperOval extends CustomClipper<Rect> {
@override
Rect getClip(Size size) {
return Rect.fromCircle(
center: Offset(size.width / 2, size.width / 2),
radius: size.width / 2 + 3);
}
@override
bool shouldReclip(CustomClipper<Rect> oldClipper) {
return false;
}
}
class ClipOvalShadow extends StatelessWidget {
final Shadow shadow;
final CustomClipper<Rect> clipper;
final Widget child;
const ClipOvalShadow({
Key? key,
required this.shadow,
required this.clipper,
required this.child,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return CustomPaint(
painter: _ClipOvalShadowPainter(
clipper: clipper,
shadow: shadow,
),
child: ClipRect(clipper: clipper, child: child),
);
}
}
class _ClipOvalShadowPainter extends CustomPainter {
final Shadow shadow;
final CustomClipper<Rect> clipper;
_ClipOvalShadowPainter({required this.shadow, required this.clipper});
@override
void paint(Canvas canvas, Size size) {
var paint = shadow.toPaint();
var clipRect = clipper.getClip(size).shift(const Offset(0, 0));
canvas.drawOval(clipRect, paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}

View File

@ -253,7 +253,7 @@ class OnboardingStepTen extends StatelessWidget {
isOwned: true);
await walletBox.put(myWallet.address, myWallet);
}
myWalletProvider.readAllWallets(currentChest);
await myWalletProvider.readAllWallets(currentChest);
myWalletProvider.reload();
generateWalletProvider.generatedMnemonic = '';

View File

@ -1,10 +1,8 @@
// ignore_for_file: file_names
import 'dart:math';
import 'package:confetti/confetti.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/widgets_keys.dart';
@ -91,17 +89,20 @@ Widget finishButton(BuildContext context) {
width: 380 * ratio,
height: 60 * ratio,
child: ElevatedButton(
key: keyGoWalletsHome,
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white, elevation: 4,
backgroundColor: orangeC, // foreground
),
onPressed: () {
Navigator.pushNamedAndRemoveUntil(
context, '/mywallets', ModalRoute.withName('/'));
},
child: Text("accessMyChest".tr(),
style:
TextStyle(fontSize: 22 * ratio, fontWeight: FontWeight.w600))),
key: keyGoWalletsHome,
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white,
elevation: 4,
backgroundColor: orangeC,
),
onPressed: () {
Navigator.pushNamedAndRemoveUntil(
context, '/mywallets', ModalRoute.withName('/'));
},
child: Text(
"accessMyChest".tr(),
style: TextStyle(fontSize: 22 * ratio, fontWeight: FontWeight.w600),
),
),
);
}

View File

@ -9,12 +9,12 @@ import 'package:gecko/models/widgets_keys.dart';
import 'package:gecko/providers/generate_wallets.dart';
import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/providers/wallets_profiles.dart';
import 'package:gecko/screens/myWallets/show_seed.dart';
import 'package:gecko/widgets/commons/build_progress_bar.dart';
import 'package:gecko/widgets/commons/build_text.dart';
import 'package:gecko/screens/onBoarding/6.dart';
import 'package:gecko/widgets/commons/fader_transition.dart';
import 'package:gecko/widgets/commons/offline_info.dart';
import 'package:printing/printing.dart';
import 'package:provider/provider.dart';
AsyncSnapshot<List>? mnemoList;
@ -63,14 +63,13 @@ class _ChooseChestState extends State<OnboardingStepFive> {
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
// const SizedBox(height: 10),
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return PrintWallet(
generateWalletProvider.generatedMnemonic);
generateWalletProvider.generatedMnemonic!);
}),
);
},
@ -79,7 +78,6 @@ class _ChooseChestState extends State<OnboardingStepFive> {
height: 42 * ratio,
),
),
SizedBox(
height: 40,
width: 120,
@ -221,44 +219,6 @@ Widget arrayCell(dataWord) {
);
}
class PrintWallet extends StatelessWidget {
const PrintWallet(this.sentence, {Key? key}) : super(key: key);
final String? sentence;
@override
Widget build(BuildContext context) {
final generateWalletProvider =
Provider.of<GenerateWalletsProvider>(context, listen: false);
return MaterialApp(
home: Scaffold(
appBar: AppBar(
leading: IconButton(
icon: const Icon(Icons.arrow_back, color: Colors.black),
onPressed: () {
Navigator.pop(context);
}),
backgroundColor: yellowC,
foregroundColor: Colors.black,
toolbarHeight: 60 * ratio,
title: const SizedBox(
height: 22,
child: Text(
'printMyMnemonic',
style: TextStyle(fontWeight: FontWeight.w600),
),
),
),
body: PdfPreview(
canDebug: false,
canChangeOrientation: false,
build: (format) => generateWalletProvider.printWallet(mnemoList),
),
),
);
}
}
Widget nextButton(
BuildContext context, String text, bool isFast, bool skipIntro) {
final generateWalletProvider =

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

@ -1,5 +1,4 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:gecko/globals.dart';
import 'package:flutter/material.dart';
import 'package:gecko/models/widgets_keys.dart';
@ -7,16 +6,19 @@ import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/providers/substrate_sdk.dart';
import 'package:gecko/providers/wallets_profiles.dart';
import 'package:provider/provider.dart';
// import 'package:gecko/models/home.dart';
// import 'package:provider/provider.dart';
class TransactionInProgress extends StatelessWidget {
const TransactionInProgress(
{Key? key, this.transType = 'pay', this.fromAddress, this.toAddress})
{Key? key,
this.transType = 'pay',
this.fromAddress,
this.toAddress,
this.toUsername})
: super(key: key);
final String transType;
final String? fromAddress;
final String? toAddress;
final String? toUsername;
@override
Widget build(BuildContext context) {
@ -26,271 +28,204 @@ class TransactionInProgress extends StatelessWidget {
final myWalletProvider =
Provider.of<MyWalletsProvider>(context, listen: false);
bool isValid = false;
String resultText;
bool isLoading = true;
bool isLoading = false;
final result = sub.transactionStatus;
log.d(walletProfiles.address);
final from = fromAddress ??
g1WalletsBox
.get(myWalletProvider.getDefaultWallet().address)
?.username ??
myWalletProvider.getDefaultWallet().name!;
String to = toAddress ?? walletProfiles.address;
to =
myWalletProvider.getWalletDataByAddress(to)?.name ?? getShortPubkey(to);
final from = fromAddress ?? myWalletProvider.getDefaultWallet().name!;
final to = toAddress ?? getShortPubkey(walletProfiles.address);
final amount = walletProfiles.payAmount.text;
String actionName = '';
final bool isUdUnit = configBox.get('isUdUnit') ?? false;
log.d("$transType :: $actionName :: $result");
final Map<String, String> actionMap = {
'pay': 'transaction'.tr(),
'cert': 'certification'.tr(),
'comfirmIdty': 'identityConfirm'.tr(),
'revokeIdty': 'revokeAdhesion'.tr(),
'identityMigration': 'identityMigration'.tr(),
};
switch (transType) {
case 'pay':
{
actionName = 'transaction'.tr();
}
break;
case 'cert':
{
actionName = 'certification'.tr();
}
break;
case 'comfirmIdty':
{
actionName = "identityConfirm".tr();
}
break;
case 'revokeIdty':
{
actionName = "revokeAdhesion".tr();
}
break;
case 'identityMigration':
{
actionName = "identityMigration".tr();
}
break;
default:
{
actionName = 'strangeTransaction'.tr();
}
String resultText = '';
final Map<String, String> resultMap = {
'': 'sending'.tr(),
'Ready': 'propagating'.tr(),
'Broadcast': 'validating'.tr(),
'cert.NotRespectCertPeriod': '24hbetweenCerts'.tr(),
'identity.CreatorNotAllowedToCreateIdty': '24hbetweenCerts'.tr(),
'cert.CannotCertifySelf': 'canNotCertifySelf'.tr(),
'identity.IdtyNameAlreadyExist': 'nameAlreadyExist'.tr(),
'balances.KeepAlive': '2GDtoKeepAlive'.tr(),
'1010: Invalid Transaction: Inability to pay some fees , e.g. account balance too low':
'youHaveToFeedThisAccountBeforeUsing'.tr(),
'Token.FundsUnavailable': 'fundsUnavailable'.tr(),
'Exception: timeout': 'execTimeoutOver'.tr(),
};
if (result.contains('blockHash: ')) {
isValid = true;
resultText = 'extrinsicValidated'
.tr(args: [actionMap[transType] ?? 'strangeTransaction'.tr()]);
log.i('Bloc of last transaction: ${sub.blocNumber} --- $result');
} else if (result.contains('Exception: ')) {
resultText = "${"anErrorOccurred".tr()}:\n";
final String exception = result.split('Exception: ')[1];
resultText = resultMap[exception] ?? "$resultText\n$exception";
log.d('Error: $exception');
} else {
isLoading = true;
resultText = resultMap[result] ?? 'unknown status...';
}
switch (result) {
case '':
{
resultText = 'sending'.tr();
}
break;
case 'Ready':
{
resultText = 'propagating'.tr();
}
break;
case 'Broadcast':
{
resultText = 'validating'.tr();
}
break;
default:
{
isLoading = false;
// jsonResult = json.decode(_result);
if (result.contains('blockHash: ')) {
isValid = true;
resultText = 'extrinsicValidated'.tr(args: [actionName]);
log.i(
'g1migration Bloc of last transaction: ${sub.blocNumber} --- $result');
} else {
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];
}
log.d('expection: $exceptionSplit');
switch (exception) {
case 'cert.NotRespectCertPeriod':
case 'identity.CreatorNotAllowedToCreateIdty':
{
resultText = "24hbetweenCerts".tr();
}
break;
case 'cert.CannotCertifySelf':
{
resultText = "canNotCertifySelf".tr();
}
break;
case 'identity.IdtyNameAlreadyExist':
{
resultText = "nameAlreadyExist".tr();
}
break;
case 'balances.KeepAlive':
{
resultText = "2GDtoKeepAlive".tr();
}
break;
case '1010: Invalid Transaction: Inability to pay some fees , e.g. account balance too low':
{
resultText = "youHaveToFeedThisAccountBeforeUsing".tr();
}
break;
case 'timeout':
{
resultText += "execTimeoutOver".tr();
}
break;
default:
{
resultText += "\n$exception";
}
break;
}
}
}
}
log.d("$transType :: ${actionMap[transType]} :: $result");
return WillPopScope(
onWillPop: () {
sub.transactionStatus = '';
onWillPop: () {
sub.transactionStatus = '';
Navigator.pop(context);
if (transType == 'identityMigration') {
Navigator.pop(context);
if (transType == 'pay' || transType == 'identityMigration') {
Navigator.pop(context);
}
return Future<bool>.value(true);
},
child: Scaffold(
backgroundColor: backgroundColor,
appBar: AppBar(
toolbarHeight: 60 * ratio,
elevation: 0,
automaticallyImplyLeading: false,
title: SizedBox(
height: 22,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('extrinsicInProgress'.tr(args: [actionName]))
]),
)),
body: SafeArea(
child: Align(
alignment: FractionalOffset.bottomCenter,
child: Column(children: <Widget>[
Container(
width: double.infinity,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
yellowC,
backgroundColor,
],
)),
child: Column(children: <Widget>[
const SizedBox(height: 10),
if (transType == 'pay')
Text(
isUdUnit
? 'ud'.tr(args: ['$amount '])
: '$amount $currencyName',
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 18, fontWeight: FontWeight.w600),
),
if (transType == 'pay') const SizedBox(height: 10),
}
return Future<bool>.value(true);
},
child: Scaffold(
backgroundColor: backgroundColor,
appBar: AppBar(
toolbarHeight: 60 * ratio,
elevation: 0,
automaticallyImplyLeading: false,
title: SizedBox(
height: 22,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('extrinsicInProgress'.tr(args: [
actionMap[transType] ?? 'strangeTransaction'.tr()
]))
]),
)),
body: SafeArea(
child: Align(
alignment: FractionalOffset.bottomCenter,
child: Column(children: <Widget>[
Container(
width: double.infinity,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
yellowC,
backgroundColor,
],
)),
child: Column(children: <Widget>[
const SizedBox(height: 10),
if (transType == 'pay')
Text(
'fromMinus'.tr(),
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 18),
),
Text(
from,
isUdUnit
? 'ud'.tr(args: ['$amount '])
: '$amount $currencyName',
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 18, fontWeight: FontWeight.w600),
),
const SizedBox(height: 10),
Text(
'toMinus'.tr(),
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 18),
),
Text(
to,
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 18, fontWeight: FontWeight.w600),
),
const SizedBox(height: 20),
]),
),
// const SizedBox(height: 20, width: double.infinity),
const Spacer(),
Column(children: [
Visibility(
visible: isLoading,
child: const SizedBox(
height: 18,
width: 18,
child: CircularProgressIndicator(
color: orangeC,
strokeWidth: 2,
),
),
if (transType == 'pay') const SizedBox(height: 10),
Text(
'fromMinus'.tr(),
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 18),
),
Visibility(
visible: !isLoading,
child: Icon(
isValid ? Icons.done_all : Icons.close,
size: 35,
color: isValid ? Colors.greenAccent : Colors.redAccent,
),
Text(
from,
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 18, fontWeight: FontWeight.w600),
),
const SizedBox(height: 10),
Text(
resultText,
'toMinus'.tr(),
textAlign: TextAlign.center,
style: TextStyle(fontSize: 19 * ratio),
style: const TextStyle(fontSize: 18),
),
Text(
toUsername ?? to,
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 18, fontWeight: FontWeight.w600),
),
const SizedBox(height: 20),
]),
const Spacer(),
Expanded(
child: Align(
alignment: Alignment.bottomCenter,
child: SizedBox(
width: 380 * ratio,
height: 60 * ratio,
child: ElevatedButton(
key: keyCloseTransactionScreen,
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white, elevation: 4,
backgroundColor: orangeC, // foreground
),
onPressed: () {
),
// const SizedBox(height: 20, width: double.infinity),
const Spacer(),
Column(children: [
Visibility(
visible: isLoading,
child: const SizedBox(
height: 18,
width: 18,
child: CircularProgressIndicator(
color: orangeC,
strokeWidth: 2,
),
),
),
Visibility(
visible: !isLoading,
child: Icon(
isValid ? Icons.done_all : Icons.close,
size: 35,
color: isValid ? Colors.greenAccent : Colors.redAccent,
),
),
const SizedBox(height: 10),
Text(
resultText,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 19 * ratio),
),
]),
const Spacer(),
Expanded(
child: Align(
alignment: Alignment.bottomCenter,
child: SizedBox(
width: 380 * ratio,
height: 60 * ratio,
child: ElevatedButton(
key: keyCloseTransactionScreen,
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white, elevation: 4,
backgroundColor: orangeC, // foreground
),
onPressed: () {
Navigator.pop(context);
sub.transactionStatus = '';
if (transType == 'identityMigration') {
Navigator.pop(context);
sub.transactionStatus = '';
if (transType == 'pay' ||
transType == 'identityMigration') {
Navigator.pop(context);
}
},
child: Text(
'close'.tr(),
style: TextStyle(
fontSize: 23 * ratio,
fontWeight: FontWeight.w600),
),
}
},
child: Text(
'close'.tr(),
style: TextStyle(
fontSize: 23 * ratio,
fontWeight: FontWeight.w600),
),
),
),
),
SizedBox(height: isTall ? 80 : 20)
])),
),
));
),
SizedBox(height: isTall ? 80 : 20)
])),
),
),
);
}
}

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;
@ -194,7 +194,7 @@ class WalletViewScreen extends StatelessWidget {
}
}
final toStatus = snapshot.data!['toStatus'] ?? 0;
final toStatus = snapshot.data!['toStatus'];
return Visibility(
visible: (snapshot.data != {}),
@ -272,7 +272,7 @@ class WalletViewScreen extends StatelessWidget {
),
const SizedBox(height: 9),
Text(
toStatus == 0
toStatus == null
? "certify".tr()
: "createIdentity".tr(),
textAlign: TextAlign.center,

View File

@ -1,5 +1,6 @@
// ignore_for_file: use_build_context_synchronously
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/wallet_data.dart';
@ -8,8 +9,6 @@ import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/providers/search.dart';
import 'package:gecko/providers/wallets_profiles.dart';
import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
import 'package:gecko/screens/myWallets/wallets_home.dart';
import 'package:gecko/screens/search.dart';
import 'package:provider/provider.dart';
class GeckoBottomAppBar extends StatelessWidget {
@ -39,23 +38,17 @@ class GeckoBottomAppBar extends StatelessWidget {
const SizedBox(width: 11),
IconButton(
key: keyAppBarSearch,
iconSize: 40,
icon: const Image(image: AssetImage('assets/loupe-noire.png')),
iconSize: 55,
icon: const Icon(Icons.home_outlined),
onPressed: () {
searchProvider.reload();
Navigator.popUntil(
context,
ModalRoute.withName('/'),
);
Navigator.push(
context,
MaterialPageRoute(builder: (homeContext) {
return const SearchScreen();
}),
);
},
),
const SizedBox(width: 22),
const SizedBox(width: 12),
const Spacer(),
IconButton(
key: keyAppBarQrcode,
@ -111,18 +104,15 @@ class GeckoBottomAppBar extends StatelessWidget {
),
);
}
if (pin != null || myWalletProvider.pinCode != '') {
Navigator.popUntil(
context,
ModalRoute.withName('/'),
);
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return const WalletsHome();
}),
);
// log.d(
// isRoutePresentInNavigator(context, '/mywallets'));
Navigator.popUntil(context, ModalRoute.withName('/'));
//FIXME: Should not have to wait 300 milliseconds when /mywallets exist in navigator...
sleep(const Duration(milliseconds: 300));
Navigator.pushNamed(context, '/mywallets');
// Navigator.pushNamedAndRemoveUntil(
// context, '/mywallets', ModalRoute.withName('/'));
}
},
),
@ -134,3 +124,15 @@ class GeckoBottomAppBar extends StatelessWidget {
);
}
}
bool isRoutePresentInNavigator(BuildContext context, String routeName) {
bool isPresent = false;
Navigator.popUntil(context, (route) {
log.d(route.settings.name);
if (route.settings.name == routeName) {
isPresent = true;
}
return true;
});
return isPresent;
}

View File

@ -0,0 +1,79 @@
// ignore_for_file: use_build_context_synchronously
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/wallet_data.dart';
import 'package:gecko/models/widgets_keys.dart';
import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
import 'package:provider/provider.dart';
class AddNewDerivationButton extends StatelessWidget {
const AddNewDerivationButton({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final myWalletProvider = Provider.of<MyWalletsProvider>(context);
String newDerivationName =
'${'wallet'.tr()} ${myWalletProvider.listWallets.last.number! + 2}';
return Padding(
padding: const EdgeInsets.all(16),
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(12)),
child: Column(children: <Widget>[
Expanded(
child: InkWell(
key: keyAddDerivation,
onTap: () async {
if (!myWalletProvider.isNewDerivationLoading) {
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 != '') {
await myWalletProvider.generateNewDerivation(
context, newDerivationName);
}
}
},
child: Container(
width: double.infinity,
height: double.infinity,
decoration: const BoxDecoration(color: floattingYellow),
child: Center(
child: myWalletProvider.isNewDerivationLoading
? const SizedBox(
height: 60,
width: 60,
child: CircularProgressIndicator(
color: orangeC,
strokeWidth: 7,
),
)
: const Text(
'+',
style: TextStyle(
fontSize: 150,
fontWeight: FontWeight.w700,
color: Color(0xFFFCB437)),
)),
)),
),
]),
),
);
}
}

View File

@ -0,0 +1,106 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/widgets_keys.dart';
import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/screens/myWallets/chest_options.dart';
import 'package:gecko/screens/myWallets/import_g1_v1.dart';
import 'package:provider/provider.dart';
class ChestOptionsButtons extends StatelessWidget {
const ChestOptionsButtons({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final myWalletProvider = Provider.of<MyWalletsProvider>(context);
return Column(children: [
const SizedBox(height: 50),
SizedBox(
height: 80,
width: 420,
child: ElevatedButton.icon(
icon: Image.asset(
'assets/chests/config.png',
height: 60,
),
style: ElevatedButton.styleFrom(
foregroundColor: Colors.black, elevation: 2,
backgroundColor: floattingYellow, // foreground
),
onPressed: () => Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return ChestOptions(walletProvider: myWalletProvider);
}),
),
label: Text(
" ${"manageChest".tr()}",
style: const TextStyle(
fontSize: 22,
fontWeight: FontWeight.w700,
color: Color(0xff8a3c0f),
),
),
)),
const SizedBox(height: 30),
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: 20),
InkWell(
key: keyChangeChest,
onTap: () {
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) {
// return const ChooseChest();
// }),
// );
},
child: SizedBox(
width: 400,
height: 60,
child: Center(
child: Text('changeChest'.tr(),
style: const TextStyle(
fontSize: 22,
color: Colors.grey, //orangeC
fontWeight: FontWeight.w500))),
),
),
const SizedBox(height: 30)
]);
}
}

View File

@ -9,7 +9,6 @@ import 'package:gecko/providers/home.dart';
import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/providers/wallets_profiles.dart';
import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
import 'package:gecko/screens/myWallets/wallets_home.dart';
import 'package:gecko/screens/search.dart';
import 'package:provider/provider.dart';
@ -105,12 +104,7 @@ class HomeButtons extends StatelessWidget {
);
}
if (pin != null || myWalletProvider.pinCode != '') {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return const WalletsHome();
}),
);
Navigator.pushNamed(context, '/mywallets');
}
},
child: Padding(

View File

@ -20,66 +20,62 @@ class CertTile extends StatelessWidget {
return Column(
children: listCerts.map((repository) {
// log.d('bbbbbbbbbbbbbbbbbbbbbb: ' + repository.toString());
return Column(children: <Widget>[
Padding(
padding: const EdgeInsets.only(right: 0),
child:
// Row(children: [Column(children: [],)],)
ListTile(
key: keyTransaction(keyID++),
contentPadding: const EdgeInsets.only(
left: 20, right: 30, top: 15, bottom: 15),
leading: ClipOval(
child: defaultAvatar(avatarSize),
child: ListTile(
key: keyTransaction(keyID++),
contentPadding: const EdgeInsets.only(
left: 20, right: 30, top: 15, bottom: 15),
leading: ClipOval(
child: defaultAvatar(avatarSize),
),
title: Padding(
padding: const EdgeInsets.only(bottom: 5),
child: Text(repository['name'],
style: const TextStyle(fontSize: 22)),
),
subtitle: RichText(
text: TextSpan(
style: TextStyle(
fontSize: 18,
color: Colors.grey[700],
),
title: Padding(
padding: const EdgeInsets.only(bottom: 5),
child: Text(repository['name'],
style: const TextStyle(fontSize: 22)),
),
subtitle: RichText(
text: TextSpan(
style: TextStyle(
fontSize: 18,
color: Colors.grey[700],
),
children: <TextSpan>[
TextSpan(
text: repository['date'],
),
if (repository[2] != '')
TextSpan(
text: ' · ',
style: TextStyle(
fontSize: 20,
color: Colors.grey[550],
),
),
TextSpan(
text: getShortPubkey(repository['address']),
style: TextStyle(
fontStyle: FontStyle.italic,
color: Colors.grey[600],
fontSize: 18),
),
],
children: <TextSpan>[
TextSpan(
text: repository['date'],
),
),
dense: false,
isThreeLine: false,
onTap: () {
Navigator.push(
homeContext,
MaterialPageRoute(builder: (context) {
return WalletViewScreen(
address: repository['address'],
username: repository['name'],
);
}),
if (repository[2] != '')
TextSpan(
text: ' · ',
style: TextStyle(
fontSize: 20,
color: Colors.grey[550],
),
),
TextSpan(
text: getShortPubkey(repository['address']),
style: TextStyle(
fontStyle: FontStyle.italic,
color: Colors.grey[600],
fontSize: 18),
),
],
),
),
dense: false,
isThreeLine: false,
onTap: () {
Navigator.push(
homeContext,
MaterialPageRoute(builder: (context) {
return WalletViewScreen(
address: repository['address'],
username: repository['name'],
);
}),
);
}),
),
]);
}).toList());

View File

@ -19,20 +19,19 @@ class Certifications extends StatelessWidget {
Consumer<SubstrateSdk>(builder: (context, sdk, _) {
return FutureBuilder(
future: sdk.getCertsCounter(address),
builder: (BuildContext context, AsyncSnapshot<List<int>> certs) {
// log.d(_certs.data);
return certs.data?[0] != 0 && certs.data != null
builder: (BuildContext context, AsyncSnapshot<List<int>?> certs) {
return certs.data != null
? Row(
children: [
Image.asset('assets/medal.png', height: 20),
Image.asset('assets/medal.png',
color: color, height: 20),
const SizedBox(width: 1),
Text(certs.data?[0].toString() ?? '0',
style: const TextStyle(fontSize: 20)),
style: TextStyle(fontSize: 20, color: color)),
const SizedBox(width: 5),
Text(
"(${certs.data?[1].toString() ?? '0'})",
style: const TextStyle(fontSize: 14),
style: TextStyle(fontSize: 14, color: color),
)
],
)

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

@ -0,0 +1,74 @@
// ignore_for_file: use_build_context_synchronously
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/wallet_data.dart';
import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/providers/substrate_sdk.dart';
import 'package:gecko/widgets/payment_popup.dart';
import 'package:provider/provider.dart';
class DragTuleAction extends StatelessWidget {
const DragTuleAction({Key? key, required this.wallet, required this.child})
: super(key: key);
final WalletData wallet;
final Widget child;
@override
Widget build(BuildContext context) {
final myWalletProvider = Provider.of<MyWalletsProvider>(context);
final sub = Provider.of<SubstrateSdk>(context, listen: false);
return LongPressDraggable<String>(
delay: const Duration(milliseconds: 200),
data: wallet.address,
dragAnchorStrategy: (Draggable<Object> _, BuildContext __, Offset ___) =>
const Offset(0, 0),
// feedbackOffset: const Offset(-500, -500),
// dragAnchorStrategy: childDragAnchorStrategy,
onDragStarted: () => myWalletProvider.dragAddress = wallet,
onDragEnd: (_) {
myWalletProvider.lastFlyBy = null;
myWalletProvider.dragAddress = null;
myWalletProvider.reload();
},
feedback: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
backgroundColor: orangeC,
shape: const CircleBorder(),
padding: const EdgeInsets.all(15),
),
child: const SizedBox(
height: 35,
child: Image(image: AssetImage('assets/vector_white.png')),
),
),
child: DragTarget<String>(
onAccept: (senderAddress) async {
log.d(
'INTERPAY: sender: $senderAddress --- receiver: ${wallet.address}');
final walletData =
myWalletProvider.getWalletDataByAddress(senderAddress);
await sub.setCurrentWallet(walletData!);
sub.reload();
paymentPopup(context, wallet.address,
g1WalletsBox.get(wallet.address)!.username ?? wallet.name!);
},
onMove: (details) {
if (wallet.address != myWalletProvider.lastFlyBy?.address) {
myWalletProvider.lastFlyBy = wallet;
myWalletProvider.reload();
}
},
onWillAccept: (senderAddress) => senderAddress != wallet.address,
builder: (
BuildContext context,
List<dynamic> accepted,
List<dynamic> rejected,
) {
return child;
}),
);
}
}

View File

@ -0,0 +1,47 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/wallet_data.dart';
import 'package:gecko/providers/duniter_indexer.dart';
import 'package:provider/provider.dart';
class DragWalletsInfo extends StatelessWidget {
const DragWalletsInfo(
{Key? key, required this.dragAddress, required this.lastFlyBy})
: super(key: key);
final WalletData dragAddress;
final WalletData lastFlyBy;
@override
Widget build(BuildContext context) {
final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false);
final bool isSameAddress = dragAddress == lastFlyBy;
final screenWidth = MediaQuery.of(homeContext).size.width;
final fromName = duniterIndexer.walletNameIndexer[dragAddress.address] ??
dragAddress.name;
final toName =
duniterIndexer.walletNameIndexer[lastFlyBy.address] ?? lastFlyBy.name;
return Container(
color: yellowC,
width: screenWidth,
height: 80,
child: Center(
child: Column(
children: [
const SizedBox(height: 5),
Text('${'executeATransfer'.tr()}:'),
MarkdownBody(data: '${'from'.tr()} **$fromName**'),
if (isSameAddress) Text('chooseATargetWallet'.tr()),
if (!isSameAddress) MarkdownBody(data: 'Vers: **$toName**'),
],
)),
);
}
}

View File

@ -31,6 +31,7 @@ class HeaderProfile extends StatelessWidget {
final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false);
final walletOptions =
Provider.of<WalletOptionsProvider>(context, listen: false);
final sub = Provider.of<SubstrateSdk>(context, listen: false);
return Stack(children: <Widget>[
Consumer<SubstrateSdk>(builder: (context, sub, _) {
@ -78,7 +79,7 @@ class HeaderProfile extends StatelessWidget {
Balance(address: address, size: 25),
const SizedBox(height: 9),
InkWell(
onTap: () => duniterIndexer.walletNameIndexer[address] != null
onTap: () => sub.certsCounterCache[address] != null
? {
Navigator.push(
context,
@ -86,7 +87,8 @@ class HeaderProfile extends StatelessWidget {
return CertificationsScreen(
address: address,
username: duniterIndexer
.walletNameIndexer[address]!);
.walletNameIndexer[address] ??
'');
}),
),
}

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

@ -2,7 +2,6 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/wallet_data.dart';
import 'package:gecko/providers/duniter_indexer.dart';
import 'package:gecko/providers/substrate_sdk.dart';
import 'package:gecko/widgets/commons/animated_text.dart';
import 'package:gecko/widgets/name_by_address.dart';
@ -21,75 +20,58 @@ class IdentityStatus extends StatelessWidget {
@override
Widget build(BuildContext context) {
final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false);
final walletData = walletBox.get(address) ?? WalletData(address: address);
return Consumer<SubstrateSdk>(builder: (context, sub, _) {
return FutureBuilder(
future: sub.idtyStatus(address),
initialData: '',
builder: (context, snapshot) {
duniterIndexer.idtyStatusCache[address] = snapshot.data.toString();
switch (snapshot.data.toString()) {
case 'noid':
walletData.isMember = false;
walletBox.put(address, walletData);
{
return showText('noIdentity'.tr());
}
case 'Created':
walletData.isMember = false;
walletBox.put(address, walletData);
{
return showText('identityCreated'.tr());
}
case 'ConfirmedByOwner':
walletData.isMember = false;
walletBox.put(address, walletData);
{
return isOwner
? showText('identityConfirmed'.tr())
: NameByAddress(
wallet: WalletData(address: address),
size: 20,
color: Colors.grey[700]!,
fontWeight: FontWeight.w500,
fontStyle: FontStyle.italic);
}
case 'Validated':
walletData.isMember = true;
walletBox.put(address, walletData);
{
return isOwner
? showText('memberValidated'.tr(), 18, true)
: NameByAddress(
wallet: WalletData(address: address),
size: 24,
color: Colors.black,
fontWeight: FontWeight.w600,
fontStyle: FontStyle.normal);
}
case 'expired':
walletData.isMember = false;
walletBox.put(address, walletData);
{
return showText('identityExpired'.tr());
}
future: sub.idtyStatus([address]),
initialData: [walletData.identityStatus],
builder: (context, AsyncSnapshot<List<IdtyStatus>> snapshot) {
final resStatus = snapshot.data!.first;
walletData.identityStatus = resStatus;
walletBox.put(address, walletData);
if (!isOwner) {
if (resStatus == IdtyStatus.confirmed) {
return NameByAddress(
wallet: WalletData(address: address),
size: 20,
color: Colors.grey[700]!,
fontWeight: FontWeight.w500,
fontStyle: FontStyle.italic);
} else if (resStatus == IdtyStatus.validated) {
return NameByAddress(
wallet: WalletData(address: address),
size: 24,
color: Colors.black,
fontWeight: FontWeight.w600,
fontStyle: FontStyle.normal);
}
}
final Map<IdtyStatus, String> statusText = {
IdtyStatus.none: 'noIdentity'.tr(),
IdtyStatus.created: 'identityCreated'.tr(),
IdtyStatus.confirmed: 'identityConfirmed'.tr(),
IdtyStatus.validated: 'memberValidated'.tr(),
IdtyStatus.expired: 'identityExpired'.tr(),
IdtyStatus.unknown: ''
};
return SizedBox(
child: showText('', 18, false, false),
child: showText(statusText[resStatus]!,
bold: resStatus == IdtyStatus.validated ? true : false),
);
});
});
}
AnimatedFadeOutIn showText(String text,
[double size = 18, bool bold = false, bool smooth = true]) {
{double size = 18, bool bold = false}) {
// log.d('$address $text');
return AnimatedFadeOutIn<String>(
data: text,
duration: Duration(milliseconds: smooth ? 200 : 0),
duration: const Duration(milliseconds: 150),
builder: (value) => Text(
value,
textAlign: TextAlign.center,

View File

@ -33,6 +33,10 @@ class NameByAddress extends StatelessWidget {
return WalletName(wallet: wallet, size: size, color: color);
}
// if (g1WalletsBox.get(wallet.address)?.username != null) {
// return Text(g1WalletsBox.get(wallet.address)!.username!);
// }
final httpLink = HttpLink(
'$indexerEndpoint/v1/graphql',
);
@ -47,12 +51,10 @@ class NameByAddress extends StatelessWidget {
client: client,
child: Query(
options: QueryOptions(
document: gql(
getNameByAddressQ), // this is the query string you just created
document: gql(getNameByAddressQ),
variables: {
'address': wallet.address,
},
// pollInterval: const Duration(seconds: 10),
),
builder: (QueryResult result,
{VoidCallback? refetch, FetchMore? fetchMore}) {
@ -76,8 +78,6 @@ class NameByAddress extends StatelessWidget {
username:
duniterIndexer.walletNameIndexer[wallet.address]));
// log.d(g1WalletsBox.toMap().values.first.username);
if (duniterIndexer.walletNameIndexer[wallet.address] == null) {
return WalletName(wallet: wallet, size: size, color: color);
}

View File

@ -13,10 +13,11 @@ import 'package:gecko/providers/wallets_profiles.dart';
import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
import 'package:gecko/screens/transaction_in_progress.dart';
import 'package:gecko/widgets/balance.dart';
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 =
@ -27,7 +28,8 @@ void paymentPopup(BuildContext context, String toAddress, String username) {
var defaultWallet = myWalletProvider.getDefaultWallet();
bool canValidate = false;
final amountFocus = FocusNode();
final dropdownKey = GlobalKey();
walletViewProvider.payAmount.text = '';
Future executeTransfert() async {
String? pin;
@ -56,14 +58,15 @@ void paymentPopup(BuildContext context, String toAddress, String username) {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return const TransactionInProgress();
return TransactionInProgress(
toAddress: toAddress, toUsername: username);
}),
);
}
}
myWalletProvider.readAllWallets();
log.d(myWalletProvider.listWallets);
myWalletProvider.readAllWallets().then((value) => myWalletProvider.listWallets
.sort((a, b) => a.derivation!.compareTo(b.derivation!)));
showModalBottomSheet<void>(
shape: const RoundedRectangleBorder(
@ -128,6 +131,7 @@ void paymentPopup(BuildContext context, String toAddress, String username) {
fontSize: 26, fontWeight: FontWeight.w700),
),
IconButton(
key: keyPopButton,
iconSize: 40,
icon: const Icon(Icons.cancel_outlined),
onPressed: () {
@ -145,68 +149,70 @@ void paymentPopup(BuildContext context, String toAddress, String username) {
),
const SizedBox(height: 10),
Consumer<SubstrateSdk>(builder: (context, sub, _) {
// TODO: about keyboard dismiss issue, should try this: https://stackoverflow.com/a/76352647/8301867
return DropdownButton(
dropdownColor: const Color(0xffffeed1),
elevation: 12,
key: dropdownKey,
value: defaultWallet,
// onTap: () async {
// await Future.delayed(const Duration(milliseconds: 10));
// amountFocus.requestFocus();
// },
selectedItemBuilder: (_) {
return myWalletProvider.listWallets
dropdownColor: const Color(0xffffeed1),
elevation: 12,
key: keyDropdownWallets,
value: defaultWallet,
menuMaxHeight: 300,
onTap: () {
FocusScope.of(context).requestFocus(amountFocus);
},
selectedItemBuilder: (_) {
return myWalletProvider.listWallets
.map((WalletData wallet) {
return Container(
width: 408,
decoration: BoxDecoration(
border: Border.all(
color: Colors.blueAccent.shade200,
width: 2),
borderRadius: const BorderRadius.all(
Radius.circular(10.0)),
),
padding: const EdgeInsets.all(10),
child: Visibility(
visible:
wallet.address == defaultWallet.address,
child: Row(children: [
NameByAddress(
wallet: wallet,
fontStyle: FontStyle.normal),
const Spacer(),
Balance(
address: wallet.address, size: 20),
]),
),
);
}).toList();
},
onChanged: (WalletData? newSelectedWallet) async {
defaultWallet = newSelectedWallet!;
await sub.setCurrentWallet(newSelectedWallet);
sub.reload();
amountFocus.requestFocus();
setState(() {});
},
items: myWalletProvider.listWallets
.map((WalletData wallet) {
return Container(
width: 408,
decoration: BoxDecoration(
border: Border.all(
color: Colors.blueAccent.shade200,
width: 2),
borderRadius: const BorderRadius.all(
Radius.circular(10.0)),
return DropdownMenuItem(
value: wallet,
key: keySelectThisWallet(wallet.address),
child: Container(
color: const Color(0xffffeed1),
width: 408,
height: 80,
padding: const EdgeInsets.all(10),
child: Row(children: [
NameByAddress(
wallet: wallet,
fontStyle: FontStyle.normal),
const Spacer(),
Balance(address: wallet.address, size: 20),
]),
),
padding: const EdgeInsets.all(10),
child: Row(children: [
Text(g1WalletsBox
.get(wallet.address)
?.username ??
wallet.name!),
const Spacer(),
Balance(address: wallet.address, size: 20),
]),
);
}).toList();
},
onChanged: (WalletData? newSelectedWallet) async {
defaultWallet = newSelectedWallet!;
await sub.setCurrentWallet(newSelectedWallet);
sub.reload();
amountFocus.requestFocus();
setState(() {});
},
items: myWalletProvider.listWallets
.map((WalletData wallet) {
return DropdownMenuItem(
value: wallet,
child: Container(
color: const Color(0xffffeed1),
width: 408,
height: 80,
padding: const EdgeInsets.all(10),
child: Row(children: [
Text(g1WalletsBox
.get(wallet.address)
?.username ??
wallet.name!),
const Spacer(),
Balance(address: wallet.address, size: 20),
]),
),
);
}).toList(),
);
}).toList());
}),
const SizedBox(height: 12),
Row(
@ -223,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,
@ -268,53 +272,61 @@ void paymentPopup(BuildContext context, String toAddress, String username) {
],
),
const SizedBox(height: 10),
TextField(
textInputAction: TextInputAction.done,
onEditingComplete: () async =>
canValidate ? await executeTransfert() : null,
key: keyAmountField,
controller: walletViewProvider.payAmount,
autofocus: true,
focusNode: amountFocus,
maxLines: 1,
textAlign: TextAlign.center,
keyboardType: const TextInputType.numberWithOptions(
decimal: true),
onChanged: (_) async {
fees = await sub.txFees(
defaultWallet.address,
toAddress,
double.parse(
walletViewProvider.payAmount.text == ''
? '0'
: walletViewProvider.payAmount.text));
log.d(fees);
setState(() {});
Focus(
onFocusChange: (focused) {
setState(() {
FocusScope.of(context).requestFocus(amountFocus);
});
},
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.deny(',',
replacementString: '.'),
FilteringTextInputFormatter.allow(
RegExp(r'(^\d+\.?\d{0,2})')),
],
decoration: InputDecoration(
hintText: '0.00',
suffix: Text(isUdUnit
? 'ud'.tr(args: [''])
: currencyName), // udUnitDisplay(40),
filled: true,
fillColor: Colors.transparent,
focusedBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.grey[500]!, width: 2),
borderRadius: BorderRadius.circular(8),
child: TextField(
textInputAction: TextInputAction.done,
onEditingComplete: () async =>
canValidate ? await executeTransfert() : null,
key: keyAmountField,
controller: walletViewProvider.payAmount,
autofocus: true,
focusNode: amountFocus,
maxLines: 1,
textAlign: TextAlign.center,
autocorrect: false,
keyboardType: const TextInputType.numberWithOptions(
decimal: true),
onChanged: (_) async {
fees = await sub.txFees(
defaultWallet.address,
toAddress,
double.parse(
walletViewProvider.payAmount.text == ''
? '0'
: walletViewProvider.payAmount.text));
log.d(fees);
setState(() {});
},
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.deny(',',
replacementString: '.'),
FilteringTextInputFormatter.allow(
RegExp(r'(^\d+\.?\d{0,2})')),
],
decoration: InputDecoration(
hintText: '0.00',
suffix: Text(isUdUnit
? 'ud'.tr(args: [''])
: currencyName), // udUnitDisplay(40),
filled: true,
fillColor: Colors.transparent,
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.grey[500]!, width: 2),
borderRadius: BorderRadius.circular(8),
),
contentPadding: const EdgeInsets.all(20),
),
style: const TextStyle(
fontSize: 35,
color: Colors.black,
fontWeight: FontWeight.w600,
),
contentPadding: const EdgeInsets.all(20),
),
style: const TextStyle(
fontSize: 35,
color: Colors.black,
fontWeight: FontWeight.w600,
),
),
const Spacer(),
@ -328,7 +340,10 @@ void paymentPopup(BuildContext context, String toAddress, String username) {
backgroundColor: orangeC, // foreground
),
onPressed: canValidate
? () async => await executeTransfert()
? () async {
Navigator.pop(context);
await executeTransfert();
}
: null,
child: Text(
'executeTheTransfer'.tr(),
@ -343,8 +358,9 @@ void paymentPopup(BuildContext context, String toAddress, String username) {
),
);
});
}).then((value) => walletViewProvider.payAmount.text = '');
});
}
//).then((value) => walletViewProvider.payAmount.text = ''
Future<void> infoFeesPopup(BuildContext context) async {
return showDialog<void>(

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,8 +100,8 @@ class SearchResult extends StatelessWidget {
walletsProfilesClass.address = g1Wallet.address;
return WalletViewScreen(
address: g1Wallet.address,
username: g1WalletsBox.get(g1Wallet)!.username ?? '',
avatar: g1WalletsBox.get(g1Wallet.address)?.avatar,
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,
);
}),
);

View File

@ -0,0 +1,211 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/wallet_data.dart';
import 'package:gecko/models/widgets_keys.dart';
import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/screens/myWallets/wallet_options.dart';
import 'package:gecko/widgets/balance.dart';
import 'package:gecko/widgets/commons/smooth_transition.dart';
import 'package:gecko/widgets/name_by_address.dart';
import 'package:provider/provider.dart';
class WalletTile extends StatelessWidget {
const WalletTile({
Key? key,
required this.repository,
}) : super(key: key);
final WalletData repository;
@override
Widget build(BuildContext context) {
final myWalletProvider = Provider.of<MyWalletsProvider>(context);
final defaultWallet = myWalletProvider.getDefaultWallet();
return Padding(
padding: const EdgeInsets.all(16),
child: GestureDetector(
key: keyOpenWallet(repository.address),
onTap: () {
Navigator.push(
context,
SmoothTransition(
page: WalletOptions(
wallet: repository,
),
),
);
},
child: SizedBox(
key: repository.number == 1 ? keyDragAndDrop : const Key('nothing'),
child: ClipOvalShadow(
shadow: const Shadow(
color: Colors.transparent,
offset: Offset(0, 0),
blurRadius: 5,
),
clipper: CustomClipperOval(),
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(12)),
child: Column(children: <Widget>[
Expanded(
child: Container(
width: double.infinity,
height: double.infinity,
decoration: const BoxDecoration(
gradient: RadialGradient(
radius: 0.8,
colors: [
Color.fromARGB(255, 255, 255, 211),
yellowC,
],
),
),
child: repository.imageCustomPath == null ||
repository.imageCustomPath == ''
? Image.asset(
'assets/avatars/${repository.imageDefaultPath}',
alignment: Alignment.bottomCenter,
scale: 0.5,
)
: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.transparent,
image: DecorationImage(
fit: BoxFit.fitHeight,
image: FileImage(
File(repository.imageCustomPath!),
),
),
),
),
)),
Stack(children: <Widget>[
BalanceBuilder(
address: repository.address,
isDefault: repository.address == defaultWallet.address),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
children: [
const SizedBox(height: 7),
Opacity(
opacity: 0.7,
child: NameByAddress(
wallet: repository,
size: 20,
color:
defaultWallet.address == repository.address
? Colors.white
: Colors.black,
fontWeight: FontWeight.w600,
fontStyle: FontStyle.normal,
))
],
),
],
),
]),
]),
),
),
),
),
);
}
}
class BalanceBuilder extends StatelessWidget {
const BalanceBuilder({
Key? key,
required this.address,
required this.isDefault,
}) : super(key: key);
final String address;
final bool isDefault;
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
color: isDefault ? orangeC : yellowC,
child: Padding(
padding:
const EdgeInsets.only(left: 5, right: 5, top: 38, bottom: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Opacity(
opacity: 0.7,
child: Balance(
address: address,
size: 16,
color: isDefault ? Colors.white : Colors.black,
loadingColor: isDefault ? yellowC : orangeC),
)
],
)),
);
}
}
class ClipOvalShadow extends StatelessWidget {
final Shadow shadow;
final CustomClipper<Rect> clipper;
final Widget child;
const ClipOvalShadow({
Key? key,
required this.shadow,
required this.clipper,
required this.child,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return CustomPaint(
painter: _ClipOvalShadowPainter(
clipper: clipper,
shadow: shadow,
),
child: ClipRect(clipper: clipper, child: child),
);
}
}
class _ClipOvalShadowPainter extends CustomPainter {
final Shadow shadow;
final CustomClipper<Rect> clipper;
_ClipOvalShadowPainter({required this.shadow, required this.clipper});
@override
void paint(Canvas canvas, Size size) {
var paint = shadow.toPaint();
var clipRect = clipper.getClip(size).shift(const Offset(0, 0));
canvas.drawOval(clipRect, paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}
class CustomClipperOval extends CustomClipper<Rect> {
@override
Rect getClip(Size size) {
return Rect.fromCircle(
center: Offset(size.width / 2, size.width / 2),
radius: size.width / 2 + 3);
}
@override
bool shouldReclip(CustomClipper<Rect> oldClipper) {
return false;
}
}

View File

@ -0,0 +1,231 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/wallet_data.dart';
import 'package:gecko/models/widgets_keys.dart';
import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/screens/myWallets/wallet_options.dart';
import 'package:gecko/widgets/balance.dart';
import 'package:gecko/widgets/certifications.dart';
import 'package:gecko/widgets/commons/smooth_transition.dart';
import 'package:gecko/widgets/name_by_address.dart';
import 'package:provider/provider.dart';
class WalletTileMembre extends StatelessWidget {
const WalletTileMembre({Key? key, required this.repository})
: super(key: key);
final WalletData repository;
@override
Widget build(BuildContext context) {
final myWalletProvider = Provider.of<MyWalletsProvider>(context);
final defaultWallet = myWalletProvider.getDefaultWallet();
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 70, vertical: 20),
child: GestureDetector(
key: keyOpenWallet(repository.address),
onTap: () {
Navigator.push(
context,
SmoothTransition(
page: WalletOptions(
wallet: repository,
),
),
);
},
child: SizedBox(
key: repository.number == 1 ? keyDragAndDrop : const Key('nothing'),
height: 240,
child: ClipOvalShadow(
shadow: const Shadow(
color: Colors.transparent,
offset: Offset(0, 0),
blurRadius: 5,
),
clipper: CustomClipperOval(),
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(12)),
child: Column(children: <Widget>[
Expanded(
child: Stack(
children: [
Container(
width: double.infinity,
height: double.infinity,
decoration: const BoxDecoration(
gradient: RadialGradient(
radius: 0.8,
colors: [
Color.fromARGB(255, 255, 255, 211),
yellowC,
],
),
),
child: repository.imageCustomPath == null ||
repository.imageCustomPath == ''
? Image.asset(
'assets/avatars/${repository.imageDefaultPath}',
alignment: Alignment.bottomCenter,
scale: 0.5,
)
: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.transparent,
image: DecorationImage(
fit: BoxFit.fitHeight,
image: FileImage(
File(repository.imageCustomPath!),
),
),
),
),
),
Positioned(
left: 25,
top: 25,
child: Opacity(
opacity: 0.6,
child: Image.asset('assets/medal.png',
color: Colors.black, height: 40),
),
),
],
),
),
Stack(children: <Widget>[
BalanceBuilder(
address: repository.address,
isDefault: repository.address == defaultWallet.address),
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Column(children: [
const SizedBox(height: 10),
Opacity(
opacity: 0.7,
child: NameByAddress(
wallet: repository,
size: 20,
color: defaultWallet.address == repository.address
? Colors.white
: Colors.black,
fontWeight: FontWeight.w600,
fontStyle: FontStyle.normal,
))
]),
]),
Positioned(
right: 25,
top: 25,
child: Opacity(
opacity: 0.7,
child: Certifications(
address: repository.address,
color: defaultWallet.address == repository.address
? Colors.white
: Colors.black,
size: 15),
),
),
]),
]),
),
),
),
),
);
}
}
class BalanceBuilder extends StatelessWidget {
const BalanceBuilder({
Key? key,
required this.address,
required this.isDefault,
}) : super(key: key);
final String address;
final bool isDefault;
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
color: isDefault ? orangeC : yellowC,
child: Padding(
padding:
const EdgeInsets.only(left: 5, right: 5, top: 45, bottom: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Opacity(
opacity: 0.7,
child: Balance(
address: address,
size: 16,
color: isDefault ? Colors.white : Colors.black,
loadingColor: isDefault ? yellowC : orangeC),
)
],
)),
);
}
}
class ClipOvalShadow extends StatelessWidget {
final Shadow shadow;
final CustomClipper<Rect> clipper;
final Widget child;
const ClipOvalShadow({
Key? key,
required this.shadow,
required this.clipper,
required this.child,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return CustomPaint(
painter: _ClipOvalShadowPainter(
clipper: clipper,
shadow: shadow,
),
child: ClipRect(clipper: clipper, child: child),
);
}
}
class _ClipOvalShadowPainter extends CustomPainter {
final Shadow shadow;
final CustomClipper<Rect> clipper;
_ClipOvalShadowPainter({required this.shadow, required this.clipper});
@override
void paint(Canvas canvas, Size size) {
var paint = shadow.toPaint();
var clipRect = clipper.getClip(size).shift(const Offset(0, 0));
canvas.drawOval(clipRect, paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}
class CustomClipperOval extends CustomClipper<Rect> {
@override
Rect getClip(Size size) {
return Rect.fromCircle(
center: Offset(size.width / 2, size.width / 2),
radius: size.width / 2 + 3);
}
@override
bool shouldReclip(CustomClipper<Rect> oldClipper) {
return false;
}
}

View File

@ -205,10 +205,10 @@ packages:
dependency: transitive
description:
name: built_value
sha256: "723b4021e903217dfc445ec4cf5b42e27975aece1fc4ebbc1ca6329c2d9fb54e"
sha256: "69acb7007eb2a31dc901512bfe0f7b767168be34cb734835d54c070bfa74c1b2"
url: "https://pub.dev"
source: hosted
version: "8.7.0"
version: "8.8.0"
carousel_slider:
dependency: "direct main"
description:
@ -233,14 +233,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
cli_util:
dependency: transitive
description:
name: cli_util
sha256: b8db3080e59b2503ca9e7922c3df2072cf13992354d5e944074ffa836fba43b7
url: "https://pub.dev"
source: hosted
version: "0.4.0"
clock:
dependency: transitive
description:
@ -253,10 +245,10 @@ packages:
dependency: transitive
description:
name: code_builder
sha256: "1be9be30396d7e4c0db42c35ea6ccd7cc6a1e19916b5dc64d6ac216b5544d677"
sha256: b2151ce26a06171005b379ecff6e08d34c470180ffe16b8e14b6d52be292b55f
url: "https://pub.dev"
source: hosted
version: "4.7.0"
version: "4.8.0"
collection:
dependency: transitive
description:
@ -301,10 +293,10 @@ packages:
dependency: transitive
description:
name: cross_file
sha256: "445db18de832dba8d851e287aff8ccf169bed30d2e94243cb54c7d2f1ed2142c"
sha256: "2f9d2cbccb76127ba28528cb3ae2c2326a122446a83de5a056aaa3880d3882c5"
url: "https://pub.dev"
source: hosted
version: "0.3.3+6"
version: "0.3.3+7"
crypto:
dependency: transitive
description:
@ -349,10 +341,10 @@ packages:
dependency: transitive
description:
name: dbus
sha256: "6f07cba3f7b3448d42d015bfd3d53fe12e5b36da2423f23838efc1d5fb31a263"
sha256: "365c771ac3b0e58845f39ec6deebc76e3276aa9922b0cc60840712094d9047ac"
url: "https://pub.dev"
source: hosted
version: "0.7.8"
version: "0.7.10"
decimal:
dependency: transitive
description:
@ -365,10 +357,10 @@ packages:
dependency: "direct main"
description:
name: dio
sha256: "417e2a6f9d83ab396ec38ff4ea5da6c254da71e4db765ad737a42af6930140b7"
sha256: "01870acd87986f768e0c09cc4d7a19a59d814af7b34cbeb0b437d2c33bdfea4c"
url: "https://pub.dev"
source: hosted
version: "5.3.3"
version: "5.3.4"
dots_indicator:
dependency: "direct main"
description:
@ -381,10 +373,10 @@ packages:
dependency: "direct main"
description:
name: durt
sha256: "1e1c494bd7cd8b372b89e5bc03c07f6e96aad5ef7d2159cfa28da3c181269678"
sha256: "97007458aa5ba95c78465af8489e1330d0f7d48c74e10699f6283ce4cf8a5410"
url: "https://pub.dev"
source: hosted
version: "0.1.6"
version: "0.1.7"
easy_localization:
dependency: "direct main"
description:
@ -510,16 +502,8 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.1.3"
flutter_dotenv:
dependency: "direct main"
description:
name: flutter_dotenv
sha256: "9357883bdd153ab78cbf9ffa07656e336b8bbb2b5a3ca596b0b27e119f7c7d77"
url: "https://pub.dev"
source: hosted
version: "5.1.0"
flutter_driver:
dependency: "direct main"
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
@ -539,22 +523,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.8.0"
flutter_launcher_icons:
flutter_lints:
dependency: "direct dev"
description:
name: flutter_launcher_icons
sha256: "526faf84284b86a4cb36d20a5e45147747b7563d921373d4ee0559c54fcdbcea"
url: "https://pub.dev"
source: hosted
version: "0.13.1"
flutter_lints:
dependency: "direct main"
description:
name: flutter_lints
sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04
sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7
url: "https://pub.dev"
source: hosted
version: "2.0.3"
version: "3.0.1"
flutter_localizations:
dependency: transitive
description: flutter
@ -688,7 +664,7 @@ packages:
source: hosted
version: "0.2.2+1"
graphql:
dependency: "direct main"
dependency: transitive
description:
name: graphql
sha256: b061201579040e9548cec2bae17bbdea0ab30666cb4e7ba48b9675f14d982199
@ -735,14 +711,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.1.0"
hive_generator:
dependency: "direct main"
description:
name: hive_generator
sha256: "06cb8f58ace74de61f63500564931f9505368f45f98958bd7a6c35ba24159db4"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
html:
dependency: transitive
description:
@ -795,34 +763,34 @@ packages:
dependency: "direct main"
description:
name: image_cropper
sha256: "710ab4b7953e9ce1d27d833f741e5f8f3afb0b0ba3556dc0b844741b5f55c2b3"
sha256: "542c3453109d16bcc388e43ae2276044d2cd6a6d20c68bdcff2c94ab9363ea15"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
version: "4.0.1"
image_cropper_for_web:
dependency: transitive
description:
name: image_cropper_for_web
sha256: "09e93a8ec0435adcaa23622ac090442872f18145d70b9ff605ffedcf97d56255"
sha256: "89c936aa772a35b69ca67b78049ae9fa163a4fb8da2f6dee3893db8883fb49d2"
url: "https://pub.dev"
source: hosted
version: "1.0.3"
version: "2.0.0"
image_cropper_platform_interface:
dependency: transitive
description:
name: image_cropper_platform_interface
sha256: "62349e3aab63873ea9b9ab9f69d036ab8a0d74b3004beec4303981386cb9273f"
sha256: b232175c132b2f7ede3e1f101652bcd635cb4079a77c6dded8e6d32e6578d685
url: "https://pub.dev"
source: hosted
version: "3.0.3"
version: "4.0.0"
image_picker:
dependency: "direct main"
description:
name: image_picker
sha256: b6951e25b795d053a6ba03af5f710069c99349de9341af95155d52665cb4607c
sha256: "7d7f2768df2a8b0a3cefa5ef4f84636121987d403130e70b17ef7e2cf650ba84"
url: "https://pub.dev"
source: hosted
version: "0.8.9"
version: "1.0.4"
image_picker_android:
dependency: transitive
description:
@ -936,18 +904,18 @@ packages:
dependency: transitive
description:
name: lints
sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "3.0.0"
logger:
dependency: "direct main"
description:
name: logger
sha256: "7ad7215c15420a102ec687bb320a7312afd449bac63bfb1c60d9787c27b9767f"
sha256: "6bbb9d6f7056729537a4309bda2e74e18e5d9f14302489cc1e93f33b3fe32cac"
url: "https://pub.dev"
source: hosted
version: "1.4.0"
version: "2.0.2+1"
logging:
dependency: transitive
description:
@ -1040,10 +1008,10 @@ packages:
dependency: "direct main"
description:
name: package_info_plus
sha256: "10259b111176fba5c505b102e3a5b022b51dd97e30522e906d6922c745584745"
sha256: "7e76fad405b3e4016cd39d08f455a4eb5199723cf594cd1b8916d47140d93017"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
version: "4.2.0"
package_info_plus_platform_interface:
dependency: transitive
description:
@ -1128,18 +1096,18 @@ packages:
dependency: "direct main"
description:
name: permission_handler
sha256: bc56bfe9d3f44c3c612d8d393bd9b174eb796d706759f9b495ac254e4294baa5
sha256: "284a66179cabdf942f838543e10413246f06424d960c92ba95c84439154fcac8"
url: "https://pub.dev"
source: hosted
version: "10.4.5"
version: "11.0.1"
permission_handler_android:
dependency: transitive
description:
name: permission_handler_android
sha256: "59c6322171c29df93a22d150ad95f3aa19ed86542eaec409ab2691b8f35f9a47"
sha256: f9fddd3b46109bd69ff3f9efa5006d2d309b7aec0f3c1c5637a60a2d5659e76e
url: "https://pub.dev"
source: hosted
version: "10.3.6"
version: "11.1.0"
permission_handler_apple:
dependency: transitive
description:
@ -1176,10 +1144,10 @@ packages:
dependency: "direct main"
description:
name: pin_code_fields
sha256: c8652519d14688f3fe2a8288d86910a46aa0b9046d728f292d3bf6067c31b4c7
sha256: "4c0db7fbc889e622e7c71ea54b9ee624bb70c7365b532abea0271b17ea75b729"
url: "https://pub.dev"
source: hosted
version: "7.4.0"
version: "8.0.1"
pinenacl:
dependency: "direct main"
description:
@ -1200,10 +1168,10 @@ packages:
dependency: transitive
description:
name: plugin_platform_interface
sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d
sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8
url: "https://pub.dev"
source: hosted
version: "2.1.6"
version: "2.1.7"
pointycastle:
dependency: "direct main"
description:
@ -1216,11 +1184,11 @@ packages:
dependency: "direct main"
description:
path: "."
ref: ff98a117e86060a91113107f31355a17ccfb346c
resolved-ref: ff98a117e86060a91113107f31355a17ccfb346c
ref: gecko-fixes-3
resolved-ref: ac7347e907ca30766eedb9e15583ebc20916d56c
url: "https://github.com/poka-IT/sdk.git"
source: git
version: "0.5.3"
version: "0.5.4+4"
pool:
dependency: transitive
description:
@ -1318,14 +1286,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.2.0"
riverpod:
dependency: "direct main"
description:
name: riverpod
sha256: "2e84315036e64c59affaff7443dea51247bc2fe704461a32f26a27986fb63d55"
url: "https://pub.dev"
source: hosted
version: "2.4.5"
rxdart:
dependency: transitive
description:
@ -1354,20 +1314,20 @@ packages:
dependency: transitive
description:
name: sentry
sha256: "9cfd325611ab54b57d5e26957466823f05bea9d6cfcc8d48f11817b8bcedf0d1"
sha256: e7ded42974bac5f69e4ca4ddc57d30499dd79381838f24b7e8fd9aa4139e7b79
url: "https://pub.dev"
source: hosted
version: "7.12.0"
version: "7.13.2"
sentry_flutter:
dependency: "direct main"
description:
name: sentry_flutter
sha256: "0cd7d622cb63c94fd1b2f87ab508e158b950bd281e2a80f327ebf73bb217eaf3"
sha256: d6f55ec7a1f681784165021f749007712a72ff57eadf91e963331b6ae326f089
url: "https://pub.dev"
source: hosted
version: "7.12.0"
version: "7.13.2"
shared_preferences:
dependency: "direct main"
dependency: transitive
description:
name: shared_preferences
sha256: "81429e4481e1ccfb51ede496e916348668fd0921627779233bd24cc3ff6abd02"
@ -1443,22 +1403,6 @@ packages:
description: flutter
source: sdk
version: "0.0.99"
source_gen:
dependency: transitive
description:
name: source_gen
sha256: fc0da689e5302edb6177fdd964efcb7f58912f43c28c2047a808f5bfff643d16
url: "https://pub.dev"
source: hosted
version: "1.4.0"
source_helper:
dependency: transitive
description:
name: source_helper
sha256: "6adebc0006c37dd63fe05bca0a929b99f06402fc95aa35bf36d67f5c06de01fd"
url: "https://pub.dev"
source: hosted
version: "1.3.4"
source_span:
dependency: transitive
description:
@ -1475,14 +1419,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.11.0"
state_notifier:
dependency: transitive
description:
name: state_notifier
sha256: b8677376aa54f2d7c58280d5a007f9e8774f1968d1fb1c096adcb4792fba29bb
url: "https://pub.dev"
source: hosted
version: "1.0.0"
stream_channel:
dependency: transitive
description:
@ -1575,10 +1511,10 @@ packages:
dependency: "direct main"
description:
name: unorm_dart
sha256: "5b35bff83fce4d76467641438f9e867dc9bcfdb8c1694854f230579d68cd8f4b"
sha256: "23d8bf65605401a6a32cff99435fed66ef3dab3ddcad3454059165df46496a3b"
url: "https://pub.dev"
source: hosted
version: "0.2.0"
version: "0.3.0"
url_launcher:
dependency: "direct main"
description:
@ -1599,10 +1535,10 @@ packages:
dependency: transitive
description:
name: url_launcher_ios
sha256: "4ac97281cf60e2e8c5cc703b2b28528f9b50c8f7cebc71df6bdf0845f647268a"
sha256: bba3373219b7abb6b5e0d071b0fe66dfbe005d07517a68e38d4fc3638f35c6d3
url: "https://pub.dev"
source: hosted
version: "6.2.0"
version: "6.2.1"
url_launcher_linux:
dependency: transitive
description:
@ -1743,34 +1679,34 @@ packages:
dependency: transitive
description:
name: webview_flutter
sha256: "392c1d83b70fe2495de3ea2c84531268d5b8de2de3f01086a53334d8b6030a88"
sha256: "42393b4492e629aa3a88618530a4a00de8bb46e50e7b3993fedbfdc5352f0dbf"
url: "https://pub.dev"
source: hosted
version: "3.0.4"
version: "4.4.2"
webview_flutter_android:
dependency: transitive
description:
name: webview_flutter_android
sha256: "8b3b2450e98876c70bfcead876d9390573b34b9418c19e28168b74f6cb252dbd"
sha256: "8326ee235f87605a2bfc444a4abc897f4abc78d83f054ba7d3d1074ce82b4fbf"
url: "https://pub.dev"
source: hosted
version: "2.10.4"
version: "3.12.1"
webview_flutter_platform_interface:
dependency: transitive
description:
name: webview_flutter_platform_interface
sha256: "812165e4e34ca677bdfbfa58c01e33b27fd03ab5fa75b70832d4b7d4ca1fa8cf"
sha256: adb8c03c2be231bea5a8ed0e9039e9d18dbb049603376beaefa15393ede468a5
url: "https://pub.dev"
source: hosted
version: "1.9.5"
version: "2.7.0"
webview_flutter_wkwebview:
dependency: transitive
description:
name: webview_flutter_wkwebview
sha256: a5364369c758892aa487cbf59ea41d9edd10f9d9baf06a94e80f1bd1b4c7bbc0
sha256: accdaaa49a2aca2dc3c3230907988954cdd23fed0a19525d6c9789d380f4dc76
url: "https://pub.dev"
source: hosted
version: "2.9.5"
version: "3.9.4"
win32:
dependency: transitive
description:

View File

@ -3,30 +3,27 @@ description: Pay with G1.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
publish_to: "none" # Remove this line if you wish to publish to pub.dev
version: 0.1.1+58
version: 0.1.2+59
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_driver:
sdk: flutter
bubble: ^1.2.1
carousel_slider: ^4.0.0
flutter_lints: ^2.0.1
graphql_flutter: ^5.1.1-beta.4
hive_flutter: ^1.1.0
image_picker: ^0.8.4
image_picker: ^1.0.4
jdenticon_dart: ^2.0.0
logger: ^1.1.0
logger: ^2.0.2+1
path_provider: ^2.0.11
pdf: ^3.7.1
permission_handler: ^10.0.0
pin_code_fields: ^7.4.0
permission_handler: ^11.0.1
pin_code_fields: ^8.0.1
printing: ^5.10.1
provider: ^6.0.1
barcode_scan2: ^4.2.1
@ -36,34 +33,29 @@ dependencies:
ref: master
responsive_framework: 0.2.0
sentry_flutter: ^7.4.1
shared_preferences: ^2.0.7
truncate: ^3.0.1
unorm_dart: ^0.2.0
unorm_dart: ^0.3.0
dio: ^5.0.1
durt: ^0.1.6
package_info_plus: ^3.0.2
package_info_plus: ^4.2.0
polkawallet_sdk: #^0.5.2
git:
# url: https://github.com/polkawallet-io/sdk.git
# ref: develop
url: https://github.com/poka-IT/sdk.git
# ref: gecko-fixes-2
ref: ff98a117e86060a91113107f31355a17ccfb346c
ref: gecko-fixes-3
# ref: ff98a117e86060a91113107f31355a17ccfb346c
dots_indicator: ^3.0.0
connectivity_plus: ^3.0.2
image_cropper: ^3.0.0
image_cropper: ^4.0.1
easy_localization: ^3.0.1
flutter_markdown: ^0.6.10+2
pointycastle: ^3.6.1
hex: ^0.2.0
flutter_dotenv: ^5.0.2
accordion: ^2.5.1
flutter_svg: ^2.0.2
pinenacl: ^0.3.3
fast_base58: ^0.2.1
graphql: ^5.1.1
hive_generator: ^2.0.0
riverpod: ^2.1.1
tutorial_coach_mark: ^1.2.8
confetti: ^0.7.0
url_launcher: ^6.1.11
@ -71,9 +63,9 @@ dependencies:
dev_dependencies:
# flutter_launcher_icons: ^0.9.2
# flutter_launcher_icons_maker: ^^0.10.2
flutter_launcher_icons: ^0.13.0
icons_launcher: ^2.0.6
build_runner: ^2.1.2
flutter_lints: ^3.0.1
flutter_test:
sdk: flutter
integration_test:
@ -81,7 +73,7 @@ dev_dependencies:
dart_code_metrics: ^5.0.1
icons_launcher:
image_path: 'assets/icon/gecko_flat.png'
image_path: "assets/icon/gecko_flat.png"
platforms:
android:
enable: true
@ -112,4 +104,4 @@ flutter:
- assets/onBoarding/
- assets/onBoarding/progress_bar/
- assets/walletOptions/
- sounds/
- sounds/

View File

@ -1,4 +1,4 @@
#!/bin/bash
flutter packages pub run build_runner build --delete-conflicting-outputs
dart run build_runner build --delete-conflicting-outputs