fix address format

This commit is contained in:
Serhii 2023-08-30 15:26:18 +03:00
parent 20acc303fd
commit 1549bf4d8c
3 changed files with 18 additions and 6 deletions

View file

@ -4,6 +4,7 @@ import 'package:cake_wallet/entities/parse_address_from_domain.dart';
import 'package:cake_wallet/entities/parsed_address.dart'; import 'package:cake_wallet/entities/parsed_address.dart';
import 'package:cake_wallet/ethereum/ethereum.dart'; import 'package:cake_wallet/ethereum/ethereum.dart';
import 'package:cake_wallet/haven/haven.dart'; import 'package:cake_wallet/haven/haven.dart';
import 'package:bitbox/bitbox.dart' as bitbox;
import 'package:cake_wallet/src/screens/send/widgets/extract_address_from_parsed.dart'; import 'package:cake_wallet/src/screens/send/widgets/extract_address_from_parsed.dart';
import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/crypto_currency.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -259,7 +260,10 @@ abstract class OutputBase with Store {
void loadContact(ContactBase contact) { void loadContact(ContactBase contact) {
address = contact.name; address = contact.name;
parsedAddress = ParsedAddress.fetchContactAddress(address: contact.address, name: contact.name); final cantactAddress = _wallet.type == WalletType.bitcoinCash
? bitbox.Address.toCashAddress(contact.address)
: contact.address;
parsedAddress = ParsedAddress.fetchContactAddress(address: cantactAddress, name: contact.name);
extractedAddress = parsedAddress.addresses.first; extractedAddress = parsedAddress.addresses.first;
note = parsedAddress.description; note = parsedAddress.description;
} }

View file

@ -3,7 +3,7 @@ import 'package:cake_wallet/bitcoin/bitcoin.dart';
import 'package:cw_core/unspent_transaction_output.dart'; import 'package:cw_core/unspent_transaction_output.dart';
import 'package:cake_wallet/monero/monero.dart'; import 'package:cake_wallet/monero/monero.dart';
import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_item.dart'; import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_item.dart';
import 'package:cw_bitcoin/bitcoin_wallet.dart'; import 'package:bitbox/bitbox.dart' as bitbox;
import 'package:cw_core/unspent_coins_info.dart'; import 'package:cw_core/unspent_coins_info.dart';
import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_base.dart';
import 'package:cw_core/wallet_type.dart'; import 'package:cw_core/wallet_type.dart';
@ -29,11 +29,13 @@ abstract class UnspentCoinsListViewModelBase with Store {
ObservableList<UnspentCoinsItem> get items => ObservableList<UnspentCoinsItem> get items =>
ObservableList.of(_getUnspents().map((elem) { ObservableList.of(_getUnspents().map((elem) {
final amount = formatAmountToString(elem.value) + ' ${wallet.currency.title}'; final amount = formatAmountToString(elem.value) + ' ${wallet.currency.title}';
final address = wallet.type == WalletType.bitcoinCash
? bitbox.Address.toCashAddress(elem.address) : elem.address;
final info = getUnspentCoinInfo(elem.hash, elem.address, elem.value, elem.vout, elem.keyImage); final info = getUnspentCoinInfo(elem.hash, address, elem.value, elem.vout, elem.keyImage);
return UnspentCoinsItem( return UnspentCoinsItem(
address: elem.address, address: address,
amount: amount, amount: amount,
hash: elem.hash, hash: elem.hash,
isFrozen: info?.isFrozen ?? false, isFrozen: info?.isFrozen ?? false,

View file

@ -1,4 +1,5 @@
import 'package:cake_wallet/ethereum/ethereum.dart'; import 'package:cake_wallet/ethereum/ethereum.dart';
import 'package:bitbox/bitbox.dart' as bitbox;
import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cake_wallet/entities/fiat_currency.dart';
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart'; import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
import 'package:cake_wallet/store/yat/yat_store.dart'; import 'package:cake_wallet/store/yat/yat_store.dart';
@ -165,8 +166,13 @@ abstract class WalletAddressListViewModelBase with Store {
WalletType get type => _wallet.type; WalletType get type => _wallet.type;
@computed @computed
WalletAddressListItem get address => WalletAddressListItem get address {
WalletAddressListItem(address: _wallet.walletAddresses.address, isPrimary: false); final address = _wallet.type == WalletType.bitcoinCash ?
bitbox.Address.toCashAddress(_wallet.walletAddresses.address) :
_wallet.walletAddresses.address;
return WalletAddressListItem(address: address, isPrimary: false);
}
@computed @computed
PaymentURI get uri { PaymentURI get uri {