Skip to content

Commit

Permalink
initial implementation of token uri base 64
Browse files Browse the repository at this point in the history
  • Loading branch information
mubarak23 committed Jun 26, 2024
1 parent e57ff37 commit d0581e9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ keywords = ["Karst", "SocialFi", "tokenbound", "cairo", "contracts", "starknet"]
starknet = "2.6.3"
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.11.0" }
token_bound_accounts= { git = "https://github.com/Starknet-Africa-Edu/TBA", tag = "v0.3.0" }
alexandria_bytes = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "c1a604e" }

[dev-dependencies]
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.22.0" }
Expand Down
22 changes: 20 additions & 2 deletions src/namespaces/handles.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ use openzeppelin::{
token::erc721::{ERC721Component::{ERC721Metadata, ERC721Mixin, HasComponent}},
introspection::src5::SRC5Component,
};

use alexandria_bytes::{Bytes, BytesTrait};
// use alexandria_encoding::{ BytesTrait};
// use starknet::ByteArray;

#[starknet::interface]
trait IERC721Metadata<TState> {
Expand Down Expand Up @@ -211,10 +213,26 @@ mod Handles {
self: @ContractState, token_id: u256, local_name: felt252
) -> ByteArray {
// TODO
return "TODO";
let bytes = BytesTrait::new();
bytes.append(local_name);
bytes.append(token_id);

let byte_array = bytes.read_u8();

let base64_encoded = alexandria_encoding::base64::encode(byte_array);

let mut result_byte_array = ByteArray::new();
for byte in base64_encoded {
result_byte_array.append_byte(byte);
}
let result_string = result_byte_array.to_string();

return result_string;

}
}


// *************************************************************************
// PRIVATE FUNCTIONS
// *************************************************************************
Expand Down

0 comments on commit d0581e9

Please sign in to comment.