Skip to content

Commit 265f7f3

Browse files
committed
remove redundant Get from response types
1 parent 249f1af commit 265f7f3

File tree

3 files changed

+51
-53
lines changed

3 files changed

+51
-53
lines changed

verifiable-api/bin/handlers.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub async fn get_account<N: NetworkSpec, R: ExecutionRpc<N>>(
121121
block,
122122
}): Query<AccountProofQuery>,
123123
State(ApiState { execution_client }): State<ApiState<N, R>>,
124-
) -> Response<GetAccountResponse> {
124+
) -> Response<AccountResponse> {
125125
// Ensure that BlockId is of block number variant
126126
let block = block.unwrap_or(BlockId::latest());
127127
let block_num = match block {
@@ -161,7 +161,7 @@ pub async fn get_account<N: NetworkSpec, R: ExecutionRpc<N>>(
161161
.await
162162
.map_err(map_server_err)?;
163163

164-
Ok(Json(GetAccountResponse {
164+
Ok(Json(AccountResponse {
165165
account: Account {
166166
balance: proof.balance,
167167
nonce: proof.nonce,
@@ -183,7 +183,7 @@ pub async fn get_storage_at<N: NetworkSpec, R: ExecutionRpc<N>>(
183183
Path((address, key)): Path<(Address, U256)>,
184184
Query(BlockQuery { block }): Query<BlockQuery>,
185185
State(ApiState { execution_client }): State<ApiState<N, R>>,
186-
) -> Response<GetStorageAtResponse> {
186+
) -> Response<StorageAtResponse> {
187187
let block = block.unwrap_or(BlockId::latest());
188188

189189
let storage_slot = execution_client
@@ -208,7 +208,7 @@ pub async fn get_storage_at<N: NetworkSpec, R: ExecutionRpc<N>>(
208208
}
209209
};
210210

211-
Ok(Json(GetStorageAtResponse {
211+
Ok(Json(StorageAtResponse {
212212
storage,
213213
account: Account {
214214
balance: proof.balance,
@@ -226,7 +226,7 @@ pub async fn get_storage_at<N: NetworkSpec, R: ExecutionRpc<N>>(
226226
pub async fn get_block_receipts<N: NetworkSpec, R: ExecutionRpc<N>>(
227227
Path(block): Path<BlockId>,
228228
State(ApiState { execution_client }): State<ApiState<N, R>>,
229-
) -> Response<GetBlockReceiptsResponse<N>> {
229+
) -> Response<BlockReceiptsResponse<N>> {
230230
let receipts = execution_client
231231
.rpc
232232
.get_block_receipts(block)
@@ -243,7 +243,7 @@ pub async fn get_block_receipts<N: NetworkSpec, R: ExecutionRpc<N>>(
243243
pub async fn get_transaction_receipt<N: NetworkSpec, R: ExecutionRpc<N>>(
244244
Path(tx_hash): Path<B256>,
245245
State(ApiState { execution_client }): State<ApiState<N, R>>,
246-
) -> Response<GetTransactionReceiptResponse<N>> {
246+
) -> Response<TransactionReceiptResponse<N>> {
247247
let receipt = execution_client
248248
.rpc
249249
.get_transaction_receipt(tx_hash)
@@ -271,7 +271,7 @@ pub async fn get_transaction_receipt<N: NetworkSpec, R: ExecutionRpc<N>>(
271271
let receipt_proof =
272272
create_receipt_proof::<N>(receipts, receipt.transaction_index().unwrap() as usize);
273273

274-
Ok(Json(GetTransactionReceiptResponse {
274+
Ok(Json(TransactionReceiptResponse {
275275
receipt,
276276
receipt_proof,
277277
}))
@@ -284,7 +284,7 @@ pub async fn get_transaction_receipt<N: NetworkSpec, R: ExecutionRpc<N>>(
284284
pub async fn get_logs<N: NetworkSpec, R: ExecutionRpc<N>>(
285285
Query(logs_filter_query): Query<LogsQuery>,
286286
State(ApiState { execution_client }): State<ApiState<N, R>>,
287-
) -> Response<GetLogsResponse<N>> {
287+
) -> Response<LogsResponse<N>> {
288288
let filter: Filter = logs_filter_query.try_into().map_err(map_server_err)?;
289289

290290
// Fetch the filter logs from RPC
@@ -299,7 +299,7 @@ pub async fn get_logs<N: NetworkSpec, R: ExecutionRpc<N>>(
299299
.await
300300
.map_err(map_server_err)?;
301301

302-
Ok(Json(GetLogsResponse {
302+
Ok(Json(LogsResponse {
303303
logs,
304304
receipt_proofs,
305305
}))
@@ -312,7 +312,7 @@ pub async fn get_logs<N: NetworkSpec, R: ExecutionRpc<N>>(
312312
pub async fn get_filter_logs<N: NetworkSpec, R: ExecutionRpc<N>>(
313313
Path(filter_id): Path<U256>,
314314
State(ApiState { execution_client }): State<ApiState<N, R>>,
315-
) -> Response<GetFilterLogsResponse<N>> {
315+
) -> Response<FilterLogsResponse<N>> {
316316
// Fetch the filter logs from RPC
317317
let logs = execution_client
318318
.rpc
@@ -325,7 +325,7 @@ pub async fn get_filter_logs<N: NetworkSpec, R: ExecutionRpc<N>>(
325325
.await
326326
.map_err(map_server_err)?;
327327

328-
Ok(Json(GetFilterLogsResponse {
328+
Ok(Json(FilterLogsResponse {
329329
logs,
330330
receipt_proofs,
331331
}))
@@ -339,7 +339,7 @@ pub async fn get_filter_logs<N: NetworkSpec, R: ExecutionRpc<N>>(
339339
pub async fn get_filter_changes<N: NetworkSpec, R: ExecutionRpc<N>>(
340340
Path(filter_id): Path<U256>,
341341
State(ApiState { execution_client }): State<ApiState<N, R>>,
342-
) -> Response<GetFilterChangesResponse<N>> {
342+
) -> Response<FilterChangesResponse<N>> {
343343
let filter_changes = execution_client
344344
.rpc
345345
.get_filter_changes(filter_id)
@@ -353,14 +353,14 @@ pub async fn get_filter_changes<N: NetworkSpec, R: ExecutionRpc<N>>(
353353
.await
354354
.map_err(map_server_err)?;
355355

356-
GetFilterChangesResponse::Logs(GetFilterLogsResponse {
356+
FilterChangesResponse::Logs(FilterLogsResponse {
357357
logs,
358358
receipt_proofs,
359359
})
360360
}
361-
FilterChanges::Hashes(hashes) => GetFilterChangesResponse::Hashes(hashes),
362-
FilterChanges::Empty => GetFilterChangesResponse::Hashes(vec![]),
363-
FilterChanges::Transactions(txs) => GetFilterChangesResponse::Hashes(
361+
FilterChanges::Hashes(hashes) => FilterChangesResponse::Hashes(hashes),
362+
FilterChanges::Empty => FilterChangesResponse::Hashes(vec![]),
363+
FilterChanges::Transactions(txs) => FilterChangesResponse::Hashes(
364364
txs.into_iter().map(|t| t.inner.tx_hash().clone()).collect(),
365365
),
366366
}))
@@ -369,7 +369,7 @@ pub async fn get_filter_changes<N: NetworkSpec, R: ExecutionRpc<N>>(
369369
async fn create_receipt_proofs_for_logs<N: NetworkSpec, R: ExecutionRpc<N>>(
370370
logs: &[Log],
371371
execution_client: Arc<ExecutionClient<N, R>>,
372-
) -> Result<HashMap<B256, GetTransactionReceiptResponse<N>>> {
372+
) -> Result<HashMap<B256, TransactionReceiptResponse<N>>> {
373373
// Collect all (unique) block numbers
374374
let block_nums = logs
375375
.iter()
@@ -391,7 +391,7 @@ async fn create_receipt_proofs_for_logs<N: NetworkSpec, R: ExecutionRpc<N>>(
391391
let blocks_receipts = blocks_receipts.into_iter().collect::<HashMap<_, _>>();
392392

393393
// Create a map of transaction hashes to their receipt and proof
394-
let mut receipt_proofs: HashMap<B256, GetTransactionReceiptResponse<N>> = HashMap::new();
394+
let mut receipt_proofs: HashMap<B256, TransactionReceiptResponse<N>> = HashMap::new();
395395

396396
for log in logs {
397397
let tx_hash = log.transaction_hash.unwrap();
@@ -412,7 +412,7 @@ async fn create_receipt_proofs_for_logs<N: NetworkSpec, R: ExecutionRpc<N>>(
412412

413413
receipt_proofs.insert(
414414
tx_hash,
415-
GetTransactionReceiptResponse {
415+
TransactionReceiptResponse {
416416
receipt: receipt.clone(),
417417
receipt_proof,
418418
},

verifiable-api/src/api_client.rs

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,19 @@ pub trait VerifiableApi<N: NetworkSpec> {
1818
address: Address,
1919
storage_keys: Vec<B256>,
2020
block: Option<BlockId>,
21-
) -> Result<GetAccountResponse>;
21+
) -> Result<AccountResponse>;
2222
async fn get_storage_at(
2323
&self,
2424
address: Address,
2525
key: U256,
2626
block: Option<BlockId>,
27-
) -> Result<GetStorageAtResponse>;
28-
async fn get_block_receipts(&self, block: BlockId) -> Result<GetBlockReceiptsResponse<N>>;
29-
async fn get_transaction_receipt(
30-
&self,
31-
tx_hash: B256,
32-
) -> Result<GetTransactionReceiptResponse<N>>;
33-
async fn get_logs(&self, filter: Filter) -> Result<GetLogsResponse<N>>;
34-
async fn get_filter_logs(&self, filter_id: U256) -> Result<GetFilterLogsResponse<N>>;
35-
async fn get_filter_changes(&self, filter_id: U256) -> Result<GetFilterChangesResponse<N>>;
27+
) -> Result<StorageAtResponse>;
28+
async fn get_block_receipts(&self, block: BlockId) -> Result<BlockReceiptsResponse<N>>;
29+
async fn get_transaction_receipt(&self, tx_hash: B256)
30+
-> Result<TransactionReceiptResponse<N>>;
31+
async fn get_logs(&self, filter: Filter) -> Result<LogsResponse<N>>;
32+
async fn get_filter_logs(&self, filter_id: U256) -> Result<FilterLogsResponse<N>>;
33+
async fn get_filter_changes(&self, filter_id: U256) -> Result<FilterChangesResponse<N>>;
3634
}
3735

3836
pub struct VerifiableApiClient {
@@ -56,7 +54,7 @@ impl<N: NetworkSpec> VerifiableApi<N> for VerifiableApiClient {
5654
address: Address,
5755
storage_keys: Vec<B256>,
5856
block: Option<BlockId>,
59-
) -> Result<GetAccountResponse> {
57+
) -> Result<AccountResponse> {
6058
let url = format!("{}/eth/v1/proof/account/{}", self.base_url, address);
6159
let response = self
6260
.client
@@ -65,7 +63,7 @@ impl<N: NetworkSpec> VerifiableApi<N> for VerifiableApiClient {
6563
.query(&[("storageKeys", &storage_keys)])
6664
.send()
6765
.await?;
68-
let response = response.json::<GetAccountResponse>().await?;
66+
let response = response.json::<AccountResponse>().await?;
6967
Ok(response)
7068
}
7169

@@ -74,36 +72,36 @@ impl<N: NetworkSpec> VerifiableApi<N> for VerifiableApiClient {
7472
address: Address,
7573
key: U256,
7674
block: Option<BlockId>,
77-
) -> Result<GetStorageAtResponse> {
75+
) -> Result<StorageAtResponse> {
7876
let url = format!("{}/eth/v1/proof/storage/{}/{}", self.base_url, address, key);
7977
let response = self
8078
.client
8179
.get(&url)
8280
.query(&[("block", block)])
8381
.send()
8482
.await?;
85-
let response = response.json::<GetStorageAtResponse>().await?;
83+
let response = response.json::<StorageAtResponse>().await?;
8684
Ok(response)
8785
}
8886

89-
async fn get_block_receipts(&self, block: BlockId) -> Result<GetBlockReceiptsResponse<N>> {
87+
async fn get_block_receipts(&self, block: BlockId) -> Result<BlockReceiptsResponse<N>> {
9088
let url = format!("{}/eth/v1/proof/block_receipts/{}", self.base_url, block);
9189
let response = self.client.get(&url).send().await?;
92-
let response = response.json::<GetBlockReceiptsResponse<N>>().await?;
90+
let response = response.json::<BlockReceiptsResponse<N>>().await?;
9391
Ok(response)
9492
}
9593

9694
async fn get_transaction_receipt(
9795
&self,
9896
tx_hash: B256,
99-
) -> Result<GetTransactionReceiptResponse<N>> {
97+
) -> Result<TransactionReceiptResponse<N>> {
10098
let url = format!("{}/eth/v1/proof/tx_receipt/{}", self.base_url, tx_hash);
10199
let response = self.client.get(&url).send().await?;
102-
let response = response.json::<GetTransactionReceiptResponse<N>>().await?;
100+
let response = response.json::<TransactionReceiptResponse<N>>().await?;
103101
Ok(response)
104102
}
105103

106-
async fn get_logs(&self, filter: Filter) -> Result<GetLogsResponse<N>> {
104+
async fn get_logs(&self, filter: Filter) -> Result<LogsResponse<N>> {
107105
let url = format!("{}/eth/v1/proof/logs", self.base_url);
108106

109107
let mut request = self.client.get(&url);
@@ -129,24 +127,24 @@ impl<N: NetworkSpec> VerifiableApi<N> for VerifiableApiClient {
129127
}
130128

131129
let response = request.send().await?;
132-
let response = response.json::<GetLogsResponse<N>>().await?;
130+
let response = response.json::<LogsResponse<N>>().await?;
133131
Ok(response)
134132
}
135133

136-
async fn get_filter_logs(&self, filter_id: U256) -> Result<GetFilterLogsResponse<N>> {
134+
async fn get_filter_logs(&self, filter_id: U256) -> Result<FilterLogsResponse<N>> {
137135
let url = format!("{}/eth/v1/proof/filter_logs/{}", self.base_url, filter_id);
138136
let response = self.client.get(&url).send().await?;
139-
let response = response.json::<GetFilterLogsResponse<N>>().await?;
137+
let response = response.json::<FilterLogsResponse<N>>().await?;
140138
Ok(response)
141139
}
142140

143-
async fn get_filter_changes(&self, filter_id: U256) -> Result<GetFilterChangesResponse<N>> {
141+
async fn get_filter_changes(&self, filter_id: U256) -> Result<FilterChangesResponse<N>> {
144142
let url = format!(
145143
"{}/eth/v1/proof/filter_changes/{}",
146144
self.base_url, filter_id
147145
);
148146
let response = self.client.get(&url).send().await?;
149-
let response = response.json::<GetFilterChangesResponse<N>>().await?;
147+
let response = response.json::<FilterChangesResponse<N>>().await?;
150148
Ok(response)
151149
}
152150
}

verifiable-api/src/types.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use helios_core::{execution::types::Account, network_spec::NetworkSpec};
1111

1212
#[derive(Serialize, Deserialize)]
1313
#[serde(rename_all = "camelCase")]
14-
pub struct GetAccountResponse {
14+
pub struct AccountResponse {
1515
pub account: TrieAccount,
1616
pub code: Bytes,
1717
pub account_proof: Vec<Bytes>,
@@ -20,46 +20,46 @@ pub struct GetAccountResponse {
2020

2121
#[derive(Serialize, Deserialize)]
2222
#[serde(rename_all = "camelCase")]
23-
pub struct GetStorageAtResponse {
23+
pub struct StorageAtResponse {
2424
pub storage: EIP1186StorageProof,
2525
pub account: TrieAccount,
2626
pub account_proof: Vec<Bytes>,
2727
}
2828

2929
#[allow(type_alias_bounds)]
30-
pub type GetBlockReceiptsResponse<N: NetworkSpec> = Vec<N::ReceiptResponse>;
30+
pub type BlockReceiptsResponse<N: NetworkSpec> = Vec<N::ReceiptResponse>;
3131

3232
#[derive(Serialize, Deserialize)]
3333
#[serde(rename_all = "camelCase")]
34-
pub struct GetTransactionReceiptResponse<N: NetworkSpec> {
34+
pub struct TransactionReceiptResponse<N: NetworkSpec> {
3535
pub receipt: N::ReceiptResponse,
3636
pub receipt_proof: Vec<Bytes>,
3737
}
3838

3939
#[derive(Serialize, Deserialize)]
4040
#[serde(rename_all = "camelCase")]
4141
#[serde(bound = "N: NetworkSpec")]
42-
pub struct GetLogsResponse<N: NetworkSpec> {
42+
pub struct LogsResponse<N: NetworkSpec> {
4343
pub logs: Vec<Log>,
44-
pub receipt_proofs: HashMap<B256, GetTransactionReceiptResponse<N>>, // tx_hash -> receipt & proof
44+
pub receipt_proofs: HashMap<B256, TransactionReceiptResponse<N>>, // tx_hash -> receipt & proof
4545
}
4646

4747
#[derive(Serialize, Deserialize)]
4848
#[serde(rename_all = "camelCase")]
4949
#[serde(bound = "N: NetworkSpec")]
50-
pub struct GetFilterLogsResponse<N: NetworkSpec> {
50+
pub struct FilterLogsResponse<N: NetworkSpec> {
5151
pub logs: Vec<Log>,
52-
pub receipt_proofs: HashMap<B256, GetTransactionReceiptResponse<N>>, // tx_hash -> receipt & proof
52+
pub receipt_proofs: HashMap<B256, TransactionReceiptResponse<N>>, // tx_hash -> receipt & proof
5353
}
5454

5555
#[derive(Serialize, Deserialize)]
5656
#[serde(rename_all = "camelCase")]
5757
#[serde(bound = "N: NetworkSpec")]
5858
#[serde(untagged)]
5959

60-
pub enum GetFilterChangesResponse<N: NetworkSpec> {
60+
pub enum FilterChangesResponse<N: NetworkSpec> {
6161
Hashes(Vec<B256>),
62-
Logs(GetFilterLogsResponse<N>),
62+
Logs(FilterLogsResponse<N>),
6363
}
6464

6565
#[derive(Serialize, Deserialize)]

0 commit comments

Comments
 (0)