Enum game_of_chance_io::Action
source · pub enum Action {
Start {
duration: u64,
participation_cost: u128,
fungible_token: Option<ActorId>,
},
PickWinner,
Enter,
}Expand description
Sends the contract info about what it should do.
Variants§
Start
Fields
Starts a game round and allows to participate in it.
Requirements
msg::source()must be the game administrator.- The current game round must be over.
ft_actor_idmustn’t be [ActorId::zero()].
On success, replies with Event::Started.
PickWinner
Randomly picks a winner from current game round participants (players) and sends a prize fund to it.
The randomness of a winner pick depends on
exec::block_timestamp().
Not the best source of entropy, but, in theory, it’s impossible to
exactly predict a winner if the time of an execution of this action is
unknown.
If no one participated in the round, then a winner will be
[ActorId::zero()].
Requirements
msg::source()must be the game administrator.- The players entry stage must be over.
- A winner mustn’t already be picked.
On success, replies with Event::Winner.
Enter
Pays a participation cost and adds msg::source() to the current game
round participants (players).
A participation cost and its currency can be queried from the contract state.
Requirements
- The players entry stage mustn’t be over.
msg::source()mustn’t already participate.msg::source()must have enough currency to pay a participation cost.- If the current game round currency is the native value
(
fungible_tokenisNone),msg::source()must send this action with the amount of the value exactly equal to a participation cost.
On success, replies with Event::PlayerAdded.
Trait Implementations§
source§impl Decode for Action
impl Decode for Action
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 Action
impl Encode for Action
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) -> Rwhere
F: FnOnce(&[u8]) -> R,
fn using_encoded<R, F>(&self, f: F) -> Rwhere F: FnOnce(&[u8]) -> R,
§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
source§impl Ord for Action
impl Ord for Action
source§impl PartialEq<Action> for Action
impl PartialEq<Action> for Action
source§impl PartialOrd<Action> for Action
impl PartialOrd<Action> for Action
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moreimpl Copy for Action
impl EncodeLike<Action> for Action
impl Eq for Action
impl StructuralEq for Action
impl StructuralPartialEq for Action
Auto Trait Implementations§
impl RefUnwindSafe for Action
impl Send for Action
impl Sync for Action
impl Unpin for Action
impl UnwindSafe for Action
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