fixed lookup references

This commit is contained in:
Zachary Atkins 2021-04-10 15:36:05 -05:00
parent ad62f5f1b0
commit dceeb18513
2 changed files with 5 additions and 4 deletions

View File

@ -7,7 +7,7 @@ void main() async {
runApp(App()); runApp(App());
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
final userName = prefs.getString('userName') ?? '0'; final userName = prefs.getString('userName') ?? '0';
if (id == '0') { if (userName == '0') {
prefs.setString('id', Random().nextInt(10000).toString()); prefs.setString('id', Random().nextInt(10000).toString());
} }
} }

View File

@ -9,13 +9,14 @@ import 'dart:io';
class Transaction { class Transaction {
Transaction({required this.hash}) { Transaction({required this.hash}) {
SharedPreferences.getInstance().then((s) => _id = s.getString('id') ?? '0'); SharedPreferences.getInstance()
.then((s) => _id = s.getString('userName') ?? '0');
} }
late final String _id; late final String _id;
final String hash; final String hash;
static Future<String> makeTransactionHash(String otherUserId) async { static Future<String> signTransaction(String otherUserId) async {
String id = await SharedPreferences.getInstance() String id = await SharedPreferences.getInstance()
.then((s) => s.getString('id') ?? ''); .then((s) => s.getString('userName') ?? '');
bool idLess = id.compareTo(otherUserId) < 0; bool idLess = id.compareTo(otherUserId) < 0;
var lesser = idLess ? id : otherUserId; var lesser = idLess ? id : otherUserId;
var greater = idLess ? otherUserId : id; var greater = idLess ? otherUserId : id;