mirror of
				https://github.com/hackku21/loc-chain-app.git
				synced 2025-06-13 12:54:05 +00:00 
			
		
		
		
	fix transaction manager
This commit is contained in:
		
							parent
							
								
									f0b1fed1c2
								
							
						
					
					
						commit
						8c2dc2a1b7
					
				@ -1,21 +1,13 @@
 | 
			
		||||
import 'package:fast_rsa/model/bridge.pb.dart';
 | 
			
		||||
import 'package:shared_preferences/shared_preferences.dart';
 | 
			
		||||
import 'package:sqflite/sqflite.dart';
 | 
			
		||||
import 'package:fast_rsa/rsa.dart';
 | 
			
		||||
import 'package:dbcrypt/dbcrypt.dart';
 | 
			
		||||
 | 
			
		||||
import 'package:flutter_udid/flutter_udid.dart';
 | 
			
		||||
import 'package:loc_chain_app/util/keyfile_manager.dart';
 | 
			
		||||
 | 
			
		||||
import 'dart:io';
 | 
			
		||||
 | 
			
		||||
class Transaction {
 | 
			
		||||
  Transaction({required this.hash, required this.pubKey});
 | 
			
		||||
  final String hash;
 | 
			
		||||
  final String pubKey;
 | 
			
		||||
 | 
			
		||||
  static Future<String> generateHash(String otherUserId) async {
 | 
			
		||||
    String id = await SharedPreferences.getInstance()
 | 
			
		||||
        .then((s) => s.getString('userName') ?? '');
 | 
			
		||||
    String id = await FlutterUdid.consistentUdid;
 | 
			
		||||
    bool idLess = id.compareTo(otherUserId) < 0;
 | 
			
		||||
    var lesser = idLess ? id : otherUserId;
 | 
			
		||||
    var greater = idLess ? otherUserId : id;
 | 
			
		||||
@ -27,13 +19,3 @@ class Transaction {
 | 
			
		||||
  Future<String> generateP2PPayload(String otherUserId) async =>
 | 
			
		||||
      "${await generateHash(otherUserId)}:${KeyFileManager.keyPair.publicKey}";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class TransactionsDBManager {
 | 
			
		||||
  static Future<Database> get _localFile async {
 | 
			
		||||
    return openDatabase('transactions.db');
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static Future<List<Transaction>?> readTransactions() async {}
 | 
			
		||||
 | 
			
		||||
  static Future<void> writeKeyPair(KeyPair pair) async {}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -77,7 +77,7 @@ packages:
 | 
			
		||||
      name: fast_rsa
 | 
			
		||||
      url: "https://pub.dartlang.org"
 | 
			
		||||
    source: hosted
 | 
			
		||||
    version: "1.4.0-nullsafety.4"
 | 
			
		||||
    version: "2.0.0-nullsafety.0"
 | 
			
		||||
  ffi:
 | 
			
		||||
    dependency: transitive
 | 
			
		||||
    description:
 | 
			
		||||
@ -92,6 +92,34 @@ packages:
 | 
			
		||||
      url: "https://pub.dartlang.org"
 | 
			
		||||
    source: hosted
 | 
			
		||||
    version: "6.1.0"
 | 
			
		||||
  firebase_core:
 | 
			
		||||
    dependency: transitive
 | 
			
		||||
    description:
 | 
			
		||||
      name: firebase_core
 | 
			
		||||
      url: "https://pub.dartlang.org"
 | 
			
		||||
    source: hosted
 | 
			
		||||
    version: "1.0.3"
 | 
			
		||||
  firebase_core_platform_interface:
 | 
			
		||||
    dependency: transitive
 | 
			
		||||
    description:
 | 
			
		||||
      name: firebase_core_platform_interface
 | 
			
		||||
      url: "https://pub.dartlang.org"
 | 
			
		||||
    source: hosted
 | 
			
		||||
    version: "4.0.0"
 | 
			
		||||
  firebase_core_web:
 | 
			
		||||
    dependency: transitive
 | 
			
		||||
    description:
 | 
			
		||||
      name: firebase_core_web
 | 
			
		||||
      url: "https://pub.dartlang.org"
 | 
			
		||||
    source: hosted
 | 
			
		||||
    version: "1.0.2"
 | 
			
		||||
  firebase_database:
 | 
			
		||||
    dependency: "direct main"
 | 
			
		||||
    description:
 | 
			
		||||
      name: firebase_database
 | 
			
		||||
      url: "https://pub.dartlang.org"
 | 
			
		||||
    source: hosted
 | 
			
		||||
    version: "6.1.2"
 | 
			
		||||
  fixnum:
 | 
			
		||||
    dependency: transitive
 | 
			
		||||
    description:
 | 
			
		||||
 | 
			
		||||
@ -30,10 +30,11 @@ dependencies:
 | 
			
		||||
  # Use with the CupertinoIcons class for iOS style icons.
 | 
			
		||||
  cupertino_icons: ^1.0.2
 | 
			
		||||
  path_provider: ^2.0.1
 | 
			
		||||
  fast_rsa: ^1.4.0-nullsafety.4
 | 
			
		||||
  fast_rsa: ^2.0.0-nullsafety.0
 | 
			
		||||
  sqflite: ^2.0.0+3
 | 
			
		||||
  dbcrypt: ^2.0.0
 | 
			
		||||
  flutter_udid: ^2.0.0
 | 
			
		||||
  firebase_database: ^6.1.2
 | 
			
		||||
 | 
			
		||||
dev_dependencies:
 | 
			
		||||
  flutter_test:
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user