pub enum NFTPixelboardAction {
    Mint {
        rectangle: Rectangle,
        token_metadata: TokenMetadata,
        painting: Vec<Color>,
    },
    Buy(TokenId),
    ChangeSaleState {
        token_id: TokenId,
        pixel_price: Option<u128>,
    },
    Paint {
        token_id: TokenId,
        painting: Vec<Color>,
    },
}
Expand description

Sends a program info about what it should do.

Variants§

§

Mint

Fields

§rectangle: Rectangle
§token_metadata: TokenMetadata
§painting: Vec<Color>

A painting that’ll be displayed in a place of an NFT on a pixelboard after a successful minting.

Mints one NFT on a pixelboard with given token_metadata & painting.

Transfers a minted NFT to msg::source().

§Requirements

  • rectangle coordinates mustn’t be out of a canvas.
  • rectangle coordinates mustn’t be mixed up or belong to wrong corners.
  • rectangle coordinates must observe a block layout. In other words, each rectangle coordinate must be a multiple of a block side length in the canvas. The block side length can be obtained by block_side_length().
  • NFT rectangle mustn’t collide with already minted one.
  • painting length must equal a pixel count in an NFT (which can be calculated by multiplying a width & height from rectangle).
  • msg::source() must have enough fungible tokens to buy all free pixels that rectangle will occupy. An enough number of tokens can be calculated by multiplying a rectangle area and the price of a free pixel. The area can be calculated by multiplying a width & height from rectangle. The price of a free pixel can be obtained by pixel_price().

On success, returns NFTPixelboardEvent::Minted.

§

Buy(TokenId)

Buys an NFT minted on a pixelboard.

Transfers a purchased NFT from a pixelboard program to msg::source().

Note: If msg::source() has enough fungible tokens to pay a resale commission but not the entire NFT, then the commission will still be withdrawn from its account.

§Requirements

  • An NFT must be minted on a pixelboard.
  • An NFT must be for sale. This can be found out by token_info(). See also the documentation of TokenInfo.
  • msg::source() must have enough fungible tokens to buy all pixels that an NFT occupies. This can be found out by token_info(). See also the documentation of TokenInfo.

On success, returns NFTPixelboardEvent::Bought.

§

ChangeSaleState

Fields

§token_id: TokenId
§pixel_price: Option<u128>

A price of each pixel that an NFT occupies. To calculate a price of the entire NFT, see the documentation of TokenInfo.

Changes a sale state of an NFT minted on a pixelboard.

There are 3 options of a sale state change:

  • Putting up for sale
    If an NFT is not for sale, then assigning pixel_price to Some price will transfer it to a pixelboard program & put it up for sale.
  • Updating a pixel price
    If an NFT is for sale, then assigning pixel_price to Some price will update its pixel price.
  • Removing from sale
    Assigning the pixel_price to None will transfer an NFT back to its owner & remove an NFT from sale.

Note: A commission is included in each NFT resale, so a seller will receive not all fungible tokens but tokens with a commission deduction. A commission percentage can be obtained by commission_percentage().

§Requirements

On success, returns NFTPixelboardEvent::SaleStateChanged.

§

Paint

Fields

§token_id: TokenId
§painting: Vec<Color>

Paints with painting an NFT minted on a pixelboard.

§Requirements

  • An NFT must be minted on a pixelboard.
  • msg::source() must be the owner of an NFT.
  • painting length must equal a pixel count in an NFT. The count can be calculated by multiplying a width & height from a rectangle of the NFT. The NFT rectangle can be obtained by token_info().

On success, returns NFTPixelboardEvent::Painted.

Trait Implementations§

source§

impl Clone for NFTPixelboardAction

source§

fn clone(&self) -> NFTPixelboardAction

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Decode for NFTPixelboardAction

source§

fn decode<__CodecInputEdqy: Input>( __codec_input_edqy: &mut __CodecInputEdqy ) -> Result<Self, Error>

Attempt to deserialise the value from input.
§

fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self> ) -> Result<DecodeFinished, Error>
where I: Input,

Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
source§

impl Encode for NFTPixelboardAction

source§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
source§

fn encode_to<__CodecOutputEdqy: Output + ?Sized>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy )

Convert self to a slice and append it to the destination.
§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
source§

impl PartialEq for NFTPixelboardAction

source§

fn eq(&self, other: &NFTPixelboardAction) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TypeInfo for NFTPixelboardAction

§

type Identity = NFTPixelboardAction

The type identifying for which type info is provided. Read more
source§

fn type_info() -> Type

Returns the static type identifier for Self.
source§

impl EncodeLike for NFTPixelboardAction

source§

impl Eq for NFTPixelboardAction

source§

impl StructuralPartialEq for NFTPixelboardAction

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> DecodeAll for T
where T: Decode,

§

fn decode_all(input: &mut &[u8]) -> Result<T, Error>

Decode Self and consume all of the given input data. Read more
§

impl<T> DecodeLimit for T
where T: Decode,

§

fn decode_all_with_depth_limit( limit: u32, input: &mut &[u8] ) -> Result<T, Error>

Decode Self and consume all of the given input data. Read more
§

fn decode_with_depth_limit<I>(limit: u32, input: &mut I) -> Result<T, Error>
where I: Input,

Decode Self with the given maximum recursion depth and advance input by the number of bytes consumed. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> KeyedVec for T
where T: Codec,

§

fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8>

Return an encoding of Self prepended by given slice.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Type for T
where T: TypeInfo + 'static,

§

fn is_unit() -> bool

Return true if type is unit.
§

fn meta_type() -> MetaType

Create [MetaType] information about type.
§

fn register(registry: &mut Registry) -> Option<u32>

Register type in the registry and return its identifier if it is not the unit type.
§

impl<S> Codec for S
where S: Decode + Encode,

§

impl<T> EncodeLike<&&T> for T
where T: Encode,

§

impl<T> EncodeLike<&T> for T
where T: Encode,

§

impl<T> EncodeLike<&mut T> for T
where T: Encode,

§

impl<T> EncodeLike<Arc<T>> for T
where T: Encode,

§

impl<T> EncodeLike<Box<T>> for T
where T: Encode,

§

impl<'a, T> EncodeLike<Cow<'a, T>> for T
where T: ToOwned + Encode,

§

impl<T> EncodeLike<Rc<T>> for T
where T: Encode,

§

impl<S> FullCodec for S
where S: Decode + FullEncode,

§

impl<S> FullEncode for S
where S: Encode + EncodeLike,

§

impl<T> JsonSchemaMaybe for T

§

impl<T> StaticTypeInfo for T
where T: TypeInfo + 'static,