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
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, eachrectangle
coordinate must be a multiple of a block side length in the canvas. The block side length can be obtained byblock_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 fromrectangle
).msg::source()
must have enough fungible tokens to buy all free pixels thatrectangle
will occupy. An enough number of tokens can be calculated by multiplying arectangle
area and the price of a free pixel. The area can be calculated by multiplying a width & height fromrectangle
. The price of a free pixel can be obtained bypixel_price()
.
On success, returns NFTPixelboardEvent::Minted
.
Fields
token_metadata: TokenMetadata
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 ofTokenInfo
. msg::source()
must have enough fungible tokens to buy all pixels that an NFT occupies. This can be found out bytoken_info()
. See also the documentation ofTokenInfo
.
On success, returns NFTPixelboardEvent::Bought
.
ChangeSaleState
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 assigningpixel_price
toSome
price will transfer it to a pixelboard program & put it up for sale. - Updating a pixel price
If an NFT is for sale, then assigningpixel_price
toSome
price will update its pixel price. - Removing from sale
Assigning thepixel_price
toNone
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
- An NFT must be minted on a pixelboard.
msg::source()
must be the owner of an NFT.pixel_price
mustn’t be more thanMAX_PIXEL_PRICE
.
On success, returns NFTPixelboardEvent::SaleStateChanged
.
Fields
token_id: TokenId
Paint
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 bytoken_info()
.
On success, returns NFTPixelboardEvent::Painted
.
Trait Implementations§
source§impl Clone for NFTPixelboardAction
impl Clone for NFTPixelboardAction
source§fn clone(&self) -> NFTPixelboardAction
fn clone(&self) -> NFTPixelboardAction
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Decode for NFTPixelboardAction
impl Decode for NFTPixelboardAction
source§fn decode<__CodecInputEdqy: Input>(
__codec_input_edqy: &mut __CodecInputEdqy
) -> Result<Self, Error>
fn decode<__CodecInputEdqy: Input>( __codec_input_edqy: &mut __CodecInputEdqy ) -> Result<Self, Error>
§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>
) -> Result<DecodeFinished, Error>where
I: Input,
§fn skip<I>(input: &mut I) -> Result<(), Error>where
I: Input,
fn skip<I>(input: &mut I) -> Result<(), Error>where
I: Input,
§fn encoded_fixed_size() -> Option<usize>
fn encoded_fixed_size() -> Option<usize>
source§impl Encode for NFTPixelboardAction
impl Encode for NFTPixelboardAction
source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
source§fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy
)
fn encode_to<__CodecOutputEdqy: Output + ?Sized>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy )
§fn using_encoded<R, F>(&self, f: F) -> R
fn using_encoded<R, F>(&self, f: F) -> R
§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
source§impl PartialEq for NFTPixelboardAction
impl PartialEq for NFTPixelboardAction
source§fn eq(&self, other: &NFTPixelboardAction) -> bool
fn eq(&self, other: &NFTPixelboardAction) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl TypeInfo for NFTPixelboardAction
impl TypeInfo for NFTPixelboardAction
impl EncodeLike for NFTPixelboardAction
impl Eq for NFTPixelboardAction
impl StructuralPartialEq for NFTPixelboardAction
Auto Trait Implementations§
impl Freeze for NFTPixelboardAction
impl RefUnwindSafe for NFTPixelboardAction
impl Send for NFTPixelboardAction
impl Sync for NFTPixelboardAction
impl Unpin for NFTPixelboardAction
impl UnwindSafe for NFTPixelboardAction
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> DecodeAll for Twhere
T: Decode,
impl<T> DecodeAll for Twhere
T: Decode,
§fn decode_all(input: &mut &[u8]) -> Result<T, Error>
fn decode_all(input: &mut &[u8]) -> Result<T, Error>
Self
and consume all of the given input data. Read more§impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> DecodeLimit for Twhere
T: Decode,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> KeyedVec for Twhere
T: Codec,
impl<T> KeyedVec for Twhere
T: Codec,
§fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8>
fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8>
Self
prepended by given slice.