Compare commits

...

1 Commits

Author SHA1 Message Date
poka 89ae21cde9 Decompose seed getting 2022-03-02 21:33:50 +01:00
4 changed files with 20 additions and 13 deletions

View File

@ -1,6 +1,5 @@
// ignore_for_file: avoid_print
import 'dart:convert';
import 'package:crypto/crypto.dart';
import 'package:fast_base58/fast_base58.dart';
import 'package:flutter/material.dart';
@ -10,13 +9,10 @@ import 'package:polkawallet_sdk/api/types/networkParams.dart';
import 'package:polkawallet_sdk/api/types/txInfoData.dart';
import 'package:polkawallet_sdk/polkawallet_sdk.dart';
import 'package:polkawallet_sdk/storage/keyring.dart';
import 'package:polkawallet_sdk/storage/localStorage.dart';
import 'package:polkawallet_sdk/utils/localStorage.dart';
import 'package:truncate/truncate.dart';
import 'package:get_storage/get_storage.dart';
class SubstrateSdk with ChangeNotifier {
final List subNode = ['127.0.0.1:9944', '192.168.1.45:9944'];
final List subNode = ['127.0.0.1:9944', '192.168.1.72:9944'];
final bool isSsl = false;
final int ss58 = 42;
@ -97,7 +93,8 @@ class SubstrateSdk with ChangeNotifier {
key: keyToImport,
name: 'testKey',
password: keystorePassword.text,
derivePath: derivePath)
derivePath: derivePath,
cryptoType: CryptoType.sr25519)
.catchError((e) {
importIsLoading = false;
notifyListeners();
@ -178,12 +175,13 @@ class SubstrateSdk with ChangeNotifier {
onStatusChange: (status) {
print('status: ' + status);
if (status == 'Ready') {
snack(context, 'Paiement effectué avec succès !');
snack(context, 'Transaction terminé');
}
},
);
print(hash.toString());
} catch (err) {
print('taterror');
print(err.toString());
}
}
@ -196,7 +194,15 @@ class SubstrateSdk with ChangeNotifier {
final seedMap =
await keyring.store.getDecryptedSeed(keypair.pubKey, password);
print(seedMap);
generatedMnemonic = seedMap!['seed'];
if (seedMap!['type'] != 'mnemonic') return;
final List seedList = seedMap['seed'].split('/');
generatedMnemonic = seedList[0];
int sourceDerivation = -1; // To get derivation number of this account
if (seedList.length > 1) {
sourceDerivation = int.parse(seedMap['seed'].split('/')[1]);
}
print(generatedMnemonic);
print(sourceDerivation);
importAccount(fromMnemonic: true, derivePath: '/$number');
}

View File

@ -94,7 +94,7 @@ class SubstrateSandBox extends StatelessWidget {
child: const Text("Dériver"),
)
])
]);
]);
}),
const SizedBox(height: 20),
const Text('Mot de passe du trousseau:'),
@ -141,7 +141,7 @@ class SubstrateSandBox extends StatelessWidget {
onPrimary: Colors.black, // foreground
),
onPressed: () async {
final res = await _sub.generateMnemonic();
await _sub.generateMnemonic();
_sub.importIsLoading = false;
_sub.reload();
snack(context, 'Le mnemonic a été copié');

View File

@ -967,10 +967,10 @@ packages:
description:
path: "."
ref: fixAndroidActivityVersion
resolved-ref: bcb33239d99605258361951f447ab097ff03208a
resolved-ref: "05d80150def4d5b3cac02ba4db96a39550719c9b"
url: "git://github.com/poka-IT/sdk.git"
source: git
version: "0.4.1"
version: "0.4.2"
pool:
dependency: transitive
description:
@ -1350,7 +1350,7 @@ packages:
name: webview_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.0"
version: "3.0.1"
webview_flutter_android:
dependency: transitive
description:

View File

@ -73,6 +73,7 @@ dependencies:
durt: ^0.1.6
package_info_plus: ^1.3.0
polkawallet_sdk: #^0.4.1 ## Wait for merging PR: https://github.com/polkawallet-io/sdk/pull/19
# path: ../substrate-sdk
git:
url: git://github.com/poka-IT/sdk.git
ref: fixAndroidActivityVersion