Skip to main content

alibi_sqlx/store/entities/
wallet_address.rs

1pub use crate::Number as WalletChainId;
2use crate::SqlxModel;
3use alibi_core::WalletAddress;
4use chrono::{DateTime, Utc};
5#[derive(Clone, Debug, PartialEq, sqlx::FromRow, SqlxModel)]
6#[auth(table = "walletAddress")]
7pub struct Model {
8    pub id: String,
9    #[sqlx(rename = "userId")]
10    pub user_id: String,
11    pub address: String,
12    #[sqlx(rename = "chainId")]
13    pub chain_id: WalletChainId,
14    #[sqlx(rename = "isPrimary")]
15    pub is_primary: bool,
16    #[sqlx(rename = "createdAt")]
17    pub created_at: DateTime<Utc>,
18}
19
20impl From<Model> for WalletAddress {
21    fn from(row: Model) -> Self {
22        Self {
23            id: row.id,
24            user_id: row.user_id,
25            address: row.address,
26            chain_id: row.chain_id.0,
27            is_primary: row.is_primary,
28            created_at: row.created_at,
29        }
30    }
31}