Skip to content

Commit 0b0b59e

Browse files
committed
refactor!: rename EIP712SignedMessage to Eip712SignedMessage
Signed-off-by: Gustavo Inacio <[email protected]>
1 parent 3d35cac commit 0b0b59e

File tree

21 files changed

+140
-140
lines changed

21 files changed

+140
-140
lines changed

tap_aggregator/src/aggregator.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ use alloy::{
99
};
1010
use anyhow::{bail, Ok, Result};
1111
use rayon::prelude::*;
12-
use tap_core::signed_message::{EIP712SignedMessage, SignatureBytes, SignatureBytesExt};
12+
use tap_core::signed_message::{Eip712SignedMessage, SignatureBytes, SignatureBytesExt};
1313
use tap_graph::{Receipt, ReceiptAggregateVoucher};
1414

1515
pub fn check_and_aggregate_receipts(
1616
domain_separator: &Eip712Domain,
17-
receipts: &[EIP712SignedMessage<Receipt>],
18-
previous_rav: Option<EIP712SignedMessage<ReceiptAggregateVoucher>>,
17+
receipts: &[Eip712SignedMessage<Receipt>],
18+
previous_rav: Option<Eip712SignedMessage<ReceiptAggregateVoucher>>,
1919
wallet: &PrivateKeySigner,
2020
accepted_addresses: &HashSet<Address>,
21-
) -> Result<EIP712SignedMessage<ReceiptAggregateVoucher>> {
21+
) -> Result<Eip712SignedMessage<ReceiptAggregateVoucher>> {
2222
check_signatures_unique(receipts)?;
2323

2424
// Check that the receipts are signed by an accepted signer address
@@ -63,11 +63,11 @@ pub fn check_and_aggregate_receipts(
6363
let rav = ReceiptAggregateVoucher::aggregate_receipts(allocation_id, receipts, previous_rav)?;
6464

6565
// Sign the rav and return
66-
Ok(EIP712SignedMessage::new(domain_separator, rav, wallet)?)
66+
Ok(Eip712SignedMessage::new(domain_separator, rav, wallet)?)
6767
}
6868

6969
fn check_signature_is_from_one_of_addresses<M: SolStruct>(
70-
message: &EIP712SignedMessage<M>,
70+
message: &Eip712SignedMessage<M>,
7171
domain_separator: &Eip712Domain,
7272
accepted_addresses: &HashSet<Address>,
7373
) -> Result<()> {
@@ -81,7 +81,7 @@ fn check_signature_is_from_one_of_addresses<M: SolStruct>(
8181
}
8282

8383
fn check_allocation_id(
84-
receipts: &[EIP712SignedMessage<Receipt>],
84+
receipts: &[Eip712SignedMessage<Receipt>],
8585
allocation_id: Address,
8686
) -> Result<()> {
8787
for receipt in receipts.iter() {
@@ -93,7 +93,7 @@ fn check_allocation_id(
9393
Ok(())
9494
}
9595

96-
fn check_signatures_unique(receipts: &[EIP712SignedMessage<Receipt>]) -> Result<()> {
96+
fn check_signatures_unique(receipts: &[Eip712SignedMessage<Receipt>]) -> Result<()> {
9797
let mut receipt_signatures: hash_set::HashSet<SignatureBytes> = hash_set::HashSet::new();
9898
for receipt in receipts.iter() {
9999
let signature = receipt.signature.get_signature_bytes();
@@ -109,8 +109,8 @@ fn check_signatures_unique(receipts: &[EIP712SignedMessage<Receipt>]) -> Result<
109109
}
110110

111111
fn check_receipt_timestamps(
112-
receipts: &[EIP712SignedMessage<Receipt>],
113-
previous_rav: Option<&EIP712SignedMessage<ReceiptAggregateVoucher>>,
112+
receipts: &[Eip712SignedMessage<Receipt>],
113+
previous_rav: Option<&Eip712SignedMessage<ReceiptAggregateVoucher>>,
114114
) -> Result<()> {
115115
if let Some(previous_rav) = &previous_rav {
116116
for receipt in receipts.iter() {
@@ -134,7 +134,7 @@ mod tests {
134134

135135
use alloy::{dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner};
136136
use rstest::*;
137-
use tap_core::{signed_message::EIP712SignedMessage, tap_eip712_domain};
137+
use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain};
138138
use tap_graph::{Receipt, ReceiptAggregateVoucher};
139139

140140
use crate::aggregator;
@@ -170,7 +170,7 @@ mod tests {
170170
) {
171171
// Create the same receipt twice (replay attack)
172172
let mut receipts = Vec::new();
173-
let receipt = EIP712SignedMessage::new(
173+
let receipt = Eip712SignedMessage::new(
174174
&domain_separator,
175175
Receipt::new(allocation_ids[0], 42).unwrap(),
176176
&keys.0,
@@ -192,13 +192,13 @@ mod tests {
192192
) {
193193
// Create 2 different receipts
194194
let receipts = vec![
195-
EIP712SignedMessage::new(
195+
Eip712SignedMessage::new(
196196
&domain_separator,
197197
Receipt::new(allocation_ids[0], 42).unwrap(),
198198
&keys.0,
199199
)
200200
.unwrap(),
201-
EIP712SignedMessage::new(
201+
Eip712SignedMessage::new(
202202
&domain_separator,
203203
Receipt::new(allocation_ids[0], 43).unwrap(),
204204
&keys.0,
@@ -223,7 +223,7 @@ mod tests {
223223
let mut receipts = Vec::new();
224224
for i in receipt_timestamp_range.clone() {
225225
receipts.push(
226-
EIP712SignedMessage::new(
226+
Eip712SignedMessage::new(
227227
&domain_separator,
228228
Receipt {
229229
allocation_id: allocation_ids[0],
@@ -238,7 +238,7 @@ mod tests {
238238
}
239239

240240
// Create rav with max_timestamp below the receipts timestamps
241-
let rav = EIP712SignedMessage::new(
241+
let rav = Eip712SignedMessage::new(
242242
&domain_separator,
243243
ReceiptAggregateVoucher {
244244
allocationId: allocation_ids[0],
@@ -252,7 +252,7 @@ mod tests {
252252

253253
// Create rav with max_timestamp equal to the lowest receipt timestamp
254254
// Aggregation should fail
255-
let rav = EIP712SignedMessage::new(
255+
let rav = Eip712SignedMessage::new(
256256
&domain_separator,
257257
ReceiptAggregateVoucher {
258258
allocationId: allocation_ids[0],
@@ -266,7 +266,7 @@ mod tests {
266266

267267
// Create rav with max_timestamp above highest receipt timestamp
268268
// Aggregation should fail
269-
let rav = EIP712SignedMessage::new(
269+
let rav = Eip712SignedMessage::new(
270270
&domain_separator,
271271
ReceiptAggregateVoucher {
272272
allocationId: allocation_ids[0],
@@ -289,19 +289,19 @@ mod tests {
289289
domain_separator: Eip712Domain,
290290
) {
291291
let receipts = vec![
292-
EIP712SignedMessage::new(
292+
Eip712SignedMessage::new(
293293
&domain_separator,
294294
Receipt::new(allocation_ids[0], 42).unwrap(),
295295
&keys.0,
296296
)
297297
.unwrap(),
298-
EIP712SignedMessage::new(
298+
Eip712SignedMessage::new(
299299
&domain_separator,
300300
Receipt::new(allocation_ids[0], 43).unwrap(),
301301
&keys.0,
302302
)
303303
.unwrap(),
304-
EIP712SignedMessage::new(
304+
Eip712SignedMessage::new(
305305
&domain_separator,
306306
Receipt::new(allocation_ids[1], 44).unwrap(),
307307
&keys.0,
@@ -323,19 +323,19 @@ mod tests {
323323
domain_separator: Eip712Domain,
324324
) {
325325
let receipts = vec![
326-
EIP712SignedMessage::new(
326+
Eip712SignedMessage::new(
327327
&domain_separator,
328328
Receipt::new(allocation_ids[0], 42).unwrap(),
329329
&keys.0,
330330
)
331331
.unwrap(),
332-
EIP712SignedMessage::new(
332+
Eip712SignedMessage::new(
333333
&domain_separator,
334334
Receipt::new(allocation_ids[0], 43).unwrap(),
335335
&keys.0,
336336
)
337337
.unwrap(),
338-
EIP712SignedMessage::new(
338+
Eip712SignedMessage::new(
339339
&domain_separator,
340340
Receipt::new(allocation_ids[0], 44).unwrap(),
341341
&keys.0,

tap_aggregator/src/grpc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
use anyhow::anyhow;
5-
use tap_core::signed_message::EIP712SignedMessage;
5+
use tap_core::signed_message::Eip712SignedMessage;
66

77
tonic::include_proto!("tap_aggregator.v1");
88

@@ -51,7 +51,7 @@ impl From<tap_graph::SignedReceipt> for SignedReceipt {
5151
}
5252
}
5353

54-
impl TryFrom<SignedRav> for EIP712SignedMessage<tap_graph::ReceiptAggregateVoucher> {
54+
impl TryFrom<SignedRav> for Eip712SignedMessage<tap_graph::ReceiptAggregateVoucher> {
5555
type Error = anyhow::Error;
5656
fn try_from(voucher: SignedRav) -> Result<Self, Self::Error> {
5757
Ok(Self {
@@ -64,8 +64,8 @@ impl TryFrom<SignedRav> for EIP712SignedMessage<tap_graph::ReceiptAggregateVouch
6464
}
6565
}
6666

67-
impl From<EIP712SignedMessage<tap_graph::ReceiptAggregateVoucher>> for SignedRav {
68-
fn from(voucher: EIP712SignedMessage<tap_graph::ReceiptAggregateVoucher>) -> Self {
67+
impl From<Eip712SignedMessage<tap_graph::ReceiptAggregateVoucher>> for SignedRav {
68+
fn from(voucher: Eip712SignedMessage<tap_graph::ReceiptAggregateVoucher>) -> Self {
6969
Self {
7070
signature: voucher.signature.as_bytes().to_vec(),
7171
message: Some(voucher.message.into()),

tap_aggregator/src/server.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use jsonrpsee::{
1414
use lazy_static::lazy_static;
1515
use log::info;
1616
use prometheus::{register_counter, register_int_counter, Counter, IntCounter};
17-
use tap_core::signed_message::EIP712SignedMessage;
17+
use tap_core::signed_message::Eip712SignedMessage;
1818
use tap_graph::{Receipt, ReceiptAggregateVoucher, SignedReceipt};
1919
use tokio::{net::TcpListener, signal, task::JoinHandle};
2020
use tonic::{codec::CompressionEncoding, service::Routes, Request, Response, Status};
@@ -87,9 +87,9 @@ pub trait Rpc {
8787
fn aggregate_receipts(
8888
&self,
8989
api_version: String,
90-
receipts: Vec<EIP712SignedMessage<Receipt>>,
91-
previous_rav: Option<EIP712SignedMessage<ReceiptAggregateVoucher>>,
92-
) -> JsonRpcResult<EIP712SignedMessage<ReceiptAggregateVoucher>>;
90+
receipts: Vec<Eip712SignedMessage<Receipt>>,
91+
previous_rav: Option<Eip712SignedMessage<ReceiptAggregateVoucher>>,
92+
) -> JsonRpcResult<Eip712SignedMessage<ReceiptAggregateVoucher>>;
9393
}
9494

9595
#[derive(Clone)]
@@ -134,9 +134,9 @@ fn aggregate_receipts_(
134134
wallet: &PrivateKeySigner,
135135
accepted_addresses: &HashSet<Address>,
136136
domain_separator: &Eip712Domain,
137-
receipts: Vec<EIP712SignedMessage<Receipt>>,
138-
previous_rav: Option<EIP712SignedMessage<ReceiptAggregateVoucher>>,
139-
) -> JsonRpcResult<EIP712SignedMessage<ReceiptAggregateVoucher>> {
137+
receipts: Vec<Eip712SignedMessage<Receipt>>,
138+
previous_rav: Option<Eip712SignedMessage<ReceiptAggregateVoucher>>,
139+
) -> JsonRpcResult<Eip712SignedMessage<ReceiptAggregateVoucher>> {
140140
// Return an error if the API version is not supported.
141141
let api_version = match parse_api_version(api_version.as_str()) {
142142
Ok(v) => v,
@@ -230,9 +230,9 @@ impl RpcServer for RpcImpl {
230230
fn aggregate_receipts(
231231
&self,
232232
api_version: String,
233-
receipts: Vec<EIP712SignedMessage<Receipt>>,
234-
previous_rav: Option<EIP712SignedMessage<ReceiptAggregateVoucher>>,
235-
) -> JsonRpcResult<EIP712SignedMessage<ReceiptAggregateVoucher>> {
233+
receipts: Vec<Eip712SignedMessage<Receipt>>,
234+
previous_rav: Option<Eip712SignedMessage<ReceiptAggregateVoucher>>,
235+
) -> JsonRpcResult<Eip712SignedMessage<ReceiptAggregateVoucher>> {
236236
// Values for Prometheus metrics
237237
let receipts_grt: u128 = receipts.iter().map(|r| r.message.value).sum();
238238
let receipts_count: u64 = receipts.len() as u64;
@@ -391,7 +391,7 @@ mod tests {
391391
use jsonrpsee::{core::client::ClientT, http_client::HttpClientBuilder, rpc_params};
392392
use rand::{prelude::*, seq::SliceRandom};
393393
use rstest::*;
394-
use tap_core::{signed_message::EIP712SignedMessage, tap_eip712_domain};
394+
use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain};
395395
use tap_graph::{Receipt, ReceiptAggregateVoucher};
396396

397397
use crate::server;
@@ -520,7 +520,7 @@ mod tests {
520520
let mut receipts = Vec::new();
521521
for value in values {
522522
receipts.push(
523-
EIP712SignedMessage::new(
523+
Eip712SignedMessage::new(
524524
&domain_separator,
525525
Receipt::new(allocation_ids[0], value).unwrap(),
526526
&all_wallets.choose(&mut rng).unwrap().wallet,
@@ -531,7 +531,7 @@ mod tests {
531531

532532
// Skipping receipts validation in this test, aggregate_receipts assumes receipts are valid.
533533
// Create RAV through the JSON-RPC server.
534-
let res: server::JsonRpcResponse<EIP712SignedMessage<ReceiptAggregateVoucher>> = client
534+
let res: server::JsonRpcResponse<Eip712SignedMessage<ReceiptAggregateVoucher>> = client
535535
.request(
536536
"aggregate_receipts",
537537
rpc_params!(api_version, &receipts, None::<()>),
@@ -600,7 +600,7 @@ mod tests {
600600
let mut receipts = Vec::new();
601601
for value in values {
602602
receipts.push(
603-
EIP712SignedMessage::new(
603+
Eip712SignedMessage::new(
604604
&domain_separator,
605605
Receipt::new(allocation_ids[0], value).unwrap(),
606606
&all_wallets.choose(&mut rng).unwrap().wallet,
@@ -616,15 +616,15 @@ mod tests {
616616
None,
617617
)
618618
.unwrap();
619-
let signed_prev_rav = EIP712SignedMessage::new(
619+
let signed_prev_rav = Eip712SignedMessage::new(
620620
&domain_separator,
621621
prev_rav,
622622
&all_wallets.choose(&mut rng).unwrap().wallet,
623623
)
624624
.unwrap();
625625

626626
// Create new RAV from last half of receipts and prev_rav through the JSON-RPC server
627-
let res: server::JsonRpcResponse<EIP712SignedMessage<ReceiptAggregateVoucher>> = client
627+
let res: server::JsonRpcResponse<Eip712SignedMessage<ReceiptAggregateVoucher>> = client
628628
.request(
629629
"aggregate_receipts",
630630
rpc_params!(
@@ -674,7 +674,7 @@ mod tests {
674674
.unwrap();
675675

676676
// Create receipts
677-
let receipts = vec![EIP712SignedMessage::new(
677+
let receipts = vec![Eip712SignedMessage::new(
678678
&domain_separator,
679679
Receipt::new(allocation_ids[0], 42).unwrap(),
680680
&keys_main.wallet,
@@ -684,7 +684,7 @@ mod tests {
684684
// Skipping receipts validation in this test, aggregate_receipts assumes receipts are valid.
685685
// Create RAV through the JSON-RPC server.
686686
let res: Result<
687-
server::JsonRpcResponse<EIP712SignedMessage<ReceiptAggregateVoucher>>,
687+
server::JsonRpcResponse<Eip712SignedMessage<ReceiptAggregateVoucher>>,
688688
jsonrpsee::core::ClientError,
689689
> = client
690690
.request(
@@ -768,7 +768,7 @@ mod tests {
768768
let mut receipts = Vec::new();
769769
for _ in 1..number_of_receipts_to_exceed_limit {
770770
receipts.push(
771-
EIP712SignedMessage::new(
771+
Eip712SignedMessage::new(
772772
&domain_separator,
773773
Receipt::new(allocation_ids[0], u128::MAX / 1000).unwrap(),
774774
&keys_main.wallet,
@@ -781,7 +781,7 @@ mod tests {
781781
// Create RAV through the JSON-RPC server.
782782
// Test with a number of receipts that stays within request size limit
783783
let res: Result<
784-
server::JsonRpcResponse<EIP712SignedMessage<ReceiptAggregateVoucher>>,
784+
server::JsonRpcResponse<Eip712SignedMessage<ReceiptAggregateVoucher>>,
785785
jsonrpsee::core::ClientError,
786786
> = client
787787
.request(
@@ -798,7 +798,7 @@ mod tests {
798798
// Create RAV through the JSON-RPC server.
799799
// Test with all receipts to exceed request size limit
800800
let res: Result<
801-
server::JsonRpcResponse<EIP712SignedMessage<ReceiptAggregateVoucher>>,
801+
server::JsonRpcResponse<Eip712SignedMessage<ReceiptAggregateVoucher>>,
802802
jsonrpsee::core::ClientError,
803803
> = client
804804
.request(

tap_aggregator/tests/aggregate_test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use tap_aggregator::{
1010
jsonrpsee_helpers::JsonRpcResponse,
1111
server,
1212
};
13-
use tap_core::{signed_message::EIP712SignedMessage, tap_eip712_domain};
13+
use tap_core::{signed_message::Eip712SignedMessage, tap_eip712_domain};
1414
use tap_graph::{Receipt, ReceiptAggregateVoucher};
1515
use tonic::codec::CompressionEncoding;
1616

@@ -51,7 +51,7 @@ async fn aggregation_test() {
5151
let mut receipts = Vec::new();
5252
for value in 50..60 {
5353
receipts.push(
54-
EIP712SignedMessage::new(
54+
Eip712SignedMessage::new(
5555
&domain_separator,
5656
Receipt::new(allocation_id, value).unwrap(),
5757
&wallet,
@@ -68,7 +68,7 @@ async fn aggregation_test() {
6868

6969
let previous_rav: Option<tap_graph::SignedRav> = None;
7070

71-
let response: JsonRpcResponse<EIP712SignedMessage<ReceiptAggregateVoucher>> = sender_aggregator
71+
let response: JsonRpcResponse<Eip712SignedMessage<ReceiptAggregateVoucher>> = sender_aggregator
7272
.request(
7373
"aggregate_receipts",
7474
rpc_params!(

0 commit comments

Comments
 (0)