Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refac contracts #37

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/cairo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:
- uses: actions/checkout@v4
- uses: asdf-vm/actions/install@v3
- run: scarb fmt --check
working-directory: contracts
working-directory: onchain
- run: scarb build
working-directory: contracts
working-directory: onchain

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: asdf-vm/actions/install@v3
- run: snforge test
working-directory: contracts
working-directory: onchain
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 → onchain/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 onchain/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';
}
File renamed without changes.
Loading