-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from PavitraAgarwal21/main
Start Working on Creation of Profile Svg
- Loading branch information
Showing
19 changed files
with
694 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
mod follow_token_uri; | ||
mod handle_token_uri; | ||
mod profile_token_uri; | ||
mod traits; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,56 @@ | ||
// TODO: https://github.com/lens-protocol/core/blob/master/contracts/misc/token-uris/HandleTokenURI.sol | ||
|
||
pub mod HandleTokenUri { | ||
use core::array::ArrayTrait; | ||
use alexandria_bytes::{Bytes, BytesTrait}; | ||
use karst::base::utils::byte_array_extra::FeltTryIntoByteArray; | ||
use karst::base::utils::base64_extended::{convert_into_byteArray, get_base64_encode}; | ||
use karst::base::token_uris::traits::handle::handle::get_svg_handle; | ||
|
||
pub fn get_token_uri(token_id: u256, local_name: felt252, namespace: felt252) -> ByteArray { | ||
"TODO" | ||
let baseuri = 'data:image/svg+xml;base64,'; | ||
/// TODO what are feaature include in the svg | ||
let mut svg_byte_array: ByteArray = get_svg_handle(token_id, local_name, namespace); | ||
let mut svg_encoded: ByteArray = get_base64_encode(svg_byte_array); | ||
let mut attribute_byte_array: ByteArray = get_attributes( | ||
token_id, ref svg_encoded, local_name, namespace | ||
); | ||
let mut token_uri: ByteArray = baseuri.try_into().unwrap(); | ||
token_uri.append(@attribute_byte_array); | ||
token_uri | ||
} | ||
|
||
fn get_attributes( | ||
token_id: u256, | ||
ref svg_encoded_byteArray: ByteArray, | ||
local_name: felt252, | ||
namespace: felt252 | ||
) -> ByteArray { | ||
let mut attributespre = ArrayTrait::<felt252>::new(); | ||
let mut attributespost = ArrayTrait::<felt252>::new(); | ||
attributespre.append('{"name":"@'); | ||
attributespre.append(local_name); | ||
attributespre.append('","description":"Lens '); | ||
attributespre.append('Protocol - Handle @'); | ||
attributespre.append(local_name); | ||
attributespre.append('","image":"data:image'); | ||
attributespre.append('/svg+xml;base64,'); | ||
attributespost.append('","attributes":[{"display'); | ||
attributespost.append('_type":"number","trait_type'); | ||
attributespost.append('":"ID","value":"'); | ||
attributespost.append(token_id.try_into().unwrap()); | ||
attributespost.append('"},{"trait_type":"NAMES'); | ||
attributespost.append('PACE","value":"'); | ||
attributespost.append(namespace); | ||
attributespost.append('"},{"trait_type":"'); | ||
attributespost.append('LENGTH","value":"'); | ||
attributespost.append('token_id_byte_len'); | ||
attributespost.append('"}]}'); | ||
let mut attributespre_bytearray = convert_into_byteArray(ref attributespre); | ||
let mut attributespost_bytearray = convert_into_byteArray(ref attributespost); | ||
attributespre_bytearray.append(@svg_encoded_byteArray); | ||
attributespre_bytearray.append(@attributespost_bytearray); | ||
get_base64_encode(attributespre_bytearray) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
mod head; | ||
mod glass; | ||
mod color; | ||
mod beard; | ||
mod background; | ||
mod cloth; | ||
mod profile; | ||
mod handle; | ||
mod follow; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// let make the face of the profile svg | ||
|
||
mod background { | ||
use core::traits::TryInto; | ||
use karst::base::token_uris::traits::color::karstColors; | ||
use karst::base::utils::byte_array_extra::FeltTryIntoByteArray; | ||
|
||
#[derive(Drop)] | ||
enum BackgroundVariants { | ||
BACKGROUND1, // 1 | ||
BACKGROUND2, // 2 | ||
BACKGROUND3, // 3 | ||
BACKGROUND4, // 4 | ||
} | ||
|
||
pub fn backgroundSvgStart() -> ByteArray { | ||
getBackgroundVariant(BackgroundVariants::BACKGROUND2) | ||
} | ||
|
||
pub fn getBackgroundVariant(backgroundVariant: BackgroundVariants) -> ByteArray { | ||
let mut decidedbackground: ByteArray = Default::default(); | ||
match backgroundVariant { | ||
BackgroundVariants::BACKGROUND1 => { | ||
decidedbackground = | ||
"<g style=\"fill:orange;fill-opacity:1\"><path style=\"display:inline;fill:#2f5e6e;fill-opacity:1;stroke:#000;stroke-width:1.165;stroke-linecap:round;stroke-dasharray:1.165,1.165;stroke-dashoffset:0;stroke-opacity:1\" d=\"M.145 0h52.952v52.952H.145z\"/></g>" | ||
}, | ||
BackgroundVariants::BACKGROUND2 => { | ||
decidedbackground = | ||
"<defs><pattern href=\"#a\" preserveAspectRatio=\"xMidYMid\" id=\"b\" patternTransform=\"matrix(.11 0 0 .11 20.717 451.73)\" x=\"0\" y=\"0\"/><pattern patternUnits=\"userSpaceOnUse\" preserveAspectRatio=\"xMidYMid\" width=\"377.875\" height=\"377.953\" patternTransform=\"matrix(.2 0 0 .2 20.717 452.26)\" id=\"a\"><path style=\"color:#000;fill:#f32500;stroke-width:4.21429;paint-order:markers fill stroke\" d=\"M18.013.003v18.015H0v9.608h13.267L.004 40.89 0 40.885v14.302l.004.004 27.569-27.569h.046v-.043L55.187.009l-.006-.007H40.868l.011.012-13.26 13.26V.003Zm67.818 0L0 85.837v206.27l85.831 85.83-.015.015h206.193l-.02-.022 85.884-85.884.002.002V85.888l-.002.002L291.983 0Zm236.861 0-.007.008 27.567 27.566v.046h.045l27.569 27.57.009-.008V40.883l-.009.008-13.263-13.263h13.272V18.02h-18.008V.005h-9.615v13.271L336.992.016l.01-.012zm-227.62 5.07h187.67l90.072 90.071V282.8l-90.073 90.076H95.076L5.002 282.803V95.143Zm93.836 17.194c-92.01 0-166.703 74.694-166.703 166.703 0 92.01 74.693 166.712 166.703 166.712s166.71-74.702 166.71-166.712-74.7-166.703-166.71-166.703m0 10.116c86.544 0 156.594 70.044 156.594 156.587 0 86.544-70.05 156.597-156.594 156.597S32.312 275.514 32.312 188.97c0-86.543 70.053-156.587 156.596-156.587m0 24.495c-72.894 0-132.092 59.198-132.092 132.092s59.198 132.1 132.092 132.1 132.099-59.205 132.099-132.1S261.803 56.878 188.908 56.878m-5.054 10.225v243.734c-58.475-2.378-106.263-45.806-115.36-102.282h87.654l-.074 67.388c-21.292-8.063-38.776-23.069-49.887-42.43h25.474v13.95h10.115v-24.066H89.38l3.317 7.178c12.795 27.687 37.163 48.88 66.975 57.772l6.495 1.934.115-91.842H67.285a124 124 0 0 1 .248-21.73h98.748l-.115-91.842-6.495 1.936c-29.812 8.892-54.18 30.086-66.975 57.773l-3.317 7.178h52.397v-24.067h-10.115v13.951h-25.468c11.112-19.358 28.591-34.362 49.88-42.423l.075 67.378H68.973c10.195-55.112 57.37-97.151 114.88-99.49m10.107.004c57.51 2.338 104.685 44.377 114.88 99.49h-88.194l.083-67.378c21.288 8.062 38.76 23.065 49.871 42.423h-25.467V127.69H235.02v24.067h52.397l-3.317-7.178c-12.795-27.69-37.163-48.885-66.975-57.777l-6.495-1.936-.115 91.842h99.769a124 124 0 0 1 .246 21.73H210.514l.115 91.842 6.495-1.934c29.812-8.892 54.18-30.085 66.975-57.773l3.317-7.178H235.02v24.067h10.115v-13.95h25.474c-11.11 19.36-28.587 34.366-49.878 42.43l-.083-67.388h88.676c-9.098 56.476-56.887 99.905-115.362 102.282zm183.912 255.649-3.574 3.574-23.992 23.992h-.055v.055l-27.562 27.56.015.015h14.304l-.013-.012 13.256-13.256v13.27h9.615v-18.022h18.008v-9.606h-13.263l13.26-13.26.003.001V322.76ZM0 322.76v14.305l13.271 13.257L0 350.324v9.608l18.013-.002v18.021h9.606v-13.28l13.267 13.267-.013.012h14.295l.02-.023z\"/></pattern></defs><g style=\"fill:orange;fill-opacity:1\"><path style=\"display:inline;fill:#2f5e6e;fill-opacity:1;stroke:#000;stroke-width:1.165;stroke-linecap:round;stroke-dasharray:1.165,1.165;stroke-dashoffset:0;stroke-opacity:1\" d=\"M.145 0h52.952v52.952H.145z\"/><path style=\"display:inline;fill:url(#b);fill-opacity:1;stroke:#0a0805;stroke-width:1.165;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1\" d=\"M.145 0h52.952v52.952H.145z\"/></g>" | ||
}, | ||
BackgroundVariants::BACKGROUND3 => { | ||
decidedbackground = | ||
"<defs><pattern href=\"#a\" preserveAspectRatio=\"xMidYMid\" id=\"b\" patternTransform=\"matrix(.11 0 0 .11 20.717 451.73)\" x=\"0\" y=\"0\"/><pattern patternUnits=\"userSpaceOnUse\" preserveAspectRatio=\"xMidYMid\" width=\"377.875\" height=\"377.953\" patternTransform=\"matrix(.2 0 0 .2 20.717 452.26)\" id=\"a\"><path style=\"color:#000;fill:#f32500;stroke-width:4.21429;paint-order:markers fill stroke\" d=\"M18.013.003v18.015H0v9.608h13.267L.004 40.89 0 40.885v14.302l.004.004 27.569-27.569h.046v-.043L55.187.009l-.006-.007H40.868l.011.012-13.26 13.26V.003Zm67.818 0L0 85.837v206.27l85.831 85.83-.015.015h206.193l-.02-.022 85.884-85.884.002.002V85.888l-.002.002L291.983 0Zm236.861 0-.007.008 27.567 27.566v.046h.045l27.569 27.57.009-.008V40.883l-.009.008-13.263-13.263h13.272V18.02h-18.008V.005h-9.615v13.271L336.992.016l.01-.012zm-227.62 5.07h187.67l90.072 90.071V282.8l-90.073 90.076H95.076L5.002 282.803V95.143Zm93.836 17.194c-92.01 0-166.703 74.694-166.703 166.703 0 92.01 74.693 166.712 166.703 166.712s166.71-74.702 166.71-166.712-74.7-166.703-166.71-166.703m0 10.116c86.544 0 156.594 70.044 156.594 156.587 0 86.544-70.05 156.597-156.594 156.597S32.312 275.514 32.312 188.97c0-86.543 70.053-156.587 156.596-156.587m0 24.495c-72.894 0-132.092 59.198-132.092 132.092s59.198 132.1 132.092 132.1 132.099-59.205 132.099-132.1S261.803 56.878 188.908 56.878m-5.054 10.225v243.734c-58.475-2.378-106.263-45.806-115.36-102.282h87.654l-.074 67.388c-21.292-8.063-38.776-23.069-49.887-42.43h25.474v13.95h10.115v-24.066H89.38l3.317 7.178c12.795 27.687 37.163 48.88 66.975 57.772l6.495 1.934.115-91.842H67.285a124 124 0 0 1 .248-21.73h98.748l-.115-91.842-6.495 1.936c-29.812 8.892-54.18 30.086-66.975 57.773l-3.317 7.178h52.397v-24.067h-10.115v13.951h-25.468c11.112-19.358 28.591-34.362 49.88-42.423l.075 67.378H68.973c10.195-55.112 57.37-97.151 114.88-99.49m10.107.004c57.51 2.338 104.685 44.377 114.88 99.49h-88.194l.083-67.378c21.288 8.062 38.76 23.065 49.871 42.423h-25.467V127.69H235.02v24.067h52.397l-3.317-7.178c-12.795-27.69-37.163-48.885-66.975-57.777l-6.495-1.936-.115 91.842h99.769a124 124 0 0 1 .246 21.73H210.514l.115 91.842 6.495-1.934c29.812-8.892 54.18-30.085 66.975-57.773l3.317-7.178H235.02v24.067h10.115v-13.95h25.474c-11.11 19.36-28.587 34.366-49.878 42.43l-.083-67.388h88.676c-9.098 56.476-56.887 99.905-115.362 102.282zm183.912 255.649-3.574 3.574-23.992 23.992h-.055v.055l-27.562 27.56.015.015h14.304l-.013-.012 13.256-13.256v13.27h9.615v-18.022h18.008v-9.606h-13.263l13.26-13.26.003.001V322.76ZM0 322.76v14.305l13.271 13.257L0 350.324v9.608l18.013-.002v18.021h9.606v-13.28l13.267 13.267-.013.012h14.295l.02-.023z\"/></pattern></defs><g style=\"fill:orange;fill-opacity:1\"><path style=\"display:inline;fill:url(#b);fill-opacity:1;stroke:#0a0805;stroke-width:1.165;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1\" d=\"M.145 0h52.952v52.952H.145z\"/></g>" | ||
}, | ||
BackgroundVariants::BACKGROUND4 => { | ||
decidedbackground = | ||
"<defs><pattern href=\"#a\" preserveAspectRatio=\"xMidYMid\" id=\"b\" patternTransform=\"matrix(.11 0 0 .11 20.717 451.73)\" x=\"0\" y=\"0\"/><pattern patternUnits=\"userSpaceOnUse\" preserveAspectRatio=\"xMidYMid\" width=\"377.875\" height=\"377.953\" patternTransform=\"matrix(.2 0 0 .2 20.717 452.26)\" id=\"a\"><path style=\"color:#000;fill:#f32500;stroke-width:4.21429;paint-order:markers fill stroke\" d=\"M18.013.003v18.015H0v9.608h13.267L.004 40.89 0 40.885v14.302l.004.004 27.569-27.569h.046v-.043L55.187.009l-.006-.007H40.868l.011.012-13.26 13.26V.003Zm67.818 0L0 85.837v206.27l85.831 85.83-.015.015h206.193l-.02-.022 85.884-85.884.002.002V85.888l-.002.002L291.983 0Zm236.861 0-.007.008 27.567 27.566v.046h.045l27.569 27.57.009-.008V40.883l-.009.008-13.263-13.263h13.272V18.02h-18.008V.005h-9.615v13.271L336.992.016l.01-.012zm-227.62 5.07h187.67l90.072 90.071V282.8l-90.073 90.076H95.076L5.002 282.803V95.143Zm93.836 17.194c-92.01 0-166.703 74.694-166.703 166.703 0 92.01 74.693 166.712 166.703 166.712s166.71-74.702 166.71-166.712-74.7-166.703-166.71-166.703m0 10.116c86.544 0 156.594 70.044 156.594 156.587 0 86.544-70.05 156.597-156.594 156.597S32.312 275.514 32.312 188.97c0-86.543 70.053-156.587 156.596-156.587m0 24.495c-72.894 0-132.092 59.198-132.092 132.092s59.198 132.1 132.092 132.1 132.099-59.205 132.099-132.1S261.803 56.878 188.908 56.878m-5.054 10.225v243.734c-58.475-2.378-106.263-45.806-115.36-102.282h87.654l-.074 67.388c-21.292-8.063-38.776-23.069-49.887-42.43h25.474v13.95h10.115v-24.066H89.38l3.317 7.178c12.795 27.687 37.163 48.88 66.975 57.772l6.495 1.934.115-91.842H67.285a124 124 0 0 1 .248-21.73h98.748l-.115-91.842-6.495 1.936c-29.812 8.892-54.18 30.086-66.975 57.773l-3.317 7.178h52.397v-24.067h-10.115v13.951h-25.468c11.112-19.358 28.591-34.362 49.88-42.423l.075 67.378H68.973c10.195-55.112 57.37-97.151 114.88-99.49m10.107.004c57.51 2.338 104.685 44.377 114.88 99.49h-88.194l.083-67.378c21.288 8.062 38.76 23.065 49.871 42.423h-25.467V127.69H235.02v24.067h52.397l-3.317-7.178c-12.795-27.69-37.163-48.885-66.975-57.777l-6.495-1.936-.115 91.842h99.769a124 124 0 0 1 .246 21.73H210.514l.115 91.842 6.495-1.934c29.812-8.892 54.18-30.085 66.975-57.773l3.317-7.178H235.02v24.067h10.115v-13.95h25.474c-11.11 19.36-28.587 34.366-49.878 42.43l-.083-67.388h88.676c-9.098 56.476-56.887 99.905-115.362 102.282zm183.912 255.649-3.574 3.574-23.992 23.992h-.055v.055l-27.562 27.56.015.015h14.304l-.013-.012 13.256-13.256v13.27h9.615v-18.022h18.008v-9.606h-13.263l13.26-13.26.003.001V322.76ZM0 322.76v14.305l13.271 13.257L0 350.324v9.608l18.013-.002v18.021h9.606v-13.28l13.267 13.267-.013.012h14.295l.02-.023z\"/></pattern></defs><g style=\"fill:orange;fill-opacity:1\"><path style=\"display:inline;fill:#d8ba69;fill-opacity:1;stroke:#000;stroke-width:1.165;stroke-linecap:round;stroke-dasharray:1.165,1.165;stroke-dashoffset:0;stroke-opacity:1\" d=\"M.145 0h52.952v52.952H.145z\"/><path style=\"display:inline;fill:url(#b);fill-opacity:1;stroke:#0a0805;stroke-width:1.165;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1\" d=\"M.145 0h52.952v52.952H.145z\"/></g>" | ||
}, | ||
} | ||
decidedbackground | ||
} | ||
} |
Oops, something went wrong.