Skip to content

Commit

Permalink
fix rebase conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
mubarak23 committed Jul 27, 2024
1 parent a3ae9f5 commit ee18758
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 46 deletions.
73 changes: 34 additions & 39 deletions src/base/token_uris/profile_token_uri.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,44 @@ pub mod ProfileTokenUri {
use alexandria_bytes::{Bytes, BytesTrait};
use alexandria_encoding::sol_abi::{SolBytesTrait, SolAbiEncodeTrait};
use karst::base::utils::byte_array_extra::FeltTryIntoByteArray;
use starknet::{
use starknet::{
ContractAddress, get_caller_address, get_contract_address, contract_address_const
};
use karst::base::{
constants::types::Profile
};


use karst::base::{constants::types::Profile};


pub fn get_token_uri(token_id: u256, mint_timestamp: u64, profile: Profile) -> ByteArray {
// get profile using token id or pass the profile Id
let mut encoded_inner: Bytes = BytesTrait::new(0, array![]); // BytesTrait::new_empty();
let profile_svg_example = '<svg xmlns="http://www.w3.org/2000/svg" width="210" height="335" fill="none"><path fill="url(#a)" d="M143.3 104.8c-.8.8-2.2.3-2.2-.9v-3.3c-1.3-46.1-71-46.1-72.2 0v3.3c0 1.1-1.4 1.7-2.2 1a145 145 0 0 0-2.4-2.4c-33.6-31.7-82.8 17.4-51 50.9l2.3 2.4A138.4 138.4 0 0 0 105 194s51 0 89.4-38.2l2.4-2.4c31.7-33.5-17.5-82.6-51-51l-2.5 2.4Z"/><circle cx="4" cy="4" r="4" fill="#fff" fill-opacity=".5" transform="matrix(-1 0 0 1 199.3 126)"/><path fill="#fff" fill-opacity=".5" d="M195.5 117.5a5 5 0 0 1-9 4 6.7 6.7 0 0 0-.3-.7l-1.2-2c-1-1.7-2.3-3.5-3.6-4.6-1.5-1.2-2.6-2-3.7-2.5l-1.7-.8a3 3 0 0 1-1.4-4l.1-.3c.8-1.5 0-3.3-1.5-3.5-1.9-.3-3.4-.3-5-.2h-.1a1.8 1.8 0 0 1-.3-3.5 23.6 23.6 0 0 1 16.6 4.8c1 .7 2.2 1.5 3.3 2.5a29.2 29.2 0 0 1 7.7 10.4v.3h.1"/><path stroke="#000" stroke-linecap="square" stroke-linejoin="round" stroke-width="4" d="M143.3 104.8v0c-.8.8-2.2.3-2.2-.9v0-3.3c-1.3-46.1-71-46.1-72.2 0v3.3c0 1.1-1.4 1.7-2.2 1v0a145 145 0 0 0-2.4-2.4c-33.6-31.7-82.8 17.4-51 50.9l2.3 2.4A138.4 138.4 0 0 0 105 194s51 0 89.4-38.2l2.4-2.4c31.7-33.5-17.5-82.6-51-51l-2.5 2.4Z"/><defs><radialGradient id="a" cx="0" cy="0" r="1" gradientTransform="matrix(0 128 -204 0 105 66)" gradientUnits="userSpaceOnUse"><stop stop-color="#FFDB76"/><stop offset="1" stop-color="#F8C944"/></radialGradient></defs></svg>'
let json = format!(
"{{\"name\":\"Profile #{}\",\"description\":\"Karst Protocol - Profile #{}\",\"image\":\"data:image/svg+xml;base64,{}",
profile.metadata_URI.into(),
profile.profile_owner,
encoded_inner.encode_packed(profile_svg_example)
);

let mut encoded: Bytes = BytesTrait::new(0, array![]);
let mut encoded_empty: Bytes = BytesTrait::new_empty();

return format!(
"data:application/json;base64,",
encoded.encode_packed(
encoded_empty(
format!(
{},
{},
{},
{},
json,
profile.profile_owner,
byte(profile.profile_owner.into())
mint_timestamp
)
)
)

)

// let mut encoded_inner: Bytes = BytesTrait::new(0, array![]); // BytesTrait::new_empty();
// let profile_svg_example = '<svg xmlns="http://www.w3.org/2000/svg" width="210" height="335" fill="none"><path fill="url(#a)" d="M143.3 104.8c-.8.8-2.2.3-2.2-.9v-3.3c-1.3-46.1-71-46.1-72.2 0v3.3c0 1.1-1.4 1.7-2.2 1a145 145 0 0 0-2.4-2.4c-33.6-31.7-82.8 17.4-51 50.9l2.3 2.4A138.4 138.4 0 0 0 105 194s51 0 89.4-38.2l2.4-2.4c31.7-33.5-17.5-82.6-51-51l-2.5 2.4Z"/><circle cx="4" cy="4" r="4" fill="#fff" fill-opacity=".5" transform="matrix(-1 0 0 1 199.3 126)"/><path fill="#fff" fill-opacity=".5" d="M195.5 117.5a5 5 0 0 1-9 4 6.7 6.7 0 0 0-.3-.7l-1.2-2c-1-1.7-2.3-3.5-3.6-4.6-1.5-1.2-2.6-2-3.7-2.5l-1.7-.8a3 3 0 0 1-1.4-4l.1-.3c.8-1.5 0-3.3-1.5-3.5-1.9-.3-3.4-.3-5-.2h-.1a1.8 1.8 0 0 1-.3-3.5 23.6 23.6 0 0 1 16.6 4.8c1 .7 2.2 1.5 3.3 2.5a29.2 29.2 0 0 1 7.7 10.4v.3h.1"/><path stroke="#000" stroke-linecap="square" stroke-linejoin="round" stroke-width="4" d="M143.3 104.8v0c-.8.8-2.2.3-2.2-.9v0-3.3c-1.3-46.1-71-46.1-72.2 0v3.3c0 1.1-1.4 1.7-2.2 1v0a145 145 0 0 0-2.4-2.4c-33.6-31.7-82.8 17.4-51 50.9l2.3 2.4A138.4 138.4 0 0 0 105 194s51 0 89.4-38.2l2.4-2.4c31.7-33.5-17.5-82.6-51-51l-2.5 2.4Z"/><defs><radialGradient id="a" cx="0" cy="0" r="1" gradientTransform="matrix(0 128 -204 0 105 66)" gradientUnits="userSpaceOnUse"><stop stop-color="#FFDB76"/><stop offset="1" stop-color="#F8C944"/></radialGradient></defs></svg>'
// let json = format!(
// "{{\"name\":\"Profile #{}\",\"description\":\"Karst Protocol - Profile #{}\",\"image\":\"data:image/svg+xml;base64,{}",
// profile.metadata_URI.into(),
// profile.profile_owner,
// encoded_inner.encode_packed(profile_svg_example)
// );

// let mut encoded: Bytes = BytesTrait::new(0, array![]);
// let mut encoded_empty: Bytes = BytesTrait::new_empty();

// return format!(
// "data:application/json;base64,",
// encoded.encode_packed(
// encoded_empty(
// format!(
// {},
// {},
// {},
// {},
// json,
// profile.profile_owner,
// byte(profile.profile_owner.into())
// mint_timestamp
// )
// )
// )

// )
"TODO"
}

}
}
2 changes: 2 additions & 0 deletions src/base/token_uris/token_uris.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ mod TokenURIComponent {
)
);
}

