Skip to content

Commit

Permalink
chore: add 'empty' variant to attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Darlington02 committed Dec 9, 2024
1 parent 395ec24 commit 9035a62
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 19 deletions.
6 changes: 5 additions & 1 deletion src/base/constants/types.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub enum ToolVariants {
TOOL4,
TOOL5,
TOOL6,
EMPTY
}

#[derive(Copy, Drop, Serde, starknet::Store, Clone)]
Expand All @@ -40,7 +41,7 @@ pub enum BodyVariants {
BODY4,
BODY5,
BODY6,
BODY7,
BODY7
}

#[derive(Copy, Drop, Serde, starknet::Store, Clone)]
Expand All @@ -50,6 +51,7 @@ pub enum BackgroundVariants {
BACKGROUND3,
BACKGROUND4,
BACKGROUND5,
EMPTY
}

#[derive(Copy, Drop, Serde, starknet::Store, Clone)]
Expand All @@ -59,6 +61,7 @@ pub enum ClothVariants {
CLOTH3,
CLOTH4,
CLOTH5,
EMPTY
}

#[derive(Copy, Drop, Serde, starknet::Store, Clone)]
Expand All @@ -82,6 +85,7 @@ pub enum AccessoryVariants {
ACCESSORY5,
ACCESSORY6,
ACCESSORY7,
EMPTY
}

#[derive(Copy, Drop, Serde, starknet::Store)]
Expand Down
2 changes: 1 addition & 1 deletion src/base/token_uris/attributes.cairo
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub mod profile_attributes;
pub mod profile_attributes;
19 changes: 13 additions & 6 deletions src/base/token_uris/attributes/profile_attributes.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
pub mod profile {
use coloniz::base::constants::types::{ ProfileVariants, AccessoryVariants, FaceVariants, ClothVariants, BackgroundVariants, BodyVariants, ToolVariants };
use coloniz::base::constants::types::{
ProfileVariants, AccessoryVariants, FaceVariants, ClothVariants, BackgroundVariants,
BodyVariants, ToolVariants
};

#[derive(Drop)]
pub struct ProfileAttributes {
Expand All @@ -18,7 +21,8 @@ pub mod profile {
ToolVariants::TOOL3 => "FISHING ROD",
ToolVariants::TOOL4 => "RED FLAG",
ToolVariants::TOOL5 => "STYLIZED BATON",
ToolVariants::TOOL6 => "WHITE GOLFSTICK"
ToolVariants::TOOL6 => "WHITE GOLFSTICK",
ToolVariants::EMPTY => ""
}
}

Expand All @@ -40,7 +44,8 @@ pub mod profile {
BackgroundVariants::BACKGROUND2 => "BROWN",
BackgroundVariants::BACKGROUND3 => "GOLD",
BackgroundVariants::BACKGROUND4 => "BLUE",
BackgroundVariants::BACKGROUND5 => "GREEN"
BackgroundVariants::BACKGROUND5 => "GREEN",
BackgroundVariants::EMPTY => ""
}
}

Expand All @@ -50,7 +55,8 @@ pub mod profile {
ClothVariants::ClOTH2 => "BLUE WEAR",
ClothVariants::CLOTH3 => "RED WEAR",
ClothVariants::CLOTH4 => "ORANGE WEAR",
ClothVariants::CLOTH5 => "PINK WEAR"
ClothVariants::CLOTH5 => "PINK WEAR",
ClothVariants::EMPTY => ""
}
}

Expand All @@ -75,7 +81,8 @@ pub mod profile {
AccessoryVariants::ACCESSORY4 => "PINK VISOR",
AccessoryVariants::ACCESSORY5 => "BLACK VISOR",
AccessoryVariants::ACCESSORY6 => "RED MASK",
AccessoryVariants::ACCESSORY7 => "VR HEADSET"
AccessoryVariants::ACCESSORY7 => "VR HEADSET",
AccessoryVariants::EMPTY => ""
}
}

