Add dead methode to get ss58 prefix from const storage; remove unused comments
This commit is contained in:
parent
a88034b206
commit
175334457a
|
@ -46,7 +46,6 @@ Color floattingYellow = const Color(0xffEFEFBF);
|
||||||
Color backgroundColor = const Color(0xFFF5F5F5);
|
Color backgroundColor = const Color(0xFFF5F5F5);
|
||||||
|
|
||||||
// Substrate settings
|
// Substrate settings
|
||||||
const int ss58 = 42;
|
|
||||||
String currencyName = 'ĞD';
|
String currencyName = 'ĞD';
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
|
|
|
@ -385,7 +385,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(ss58,
|
final addressData = await sub.sdk.api.keyring.addressFromMnemonic(sub.ss58,
|
||||||
cryptoType: CryptoType.sr25519,
|
cryptoType: CryptoType.sr25519,
|
||||||
mnemonic: generatedMnemonic!,
|
mnemonic: generatedMnemonic!,
|
||||||
derivePath: '//$derivationNbr');
|
derivePath: '//$derivationNbr');
|
||||||
|
@ -426,7 +426,7 @@ 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(ss58,
|
final addressData = await sub.sdk.api.keyring.addressFromMnemonic(sub.ss58,
|
||||||
cryptoType: CryptoType.sr25519, mnemonic: generatedMnemonic!);
|
cryptoType: CryptoType.sr25519, mnemonic: generatedMnemonic!);
|
||||||
|
|
||||||
final balance = await sub.getBalance(addressData.address!).timeout(
|
final balance = await sub.getBalance(addressData.address!).timeout(
|
||||||
|
|
|
@ -28,6 +28,7 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
bool isLoadingEndpoint = false;
|
bool isLoadingEndpoint = false;
|
||||||
String debugConnection = '';
|
String debugConnection = '';
|
||||||
String transactionStatus = '';
|
String transactionStatus = '';
|
||||||
|
int ss58 = 42;
|
||||||
|
|
||||||
TextEditingController jsonKeystore = TextEditingController();
|
TextEditingController jsonKeystore = TextEditingController();
|
||||||
TextEditingController keystorePassword = TextEditingController();
|
TextEditingController keystorePassword = TextEditingController();
|
||||||
|
@ -46,12 +47,6 @@ 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);
|
||||||
|
|
||||||
// var connectivityResult = await (Connectivity().checkConnectivity());
|
|
||||||
// if (connectivityResult == ConnectivityResult.mobile ||
|
|
||||||
// connectivityResult == ConnectivityResult.wifi) {
|
|
||||||
// _homeProvider.changeMessage("Vous n'êtes pas connecté à internet", 0);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
homeProvider.changeMessage("connectionPending".tr(), 0);
|
homeProvider.changeMessage("connectionPending".tr(), 0);
|
||||||
|
|
||||||
// configBox.delete('customEndpoint');
|
// configBox.delete('customEndpoint');
|
||||||
|
@ -60,31 +55,8 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
? [getDuniterCustomEndpoint()]
|
? [getDuniterCustomEndpoint()]
|
||||||
: getDuniterBootstrap();
|
: getDuniterBootstrap();
|
||||||
|
|
||||||
// final nodes = getDuniterBootstrap();
|
|
||||||
|
|
||||||
int timeout = 10000;
|
int timeout = 10000;
|
||||||
|
|
||||||
// if (n.endpoint!.startsWith('ws://')) {
|
|
||||||
// timeout = 5000;
|
|
||||||
// }
|
|
||||||
|
|
||||||
//// Check websocket conenction - only for wss
|
|
||||||
// final channel = IOWebSocketChannel.connect(
|
|
||||||
// Uri.parse('wss://192.168.1.72:9944'),
|
|
||||||
// );
|
|
||||||
|
|
||||||
// channel.stream.listen(
|
|
||||||
// (dynamic message) {
|
|
||||||
// log.d('message $message');
|
|
||||||
// },
|
|
||||||
// onDone: () {
|
|
||||||
// log.d('ws channel closed');
|
|
||||||
// },
|
|
||||||
// onError: (error) {
|
|
||||||
// log.d('ws error $error');
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
|
|
||||||
if (sdk.api.connectedNode?.endpoint != null) {
|
if (sdk.api.connectedNode?.endpoint != null) {
|
||||||
await sdk.api.setting.unsubscribeBestNumber();
|
await sdk.api.setting.unsubscribeBestNumber();
|
||||||
}
|
}
|
||||||
|
@ -99,6 +71,7 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
nodeConnected = true;
|
nodeConnected = true;
|
||||||
|
// await getSs58Prefix();
|
||||||
|
|
||||||
// Subscribe bloc number
|
// Subscribe bloc number
|
||||||
sdk.api.setting.subscribeBestNumber((res) {
|
sdk.api.setting.subscribeBestNumber((res) {
|
||||||
|
@ -197,7 +170,7 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
});
|
});
|
||||||
if (json == null) return '';
|
if (json == null) return '';
|
||||||
log.d(json);
|
// log.d(json);
|
||||||
try {
|
try {
|
||||||
await sdk.api.keyring.addAccount(
|
await sdk.api.keyring.addAccount(
|
||||||
keyring,
|
keyring,
|
||||||
|
@ -205,7 +178,6 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
acc: json,
|
acc: json,
|
||||||
password: password,
|
password: password,
|
||||||
);
|
);
|
||||||
// Clipboard.setData(ClipboardData(text: jsonEncode(acc.toJson())));
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.e(e);
|
log.e(e);
|
||||||
importIsLoading = false;
|
importIsLoading = false;
|
||||||
|
@ -225,14 +197,8 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
Future<List<AddressInfo>> getKeyStoreAddress() async {
|
Future<List<AddressInfo>> getKeyStoreAddress() async {
|
||||||
List<AddressInfo> result = [];
|
List<AddressInfo> result = [];
|
||||||
|
|
||||||
// sdk.api.account.unsubscribeBalance();
|
|
||||||
for (var element in keyring.allAccounts) {
|
for (var element in keyring.allAccounts) {
|
||||||
// Clipboard.setData(ClipboardData(text: jsonEncode(element)));
|
|
||||||
final account = AddressInfo(address: element.address);
|
final account = AddressInfo(address: element.address);
|
||||||
// await sdk.api.account.subscribeBalance(element.address, (p0) {
|
|
||||||
// account.balance = int.parse(p0.freeBalance) / 100;
|
|
||||||
// });
|
|
||||||
// sdk.api.setting.unsubscribeBestNumber();
|
|
||||||
account.balance = await getBalance(element.address!);
|
account.balance = await getBalance(element.address!);
|
||||||
result.add(account);
|
result.add(account);
|
||||||
}
|
}
|
||||||
|
@ -248,8 +214,6 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
|
|
||||||
Future<List<int>> getCerts(String address) async {
|
Future<List<int>> getCerts(String address) async {
|
||||||
final idtyIndex = await getIdentityIndexOf(address);
|
final idtyIndex = await getIdentityIndexOf(address);
|
||||||
// log.d('u32: ' + idtyIndex.toString());
|
|
||||||
|
|
||||||
final certsReceiver = await sdk.webView!
|
final certsReceiver = await sdk.webView!
|
||||||
.evalJavascript('api.query.cert.storageIdtyCertMeta($idtyIndex)') ??
|
.evalJavascript('api.query.cert.storageIdtyCertMeta($idtyIndex)') ??
|
||||||
[];
|
[];
|
||||||
|
@ -288,14 +252,12 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
final accountInfo = await sdk.webView!
|
final accountInfo = await sdk.webView!
|
||||||
.evalJavascript('api.query.system.account("$address")');
|
.evalJavascript('api.query.system.account("$address")');
|
||||||
final consumers = accountInfo['consumers'];
|
final consumers = accountInfo['consumers'];
|
||||||
// log.d('Consumers: $_consumers');
|
|
||||||
return consumers == 0 ? false : true;
|
return consumers == 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<double> getBalance(String address, {bool isUd = false}) async {
|
Future<double> getBalance(String address, {bool isUd = false}) async {
|
||||||
double balance = 0.0;
|
double balance = 0.0;
|
||||||
|
|
||||||
// log.d('nodeConnected: ' + nodeConnected.toString());
|
|
||||||
if (nodeConnected) {
|
if (nodeConnected) {
|
||||||
final brutBalance = await sdk.api.account.queryBalance(address);
|
final brutBalance = await sdk.api.account.queryBalance(address);
|
||||||
balance = int.parse(brutBalance!.freeBalance) / 100;
|
balance = int.parse(brutBalance!.freeBalance) / 100;
|
||||||
|
@ -324,7 +286,6 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
|
|
||||||
Future<bool> checkPassword(String address, String pass) async {
|
Future<bool> checkPassword(String address, String pass) async {
|
||||||
final account = getKeypair(address);
|
final account = getKeypair(address);
|
||||||
// log.d(account.address);
|
|
||||||
|
|
||||||
return await sdk.api.keyring.checkPassword(account, pass);
|
return await sdk.api.keyring.checkPassword(account, pass);
|
||||||
}
|
}
|
||||||
|
@ -380,8 +341,6 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
final gen = await sdk.api.keyring.generateMnemonic(ss58);
|
final gen = await sdk.api.keyring.generateMnemonic(ss58);
|
||||||
generatedMnemonic = gen.mnemonic!;
|
generatedMnemonic = gen.mnemonic!;
|
||||||
|
|
||||||
// final res = await importAccount(fromMnemonic: true);
|
|
||||||
// await Clipboard.setData(ClipboardData(text: generatedMnemonic));
|
|
||||||
return gen.mnemonic!;
|
return gen.mnemonic!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,12 +375,9 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
required String password}) async {
|
required String password}) async {
|
||||||
transactionStatus = '';
|
transactionStatus = '';
|
||||||
|
|
||||||
// setCurrentWallet(fromAddress);
|
|
||||||
|
|
||||||
log.d(keyring.current.address);
|
log.d(keyring.current.address);
|
||||||
log.d(fromAddress);
|
log.d(fromAddress);
|
||||||
log.d(password);
|
log.d(password);
|
||||||
// log.d(await checkPassword(fromAddress, password));
|
|
||||||
|
|
||||||
final fromPubkey = await sdk.api.account.decodeAddress([fromAddress]);
|
final fromPubkey = await sdk.api.account.decodeAddress([fromAddress]);
|
||||||
log.d(fromPubkey!.keys.first);
|
log.d(fromPubkey!.keys.first);
|
||||||
|
@ -469,7 +425,6 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
String fromAddress, String password, String toAddress) async {
|
String fromAddress, String password, String toAddress) async {
|
||||||
transactionStatus = '';
|
transactionStatus = '';
|
||||||
|
|
||||||
// setCurrentWallet(fromAddress);
|
|
||||||
log.d('me: $fromAddress');
|
log.d('me: $fromAddress');
|
||||||
log.d('to: $toAddress');
|
log.d('to: $toAddress');
|
||||||
|
|
||||||
|
@ -507,7 +462,7 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
toIdtyStatus == 'ConfirmedByOwner') {
|
toIdtyStatus == 'ConfirmedByOwner') {
|
||||||
if (toCerts[0] >= currencyParameters['wotMinCertForMembership'] &&
|
if (toCerts[0] >= currencyParameters['wotMinCertForMembership'] &&
|
||||||
toIdtyStatus != 'Validated') {
|
toIdtyStatus != 'Validated') {
|
||||||
log.d('Batch cert and membership validation');
|
log.i('Batch cert and membership validation');
|
||||||
txInfo = TxInfoData(
|
txInfo = TxInfoData(
|
||||||
'utility',
|
'utility',
|
||||||
'batchAll',
|
'batchAll',
|
||||||
|
@ -572,9 +527,6 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> idtyStatus(String address, [bool smooth = true]) async {
|
Future<String> idtyStatus(String address, [bool smooth = true]) async {
|
||||||
// var tata = await sdk.webView!
|
|
||||||
// .evalJavascript('api.query.system.account("$address")');
|
|
||||||
|
|
||||||
var idtyIndex = await getIdentityIndexOf(address);
|
var idtyIndex = await getIdentityIndexOf(address);
|
||||||
|
|
||||||
if (idtyIndex == 0) {
|
if (idtyIndex == 0) {
|
||||||
|
@ -586,7 +538,7 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
|
|
||||||
if (idtyStatus != null) {
|
if (idtyStatus != null) {
|
||||||
final String status = idtyStatus['status'];
|
final String status = idtyStatus['status'];
|
||||||
// log.d('Status $address: $_status');
|
|
||||||
return (status);
|
return (status);
|
||||||
} else {
|
} else {
|
||||||
return 'expired';
|
return 'expired';
|
||||||
|
@ -595,8 +547,6 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
|
|
||||||
Future<String> confirmIdentity(
|
Future<String> confirmIdentity(
|
||||||
String fromAddress, String name, String password) async {
|
String fromAddress, String name, String password) async {
|
||||||
// Confirm identity
|
|
||||||
// setCurrentWallet(fromAddress);
|
|
||||||
log.d('me: ${keyring.current.address!}');
|
log.d('me: ${keyring.current.address!}');
|
||||||
|
|
||||||
final sender = TxSenderData(
|
final sender = TxSenderData(
|
||||||
|
@ -788,6 +738,17 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
String? getConnectedEndpoint() {
|
String? getConnectedEndpoint() {
|
||||||
return sdk.api.connectedNode?.endpoint;
|
return sdk.api.connectedNode?.endpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void snack(BuildContext context, String message, {int duration = 2}) {
|
void snack(BuildContext context, String message, {int duration = 2}) {
|
||||||
|
|
|
@ -77,14 +77,9 @@ class SettingsScreen extends StatelessWidget {
|
||||||
sub.getConnectedEndpoint() ?? duniterBootstrapNodes.first.endpoint;
|
sub.getConnectedEndpoint() ?? duniterBootstrapNodes.first.endpoint;
|
||||||
|
|
||||||
final customEndpoint = NetworkParams();
|
final customEndpoint = NetworkParams();
|
||||||
customEndpoint.name = currencyName;
|
|
||||||
customEndpoint.endpoint = 'Personnalisé';
|
customEndpoint.endpoint = 'Personnalisé';
|
||||||
customEndpoint.ss58 = ss58;
|
|
||||||
|
|
||||||
final automaticEndpoint = NetworkParams();
|
final automaticEndpoint = NetworkParams();
|
||||||
automaticEndpoint.name = currencyName;
|
|
||||||
automaticEndpoint.endpoint = 'Auto';
|
automaticEndpoint.endpoint = 'Auto';
|
||||||
automaticEndpoint.ss58 = ss58;
|
|
||||||
// duniterBootstrapNodes.add(_sub.getDuniterCustomEndpoint());
|
// duniterBootstrapNodes.add(_sub.getDuniterCustomEndpoint());
|
||||||
duniterBootstrapNodes.insert(0, automaticEndpoint);
|
duniterBootstrapNodes.insert(0, automaticEndpoint);
|
||||||
duniterBootstrapNodes.add(customEndpoint);
|
duniterBootstrapNodes.add(customEndpoint);
|
||||||
|
|
|
@ -60,7 +60,7 @@ dependencies:
|
||||||
desktop_window: ^0.4.0
|
desktop_window: ^0.4.0
|
||||||
durt: ^0.1.6
|
durt: ^0.1.6
|
||||||
package_info_plus: ^1.4.2
|
package_info_plus: ^1.4.2
|
||||||
polkawallet_sdk: #^0.4.8
|
polkawallet_sdk: #^0.4.9
|
||||||
git:
|
git:
|
||||||
url: https://github.com/poka-IT/sdk.git
|
url: https://github.com/poka-IT/sdk.git
|
||||||
ref: gecko-old
|
ref: gecko-old
|
||||||
|
|
Loading…
Reference in New Issue