Skip to content

Commit

Permalink
adds general storage
Browse files Browse the repository at this point in the history
  • Loading branch information
thuyenBitmark authored and hvthhien committed Sep 23, 2022
1 parent 73e06d1 commit c58dcb3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
21 changes: 21 additions & 0 deletions lib/general_storage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'dart:async';

import 'package:flutter/services.dart';

class GeneralStorage {
static const MethodChannel _channel = const MethodChannel('libauk_dart');

Future<bool> hasPlatformShards() async {
final result = await _channel.invokeMethod('hasPlatformShards');
return result['result'];
}

Future<List<String>> scanPersonaUUIDs() async {
final result = await _channel.invokeMethod('scanPersonaUUIDs');
return List<String>.from(result['result']);
}

Future migrateAccountsFromV0ToV1() async {
await _channel.invokeMethod('migrateAccountsFromV0ToV1');
}
}
15 changes: 12 additions & 3 deletions lib/libauk_dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ import 'dart:async';
import 'dart:typed_data';

import 'package:flutter/services.dart';
import 'package:libauk_dart/general_storage.dart';

class LibAukDart {
static WalletStorage getWallet(String uuid) {
return WalletStorage(uuid);
}

static GeneralStorage general() {
return GeneralStorage();
}
}

class WalletStorage {
Expand Down Expand Up @@ -150,9 +155,13 @@ class WalletStorage {
}

Future<String?> getShard(ShardType shardType) async {
Map res = await _channel.invokeMethod(
'getShard', {'uuid': uuid, 'shardType': shardType.intValue});
return res["data"];
try {
Map res = await _channel.invokeMethod(
'getShard', {'uuid': uuid, 'shardType': shardType.intValue});
return res["data"];
} catch (_) {
return null;
}
}

Future removeShard(ShardType shardType) async {
Expand Down

0 comments on commit c58dcb3

Please sign in to comment.