Skip to content

Commit

Permalink
refac: contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
manlikeHB committed Jan 14, 2025
1 parent 3de9188 commit 5595ec3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
14 changes: 4 additions & 10 deletions contracts/src/contracts/lyricsflip.cairo
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
#[starknet::contract]
pub mod LyricsFlip {
use core::traits::Into;
use lyricsflip::interfaces::lyricsflip::{ILyricsFlip};
use lyricsflip::utils::errors::Errors;
use lyricsflip::utils::types::{Card, Genre, Round};
use starknet::storage::{
StoragePointerReadAccess, StoragePointerWriteAccess, StoragePathEntry, Map, Vec,
MutableVecTrait, VecTrait
};
use starknet::{get_caller_address, get_block_timestamp, ContractAddress};

pub mod Errors {
pub const NON_EXISTING_ROUND: felt252 = 'Round does not exists';
pub const NOT_ROUND_ADMIN: felt252 = 'Only round admin can start';
pub const ROUND_ALREADY_STARTED: felt252 = 'Round already started';
pub const NON_EXISTING_GENRE: felt252 = 'Genre does not exists';
pub const ROUND_ALREADY_JOINED: felt252 = 'You are already a player';
}

#[storage]
struct Storage {
Expand All @@ -24,8 +17,9 @@ pub mod LyricsFlip {
cards_per_round: u8,
cards: Map<u64, Card>,
rounds: Map<u64, Round>, // round_id -> Round
round_owner: Map<ContractAddress, Round>,
round_players: Map<u64, Map<u256, ContractAddress>>,
round_players: Map<
u64, Map<u256, ContractAddress>
>, // round_id -> player_index -> player_address
round_players_count: Map<u64, u256>,
round_cards: Map<u64, Vec<u64>>, // round_id -> vec<card_ids>
}
Expand Down
1 change: 1 addition & 0 deletions contracts/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub mod contracts {
}

pub mod utils {
pub mod errors;
pub mod types;
}

Expand Down
7 changes: 7 additions & 0 deletions contracts/src/utils/errors.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pub mod Errors {
pub const NON_EXISTING_ROUND: felt252 = 'Round does not exists';
pub const NOT_ROUND_ADMIN: felt252 = 'Only round admin can start';
pub const ROUND_ALREADY_STARTED: felt252 = 'Round already started';
pub const NON_EXISTING_GENRE: felt252 = 'Genre does not exists';
pub const ROUND_ALREADY_JOINED: felt252 = 'You are already a player';
}

0 comments on commit 5595ec3

Please sign in to comment.