wownero node and ui fixes

This commit is contained in:
julian 2022-09-28 09:17:16 -06:00
parent edc9c11c95
commit 7b3b7554b0
10 changed files with 46 additions and 19 deletions

View file

@ -85,7 +85,7 @@ class _SendFromViewState extends ConsumerState<SendFromView> {
height: 8,
),
Text(
"You need to send ${amount.toStringAsFixed(coin == Coin.monero ? 12 : 8)} ${coin.ticker}",
"You need to send ${amount.toStringAsFixed(coin == Coin.monero || coin == Coin.wownero ? 12 : 8)} ${coin.ticker}",
style: STextStyles.itemSubtitle(context),
),
const SizedBox(
@ -307,7 +307,10 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
"${Format.localizedStringAsFixed(
value: snapshot.data!,
locale: locale,
decimalPlaces: coin == Coin.monero ? 12 : 8,
decimalPlaces:
coin == Coin.monero || coin == Coin.wownero
? 12
: 8,
)} ${coin.ticker}",
style: STextStyles.itemSubtitle(context),
);

View file

@ -90,6 +90,7 @@ class _AddEditNodeViewState extends ConsumerState<AddEditNodeView> {
break;
case Coin.monero:
case Coin.wownero:
try {
final uri = Uri.parse(formData.host!);
if (uri.scheme.startsWith("http")) {
@ -384,6 +385,7 @@ class _AddEditNodeViewState extends ConsumerState<AddEditNodeView> {
// strip unused path
String address = formData.host!;
if (coin == Coin.monero ||
coin == Coin.wownero ||
coin == Coin.epicCash) {
if (address.startsWith("http")) {
final uri = Uri.parse(address);
@ -700,7 +702,9 @@ class _NodeFormState extends ConsumerState<NodeForm> {
focusNode: _hostFocusNode,
style: STextStyles.field(context),
decoration: standardInputDecoration(
(widget.coin != Coin.monero && widget.coin != Coin.epicCash)
(widget.coin != Coin.monero &&
widget.coin != Coin.wownero &&
widget.coin != Coin.epicCash)
? "IP address"
: "Url",
_hostFocusNode,
@ -881,7 +885,9 @@ class _NodeFormState extends ConsumerState<NodeForm> {
const SizedBox(
height: 8,
),
if (widget.coin != Coin.monero && widget.coin != Coin.epicCash)
if (widget.coin != Coin.monero &&
widget.coin != Coin.wownero &&
widget.coin != Coin.epicCash)
Row(
children: [
GestureDetector(
@ -932,11 +938,15 @@ class _NodeFormState extends ConsumerState<NodeForm> {
),
],
),
if (widget.coin != Coin.monero && widget.coin != Coin.epicCash)
if (widget.coin != Coin.monero &&
widget.coin != Coin.wownero &&
widget.coin != Coin.epicCash)
const SizedBox(
height: 8,
),
if (widget.coin != Coin.monero && widget.coin != Coin.epicCash)
if (widget.coin != Coin.monero &&
widget.coin != Coin.wownero &&
widget.coin != Coin.epicCash)
Row(
children: [
GestureDetector(

View file

@ -81,6 +81,7 @@ class _NodeDetailsViewState extends ConsumerState<NodeDetailsView> {
break;
case Coin.monero:
case Coin.wownero:
try {
final uri = Uri.parse(node!.host);
if (uri.scheme.startsWith("http")) {

View file

@ -12,6 +12,7 @@ import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_net
import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart';
import 'package:stackwallet/services/coins/monero/monero_wallet.dart';
import 'package:stackwallet/services/coins/wownero/wownero_wallet.dart';
import 'package:stackwallet/services/event_bus/events/global/blocks_remaining_event.dart';
import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart';
import 'package:stackwallet/services/event_bus/events/global/refresh_percent_changed_event.dart';
@ -205,7 +206,7 @@ class _WalletNetworkSettingsViewState
.getManager(widget.walletId)
.coin;
if (coin == Coin.monero || coin == Coin.epicCash) {
if (coin == Coin.monero || coin == Coin.wownero || coin == Coin.epicCash) {
_blocksRemainingSubscription = eventBus.on<BlocksRemainingEvent>().listen(
(event) async {
if (event.walletId == widget.walletId) {
@ -271,6 +272,15 @@ class _WalletNetworkSettingsViewState
if (_percent < highestPercent) {
_percent = highestPercent.clamp(0.0, 1.0);
}
} else if (coin == Coin.wownero) {
double highestPercent = (ref
.read(walletsChangeNotifierProvider)
.getManager(widget.walletId)
.wallet as WowneroWallet)
.highestPercentCached;
if (_percent < highestPercent) {
_percent = highestPercent.clamp(0.0, 1.0);
}
} else if (coin == Coin.epicCash) {
double highestPercent = (ref
.read(walletsChangeNotifierProvider)
@ -545,6 +555,7 @@ class _WalletNetworkSettingsViewState
),
),
if (coin == Coin.monero ||
coin == Coin.wownero ||
coin == Coin.epicCash)
Text(
" (Blocks to go: ${_blocksRemaining == -1 ? "?" : _blocksRemaining})",

View file

@ -239,7 +239,7 @@ class _TransactionDetailsViewState
children: [
SelectableText(
"$amountPrefix${Format.localizedStringAsFixed(
value: coin == Coin.monero
value: coin == Coin.monero || coin == Coin.wownero
? (amount / 10000.toDecimal()).toDecimal()
: amount,
locale: ref.watch(
@ -254,7 +254,7 @@ class _TransactionDetailsViewState
height: 2,
),
SelectableText(
"${Format.localizedStringAsFixed(value: (coin == Coin.monero ? (amount / 10000.toDecimal()).toDecimal() : amount) * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin).item1)), locale: ref.watch(
"${Format.localizedStringAsFixed(value: (coin == Coin.monero || coin == Coin.wownero ? (amount / 10000.toDecimal()).toDecimal() : amount) * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin).item1)), locale: ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
), decimalPlaces: 2)} ${ref.watch(
@ -298,14 +298,14 @@ class _TransactionDetailsViewState
],
),
),
if (!(coin == Coin.monero &&
if (!((coin == Coin.monero || coin == Coin.wownero) &&
_transaction.txType.toLowerCase() == "sent") &&
!((coin == Coin.firo || coin == Coin.firoTestNet) &&
_transaction.subType == "mint"))
const SizedBox(
height: 12,
),
if (!(coin == Coin.monero &&
if (!((coin == Coin.monero || coin == Coin.wownero) &&
_transaction.txType.toLowerCase() == "sent") &&
!((coin == Coin.firo || coin == Coin.firoTestNet) &&
_transaction.subType == "mint"))
@ -462,7 +462,7 @@ class _TransactionDetailsViewState
showFeePending
? _transaction.confirmedStatus
? Format.localizedStringAsFixed(
value: coin == Coin.monero
value: coin == Coin.monero || coin == Coin.wownero
? (fee / 10000.toDecimal()).toDecimal()
: fee,
locale: ref.watch(
@ -471,7 +471,7 @@ class _TransactionDetailsViewState
decimalPlaces: Constants.decimalPlaces)
: "Pending"
: Format.localizedStringAsFixed(
value: coin == Coin.monero
value: coin == Coin.monero || coin == Coin.wownero
? (fee / 10000.toDecimal()).toDecimal()
: fee,
locale: ref.watch(

View file

@ -750,7 +750,7 @@ class _TransactionSearchViewState
}
int? amount;
if (amountDecimal != null) {
if (widget.coin == Coin.monero) {
if (widget.coin == Coin.monero || widget.coin == Coin.wownero) {
amount = (amountDecimal * Decimal.fromInt(Constants.satsPerCoinMonero))
.floor()
.toBigInt()

View file

@ -223,7 +223,7 @@ class Wallets extends ChangeNotifier {
final shouldSetAutoSync = shouldAutoSyncAll ||
walletIdsToEnableAutoSync.contains(manager.walletId);
if (manager.coin == Coin.monero) {
if (manager.coin == Coin.monero || manager.coin == Coin.wownero) {
walletsToInitLinearly.add(Tuple2(manager, shouldSetAutoSync));
} else {
walletInitFutures.add(manager.initializeExisting().then((value) {
@ -312,7 +312,7 @@ class Wallets extends ChangeNotifier {
final shouldSetAutoSync = shouldAutoSyncAll ||
walletIdsToEnableAutoSync.contains(manager.walletId);
if (manager.coin == Coin.monero) {
if (manager.coin == Coin.monero || manager.coin == Coin.wownero) {
walletsToInitLinearly.add(Tuple2(manager, shouldSetAutoSync));
} else {
walletInitFutures.add(manager.initializeExisting().then((value) {

View file

@ -15,6 +15,7 @@ abstract class DefaultNodes {
epicCash,
bitcoincash,
namecoin,
wownero,
bitcoinTestnet,
bitcoincashTestnet,
dogecoinTestnet,
@ -86,7 +87,7 @@ abstract class DefaultNodes {
// TODO: eventually enable ssl and set scheme to https
// currently get certificate failure
static NodeModel get wownero => NodeModel(
host: "eu-west-2.wow.xmr.pm",
host: "http://eu-west-2.wow.xmr.pm",
port: 34568,
name: defaultName,
id: _nodeId(Coin.wownero),

View file

@ -85,6 +85,7 @@ class NodeOptionsSheet extends ConsumerWidget {
break;
case Coin.monero:
case Coin.wownero:
try {
final uri = Uri.parse(node.host);
if (uri.scheme.startsWith("http")) {

View file

@ -170,7 +170,7 @@ class _TransactionCardState extends ConsumerState<TransactionCard> {
fit: BoxFit.scaleDown,
child: Builder(
builder: (_) {
final amount = coin == Coin.monero
final amount = coin == Coin.monero || coin == Coin.wownero
? (_transaction.amount ~/ 10000)
: _transaction.amount;
return Text(
@ -210,7 +210,7 @@ class _TransactionCardState extends ConsumerState<TransactionCard> {
builder: (_) {
// TODO: modify Format.<functions> to take optional Coin parameter so this type oif check isn't done in ui
int value = _transaction.amount;
if (coin == Coin.monero) {
if (coin == Coin.monero || coin == Coin.wownero) {
value = (value ~/ 10000);
}