feat: Change short pubkey format
This commit is contained in:
parent
2a4b54d9eb
commit
104d00ff7e
|
@ -1,7 +1,5 @@
|
||||||
// ignore_for_file: avoid_print
|
// ignore_for_file: avoid_print
|
||||||
|
|
||||||
import 'package:crypto/crypto.dart';
|
|
||||||
import 'package:fast_base58/fast_base58.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
|
@ -54,7 +52,6 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
n.ss58 = ss58;
|
n.ss58 = ss58;
|
||||||
node.add(n);
|
node.add(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
int timeout = 10000;
|
int timeout = 10000;
|
||||||
|
|
||||||
// if (n.endpoint!.startsWith('ws://')) {
|
// if (n.endpoint!.startsWith('ws://')) {
|
||||||
|
@ -520,18 +517,10 @@ void snackNode(BuildContext context, bool isConnected) {
|
||||||
}
|
}
|
||||||
|
|
||||||
String getShortPubkey(String pubkey) {
|
String getShortPubkey(String pubkey) {
|
||||||
List<int> pubkeyByte = Base58Decode(pubkey);
|
String pubkeyShort = truncate(pubkey, 7,
|
||||||
Digest pubkeyS256 = sha256.convert(sha256.convert(pubkeyByte).bytes);
|
|
||||||
String pubkeyCheksum = Base58Encode(pubkeyS256.bytes);
|
|
||||||
String pubkeyChecksumShort =
|
|
||||||
truncate(pubkeyCheksum, 3, omission: "", position: TruncatePosition.end);
|
|
||||||
|
|
||||||
String pubkeyShort = truncate(pubkey, 5,
|
|
||||||
omission: String.fromCharCode(0x2026),
|
omission: String.fromCharCode(0x2026),
|
||||||
position: TruncatePosition.end) +
|
position: TruncatePosition.end) +
|
||||||
truncate(pubkey, 4, omission: "", position: TruncatePosition.start) +
|
truncate(pubkey, 6, omission: "", position: TruncatePosition.start);
|
||||||
':$pubkeyChecksumShort';
|
|
||||||
|
|
||||||
return pubkeyShort;
|
return pubkeyShort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:crypto/crypto.dart';
|
|
||||||
import 'package:fast_base58/fast_base58.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
|
@ -9,7 +7,6 @@ import 'package:gecko/models/wallet_data.dart';
|
||||||
import 'package:gecko/providers/substrate_sdk.dart';
|
import 'package:gecko/providers/substrate_sdk.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:truncate/truncate.dart';
|
|
||||||
|
|
||||||
class WalletOptionsProvider with ChangeNotifier {
|
class WalletOptionsProvider with ChangeNotifier {
|
||||||
TextEditingController address = TextEditingController();
|
TextEditingController address = TextEditingController();
|
||||||
|
@ -108,22 +105,6 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String getShortPubkey(String pubkey) {
|
|
||||||
List<int> pubkeyByte = Base58Decode(pubkey);
|
|
||||||
Digest pubkeyS256 = sha256.convert(sha256.convert(pubkeyByte).bytes);
|
|
||||||
String pubkeyCheksum = Base58Encode(pubkeyS256.bytes);
|
|
||||||
String pubkeyChecksumShort = truncate(pubkeyCheksum, 3,
|
|
||||||
omission: "", position: TruncatePosition.end);
|
|
||||||
|
|
||||||
String pubkeyShort = truncate(pubkey, 5,
|
|
||||||
omission: String.fromCharCode(0x2026),
|
|
||||||
position: TruncatePosition.end) +
|
|
||||||
truncate(pubkey, 4, omission: "", position: TruncatePosition.start) +
|
|
||||||
':$pubkeyChecksumShort';
|
|
||||||
|
|
||||||
return pubkeyShort;
|
|
||||||
}
|
|
||||||
|
|
||||||
void bluringBalance() {
|
void bluringBalance() {
|
||||||
isBalanceBlur = !isBalanceBlur;
|
isBalanceBlur = !isBalanceBlur;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
|
import 'package:gecko/providers/substrate_sdk.dart';
|
||||||
import 'package:gecko/screens/wallet_view.dart';
|
import 'package:gecko/screens/wallet_view.dart';
|
||||||
import 'package:graphql_flutter/graphql_flutter.dart';
|
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||||
import 'package:jdenticon_dart/jdenticon_dart.dart';
|
import 'package:jdenticon_dart/jdenticon_dart.dart';
|
||||||
|
@ -8,9 +9,6 @@ import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:qrscan/qrscan.dart' as scanner;
|
import 'package:qrscan/qrscan.dart' as scanner;
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:truncate/truncate.dart';
|
|
||||||
import 'package:crypto/crypto.dart';
|
|
||||||
import 'package:fast_base58/fast_base58.dart';
|
|
||||||
|
|
||||||
class WalletsProfilesProvider with ChangeNotifier {
|
class WalletsProfilesProvider with ChangeNotifier {
|
||||||
WalletsProfilesProvider(this.pubkey);
|
WalletsProfilesProvider(this.pubkey);
|
||||||
|
@ -105,23 +103,6 @@ class WalletsProfilesProvider with ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String getShortPubkey(String pubkey) {
|
|
||||||
// log.d(pubkey);
|
|
||||||
List<int> pubkeyByte = Base58Decode(pubkey);
|
|
||||||
Digest pubkeyS256 = sha256.convert(sha256.convert(pubkeyByte).bytes);
|
|
||||||
String pubkeyCheksum = Base58Encode(pubkeyS256.bytes);
|
|
||||||
String pubkeyChecksumShort = truncate(pubkeyCheksum, 3,
|
|
||||||
omission: "", position: TruncatePosition.end);
|
|
||||||
|
|
||||||
pubkeyShort = truncate(pubkey, 5,
|
|
||||||
omission: String.fromCharCode(0x2026),
|
|
||||||
position: TruncatePosition.end) +
|
|
||||||
truncate(pubkey, 4, omission: "", position: TruncatePosition.start) +
|
|
||||||
':$pubkeyChecksumShort';
|
|
||||||
|
|
||||||
return pubkeyShort;
|
|
||||||
}
|
|
||||||
|
|
||||||
// poka: Do99s6wQR2JLfhirPdpAERSjNbmjjECzGxHNJMiNKT3P
|
// poka: Do99s6wQR2JLfhirPdpAERSjNbmjjECzGxHNJMiNKT3P
|
||||||
// Pi: D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU // For debug
|
// Pi: D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU // For debug
|
||||||
// Boris: JE6mkuzSpT3ePciCPRTpuMT9fqPUVVLJz2618d33p7tn
|
// Boris: JE6mkuzSpT3ePciCPRTpuMT9fqPUVVLJz2618d33p7tn
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'package:flutter/services.dart';
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
import 'package:gecko/providers/cesium_plus.dart';
|
import 'package:gecko/providers/cesium_plus.dart';
|
||||||
import 'package:gecko/models/queries.dart';
|
import 'package:gecko/models/queries.dart';
|
||||||
|
import 'package:gecko/providers/substrate_sdk.dart';
|
||||||
import 'package:gecko/providers/wallets_profiles.dart';
|
import 'package:gecko/providers/wallets_profiles.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gecko/screens/avatar_fullscreen.dart';
|
import 'package:gecko/screens/avatar_fullscreen.dart';
|
||||||
|
@ -406,7 +407,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
||||||
snackCopyKey(context);
|
snackCopyKey(context);
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
_historyProvider.getShortPubkey(pubkey!),
|
getShortPubkey(pubkey!),
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 30,
|
fontSize: 30,
|
||||||
fontWeight: FontWeight.w800,
|
fontWeight: FontWeight.w800,
|
||||||
|
|
|
@ -239,8 +239,7 @@ class WalletOptions extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget pubkeyWidget(WalletOptionsProvider walletProvider, BuildContext ctx) {
|
Widget pubkeyWidget(WalletOptionsProvider walletProvider, BuildContext ctx) {
|
||||||
final String shortPubkey =
|
final String shortPubkey = getShortPubkey(walletProvider.address.text);
|
||||||
walletProvider.getShortPubkey(walletProvider.address.text);
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
key: const Key('copyPubkey'),
|
key: const Key('copyPubkey'),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
@ -256,17 +255,12 @@ class WalletOptions extends StatelessWidget {
|
||||||
height: 45,
|
height: 45,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 20),
|
const SizedBox(width: 20),
|
||||||
Text("${shortPubkey.split(':')[0]}:",
|
Text(shortPubkey,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 22,
|
fontSize: 22,
|
||||||
fontWeight: FontWeight.w800,
|
fontWeight: FontWeight.w800,
|
||||||
fontFamily: 'Monospace',
|
fontFamily: 'Monospace',
|
||||||
color: Colors.black)),
|
color: Colors.black)),
|
||||||
Text(shortPubkey.split(':')[1],
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 22,
|
|
||||||
fontWeight: FontWeight.w800,
|
|
||||||
fontFamily: 'Monospace')),
|
|
||||||
const SizedBox(width: 15),
|
const SizedBox(width: 15),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 40,
|
height: 40,
|
||||||
|
|
|
@ -3,6 +3,7 @@ import 'package:gecko/globals.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gecko/providers/cesium_plus.dart';
|
import 'package:gecko/providers/cesium_plus.dart';
|
||||||
import 'package:gecko/models/g1_wallets_list.dart';
|
import 'package:gecko/models/g1_wallets_list.dart';
|
||||||
|
import 'package:gecko/providers/substrate_sdk.dart';
|
||||||
import 'package:gecko/providers/wallet_options.dart';
|
import 'package:gecko/providers/wallet_options.dart';
|
||||||
import 'package:gecko/providers/wallets_profiles.dart';
|
import 'package:gecko/providers/wallets_profiles.dart';
|
||||||
import 'package:gecko/providers/search.dart';
|
import 'package:gecko/providers/search.dart';
|
||||||
|
@ -126,8 +127,8 @@ class SearchResultScreen extends StatelessWidget {
|
||||||
}),
|
}),
|
||||||
title: Row(children: <Widget>[
|
title: Row(children: <Widget>[
|
||||||
Text(
|
Text(
|
||||||
_walletsProfilesClass
|
|
||||||
.getShortPubkey(g1Wallet.pubkey!),
|
getShortPubkey(g1Wallet.pubkey!),
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontFamily: 'Monospace',
|
fontFamily: 'Monospace',
|
||||||
|
|
|
@ -31,7 +31,7 @@ class TransactionInProgress extends StatelessWidget {
|
||||||
log.d(_walletViewProvider.pubkey!);
|
log.d(_walletViewProvider.pubkey!);
|
||||||
|
|
||||||
final from = _myWalletProvider.getDefaultWallet()!.name!;
|
final from = _myWalletProvider.getDefaultWallet()!.name!;
|
||||||
final to = _walletViewProvider.getShortPubkey(_walletViewProvider.pubkey!);
|
final to = getShortPubkey(_walletViewProvider.pubkey!);
|
||||||
final amount = _walletViewProvider.payAmount.text;
|
final amount = _walletViewProvider.payAmount.text;
|
||||||
String _actionName = '';
|
String _actionName = '';
|
||||||
|
|
||||||
|
|
|
@ -519,7 +519,7 @@ class WalletViewScreen extends StatelessWidget {
|
||||||
snackCopyKey(context);
|
snackCopyKey(context);
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
_historyProvider.getShortPubkey(pubkey!),
|
getShortPubkey(pubkey!),
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 30,
|
fontSize: 30,
|
||||||
fontWeight: FontWeight.w800,
|
fontWeight: FontWeight.w800,
|
||||||
|
|
Loading…
Reference in New Issue