2023-07-24 18:09:28 +00:00
|
|
|
part of 'nano.dart';
|
|
|
|
|
2023-08-10 22:34:20 +00:00
|
|
|
class CWNanoAccountList extends NanoAccountList {
|
|
|
|
CWNanoAccountList(this._wallet);
|
|
|
|
final Object _wallet;
|
|
|
|
|
|
|
|
@override
|
|
|
|
@computed
|
|
|
|
ObservableList<NanoAccount> get accounts {
|
|
|
|
final nanoWallet = _wallet as NanoWallet;
|
|
|
|
final accounts = nanoWallet.walletAddresses.accountList.accounts
|
|
|
|
.map((acc) => NanoAccount(id: acc.id, label: acc.label, balance: acc.balance))
|
|
|
|
.toList();
|
|
|
|
return ObservableList<NanoAccount>.of(accounts);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void update(Object wallet) {
|
|
|
|
final nanoWallet = wallet as NanoWallet;
|
|
|
|
nanoWallet.walletAddresses.accountList.update();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void refresh(Object wallet) {
|
|
|
|
final nanoWallet = wallet as NanoWallet;
|
|
|
|
nanoWallet.walletAddresses.accountList.refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Future<List<NanoAccount>> getAll(Object wallet) async {
|
|
|
|
final nanoWallet = wallet as NanoWallet;
|
|
|
|
return (await nanoWallet.walletAddresses.accountList.getAll())
|
|
|
|
.map((acc) => NanoAccount(id: acc.id, label: acc.label, balance: acc.balance))
|
|
|
|
.toList();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Future<void> addAccount(Object wallet, {required String label}) async {
|
|
|
|
final nanoWallet = wallet as NanoWallet;
|
|
|
|
await nanoWallet.walletAddresses.accountList.addAccount(label: label);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Future<void> setLabelAccount(Object wallet,
|
|
|
|
{required int accountIndex, required String label}) async {
|
|
|
|
final nanoWallet = wallet as NanoWallet;
|
|
|
|
await nanoWallet.walletAddresses.accountList
|
|
|
|
.setLabelAccount(accountIndex: accountIndex, label: label);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-24 20:23:09 +00:00
|
|
|
class CWNano extends Nano {
|
2023-08-10 22:34:20 +00:00
|
|
|
@override
|
|
|
|
NanoAccountList getAccountList(Object wallet) {
|
|
|
|
return CWNanoAccountList(wallet);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Account getCurrentAccount(Object wallet) {
|
|
|
|
final nanoWallet = wallet as NanoWallet;
|
|
|
|
final acc = nanoWallet.walletAddresses.account;
|
|
|
|
return Account(id: acc!.id, label: acc.label, balance: acc.balance);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void setCurrentAccount(Object wallet, int id, String label, String? balance) {
|
|
|
|
final nanoWallet = wallet as NanoWallet;
|
|
|
|
nanoWallet.walletAddresses.account = NanoAccount(id: id, label: label, balance: balance);
|
|
|
|
nanoWallet.regenerateAddress();
|
|
|
|
}
|
|
|
|
|
2023-07-24 18:09:28 +00:00
|
|
|
@override
|
2023-07-24 20:23:09 +00:00
|
|
|
List<String> getNanoWordList(String language) {
|
2023-07-25 20:31:52 +00:00
|
|
|
return NanoMnemomics.WORDLIST;
|
2023-07-24 20:23:09 +00:00
|
|
|
}
|
2023-07-24 18:09:28 +00:00
|
|
|
|
|
|
|
@override
|
2023-07-24 20:23:09 +00:00
|
|
|
WalletService createNanoWalletService(Box<WalletInfo> walletInfoSource) {
|
2023-07-25 15:21:49 +00:00
|
|
|
return NanoWalletService(walletInfoSource);
|
2023-07-24 21:01:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
String getTransactionAddress(Object wallet, int accountIndex, int addressIndex) {
|
|
|
|
throw UnimplementedError();
|
2023-07-24 18:09:28 +00:00
|
|
|
}
|
|
|
|
|
2023-07-31 15:39:22 +00:00
|
|
|
@override
|
|
|
|
Map<String, String> getKeys(Object wallet) {
|
|
|
|
final nanoWallet = wallet as NanoWallet;
|
|
|
|
final keys = nanoWallet.keys;
|
|
|
|
return <String, String>{
|
|
|
|
"seedKey": keys.seedKey,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-07-24 18:09:28 +00:00
|
|
|
@override
|
2023-07-24 20:23:09 +00:00
|
|
|
WalletCredentials createNanoNewWalletCredentials({
|
|
|
|
required String name,
|
|
|
|
String? password,
|
2023-07-25 20:31:52 +00:00
|
|
|
}) =>
|
|
|
|
NanoNewWalletCredentials(
|
|
|
|
name: name,
|
|
|
|
password: password,
|
|
|
|
);
|
|
|
|
|
|
|
|
@override
|
|
|
|
WalletCredentials createNanoRestoreWalletFromSeedCredentials({
|
|
|
|
required String name,
|
|
|
|
required String password,
|
2023-07-31 13:10:33 +00:00
|
|
|
required String mnemonic,
|
|
|
|
DerivationType? derivationType,
|
2023-07-25 20:31:52 +00:00
|
|
|
}) =>
|
|
|
|
NanoRestoreWalletFromSeedCredentials(
|
|
|
|
name: name,
|
|
|
|
password: password,
|
|
|
|
mnemonic: mnemonic,
|
2023-07-26 17:15:22 +00:00
|
|
|
derivationType: derivationType,
|
2023-07-25 20:31:52 +00:00
|
|
|
);
|
2023-07-24 18:09:28 +00:00
|
|
|
|
|
|
|
@override
|
2023-07-24 20:23:09 +00:00
|
|
|
TransactionHistoryBase getTransactionHistory(Object wallet) {
|
|
|
|
throw UnimplementedError();
|
2023-07-24 18:09:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
2023-08-01 13:50:07 +00:00
|
|
|
void onStartup() {}
|
2023-07-31 13:10:33 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Object createNanoTransactionCredentials(List<Output> outputs) {
|
|
|
|
return NanoTransactionCredentials(
|
|
|
|
outputs
|
|
|
|
.map((out) => OutputInfo(
|
|
|
|
fiatAmount: out.fiatAmount,
|
|
|
|
cryptoAmount: out.cryptoAmount,
|
|
|
|
address: out.address,
|
|
|
|
note: out.note,
|
|
|
|
sendAll: out.sendAll,
|
|
|
|
extractedAddress: out.extractedAddress,
|
|
|
|
isParsedAddress: out.isParsedAddress,
|
|
|
|
formattedCryptoAmount: out.formattedCryptoAmount,
|
|
|
|
))
|
|
|
|
.toList(),
|
|
|
|
);
|
|
|
|
}
|
2023-08-10 22:34:20 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Future<void> setLabelAccount(Object wallet,
|
|
|
|
{required int accountIndex, required String label}) async {
|
|
|
|
final nanoWallet = wallet as NanoWallet;
|
|
|
|
await nanoWallet.walletAddresses.accountList
|
|
|
|
.setLabelAccount(accountIndex: accountIndex, label: label);
|
|
|
|
}
|
2023-07-24 18:09:28 +00:00
|
|
|
}
|