88#![ allow( unused_imports) ]
99
1010use alloy_primitives:: Address ;
11- use alloy_sol_types:: { sol , SolCall } ;
11+ use alloy_sol_types:: { SolCall , sol } ;
1212use chrono:: { TimeZone , Utc } ;
1313use visualsign:: { SignablePayloadField , SignablePayloadFieldCommon , SignablePayloadFieldTextV2 } ;
1414
@@ -108,11 +108,7 @@ impl Permit2Visualizer {
108108
109109 let text = format ! (
110110 "Approve {} {} {} to spend {} (expires: {})" ,
111- call. spender,
112- amount_str,
113- token_symbol,
114- token_symbol,
115- expiration_str
111+ call. spender, amount_str, token_symbol, token_symbol, expiration_str
116112 ) ;
117113
118114 SignablePayloadField :: TextV2 {
@@ -136,29 +132,40 @@ impl Permit2Visualizer {
136132 . unwrap_or_else ( || format ! ( "{:?}" , token) ) ;
137133
138134 // Format amount with proper decimals
139- let amount_u128: u128 = call. permitSingle . details . amount . to_string ( ) . parse ( ) . unwrap_or ( 0 ) ;
135+ let amount_u128: u128 = call
136+ . permitSingle
137+ . details
138+ . amount
139+ . to_string ( )
140+ . parse ( )
141+ . unwrap_or ( 0 ) ;
140142 let ( amount_str, _) = registry
141143 . and_then ( |r| r. format_token_amount ( chain_id, token, amount_u128) )
142- . unwrap_or_else ( || ( call. permitSingle . details . amount . to_string ( ) , token_symbol. clone ( ) ) ) ;
144+ . unwrap_or_else ( || {
145+ (
146+ call. permitSingle . details . amount . to_string ( ) ,
147+ token_symbol. clone ( ) ,
148+ )
149+ } ) ;
143150
144151 // Format expiration timestamp
145- let expiration_u64: u64 = call. permitSingle . details . expiration . to_string ( ) . parse ( ) . unwrap_or ( 0 ) ;
152+ let expiration_u64: u64 = call
153+ . permitSingle
154+ . details
155+ . expiration
156+ . to_string ( )
157+ . parse ( )
158+ . unwrap_or ( 0 ) ;
146159 let expiration_str = if expiration_u64 == u64:: MAX {
147160 "never" . to_string ( )
148161 } else {
149- let dt = Utc
150- . timestamp_opt ( expiration_u64 as i64 , 0 )
151- . unwrap ( ) ;
162+ let dt = Utc . timestamp_opt ( expiration_u64 as i64 , 0 ) . unwrap ( ) ;
152163 dt. format ( "%Y-%m-%d %H:%M UTC" ) . to_string ( )
153164 } ;
154165
155166 let text = format ! (
156167 "Permit {} to spend {} {} from {} (expires: {})" ,
157- call. permitSingle. spender,
158- amount_str,
159- token_symbol,
160- call. owner,
161- expiration_str
168+ call. permitSingle. spender, amount_str, token_symbol, call. owner, expiration_str
162169 ) ;
163170
164171 SignablePayloadField :: TextV2 {
@@ -214,7 +221,10 @@ mod tests {
214221 #[ test]
215222 fn test_visualize_too_short ( ) {
216223 let visualizer = Permit2Visualizer ;
217- assert_eq ! ( visualizer. visualize_tx_commands( & [ 0x01 , 0x02 ] , 1 , None ) , None ) ;
224+ assert_eq ! (
225+ visualizer. visualize_tx_commands( & [ 0x01 , 0x02 ] , 1 , None ) ,
226+ None
227+ ) ;
218228 }
219229
220230 // TODO: Add tests for Permit2 functions once implemented
@@ -247,7 +257,8 @@ impl crate::visualizer::ContractVisualizer for Permit2ContractVisualizer {
247257 fn visualize (
248258 & self ,
249259 context : & crate :: context:: VisualizerContext ,
250- ) -> Result < Option < Vec < visualsign:: AnnotatedPayloadField > > , visualsign:: vsptrait:: VisualSignError > {
260+ ) -> Result < Option < Vec < visualsign:: AnnotatedPayloadField > > , visualsign:: vsptrait:: VisualSignError >
261+ {
251262 let contract_registry = crate :: registry:: ContractRegistry :: with_default_protocols ( ) ;
252263
253264 if let Some ( field) = self . inner . visualize_tx_commands (
0 commit comments