Merge branch 'importCsAccounts' into 'master'
Import cs accounts See merge request clients/gecko!27
This commit is contained in:
commit
5369599b20
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
|
@ -147,6 +147,7 @@
|
||||||
"execTimeoutOver": "Execution timeout is over",
|
"execTimeoutOver": "Execution timeout is over",
|
||||||
"seeAWallet": "See a wallet",
|
"seeAWallet": "See a wallet",
|
||||||
"mustWaitXBeforeCertify": "You have to wait\n{} before\ncertifying again",
|
"mustWaitXBeforeCertify": "You have to wait\n{} before\ncertifying again",
|
||||||
|
"mustConfirmHisIdentity": "This person must confirm\nhis identity before can be\ncertified",
|
||||||
"canRenewCertInX": "You can renew\nthis certification\nin {}",
|
"canRenewCertInX": "You can renew\nthis certification\nin {}",
|
||||||
"executeATransfer": "Execute a transfer",
|
"executeATransfer": "Execute a transfer",
|
||||||
"executeTheTransfer": "Execute the transfer",
|
"executeTheTransfer": "Execute the transfer",
|
||||||
|
@ -174,5 +175,18 @@
|
||||||
"noContacts": "You don't have any contact",
|
"noContacts": "You don't have any contact",
|
||||||
"addContact": "Add\nto contacts",
|
"addContact": "Add\nto contacts",
|
||||||
"removeContact": "Remove\nthis contact",
|
"removeContact": "Remove\nthis contact",
|
||||||
"derivationsScanProgress": "Scan address {}/{}"
|
"derivationsScanProgress": "Scan address {}/{}",
|
||||||
|
"youAreOffline": "You are offline...",
|
||||||
|
"importG1v1": "Import old G1v1 account",
|
||||||
|
"selectDestWallet": "Select a target wallet:",
|
||||||
|
"youMustWaitBeforeCashoutThisAccount": "You have to wait {} minutes\nbefore migrate this account",
|
||||||
|
"thisAccountIsEmpty": "This account is empty",
|
||||||
|
"youCannotMigrateIdentityToExistingIdentity": "You cannot migrate an identity\nto an account that already has an identity",
|
||||||
|
"importOldAccount": "Import your old account",
|
||||||
|
"enterCesiumId": "Enter your Cesium ID",
|
||||||
|
"enterCesiumPassword": "Enter your Cesium password",
|
||||||
|
"migrateAccount": "Migrate account",
|
||||||
|
"migrateIdentity": "Migrate identity",
|
||||||
|
"identityMigration": "Identity migration",
|
||||||
|
"areYouSureMigrateIdentity": "Are you sure you want to permanently migrate identity **{}** with balance of **{}** ?"
|
||||||
}
|
}
|
|
@ -147,6 +147,7 @@
|
||||||
"execTimeoutOver": "Execution timeout is over",
|
"execTimeoutOver": "Execution timeout is over",
|
||||||
"seeAWallet": "See a wallet",
|
"seeAWallet": "See a wallet",
|
||||||
"mustWaitXBeforeCertify": "You have to wait\n{} before\ncertifying again",
|
"mustWaitXBeforeCertify": "You have to wait\n{} before\ncertifying again",
|
||||||
|
"mustConfirmHisIdentity": "This person must confirm\nhis identity before can be\ncertified",
|
||||||
"canRenewCertInX": "You can renew\nthis certification\nin {}",
|
"canRenewCertInX": "You can renew\nthis certification\nin {}",
|
||||||
"executeATransfer": "Execute a transfer",
|
"executeATransfer": "Execute a transfer",
|
||||||
"executeTheTransfer": "Execute the transfer",
|
"executeTheTransfer": "Execute the transfer",
|
||||||
|
@ -174,5 +175,18 @@
|
||||||
"noContacts": "You don't have any contact",
|
"noContacts": "You don't have any contact",
|
||||||
"addContact": "Add\nto contacts",
|
"addContact": "Add\nto contacts",
|
||||||
"removeContact": "Remove\nthis contact",
|
"removeContact": "Remove\nthis contact",
|
||||||
"derivationsScanProgress": "Scan address {}/{}"
|
"derivationsScanProgress": "Scan address {}/{}",
|
||||||
|
"youAreOffline": "You are offline...",
|
||||||
|
"importG1v1": "Import old G1v1 account",
|
||||||
|
"selectDestWallet": "Select a target wallet:",
|
||||||
|
"youMustWaitBeforeCashoutThisAccount": "You have to wait {} minutes\nbefore migrate this account",
|
||||||
|
"thisAccountIsEmpty": "This account is empty",
|
||||||
|
"youCannotMigrateIdentityToExistingIdentity": "You cannot migrate an identity\nto an account that already has an identity",
|
||||||
|
"importOldAccount": "Import your old account",
|
||||||
|
"enterCesiumId": "Enter your Cesium ID",
|
||||||
|
"enterCesiumPassword": "Enter your Cesium password",
|
||||||
|
"migrateAccount": "Migrate account",
|
||||||
|
"migrateIdentity": "Migrate identity",
|
||||||
|
"identityMigration": "Identity migration",
|
||||||
|
"areYouSureMigrateIdentity": "Are you sure you want to permanently migrate identity **{}** with balance of **{}** ?"
|
||||||
}
|
}
|
|
@ -148,6 +148,7 @@
|
||||||
"execTimeoutOver": "Le délais d'éxecution est dépassé",
|
"execTimeoutOver": "Le délais d'éxecution est dépassé",
|
||||||
"seeAWallet": "Voir un portefeuille",
|
"seeAWallet": "Voir un portefeuille",
|
||||||
"mustWaitXBeforeCertify": "Vous devez attendre\n{} avant\nde pouvoir certifier",
|
"mustWaitXBeforeCertify": "Vous devez attendre\n{} avant\nde pouvoir certifier",
|
||||||
|
"mustConfirmHisIdentity": "Cette personne doit confirmer\nson identité avant de pouvoir\nêtre certifié",
|
||||||
"canRenewCertInX": "Vous pourrez renouveller\ncette certification\ndans {}",
|
"canRenewCertInX": "Vous pourrez renouveller\ncette certification\ndans {}",
|
||||||
"executeATransfer": "Effectuer un virement",
|
"executeATransfer": "Effectuer un virement",
|
||||||
"executeTheTransfer": "Effectuer le virement",
|
"executeTheTransfer": "Effectuer le virement",
|
||||||
|
@ -175,5 +176,18 @@
|
||||||
"noContacts": "Vous n'avez aucun contact",
|
"noContacts": "Vous n'avez aucun contact",
|
||||||
"addContact": "Ajouter\naux contacts",
|
"addContact": "Ajouter\naux contacts",
|
||||||
"removeContact": "Supprimer\nce contact",
|
"removeContact": "Supprimer\nce contact",
|
||||||
"derivationsScanProgress": "Scan de l'adresse {}/{}"
|
"derivationsScanProgress": "Scan de l'adresse {}/{}",
|
||||||
|
"youAreOffline": "Vous êtes hors ligne...",
|
||||||
|
"importG1v1": "Importer un ancien compte G1v1",
|
||||||
|
"selectDestWallet": "Sélectionnez un portefeuille cible:",
|
||||||
|
"youMustWaitBeforeCashoutThisAccount": "Vous devez attendre {} minutes\navant de pouvoir migrer ce compte",
|
||||||
|
"thisAccountIsEmpty": "Ce compte est vide",
|
||||||
|
"youCannotMigrateIdentityToExistingIdentity": "Vous ne pouvez pas migrer une identité\nvers un compte disposant déjà d'une identité",
|
||||||
|
"importOldAccount": "Importer son ancien compte",
|
||||||
|
"enterCesiumId": "Entrez votre identifiant Cesium",
|
||||||
|
"enterCesiumPassword": "Entrez votre mot de passe Cesium",
|
||||||
|
"migrateAccount": "Migrer le compte",
|
||||||
|
"migrateIdentity": "Migrer l'identité",
|
||||||
|
"identityMigration": "Migration de l'identité",
|
||||||
|
"areYouSureMigrateIdentity": "Êtes-vous certain de vouloir migrer définitivement l'identité **{}** et son solde de **{}** ?"
|
||||||
}
|
}
|
|
@ -390,7 +390,7 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
|
|
||||||
for (var derivationNbr in [for (var i = 0; i < numberScan; i += 1) i]) {
|
for (var derivationNbr in [for (var i = 0; i < numberScan; i += 1) i]) {
|
||||||
final addressData = await sub.sdk.api.keyring.addressFromMnemonic(
|
final addressData = await sub.sdk.api.keyring.addressFromMnemonic(
|
||||||
sub.ss58,
|
sub.currencyParameters['ss58']!,
|
||||||
cryptoType: CryptoType.sr25519,
|
cryptoType: CryptoType.sr25519,
|
||||||
mnemonic: generatedMnemonic!,
|
mnemonic: generatedMnemonic!,
|
||||||
derivePath: '//$derivationNbr');
|
derivePath: '//$derivationNbr');
|
||||||
|
@ -409,7 +409,9 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
? 'currentWallet'.tr()
|
? 'currentWallet'.tr()
|
||||||
: '${'wallet'.tr()} ${scanedValidWalletNumber + 1}';
|
: '${'wallet'.tr()} ${scanedValidWalletNumber + 1}';
|
||||||
await sub.importAccount(
|
await sub.importAccount(
|
||||||
derivePath: '//$derivationNbr', password: pin.text);
|
mnemonic: generatedMnemonic!,
|
||||||
|
derivePath: '//$derivationNbr',
|
||||||
|
password: pin.text);
|
||||||
|
|
||||||
WalletData myWallet = WalletData(
|
WalletData myWallet = WalletData(
|
||||||
version: dataVersion,
|
version: dataVersion,
|
||||||
|
@ -433,8 +435,10 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> scanRootBalance(SubstrateSdk sub, int currentChestNumber) async {
|
Future<bool> scanRootBalance(SubstrateSdk sub, int currentChestNumber) async {
|
||||||
final addressData = await sub.sdk.api.keyring.addressFromMnemonic(sub.ss58,
|
final addressData = await sub.sdk.api.keyring.addressFromMnemonic(
|
||||||
cryptoType: CryptoType.sr25519, mnemonic: generatedMnemonic!);
|
sub.currencyParameters['ss58']!,
|
||||||
|
cryptoType: CryptoType.sr25519,
|
||||||
|
mnemonic: generatedMnemonic!);
|
||||||
|
|
||||||
final balance = await sub.getBalance(addressData.address!).timeout(
|
final balance = await sub.getBalance(addressData.address!).timeout(
|
||||||
const Duration(seconds: 1),
|
const Duration(seconds: 1),
|
||||||
|
@ -445,7 +449,7 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
"${addressData.address!}: ${balance['transferableBalance']} $currencyName");
|
"${addressData.address!}: ${balance['transferableBalance']} $currencyName");
|
||||||
if (balance['transferableBalance'] != 0) {
|
if (balance['transferableBalance'] != 0) {
|
||||||
String walletName = 'myRootWallet'.tr();
|
String walletName = 'myRootWallet'.tr();
|
||||||
await sub.importAccount(password: pin.text);
|
await sub.importAccount(mnemonic: generatedMnemonic!, password: pin.text);
|
||||||
|
|
||||||
WalletData myWallet = WalletData(
|
WalletData myWallet = WalletData(
|
||||||
version: dataVersion,
|
version: dataVersion,
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
|
||||||
|
import 'dart:typed_data';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
|
@ -11,9 +14,11 @@ import 'package:polkawallet_sdk/api/types/txInfoData.dart';
|
||||||
import 'package:polkawallet_sdk/polkawallet_sdk.dart';
|
import 'package:polkawallet_sdk/polkawallet_sdk.dart';
|
||||||
import 'package:polkawallet_sdk/storage/keyring.dart';
|
import 'package:polkawallet_sdk/storage/keyring.dart';
|
||||||
import 'package:polkawallet_sdk/storage/types/keyPairData.dart';
|
import 'package:polkawallet_sdk/storage/types/keyPairData.dart';
|
||||||
|
import 'package:polkawallet_sdk/webviewWithExtension/types/signExtrinsicParam.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:truncate/truncate.dart';
|
import 'package:truncate/truncate.dart';
|
||||||
// import 'package:web_socket_channel/io.dart';
|
import 'package:pointycastle/pointycastle.dart' as pc;
|
||||||
|
import "package:hex/hex.dart";
|
||||||
|
|
||||||
class SubstrateSdk with ChangeNotifier {
|
class SubstrateSdk with ChangeNotifier {
|
||||||
final WalletSDK sdk = WalletSDK();
|
final WalletSDK sdk = WalletSDK();
|
||||||
|
@ -27,13 +32,18 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
bool isLoadingEndpoint = false;
|
bool isLoadingEndpoint = false;
|
||||||
String debugConnection = '';
|
String debugConnection = '';
|
||||||
String transactionStatus = '';
|
String transactionStatus = '';
|
||||||
int ss58 = 42;
|
final int initSs58 = 42;
|
||||||
|
Map<String, int> currencyParameters = {};
|
||||||
|
TextEditingController csSalt = TextEditingController();
|
||||||
|
TextEditingController csPassword = TextEditingController();
|
||||||
|
String g1V1NewAddress = '';
|
||||||
|
bool isCesiumIDVisible = true;
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
////////// 1: API METHODS ///////////
|
////////// 1: API METHODS ///////////
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
|
|
||||||
Future<String> executeCall(TxInfoData txInfo, txOptions, String password,
|
Future<String> _executeCall(TxInfoData txInfo, txOptions, String password,
|
||||||
[String? rawParams]) async {
|
[String? rawParams]) async {
|
||||||
try {
|
try {
|
||||||
final hash = await sdk.api.tx
|
final hash = await sdk.api.tx
|
||||||
|
@ -60,10 +70,16 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future getStorage(String call) async {
|
Future _getStorage(String call) async {
|
||||||
return await sdk.webView!.evalJavascript('api.query.$call');
|
return await sdk.webView!.evalJavascript('api.query.$call');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future _getStorageConst(String call) async {
|
||||||
|
return (await sdk.webView!
|
||||||
|
.evalJavascript('api.consts.$call', wrapPromise: false) ??
|
||||||
|
[null])[0];
|
||||||
|
}
|
||||||
|
|
||||||
TxSenderData _setSender() {
|
TxSenderData _setSender() {
|
||||||
return TxSenderData(
|
return TxSenderData(
|
||||||
keyring.current.address,
|
keyring.current.address,
|
||||||
|
@ -71,30 +87,43 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String> _signMessage(
|
||||||
|
Uint8List message, String address, String password) async {
|
||||||
|
final params = SignAsExtensionParam();
|
||||||
|
params.msgType = "pub(bytes.sign)";
|
||||||
|
params.request = {
|
||||||
|
"address": address,
|
||||||
|
"data": message,
|
||||||
|
};
|
||||||
|
|
||||||
|
final res = await sdk.api.keyring.signAsExtension(password, params);
|
||||||
|
return res?.signature ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////
|
////////////////////////////////////////////
|
||||||
////////// 2: GET ONCHAIN STORAGE //////////
|
////////// 2: GET ONCHAIN STORAGE //////////
|
||||||
////////////////////////////////////////////
|
////////////////////////////////////////////
|
||||||
|
|
||||||
Future<int> getIdentityIndexOf(String address) async {
|
Future<int> _getIdentityIndexOf(String address) async {
|
||||||
return await getStorage('identity.identityIndexOf("$address")') ?? 0;
|
return await _getStorage('identity.identityIndexOf("$address")') ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<int>> getCerts(String address) async {
|
Future<List<int>> getCerts(String address) async {
|
||||||
final idtyIndex = await getIdentityIndexOf(address);
|
final idtyIndex = await _getIdentityIndexOf(address);
|
||||||
final certsReceiver =
|
final certsReceiver =
|
||||||
await getStorage('cert.storageIdtyCertMeta($idtyIndex)') ?? [];
|
await _getStorage('cert.storageIdtyCertMeta($idtyIndex)') ?? [];
|
||||||
|
|
||||||
return [certsReceiver['receivedCount'], certsReceiver['issuedCount']];
|
return [certsReceiver['receivedCount'], certsReceiver['issuedCount']];
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<int> getCertValidityPeriod(String from, String to) async {
|
Future<int> getCertValidityPeriod(String from, String to) async {
|
||||||
final idtyIndexFrom = await getIdentityIndexOf(from);
|
final idtyIndexFrom = await _getIdentityIndexOf(from);
|
||||||
final idtyIndexTo = await getIdentityIndexOf(to);
|
final idtyIndexTo = await _getIdentityIndexOf(to);
|
||||||
|
|
||||||
if (idtyIndexFrom == 0 || idtyIndexTo == 0) return 0;
|
if (idtyIndexFrom == 0 || idtyIndexTo == 0) return 0;
|
||||||
|
|
||||||
final List certData =
|
final List certData =
|
||||||
await getStorage('cert.certsByReceiver($idtyIndexTo)') ?? [];
|
await _getStorage('cert.certsByReceiver($idtyIndexTo)') ?? [];
|
||||||
|
|
||||||
if (certData.isEmpty) return 0;
|
if (certData.isEmpty) return 0;
|
||||||
for (List certInfo in certData) {
|
for (List certInfo in certData) {
|
||||||
|
@ -106,14 +135,8 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getParameters() async {
|
|
||||||
final currencyParameters =
|
|
||||||
await getStorage('parameters.parametersStorage()') ?? {};
|
|
||||||
return currencyParameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<bool> hasAccountConsumers(String address) async {
|
Future<bool> hasAccountConsumers(String address) async {
|
||||||
final accountInfo = await getStorage('system.account("$address")');
|
final accountInfo = await _getStorage('system.account("$address")');
|
||||||
final consumers = accountInfo['consumers'];
|
final consumers = accountInfo['consumers'];
|
||||||
return consumers == 0 ? false : true;
|
return consumers == 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
@ -134,6 +157,8 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Future<Map<String, double>> getBalance(String address) async {
|
Future<Map<String, double>> getBalance(String address) async {
|
||||||
|
// log.d('currencyParameters: $currencyParameters');
|
||||||
|
|
||||||
if (!nodeConnected) {
|
if (!nodeConnected) {
|
||||||
return {
|
return {
|
||||||
'transferableBalance': 0,
|
'transferableBalance': 0,
|
||||||
|
@ -144,16 +169,16 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get onchain storage values
|
// Get onchain storage values
|
||||||
final Map balanceGlobal = await getStorage('system.account("$address")');
|
final Map balanceGlobal = await _getStorage('system.account("$address")');
|
||||||
final int? idtyIndex =
|
final int? idtyIndex =
|
||||||
await getStorage('identity.identityIndexOf("$address")');
|
await _getStorage('identity.identityIndexOf("$address")');
|
||||||
final Map? idtyData = idtyIndex == null
|
final Map? idtyData = idtyIndex == null
|
||||||
? null
|
? null
|
||||||
: await getStorage('identity.identities($idtyIndex)');
|
: await _getStorage('identity.identities($idtyIndex)');
|
||||||
final int currentUdIndex =
|
final int currentUdIndex =
|
||||||
int.parse(await getStorage('universalDividend.currentUdIndex()'));
|
int.parse(await _getStorage('universalDividend.currentUdIndex()'));
|
||||||
final List pastReevals =
|
final List pastReevals =
|
||||||
await getStorage('universalDividend.pastReevals()');
|
await _getStorage('universalDividend.pastReevals()');
|
||||||
|
|
||||||
// Compute amount of claimable UDs
|
// Compute amount of claimable UDs
|
||||||
final int unclaimedUds = _computeUnclaimUds(currentUdIndex,
|
final int unclaimedUds = _computeUnclaimUds(currentUdIndex,
|
||||||
|
@ -200,23 +225,14 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
return totalAmount;
|
return totalAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<int> getSs58Prefix() async {
|
|
||||||
final List res = await sdk.webView!.evalJavascript(
|
|
||||||
'api.consts.system.ss58Prefix.words',
|
|
||||||
wrapPromise: false) ??
|
|
||||||
[42];
|
|
||||||
|
|
||||||
ss58 = res[0];
|
|
||||||
log.d(ss58);
|
|
||||||
return ss58;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<bool> isMemberGet(String address) async {
|
Future<bool> isMemberGet(String address) async {
|
||||||
return await idtyStatus(address) == 'Validated';
|
return await idtyStatus(address) == 'Validated';
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, int>> certState(String from, String to) async {
|
Future<Map<String, int>> certState(String from, String to) async {
|
||||||
Map<String, int> result = {};
|
Map<String, int> result = {};
|
||||||
|
final toStatus = await idtyStatus(to);
|
||||||
|
|
||||||
if (from != to && await isMemberGet(from)) {
|
if (from != to && await isMemberGet(from)) {
|
||||||
final removableOn = await getCertValidityPeriod(from, to);
|
final removableOn = await getCertValidityPeriod(from, to);
|
||||||
final certMeta = await getCertMeta(from);
|
final certMeta = await getCertMeta(from);
|
||||||
|
@ -230,32 +246,35 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
} else if (nextIssuableOn > blocNumber) {
|
} else if (nextIssuableOn > blocNumber) {
|
||||||
final certDelayDuration = (nextIssuableOn - blocNumber) * 6;
|
final certDelayDuration = (nextIssuableOn - blocNumber) * 6;
|
||||||
result.putIfAbsent('certDelay', () => certDelayDuration);
|
result.putIfAbsent('certDelay', () => certDelayDuration);
|
||||||
|
} else if (toStatus == 'Created') {
|
||||||
|
result.putIfAbsent('toStatus', () => 1);
|
||||||
} else {
|
} else {
|
||||||
result.putIfAbsent('canCert', () => 0);
|
result.putIfAbsent('canCert', () => 0);
|
||||||
}
|
}
|
||||||
// log.d('tatatatata: ${nextIssuableOn - blocNumber}');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (toStatus == 'Created') result.putIfAbsent('toStatus', () => 1);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map> getCertMeta(String address) async {
|
Future<Map> getCertMeta(String address) async {
|
||||||
var idtyIndex = await getIdentityIndexOf(address);
|
var idtyIndex = await _getIdentityIndexOf(address);
|
||||||
|
|
||||||
final certMeta =
|
final certMeta =
|
||||||
await getStorage('cert.storageIdtyCertMeta($idtyIndex)') ?? '';
|
await _getStorage('cert.storageIdtyCertMeta($idtyIndex)') ?? '';
|
||||||
|
|
||||||
return certMeta;
|
return certMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> idtyStatus(String address, [bool smooth = true]) async {
|
Future<String> idtyStatus(String address) async {
|
||||||
var idtyIndex = await getIdentityIndexOf(address);
|
var idtyIndex = await _getIdentityIndexOf(address);
|
||||||
|
|
||||||
if (idtyIndex == 0) {
|
if (idtyIndex == 0) {
|
||||||
return 'noid';
|
return 'noid';
|
||||||
}
|
}
|
||||||
|
|
||||||
final idtyStatus = await getStorage('identity.identities($idtyIndex)');
|
final idtyStatus = await _getStorage('identity.identities($idtyIndex)');
|
||||||
|
|
||||||
if (idtyStatus != null) {
|
if (idtyStatus != null) {
|
||||||
final String status = idtyStatus['status'];
|
final String status = idtyStatus['status'];
|
||||||
|
@ -266,7 +285,53 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future getCurencyName() async {}
|
Future<String> getGenesisHash() async {
|
||||||
|
final String genesisHash = await sdk.webView!.evalJavascript(
|
||||||
|
'api.genesisHash.toHex()',
|
||||||
|
wrapPromise: false,
|
||||||
|
) ??
|
||||||
|
[];
|
||||||
|
// log.d('genesisHash: $genesisHash');
|
||||||
|
// log.d('genesisHash: ${HEX.decode(genesisHash.substring(2))}');
|
||||||
|
return genesisHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Uint8List> addressToPubkey(String address) async {
|
||||||
|
final pubkey = await sdk.api.account.decodeAddress([address]);
|
||||||
|
final String pubkeyHex = pubkey!.keys.first;
|
||||||
|
final pubkeyByte = HEX.decode(pubkeyHex.substring(2)) as Uint8List;
|
||||||
|
// final pubkey58 = Base58Encode(pubkeyByte);
|
||||||
|
|
||||||
|
return pubkeyByte;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Future pubkeyToAddress(String pubkey) async {
|
||||||
|
// await sdk.api.account.encodeAddress([pubkey]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
Future initCurrencyParameters() async {
|
||||||
|
currencyParameters['ss58'] =
|
||||||
|
await _getStorageConst('system.ss58Prefix.words');
|
||||||
|
currencyParameters['minCertForMembership'] =
|
||||||
|
await _getStorageConst('wot.minCertForMembership.words');
|
||||||
|
currencyParameters['newAccountPrice'] =
|
||||||
|
await _getStorageConst('account.newAccountPrice.words');
|
||||||
|
currencyParameters['existentialDeposit'] =
|
||||||
|
await _getStorageConst('balances.existentialDeposit.words');
|
||||||
|
currencyParameters['certPeriod'] =
|
||||||
|
await _getStorageConst('cert.certPeriod.words');
|
||||||
|
currencyParameters['certMaxByIssuer'] =
|
||||||
|
await _getStorageConst('cert.maxByIssuer.words');
|
||||||
|
currencyParameters['certValidityPeriod'] =
|
||||||
|
await _getStorageConst('cert.validityPeriod.words');
|
||||||
|
|
||||||
|
log.i('currencyParameters: $currencyParameters');
|
||||||
|
}
|
||||||
|
|
||||||
|
void cesiumIDisVisible() {
|
||||||
|
isCesiumIDVisible = !isCesiumIDVisible;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
////// 3: SUBSTRATE CONNECTION //////
|
////// 3: SUBSTRATE CONNECTION //////
|
||||||
|
@ -274,8 +339,8 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
|
|
||||||
Future<void> initApi() async {
|
Future<void> initApi() async {
|
||||||
sdkLoading = true;
|
sdkLoading = true;
|
||||||
await keyring.init([ss58]);
|
await keyring.init([initSs58]);
|
||||||
keyring.setSS58(ss58);
|
keyring.setSS58(initSs58);
|
||||||
|
|
||||||
await sdk.init(keyring);
|
await sdk.init(keyring);
|
||||||
sdkReady = true;
|
sdkReady = true;
|
||||||
|
@ -289,6 +354,8 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
|
|
||||||
Future<void> connectNode(BuildContext ctx) async {
|
Future<void> connectNode(BuildContext ctx) async {
|
||||||
HomeProvider homeProvider = Provider.of<HomeProvider>(ctx, listen: false);
|
HomeProvider homeProvider = Provider.of<HomeProvider>(ctx, listen: false);
|
||||||
|
MyWalletsProvider myWalletProvider =
|
||||||
|
Provider.of<MyWalletsProvider>(ctx, listen: false);
|
||||||
|
|
||||||
homeProvider.changeMessage("connectionPending".tr(), 0);
|
homeProvider.changeMessage("connectionPending".tr(), 0);
|
||||||
|
|
||||||
|
@ -329,7 +396,7 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
});
|
});
|
||||||
|
|
||||||
// currencyName = await getCurencyName();
|
await initCurrencyParameters();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
homeProvider.changeMessage(
|
homeProvider.changeMessage(
|
||||||
"wellConnectedToNode"
|
"wellConnectedToNode"
|
||||||
|
@ -341,7 +408,7 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
debugConnection = res.toString();
|
debugConnection = res.toString();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
homeProvider.changeMessage("noDuniterEndointAvailable".tr(), 0);
|
homeProvider.changeMessage("noDuniterEndointAvailable".tr(), 0);
|
||||||
// snackNode(ctx, false);
|
if (!myWalletProvider.checkIfWalletExist()) snackNode(homeContext, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.d(sdk.api.connectedNode?.endpoint);
|
log.d(sdk.api.connectedNode?.endpoint);
|
||||||
|
@ -354,7 +421,7 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
final n = NetworkParams();
|
final n = NetworkParams();
|
||||||
n.name = currencyName;
|
n.name = currencyName;
|
||||||
n.endpoint = endpoint;
|
n.endpoint = endpoint;
|
||||||
n.ss58 = ss58;
|
n.ss58 = currencyParameters['ss58'] ?? initSs58;
|
||||||
node.add(n);
|
node.add(n);
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
|
@ -364,7 +431,7 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
final nodeParams = NetworkParams();
|
final nodeParams = NetworkParams();
|
||||||
nodeParams.name = currencyName;
|
nodeParams.name = currencyName;
|
||||||
nodeParams.endpoint = configBox.get('customEndpoint');
|
nodeParams.endpoint = configBox.get('customEndpoint');
|
||||||
nodeParams.ss58 = ss58;
|
nodeParams.ss58 = currencyParameters['ss58'] ?? initSs58;
|
||||||
return nodeParams;
|
return nodeParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,7 +541,8 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> generateMnemonic({String lang = appLang}) async {
|
Future<String> generateMnemonic({String lang = appLang}) async {
|
||||||
final gen = await sdk.api.keyring.generateMnemonic(ss58);
|
final gen = await sdk.api.keyring
|
||||||
|
.generateMnemonic(currencyParameters['ss58'] ?? initSs58);
|
||||||
generatedMnemonic = gen.mnemonic!;
|
generatedMnemonic = gen.mnemonic!;
|
||||||
|
|
||||||
return gen.mnemonic!;
|
return gen.mnemonic!;
|
||||||
|
@ -508,9 +576,6 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
BuildContext context, String address, int number, String password) async {
|
BuildContext context, String address, int number, String password) async {
|
||||||
final keypair = getKeypair(address);
|
final keypair = getKeypair(address);
|
||||||
|
|
||||||
//TODO: fix null keypair after used chest import
|
|
||||||
log.d('tatatata $address $number $password ${keypair.encoded}');
|
|
||||||
|
|
||||||
final seedMap =
|
final seedMap =
|
||||||
await keyring.store.getDecryptedSeed(keypair.pubKey, password);
|
await keyring.store.getDecryptedSeed(keypair.pubKey, password);
|
||||||
|
|
||||||
|
@ -545,6 +610,46 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
return await sdk.api.keyring.checkMnemonicValid(mnemonic);
|
return await sdk.api.keyring.checkMnemonicValid(mnemonic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String> csToV2Address(String salt, String password) async {
|
||||||
|
final scrypt = pc.KeyDerivator('scrypt');
|
||||||
|
|
||||||
|
scrypt.init(
|
||||||
|
pc.ScryptParameters(
|
||||||
|
4096,
|
||||||
|
16,
|
||||||
|
1,
|
||||||
|
32,
|
||||||
|
Uint8List.fromList(salt.codeUnits),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final rawSeed = scrypt.process(Uint8List.fromList(password.codeUnits));
|
||||||
|
final rawSeedHex = '0x${HEX.encode(rawSeed)}';
|
||||||
|
|
||||||
|
// Just get the address without keystore
|
||||||
|
final newAddress = await sdk.api.keyring.addressFromRawSeed(
|
||||||
|
currencyParameters['ss58']!,
|
||||||
|
cryptoType: CryptoType.ed25519,
|
||||||
|
rawSeed: rawSeedHex);
|
||||||
|
|
||||||
|
g1V1NewAddress = newAddress.address!;
|
||||||
|
notifyListeners();
|
||||||
|
return g1V1NewAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List> getBalanceAndIdtyStatus(
|
||||||
|
String fromAddress, String toAddress) async {
|
||||||
|
final fromBalance = fromAddress == ''
|
||||||
|
? {'transferableBalance': 0}
|
||||||
|
: await getBalance(fromAddress);
|
||||||
|
final fromIdtyStatus =
|
||||||
|
fromAddress == '' ? 'noid' : await idtyStatus(fromAddress);
|
||||||
|
final fromHasConsumer =
|
||||||
|
fromAddress == '' ? false : await hasAccountConsumers(fromAddress);
|
||||||
|
final toIdtyStatus = await idtyStatus(toAddress);
|
||||||
|
|
||||||
|
return [fromBalance, fromIdtyStatus, toIdtyStatus, fromHasConsumer];
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
///////// 5: CALLS EXECUTION /////////
|
///////// 5: CALLS EXECUTION /////////
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
|
@ -587,7 +692,7 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
// log.d('pay args: ${txInfo.module}, ${txInfo.call}, $txOptions, $rawParams');
|
// log.d('pay args: ${txInfo.module}, ${txInfo.call}, $txOptions, $rawParams');
|
||||||
return await executeCall(txInfo, txOptions, password, rawParams);
|
return await _executeCall(txInfo, txOptions, password, rawParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> certify(
|
Future<String> certify(
|
||||||
|
@ -597,8 +702,8 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
final myIdtyStatus = await idtyStatus(fromAddress);
|
final myIdtyStatus = await idtyStatus(fromAddress);
|
||||||
final toIdtyStatus = await idtyStatus(toAddress);
|
final toIdtyStatus = await idtyStatus(toAddress);
|
||||||
|
|
||||||
final fromIndex = await getIdentityIndexOf(fromAddress);
|
final fromIndex = await _getIdentityIndexOf(fromAddress);
|
||||||
final toIndex = await getIdentityIndexOf(toAddress);
|
final toIndex = await _getIdentityIndexOf(toAddress);
|
||||||
|
|
||||||
if (myIdtyStatus != 'Validated') {
|
if (myIdtyStatus != 'Validated') {
|
||||||
transactionStatus = 'notMember';
|
transactionStatus = 'notMember';
|
||||||
|
@ -612,7 +717,8 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
String? rawParams;
|
String? rawParams;
|
||||||
|
|
||||||
final toCerts = await getCerts(toAddress);
|
final toCerts = await getCerts(toAddress);
|
||||||
final currencyParameters = await getParameters();
|
|
||||||
|
// log.d('debug: ${currencyParameters['minCertForMembership']}');
|
||||||
|
|
||||||
if (toIdtyStatus == 'noid') {
|
if (toIdtyStatus == 'noid') {
|
||||||
txInfo = TxInfoData(
|
txInfo = TxInfoData(
|
||||||
|
@ -623,7 +729,7 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
txOptions = [toAddress];
|
txOptions = [toAddress];
|
||||||
} else if (toIdtyStatus == 'Validated' ||
|
} else if (toIdtyStatus == 'Validated' ||
|
||||||
toIdtyStatus == 'ConfirmedByOwner') {
|
toIdtyStatus == 'ConfirmedByOwner') {
|
||||||
if (toCerts[0] >= currencyParameters['wotMinCertForMembership'] &&
|
if (toCerts[0] >= currencyParameters['minCertForMembership']! - 1 &&
|
||||||
toIdtyStatus != 'Validated') {
|
toIdtyStatus != 'Validated') {
|
||||||
log.i('Batch cert and membership validation');
|
log.i('Batch cert and membership validation');
|
||||||
txInfo = TxInfoData(
|
txInfo = TxInfoData(
|
||||||
|
@ -631,8 +737,8 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
'batchAll',
|
'batchAll',
|
||||||
sender,
|
sender,
|
||||||
);
|
);
|
||||||
final tx1 = 'cert.addCert($fromIndex, $toIndex)';
|
final tx1 = 'api.tx.cert.addCert($fromIndex, $toIndex)';
|
||||||
final tx2 = 'identity.validateIdentity($toIndex)';
|
final tx2 = 'api.tx.identity.validateIdentity($toIndex)';
|
||||||
|
|
||||||
rawParams = '[[$tx1, $tx2]]';
|
rawParams = '[[$tx1, $tx2]]';
|
||||||
} else {
|
} else {
|
||||||
|
@ -650,7 +756,7 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.d('Cert action: ${txInfo.call!}');
|
log.d('Cert action: ${txInfo.call!}');
|
||||||
return await executeCall(txInfo, txOptions, password, rawParams);
|
return await _executeCall(txInfo, txOptions, password, rawParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Future claimUDs(String password) async {
|
// Future claimUDs(String password) async {
|
||||||
|
@ -684,11 +790,83 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
);
|
);
|
||||||
final txOptions = [name];
|
final txOptions = [name];
|
||||||
|
|
||||||
return await executeCall(txInfo, txOptions, password);
|
return await _executeCall(txInfo, txOptions, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> migrateIdentity(
|
||||||
|
{required String fromAddress,
|
||||||
|
required String destAddress,
|
||||||
|
required String fromPassword,
|
||||||
|
required String destPassword,
|
||||||
|
required Map fromBalance,
|
||||||
|
bool withBalance = false}) async {
|
||||||
|
transactionStatus = '';
|
||||||
|
final fromPubkey = await sdk.api.account.decodeAddress([fromAddress]);
|
||||||
|
final sender = TxSenderData(
|
||||||
|
fromAddress,
|
||||||
|
fromPubkey!.keys.first,
|
||||||
|
);
|
||||||
|
|
||||||
|
TxInfoData txInfo;
|
||||||
|
List txOptions = [];
|
||||||
|
String? rawParams;
|
||||||
|
|
||||||
|
final prefix = 'icok'.codeUnits;
|
||||||
|
final genesisHashString = await getGenesisHash();
|
||||||
|
final genesisHash = HEX.decode(genesisHashString.substring(2)) as Uint8List;
|
||||||
|
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);
|
||||||
|
|
||||||
|
// 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]
|
||||||
|
|
||||||
|
log.d("""
|
||||||
|
fromAddress: $fromAddress
|
||||||
|
destAddress: $destAddress
|
||||||
|
genesisHashString: $genesisHashString
|
||||||
|
|
||||||
|
prefix: $prefix
|
||||||
|
genesisHash: $genesisHash
|
||||||
|
idtyIndex: $idtyIndex
|
||||||
|
oldPubkey: $oldPubkey
|
||||||
|
|
||||||
|
messageToSign: $messageToSign
|
||||||
|
messageToSignHex: $messageToSignHex
|
||||||
|
newKeySig: $newKeySig""");
|
||||||
|
|
||||||
|
if (withBalance) {
|
||||||
|
txInfo = TxInfoData(
|
||||||
|
'utility',
|
||||||
|
'batchAll',
|
||||||
|
sender,
|
||||||
|
);
|
||||||
|
|
||||||
|
const tx1 = 'api.tx.universalDividend.claimUds()';
|
||||||
|
final tx2 =
|
||||||
|
'api.tx.identity.changeOwnerKey("$destAddress", "$newKeySig")';
|
||||||
|
// const tx3 = 'api.tx.balances.transferAll(false)';
|
||||||
|
|
||||||
|
rawParams =
|
||||||
|
fromBalance['unclaimedUds'] == 0 ? '[[$tx2]]' : '[[$tx1, $tx2]]';
|
||||||
|
} else {
|
||||||
|
txInfo = TxInfoData(
|
||||||
|
'identity',
|
||||||
|
'changeOwnerKey',
|
||||||
|
sender,
|
||||||
|
);
|
||||||
|
|
||||||
|
txOptions = [destAddress, newKeySig];
|
||||||
|
}
|
||||||
|
|
||||||
|
return await _executeCall(txInfo, txOptions, fromPassword, rawParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future revokeIdentity(String address, String password) async {
|
Future revokeIdentity(String address, String password) async {
|
||||||
final idtyIndex = await getIdentityIndexOf(address);
|
final idtyIndex = await _getIdentityIndexOf(address);
|
||||||
|
|
||||||
final sender = TxSenderData(
|
final sender = TxSenderData(
|
||||||
keyring.current.address,
|
keyring.current.address,
|
||||||
|
@ -706,7 +884,60 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
|
|
||||||
final txOptions = [idtyIndex];
|
final txOptions = [idtyIndex];
|
||||||
|
|
||||||
return await executeCall(txInfo, txOptions, password);
|
return await _executeCall(txInfo, txOptions, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future migrateCsToV2(String salt, String password, String destAddress,
|
||||||
|
{required destPassword,
|
||||||
|
required Map balance,
|
||||||
|
String idtyStatus = 'noid'}) async {
|
||||||
|
final scrypt = pc.KeyDerivator('scrypt');
|
||||||
|
|
||||||
|
scrypt.init(
|
||||||
|
pc.ScryptParameters(
|
||||||
|
4096,
|
||||||
|
16,
|
||||||
|
1,
|
||||||
|
32,
|
||||||
|
Uint8List.fromList(salt.codeUnits),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final rawSeed = scrypt.process(Uint8List.fromList(password.codeUnits));
|
||||||
|
final rawSeedHex = '0x${HEX.encode(rawSeed)}';
|
||||||
|
|
||||||
|
final json = await sdk.api.keyring.importAccount(keyring,
|
||||||
|
keyType: KeyType.rawSeed,
|
||||||
|
key: rawSeedHex,
|
||||||
|
name: 'test',
|
||||||
|
password: 'password',
|
||||||
|
derivePath: '',
|
||||||
|
cryptoType: CryptoType.ed25519);
|
||||||
|
|
||||||
|
final keypair = await sdk.api.keyring.addAccount(
|
||||||
|
keyring,
|
||||||
|
keyType: KeyType.rawSeed,
|
||||||
|
acc: json!,
|
||||||
|
password: password,
|
||||||
|
);
|
||||||
|
|
||||||
|
log.d('g1migration idtyStatus: $idtyStatus');
|
||||||
|
if (idtyStatus != 'noid') {
|
||||||
|
await migrateIdentity(
|
||||||
|
fromAddress: keypair.address!,
|
||||||
|
destAddress: destAddress,
|
||||||
|
fromPassword: 'password',
|
||||||
|
destPassword: destPassword,
|
||||||
|
withBalance: true,
|
||||||
|
fromBalance: balance);
|
||||||
|
} else if (balance['transferableBalance'] != 0) {
|
||||||
|
await pay(
|
||||||
|
fromAddress: keypair.address!,
|
||||||
|
destAddress: destAddress,
|
||||||
|
amount: -1,
|
||||||
|
password: 'password');
|
||||||
|
}
|
||||||
|
|
||||||
|
await sdk.api.keyring.deleteAccount(keyring, keypair);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reload() {
|
void reload() {
|
||||||
|
@ -734,8 +965,7 @@ class AddressInfo {
|
||||||
void snackNode(BuildContext context, bool isConnected) {
|
void snackNode(BuildContext context, bool isConnected) {
|
||||||
String message;
|
String message;
|
||||||
if (!isConnected) {
|
if (!isConnected) {
|
||||||
message =
|
message = "noDuniterNodeAvailableTryLater".tr();
|
||||||
"${"noDuniterNodeAvailableTryLater".tr()}:\n${configBox.get('endpoint').first}";
|
|
||||||
} else {
|
} else {
|
||||||
SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false);
|
SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||||
|
|
||||||
|
@ -761,3 +991,6 @@ class PasswordException implements Exception {
|
||||||
String cause;
|
String cause;
|
||||||
PasswordException(this.cause);
|
PasswordException(this.cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Uint8List _int32bytes(int value) =>
|
||||||
|
Uint8List(4)..buffer.asInt32List()[0] = value;
|
||||||
|
|
|
@ -30,6 +30,7 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
TextEditingController nameController = TextEditingController();
|
TextEditingController nameController = TextEditingController();
|
||||||
late bool isDefaultWallet;
|
late bool isDefaultWallet;
|
||||||
bool canValidateNameBool = false;
|
bool canValidateNameBool = false;
|
||||||
|
Map<String, String> idtyStatusCache = {};
|
||||||
|
|
||||||
Future<NewWallet>? get badWallet => null;
|
Future<NewWallet>? get badWallet => null;
|
||||||
|
|
||||||
|
@ -157,6 +158,7 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
future: sub.idtyStatus(address),
|
future: sub.idtyStatus(address),
|
||||||
initialData: '',
|
initialData: '',
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
|
idtyStatusCache[address] = snapshot.data.toString();
|
||||||
switch (snapshot.data.toString()) {
|
switch (snapshot.data.toString()) {
|
||||||
case 'noid':
|
case 'noid':
|
||||||
{
|
{
|
||||||
|
@ -300,8 +302,11 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(builder: (context) {
|
MaterialPageRoute(builder: (context) {
|
||||||
return const TransactionInProgress(
|
return TransactionInProgress(
|
||||||
transType: 'comfirmIdty');
|
transType: 'comfirmIdty',
|
||||||
|
fromAddress: wallet.address,
|
||||||
|
toAddress: wallet.address,
|
||||||
|
);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,10 +138,9 @@ class WalletsProfilesProvider with ChangeNotifier {
|
||||||
Provider.of<CesiumPlusProvider>(context, listen: false);
|
Provider.of<CesiumPlusProvider>(context, listen: false);
|
||||||
// SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false);
|
// SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||||
|
|
||||||
bool isAccountExist = balanceCache[address] != 0;
|
|
||||||
|
|
||||||
return Stack(children: <Widget>[
|
return Stack(children: <Widget>[
|
||||||
Consumer<SubstrateSdk>(builder: (context, sub, _) {
|
Consumer<SubstrateSdk>(builder: (context, sub, _) {
|
||||||
|
bool isAccountExist = balanceCache[address] != 0;
|
||||||
return Container(
|
return Container(
|
||||||
height: 180,
|
height: 180,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
|
|
@ -159,8 +159,7 @@ class CommonElements {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget offlineInfo(BuildContext context) {
|
Widget offlineInfo(BuildContext context) {
|
||||||
// SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false);
|
final double screenWidth = MediaQuery.of(homeContext).size.width;
|
||||||
final double screenWidth = MediaQuery.of(context).size.width;
|
|
||||||
return Consumer<SubstrateSdk>(builder: (context, sub, _) {
|
return Consumer<SubstrateSdk>(builder: (context, sub, _) {
|
||||||
return Visibility(
|
return Visibility(
|
||||||
visible: !sub.nodeConnected,
|
visible: !sub.nodeConnected,
|
||||||
|
@ -174,7 +173,7 @@ class CommonElements {
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Vous êtes hors ligne...",
|
'youAreOffline'.tr(),
|
||||||
style: TextStyle(color: Colors.grey[50]),
|
style: TextStyle(color: Colors.grey[50]),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
|
|
|
@ -0,0 +1,299 @@
|
||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:gecko/globals.dart';
|
||||||
|
import 'package:flutter/material.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/providers/wallet_options.dart';
|
||||||
|
import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
|
||||||
|
import 'package:gecko/screens/transaction_in_progress.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class ImportG1v1 extends StatelessWidget {
|
||||||
|
const ImportG1v1({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||||
|
// HomeProvider _homeProvider = Provider.of<HomeProvider>(context);
|
||||||
|
WalletOptionsProvider walletOptions =
|
||||||
|
Provider.of<WalletOptionsProvider>(context, listen: false);
|
||||||
|
MyWalletsProvider myWalletProvider =
|
||||||
|
Provider.of<MyWalletsProvider>(context, listen: false);
|
||||||
|
|
||||||
|
Timer? debounce;
|
||||||
|
const int debouneTime = 300;
|
||||||
|
WalletData selectedWallet = myWalletProvider.getDefaultWallet();
|
||||||
|
bool canValidate = false;
|
||||||
|
String validationStatus = '';
|
||||||
|
|
||||||
|
return WillPopScope(
|
||||||
|
onWillPop: () {
|
||||||
|
resetScreen(context);
|
||||||
|
return Future<bool>.value(true);
|
||||||
|
},
|
||||||
|
child: Scaffold(
|
||||||
|
backgroundColor: backgroundColor,
|
||||||
|
appBar: AppBar(
|
||||||
|
toolbarHeight: 60 * ratio,
|
||||||
|
leading: IconButton(
|
||||||
|
icon: const Icon(Icons.arrow_back, color: Colors.black),
|
||||||
|
onPressed: () {
|
||||||
|
resetScreen(context);
|
||||||
|
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
title: SizedBox(
|
||||||
|
height: 22,
|
||||||
|
child: Text('importOldAccount'.tr()),
|
||||||
|
)),
|
||||||
|
body: SafeArea(
|
||||||
|
child: Consumer<SubstrateSdk>(builder: (context, sub, _) {
|
||||||
|
return FutureBuilder(
|
||||||
|
future: sub.getBalanceAndIdtyStatus(
|
||||||
|
sub.g1V1NewAddress, selectedWallet.address!),
|
||||||
|
builder: (BuildContext context, AsyncSnapshot<List> status) {
|
||||||
|
// log.d(_certs.data);
|
||||||
|
|
||||||
|
if (status.data == null) {
|
||||||
|
return Column(children: [
|
||||||
|
const SizedBox(height: 80),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 35,
|
||||||
|
width: 35,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: orangeC,
|
||||||
|
strokeWidth: 4,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Map balance = status.data?[0] ?? {};
|
||||||
|
final String idtyStatus = status.data?[1];
|
||||||
|
final String myIdtyStatus = status.data?[2];
|
||||||
|
final bool hasConsumer = status.data?[3] ?? false;
|
||||||
|
|
||||||
|
// log.d('hasconsumer: $hasConsumer');
|
||||||
|
|
||||||
|
if (balance['transferableBalance'] != 0 && !hasConsumer) {
|
||||||
|
canValidate = true;
|
||||||
|
validationStatus = '';
|
||||||
|
} else {
|
||||||
|
canValidate = false;
|
||||||
|
validationStatus = hasConsumer
|
||||||
|
? 'youMustWaitBeforeCashoutThisAccount'.tr(args: ['X'])
|
||||||
|
: 'thisAccountIsEmpty'.tr();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (idtyStatus != 'noid' && myIdtyStatus != 'noid') {
|
||||||
|
canValidate = false;
|
||||||
|
validationStatus =
|
||||||
|
'youCannotMigrateIdentityToExistingIdentity'.tr();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sub.g1V1NewAddress == '') {
|
||||||
|
validationStatus = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return Column(children: <Widget>[
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
TextFormField(
|
||||||
|
autofocus: true,
|
||||||
|
onChanged: (text) {
|
||||||
|
if (debounce?.isActive ?? false) {
|
||||||
|
debounce!.cancel();
|
||||||
|
}
|
||||||
|
debounce = Timer(
|
||||||
|
const Duration(milliseconds: debouneTime), () {
|
||||||
|
sub.csToV2Address(
|
||||||
|
sub.csSalt.text, sub.csPassword.text);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
keyboardType: TextInputType.text,
|
||||||
|
controller: sub.csSalt,
|
||||||
|
obscureText: sub
|
||||||
|
.isCesiumIDVisible, //This will obscure text dynamically
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'enterCesiumId'.tr(),
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
sub.isCesiumIDVisible
|
||||||
|
? Icons.visibility
|
||||||
|
: Icons.visibility_off,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
sub.cesiumIDisVisible();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
TextFormField(
|
||||||
|
autofocus: true,
|
||||||
|
onChanged: (text) {
|
||||||
|
if (debounce?.isActive ?? false) {
|
||||||
|
debounce!.cancel();
|
||||||
|
}
|
||||||
|
debounce = Timer(
|
||||||
|
const Duration(milliseconds: debouneTime), () {
|
||||||
|
sub.csToV2Address(
|
||||||
|
sub.csSalt.text, sub.csPassword.text);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
keyboardType: TextInputType.text,
|
||||||
|
controller: sub.csPassword,
|
||||||
|
obscureText: sub
|
||||||
|
.isCesiumIDVisible, //This will obscure text dynamically
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'enterCesiumPassword'.tr(),
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
sub.isCesiumIDVisible
|
||||||
|
? Icons.visibility
|
||||||
|
: Icons.visibility_off,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
sub.cesiumIDisVisible();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Text(
|
||||||
|
getShortPubkey(sub.g1V1NewAddress),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
color: Colors.black,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontFamily: 'Monospace'),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Text(
|
||||||
|
'${balance['transferableBalance']} $currencyName',
|
||||||
|
style: const TextStyle(fontSize: 17),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
walletOptions.idtyStatus(context, sub.g1V1NewAddress,
|
||||||
|
isOwner: false, color: Colors.black),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
getCerts(context, sub.g1V1NewAddress, 14)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
Text('selectDestWallet'.tr()),
|
||||||
|
const SizedBox(height: 5),
|
||||||
|
DropdownButtonHideUnderline(
|
||||||
|
child: DropdownButton(
|
||||||
|
// alignment: AlignmentDirectional.topStart,
|
||||||
|
value: selectedWallet,
|
||||||
|
icon: const Icon(Icons.keyboard_arrow_down),
|
||||||
|
items: myWalletProvider.listWallets.map((wallet) {
|
||||||
|
return DropdownMenuItem(
|
||||||
|
value: wallet,
|
||||||
|
child: Text(
|
||||||
|
wallet.name!,
|
||||||
|
style: const TextStyle(fontSize: 18),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
onChanged: (WalletData? newSelectedWallet) {
|
||||||
|
selectedWallet = newSelectedWallet!;
|
||||||
|
sub.reload();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
SizedBox(
|
||||||
|
width: 380 * ratio,
|
||||||
|
height: 60 * ratio,
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
elevation: 4,
|
||||||
|
primary: orangeC, // background
|
||||||
|
onPrimary: Colors.white, // foreground
|
||||||
|
),
|
||||||
|
onPressed: canValidate
|
||||||
|
? () async {
|
||||||
|
log.d('GOOO');
|
||||||
|
WalletData? defaultWallet =
|
||||||
|
myWalletProvider.getDefaultWallet();
|
||||||
|
|
||||||
|
String? pin;
|
||||||
|
if (myWalletProvider.pinCode == '') {
|
||||||
|
pin = await Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (homeContext) {
|
||||||
|
return UnlockingWallet(
|
||||||
|
wallet: defaultWallet);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub.migrateCsToV2(
|
||||||
|
sub.csSalt.text,
|
||||||
|
sub.csPassword.text,
|
||||||
|
selectedWallet.address!,
|
||||||
|
destPassword:
|
||||||
|
pin ?? myWalletProvider.pinCode,
|
||||||
|
balance: balance,
|
||||||
|
idtyStatus: idtyStatus);
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) {
|
||||||
|
return TransactionInProgress(
|
||||||
|
transType: 'identityMigration',
|
||||||
|
fromAddress:
|
||||||
|
getShortPubkey(sub.g1V1NewAddress),
|
||||||
|
toAddress: getShortPubkey(
|
||||||
|
selectedWallet.address!));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
resetScreen(context);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
child: Text(
|
||||||
|
'migrateAccount'.tr(),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 23 * ratio,
|
||||||
|
fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Text(
|
||||||
|
validationStatus,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(fontSize: 15, color: Colors.grey[600]),
|
||||||
|
)
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void resetScreen(BuildContext context) {
|
||||||
|
SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||||
|
|
||||||
|
sub.csSalt.text = '';
|
||||||
|
sub.csPassword.text = '';
|
||||||
|
sub.g1V1NewAddress = '';
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gecko/screens/myWallets/migrate_identity.dart';
|
||||||
// import 'package:gecko/models/wallet_data.dart';
|
// import 'package:gecko/models/wallet_data.dart';
|
||||||
// import 'package:gecko/providers/my_wallets.dart';
|
// import 'package:gecko/providers/my_wallets.dart';
|
||||||
// import 'package:gecko/providers/substrate_sdk.dart';
|
// import 'package:gecko/providers/substrate_sdk.dart';
|
||||||
|
@ -22,19 +24,44 @@ class ManageMembership extends StatelessWidget {
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
toolbarHeight: 60 * ratio,
|
toolbarHeight: 60 * ratio,
|
||||||
title: const SizedBox(
|
title: SizedBox(
|
||||||
height: 22,
|
height: 22,
|
||||||
child: Text('manageMembership'),
|
child: const Text('manageMembership').tr(),
|
||||||
)),
|
)),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Column(children: <Widget>[
|
child: Column(children: <Widget>[
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
revokeMyIdentity(context),
|
migrateIdentity(context),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
revokeMyIdentity(context)
|
||||||
// const SizedBox(height: 20),
|
// const SizedBox(height: 20),
|
||||||
]),
|
]),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget migrateIdentity(BuildContext context) {
|
||||||
|
return InkWell(
|
||||||
|
key: const Key('migrateIdentity'),
|
||||||
|
onTap: () async {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) {
|
||||||
|
return const MigrateIdentityScreen();
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: SizedBox(
|
||||||
|
height: 60,
|
||||||
|
child: Row(children: const <Widget>[
|
||||||
|
SizedBox(width: 16),
|
||||||
|
Icon(Icons.change_circle_outlined, size: 35),
|
||||||
|
SizedBox(width: 11.5),
|
||||||
|
Text('Migrer mon identité', style: TextStyle(fontSize: 20)),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget revokeMyIdentity(BuildContext context) {
|
Widget revokeMyIdentity(BuildContext context) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
key: const Key('revokeIdty'),
|
key: const Key('revokeIdty'),
|
||||||
|
@ -79,14 +106,15 @@ class ManageMembership extends StatelessWidget {
|
||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 40,
|
height: 60,
|
||||||
child: Row(children: const <Widget>[
|
child: Row(children: <Widget>[
|
||||||
SizedBox(width: 32),
|
const SizedBox(width: 20),
|
||||||
// Image.asset(
|
Image.asset(
|
||||||
// 'assets/medal.png',
|
'assets/skull_Icon.png',
|
||||||
// height: 45,
|
height: 30,
|
||||||
// ),
|
),
|
||||||
Text('Révoquer mon adhésion', style: TextStyle(fontSize: 20)),
|
const SizedBox(width: 16),
|
||||||
|
const Text('Révoquer mon adhésion', style: TextStyle(fontSize: 20)),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,252 @@
|
||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||||
|
import 'package:gecko/globals.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gecko/models/wallet_data.dart';
|
||||||
|
import 'package:gecko/providers/duniter_indexer.dart';
|
||||||
|
import 'package:gecko/providers/my_wallets.dart';
|
||||||
|
import 'package:gecko/providers/substrate_sdk.dart';
|
||||||
|
import 'package:gecko/providers/wallet_options.dart';
|
||||||
|
import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
|
||||||
|
import 'package:gecko/screens/transaction_in_progress.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class MigrateIdentityScreen extends StatelessWidget {
|
||||||
|
const MigrateIdentityScreen({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||||
|
// HomeProvider _homeProvider = Provider.of<HomeProvider>(context);
|
||||||
|
WalletOptionsProvider walletOptions =
|
||||||
|
Provider.of<WalletOptionsProvider>(context, listen: false);
|
||||||
|
MyWalletsProvider myWalletProvider =
|
||||||
|
Provider.of<MyWalletsProvider>(context, listen: false);
|
||||||
|
DuniterIndexer duniterIndexer =
|
||||||
|
Provider.of<DuniterIndexer>(context, listen: false);
|
||||||
|
|
||||||
|
final fromAddress = walletOptions.address.text;
|
||||||
|
final defaultWallet = myWalletProvider.getDefaultWallet();
|
||||||
|
final walletsList = myWalletProvider.listWallets.toList();
|
||||||
|
late WalletData selectedWallet;
|
||||||
|
|
||||||
|
if (fromAddress == defaultWallet.address) {
|
||||||
|
selectedWallet =
|
||||||
|
walletsList[fromAddress == walletsList[0].address ? 1 : 0];
|
||||||
|
} else {
|
||||||
|
selectedWallet = defaultWallet;
|
||||||
|
}
|
||||||
|
bool canValidate = false;
|
||||||
|
String validationStatus = '';
|
||||||
|
|
||||||
|
final mdStyle = MarkdownStyleSheet(
|
||||||
|
p: const TextStyle(fontSize: 18, color: Colors.black, letterSpacing: 0.3),
|
||||||
|
textAlign: WrapAlignment.center,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (walletsList.length < 2) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 80),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: const [
|
||||||
|
Text(
|
||||||
|
'Vous devez avoir au moins 2 portefeuilles\npour effecter cette opération',
|
||||||
|
style: TextStyle(fontSize: 20),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: backgroundColor,
|
||||||
|
appBar: AppBar(
|
||||||
|
toolbarHeight: 60 * ratio,
|
||||||
|
title: SizedBox(
|
||||||
|
height: 22,
|
||||||
|
child: Text('importOldAccount'.tr()),
|
||||||
|
)),
|
||||||
|
body: SafeArea(
|
||||||
|
child: Consumer<SubstrateSdk>(builder: (context, sub, _) {
|
||||||
|
return FutureBuilder(
|
||||||
|
future: sub.getBalanceAndIdtyStatus(
|
||||||
|
fromAddress, selectedWallet.address!),
|
||||||
|
builder: (BuildContext context, AsyncSnapshot<List> status) {
|
||||||
|
if (status.data == null) {
|
||||||
|
return Column(children: [
|
||||||
|
const SizedBox(height: 80),
|
||||||
|
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 35,
|
||||||
|
width: 35,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: orangeC,
|
||||||
|
strokeWidth: 4,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// log.d('statusData: ${status.data}');
|
||||||
|
|
||||||
|
final Map balance = status.data?[0] ?? {};
|
||||||
|
final String idtyStatus = status.data?[1];
|
||||||
|
final String myIdtyStatus = status.data?[2];
|
||||||
|
final bool hasConsumer = status.data?[3] ?? false;
|
||||||
|
|
||||||
|
// log.d('hasconsumer: $hasConsumer');
|
||||||
|
|
||||||
|
if (balance['transferableBalance'] != 0 && !hasConsumer) {
|
||||||
|
canValidate = true;
|
||||||
|
validationStatus = '';
|
||||||
|
} else {
|
||||||
|
canValidate = false;
|
||||||
|
validationStatus = hasConsumer
|
||||||
|
? 'youMustWaitBeforeCashoutThisAccount'.tr(args: ['X'])
|
||||||
|
: 'thisAccountIsEmpty'.tr();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (idtyStatus != 'noid' && myIdtyStatus != 'noid') {
|
||||||
|
canValidate = false;
|
||||||
|
validationStatus =
|
||||||
|
'youCannotMigrateIdentityToExistingIdentity'.tr();
|
||||||
|
}
|
||||||
|
|
||||||
|
log.d(
|
||||||
|
'tatatata: ${sub.g1V1NewAddress}, ${selectedWallet.address!}, $balance, $idtyStatus, $myIdtyStatus');
|
||||||
|
|
||||||
|
final walletsList = myWalletProvider.listWallets.toList();
|
||||||
|
|
||||||
|
walletsList
|
||||||
|
.removeWhere((element) => element.address == fromAddress);
|
||||||
|
// walletsList.add(WalletData(address: 'custom', name: 'custom'));
|
||||||
|
|
||||||
|
return Column(children: <Widget>[
|
||||||
|
Row(children: const []),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
|
||||||
|
SizedBox(
|
||||||
|
width: 350,
|
||||||
|
child: MarkdownBody(
|
||||||
|
data: 'areYouSureMigrateIdentity'.tr(args: [
|
||||||
|
duniterIndexer.walletNameIndexer[fromAddress] ??
|
||||||
|
'???',
|
||||||
|
'${balance['transferableBalance']} $currencyName'
|
||||||
|
]),
|
||||||
|
styleSheet: mdStyle),
|
||||||
|
),
|
||||||
|
// Text(
|
||||||
|
// 'areYouSureMigrateIdentity'.tr(args: [
|
||||||
|
// duniterIndexer
|
||||||
|
// .walletNameIndexer[fromAddress]!,
|
||||||
|
// '$balance $currencyName'
|
||||||
|
// ]),
|
||||||
|
// textAlign: TextAlign.center,
|
||||||
|
// ),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Text(
|
||||||
|
sub.g1V1NewAddress,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 14.0,
|
||||||
|
color: Colors.black,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontFamily: 'Monospace'),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
Text('selectDestWallet'.tr()),
|
||||||
|
const SizedBox(height: 5),
|
||||||
|
DropdownButtonHideUnderline(
|
||||||
|
child: DropdownButton(
|
||||||
|
// alignment: AlignmentDirectional.topStart,
|
||||||
|
value: selectedWallet,
|
||||||
|
icon: const Icon(Icons.keyboard_arrow_down),
|
||||||
|
items: walletsList.map((wallet) {
|
||||||
|
return DropdownMenuItem(
|
||||||
|
value: wallet,
|
||||||
|
child: Text(
|
||||||
|
wallet.name!,
|
||||||
|
style: const TextStyle(fontSize: 18),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
onChanged: (WalletData? newSelectedWallet) {
|
||||||
|
selectedWallet = newSelectedWallet!;
|
||||||
|
sub.reload();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
SizedBox(
|
||||||
|
width: 380 * ratio,
|
||||||
|
height: 60 * ratio,
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
elevation: 4,
|
||||||
|
primary: orangeC, // background
|
||||||
|
onPrimary: Colors.white, // foreground
|
||||||
|
),
|
||||||
|
onPressed: canValidate
|
||||||
|
? () async {
|
||||||
|
log.d('GOOO');
|
||||||
|
WalletData? defaultWallet =
|
||||||
|
myWalletProvider.getDefaultWallet();
|
||||||
|
|
||||||
|
String? pin;
|
||||||
|
if (myWalletProvider.pinCode == '') {
|
||||||
|
pin = await Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (homeContext) {
|
||||||
|
return UnlockingWallet(
|
||||||
|
wallet: defaultWallet);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub.migrateIdentity(
|
||||||
|
fromAddress: fromAddress,
|
||||||
|
destAddress: selectedWallet.address!,
|
||||||
|
fromPassword: pin ?? myWalletProvider.pinCode,
|
||||||
|
destPassword: pin ?? myWalletProvider.pinCode,
|
||||||
|
withBalance: true,
|
||||||
|
fromBalance: balance);
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) {
|
||||||
|
return TransactionInProgress(
|
||||||
|
transType: 'identityMigration',
|
||||||
|
fromAddress: getShortPubkey(fromAddress),
|
||||||
|
toAddress: getShortPubkey(
|
||||||
|
selectedWallet.address!));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
child: Text(
|
||||||
|
'migrateIdentity'.tr(),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 23 * ratio, fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Text(
|
||||||
|
validationStatus,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(fontSize: 15, color: Colors.grey[600]),
|
||||||
|
)
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -49,110 +49,114 @@ class RestoreChest extends StatelessWidget {
|
||||||
child: Text('restoreAChest'.tr()),
|
child: Text('restoreAChest'.tr()),
|
||||||
)),
|
)),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Column(children: <Widget>[
|
child: Stack(children: [
|
||||||
SizedBox(height: isTall ? 30 : 15),
|
|
||||||
bubbleSpeak('toRestoreEnterMnemonic'.tr()),
|
|
||||||
SizedBox(height: isTall ? 30 : 15),
|
|
||||||
Column(children: <Widget>[
|
Column(children: <Widget>[
|
||||||
Row(
|
SizedBox(height: isTall ? 30 : 15),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
bubbleSpeak('toRestoreEnterMnemonic'.tr()),
|
||||||
children: <Widget>[
|
SizedBox(height: isTall ? 30 : 15),
|
||||||
arrayCell(context, genW.cellController0),
|
Column(children: <Widget>[
|
||||||
arrayCell(context, genW.cellController1),
|
Row(
|
||||||
arrayCell(context, genW.cellController2),
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
arrayCell(context, genW.cellController3),
|
children: <Widget>[
|
||||||
]),
|
arrayCell(context, genW.cellController0),
|
||||||
const SizedBox(height: 15),
|
arrayCell(context, genW.cellController1),
|
||||||
Row(
|
arrayCell(context, genW.cellController2),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
arrayCell(context, genW.cellController3),
|
||||||
children: <Widget>[
|
]),
|
||||||
arrayCell(context, genW.cellController4),
|
const SizedBox(height: 15),
|
||||||
arrayCell(context, genW.cellController5),
|
Row(
|
||||||
arrayCell(context, genW.cellController6),
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
arrayCell(context, genW.cellController7),
|
children: <Widget>[
|
||||||
]),
|
arrayCell(context, genW.cellController4),
|
||||||
const SizedBox(height: 15),
|
arrayCell(context, genW.cellController5),
|
||||||
Row(
|
arrayCell(context, genW.cellController6),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
arrayCell(context, genW.cellController7),
|
||||||
children: <Widget>[
|
]),
|
||||||
arrayCell(context, genW.cellController8),
|
const SizedBox(height: 15),
|
||||||
arrayCell(context, genW.cellController9),
|
Row(
|
||||||
arrayCell(context, genW.cellController10),
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
arrayCell(context, genW.cellController11),
|
children: <Widget>[
|
||||||
]),
|
arrayCell(context, genW.cellController8),
|
||||||
]),
|
arrayCell(context, genW.cellController9),
|
||||||
// const Spacer(),
|
arrayCell(context, genW.cellController10),
|
||||||
if (genW.isSentenceComplete(context))
|
arrayCell(context, genW.cellController11),
|
||||||
Expanded(
|
]),
|
||||||
child: Align(
|
]),
|
||||||
alignment: Alignment.center,
|
// const Spacer(),
|
||||||
child: SizedBox(
|
if (genW.isSentenceComplete(context))
|
||||||
width: 410,
|
Expanded(
|
||||||
height: 70,
|
child: Align(
|
||||||
child: ElevatedButton(
|
alignment: Alignment.center,
|
||||||
style: ElevatedButton.styleFrom(
|
child: SizedBox(
|
||||||
elevation: 4,
|
width: 410,
|
||||||
primary: orangeC, // background
|
height: 70,
|
||||||
onPrimary: Colors.white, // foreground
|
child: ElevatedButton(
|
||||||
),
|
|
||||||
onPressed: () async {
|
|
||||||
if (await sub.isMnemonicValid(genW.generatedMnemonic!)) {
|
|
||||||
genW.resetImportView();
|
|
||||||
await Navigator.push(
|
|
||||||
context,
|
|
||||||
FaderTransition(
|
|
||||||
page: skipIntro
|
|
||||||
? const OnboardingStepNine(
|
|
||||||
scanDerivation: true)
|
|
||||||
: const OnboardingStepSeven(
|
|
||||||
scanDerivation: true),
|
|
||||||
isFast: true),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
await badMnemonicPopup(context);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
'restoreThisChest'.tr(),
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 24, fontWeight: FontWeight.w600),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// SizedBox(height: isTall ? 80 : 80),
|
|
||||||
))
|
|
||||||
else
|
|
||||||
Column(children: [
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
SizedBox(
|
|
||||||
width: 190,
|
|
||||||
height: 60,
|
|
||||||
child: ElevatedButton(
|
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
elevation: 4,
|
elevation: 4,
|
||||||
primary: yellowC, // background
|
primary: orangeC, // background
|
||||||
onPrimary: Colors.black, // foreground
|
onPrimary: Colors.white, // foreground
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
genW.pasteMnemonic(context);
|
if (await sub
|
||||||
|
.isMnemonicValid(genW.generatedMnemonic!)) {
|
||||||
|
genW.resetImportView();
|
||||||
|
await Navigator.push(
|
||||||
|
context,
|
||||||
|
FaderTransition(
|
||||||
|
page: skipIntro
|
||||||
|
? const OnboardingStepNine(
|
||||||
|
scanDerivation: true)
|
||||||
|
: const OnboardingStepSeven(
|
||||||
|
scanDerivation: true),
|
||||||
|
isFast: true),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await badMnemonicPopup(context);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Text(
|
||||||
children: [
|
'restoreThisChest'.tr(),
|
||||||
const Icon(
|
style: const TextStyle(
|
||||||
Icons.content_paste_go,
|
fontSize: 24, fontWeight: FontWeight.w600),
|
||||||
size: 25,
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
),
|
||||||
Text(
|
// SizedBox(height: isTall ? 80 : 80),
|
||||||
'pasteFromClipboard'.tr(),
|
))
|
||||||
textAlign: TextAlign.center,
|
else
|
||||||
style: const TextStyle(
|
Column(children: [
|
||||||
fontSize: 17, fontWeight: FontWeight.w400),
|
const SizedBox(height: 20),
|
||||||
),
|
SizedBox(
|
||||||
],
|
width: 190,
|
||||||
)),
|
height: 60,
|
||||||
)
|
child: ElevatedButton(
|
||||||
])
|
style: ElevatedButton.styleFrom(
|
||||||
|
elevation: 4,
|
||||||
|
primary: yellowC, // background
|
||||||
|
onPrimary: Colors.black, // foreground
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
genW.pasteMnemonic(context);
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(
|
||||||
|
Icons.content_paste_go,
|
||||||
|
size: 25,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Text(
|
||||||
|
'pasteFromClipboard'.tr(),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 17, fontWeight: FontWeight.w400),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
)
|
||||||
|
])
|
||||||
|
]),
|
||||||
|
CommonElements().offlineInfo(context),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -14,6 +14,7 @@ import 'package:gecko/providers/wallet_options.dart';
|
||||||
import 'package:gecko/screens/common_elements.dart';
|
import 'package:gecko/screens/common_elements.dart';
|
||||||
import 'package:gecko/screens/myWallets/chest_options.dart';
|
import 'package:gecko/screens/myWallets/chest_options.dart';
|
||||||
import 'package:gecko/screens/myWallets/choose_chest.dart';
|
import 'package:gecko/screens/myWallets/choose_chest.dart';
|
||||||
|
import 'package:gecko/screens/myWallets/import_g1_v1.dart';
|
||||||
import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
|
import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
|
||||||
import 'package:gecko/screens/myWallets/wallet_options.dart';
|
import 'package:gecko/screens/myWallets/wallet_options.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
@ -64,12 +65,10 @@ class WalletsHome extends StatelessWidget {
|
||||||
),
|
),
|
||||||
bottomNavigationBar: homeProvider.bottomAppBar(context),
|
bottomNavigationBar: homeProvider.bottomAppBar(context),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Stack(
|
child: Stack(children: [
|
||||||
children: [
|
myWalletsTiles(context, currentChestNumber),
|
||||||
myWalletsTiles(context, currentChestNumber),
|
CommonElements().offlineInfo(context),
|
||||||
CommonElements().offlineInfo(context),
|
]),
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -80,7 +79,7 @@ class WalletsHome extends StatelessWidget {
|
||||||
return Column(children: [
|
return Column(children: [
|
||||||
const SizedBox(height: 50),
|
const SizedBox(height: 50),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 90,
|
height: 80,
|
||||||
width: 420,
|
width: 420,
|
||||||
child: ElevatedButton.icon(
|
child: ElevatedButton.icon(
|
||||||
icon: Image.asset(
|
icon: Image.asset(
|
||||||
|
@ -108,6 +107,28 @@ class WalletsHome extends StatelessWidget {
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
|
InkWell(
|
||||||
|
key: const Key('importG1v1'),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) {
|
||||||
|
return const ImportG1v1();
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: SizedBox(
|
||||||
|
width: 400,
|
||||||
|
height: 60,
|
||||||
|
child: Center(
|
||||||
|
child: Text('importG1v1'.tr(),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 22,
|
||||||
|
color: Colors.blue[900],
|
||||||
|
fontWeight: FontWeight.w500))),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 5),
|
||||||
InkWell(
|
InkWell(
|
||||||
key: const Key('changeChest'),
|
key: const Key('changeChest'),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
@ -120,7 +141,7 @@ class WalletsHome extends StatelessWidget {
|
||||||
},
|
},
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 400,
|
width: 400,
|
||||||
height: 50,
|
height: 60,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text('changeChest'.tr(),
|
child: Text('changeChest'.tr(),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
@ -168,7 +189,6 @@ class WalletsHome extends StatelessWidget {
|
||||||
|
|
||||||
return CustomScrollView(slivers: <Widget>[
|
return CustomScrollView(slivers: <Widget>[
|
||||||
const SliverToBoxAdapter(child: SizedBox(height: 20)),
|
const SliverToBoxAdapter(child: SizedBox(height: 20)),
|
||||||
|
|
||||||
SliverGrid.count(
|
SliverGrid.count(
|
||||||
key: const Key('listWallets'),
|
key: const Key('listWallets'),
|
||||||
crossAxisCount: nTule,
|
crossAxisCount: nTule,
|
||||||
|
|
|
@ -27,15 +27,18 @@ class OnboardingStepOne extends StatelessWidget {
|
||||||
),
|
),
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: common.infoIntro(
|
child: Stack(children: [
|
||||||
context,
|
common.infoIntro(
|
||||||
'geckoGenerateYourWalletFromMnemonic'.tr(),
|
context,
|
||||||
'fabrication-de-portefeuille.png',
|
'geckoGenerateYourWalletFromMnemonic'.tr(),
|
||||||
'>',
|
'fabrication-de-portefeuille.png',
|
||||||
const OnboardingStepTwo(),
|
'>',
|
||||||
0,
|
const OnboardingStepTwo(),
|
||||||
isMd: true,
|
0,
|
||||||
),
|
isMd: true,
|
||||||
|
),
|
||||||
|
CommonElements().offlineInfo(context),
|
||||||
|
]),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,79 +49,82 @@ class OnboardingStepTen extends StatelessWidget {
|
||||||
),
|
),
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Column(children: <Widget>[
|
child: Stack(children: [
|
||||||
SizedBox(height: isTall ? 40 : 20),
|
Column(children: <Widget>[
|
||||||
common.buildProgressBar(9),
|
SizedBox(height: isTall ? 40 : 20),
|
||||||
SizedBox(height: isTall ? 40 : 20),
|
common.buildProgressBar(9),
|
||||||
common.buildText("geckoWillCheckPassword".tr()),
|
SizedBox(height: isTall ? 40 : 20),
|
||||||
SizedBox(height: isTall ? 80 : 20),
|
common.buildText("geckoWillCheckPassword".tr()),
|
||||||
Visibility(
|
SizedBox(height: isTall ? 80 : 20),
|
||||||
visible: generateWalletProvider.scanedValidWalletNumber != -1,
|
Visibility(
|
||||||
child: Padding(
|
visible: generateWalletProvider.scanedValidWalletNumber != -1,
|
||||||
padding: const EdgeInsets.only(bottom: 15),
|
child: Padding(
|
||||||
child: Row(
|
padding: const EdgeInsets.only(bottom: 15),
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
child: Row(
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
Text("derivationsScanProgress".tr(args: [
|
children: [
|
||||||
'${generateWalletProvider.scanedWalletNumber}',
|
Text("derivationsScanProgress".tr(args: [
|
||||||
'${generateWalletProvider.numberScan + 1}'
|
'${generateWalletProvider.scanedWalletNumber}',
|
||||||
])),
|
'${generateWalletProvider.numberScan + 1}'
|
||||||
const SizedBox(width: 10),
|
])),
|
||||||
SizedBox(
|
const SizedBox(width: 10),
|
||||||
height: 22,
|
SizedBox(
|
||||||
width: 22,
|
height: 22,
|
||||||
child: CircularProgressIndicator(
|
width: 22,
|
||||||
color: orangeC,
|
child: CircularProgressIndicator(
|
||||||
strokeWidth: 3,
|
color: orangeC,
|
||||||
|
strokeWidth: 3,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
Consumer<SubstrateSdk>(builder: (context, sub, _) {
|
||||||
Consumer<SubstrateSdk>(builder: (context, sub, _) {
|
return sub.nodeConnected
|
||||||
return sub.nodeConnected
|
? pinForm(context, walletOptions, pinLenght, 1, 2)
|
||||||
? pinForm(context, walletOptions, pinLenght, 1, 2)
|
: Row(
|
||||||
: Row(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
children: const [
|
||||||
children: const [
|
Text(
|
||||||
Text(
|
'Vous devez vous connecter à internet\npour valider votre coffre',
|
||||||
'Vous devez vous connecter à internet\npour valider votre coffre',
|
style: TextStyle(
|
||||||
style: TextStyle(
|
fontSize: 20,
|
||||||
fontSize: 20,
|
color: Colors.redAccent,
|
||||||
color: Colors.redAccent,
|
fontWeight: FontWeight.w500,
|
||||||
fontWeight: FontWeight.w500,
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.center,
|
]);
|
||||||
|
}),
|
||||||
|
Consumer<SubstrateSdk>(builder: (context, sub, _) {
|
||||||
|
return sub.nodeConnected
|
||||||
|
? InkWell(
|
||||||
|
onTap: () {
|
||||||
|
walletOptions.changePinCacheChoice();
|
||||||
|
},
|
||||||
|
child: Row(children: [
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
const Spacer(),
|
||||||
|
Icon(
|
||||||
|
configBox.get('isCacheChecked') ?? false
|
||||||
|
? Icons.check_box
|
||||||
|
: Icons.check_box_outline_blank,
|
||||||
|
color: orangeC,
|
||||||
),
|
),
|
||||||
]);
|
const SizedBox(width: 8),
|
||||||
}),
|
Text(
|
||||||
Consumer<SubstrateSdk>(builder: (context, sub, _) {
|
'rememberPassword'.tr(),
|
||||||
return sub.nodeConnected
|
style: TextStyle(
|
||||||
? InkWell(
|
fontSize: 16, color: Colors.grey[700]),
|
||||||
onTap: () {
|
),
|
||||||
walletOptions.changePinCacheChoice();
|
const Spacer()
|
||||||
},
|
]))
|
||||||
child: Row(children: [
|
: const Text('');
|
||||||
const SizedBox(height: 30),
|
}),
|
||||||
const Spacer(),
|
const SizedBox(height: 10),
|
||||||
Icon(
|
]),
|
||||||
configBox.get('isCacheChecked') ?? false
|
CommonElements().offlineInfo(context),
|
||||||
? Icons.check_box
|
|
||||||
: Icons.check_box_outline_blank,
|
|
||||||
color: orangeC,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Text(
|
|
||||||
'rememberPassword'.tr(),
|
|
||||||
style:
|
|
||||||
TextStyle(fontSize: 16, color: Colors.grey[700]),
|
|
||||||
),
|
|
||||||
const Spacer()
|
|
||||||
]))
|
|
||||||
: const Text('');
|
|
||||||
}),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
]),
|
]),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,13 +29,16 @@ class OnboardingStepTwo extends StatelessWidget {
|
||||||
),
|
),
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: common.infoIntro(
|
child: Stack(children: [
|
||||||
context,
|
common.infoIntro(
|
||||||
'keepThisMnemonicSecure'.tr(),
|
context,
|
||||||
'fabrication-de-portefeuille-impossible-sans-phrase.png',
|
'keepThisMnemonicSecure'.tr(),
|
||||||
'>',
|
'fabrication-de-portefeuille-impossible-sans-phrase.png',
|
||||||
const OnboardingStepThree(),
|
'>',
|
||||||
1),
|
const OnboardingStepThree(),
|
||||||
|
1),
|
||||||
|
CommonElements().offlineInfo(context),
|
||||||
|
]),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,11 @@ class OnboardingStepThree extends StatelessWidget {
|
||||||
),
|
),
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: common.infoIntro(context, 'warningForgotPassword'.tr(),
|
child: Stack(children: [
|
||||||
'forgot_password.png'.tr(), '>', const OnboardingStepFor(), 2),
|
common.infoIntro(context, 'warningForgotPassword'.tr(),
|
||||||
|
'forgot_password.png'.tr(), '>', const OnboardingStepFor(), 2),
|
||||||
|
CommonElements().offlineInfo(context),
|
||||||
|
]),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,14 +29,17 @@ class OnboardingStepFor extends StatelessWidget {
|
||||||
),
|
),
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: common.infoIntro(
|
child: Stack(children: [
|
||||||
context,
|
common.infoIntro(
|
||||||
'itsTimeToUseAPenAndPaper'.tr(),
|
context,
|
||||||
'gecko_also_can_forget.png'.tr(),
|
'itsTimeToUseAPenAndPaper'.tr(),
|
||||||
'>',
|
'gecko_also_can_forget.png'.tr(),
|
||||||
const OnboardingStepFive(),
|
'>',
|
||||||
3,
|
const OnboardingStepFive(),
|
||||||
isMd: true),
|
3,
|
||||||
|
isMd: true),
|
||||||
|
CommonElements().offlineInfo(context),
|
||||||
|
]),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,57 +48,62 @@ class _ChooseChestState extends State<OnboardingStepFive> {
|
||||||
),
|
),
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Column(children: [
|
child: Stack(children: [
|
||||||
SizedBox(height: isTall ? 40 : 20),
|
Column(children: [
|
||||||
common.buildProgressBar(4),
|
SizedBox(height: isTall ? 40 : 20),
|
||||||
SizedBox(height: isTall ? 40 : 20),
|
common.buildProgressBar(4),
|
||||||
common.buildText('geckoGeneratedYourMnemonicKeepItSecret'.tr()),
|
SizedBox(height: isTall ? 40 : 20),
|
||||||
SizedBox(height: 35 * ratio),
|
common.buildText('geckoGeneratedYourMnemonicKeepItSecret'.tr()),
|
||||||
sentanceArray(context),
|
SizedBox(height: 35 * ratio),
|
||||||
SizedBox(height: 17 * ratio),
|
sentanceArray(context),
|
||||||
GestureDetector(
|
SizedBox(height: 17 * ratio),
|
||||||
onTap: () {
|
GestureDetector(
|
||||||
Navigator.push(
|
onTap: () {
|
||||||
context,
|
Navigator.push(
|
||||||
MaterialPageRoute(builder: (context) {
|
context,
|
||||||
return PrintWallet(generateWalletProvider.generatedMnemonic);
|
MaterialPageRoute(builder: (context) {
|
||||||
}),
|
return PrintWallet(
|
||||||
);
|
generateWalletProvider.generatedMnemonic);
|
||||||
},
|
}),
|
||||||
child: Image.asset(
|
);
|
||||||
'assets/printer.png',
|
},
|
||||||
height: 42 * ratio,
|
child: Image.asset(
|
||||||
),
|
'assets/printer.png',
|
||||||
),
|
height: 42 * ratio,
|
||||||
const SizedBox(height: 40),
|
|
||||||
Expanded(
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.bottomCenter,
|
|
||||||
child: SizedBox(
|
|
||||||
width: 380 * ratio,
|
|
||||||
height: 60 * ratio,
|
|
||||||
child: ElevatedButton(
|
|
||||||
key: const Key('generateMnemonic'),
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
elevation: 4,
|
|
||||||
primary: const Color(0xffFFD58D),
|
|
||||||
onPrimary: Colors.black, // foreground
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
// _generateWalletProvider.reloadBuild();
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
child: Text("chooseAnotherMnemonic".tr(),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 22 * ratio,
|
|
||||||
fontWeight: FontWeight.w600))),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 40),
|
||||||
SizedBox(height: 22 * ratio),
|
Expanded(
|
||||||
nextButton(context, "iNotedMyMnemonic".tr(), false, widget.skipIntro),
|
child: Align(
|
||||||
SizedBox(height: 35 * ratio),
|
alignment: Alignment.bottomCenter,
|
||||||
|
child: SizedBox(
|
||||||
|
width: 380 * ratio,
|
||||||
|
height: 60 * ratio,
|
||||||
|
child: ElevatedButton(
|
||||||
|
key: const Key('generateMnemonic'),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
elevation: 4,
|
||||||
|
primary: const Color(0xffFFD58D),
|
||||||
|
onPrimary: Colors.black, // foreground
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
// _generateWalletProvider.reloadBuild();
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
child: Text("chooseAnotherMnemonic".tr(),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 22 * ratio,
|
||||||
|
fontWeight: FontWeight.w600))),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 22 * ratio),
|
||||||
|
nextButton(
|
||||||
|
context, "iNotedMyMnemonic".tr(), false, widget.skipIntro),
|
||||||
|
SizedBox(height: 35 * ratio),
|
||||||
|
]),
|
||||||
|
CommonElements().offlineInfo(context),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -51,88 +51,92 @@ class OnboardingStepSix extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Align(
|
child: Stack(children: [
|
||||||
alignment: Alignment.topCenter,
|
Align(
|
||||||
child: Column(children: [
|
alignment: Alignment.topCenter,
|
||||||
SizedBox(height: isTall ? 40 : 20),
|
child: Column(children: [
|
||||||
common.buildProgressBar(5),
|
SizedBox(height: isTall ? 40 : 20),
|
||||||
SizedBox(height: isTall ? 40 : 20),
|
common.buildProgressBar(5),
|
||||||
common.buildText(
|
SizedBox(height: isTall ? 40 : 20),
|
||||||
"didYouNoteMnemonicToBeSureTypeWord".tr(
|
common.buildText(
|
||||||
args: [(generateWalletProvider.nbrWord + 1).toString()]),
|
"didYouNoteMnemonicToBeSureTypeWord".tr(args: [
|
||||||
20,
|
(generateWalletProvider.nbrWord + 1).toString()
|
||||||
true),
|
]),
|
||||||
SizedBox(height: isTall ? 70 : 20),
|
20,
|
||||||
Text('${generateWalletProvider.nbrWord + 1}',
|
true),
|
||||||
key: const Key('askedWord'),
|
SizedBox(height: isTall ? 70 : 20),
|
||||||
style: TextStyle(
|
Text('${generateWalletProvider.nbrWord + 1}',
|
||||||
fontSize: isTall ? 17 : 15,
|
key: const Key('askedWord'),
|
||||||
color: orangeC,
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.w400)),
|
fontSize: isTall ? 17 : 15,
|
||||||
const SizedBox(height: 10),
|
color: orangeC,
|
||||||
Container(
|
fontWeight: FontWeight.w400)),
|
||||||
decoration: BoxDecoration(
|
const SizedBox(height: 10),
|
||||||
borderRadius: BorderRadius.circular(7),
|
Container(
|
||||||
border: Border.all(
|
decoration: BoxDecoration(
|
||||||
color: Colors.grey[600]!,
|
borderRadius: BorderRadius.circular(7),
|
||||||
width: 3,
|
border: Border.all(
|
||||||
)),
|
color: Colors.grey[600]!,
|
||||||
width: 430,
|
width: 3,
|
||||||
child: TextFormField(
|
)),
|
||||||
key: const Key('inputWord'),
|
width: 430,
|
||||||
autofocus: true,
|
child: TextFormField(
|
||||||
enabled: !generateWalletProvider.isAskedWordValid,
|
key: const Key('inputWord'),
|
||||||
controller: wordController,
|
autofocus: true,
|
||||||
textInputAction: TextInputAction.next,
|
enabled: !generateWalletProvider.isAskedWordValid,
|
||||||
onChanged: (value) {
|
controller: wordController,
|
||||||
generateWalletProvider.checkAskedWord(
|
textInputAction: TextInputAction.next,
|
||||||
value, _mnemonicController.text);
|
onChanged: (value) {
|
||||||
},
|
generateWalletProvider.checkAskedWord(
|
||||||
maxLines: 1,
|
value, _mnemonicController.text);
|
||||||
textAlign: TextAlign.center,
|
},
|
||||||
decoration: InputDecoration(
|
maxLines: 1,
|
||||||
labelStyle: TextStyle(
|
textAlign: TextAlign.center,
|
||||||
fontSize: 22.0,
|
decoration: InputDecoration(
|
||||||
color: Colors.grey[500],
|
labelStyle: TextStyle(
|
||||||
fontWeight: FontWeight.w500),
|
fontSize: 22.0,
|
||||||
labelText: generateWalletProvider.isAskedWordValid
|
color: Colors.grey[500],
|
||||||
? "itsTheGoodWord".tr()
|
fontWeight: FontWeight.w500),
|
||||||
: "${generateWalletProvider.nbrWordAlpha} ${"nthMnemonicWord".tr()}",
|
labelText: generateWalletProvider.isAskedWordValid
|
||||||
fillColor: const Color(0xffeeeedd),
|
? "itsTheGoodWord".tr()
|
||||||
filled: true,
|
: "${generateWalletProvider.nbrWordAlpha} ${"nthMnemonicWord".tr()}",
|
||||||
contentPadding: const EdgeInsets.all(12),
|
fillColor: const Color(0xffeeeedd),
|
||||||
),
|
filled: true,
|
||||||
style: TextStyle(
|
contentPadding: const EdgeInsets.all(12),
|
||||||
fontSize: 40.0,
|
),
|
||||||
color: generateWalletProvider.askedWordColor,
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.w500))),
|
fontSize: 40.0,
|
||||||
Visibility(
|
color: generateWalletProvider.askedWordColor,
|
||||||
visible: generateWalletProvider.isAskedWordValid,
|
fontWeight: FontWeight.w500))),
|
||||||
child: Expanded(
|
Visibility(
|
||||||
child: Align(
|
visible: generateWalletProvider.isAskedWordValid,
|
||||||
alignment: Alignment.bottomCenter,
|
child: Expanded(
|
||||||
child: nextButton(
|
child: Align(
|
||||||
context,
|
alignment: Alignment.bottomCenter,
|
||||||
'continue'.tr(),
|
child: nextButton(
|
||||||
skipIntro
|
context,
|
||||||
? const OnboardingStepNine()
|
'continue'.tr(),
|
||||||
: const OnboardingStepSeven(),
|
skipIntro
|
||||||
false),
|
? const OnboardingStepNine()
|
||||||
|
: const OnboardingStepSeven(),
|
||||||
|
false),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
// Visibility(
|
||||||
// Visibility(
|
// visible: !_generateWalletProvider.isAskedWordValid,
|
||||||
// visible: !_generateWalletProvider.isAskedWordValid,
|
// child: const Expanded(
|
||||||
// child: const Expanded(
|
// child: Align(
|
||||||
// child: Align(
|
// alignment: Alignment.bottomCenter,
|
||||||
// alignment: Alignment.bottomCenter,
|
// child: Text(''),
|
||||||
// child: Text(''),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
// ),
|
SizedBox(height: 35 * ratio),
|
||||||
SizedBox(height: 35 * ratio),
|
]),
|
||||||
]),
|
),
|
||||||
),
|
CommonElements().offlineInfo(context),
|
||||||
|
]),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -29,14 +29,17 @@ class OnboardingStepSeven extends StatelessWidget {
|
||||||
),
|
),
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: common.infoIntro(
|
child: Stack(children: [
|
||||||
context,
|
common.infoIntro(
|
||||||
'geckoWillGenerateAPassword'.tr(),
|
context,
|
||||||
'coffre-fort-code-secret-dans-telephone.png',
|
'geckoWillGenerateAPassword'.tr(),
|
||||||
'>',
|
'coffre-fort-code-secret-dans-telephone.png',
|
||||||
OnboardingStepEight(scanDerivation: scanDerivation),
|
'>',
|
||||||
6,
|
OnboardingStepEight(scanDerivation: scanDerivation),
|
||||||
boxHeight: 400),
|
6,
|
||||||
|
boxHeight: 400),
|
||||||
|
CommonElements().offlineInfo(context),
|
||||||
|
]),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,14 +29,17 @@ class OnboardingStepEight extends StatelessWidget {
|
||||||
),
|
),
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: common.infoIntro(
|
child: Stack(children: [
|
||||||
context,
|
common.infoIntro(
|
||||||
'thisPasswordProtectsYourWalletsInASecureChest'.tr(),
|
context,
|
||||||
'coffre-fort-protege-les-portefeuilles.png',
|
'thisPasswordProtectsYourWalletsInASecureChest'.tr(),
|
||||||
'>',
|
'coffre-fort-protege-les-portefeuilles.png',
|
||||||
OnboardingStepNine(scanDerivation: scanDerivation),
|
'>',
|
||||||
7,
|
OnboardingStepNine(scanDerivation: scanDerivation),
|
||||||
isMd: true),
|
7,
|
||||||
|
isMd: true),
|
||||||
|
CommonElements().offlineInfo(context),
|
||||||
|
]),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,61 +41,65 @@ class OnboardingStepNine extends StatelessWidget {
|
||||||
),
|
),
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Column(children: <Widget>[
|
child: Stack(children: [
|
||||||
SizedBox(height: isTall ? 40 : 20),
|
Column(children: <Widget>[
|
||||||
common.buildProgressBar(8),
|
SizedBox(height: isTall ? 40 : 20),
|
||||||
SizedBox(height: isTall ? 40 : 20),
|
common.buildProgressBar(8),
|
||||||
common.buildText("hereIsThePasswordKeepIt".tr(), 20, true),
|
SizedBox(height: isTall ? 40 : 20),
|
||||||
const SizedBox(height: 100),
|
common.buildText("hereIsThePasswordKeepIt".tr(), 20, true),
|
||||||
Stack(
|
const SizedBox(height: 100),
|
||||||
alignment: Alignment.centerRight,
|
Stack(
|
||||||
children: <Widget>[
|
alignment: Alignment.centerRight,
|
||||||
TextField(
|
children: <Widget>[
|
||||||
key: const Key('generatedPin'),
|
TextField(
|
||||||
enabled: false,
|
key: const Key('generatedPin'),
|
||||||
controller: generateWalletProvider.pin,
|
enabled: false,
|
||||||
maxLines: 1,
|
controller: generateWalletProvider.pin,
|
||||||
textAlign: TextAlign.center,
|
maxLines: 1,
|
||||||
decoration: const InputDecoration(),
|
textAlign: TextAlign.center,
|
||||||
style: const TextStyle(
|
decoration: const InputDecoration(),
|
||||||
letterSpacing: 5,
|
style: const TextStyle(
|
||||||
fontSize: 35.0,
|
letterSpacing: 5,
|
||||||
color: Colors.black,
|
fontSize: 35.0,
|
||||||
fontWeight: FontWeight.bold)),
|
color: Colors.black,
|
||||||
IconButton(
|
fontWeight: FontWeight.bold)),
|
||||||
icon: const Icon(Icons.replay),
|
IconButton(
|
||||||
color: orangeC,
|
icon: const Icon(Icons.replay),
|
||||||
onPressed: () {
|
color: orangeC,
|
||||||
generateWalletProvider.changePinCode(reload: true);
|
onPressed: () {
|
||||||
},
|
generateWalletProvider.changePinCode(reload: true);
|
||||||
),
|
},
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
Expanded(
|
),
|
||||||
child: Align(
|
Expanded(
|
||||||
alignment: Alignment.bottomCenter,
|
child: Align(
|
||||||
child: SizedBox(
|
alignment: Alignment.bottomCenter,
|
||||||
width: 380 * ratio,
|
child: SizedBox(
|
||||||
height: 60 * ratio,
|
width: 380 * ratio,
|
||||||
child: ElevatedButton(
|
height: 60 * ratio,
|
||||||
key: const Key('changeSecretCode'),
|
child: ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
key: const Key('changeSecretCode'),
|
||||||
elevation: 4,
|
style: ElevatedButton.styleFrom(
|
||||||
primary: const Color(0xffFFD58D),
|
elevation: 4,
|
||||||
onPrimary: Colors.black, // foreground
|
primary: const Color(0xffFFD58D),
|
||||||
),
|
onPrimary: Colors.black, // foreground
|
||||||
onPressed: () {
|
),
|
||||||
generateWalletProvider.changePinCode(reload: true);
|
onPressed: () {
|
||||||
},
|
generateWalletProvider.changePinCode(
|
||||||
child: Text("chooseAnotherPassword".tr(),
|
reload: true);
|
||||||
style: TextStyle(
|
},
|
||||||
fontSize: 22 * ratio,
|
child: Text("chooseAnotherPassword".tr(),
|
||||||
fontWeight: FontWeight.w600))),
|
style: TextStyle(
|
||||||
))),
|
fontSize: 22 * ratio,
|
||||||
SizedBox(height: 22 * ratio),
|
fontWeight: FontWeight.w600))),
|
||||||
common.nextButton(context, "iNotedMyPassword".tr(),
|
))),
|
||||||
OnboardingStepTen(scanDerivation: scanDerivation), false),
|
SizedBox(height: 22 * ratio),
|
||||||
SizedBox(height: 35 * ratio),
|
common.nextButton(context, "iNotedMyPassword".tr(),
|
||||||
|
OnboardingStepTen(scanDerivation: scanDerivation), false),
|
||||||
|
SizedBox(height: 35 * ratio),
|
||||||
|
]),
|
||||||
|
CommonElements().offlineInfo(context),
|
||||||
]),
|
]),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,12 @@ import 'package:provider/provider.dart';
|
||||||
|
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
class TransactionInProgress extends StatelessWidget {
|
class TransactionInProgress extends StatelessWidget {
|
||||||
const TransactionInProgress({Key? key, this.transType = 'pay'})
|
const TransactionInProgress(
|
||||||
|
{Key? key, this.transType = 'pay', this.fromAddress, this.toAddress})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
final String transType;
|
final String transType;
|
||||||
|
final String? fromAddress;
|
||||||
|
final String? toAddress;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -32,8 +35,8 @@ class TransactionInProgress extends StatelessWidget {
|
||||||
|
|
||||||
log.d(walletViewProvider.address!);
|
log.d(walletViewProvider.address!);
|
||||||
|
|
||||||
final from = myWalletProvider.getDefaultWallet().name!;
|
final from = fromAddress ?? myWalletProvider.getDefaultWallet().name!;
|
||||||
final to = getShortPubkey(walletViewProvider.address!);
|
final to = toAddress ?? getShortPubkey(walletViewProvider.address!);
|
||||||
final amount = walletViewProvider.payAmount.text;
|
final amount = walletViewProvider.payAmount.text;
|
||||||
String actionName = '';
|
String actionName = '';
|
||||||
|
|
||||||
|
@ -58,6 +61,11 @@ class TransactionInProgress extends StatelessWidget {
|
||||||
actionName = "revokeAdhesion".tr();
|
actionName = "revokeAdhesion".tr();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'identityMigration':
|
||||||
|
{
|
||||||
|
actionName = "identityMigration".tr();
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
actionName = 'strangeTransaction'.tr();
|
actionName = 'strangeTransaction'.tr();
|
||||||
|
@ -88,6 +96,8 @@ class TransactionInProgress extends StatelessWidget {
|
||||||
if (result.contains('blockHash: ')) {
|
if (result.contains('blockHash: ')) {
|
||||||
isValid = true;
|
isValid = true;
|
||||||
resultText = 'extrinsicValidated'.tr(args: [actionName]);
|
resultText = 'extrinsicValidated'.tr(args: [actionName]);
|
||||||
|
log.i(
|
||||||
|
'g1migration Bloc of last transaction: ${sub.blocNumber} --- $result');
|
||||||
} else {
|
} else {
|
||||||
isValid = false;
|
isValid = false;
|
||||||
resultText = "${"anErrorOccured".tr()}:\n";
|
resultText = "${"anErrorOccured".tr()}:\n";
|
||||||
|
@ -146,7 +156,9 @@ class TransactionInProgress extends StatelessWidget {
|
||||||
onWillPop: () {
|
onWillPop: () {
|
||||||
sub.transactionStatus = '';
|
sub.transactionStatus = '';
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
if (transType == 'pay') Navigator.pop(context);
|
if (transType == 'pay' || transType == 'identityMigration') {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
return Future<bool>.value(true);
|
return Future<bool>.value(true);
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
|
@ -259,7 +271,10 @@ class TransactionInProgress extends StatelessWidget {
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
sub.transactionStatus = '';
|
sub.transactionStatus = '';
|
||||||
if (transType == 'pay') Navigator.pop(context);
|
if (transType == 'pay' ||
|
||||||
|
transType == 'identityMigration') {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
'close'.tr(),
|
'close'.tr(),
|
||||||
|
|
|
@ -191,6 +191,8 @@ class WalletViewScreen extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final toStatus = snapshot.data!['toStatus'] ?? 0;
|
||||||
|
|
||||||
return Visibility(
|
return Visibility(
|
||||||
visible: (snapshot.data != {}),
|
visible: (snapshot.data != {}),
|
||||||
child: Column(children: <Widget>[
|
child: Column(children: <Widget>[
|
||||||
|
@ -268,67 +270,14 @@ class WalletViewScreen extends StatelessWidget {
|
||||||
fontSize: buttonFontSize,
|
fontSize: buttonFontSize,
|
||||||
fontWeight: FontWeight.w500),
|
fontWeight: FontWeight.w500),
|
||||||
),
|
),
|
||||||
]),
|
])
|
||||||
if (snapshot.data!['certDelay'] != null)
|
else if (toStatus == 1)
|
||||||
Column(children: <Widget>[
|
waitToCert('mustConfirmHisIdentity', duration)
|
||||||
SizedBox(
|
else if (snapshot.data!['certRenewable'] != null &&
|
||||||
height: buttonSize,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 0),
|
|
||||||
child: Container(
|
|
||||||
foregroundDecoration: const BoxDecoration(
|
|
||||||
color: Colors.grey,
|
|
||||||
backgroundBlendMode: BlendMode.saturation,
|
|
||||||
),
|
|
||||||
child: const Opacity(
|
|
||||||
opacity: 0.5,
|
|
||||||
child: Image(
|
|
||||||
image: AssetImage(
|
|
||||||
'assets/gecko_certify.png')),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
"mustWaitXBeforeCertify"
|
|
||||||
.tr(args: [duration.toString()]),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: buttonFontSize - 4,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
color: Colors.grey[600]),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
if (snapshot.data!['certRenewable'] != null &&
|
|
||||||
duration != 'seconds'.tr(args: ['0']))
|
duration != 'seconds'.tr(args: ['0']))
|
||||||
Column(children: <Widget>[
|
waitToCert('canRenewCertInX', duration)
|
||||||
SizedBox(
|
else if (snapshot.data!['certDelay'] != null)
|
||||||
height: buttonSize,
|
waitToCert('mustWaitXBeforeCertify', duration)
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 0),
|
|
||||||
child: Container(
|
|
||||||
foregroundDecoration: const BoxDecoration(
|
|
||||||
color: Colors.grey,
|
|
||||||
backgroundBlendMode: BlendMode.saturation,
|
|
||||||
),
|
|
||||||
child: const Opacity(
|
|
||||||
opacity: 0.5,
|
|
||||||
child: Image(
|
|
||||||
image: AssetImage(
|
|
||||||
'assets/gecko_certify.png')),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
"canRenewCertInX".tr(args: [duration.toString()]),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: buttonFontSize - 4,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
color: Colors.grey[600]),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -415,6 +364,35 @@ class WalletViewScreen extends StatelessWidget {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget waitToCert(String status, String duration) {
|
||||||
|
return Column(children: <Widget>[
|
||||||
|
SizedBox(
|
||||||
|
height: buttonSize,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 0),
|
||||||
|
child: Container(
|
||||||
|
foregroundDecoration: const BoxDecoration(
|
||||||
|
color: Colors.grey,
|
||||||
|
backgroundBlendMode: BlendMode.saturation,
|
||||||
|
),
|
||||||
|
child: const Opacity(
|
||||||
|
opacity: 0.5,
|
||||||
|
child: Image(image: AssetImage('assets/gecko_certify.png')),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
status.tr(args: [duration]),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: buttonFontSize - 4,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: Colors.grey[600]),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
void paymentPopup(
|
void paymentPopup(
|
||||||
BuildContext context, WalletsProfilesProvider walletViewProvider) {
|
BuildContext context, WalletsProfilesProvider walletViewProvider) {
|
||||||
// WalletsProfilesProvider _walletViewProvider =
|
// WalletsProfilesProvider _walletViewProvider =
|
||||||
|
|
|
@ -557,7 +557,7 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.1.0"
|
||||||
hex:
|
hex:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: hex
|
name: hex
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
|
@ -1052,7 +1052,7 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.2"
|
||||||
pointycastle:
|
pointycastle:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: pointycastle
|
name: pointycastle
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
|
@ -1062,8 +1062,8 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: gecko-old
|
ref: gecko-unwrapbytes
|
||||||
resolved-ref: "87096351fb187614b6386343615db39a2f2b5b9b"
|
resolved-ref: b019cc2a6e77b6989f94b1bef8259298410cd82a
|
||||||
url: "https://github.com/poka-IT/sdk.git"
|
url: "https://github.com/poka-IT/sdk.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.4.8"
|
version: "0.4.8"
|
||||||
|
|
|
@ -5,7 +5,7 @@ description: Pay with G1.
|
||||||
# pub.dev using `pub publish`. This is preferred for private packages.
|
# 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.0.9+21
|
version: 0.0.10+26
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.12.0 <3.0.0'
|
sdk: '>=2.12.0 <3.0.0'
|
||||||
|
@ -62,8 +62,11 @@ dependencies:
|
||||||
package_info_plus: ^1.4.2
|
package_info_plus: ^1.4.2
|
||||||
polkawallet_sdk: #^0.4.9
|
polkawallet_sdk: #^0.4.9
|
||||||
git:
|
git:
|
||||||
|
# url: https://github.com/polkawallet-io/sdk.git
|
||||||
|
# ref: develop
|
||||||
url: https://github.com/poka-IT/sdk.git
|
url: https://github.com/poka-IT/sdk.git
|
||||||
ref: gecko-old
|
# ref: gecko-old
|
||||||
|
ref: gecko-unwrapbytes
|
||||||
dots_indicator: ^2.1.0
|
dots_indicator: ^2.1.0
|
||||||
web_socket_channel: ^2.2.0
|
web_socket_channel: ^2.2.0
|
||||||
connectivity_plus: ^2.3.3
|
connectivity_plus: ^2.3.3
|
||||||
|
@ -71,6 +74,8 @@ dependencies:
|
||||||
easy_localization: ^3.0.1
|
easy_localization: ^3.0.1
|
||||||
flutter_markdown: ^0.6.10+2
|
flutter_markdown: ^0.6.10+2
|
||||||
dropdown_button2: ^1.6.3
|
dropdown_button2: ^1.6.3
|
||||||
|
pointycastle: ^3.6.1
|
||||||
|
hex: ^0.2.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
# flutter_launcher_icons: ^0.9.2
|
# flutter_launcher_icons: ^0.9.2
|
||||||
|
|
Loading…
Reference in New Issue