@@ -4,68 +4,86 @@ use ethers::types::{
4
4
} ;
5
5
use serde:: { Deserialize , Serialize } ;
6
6
7
- use crate :: { beacon_client:: types:: BlobData , utils:: web3:: calculate_versioned_hash} ;
7
+ use crate :: { beacon_client:: types:: Blob as BeaconBlob , utils:: web3:: calculate_versioned_hash} ;
8
8
9
9
#[ derive( Serialize , Deserialize , Debug ) ]
10
- pub struct BlockEntity {
10
+ pub struct Block {
11
11
pub number : U64 ,
12
12
pub hash : H256 ,
13
13
pub timestamp : U256 ,
14
14
pub slot : u32 ,
15
15
}
16
16
17
17
#[ derive( Serialize , Deserialize , Debug ) ]
18
- pub struct TransactionEntity {
18
+ #[ serde( rename_all = "camelCase" ) ]
19
+ pub struct Transaction {
19
20
pub hash : H256 ,
20
21
pub from : Address ,
21
- pub to : Address ,
22
- # [ serde ( rename = "blockNumber" ) ]
22
+ # [ serde ( default , skip_serializing_if = "Option::is_none" ) ]
23
+ pub to : Option < Address > ,
23
24
pub block_number : U64 ,
24
25
}
25
26
26
27
#[ derive( Serialize , Deserialize , Debug ) ]
27
- pub struct BlobEntity {
28
- # [ serde ( rename = "versionedHash" ) ]
28
+ # [ serde ( rename_all = "camelCase" ) ]
29
+ pub struct Blob {
29
30
pub versioned_hash : H256 ,
30
31
pub commitment : String ,
31
32
pub data : Bytes ,
32
- #[ serde( rename = "txHash" ) ]
33
33
pub tx_hash : H256 ,
34
34
pub index : u32 ,
35
35
}
36
36
37
37
#[ derive( Serialize , Deserialize , Debug ) ]
38
- pub struct SlotResponse {
39
- pub slot : u32 ,
38
+ #[ serde( rename_all = "camelCase" ) ]
39
+ pub struct FailedSlotsChunk {
40
+ #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
41
+ pub id : Option < u32 > ,
42
+ pub initial_slot : u32 ,
43
+ pub final_slot : u32 ,
40
44
}
41
45
42
- #[ derive( Serialize , Deserialize , Debug ) ]
46
+ #[ derive( Serialize , Debug ) ]
43
47
pub struct SlotRequest {
44
48
pub slot : u32 ,
45
49
}
50
+ #[ derive( Deserialize , Debug ) ]
51
+ pub struct SlotResponse {
52
+ pub slot : u32 ,
53
+ }
46
54
47
- #[ derive( Serialize , Deserialize , Debug ) ]
55
+ #[ derive( Serialize , Debug ) ]
48
56
pub struct IndexRequest {
49
- pub block : BlockEntity ,
50
- pub transactions : Vec < TransactionEntity > ,
51
- pub blobs : Vec < BlobEntity > ,
57
+ pub block : Block ,
58
+ pub transactions : Vec < Transaction > ,
59
+ pub blobs : Vec < Blob > ,
52
60
}
53
61
54
62
#[ derive( Debug , thiserror:: Error ) ]
55
63
pub enum BlobscanClientError {
56
64
#[ error( transparent) ]
57
65
Reqwest ( #[ from] reqwest:: Error ) ,
58
66
59
- #[ error( "Blobscan client error: {0}" ) ]
60
- BlobscanClientError ( String ) ,
67
+ #[ error( "API usage error: {0}" ) ]
68
+ ApiError ( String ) ,
61
69
62
70
#[ error( transparent) ]
63
- JWTError ( #[ from] anyhow:: Error ) ,
71
+ Other ( #[ from] anyhow:: Error ) ,
64
72
}
65
73
66
74
pub type BlobscanClientResult < T > = Result < T , BlobscanClientError > ;
67
75
68
- impl < ' a > TryFrom < ( & ' a EthersBlock < EthersTransaction > , u32 ) > for BlockEntity {
76
+ impl From < ( u32 , u32 ) > for FailedSlotsChunk {
77
+ fn from ( ( initial_slot, final_slot) : ( u32 , u32 ) ) -> Self {
78
+ Self {
79
+ id : None ,
80
+ initial_slot,
81
+ final_slot,
82
+ }
83
+ }
84
+ }
85
+
86
+ impl < ' a > TryFrom < ( & ' a EthersBlock < EthersTransaction > , u32 ) > for Block {
69
87
type Error = anyhow:: Error ;
70
88
71
89
fn try_from (
@@ -86,9 +104,7 @@ impl<'a> TryFrom<(&'a EthersBlock<EthersTransaction>, u32)> for BlockEntity {
86
104
}
87
105
}
88
106
89
- impl < ' a > TryFrom < ( & ' a EthersTransaction , & ' a EthersBlock < EthersTransaction > ) >
90
- for TransactionEntity
91
- {
107
+ impl < ' a > TryFrom < ( & ' a EthersTransaction , & ' a EthersBlock < EthersTransaction > ) > for Transaction {
92
108
type Error = anyhow:: Error ;
93
109
94
110
fn try_from (
@@ -102,18 +118,16 @@ impl<'a> TryFrom<(&'a EthersTransaction, &'a EthersBlock<EthersTransaction>)>
102
118
. with_context ( || "Missing block number field in execution block" . to_string ( ) ) ?,
103
119
hash,
104
120
from : ethers_tx. from ,
105
- to : ethers_tx
106
- . to
107
- . with_context ( || format ! ( "Missing to field in transaction {hash}" ) ) ?,
121
+ to : ethers_tx. to ,
108
122
} )
109
123
}
110
124
}
111
125
112
- impl < ' a > TryFrom < ( & ' a BlobData , u32 , H256 ) > for BlobEntity {
126
+ impl < ' a > TryFrom < ( & ' a BeaconBlob , u32 , H256 ) > for Blob {
113
127
type Error = anyhow:: Error ;
114
128
115
129
fn try_from (
116
- ( blob_data, index, tx_hash) : ( & ' a BlobData , u32 , H256 ) ,
130
+ ( blob_data, index, tx_hash) : ( & ' a BeaconBlob , u32 , H256 ) ,
117
131
) -> Result < Self , Self :: Error > {
118
132
Ok ( Self {
119
133
tx_hash,
@@ -125,9 +139,9 @@ impl<'a> TryFrom<(&'a BlobData, u32, H256)> for BlobEntity {
125
139
}
126
140
}
127
141
128
- impl < ' a > From < ( & ' a BlobData , & ' a H256 , usize , & ' a H256 ) > for BlobEntity {
142
+ impl < ' a > From < ( & ' a BeaconBlob , & ' a H256 , usize , & ' a H256 ) > for Blob {
129
143
fn from (
130
- ( blob_data, versioned_hash, index, tx_hash) : ( & ' a BlobData , & ' a H256 , usize , & ' a H256 ) ,
144
+ ( blob_data, versioned_hash, index, tx_hash) : ( & ' a BeaconBlob , & ' a H256 , usize , & ' a H256 ) ,
131
145
) -> Self {
132
146
Self {
133
147
tx_hash : * tx_hash,
0 commit comments