Skip to content

Commit

Permalink
contracts: run scarb fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
credence0x committed Feb 21, 2024
1 parent 5a1296c commit 3a5f187
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 85 deletions.
17 changes: 8 additions & 9 deletions contracts/src/blobert.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,11 @@ mod Blobert {
}

fn whitelist_mint_count(self: @ContractState, address: ContractAddress) -> u8 {
self.num_whitelist_mints.read(
address
)
self.num_whitelist_mints.read(address)
}

fn regular_mint_count(self: @ContractState, address: ContractAddress) -> u8 {
self.num_regular_mints.read(
address
)
self.num_regular_mints.read(address)
}

fn traits(self: @ContractState, token_id: u256) -> TokenTrait {
Expand All @@ -310,13 +306,16 @@ mod Blobert {
fn content_uri(self: @ContractState, token_id: u256) -> ByteArray {
let traits = self.traits(token_id);
match traits {
TokenTrait::Regular(seed) => { self.descriptor_regular.read().content_uri(token_id, seed) },
TokenTrait::Custom(index) => { self.descriptor_custom.read().content_uri(token_id, index) }
TokenTrait::Regular(seed) => {
self.descriptor_regular.read().content_uri(token_id, seed)
},
TokenTrait::Custom(index) => {
self.descriptor_custom.read().content_uri(token_id, index)
}
}
}



fn svg_image(self: @ContractState, token_id: u256) -> ByteArray {
let traits = self.traits(token_id);
match traits {
Expand Down
24 changes: 14 additions & 10 deletions contracts/src/descriptor/descriptor_custom.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ mod DescriptorCustom {
struct Storage {}



#[abi(embed_v0)]
impl DescriptorCustomImpl of super::IDescriptorCustom<ContractState> {
fn custom_count(self: @ContractState) -> u8 {
Expand All @@ -48,8 +47,7 @@ mod DescriptorCustom {
fn content_uri(self: @ContractState, token_id: u256, index: u8) -> ByteArray {
self.data_uri(token_id, index, include_image: false)
}




fn svg_image(self: @ContractState, index: u8) -> ByteArray {
let (image_bytes, _) = self.custom(index);
Expand All @@ -60,7 +58,9 @@ mod DescriptorCustom {

#[generate_trait]
impl InternalImpl of InternalTrait {
fn data_uri(self: @ContractState, token_id: u256, index: u8, include_image: bool) -> ByteArray {
fn data_uri(
self: @ContractState, token_id: u256, index: u8, include_image: bool
) -> ByteArray {
let (image_bytes, image_name) = self.custom(index);

let image: ByteArray = self
Expand All @@ -74,10 +74,12 @@ mod DescriptorCustom {
.add("name", self.get_token_name(image_name.clone(), token_id))
.add("description", self.get_token_description(image_name.clone(), token_id))
.add("type", type_);
let metadata = if include_image {metadata.add("image", image)} else {metadata};
let metadata = metadata
.add_array("attributes", attributes)
.build();
let metadata = if include_image {
metadata.add("image", image)
} else {
metadata
};
let metadata = metadata.add_array("attributes", attributes).build();

let base64_encoded_metadata: ByteArray = bytes_base64_encode(metadata);
format!("data:application/json;base64,{}", base64_encoded_metadata)
Expand Down Expand Up @@ -122,10 +124,12 @@ mod DescriptorCustom {


fn get_token_name(self: @ContractState, name: ByteArray, token_id: u256) -> ByteArray {
return format!("{} #{}", name, token_id);
return format!("{} #{}", name, token_id);
}

fn get_token_description(self: @ContractState, name: ByteArray, token_id: u256) -> ByteArray {
fn get_token_description(
self: @ContractState, name: ByteArray, token_id: u256
) -> ByteArray {
return format!("{} #{} is a squire from Realms World", name, token_id);
}
}
Expand Down
17 changes: 10 additions & 7 deletions contracts/src/descriptor/descriptor_regular.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ mod DescriptorRegular {

#[generate_trait]
impl InternalImpl of InternalTrait {
fn data_uri(self: @ContractState, token_id: u256, seed: Seed, include_image: bool) -> ByteArray {
fn data_uri(
self: @ContractState, token_id: u256, seed: Seed, include_image: bool
) -> ByteArray {
let (armour_bytes, armour_name) = armours(seed.armour);
let (mask_bytes, mask_name) = masks(seed.mask);
let (background_bytes, background_name) = backgrounds(seed.background);
Expand Down Expand Up @@ -156,12 +158,13 @@ mod DescriptorRegular {
.add("name", self.get_token_name(token_id))
.add("description", self.get_token_description(token_id))
.add("type", type_);
let metadata
= if include_image {metadata.add("image", image)} else {metadata};

let metadata = metadata
.add_array("attributes", attributes)
.build();
let metadata = if include_image {
metadata.add("image", image)
} else {
metadata
};

let metadata = metadata.add_array("attributes", attributes).build();

let base64_encoded_metadata: ByteArray = bytes_base64_encode(metadata);
format!("data:application/json;base64,{}", base64_encoded_metadata)
Expand Down
3 changes: 0 additions & 3 deletions contracts/src/generation/custom/image.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,3 @@ fn custom_images(index: u8) -> (ByteArray, ByteArray) {
}
}




Loading

0 comments on commit 3a5f187

Please sign in to comment.