Skip to content

Commit 4e475b8

Browse files
committed
Include AddressType in AddressName
Import AddressType into AddressName and add an optional address_type field (serialized as "type") so address names can carry their address type. Update AddressType enum to derive PartialEq, Eq and Hash and add a new Contact variant. Persist the new field by populating address_type in ScanAddressRow conversion.
1 parent 50b576e commit 4e475b8

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use serde::{Deserialize, Serialize};
22
use typeshare::typeshare;
33

4-
use crate::Chain;
4+
use crate::{scan::AddressType, Chain};
55

66
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
77
#[typeshare(swift = "Equatable, Hashable, Sendable")]
@@ -10,4 +10,6 @@ pub struct AddressName {
1010
pub chain: Chain,
1111
pub address: String,
1212
pub name: String,
13+
#[serde(rename = "type")]
14+
pub address_type: Option<AddressType>,
1315
}

crates/primitives/src/scan.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ pub struct ScanAddressTarget {
3131
pub address: String,
3232
}
3333

34-
#[derive(Debug, Clone, Serialize, Deserialize, EnumIter, AsRefStr, EnumString)]
34+
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, EnumIter, AsRefStr, EnumString)]
3535
#[typeshare(swift = "Equatable, Sendable")]
3636
#[serde(rename_all = "lowercase")]
3737
#[strum(serialize_all = "lowercase")]
3838
pub enum AddressType {
3939
Address,
4040
Contract,
4141
Validator,
42+
Contact,
4243
}
4344

4445
impl AddressType {

crates/storage/src/models/scan_addresses.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ impl ScanAddressRow {
2828
chain: Chain::from_str(&self.chain).unwrap(),
2929
address: self.address,
3030
name,
31+
address_type: Some(self.type_.0.clone()),
3132
})
3233
}
3334

0 commit comments

Comments
 (0)