@@ -1284,7 +1284,7 @@ impl ProtocolStateRequestResponse {
12841284 }
12851285}
12861286
1287- #[ derive( Clone , PartialEq , Hash , Eq ) ]
1287+ #[ derive( Serialize , Clone , PartialEq , Hash , Eq ) ]
12881288pub struct ProtocolComponentId {
12891289 pub chain : Chain ,
12901290 pub system : String ,
@@ -1322,6 +1322,117 @@ impl ProtocolSystemsRequestResponse {
13221322 }
13231323}
13241324
1325+ #[ derive( Serialize , Deserialize , Debug , Default , PartialEq , ToSchema , Eq , Hash , Clone ) ]
1326+ pub struct TracedEntryPointRequestBody {
1327+ #[ serde( default ) ]
1328+ pub chain : Chain ,
1329+ /// Filters by protocol, required to correctly apply unconfirmed state from
1330+ /// ReorgBuffers
1331+ pub protocol_system : String ,
1332+ /// Filter by component ids
1333+ pub component_ids : Option < Vec < String > > ,
1334+ /// Max page size supported is 100
1335+ #[ serde( default ) ]
1336+ pub pagination : PaginationParams ,
1337+ }
1338+
1339+ #[ derive( Debug , Serialize , Deserialize , PartialEq , Clone , ToSchema , Eq , Hash ) ]
1340+ pub struct EntryPoint {
1341+ #[ schema( example = "0xEdf63cce4bA70cbE74064b7687882E71ebB0e988:getRate()" ) ]
1342+ /// Entry point id.
1343+ pub external_id : String ,
1344+ #[ schema( value_type=String , example="0x8f4E8439b970363648421C692dd897Fb9c0Bd1D9" ) ]
1345+ #[ serde( with = "hex_bytes" ) ]
1346+ /// The address of the contract to trace.
1347+ pub target : Bytes ,
1348+ #[ schema( example = "getRate()" ) ]
1349+ /// The signature of the function to trace.
1350+ pub signature : String ,
1351+ }
1352+
1353+ #[ derive( Debug , Serialize , Deserialize , PartialEq , Clone , ToSchema , Eq , Hash ) ]
1354+ pub struct RPCTracerParams {
1355+ /// The caller address of the transaction, if not provided tracing uses the default value
1356+ /// for an address defined by the VM.
1357+ #[ schema( value_type=Option <String >) ]
1358+ #[ serde( with = "hex_bytes_option" , default ) ]
1359+ pub caller : Option < Bytes > ,
1360+ /// The call data used for the tracing call, this needs to include the function selector
1361+ #[ schema( value_type=String , example="0x679aefce" ) ]
1362+ #[ serde( with = "hex_bytes" ) ]
1363+ pub calldata : Bytes ,
1364+ }
1365+
1366+ impl From < models:: blockchain:: RPCTracerParams > for RPCTracerParams {
1367+ fn from ( value : models:: blockchain:: RPCTracerParams ) -> Self {
1368+ RPCTracerParams { caller : value. caller , calldata : value. calldata }
1369+ }
1370+ }
1371+
1372+ #[ derive( Deserialize , Serialize , Debug , PartialEq , Eq , Clone ) ]
1373+ #[ serde( tag = "method" , rename_all = "lowercase" ) ]
1374+ pub enum TracingParams {
1375+ /// Uses RPC calls to retrieve the called addresses and retriggers
1376+ RPCTracer ( RPCTracerParams ) ,
1377+ }
1378+
1379+ impl From < models:: blockchain:: TracingParams > for TracingParams {
1380+ fn from ( value : models:: blockchain:: TracingParams ) -> Self {
1381+ match value {
1382+ models:: blockchain:: TracingParams :: RPCTracer ( params) => {
1383+ TracingParams :: RPCTracer ( params. into ( ) )
1384+ }
1385+ }
1386+ }
1387+ }
1388+
1389+ impl From < models:: blockchain:: EntryPoint > for EntryPoint {
1390+ fn from ( value : models:: blockchain:: EntryPoint ) -> Self {
1391+ Self { external_id : value. external_id , target : value. target , signature : value. signature }
1392+ }
1393+ }
1394+
1395+ #[ derive( Serialize , Deserialize , Debug , PartialEq , ToSchema , Eq , Clone ) ]
1396+ pub struct EntryPointWithTracingParams {
1397+ /// The entry point object
1398+ pub entry_point : EntryPoint ,
1399+ /// The parameters used
1400+ pub params : TracingParams ,
1401+ }
1402+
1403+ impl From < models:: blockchain:: EntryPointWithTracingParams > for EntryPointWithTracingParams {
1404+ fn from ( value : models:: blockchain:: EntryPointWithTracingParams ) -> Self {
1405+ Self { entry_point : value. entry_point . into ( ) , params : value. params . into ( ) }
1406+ }
1407+ }
1408+
1409+ #[ derive( Serialize , Deserialize , Debug , Default , PartialEq , ToSchema , Eq , Clone ) ]
1410+ pub struct TracingResult {
1411+ #[ schema( value_type=HashSet <( String , String ) >) ]
1412+ pub retriggers : HashSet < ( Bytes , Bytes ) > ,
1413+ #[ schema( value_type=HashSet <String >) ]
1414+ pub called_addresses : HashSet < Bytes > ,
1415+ }
1416+
1417+ impl From < models:: blockchain:: TracingResult > for TracingResult {
1418+ fn from ( value : models:: blockchain:: TracingResult ) -> Self {
1419+ TracingResult { retriggers : value. retriggers , called_addresses : value. called_addresses }
1420+ }
1421+ }
1422+
1423+ #[ derive( Serialize , PartialEq , ToSchema , Eq , Clone ) ]
1424+ pub struct TracedEntryPointRequestResponse {
1425+ /// Map of protocol component id to a list of a tuple containing each entry point with its
1426+ /// tracing parameters and its corresponding tracing results.
1427+ pub traced_entry_points : HashMap < String , Vec < ( EntryPointWithTracingParams , TracingResult ) > > ,
1428+ pub pagination : PaginationResponse ,
1429+ }
1430+
1431+ pub struct AddEntrypointRequestBody {
1432+ pub entrypoints_with_tracing_data : Vec < ( String , Vec < EntryPointWithTracingParams > ) > ,
1433+ pub chain : Chain ,
1434+ }
1435+
13251436#[ cfg( test) ]
13261437mod test {
13271438 use std:: str:: FromStr ;
0 commit comments