use af_sui_types::Address;
use af_utilities::types::IFixed;
use sui_framework_sdk::object::{ID, UID};
use sui_framework_sdk::{Field, FieldTypeTag};
pub mod errors;
pub mod event_ext;
pub mod event_instance;
#[cfg(feature = "graphql")]
pub mod graphql;
pub use self::oracle::{PriceFeed, PriceFeedStorage, PriceFeedStorageTypeTag, PriceFeedTypeTag};
pub type PriceFeedDf = Field<keys::PriceFeedForSource, PriceFeed>;
af_sui_pkg_sdk::sui_pkg_sdk!(af_oracle {
module oracle {
struct AuthorityCap has key, store {
id: UID,
}
struct PriceFeedStorage has key, store {
id: UID,
symbol: String,
decimals: u64,
source_wrapper_ids: vector<ID>,
}
struct PriceFeed has key, store {
id: UID,
price: IFixed,
timestamp: u64,
time_tolerance: u64,
}
struct SourceCap has store {}
}
module keys {
struct PriceFeedForSource has copy, drop, store {
source_wrapper_id: ID,
}
struct Authorization has copy, drop, store {}
}
module events {
struct CreatedPriceFeedStorage has copy, drop {
price_feed_storage_id: ID,
symbol: String,
decimals: u64
}
struct AddedAuthorization has copy, drop {
source_wrapper_id: ID,
}
struct RemovedAuthorization has copy, drop {
source_wrapper_id: ID,
}
struct CreatedPriceFeed has copy, drop {
price_feed_storage_id: ID,
source_wrapper_id: ID,
price: IFixed,
timestamp: u64,
time_tolerance: u64,
}
struct RemovedPriceFeed has copy, drop {
price_feed_storage_id: ID,
source_wrapper_id: ID,
}
struct UpdatedPriceFeed has copy, drop {
price_feed_storage_id: ID,
source_wrapper_id: ID,
old_price: IFixed,
old_timestamp: u64,
new_price: IFixed,
new_timestamp: u64,
}
struct UpdatedPriceFeedTimeTolerance has copy, drop {
price_feed_storage_id: ID,
source_wrapper_id: ID,
old_time_tolerance: u64,
new_time_tolerance: u64,
}
}
});
impl PriceFeedStorage {
pub fn price_feed_df_type(
package: Address,
) -> FieldTypeTag<self::keys::PriceFeedForSource, PriceFeed> {
Field::type_(
self::keys::PriceFeedForSource::type_(package),
PriceFeed::type_(package),
)
}
}