Merge branch 'dev'
This commit is contained in:
commit
0bf9a42dd3
|
@ -3,8 +3,7 @@ version: "3.5"
|
|||
services:
|
||||
duniter-v2s-gecko-tests:
|
||||
container_name: duniter-v2s-gecko-tests
|
||||
# image: duniter/duniter-v2s:debug-sha-4d5e08be
|
||||
image: duniter/duniter-v2s:debug-sha-44b09061
|
||||
image: duniter/duniter-v2s-gdev:latest
|
||||
command: --alice --force-authoring --reserved-only --no-mdns
|
||||
#--sealing=manual
|
||||
ports:
|
||||
|
|
|
@ -27,7 +27,7 @@ void main() async {
|
|||
await tapKey(keyImportG1v1);
|
||||
await enterText(keyCesiumId, 'test');
|
||||
await enterText(keyCesiumPassword, 'test');
|
||||
await waitFor('DCovzCEnQm9GUWe6mr8u42JR1JAuoj3HbQUGdCkfTzSr');
|
||||
await waitFor('DCovzC');
|
||||
await waitFor('100.0');
|
||||
await waitFor('3', exactMatch: true);
|
||||
|
||||
|
|
|
@ -1,21 +1,24 @@
|
|||
import 'package:gecko/models/wallet_data.dart';
|
||||
|
||||
class MigrateWalletChecks {
|
||||
final Map balance;
|
||||
final IdtyStatus idtyStatus;
|
||||
final Map fromBalance;
|
||||
final IdtyStatus fromIdtyStatus;
|
||||
final IdtyStatus toIdtyStatus;
|
||||
final String validationStatus;
|
||||
final bool canValidate;
|
||||
|
||||
const MigrateWalletChecks({
|
||||
required this.balance,
|
||||
required this.idtyStatus,
|
||||
required this.fromBalance,
|
||||
required this.fromIdtyStatus,
|
||||
required this.toIdtyStatus,
|
||||
required this.validationStatus,
|
||||
required this.canValidate,
|
||||
});
|
||||
|
||||
const MigrateWalletChecks.defaultValues({
|
||||
this.balance = const {'transferableBalance': 0},
|
||||
this.idtyStatus = IdtyStatus.none,
|
||||
this.fromBalance = const {'transferableBalance': 0},
|
||||
this.fromIdtyStatus = IdtyStatus.none,
|
||||
this.toIdtyStatus = IdtyStatus.none,
|
||||
this.validationStatus = '',
|
||||
this.canValidate = false,
|
||||
});
|
||||
|
@ -23,8 +26,9 @@ class MigrateWalletChecks {
|
|||
@override
|
||||
String toString() {
|
||||
return {
|
||||
'balance': balance,
|
||||
'idtyStatus': idtyStatus,
|
||||
'balance': fromBalance,
|
||||
'fromIdtyStatus': fromIdtyStatus,
|
||||
'toIdtyStatus': toIdtyStatus,
|
||||
'validationStatus': validationStatus,
|
||||
'canValidate': canValidate,
|
||||
}.toString();
|
||||
|
|
|
@ -212,7 +212,8 @@ class SubstrateSdk with ChangeNotifier {
|
|||
Future<List<int>> getCertsCounter(String address) async {
|
||||
final idtyIndex = await _getIdentityIndexOf(address);
|
||||
if (idtyIndex == null) {
|
||||
return [];
|
||||
certsCounterCache.update(address, (_) => [0, 0], ifAbsent: () => [0, 0]);
|
||||
return [0, 0];
|
||||
}
|
||||
final certsReceiver =
|
||||
await _getStorage('certification.storageIdtyCertMeta($idtyIndex)') ??
|
||||
|
@ -221,7 +222,7 @@ class SubstrateSdk with ChangeNotifier {
|
|||
try {
|
||||
certsCounterCache.update(
|
||||
address,
|
||||
(value) => [
|
||||
(_) => [
|
||||
certsReceiver['receivedCount'] as int,
|
||||
certsReceiver['issuedCount'] as int
|
||||
],
|
||||
|
@ -479,7 +480,7 @@ class SubstrateSdk with ChangeNotifier {
|
|||
var idtyIndex = await _getIdentityIndexOf(address);
|
||||
if (idtyIndex == -1) return false;
|
||||
|
||||
final isSmith = await _getStorage('smithMembership.membership($idtyIndex)');
|
||||
final isSmith = await _getStorage('smithMembers.smiths($idtyIndex)');
|
||||
return !(isSmith == null);
|
||||
}
|
||||
|
||||
|
@ -950,24 +951,24 @@ class SubstrateSdk with ChangeNotifier {
|
|||
final isSmithData = await isSmith(fromAddress);
|
||||
|
||||
// Check conditions to set 'canValidate' and 'validationStatus'
|
||||
if (transferableBalance != 0 &&
|
||||
!fromHasConsumer &&
|
||||
await isAddress(toAddress)) {
|
||||
canValidate = true;
|
||||
} else if (toIdtyStatus != IdtyStatus.none &&
|
||||
fromIdtyStatus != IdtyStatus.none) {
|
||||
validationStatus = 'youCannotMigrateIdentityToExistingIdentity'.tr();
|
||||
} else if (isSmithData) {
|
||||
if (isSmithData) {
|
||||
validationStatus = 'smithCantMigrateIdentity'.tr();
|
||||
} else if (fromHasConsumer) {
|
||||
validationStatus = 'youMustWaitBeforeCashoutThisAccount'.tr();
|
||||
} else if (transferableBalance == 0) {
|
||||
validationStatus = 'thisAccountIsEmpty'.tr();
|
||||
} else if (toIdtyStatus != IdtyStatus.none &&
|
||||
fromIdtyStatus != IdtyStatus.none) {
|
||||
validationStatus = 'youCannotMigrateIdentityToExistingIdentity'.tr();
|
||||
} else if (fromIdtyStatus == IdtyStatus.none ||
|
||||
toIdtyStatus == IdtyStatus.none) {
|
||||
canValidate = true;
|
||||
}
|
||||
|
||||
return MigrateWalletChecks(
|
||||
balance: fromBalance,
|
||||
idtyStatus: toIdtyStatus,
|
||||
fromBalance: fromBalance,
|
||||
fromIdtyStatus: fromIdtyStatus,
|
||||
toIdtyStatus: toIdtyStatus,
|
||||
validationStatus: validationStatus,
|
||||
canValidate: canValidate,
|
||||
);
|
||||
|
@ -1045,10 +1046,7 @@ class SubstrateSdk with ChangeNotifier {
|
|||
final myIdtyStatus = statusList[0];
|
||||
final toIdtyStatus = statusList[1];
|
||||
|
||||
final idtyIndexList =
|
||||
await _getIdentityIndexOfMulti([fromAddress, destAddress]);
|
||||
final fromIndex = idtyIndexList[0];
|
||||
final toIndex = idtyIndexList[1];
|
||||
final toIndex = await _getIdentityIndexOf(destAddress);
|
||||
|
||||
if (myIdtyStatus != IdtyStatus.member) {
|
||||
return 'notMember';
|
||||
|
@ -1060,7 +1058,6 @@ class SubstrateSdk with ChangeNotifier {
|
|||
String? rawParams;
|
||||
|
||||
final toCerts = await getCertsCounter(destAddress);
|
||||
|
||||
log.d(
|
||||
"debug toCert: ${toCerts[0]} --- ${currencyParameters['minCertForMembership']!} --- $toIdtyStatus");
|
||||
|
||||
|
@ -1081,30 +1078,27 @@ class SubstrateSdk with ChangeNotifier {
|
|||
'batchAll',
|
||||
sender,
|
||||
);
|
||||
final tx1 = 'api.tx.certification.addCert($fromIndex, $toIndex)';
|
||||
final tx1 = 'api.tx.certification.addCert($toIndex)';
|
||||
final tx2 = 'api.tx.distance.requestDistanceEvaluationFor($toIndex)';
|
||||
|
||||
//TODO: add requestDistanceEvaluation tx when available
|
||||
|
||||
// final tx2 = 'api.tx.distance.requestDistanceEvaluation($toIndex)';
|
||||
// final tx2 = 'api.tx.identity.validateIdentity($toIndex)';
|
||||
|
||||
rawParams = '[[$tx1]]';
|
||||
rawParams = '[[$tx1, $tx2]]';
|
||||
} else {
|
||||
txInfo = TxInfoData(
|
||||
'cert',
|
||||
'certification',
|
||||
'addCert',
|
||||
sender,
|
||||
);
|
||||
txOptions = [fromIndex, toIndex];
|
||||
txOptions = [toIndex];
|
||||
}
|
||||
} else {
|
||||
log.e('cantBeCert: $toIdtyStatus');
|
||||
return 'cantBeCert';
|
||||
}
|
||||
|
||||
log.d('Cert action: ${txInfo.call!}');
|
||||
log.d('Cert action: ${txInfo.module!}.${txInfo.call!}');
|
||||
final transactionId = const Uuid().v4();
|
||||
final transactionContent = TransactionContent(
|
||||
transactionId: const Uuid().v4(),
|
||||
transactionId: transactionId,
|
||||
status: TransactionStatus.sending,
|
||||
from: fromAddress,
|
||||
to: destAddress,
|
||||
|
@ -1127,7 +1121,7 @@ class SubstrateSdk with ChangeNotifier {
|
|||
|
||||
final transactionId = const Uuid().v4();
|
||||
final transactionContent = TransactionContent(
|
||||
transactionId: const Uuid().v4(),
|
||||
transactionId: transactionId,
|
||||
status: TransactionStatus.sending,
|
||||
from: fromAddress,
|
||||
to: fromAddress,
|
||||
|
@ -1204,7 +1198,7 @@ newKeySig: $newKeySigType""");
|
|||
|
||||
final transactionId = const Uuid().v4();
|
||||
final transactionContent = TransactionContent(
|
||||
transactionId: const Uuid().v4(),
|
||||
transactionId: transactionId,
|
||||
status: TransactionStatus.sending,
|
||||
from: fromAddress,
|
||||
to: fromAddress,
|
||||
|
@ -1238,7 +1232,7 @@ newKeySig: $newKeySigType""");
|
|||
final txOptions = [idtyIndex, address, revocationSigTyped];
|
||||
final transactionId = const Uuid().v4();
|
||||
final transactionContent = TransactionContent(
|
||||
transactionId: const Uuid().v4(),
|
||||
transactionId: transactionId,
|
||||
status: TransactionStatus.sending,
|
||||
from: address,
|
||||
to: address,
|
||||
|
@ -1248,10 +1242,15 @@ newKeySig: $newKeySigType""");
|
|||
return transactionId;
|
||||
}
|
||||
|
||||
Future<String> migrateCsToV2(String salt, String password, String destAddress,
|
||||
{required destPassword,
|
||||
required Map balance,
|
||||
IdtyStatus idtyStatus = IdtyStatus.none}) async {
|
||||
Future<String> migrateCsToV2(
|
||||
String salt,
|
||||
String password,
|
||||
String destAddress, {
|
||||
required destPassword,
|
||||
required Map fromBalance,
|
||||
IdtyStatus fromIdtyStatus = IdtyStatus.none,
|
||||
IdtyStatus toIdtyStatus = IdtyStatus.none,
|
||||
}) async {
|
||||
final scrypt = pc.KeyDerivator('scrypt');
|
||||
|
||||
scrypt.init(
|
||||
|
@ -1266,13 +1265,15 @@ newKeySig: $newKeySigType""");
|
|||
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 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,
|
||||
|
@ -1283,20 +1284,20 @@ newKeySig: $newKeySigType""");
|
|||
|
||||
late String transactionId;
|
||||
|
||||
if (idtyStatus != IdtyStatus.none) {
|
||||
if (fromIdtyStatus == IdtyStatus.none) {
|
||||
transactionId = await pay(
|
||||
fromAddress: keypair.address!,
|
||||
destAddress: destAddress,
|
||||
amount: -1,
|
||||
password: 'password');
|
||||
} else if (fromBalance['transferableBalance'] != 0) {
|
||||
transactionId = await migrateIdentity(
|
||||
fromAddress: keypair.address!,
|
||||
destAddress: destAddress,
|
||||
fromPassword: 'password',
|
||||
destPassword: destPassword,
|
||||
withBalance: true,
|
||||
fromBalance: balance);
|
||||
} else if (balance['transferableBalance'] != 0) {
|
||||
transactionId = await pay(
|
||||
fromAddress: keypair.address!,
|
||||
destAddress: destAddress,
|
||||
amount: -1,
|
||||
password: 'password');
|
||||
fromBalance: fromBalance);
|
||||
} else {
|
||||
transactionId = '';
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class ImportG1v1 extends StatelessWidget {
|
|||
|
||||
return PopScope(
|
||||
onPopInvoked: (_) {
|
||||
resetScreen(context);
|
||||
resetScreen();
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: backgroundColor,
|
||||
|
@ -196,7 +196,7 @@ class ImportG1v1 extends StatelessWidget {
|
|||
Column(
|
||||
children: [
|
||||
Text(
|
||||
'${statusData.balance['transferableBalance']} $unit',
|
||||
'${statusData.fromBalance['transferableBalance']} $unit',
|
||||
style: scaledTextStyle(fontSize: 16),
|
||||
),
|
||||
IdentityStatus(
|
||||
|
@ -268,13 +268,14 @@ class ImportG1v1 extends StatelessWidget {
|
|||
}
|
||||
|
||||
final transactionId = await sub.migrateCsToV2(
|
||||
sub.csSalt.text,
|
||||
sub.csPassword.text,
|
||||
selectedWallet.address,
|
||||
destPassword:
|
||||
pin ?? myWalletProvider.pinCode,
|
||||
balance: statusData.balance,
|
||||
idtyStatus: statusData.idtyStatus);
|
||||
sub.csSalt.text,
|
||||
sub.csPassword.text,
|
||||
selectedWallet.address,
|
||||
destPassword: pin ?? myWalletProvider.pinCode,
|
||||
fromBalance: statusData.fromBalance,
|
||||
fromIdtyStatus: statusData.fromIdtyStatus,
|
||||
toIdtyStatus: statusData.toIdtyStatus,
|
||||
);
|
||||
Navigator.pop(context);
|
||||
await Navigator.push(
|
||||
context,
|
||||
|
@ -288,7 +289,7 @@ class ImportG1v1 extends StatelessWidget {
|
|||
selectedWallet.address));
|
||||
}),
|
||||
);
|
||||
resetScreen(context);
|
||||
resetScreen();
|
||||
}
|
||||
: null,
|
||||
child: Text(
|
||||
|
@ -313,8 +314,8 @@ class ImportG1v1 extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
void resetScreen(BuildContext context) {
|
||||
final sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||
void resetScreen() {
|
||||
final sub = Provider.of<SubstrateSdk>(homeContext, listen: false);
|
||||
|
||||
sub.csSalt.text = '';
|
||||
sub.csPassword.text = '';
|
||||
|
|
|
@ -202,7 +202,7 @@ class MigrateIdentityScreen extends StatelessWidget {
|
|||
fromPassword: myWalletProvider.pinCode,
|
||||
destPassword: 'password',
|
||||
withBalance: true,
|
||||
fromBalance: statusData.balance);
|
||||
fromBalance: statusData.fromBalance);
|
||||
|
||||
sub.deleteAccounts([newWalletAddress.text]);
|
||||
Navigator.pop(context);
|
||||
|
|
|
@ -35,9 +35,11 @@ class _SearchScreenState extends State<SearchScreen> {
|
|||
// Function to check clipboard and update if necessary
|
||||
Future<void> checkAndUpdateClipboard() async {
|
||||
final clipboardData = await Clipboard.getData(Clipboard.kTextPlain);
|
||||
if (clipboardData?.text != null && clipboardData!.text != pastedAddress) {
|
||||
pastedAddress = clipboardData.text ?? '';
|
||||
canPasteAddress = await isAddress(pastedAddress);
|
||||
if (clipboardData?.text?.isEmpty ?? true) return;
|
||||
if (clipboardData!.text != pastedAddress) {
|
||||
canPasteAddress = await isAddress(clipboardData.text!);
|
||||
if (!canPasteAddress) return;
|
||||
pastedAddress = clipboardData.text!;
|
||||
searchProvider.reload();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ class _TransactionInProgressState extends State<TransactionInProgress> {
|
|||
void waitForTransactionStatus() async {
|
||||
final sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||
while (!sub.transactionStatus.containsKey(widget.transactionId)) {
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
}
|
||||
|
||||
setState(() {
|
||||
|
@ -80,7 +80,13 @@ class _TransactionInProgressState extends State<TransactionInProgress> {
|
|||
final sub = Provider.of<SubstrateSdk>(context, listen: true);
|
||||
|
||||
if (txContent == null) {
|
||||
return const Center(child: Loading());
|
||||
return const Scaffold(
|
||||
body: Center(
|
||||
child: Loading(
|
||||
size: 25,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (sub.transactionStatus.containsKey(widget.transactionId)) {
|
||||
|
|
32
pubspec.lock
32
pubspec.lock
|
@ -73,6 +73,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.3.0"
|
||||
base_codecs:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: base_codecs
|
||||
sha256: "41701a12ede9912663decd708279924ece5018566daa7d1f484d5f4f10894f91"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
base_x:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -137,6 +145,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
buffer:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: buffer
|
||||
sha256: "389da2ec2c16283c8787e0adaede82b1842102f8c8aae2f49003a766c5c6b3d1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.3"
|
||||
build:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -305,6 +321,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.7.0"
|
||||
dart_multihash:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: dart_multihash
|
||||
sha256: "7bef7091497c531f94bf82102805a69d97e4e5d120000dcbbc4a1da679060e0a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
dart_style:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -1075,6 +1099,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.3+2"
|
||||
multiformats:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: multiformats
|
||||
sha256: aa2fa36d2e4d0069dac993b35ee52e5165d67f15b995d68f797466065a6d05a5
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.3"
|
||||
nested:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
16
pubspec.yaml
16
pubspec.yaml
|
@ -1,11 +1,8 @@
|
|||
name: gecko
|
||||
description: Pay with G1.
|
||||
publish_to: "none"
|
||||
|
||||
# The following line prevents the package from being accidentally published to
|
||||
# pub.dev using `pub publish`. This is preferred for private packages.
|
||||
publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
||||
|
||||
version: 0.1.6+74
|
||||
version: 0.1.7+75
|
||||
|
||||
environment:
|
||||
sdk: ">=2.12.0 <3.0.0"
|
||||
|
@ -66,8 +63,6 @@ dependencies:
|
|||
# url: https://git.duniter.org/libs/durt2
|
||||
|
||||
dev_dependencies:
|
||||
# flutter_launcher_icons: ^0.9.2
|
||||
# flutter_launcher_icons_maker: ^^0.10.2
|
||||
icons_launcher: ^2.1.7
|
||||
build_runner: ^2.4.9
|
||||
hive_generator: ^2.0.1
|
||||
|
@ -85,13 +80,6 @@ icons_launcher:
|
|||
ios:
|
||||
enable: true
|
||||
|
||||
# flutter_icons:
|
||||
# android: "launcher_icon"
|
||||
# ios: true
|
||||
# image_path: "assets/icon/gecko_flat.png"
|
||||
# min_sdk_android: 21
|
||||
# remove_alpha_ios: true
|
||||
|
||||
uses-material-design: true
|
||||
|
||||
# The following section is specific to Flutter.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
flutter pub run icons_launcher:create
|
||||
#flutter pub run flutter_launcher_icons
|
||||
dart run icons_launcher:create
|
||||
#dart run flutter_launcher_icons
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue