@@ -6,7 +6,7 @@ use alloy::sol;
66use alloy:: transports:: Transport ;
77use anyhow:: { anyhow, Result } ;
88use chrono:: Utc ;
9- use log :: info;
9+ use tracing :: { info, instrument , span , Level } ;
1010use Escrow :: NewIntent ;
1111
1212use crate :: { random_intent_id, retry} ;
@@ -34,6 +34,7 @@ pub struct GasFees {
3434 pub max_priority_fee_per_gas : u128 ,
3535}
3636
37+ #[ instrument( skip_all) ]
3738pub async fn escrow_funds < P , T > (
3839 provider : P ,
3940 escrow_address : Address ,
9091 . await
9192 } ,
9293 3 ,
94+ Some ( span ! ( Level :: INFO , "escrowFunds" ) ) ,
9395 )
9496 . await ?;
9597
@@ -108,12 +110,14 @@ where
108110 . ok_or ( anyhow ! ( "No transaction receipt" ) )
109111 } ,
110112 5 ,
113+ Some ( span ! ( Level :: INFO , "get_transaction_receipt" ) ) ,
111114 )
112115 . await ?;
113116
114117 Ok ( receipt)
115118}
116119
120+ #[ instrument( skip_all) ]
117121pub async fn solve_intent_remote < P , T > (
118122 provider : P ,
119123 escrow_address : Address ,
@@ -139,6 +143,7 @@ where
139143 . await
140144 } ,
141145 3 ,
146+ Some ( span ! ( Level :: INFO , "solveIntentRemote" ) ) ,
142147 )
143148 . await ?;
144149
@@ -157,12 +162,14 @@ where
157162 . ok_or ( anyhow ! ( "No transaction receipt" ) )
158163 } ,
159164 5 ,
165+ Some ( span ! ( Level :: INFO , "get_transaction_receipt" ) ) ,
160166 )
161167 . await ?;
162168
163169 Ok ( receipt)
164170}
165171
172+ #[ instrument( skip_all) ]
166173pub async fn solve_intent_local < P , T > (
167174 provider : P ,
168175 escrow_address : Address ,
@@ -184,6 +191,7 @@ where
184191 . await
185192 } ,
186193 3 ,
194+ Some ( span ! ( Level :: INFO , "solveIntentLocal" ) ) ,
187195 )
188196 . await ?;
189197
@@ -202,12 +210,14 @@ where
202210 . ok_or ( anyhow ! ( "No transaction receipt" ) )
203211 } ,
204212 5 ,
213+ Some ( span ! ( Level :: INFO , "get_transaction_receipt" ) ) ,
205214 )
206215 . await ?;
207216
208217 Ok ( receipt)
209218}
210219
220+ #[ instrument( skip_all) ]
211221pub async fn cancel_intent < P , T > (
212222 provider : P ,
213223 escrow_address : Address ,
@@ -219,7 +229,12 @@ where
219229{
220230 let contract = Escrow :: new ( escrow_address, provider. clone ( ) ) ;
221231
222- let pending = retry ( || async { contract. cancelIntent ( intent_id) . send ( ) . await } , 3 ) . await ?;
232+ let pending = retry (
233+ || async { contract. cancelIntent ( intent_id) . send ( ) . await } ,
234+ 3 ,
235+ Some ( span ! ( Level :: INFO , "cancelIntent" ) ) ,
236+ )
237+ . await ?;
223238
224239 let tx_hash = pending. tx_hash ( ) ;
225240
@@ -236,13 +251,15 @@ where
236251 . ok_or ( anyhow ! ( "No transaction receipt" ) )
237252 } ,
238253 5 ,
254+ Some ( span ! ( Level :: INFO , "get_transaction_receipt" ) ) ,
239255 )
240256 . await ?;
241257
242258 info ! ( "Canceled intent {} on Ethereum" , intent_id) ;
243259 Ok ( receipt)
244260}
245261
262+ #[ instrument( skip_all) ]
246263pub async fn approve_erc20 < P , T > (
247264 provider : P ,
248265 token : Address ,
@@ -258,6 +275,7 @@ where
258275 let pending = retry (
259276 || async { token_contract. approve ( spender, amount) . send ( ) . await } ,
260277 3 ,
278+ Some ( span ! ( Level :: INFO , "approve" ) ) ,
261279 )
262280 . await ?;
263281
@@ -273,12 +291,14 @@ where
273291 . ok_or ( anyhow ! ( "No transaction receipt" ) )
274292 } ,
275293 5 ,
294+ Some ( span ! ( Level :: INFO , "get_transaction_receipt" ) ) ,
276295 )
277296 . await ?;
278297
279298 Ok ( receipt)
280299}
281300
301+ #[ instrument( skip_all) ]
282302pub async fn send_raw_tx < P , T > (
283303 provider : P ,
284304 to : Address ,
@@ -308,7 +328,12 @@ where
308328 ..Default :: default ( )
309329 } ;
310330
311- let pending = retry ( || provider. send_transaction ( transaction. clone ( ) ) , 3 ) . await ?;
331+ let pending = retry (
332+ || provider. send_transaction ( transaction. clone ( ) ) ,
333+ 3 ,
334+ Some ( span ! ( Level :: INFO , "send_transaction" ) ) ,
335+ )
336+ . await ?;
312337 let tx_hash = pending. tx_hash ( ) ;
313338
314339 info ! ( "Ethereum transaction {} was sent to the network" , tx_hash) ;
@@ -321,6 +346,7 @@ where
321346 . ok_or ( anyhow ! ( "No transaction receipt" ) )
322347 } ,
323348 5 ,
349+ Some ( span ! ( Level :: INFO , "get_transaction_receipt" ) ) ,
324350 )
325351 . await ?;
326352
0 commit comments