Skip to content

Commit

Permalink
scarb fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
MSghais committed Dec 14, 2024
1 parent 0a80302 commit a48f30d
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 31 deletions.
8 changes: 6 additions & 2 deletions onchain/cairo/games/src/defi/vault.cairo
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
use afk_games::types::defi_types::{TokenPermitted, DepositUser, MintDepositEvent, WithdrawDepositEvent};
use afk_games::types::defi_types::{
TokenPermitted, DepositUser, MintDepositEvent, WithdrawDepositEvent
};
use starknet::ContractAddress;

// TODO
// Create the as a Vault component
#[starknet::contract]
pub mod Vault {
use afk_games::interfaces::erc20_mintable::{IERC20MintableDispatcher, IERC20MintableDispatcherTrait};
use afk_games::interfaces::erc20_mintable::{
IERC20MintableDispatcher, IERC20MintableDispatcherTrait
};
use afk_games::interfaces::vault::{IERCVault};
use afk_games::tokens::erc20::{IERC20Dispatcher, IERC20DispatcherTrait};
use afk_games::types::constants::{ // MINTER_ROLE,
Expand Down
4 changes: 0 additions & 4 deletions onchain/cairo/games/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

pub mod errors;

pub mod math;
Expand Down Expand Up @@ -46,7 +45,6 @@ pub mod pixel {
}



pub mod quests {
pub mod authority_quest;
pub mod chain_faction_quest;
Expand All @@ -64,8 +62,6 @@ pub mod quests {
}




pub mod types {
pub mod constants;
pub mod quest;
Expand Down
14 changes: 5 additions & 9 deletions onchain/cairo/games/src/pixel/art_peace.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ pub mod ArtPeace {
ExtraPixelsPlaced, DailyQuestClaimed, MainQuestClaimed, VoteColor, VotableColorAdded,
FactionCreated, FactionLeaderChanged, ChainFactionCreated, FactionJoined, FactionLeft,
ChainFactionJoined, FactionTemplateAdded, FactionTemplateRemoved, ChainFactionTemplateAdded,
ChainFactionTemplateRemoved,
InitParams,
MetadataPixel,
PixelMetadataPlaced
ChainFactionTemplateRemoved, InitParams, MetadataPixel, PixelMetadataPlaced
};
use afk_games::interfaces::pixel_template::{
ITemplateVerifier, ITemplateStore, FactionTemplateMetadata, TemplateMetadata
Expand Down Expand Up @@ -221,8 +218,7 @@ pub mod ArtPeace {
while i < color_count {
self.color_palette.write(i, *init_params.color_palette.at(i.into()));
// TODO fix events
self.emit(ColorAdded { color_key: i, color: *init_params.color_palette.at(i.into())
});
self.emit(ColorAdded { color_key: i, color: *init_params.color_palette.at(i.into()) });
i += 1;
};

Expand Down Expand Up @@ -299,10 +295,11 @@ pub mod ArtPeace {
// Check if ok
self
.emit(
PixelMetadataPlaced { placed_by: caller, pos:pos, day:day, color:color, metadata: metadata }
PixelMetadataPlaced {
placed_by: caller, pos: pos, day: day, color: color, metadata: metadata
}
);
}

}

#[abi(embed_v0)]
Expand Down Expand Up @@ -411,7 +408,6 @@ pub mod ArtPeace {
// );
// }


fn place_pixel_xy(ref self: ContractState, x: u128, y: u128, color: u8, now: u64) {
let pos = x + y * self.canvas_width.read();
self.place_pixel(pos, color, now);
Expand Down
3 changes: 2 additions & 1 deletion onchain/cairo/games/src/pixel/canvas.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ pub mod Canvas {

let caller = starknet::get_caller_address();
// TODO: let pixel = Pixel { color, owner: caller };
// TODO: self.canvas.write(pos, pixel); let day = self.day_index.read();
// TODO: self.canvas.write(pos, pixel);
// let day = self.day_index.read();
// self
// .user_pixels_placed
// .write((day, caller, color), self.user_pixels_placed.read((day, caller, color)) + 1);
Expand Down
9 changes: 5 additions & 4 deletions onchain/cairo/games/src/pixel/canvas_factory.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::starknet::{ContractAddress, ClassHash};
use afk_games::pixel::canvas::Canvas;
use core::starknet::{ContractAddress, ClassHash};

#[starknet::interface]
pub trait ICanvasFactory<TContractState> {
Expand All @@ -18,9 +18,8 @@ pub trait ICanvasFactory<TContractState> {

#[starknet::contract]
pub mod CanvasFactory {
use starknet::syscalls::deploy_syscall;
use core::starknet::{get_caller_address, ContractAddress, ClassHash};
use afk_games::pixel::canvas::Canvas;
use core::starknet::{get_caller_address, ContractAddress, ClassHash};
use starknet::storage::{
Map, StorageMapReadAccess, StorageMapWriteAccess, // Stor
StoragePointerReadAccess,
Expand All @@ -33,6 +32,7 @@ pub mod CanvasFactory {
// StorageAsPathWriteForward,
// PathableStorageEntryImpl
};
use starknet::syscalls::deploy_syscall;
#[storage]
struct Storage {
owner: ContractAddress,
Expand Down Expand Up @@ -124,7 +124,8 @@ pub mod CanvasFactory {
fn create_canvas(
ref self: ContractState, init_params: super::Canvas::InitParams
) -> (ContractAddress, u64) {
// TODO: Serialize before calling this function to defer serialization to the contract input
// TODO: Serialize before calling this function to defer serialization to the contract
// input
let mut init_params_serialized = array![];
init_params.serialize(ref init_params_serialized);
let deploy_res = deploy_syscall(
Expand Down
4 changes: 3 additions & 1 deletion onchain/cairo/games/src/quests/authority_quest.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#[starknet::contract]
pub mod AuthorityQuest {
use afk_games::interfaces::pixel_template::{ITemplateStoreDispatcher, ITemplateStoreDispatcherTrait};
use afk_games::interfaces::pixel_template::{
ITemplateStoreDispatcher, ITemplateStoreDispatcherTrait
};
use afk_games::interfaces::quests::{IAuthorityQuest, IQuest};
use starknet::storage::{
StoragePointerReadAccess, StoragePointerWriteAccess, StoragePathEntry, Map
Expand Down
1 change: 0 additions & 1 deletion onchain/cairo/games/src/quests/chain_faction_quest.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#[starknet::contract]

pub mod ChainFactionQuest {
use afk_games::interfaces::pixel::{IArtPeaceDispatcher, IArtPeaceDispatcherTrait};
use afk_games::interfaces::quests::{IAuthorityQuest, IQuest};
Expand Down
4 changes: 3 additions & 1 deletion onchain/cairo/games/src/quests/template_quest.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#[starknet::contract]
pub mod TemplateQuest {
use afk_games::interfaces::pixel_template::{ITemplateStoreDispatcher, ITemplateStoreDispatcherTrait};
use afk_games::interfaces::pixel_template::{
ITemplateStoreDispatcher, ITemplateStoreDispatcherTrait
};
use afk_games::interfaces::quests::IQuest;
use starknet::storage::{
StoragePointerReadAccess, StoragePointerWriteAccess, StoragePathEntry, Map
Expand Down
4 changes: 3 additions & 1 deletion onchain/cairo/games/src/quests/username_quest.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#[starknet::contract]
pub mod UsernameQuest {
use afk_games::interfaces::quests::{IQuest};
use afk_games::interfaces::username_store::{IUsernameStoreDispatcher, IUsernameStoreDispatcherTrait,};
use afk_games::interfaces::username_store::{
IUsernameStoreDispatcher, IUsernameStoreDispatcherTrait,
};
use starknet::storage::{
StoragePointerReadAccess, StoragePointerWriteAccess, StoragePathEntry, Map
};
Expand Down
4 changes: 2 additions & 2 deletions onchain/cairo/games/src/tests/art_peace_tests.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub(crate) fn deploy_contract() -> ContractAddress {
let contract = declare("ArtPeace").unwrap().contract_class();
let mut calldata = array![];
InitParams {
host:HOST(),
host: utils::HOST(),
canvas_width: WIDTH,
canvas_height: HEIGHT,
time_between_pixels: TIME_BETWEEN_PIXELS,
Expand Down Expand Up @@ -95,7 +95,7 @@ pub(crate) fn deploy_with_quests_contract(
let daily_quests_count = 3;
let mut calldata = array![];
InitParams {
host:HOST(),
host: utils::HOST(),
canvas_width: WIDTH,
canvas_height: HEIGHT,
time_between_pixels: TIME_BETWEEN_PIXELS,
Expand Down
4 changes: 3 additions & 1 deletion onchain/cairo/games/src/tests/nameservice_tests.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#[cfg(test)]
mod nameservice_tests {
use afk_games::interfaces::erc20::{IERC20Dispatcher, IERC20DispatcherTrait};
use afk_games::interfaces::erc20_mintable::{IERC20MintableDispatcher, IERC20MintableDispatcherTrait};
use afk_games::interfaces::erc20_mintable::{
IERC20MintableDispatcher, IERC20MintableDispatcherTrait
};
use afk_games::interfaces::nameservice::{INameserviceDispatcher, INameserviceDispatcherTrait};
use snforge_std::{
declare, ContractClass, ContractClassTrait, start_cheat_caller_address,
Expand Down
4 changes: 3 additions & 1 deletion onchain/cairo/games/src/tests/quest_factory_test.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#[cfg(test)]
mod quest_factory_tests {
use afk_games::interfaces::erc20_mintable::{IERC20MintableDispatcher, IERC20MintableDispatcherTrait};
use afk_games::interfaces::erc20_mintable::{
IERC20MintableDispatcher, IERC20MintableDispatcherTrait
};
use afk_games::interfaces::quest::{
IQuestFactoryDispatcher, IQuestFactoryDispatcherTrait, IQuestNFTDispatcher,
IQuestNFTDispatcherTrait, ITapQuestsDispatcher, ITapQuestsDispatcherTrait
Expand Down
4 changes: 3 additions & 1 deletion onchain/cairo/games/src/tests/vault_tests.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#[cfg(test)]
mod vault_test {
use afk_games::defi::vault::Vault::Event;
use afk_games::interfaces::erc20_mintable::{IERC20MintableDispatcher, IERC20MintableDispatcherTrait};
use afk_games::interfaces::erc20_mintable::{
IERC20MintableDispatcher, IERC20MintableDispatcherTrait
};
use afk_games::interfaces::vault::{IERCVaultDispatcher, IERCVaultDispatcherTrait};
use afk_games::tokens::erc20::{IERC20Dispatcher, IERC20DispatcherTrait};
use afk_games::types::defi_types::{ // TokenPermitted, DepositUser,
Expand Down
4 changes: 2 additions & 2 deletions onchain/cairo/utils/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pub mod types {

#[cfg(test)]
pub mod tests {
pub mod utils;
pub mod bip340;
pub mod utils;
// pub mod sha256;
// pub mod math;
// pub mod math;
}

0 comments on commit a48f30d

Please sign in to comment.