getMainKeyVaultStore method
Retrieves the main key vault store from disk.
name
is the filepath of the VaultStore to retrieve.
Returns the VaultStore for the Topl Main Secret Key if it exists. If retrieving fails due to an underlying cause, returns a WalletKeyException.
Implementation
@override
Future<VaultStore> getMainKeyVaultStore(String name) async {
if (await _storage.containsKey(key: name)) {
return (await _storage.read(key: name)).withResult((res) {
if (res == null) {
throw WalletKeyException.decodeVaultStore(
context: "Vault store {$name} is empty, thus undecodable");
}
final vs = VaultStore.fromJson(jsonDecode(res));
return vs.getRightOrThrowLeft();
});
} else {
throw WalletKeyException.vaultStoreDoesNotExist(context: name);
}
}