1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
//! Messages for the perps position token contract.
//!
//! The position token is a proxy providing a CW721 (NFT) interface for all
//! positions within a single market.
pub mod entry;
pub mod events;
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{Addr, Binary, BlockInfo};
use cw_utils::Expiration;
/// copied/adapted from the cw721-base reference
#[cw_serde]
pub struct Approval {
/// Account that can transfer/send the token
pub spender: Addr,
/// When the Approval expires (maybe Expiration::never)
pub expires: Expiration,
}
impl Approval {
/// Is the given approval expired at the given block?
pub fn is_expired(&self, block: &BlockInfo) -> bool {
self.expires.is_expired(block)
}
}
/// copied/adapted from the cw721-base reference
#[cw_serde]
pub struct FullTokenInfo {
/// The owner of the newly minted NFT
pub owner: Addr,
/// Approvals are stored here, as we clear them all upon transfer and cannot accumulate much
pub approvals: Vec<Approval>,
/// metadata, as per spec
pub extension: Metadata,
}
/// NFT standard metadata
#[cw_serde]
#[derive(Default)]
pub struct Metadata {
/// Unused by perps
pub image: Option<String>,
/// Unused by perps
pub image_data: Option<String>,
/// Unused by perps
pub external_url: Option<String>,
/// Unused by perps
pub description: Option<String>,
/// Unused by perps
pub name: Option<String>,
/// Characteristics of the position
pub attributes: Option<Vec<Trait>>,
/// Unused by perps
pub background_color: Option<String>,
/// Unused by perps
pub animation_url: Option<String>,
/// Unused by perps
pub youtube_url: Option<String>,
}
/// NFT-standard traits, used to express information on the position
#[cw_serde]
#[derive(Eq, Default)]
pub struct Trait {
/// Unused by pers
pub display_type: Option<String>,
/// The type of data contained in this trait.
pub trait_type: String,
/// The value for the given trait type.
pub value: String,
}
/// Cw721ReceiveMsg should be de/serialized under `Receive()` variant in a ExecuteMsg
#[cw_serde]
pub struct Cw721ReceiveMsg {
/// Sender of the NFT
pub sender: String,
/// Position ID transferred
pub token_id: String,
/// Binary message for the receiving contract to execute.
pub msg: Binary,
}