use crate::types::{
plugin::{
Plugin, PluginCodeData, PluginMetadataData, PluginWithVersionResponse, PluginsResponse,
},
plugin_registry::{RegistryConfigResponse, Subscriber, SubscriptionTier, TierDetails},
};
use cosmwasm_std::{Coin, Response, StdError, StdResult};
use cw2::ContractVersion;
use sylvia::types::{ExecCtx, QueryCtx};
use sylvia::{interface, schemars};
pub mod registry_service_trait {
use super::*;
#[interface]
pub trait RegistryServiceTrait {
type Error: From<StdError>;
#[msg(exec)]
fn proxy_install_plugin(
&self,
ctx: ExecCtx,
id: u64,
addr: String,
) -> Result<Response, Self::Error>;
#[msg(exec)]
fn proxy_remove_plugins(
&self,
ctx: ExecCtx,
addr: Vec<String>,
) -> Result<Response, Self::Error>;
#[msg(exec)]
fn subscribe(&self, ctx: ExecCtx, tier: SubscriptionTier) -> Result<Response, Self::Error>;
#[msg(query)]
fn subsciption_details(
&self,
ctx: QueryCtx,
addr: String,
) -> Result<Option<Subscriber>, StdError>;
}
}
pub mod registry_management_trait {
use super::*;
#[interface]
pub trait RegistryManagementTrait {
type Error: From<StdError>;
#[msg(exec)]
fn register_plugin(
&self,
ctx: ExecCtx,
code_data: PluginCodeData,
metadata_data: PluginMetadataData,
) -> Result<Response, Self::Error>;
#[msg(exec)]
fn unregister_plugin(&self, ctx: ExecCtx, id: u64) -> Result<Response, Self::Error>;
#[msg(exec)]
fn new_plugin_version(
&self,
ctx: ExecCtx,
id: u64,
code_update: Option<PluginCodeData>,
metadata_update: PluginMetadataData,
) -> Result<Response, Self::Error>;
#[msg(exec)]
fn update_registry_fee(&self, ctx: ExecCtx, new_fee: Coin)
-> Result<Response, Self::Error>;
#[msg(exec)]
fn add_or_update_subscription_tiers(
&self,
ctx: ExecCtx,
tier: u8,
details: TierDetails,
) -> Result<Response, Self::Error>;
#[msg(query)]
fn get_plugins(
&self,
ctx: QueryCtx,
limit: Option<u32>,
start_after: Option<u32>,
) -> StdResult<PluginsResponse>;
#[msg(query)]
fn get_plugin_by_id(&self, ctx: QueryCtx, id: u64) -> StdResult<Option<Plugin>>;
#[msg(query)]
fn get_plugin_by_address(
&self,
ctx: QueryCtx,
contract_addr: String,
) -> StdResult<PluginWithVersionResponse>;
#[msg(query)]
fn get_config(&self, ctx: QueryCtx) -> StdResult<RegistryConfigResponse>;
#[msg(query)]
fn contract_version(&self, ctx: QueryCtx) -> Result<ContractVersion, StdError>;
}
}