use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::fmt;
use cosmwasm_std::{Coin, CosmosMsg, Empty, HumanAddr};
use cw0::Expiration;
use crate::balance::Balance;
use crate::state::Permissions;
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum HandleMsg<T = Empty>
where
T: Clone + fmt::Debug + PartialEq + JsonSchema,
{
Execute { msgs: Vec<CosmosMsg<T>> },
Freeze {},
UpdateAdmins { admins: Vec<HumanAddr> },
IncreaseAllowance {
spender: HumanAddr,
amount: Coin,
expires: Option<Expiration>,
},
DecreaseAllowance {
spender: HumanAddr,
amount: Coin,
expires: Option<Expiration>,
},
SetPermissions {
spender: HumanAddr,
permissions: Permissions,
},
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg<T = Empty>
where
T: Clone + fmt::Debug + PartialEq + JsonSchema,
{
AdminList {},
Allowance { spender: HumanAddr },
Permissions { spender: HumanAddr },
CanSend {
sender: HumanAddr,
msg: CosmosMsg<T>,
},
AllAllowances {
start_after: Option<HumanAddr>,
limit: Option<u32>,
},
AllPermissions {
start_after: Option<HumanAddr>,
limit: Option<u32>,
},
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct AllAllowancesResponse {
pub allowances: Vec<AllowanceInfo>,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct AllowanceInfo {
pub spender: HumanAddr,
pub balance: Balance,
pub expires: Expiration,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct PermissionsInfo {
pub spender: HumanAddr,
pub permissions: Permissions,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct AllPermissionsResponse {
pub permissions: Vec<PermissionsInfo>,
}