@@ -27,8 +27,8 @@ use crate::coin_balance::{EnableCoinBalanceError, EnabledCoinBalanceParams, HDAc
27
27
HDWalletBalance , HDWalletBalanceOps } ;
28
28
use crate :: eth:: eth_rpc:: ETH_RPC_REQUEST_TIMEOUT ;
29
29
use crate :: eth:: web3_transport:: websocket_transport:: { WebsocketTransport , WebsocketTransportNode } ;
30
- use crate :: hd_wallet:: { HDAccountOps , HDCoinAddress , HDCoinWithdrawOps , HDConfirmAddress , HDPathAccountToAddressId ,
31
- HDWalletCoinOps , HDXPubExtractor } ;
30
+ use crate :: hd_wallet:: { DisplayAddress , HDAccountOps , HDCoinAddress , HDCoinWithdrawOps , HDConfirmAddress ,
31
+ HDPathAccountToAddressId , HDWalletCoinOps , HDXPubExtractor } ;
32
32
use crate :: lp_price:: get_base_price_in_rel;
33
33
use crate :: nft:: nft_errors:: ParseContractTypeError ;
34
34
use crate :: nft:: nft_structs:: { ContractType , ConvertChain , NftInfo , TransactionNftDetails , WithdrawErc1155 ,
@@ -1196,8 +1196,8 @@ pub async fn withdraw_erc721(ctx: MmArc, withdraw_type: WithdrawErc721) -> Withd
1196
1196
let my_address = eth_coin. derivation_method . single_addr_or_err ( ) . await ?;
1197
1197
if token_owner != my_address {
1198
1198
return MmError :: err ( WithdrawError :: MyAddressNotNftOwner {
1199
- my_address : eth_addr_to_hex ( & my_address) ,
1200
- token_owner : eth_addr_to_hex ( & token_owner) ,
1199
+ my_address : my_address. display_address ( ) ,
1200
+ token_owner : token_owner. display_address ( ) ,
1201
1201
} ) ;
1202
1202
}
1203
1203
@@ -2287,7 +2287,7 @@ impl MarketCoinOps for EthCoin {
2287
2287
2288
2288
fn my_address ( & self ) -> MmResult < String , MyAddressError > {
2289
2289
match self . derivation_method ( ) {
2290
- DerivationMethod :: SingleAddress ( my_address) => Ok ( display_eth_address ( my_address) ) ,
2290
+ DerivationMethod :: SingleAddress ( my_address) => Ok ( my_address. display_address ( ) ) ,
2291
2291
DerivationMethod :: HDWallet ( _) => MmError :: err ( MyAddressError :: UnexpectedDerivationMethod (
2292
2292
"'my_address' is deprecated for HD wallets" . to_string ( ) ,
2293
2293
) ) ,
@@ -3270,8 +3270,8 @@ impl EthCoin {
3270
3270
spent_by_me,
3271
3271
received_by_me,
3272
3272
total_amount,
3273
- to : vec ! [ display_eth_address ( & call_data. to) ] ,
3274
- from : vec ! [ display_eth_address ( & call_data. from) ] ,
3273
+ to : vec ! [ call_data. to. display_address ( ) ] ,
3274
+ from : vec ! [ call_data. from. display_address ( ) ] ,
3275
3275
coin : self . ticker . clone ( ) ,
3276
3276
fee_details : fee_details. map ( |d| d. into ( ) ) ,
3277
3277
block_height : trace. block_number ,
@@ -3650,8 +3650,8 @@ impl EthCoin {
3650
3650
spent_by_me,
3651
3651
received_by_me,
3652
3652
total_amount,
3653
- to : vec ! [ display_eth_address ( & to_addr) ] ,
3654
- from : vec ! [ display_eth_address ( & from_addr) ] ,
3653
+ to : vec ! [ to_addr. display_address ( ) ] ,
3654
+ from : vec ! [ from_addr. display_address ( ) ] ,
3655
3655
coin : self . ticker . clone ( ) ,
3656
3656
fee_details : fee_details. map ( |d| d. into ( ) ) ,
3657
3657
block_height : block_number. as_u64 ( ) ,
@@ -6550,16 +6550,12 @@ pub fn checksum_address(addr: &str) -> String {
6550
6550
6551
6551
/// `eth_addr_to_hex` converts Address to hex format.
6552
6552
/// Note: the result will be in lowercase.
6553
- pub fn eth_addr_to_hex ( address : & Address ) -> String { format ! ( "{:#02x }" , address) }
6553
+ fn eth_addr_to_hex ( address : & Address ) -> String { format ! ( "{:#x }" , address) }
6554
6554
6555
6555
/// Checks that input is valid mixed-case checksum form address
6556
6556
/// The input must be 0x prefixed hex string
6557
6557
fn is_valid_checksum_addr ( addr : & str ) -> bool { addr == checksum_address ( addr) }
6558
6558
6559
- /// `display_eth_address` converts Address to mixed-case checksum form.
6560
- #[ inline]
6561
- pub fn display_eth_address ( addr : & Address ) -> String { checksum_address ( & eth_addr_to_hex ( addr) ) }
6562
-
6563
6559
fn increase_by_percent_one_gwei ( num : U256 , percent : u64 ) -> U256 {
6564
6560
let one_gwei = U256 :: from ( 10u64 . pow ( 9 ) ) ;
6565
6561
let percent = ( num / U256 :: from ( 100 ) ) * U256 :: from ( percent) ;
@@ -6645,7 +6641,7 @@ pub async fn get_eth_address(
6645
6641
6646
6642
Ok ( MyWalletAddress {
6647
6643
coin : ticker. to_owned ( ) ,
6648
- wallet_address : display_eth_address ( & my_address) ,
6644
+ wallet_address : my_address. display_address ( ) ,
6649
6645
} )
6650
6646
}
6651
6647
@@ -7229,31 +7225,34 @@ impl TakerCoinSwapOpsV2 for EthCoin {
7229
7225
self . refund_taker_payment_with_timelock_impl ( args) . await
7230
7226
}
7231
7227
7232
- /// Eth doesnt have preimages
7228
+ fn skip_taker_payment_spend_preimage ( & self ) -> bool { true }
7229
+
7230
+ /// Eth skips taker_payment_spend_preimage, as it doesnt need it
7233
7231
async fn gen_taker_payment_spend_preimage (
7234
7232
& self ,
7235
- args : & GenTakerPaymentSpendArgs < ' _ , Self > ,
7233
+ _args : & GenTakerPaymentSpendArgs < ' _ , Self > ,
7236
7234
_swap_unique_data : & [ u8 ] ,
7237
7235
) -> GenPreimageResult < Self > {
7238
- Ok ( TxPreimageWithSig {
7239
- preimage : args. taker_tx . clone ( ) ,
7240
- signature : args. taker_tx . signature ( ) ,
7241
- } )
7236
+ MmError :: err ( TxGenError :: Other (
7237
+ "EVM-based coin doesn't have taker_payment_spend_preimage. Report the Bug!" . to_string ( ) ,
7238
+ ) )
7242
7239
}
7243
7240
7244
- /// Eth doesnt have preimages
7241
+ /// Eth skips taker_payment_spend_preimage, as it doesnt need it
7245
7242
async fn validate_taker_payment_spend_preimage (
7246
7243
& self ,
7247
7244
_gen_args : & GenTakerPaymentSpendArgs < ' _ , Self > ,
7248
7245
_preimage : & TxPreimageWithSig < Self > ,
7249
7246
) -> ValidateTakerPaymentSpendPreimageResult {
7250
- Ok ( ( ) )
7247
+ MmError :: err ( ValidateTakerPaymentSpendPreimageError :: InvalidPreimage (
7248
+ "EVM-based coin skips taker_payment_spend_preimage validation. Report the Bug!" . to_string ( ) ,
7249
+ ) )
7251
7250
}
7252
7251
7253
- /// Wrapper for [EthCoin::sign_and_broadcast_taker_payment_spend_impl]
7252
+ /// Eth doesnt have preimages
7254
7253
async fn sign_and_broadcast_taker_payment_spend (
7255
7254
& self ,
7256
- _preimage : & TxPreimageWithSig < Self > ,
7255
+ _preimage : Option < & TxPreimageWithSig < Self > > ,
7257
7256
gen_args : & GenTakerPaymentSpendArgs < ' _ , Self > ,
7258
7257
secret : & [ u8 ] ,
7259
7258
_swap_unique_data : & [ u8 ] ,
0 commit comments