0.7.27 +Refactor
This commit is contained in:
@@ -4,13 +4,13 @@
|
||||
|
||||
/// Application-facing on-chain observation DTO.
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct KbOnchainObservationDto {
|
||||
pub struct OnchainObservationDto {
|
||||
/// Optional numeric primary key.
|
||||
pub id: std::option::Option<i64>,
|
||||
/// Observation kind.
|
||||
pub observation_kind: std::string::String,
|
||||
/// Observation source family.
|
||||
pub source_kind: crate::KbObservationSourceKind,
|
||||
pub source_kind: crate::ObservationSourceKind,
|
||||
/// Optional source endpoint logical name.
|
||||
pub endpoint_name: std::option::Option<std::string::String>,
|
||||
/// Logical object key, for example a mint, signature or pool address.
|
||||
@@ -23,11 +23,11 @@ pub struct KbOnchainObservationDto {
|
||||
pub observed_at: chrono::DateTime<chrono::Utc>,
|
||||
}
|
||||
|
||||
impl KbOnchainObservationDto {
|
||||
impl OnchainObservationDto {
|
||||
/// Creates a new on-chain observation DTO with the current timestamp.
|
||||
pub fn new(
|
||||
observation_kind: std::string::String,
|
||||
source_kind: crate::KbObservationSourceKind,
|
||||
source_kind: crate::ObservationSourceKind,
|
||||
endpoint_name: std::option::Option<std::string::String>,
|
||||
object_key: std::string::String,
|
||||
slot: std::option::Option<u64>,
|
||||
@@ -46,11 +46,11 @@ impl KbOnchainObservationDto {
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<crate::KbOnchainObservationEntity> for KbOnchainObservationDto {
|
||||
type Error = crate::KbError;
|
||||
impl TryFrom<crate::OnchainObservationEntity> for OnchainObservationDto {
|
||||
type Error = crate::Error;
|
||||
|
||||
fn try_from(entity: crate::KbOnchainObservationEntity) -> Result<Self, Self::Error> {
|
||||
let source_kind_result = crate::KbObservationSourceKind::from_i16(entity.source_kind);
|
||||
fn try_from(entity: crate::OnchainObservationEntity) -> Result<Self, Self::Error> {
|
||||
let source_kind_result = crate::ObservationSourceKind::from_i16(entity.source_kind);
|
||||
let source_kind = match source_kind_result {
|
||||
Ok(source_kind) => source_kind,
|
||||
Err(error) => return Err(error),
|
||||
@@ -59,7 +59,7 @@ impl TryFrom<crate::KbOnchainObservationEntity> for KbOnchainObservationDto {
|
||||
let observed_at = match observed_at_result {
|
||||
Ok(observed_at) => observed_at.with_timezone(&chrono::Utc),
|
||||
Err(error) => {
|
||||
return Err(crate::KbError::Db(format!(
|
||||
return Err(crate::Error::Db(format!(
|
||||
"cannot parse on-chain observation observed_at '{}': {}",
|
||||
entity.observed_at, error
|
||||
)));
|
||||
@@ -69,7 +69,7 @@ impl TryFrom<crate::KbOnchainObservationEntity> for KbOnchainObservationDto {
|
||||
let payload = match payload_result {
|
||||
Ok(payload) => payload,
|
||||
Err(error) => {
|
||||
return Err(crate::KbError::Db(format!(
|
||||
return Err(crate::Error::Db(format!(
|
||||
"cannot parse on-chain observation payload_json '{}': {}",
|
||||
entity.payload_json, error
|
||||
)));
|
||||
@@ -81,7 +81,7 @@ impl TryFrom<crate::KbOnchainObservationEntity> for KbOnchainObservationDto {
|
||||
match slot_result {
|
||||
Ok(slot) => Some(slot),
|
||||
Err(error) => {
|
||||
return Err(crate::KbError::Db(format!(
|
||||
return Err(crate::Error::Db(format!(
|
||||
"cannot convert on-chain observation slot '{}' to u64: {}",
|
||||
slot, error
|
||||
)));
|
||||
|
||||
Reference in New Issue
Block a user