Skip to content

Commit d60f063

Browse files
committed
refactor: Rename EthereumAddress to AddressSqlite
So that it's more descriptive
1 parent a6d9915 commit d60f063

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/sqlite.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,30 @@ use alloy::primitives::{Address, keccak256};
99
use std::str::FromStr;
1010

1111
#[derive(Debug, Clone, Copy)]
12-
struct EthereumAddress(Address);
12+
struct AddressSqlite(Address);
1313

14-
impl ToSql for EthereumAddress {
14+
impl ToSql for AddressSqlite {
1515
fn to_sql(&self) -> Result<ToSqlOutput<'_>> {
1616
Ok(ToSqlOutput::from(self.0.as_slice()))
1717
}
1818
}
1919

20-
// Convenience methods to convert between Address (Alloy) and EthereumAddress (Used for ToSql)
21-
impl From<Address> for EthereumAddress {
20+
impl From<Address> for AddressSqlite {
2221
fn from(addr: Address) -> Self {
23-
EthereumAddress(addr)
22+
AddressSqlite(addr)
2423
}
2524
}
2625

27-
impl From<EthereumAddress> for Address {
28-
fn from(addr: EthereumAddress) -> Self {
26+
impl From<AddressSqlite> for Address {
27+
fn from(addr: AddressSqlite) -> Self {
2928
addr.0
3029
}
3130
}
3231

3332
#[derive(Debug)]
3433
struct Transactions {
3534
id: i32,
36-
sender: EthereumAddress,
35+
sender: AddressSqlite,
3736
transaction_type: TransactionType,
3837
data: Vec<u8>,
3938
timestamp: i64,
@@ -62,8 +61,8 @@ impl ToSql for TransactionType {
6261
#[derive(Debug)]
6362
struct Contracts {
6463
id: i32,
65-
address: EthereumAddress,
66-
signers: Vec<EthereumAddress>,
64+
address: AddressSqlite,
65+
signers: Vec<AddressSqlite>,
6766
transaction_id: i32,
6867
}
6968

@@ -99,7 +98,7 @@ fn initialize_db() -> Result<Connection, DatabaseError> {
9998
// Using a fixed deployer address and init code for this example
10099
// In production, these should be parameters or configured constants
101100
// TODO: Change to sender of bridge address
102-
let deployer = EthereumAddress::from(
101+
let deployer = AddressSqlite::from(
103102
Address::from_str("0x4000000000000000000000000000000000000000").unwrap()
104103
);
105104

@@ -206,7 +205,7 @@ mod tests {
206205
let mut conn = initialize_db().unwrap();
207206
let transaction = Transactions {
208207
id: 0,
209-
sender: EthereumAddress::from(Address::from_str("0x0000000000000000000000000000000000000001").unwrap()),
208+
sender: AddressSqlite::from(Address::from_str("0x0000000000000000000000000000000000000001").unwrap()),
210209
transaction_type: TransactionType::CreateToken,
211210
data: "0x".as_bytes().to_vec(),
212211
timestamp: 1715136000,

0 commit comments

Comments
 (0)