Skip to content

Commit

Permalink
chore: scarb fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Darlington02 committed Dec 5, 2024
1 parent 0366d61 commit 7665c15
Show file tree
Hide file tree
Showing 13 changed files with 175 additions and 68 deletions.
8 changes: 4 additions & 4 deletions src/base/constants/types.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct Profile {
pub enum BackVariants {
BLUEFLAG,
BLUEGOLFSTICK,
FISHINGSTICK,
FISHINGSTICK,
REDFLAG,
STYLIZEDBATON,
WHITEGOLFSTICK,
Expand Down Expand Up @@ -69,7 +69,7 @@ pub enum FaceVariants {
FACE4,
FACE5,
FACE6,
FACE7,
FACE7,
FACE8,
}

Expand All @@ -78,8 +78,8 @@ pub enum AccessoryVariants {
BLACKVISOR,
BLUEMASK,
CAP,
ORANGEMASK,
PINKVISOR,
ORANGEMASK,
PINKVISOR,
REDMASK,
VRHEADSET,
}
Expand Down
8 changes: 6 additions & 2 deletions src/base/token_uris/profile_token_uri.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ pub mod ProfileTokenUri {
use coloniz::base::utils::byte_array_extra::FeltTryIntoByteArray;
use coloniz::base::utils::base64_extended::{get_base64_encode, convert_into_byteArray};

fn get_attributes(token_id: u256, mint_timestamp: u64) -> Array<felt252> { // TODO: review necessary attributes
fn get_attributes(
token_id: u256, mint_timestamp: u64
) -> Array<felt252> { // TODO: review necessary attributes
let token_id_felt: felt252 = token_id.try_into().unwrap();
let timestamp_felt: felt252 = mint_timestamp.try_into().unwrap();
let token_id_byte: ByteArray = token_id_felt.try_into().unwrap();
Expand Down Expand Up @@ -41,7 +43,9 @@ pub mod ProfileTokenUri {
json
}

pub fn get_token_uri(token_id: u256, mint_timestamp: u64, profile_variant: ProfileVariants) -> ByteArray {
pub fn get_token_uri(
token_id: u256, mint_timestamp: u64, profile_variant: ProfileVariants
) -> ByteArray {
let baseuri = 'data:image/svg+xml;base64,';
let mut svg = gen_profile_svg(profile_variant);
let svg_encoded: ByteArray = get_base64_encode(svg);
Expand Down
2 changes: 1 addition & 1 deletion src/base/token_uris/traits/profile.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub mod profile {
pub fn gen_profile_svg(profile_variant: ProfileVariants) -> ByteArray {
let mut profilesvg: ByteArray =
"<svg width=\"200\" height=\"200\" viewBox=\"0 0 52.917 52.917\" xmlns=\"http://www.w3.org/2000/svg\">";

profilesvg.append(@backgroundVariant(profile_variant.background));
profilesvg.append(@bodyVariant(profile_variant.body));
profilesvg.append(@clothVariant(profile_variant.cloth));
Expand Down
2 changes: 1 addition & 1 deletion src/base/token_uris/traits/profile/body.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub mod body {
use coloniz::base::utils::byte_array_extra::FeltTryIntoByteArray;
use coloniz::base::constants::types::BodyVariants;

pub fn bodyVariant(variant: BodyVariants) -> ByteArray {
getBodyvariant(variant)
}
Expand Down
4 changes: 1 addition & 3 deletions src/channel/channel.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ pub mod ChannelComponent {

use coloniz::jolt::jolt::JoltComponent;
use coloniz::community::community::CommunityComponent;
use coloniz::interfaces::{
IChannel::IChannel, ICommunity::ICommunity,
};
use coloniz::interfaces::{IChannel::IChannel, ICommunity::ICommunity,};
use coloniz::base::{
constants::errors::Errors::{
NOT_CHANNEL_OWNER, ALREADY_MEMBER, NOT_CHANNEL_MEMBER, NOT_COMMUNITY_MEMBER,
Expand Down
7 changes: 4 additions & 3 deletions src/coloniznft/coloniznft.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ pub mod ColonizNFT {
use core::num::traits::zero::Zero;
use coloniz::interfaces::IColonizNFT;
use coloniz::base::{
constants::errors::Errors::ALREADY_MINTED,
constants::types::ProfileVariants,
constants::errors::Errors::ALREADY_MINTED, constants::types::ProfileVariants,
token_uris::profile_token_uri::ProfileTokenUri::get_token_uri,
};
use openzeppelin::{
Expand Down Expand Up @@ -91,7 +90,9 @@ pub mod ColonizNFT {
// *************************************************************************
/// @notice mints the coloniz NFT
/// @param address address of user trying to mint the coloniz NFT
fn mint_coloniznft(ref self: ContractState, address: ContractAddress, profile_variant: ProfileVariants) {
fn mint_coloniznft(
ref self: ContractState, address: ContractAddress, profile_variant: ProfileVariants
) {
let balance = self.erc721.balance_of(address);
assert(balance.is_zero(), ALREADY_MINTED);

Expand Down
4 changes: 3 additions & 1 deletion src/interfaces/IColonizNFT.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ pub trait IColonizNFT<TState> {
// *************************************************************************
// EXTERNALS
// *************************************************************************
fn mint_coloniznft(ref self: TState, address: ContractAddress, profile_variant: ProfileVariants);
fn mint_coloniznft(
ref self: TState, address: ContractAddress, profile_variant: ProfileVariants
);
// *************************************************************************
// GETTERS
// *************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ pub mod presets;
pub mod hub;
pub mod jolt;
pub mod community;
pub mod channel;
pub mod channel;
3 changes: 1 addition & 2 deletions src/profile/profile.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ pub mod ProfileComponent {
use coloniz::interfaces::IERC721::{IERC721Dispatcher, IERC721DispatcherTrait};
use coloniz::interfaces::IProfile::IProfile;
use coloniz::base::{
constants::types::Profile,
constants::types::ProfileVariants,
constants::types::Profile, constants::types::ProfileVariants,
constants::errors::Errors::NOT_PROFILE_OWNER
};

Expand Down
9 changes: 6 additions & 3 deletions tests/test_coloniznft.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ use snforge_std::{
DeclareResultTrait
};

use openzeppelin::{ token::erc721::interface::{ERC721ABIDispatcher, ERC721ABIDispatcherTrait} };
use openzeppelin::{token::erc721::interface::{ERC721ABIDispatcher, ERC721ABIDispatcherTrait}};

use coloniz::interfaces::IColonizNFT::{ IColonizNFTDispatcher, IColonizNFTDispatcherTrait };
use coloniz::base::constants::types::{ ProfileVariants, AccessoryVariants, FaceVariants, ClothVariants, BackgroundVariants, BodyVariants, BackVariants };
use coloniz::interfaces::IColonizNFT::{IColonizNFTDispatcher, IColonizNFTDispatcherTrait};
use coloniz::base::constants::types::{
ProfileVariants, AccessoryVariants, FaceVariants, ClothVariants, BackgroundVariants,
BodyVariants, BackVariants
};

const ADMIN: felt252 = 'ADMIN';
const USER_ONE: felt252 = 'BOB';
Expand Down
5 changes: 4 additions & 1 deletion tests/test_hub.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ use coloniz::interfaces::IHandle::{IHandleDispatcher, IHandleDispatcherTrait};
use coloniz::interfaces::IHandleRegistry::{
IHandleRegistryDispatcher, IHandleRegistryDispatcherTrait
};
use coloniz::base::constants::types::{ ProfileVariants, AccessoryVariants, FaceVariants, ClothVariants, BackgroundVariants, BodyVariants, BackVariants };
use coloniz::base::constants::types::{
ProfileVariants, AccessoryVariants, FaceVariants, ClothVariants, BackgroundVariants,
BodyVariants, BackVariants
};

const ADMIN: felt252 = 13245;
const ADDRESS1: felt252 = 1234;
Expand Down
19 changes: 14 additions & 5 deletions tests/test_profile.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ use snforge_std::{
use coloniz::interfaces::IColonizNFT::{IColonizNFTDispatcher, IColonizNFTDispatcherTrait};
use coloniz::profile::profile::ProfileComponent::{Event as ProfileEvent, CreatedProfile};
use coloniz::interfaces::IProfile::{IProfileDispatcher, IProfileDispatcherTrait};
use coloniz::base::constants::types::{ ProfileVariants, AccessoryVariants, FaceVariants, ClothVariants, BackgroundVariants, BodyVariants, BackVariants };
use coloniz::base::constants::types::{
ProfileVariants, AccessoryVariants, FaceVariants, ClothVariants, BackgroundVariants,
BodyVariants, BackVariants
};

const HUB_ADDRESS: felt252 = 'HUB';
const USER: felt252 = 'USER1';
Expand Down Expand Up @@ -80,7 +83,9 @@ fn test_profile_creation() {
start_cheat_caller_address(profile_contract_address, USER.try_into().unwrap());
start_cheat_caller_address(nft_contract_address, USER.try_into().unwrap());
let profile_address = profileDispatcher
.create_profile(nft_contract_address, registry_class_hash, account_class_hash, 2456, profile_variant);
.create_profile(
nft_contract_address, registry_class_hash, account_class_hash, 2456, profile_variant
);

// test a new coloniz nft is minted
let last_minted_id = colonizNFTDispatcher.get_last_minted_id();
Expand Down Expand Up @@ -120,7 +125,9 @@ fn test_profile_metadata() {
start_cheat_caller_address(profile_contract_address, USER.try_into().unwrap());
start_cheat_caller_address(nft_contract_address, USER.try_into().unwrap());
let profile_address = profileDispatcher
.create_profile(nft_contract_address, registry_class_hash, account_class_hash, 2456, profile_variant);
.create_profile(
nft_contract_address, registry_class_hash, account_class_hash, 2456, profile_variant
);

profileDispatcher
.set_profile_metadata_uri(
Expand Down Expand Up @@ -148,7 +155,7 @@ fn test_profile_creation_event() {
let colonizNFTDispatcher = IColonizNFTDispatcher { contract_address: nft_contract_address };
let profileDispatcher = IProfileDispatcher { contract_address: profile_contract_address };
let mut spy = spy_events();

let profile_variant = ProfileVariants {
body: BodyVariants::Body1,
back: BackVariants::BLUEFLAG,
Expand All @@ -163,7 +170,9 @@ fn test_profile_creation_event() {
start_cheat_caller_address(nft_contract_address, USER.try_into().unwrap());

let profile_address = profileDispatcher
.create_profile(nft_contract_address, registry_class_hash, account_class_hash, 2456, profile_variant);
.create_profile(
nft_contract_address, registry_class_hash, account_class_hash, 2456, profile_variant
);

let token_id = colonizNFTDispatcher.get_user_token_id(USER.try_into().unwrap());

Expand Down
Loading

0 comments on commit 7665c15

Please sign in to comment.