refactor wallet constructors and add wownero shell

This commit is contained in:
julian 2023-11-06 12:26:33 -06:00
parent fa4fa60532
commit e6556de97e
15 changed files with 102 additions and 37 deletions

View file

@ -3,8 +3,8 @@ import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
import 'package:stackwallet/wallets/crypto_currency/bip39_hd_currency.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart';
class Bitcoin extends Bip39HDCurrency {
Bitcoin(super.network) {

View file

@ -8,8 +8,8 @@ import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
import 'package:stackwallet/wallets/crypto_currency/bip39_hd_currency.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart';
class Bitcoincash extends Bip39HDCurrency {
Bitcoincash(super.network) {

View file

@ -1,7 +1,7 @@
import 'package:flutter_libepiccash/lib.dart' as epic;
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/wallets/crypto_currency/bip39_currency.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_currency.dart';
class Epiccash extends Bip39Currency {
Epiccash(super.network) {

View file

@ -0,0 +1,19 @@
import 'package:stackwallet/wallets/crypto_currency/intermediate/cryptonote_currency.dart';
class Wownero extends CryptonoteCurrency {
Wownero(super.network);
@override
// TODO: implement genesisHash
String get genesisHash => throw UnimplementedError();
@override
// TODO: implement minConfirms
int get minConfirms => throw UnimplementedError();
@override
bool validateAddress(String address) {
// TODO: implement validateAddress
throw UnimplementedError();
}
}

View file

@ -6,7 +6,7 @@ import 'package:flutter/foundation.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
import 'package:stackwallet/wallets/crypto_currency/bip39_currency.dart';
import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_currency.dart';
abstract class Bip39HDCurrency extends Bip39Currency {
Bip39HDCurrency(super.network);

View file

@ -0,0 +1,5 @@
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
abstract class CryptonoteCurrency extends CryptoCurrency {
CryptonoteCurrency(super.network);
}

View file

@ -15,12 +15,9 @@ class BitcoinWallet extends Bip39HDWallet with ElectrumXMixin {
int get isarTransactionVersion => 2;
BitcoinWallet(
super.cryptoCurrency, {
Bitcoin cryptoCurrency, {
required NodeService nodeService,
}) {
// TODO: [prio=low] ensure this hack isn't needed
assert(cryptoCurrency is Bitcoin);
}) : super(cryptoCurrency) {
this.nodeService = nodeService;
}

View file

@ -24,12 +24,9 @@ class BitcoincashWallet extends Bip39HDWallet with ElectrumXMixin {
int get isarTransactionVersion => 2;
BitcoincashWallet(
super.cryptoCurrency, {
Bitcoincash cryptoCurrency, {
required NodeService nodeService,
}) {
// TODO: [prio=low] ensure this hack isn't needed
assert(cryptoCurrency is Bitcoincash);
}) : super(cryptoCurrency) {
this.nodeService = nodeService;
}

View file

@ -4,13 +4,17 @@ import 'package:stackwallet/services/node_service.dart';
import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/test_epic_box_connection.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/epiccash.dart';
import 'package:stackwallet/wallets/models/tx_data.dart';
import 'package:stackwallet/wallets/wallet/intermediate/bip39_wallet.dart';
class EpiccashWallet extends Bip39Wallet {
final NodeService nodeService;
late final NodeService nodeService;
EpiccashWallet(super.cryptoCurrency, {required this.nodeService});
EpiccashWallet(
Epiccash cryptoCurrency, {
required this.nodeService,
}) : super(cryptoCurrency);
@override
Future<TxData> confirmSend({required TxData txData}) {

View file

@ -0,0 +1,54 @@
import 'package:stackwallet/models/paymint/fee_object_model.dart';
import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/wallets/crypto_currency/coins/wownero.dart';
import 'package:stackwallet/wallets/wallet/intermediate/cryptonote_wallet.dart';
class WowneroWallet extends CryptonoteWallet {
WowneroWallet(Wownero wownero) : super(wownero);
@override
Future<Amount> estimateFeeFor(Amount amount, int feeRate) {
// TODO: implement estimateFeeFor
throw UnimplementedError();
}
@override
// TODO: implement fees
Future<FeeObject> get fees => throw UnimplementedError();
@override
Future<bool> pingCheck() {
// TODO: implement pingCheck
throw UnimplementedError();
}
@override
Future<void> updateBalance() {
// TODO: implement updateBalance
throw UnimplementedError();
}
@override
Future<void> updateChainHeight() {
// TODO: implement updateChainHeight
throw UnimplementedError();
}
@override
Future<void> updateNode() {
// TODO: implement updateNode
throw UnimplementedError();
}
@override
Future<void> updateTransactions() {
// TODO: implement updateTransactions
throw UnimplementedError();
}
@override
Future<void> updateUTXOs() {
// TODO: implement updateUTXOs
throw UnimplementedError();
}
}

View file

@ -5,12 +5,12 @@ import 'package:stackwallet/models/balance.dart';
import 'package:stackwallet/models/isar/models/isar_models.dart';
import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
import 'package:stackwallet/wallets/crypto_currency/bip39_hd_currency.dart';
import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart';
import 'package:stackwallet/wallets/models/tx_data.dart';
import 'package:stackwallet/wallets/wallet/intermediate/bip39_wallet.dart';
abstract class Bip39HDWallet<T extends Bip39HDCurrency> extends Bip39Wallet<T> {
Bip39HDWallet(super.cryptoCurrency);
Bip39HDWallet(T cryptoCurrency) : super(cryptoCurrency);
/// Generates a receiving address of [info.mainAddressType]. If none
/// are in the current wallet db it will generate at index 0, otherwise the

View file

@ -1,10 +1,10 @@
import 'package:stackwallet/wallets/crypto_currency/bip39_currency.dart';
import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_currency.dart';
import 'package:stackwallet/wallets/wallet/mixins/mnemonic_based_wallet.dart';
import 'package:stackwallet/wallets/wallet/wallet.dart';
abstract class Bip39Wallet<T extends Bip39Currency> extends Wallet<T>
with MnemonicBasedWallet {
Bip39Wallet(super.cryptoCurrency);
Bip39Wallet(T currency) : super(currency);
// ========== Private ========================================================

View file

@ -1,21 +1,11 @@
import 'package:stackwallet/exceptions/sw_exception.dart';
import 'package:stackwallet/wallets/crypto_currency/intermediate/cryptonote_currency.dart';
import 'package:stackwallet/wallets/models/tx_data.dart';
import 'package:stackwallet/wallets/wallet/mixins/mnemonic_based_wallet.dart';
import 'package:stackwallet/wallets/wallet/wallet.dart';
abstract class CryptonoteWallet extends Wallet {
CryptonoteWallet(super.cryptoCurrency);
Future<String> getMnemonic() async {
final mnemonic = await secureStorageInterface.read(
key: Wallet.mnemonicKey(walletId: info.walletId),
);
if (mnemonic == null) {
throw SWException("mnemonic has not been set");
}
return mnemonic;
}
abstract class CryptonoteWallet<T extends CryptonoteCurrency> extends Wallet<T>
with MnemonicBasedWallet<T> {
CryptonoteWallet(T currency) : super(currency);
// ========== Overrides ======================================================

View file

@ -1,8 +1,7 @@
import 'package:stackwallet/exceptions/sw_exception.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/wallets/wallet/wallet.dart';
import '../../crypto_currency/crypto_currency.dart';
mixin MnemonicBasedWallet<T extends CryptoCurrency> on Wallet<T> {
Future<String> getMnemonic() async {
final mnemonic = await secureStorageInterface.read(