#![allow(clippy::field_reassign_with_default)]
use cosmwasm_std::{Binary, Coin, Decimal, HumanAddr};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ProvenanceRoute {
Attribute,
Marker,
Name,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct Names {
pub records: Vec<Name>,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct Name {
pub name: String,
pub address: HumanAddr,
pub restricted: bool,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct Attributes {
pub address: HumanAddr,
#[serde(default)]
pub attributes: Vec<Attribute>,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum AttributeValueType {
Uuid,
Json,
String,
Bytes,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct Attribute {
pub name: String,
pub value: Binary,
#[serde(rename(serialize = "type", deserialize = "type"))]
pub value_type: AttributeValueType,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct Marker {
pub address: HumanAddr,
#[serde(default)]
pub coins: Vec<Coin>,
pub account_number: u64,
pub sequence: u64,
#[serde(default)]
pub manager: HumanAddr,
#[serde(default)]
pub permissions: Vec<AccessGrant>,
pub status: MarkerStatus,
pub denom: String,
pub total_supply: Decimal,
pub marker_type: MarkerType,
pub supply_fixed: bool,
}
impl Marker {
pub fn bank_sends_disabled(&self) -> bool {
matches!(self.marker_type, MarkerType::Restricted)
}
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct AccessGrant {
pub permissions: Vec<MarkerAccess>,
pub address: HumanAddr,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum MarkerAccess {
Admin,
Burn,
Deposit,
Delete,
Mint,
Transfer,
Unspecified,
Withdraw,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum MarkerType {
Coin,
Restricted,
Unspecified,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum MarkerStatus {
Active,
Cancelled,
Destroyed,
Finalized,
Proposed,
Unspecified,
}