0.7.27 +Refactor
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
/// Application-facing normalized pool token DTO.
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct KbPoolTokenDto {
|
||||
pub struct PoolTokenDto {
|
||||
/// Optional numeric primary key.
|
||||
pub id: std::option::Option<i64>,
|
||||
/// Related pool id.
|
||||
@@ -12,7 +12,7 @@ pub struct KbPoolTokenDto {
|
||||
/// Related token id.
|
||||
pub token_id: i64,
|
||||
/// Token role.
|
||||
pub role: crate::KbPoolTokenRole,
|
||||
pub role: crate::PoolTokenRole,
|
||||
/// Optional vault address.
|
||||
pub vault_address: std::option::Option<std::string::String>,
|
||||
/// Optional token order inside the pool.
|
||||
@@ -23,12 +23,12 @@ pub struct KbPoolTokenDto {
|
||||
pub updated_at: chrono::DateTime<chrono::Utc>,
|
||||
}
|
||||
|
||||
impl KbPoolTokenDto {
|
||||
impl PoolTokenDto {
|
||||
/// Creates a new pool token DTO.
|
||||
pub fn new(
|
||||
pool_id: i64,
|
||||
token_id: i64,
|
||||
role: crate::KbPoolTokenRole,
|
||||
role: crate::PoolTokenRole,
|
||||
vault_address: std::option::Option<std::string::String>,
|
||||
token_order: std::option::Option<i64>,
|
||||
) -> Self {
|
||||
@@ -46,11 +46,11 @@ impl KbPoolTokenDto {
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<crate::KbPoolTokenEntity> for KbPoolTokenDto {
|
||||
type Error = crate::KbError;
|
||||
impl TryFrom<crate::PoolTokenEntity> for PoolTokenDto {
|
||||
type Error = crate::Error;
|
||||
|
||||
fn try_from(entity: crate::KbPoolTokenEntity) -> Result<Self, Self::Error> {
|
||||
let role_result = crate::KbPoolTokenRole::from_i16(entity.role);
|
||||
fn try_from(entity: crate::PoolTokenEntity) -> Result<Self, Self::Error> {
|
||||
let role_result = crate::PoolTokenRole::from_i16(entity.role);
|
||||
let role = match role_result {
|
||||
Ok(role) => role,
|
||||
Err(error) => return Err(error),
|
||||
@@ -59,7 +59,7 @@ impl TryFrom<crate::KbPoolTokenEntity> for KbPoolTokenDto {
|
||||
let created_at = match created_at_result {
|
||||
Ok(created_at) => created_at.with_timezone(&chrono::Utc),
|
||||
Err(error) => {
|
||||
return Err(crate::KbError::Db(format!(
|
||||
return Err(crate::Error::Db(format!(
|
||||
"cannot parse pool_token created_at '{}': {}",
|
||||
entity.created_at, error
|
||||
)));
|
||||
@@ -69,7 +69,7 @@ impl TryFrom<crate::KbPoolTokenEntity> for KbPoolTokenDto {
|
||||
let updated_at = match updated_at_result {
|
||||
Ok(updated_at) => updated_at.with_timezone(&chrono::Utc),
|
||||
Err(error) => {
|
||||
return Err(crate::KbError::Db(format!(
|
||||
return Err(crate::Error::Db(format!(
|
||||
"cannot parse pool_token updated_at '{}': {}",
|
||||
entity.updated_at, error
|
||||
)));
|
||||
|
||||
Reference in New Issue
Block a user