Expand All @@ -89,4 +96,4 @@ pub mod profile {
accessory: get_accessory_attribute(profile_variant.accessory)
}
}
}
}
6 changes: 2 additions & 4 deletions src/base/token_uris/profile_token_uri.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ pub mod ProfileTokenUri {
use coloniz::base::utils::byte_array_extra::FeltTryIntoByteArray;
use coloniz::base::utils::base64_extended::{get_base64_encode};
use coloniz::base::token_uris::attributes::profile_attributes::profile::gen_profile_attributes;

fn get_attributes(
profile_variant: ProfileVariants, mint_timestamp: u64
) -> ByteArray {

fn get_attributes(profile_variant: ProfileVariants, mint_timestamp: u64) -> ByteArray {
let timestamp_felt: felt252 = mint_timestamp.into();
let profile_attributes = gen_profile_attributes(profile_variant);

Expand Down
3 changes: 2 additions & 1 deletion src/base/token_uris/traits/profile/back.cairo

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/base/token_uris/traits/profile/background.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub mod background {
decidedbackground =
"<rect style=\"display:inline;fill:teal;fill-opacity:1;stroke-width:.02627\" width=\"53.114\" height=\"53.52\" x=\".007\" y=\"-.277\" ry=\"0\"/>"
},
BackgroundVariants::EMPTY => ""
}
decidedbackground
}
Expand Down
3 changes: 2 additions & 1 deletion src/base/token_uris/traits/profile/cloth.cairo

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/base/token_uris/traits/profile/head.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub mod head {
decidedAccessory =
"<g style=\"display:inline\"><g style=\"display:inline;fill:#2f2f2f;fill-opacity:1\"><path style=\"fill:#2f2f2f;fill-opacity:1\" d=\"M282.483 203.034h-52.966V79.448a8.83 8.83 0 0 1 8.828-8.828h35.31a8.83 8.83 0 0 1 8.828 8.828z\" transform=\"matrix(.04142 .00024 -.00027 .0373 15.62 9.188)\"/><path style=\"fill:#2f2f2f;fill-opacity:1\" d=\"M441.379 441.379H70.621C31.618 441.379 0 409.761 0 370.759V264.828c0-39.002 31.618-70.621 70.621-70.621H441.38c39.003 0 70.621 31.618 70.621 70.621v105.931c-.001 39.002-31.619 70.62-70.622 70.62\" transform=\"matrix(.04142 .00024 -.00027 .0373 15.62 9.188)\"/></g><g style=\"display:inline;fill:#979797;fill-opacity:1\"><path style=\"fill:#979797;fill-opacity:1\" d=\"M441.379 211.862c29.206 0 52.966 23.761 52.966 52.966v105.931c0 29.205-23.759 52.966-52.966 52.966H70.621c-29.206 0-52.966-23.761-52.966-52.966V264.828c0-29.205 23.759-52.966 52.966-52.966zm0-17.655H70.621C31.617 194.207 0 225.825 0 264.828v105.931c0 39.003 31.617 70.621 70.621 70.621H441.38c39.004 0 70.621-31.618 70.621-70.621V264.828c-.001-39.003-31.618-70.621-70.622-70.621\" transform=\"matrix(.04142 .00024 -.00027 .0373 15.62 9.188)\"/><path style=\"fill:#979797;fill-opacity:1\" d=\"M291.31 247.172h-70.62a8.829 8.829 0 0 1 0-17.656h70.621a8.83 8.83 0 0 1 8.828 8.828 8.83 8.83 0 0 1-8.829 8.828m-8.827-150.069h-52.966V79.448a8.83 8.83 0 0 1 8.828-8.828h35.31a8.83 8.83 0 0 1 8.828 8.828z\" transform=\"matrix(.04142 .00024 -.00027 .0373 15.62 9.188)\"/></g><g transform=\"matrix(.04142 0 0 .0373 15.62 9.188)\"><ellipse style=\"fill:none;fill-opacity:1;stroke:#979797;stroke-width:7.66947;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1\" cx=\"114.5\" cy=\"326.075\" rx=\"48.687\" ry=\"52.331\"/><ellipse style=\"fill:none;fill-opacity:1;stroke:#282828;stroke-width:5.11298;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1\" cx=\"115.34\" cy=\"325.242\" rx=\"41.31\" ry=\"45.093\"/><ellipse style=\"fill:#2b96d6;fill-opacity:1;stroke:#103952;stroke-width:4.73291;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1\" cx=\"114.685\" cy=\"324.51\" rx=\"38.285\" ry=\"41.691\"/></g><g transform=\"matrix(.04142 0 0 .0373 15.62 9.188)\"><ellipse style=\"fill:none;fill-opacity:1;stroke:#979797;stroke-width:7.66947;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1\" cx=\"396.099\" cy=\"326.075\" rx=\"48.687\" ry=\"52.331\"/><ellipse style=\"fill:none;fill-opacity:1;stroke:#282828;stroke-width:5.11298;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1\" cx=\"396.94\" cy=\"325.242\" rx=\"41.31\" ry=\"45.093\"/><ellipse style=\"fill:#2b96d6;fill-opacity:1;stroke:#103952;stroke-width:4.73291;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1\" cx=\"396.285\" cy=\"324.51\" rx=\"38.285\" ry=\"41.691\"/></g></g>"
},
AccessoryVariants::EMPTY => ""
}
return decidedAccessory;
}
Expand Down
3 changes: 2 additions & 1 deletion src/coloniznft/coloniznft.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ pub mod ColonizNFT {
use core::num::traits::zero::Zero;
use coloniz::interfaces::IColonizNFT;
use coloniz::base::{
constants::errors::Errors::{ ALREADY_MINTED, UNAUTHORIZED }, constants::types::ProfileVariants,
constants::errors::Errors::{ALREADY_MINTED, UNAUTHORIZED},
constants::types::ProfileVariants,
token_uris::profile_token_uri::ProfileTokenUri::get_token_uri,
};
use openzeppelin::{
Expand Down
7 changes: 5 additions & 2 deletions src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ pub mod community;
pub mod channel;

use coloniz::base::token_uris::profile_token_uri::ProfileTokenUri::get_token_uri;
use coloniz::base::constants::types::{ ProfileVariants, AccessoryVariants, FaceVariants, ClothVariants, BackgroundVariants, BodyVariants, ToolVariants };
use coloniz::base::constants::types::{
ProfileVariants, AccessoryVariants, FaceVariants, ClothVariants, BackgroundVariants,
BodyVariants, ToolVariants
};

fn main() {
let profile_variant = ProfileVariants {
Expand All @@ -29,4 +32,4 @@ fn main() {
let image_url = format!("{}{}", base_uri, 1);
let token_uri: ByteArray = get_token_uri(profile_variant, 1, 3, image_url);
println!("{:?}", token_uri);
}
}
8 changes: 6 additions & 2 deletions tests/test_profile_token_uri.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use coloniz::base::token_uris::profile_token_uri::ProfileTokenUri::get_token_uri;
use coloniz::base::constants::types::{ ProfileVariants, AccessoryVariants, FaceVariants, ClothVariants, BackgroundVariants, BodyVariants, ToolVariants };
use coloniz::base::constants::types::{
ProfileVariants, AccessoryVariants, FaceVariants, ClothVariants, BackgroundVariants,
BodyVariants, ToolVariants
};

#[test]
fn test_profile_token_uri() {
Expand All @@ -15,7 +18,8 @@ fn test_profile_token_uri() {
let base_uri: ByteArray = "https://api.coloniz.com/images/";
let image_url = format!("{}{}", base_uri, 1);
let token_uri: ByteArray = get_token_uri(profile_variant, 1, 3, image_url);
let expected_token_uri: ByteArray = "eyJuYW1lIjoiUHJvZmlsZSAjMSIsImltYWdlIjoiaHR0cHM6Ly9hcGkuY29sb25pei5jb20vaW1hZ2VzLzEiLCJhdHRyaWJ1dGVzIjpbeyJ0cmFpdF90eXBlIjoiTUlOVCBUSU1FU1RBTVAiLCJ2YWx1ZSI6IjMifSx7InRyYWl0X3R5cGUiOiJjaGFyYWN0ZXIiLCJ2YWx1ZSI6IllFTExPVyBDT0xPTklTVCJ9LHsidHJhaXRfdHlwZSI6ImJhY2tncm91bmQiLCJ2YWx1ZSI6IlBFQUNIIn0seyJ0cmFpdF90eXBlIjoiY2xvdGhpbmciLCJ2YWx1ZSI6IlNXRUFURVIifSx7InRyYWl0X3R5cGUiOiJmYWNlIiwidmFsdWUiOiJST1VORCBFWUVTIn0seyJ0cmFpdF90eXBlIjoidG9vbCIsInZhbHVlIjoiQkxVRSBGTEFHIn0seyJ0cmFpdF90eXBlIjoiYWNjZXNzb3J5IiwidmFsdWUiOiJCTFVFIE1BU0sifV19";
let expected_token_uri: ByteArray =
"eyJuYW1lIjoiUHJvZmlsZSAjMSIsImltYWdlIjoiaHR0cHM6Ly9hcGkuY29sb25pei5jb20vaW1hZ2VzLzEiLCJhdHRyaWJ1dGVzIjpbeyJ0cmFpdF90eXBlIjoiTUlOVCBUSU1FU1RBTVAiLCJ2YWx1ZSI6IjMifSx7InRyYWl0X3R5cGUiOiJjaGFyYWN0ZXIiLCJ2YWx1ZSI6IllFTExPVyBDT0xPTklTVCJ9LHsidHJhaXRfdHlwZSI6ImJhY2tncm91bmQiLCJ2YWx1ZSI6IlBFQUNIIn0seyJ0cmFpdF90eXBlIjoiY2xvdGhpbmciLCJ2YWx1ZSI6IlNXRUFURVIifSx7InRyYWl0X3R5cGUiOiJmYWNlIiwidmFsdWUiOiJST1VORCBFWUVTIn0seyJ0cmFpdF90eXBlIjoidG9vbCIsInZhbHVlIjoiQkxVRSBGTEFHIn0seyJ0cmFpdF90eXBlIjoiYWNjZXNzb3J5IiwidmFsdWUiOiJCTFVFIE1BU0sifV19";

assert(token_uri == expected_token_uri, 'invalid token uri');
}

0 comments on commit 9035a62

Please sign in to comment.