// TODO: https://github.com/lens-protocol/core/blob/master/contracts/misc/token-uris/HandleTokenURI.sol
fn handle_get_token_uri(
token_id: u256, local_name: felt252, namespace: felt252
Expand Down Expand Up @@ -88,6 +89,7 @@ mod TokenURIComponent {
)
);
}

// TODO: https://github.com/lens-protocol/core/blob/master/contracts/misc/token-uris/FollowTokenURI.sol#L14
fn follow_get_token_uri(
follow_token_id: u256, followed_profile_address: ContractAddress, follow_timestamp: u64
Expand Down
12 changes: 9 additions & 3 deletions src/follownft/follownft.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ mod Follow {
component!(path: TokenURIComponent, storage: token_uri, event: TokenUriEvent);




use openzeppelin::{
account, access::ownable::OwnableComponent,
token::erc721::{
Expand All @@ -78,7 +76,15 @@ mod Follow {
#[abi(embed_v0)]
impl OwnableImpl = OwnableComponent::OwnableImpl<ContractState>;
impl OwnableInternalImpl = OwnableComponent::InternalImpl<ContractState>;


#[abi(embed_v0)]
impl TokenURIImpl = TokenURIComponent::KarstTokenURI<ContractState>;


use karst::base::token_uris::token_uris::TokenURIComponent;
component!(path: TokenURIComponent, storage: token_uri, event: TokenUriEvent);


#[abi(embed_v0)]
impl TokenURIImpl = TokenURIComponent::KarstTokenURI<ContractState>;

Expand Down
1 change: 1 addition & 0 deletions src/interfaces/ITokenURI.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ pub trait ITokenURI<TState> {
follow_token_id: u256, followed_profile_address: ContractAddress, follow_timestamp: u64
) -> ByteArray;
}

3 changes: 1 addition & 2 deletions src/karstnft/karstnft.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ impl IERC721MetadataImpl<
let component = HasComponent::get_component(self);
ERC721Metadata::name(component)
}

fn symbol(self: @TContractState) -> ByteArray {
let component = HasComponent::get_component(self);
ERC721Metadata::symbol(component)
Expand All @@ -43,6 +42,7 @@ pub mod KarstNFT {
use karst::base::{
utils::hubrestricted::HubRestricted::hub_only, constants::errors::Errors::ALREADY_MINTED,
// token_uris::profile_token_uri::ProfileTokenUri,

};
use openzeppelin::{
account, access::ownable::OwnableComponent,
Expand All @@ -52,7 +52,6 @@ pub mod KarstNFT {
introspection::{src5::SRC5Component}
};


use karst::base::token_uris::token_uris::TokenURIComponent;
component!(path: TokenURIComponent, storage: token_uri, event: TokenUriEvent);

Expand Down
3 changes: 1 addition & 2 deletions src/namespaces/handles.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,7 @@ mod Handles {
self: @ContractState, token_id: u256, local_name: felt252
) -> ByteArray {
// call token uri component
self.token_uri.profile_get_token_uri(token_id, mint_timestamp, profile);

self.token_uri.profile_get_token_uri(token_id, mint_timestamp, profile)
}
}

Expand Down

0 comments on commit ee18758

Please sign in to comment.