@@ -39,7 +39,6 @@ mod sol {
39
39
///
40
40
/// * `token` - Address of the ERC-20 token.
41
41
#[ derive( Debug ) ]
42
- #[ allow( missing_docs) ]
43
42
error SafeErc20FailedOperation ( address token) ;
44
43
45
44
/// Indicates a failed [`ISafeErc20::safe_decrease_allowance`] request.
@@ -48,7 +47,6 @@ mod sol {
48
47
/// * `current_allowance` - Current allowance of the `spender`.
49
48
/// * `requested_decrease` - Requested decrease in allowance for `spender`.
50
49
#[ derive( Debug ) ]
51
- #[ allow( missing_docs) ]
52
50
error SafeErc20FailedDecreaseAllowance (
53
51
address spender,
54
52
uint256 current_allowance,
@@ -350,7 +348,6 @@ pub trait ISafeErc20 {
350
348
) -> Result < ( ) , Self :: Error > ;
351
349
}
352
350
353
- #[ public]
354
351
impl ISafeErc20 for SafeErc20 {
355
352
type Error = Error ;
356
353
@@ -480,7 +477,8 @@ impl ISafeErc20 for SafeErc20 {
480
477
if Self :: account_has_code ( to) == 0 {
481
478
self . safe_transfer_from ( token, from, to, value)
482
479
} else {
483
- let call = IErc1363 :: transferFromAndCallCall { from, to, value, data : data. into ( ) } ;
480
+ let data_bytes = data. into ( ) ;
481
+ let call = IErc1363 :: transferFromAndCallCall { from, to, value, data : data_bytes } ;
484
482
if !Self :: call_optional_return_bool ( & token, & call) ? {
485
483
return Err ( Error :: SafeErc20FailedOperation ( SafeErc20FailedOperation { token } ) ) ;
486
484
}
@@ -510,9 +508,9 @@ impl ISafeErc20 for SafeErc20 {
510
508
511
509
impl SafeErc20 {
512
510
#[ inline]
513
- fn account_has_code ( addr : Address ) -> usize {
514
- // SAFETY: extcodesize is a pure query, no state mutation or re-entrancy
515
- unsafe { stylus_sdk :: prelude :: extcodesize ( addr) }
511
+ fn account_has_code ( addr : Address ) -> bool {
512
+ // returns true if `addr` has contract code
513
+ addr. has_code ( )
516
514
}
517
515
518
516
fn call_optional_return (
@@ -558,7 +556,7 @@ impl SafeErc20 {
558
556
559
557
let return_data = match result {
560
558
Ok ( bytes) => bytes,
561
- Err ( _) => return Ok ( false ) , // keep “ soft” failure but make it explicit
559
+ Err ( _) => return Ok ( false ) , // keep " soft" failure but make it explicit
562
560
} ;
563
561
564
562
Ok ( Self :: encodes_true ( & return_data) )
0 commit comments