2023-07-24 20:23:09 +00:00
|
|
|
import 'dart:ffi';
|
|
|
|
import 'package:ffi/ffi.dart';
|
|
|
|
import 'package:cw_nano/api/signatures.dart';
|
|
|
|
import 'package:cw_nano/api/types.dart';
|
|
|
|
import 'package:cw_nano/api/monero_api.dart';
|
|
|
|
import 'package:cw_nano/api/structs/account_row.dart';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:cw_nano/api/wallet.dart';
|
|
|
|
|
2023-08-10 22:34:20 +00:00
|
|
|
// final accountSizeNative = moneroApi
|
|
|
|
// .lookup<NativeFunction<account_size>>('account_size')
|
|
|
|
// .asFunction<SubaddressSize>();
|
2023-07-24 20:23:09 +00:00
|
|
|
|
2023-08-10 22:34:20 +00:00
|
|
|
// final accountRefreshNative = moneroApi
|
|
|
|
// .lookup<NativeFunction<account_refresh>>('account_refresh')
|
|
|
|
// .asFunction<AccountRefresh>();
|
2023-07-24 20:23:09 +00:00
|
|
|
|
2023-08-10 22:34:20 +00:00
|
|
|
// final accountGetAllNative = moneroApi
|
|
|
|
// .lookup<NativeFunction<account_get_all>>('account_get_all')
|
|
|
|
// .asFunction<AccountGetAll>();
|
2023-07-24 20:23:09 +00:00
|
|
|
|
2023-08-10 22:34:20 +00:00
|
|
|
// final accountAddNewNative = moneroApi
|
|
|
|
// .lookup<NativeFunction<account_add_new>>('account_add_row')
|
|
|
|
// .asFunction<AccountAddNew>();
|
2023-07-24 20:23:09 +00:00
|
|
|
|
2023-08-10 22:34:20 +00:00
|
|
|
// final accountSetLabelNative = moneroApi
|
|
|
|
// .lookup<NativeFunction<account_set_label>>('account_set_label_row')
|
|
|
|
// .asFunction<AccountSetLabel>();
|
2023-07-24 20:23:09 +00:00
|
|
|
|
|
|
|
bool isUpdating = false;
|
|
|
|
|
|
|
|
void refreshAccounts() {
|
2023-08-10 22:34:20 +00:00
|
|
|
// try {
|
|
|
|
// isUpdating = true;
|
|
|
|
// accountRefreshNative();
|
|
|
|
// isUpdating = false;
|
|
|
|
// } catch (e) {
|
|
|
|
// isUpdating = false;
|
|
|
|
// rethrow;
|
|
|
|
// }
|
2023-07-24 20:23:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
List<AccountRow> getAllAccount() {
|
2023-08-10 22:34:20 +00:00
|
|
|
// final size = accountSizeNative();
|
|
|
|
// final accountAddressesPointer = accountGetAllNative();
|
|
|
|
// final accountAddresses = accountAddressesPointer.asTypedList(size);
|
|
|
|
|
|
|
|
// return accountAddresses
|
|
|
|
// .map((addr) => Pointer<AccountRow>.fromAddress(addr).ref)
|
|
|
|
// .toList();
|
|
|
|
return [];
|
2023-07-24 20:23:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void addAccountSync({required String label}) {
|
2023-08-10 22:34:20 +00:00
|
|
|
// final labelPointer = label.toNativeUtf8();
|
|
|
|
// accountAddNewNative(labelPointer);
|
|
|
|
// calloc.free(labelPointer);
|
2023-07-24 20:23:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setLabelForAccountSync({required int accountIndex, required String label}) {
|
2023-08-10 22:34:20 +00:00
|
|
|
// final labelPointer = label.toNativeUtf8();
|
|
|
|
// accountSetLabelNative(accountIndex, labelPointer);
|
|
|
|
// calloc.free(labelPointer);
|
2023-07-24 20:23:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void _addAccount(String label) => addAccountSync(label: label);
|
|
|
|
|
|
|
|
void _setLabelForAccount(Map<String, dynamic> args) {
|
2023-08-10 22:34:20 +00:00
|
|
|
// final label = args['label'] as String;
|
|
|
|
// final accountIndex = args['accountIndex'] as int;
|
2023-07-24 20:23:09 +00:00
|
|
|
|
2023-08-10 22:34:20 +00:00
|
|
|
// setLabelForAccountSync(label: label, accountIndex: accountIndex);
|
2023-07-24 20:23:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> addAccount({required String label}) async {
|
2023-08-10 22:34:20 +00:00
|
|
|
// await compute(_addAccount, label);
|
|
|
|
// await store();
|
2023-07-24 20:23:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> setLabelForAccount({required int accountIndex, required String label}) async {
|
2023-08-10 22:34:20 +00:00
|
|
|
// await compute(_setLabelForAccount, {'accountIndex': accountIndex, 'label': label});
|
|
|
|
// await store();
|
|
|
|
}
|