@@ -28,8 +28,8 @@ use crate::coin_balance::{EnableCoinBalanceError, EnabledCoinBalanceParams, HDAc
28
28
HDWalletBalance , HDWalletBalanceOps } ;
29
29
use crate :: eth:: eth_rpc:: ETH_RPC_REQUEST_TIMEOUT ;
30
30
use crate :: eth:: web3_transport:: websocket_transport:: { WebsocketTransport , WebsocketTransportNode } ;
31
- use crate :: hd_wallet:: { HDAccountOps , HDCoinAddress , HDCoinWithdrawOps , HDConfirmAddress , HDPathAccountToAddressId ,
32
- HDWalletCoinOps , HDXPubExtractor } ;
31
+ use crate :: hd_wallet:: { DisplayAddress , HDAccountOps , HDCoinAddress , HDCoinWithdrawOps , HDConfirmAddress ,
32
+ HDPathAccountToAddressId , HDWalletCoinOps , HDXPubExtractor } ;
33
33
use crate :: lp_price:: get_base_price_in_rel;
34
34
use crate :: nft:: nft_errors:: ParseContractTypeError ;
35
35
use crate :: nft:: nft_structs:: { ContractType , ConvertChain , NftInfo , TransactionNftDetails , WithdrawErc1155 ,
@@ -1204,8 +1204,8 @@ pub async fn withdraw_erc721(ctx: MmArc, withdraw_type: WithdrawErc721) -> Withd
1204
1204
let my_address = eth_coin. derivation_method . single_addr_or_err ( ) . await ?;
1205
1205
if token_owner != my_address {
1206
1206
return MmError :: err ( WithdrawError :: MyAddressNotNftOwner {
1207
- my_address : eth_addr_to_hex ( & my_address) ,
1208
- token_owner : eth_addr_to_hex ( & token_owner) ,
1207
+ my_address : my_address. display_address ( ) ,
1208
+ token_owner : token_owner. display_address ( ) ,
1209
1209
} ) ;
1210
1210
}
1211
1211
@@ -2296,7 +2296,7 @@ impl MarketCoinOps for EthCoin {
2296
2296
2297
2297
fn my_address ( & self ) -> MmResult < String , MyAddressError > {
2298
2298
match self . derivation_method ( ) {
2299
- DerivationMethod :: SingleAddress ( my_address) => Ok ( display_eth_address ( my_address) ) ,
2299
+ DerivationMethod :: SingleAddress ( my_address) => Ok ( my_address. display_address ( ) ) ,
2300
2300
DerivationMethod :: HDWallet ( _) => MmError :: err ( MyAddressError :: UnexpectedDerivationMethod (
2301
2301
"'my_address' is deprecated for HD wallets" . to_string ( ) ,
2302
2302
) ) ,
@@ -3331,8 +3331,8 @@ impl EthCoin {
3331
3331
spent_by_me,
3332
3332
received_by_me,
3333
3333
total_amount,
3334
- to : vec ! [ display_eth_address ( & call_data. to) ] ,
3335
- from : vec ! [ display_eth_address ( & call_data. from) ] ,
3334
+ to : vec ! [ call_data. to. display_address ( ) ] ,
3335
+ from : vec ! [ call_data. from. display_address ( ) ] ,
3336
3336
coin : self . ticker . clone ( ) ,
3337
3337
fee_details : fee_details. map ( |d| d. into ( ) ) ,
3338
3338
block_height : trace. block_number ,
@@ -3711,8 +3711,8 @@ impl EthCoin {
3711
3711
spent_by_me,
3712
3712
received_by_me,
3713
3713
total_amount,
3714
- to : vec ! [ display_eth_address ( & to_addr) ] ,
3715
- from : vec ! [ display_eth_address ( & from_addr) ] ,
3714
+ to : vec ! [ to_addr. display_address ( ) ] ,
3715
+ from : vec ! [ from_addr. display_address ( ) ] ,
3716
3716
coin : self . ticker . clone ( ) ,
3717
3717
fee_details : fee_details. map ( |d| d. into ( ) ) ,
3718
3718
block_height : block_number. as_u64 ( ) ,
@@ -6625,16 +6625,12 @@ pub fn checksum_address(addr: &str) -> String {
6625
6625
6626
6626
/// `eth_addr_to_hex` converts Address to hex format.
6627
6627
/// Note: the result will be in lowercase.
6628
- pub fn eth_addr_to_hex ( address : & Address ) -> String { format ! ( "{:#02x }" , address) }
6628
+ fn eth_addr_to_hex ( address : & Address ) -> String { format ! ( "{:#x }" , address) }
6629
6629
6630
6630
/// Checks that input is valid mixed-case checksum form address
6631
6631
/// The input must be 0x prefixed hex string
6632
6632
fn is_valid_checksum_addr ( addr : & str ) -> bool { addr == checksum_address ( addr) }
6633
6633
6634
- /// `display_eth_address` converts Address to mixed-case checksum form.
6635
- #[ inline]
6636
- pub fn display_eth_address ( addr : & Address ) -> String { checksum_address ( & eth_addr_to_hex ( addr) ) }
6637
-
6638
6634
fn increase_by_percent_one_gwei ( num : U256 , percent : u64 ) -> U256 {
6639
6635
let one_gwei = U256 :: from ( 10u64 . pow ( 9 ) ) ;
6640
6636
let percent = ( num / U256 :: from ( 100 ) ) * U256 :: from ( percent) ;
@@ -6720,7 +6716,7 @@ pub async fn get_eth_address(
6720
6716
6721
6717
Ok ( MyWalletAddress {
6722
6718
coin : ticker. to_owned ( ) ,
6723
- wallet_address : display_eth_address ( & my_address) ,
6719
+ wallet_address : my_address. display_address ( ) ,
6724
6720
} )
6725
6721
}
6726
6722
@@ -7304,31 +7300,34 @@ impl TakerCoinSwapOpsV2 for EthCoin {
7304
7300
self . refund_taker_payment_with_timelock_impl ( args) . await
7305
7301
}
7306
7302
7307
- /// Eth doesnt have preimages
7303
+ fn skip_taker_payment_spend_preimage ( & self ) -> bool { true }
7304
+
7305
+ /// Eth skips taker_payment_spend_preimage, as it doesnt need it
7308
7306
async fn gen_taker_payment_spend_preimage (
7309
7307
& self ,
7310
- args : & GenTakerPaymentSpendArgs < ' _ , Self > ,
7308
+ _args : & GenTakerPaymentSpendArgs < ' _ , Self > ,
7311
7309
_swap_unique_data : & [ u8 ] ,
7312
7310
) -> GenPreimageResult < Self > {
7313
- Ok ( TxPreimageWithSig {
7314
- preimage : args. taker_tx . clone ( ) ,
7315
- signature : args. taker_tx . signature ( ) ,
7316
- } )
7311
+ MmError :: err ( TxGenError :: Other (
7312
+ "EVM-based coin doesn't have taker_payment_spend_preimage. Report the Bug!" . to_string ( ) ,
7313
+ ) )
7317
7314
}
7318
7315
7319
- /// Eth doesnt have preimages
7316
+ /// Eth skips taker_payment_spend_preimage, as it doesnt need it
7320
7317
async fn validate_taker_payment_spend_preimage (
7321
7318
& self ,
7322
7319
_gen_args : & GenTakerPaymentSpendArgs < ' _ , Self > ,
7323
7320
_preimage : & TxPreimageWithSig < Self > ,
7324
7321
) -> ValidateTakerPaymentSpendPreimageResult {
7325
- Ok ( ( ) )
7322
+ MmError :: err ( ValidateTakerPaymentSpendPreimageError :: InvalidPreimage (
7323
+ "EVM-based coin skips taker_payment_spend_preimage validation. Report the Bug!" . to_string ( ) ,
7324
+ ) )
7326
7325
}
7327
7326
7328
- /// Wrapper for [EthCoin::sign_and_broadcast_taker_payment_spend_impl]
7327
+ /// Eth doesnt have preimages
7329
7328
async fn sign_and_broadcast_taker_payment_spend (
7330
7329
& self ,
7331
- _preimage : & TxPreimageWithSig < Self > ,
7330
+ _preimage : Option < & TxPreimageWithSig < Self > > ,
7332
7331
gen_args : & GenTakerPaymentSpendArgs < ' _ , Self > ,
7333
7332
secret : & [ u8 ] ,
7334
7333
_swap_unique_data : & [ u8 ] ,
0 commit comments