Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update image_data supported in metadata #54

Merged
merged 3 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,25 @@ scarb test
Instructions for deployment

1. Component Declaration
- Run the script `bash scripts/deploy_components.sh --components --debug` to declare all components.
- Run the script `./scripts/deploy_components.sh --components --debug` to declare all components.
- **Note**: This script may need to be executed multiple times until all components are declared without any errors.

2. Provider Deployment & Setup
- Use the script `bash scripts/deploy_components.sh --provider --debug` to deploy and set up the provider.
- Use the script `./scripts/deploy_components.sh --provider --debug` to deploy and set up the provider.

3. Metadata Class Declaration
- Declare classes using the script `bash scripts/declare_contracts.sh --contracts --debug`.
3. Component register into Provider
- Use the script `./scripts/deploy_components.sh --register --debug` to deploy and set up the provider.

4. Project Contract Provider Setup
4. Metadata Class Declaration
- Declare classes using the script `./scripts/declare_contracts.sh --contracts --debug`.

5. Project Contract Provider Setup
- Set the provider on the Project contract.

5. Project URI Setup
6. Project URI Setup
- Set the Project URI.

6. Slot URI Setup
7. Slot URI Setup
- Set the Slot URI.


Expand Down
69 changes: 44 additions & 25 deletions scripts/deploy_components.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ source .env
# Check if --debug parameter is passed
debug=0
declare=0
setup=0
provider=0
register=0

TEMP=$(getopt -o cpd --long components,provider,debug -- "$@")
TEMP=$(getopt -o cpdr --long components,provider,register,debug -- "$@")

eval set -- "$TEMP"

Expand All @@ -15,7 +16,9 @@ while true ; do
-c|--components)
declare=1 ; shift ;;
-p|--provider)
setup=1 ; shift ;;
provider=1 ; shift ;;
-r|--register)
register=1 ; shift ;;
-d|--debug)
debug=1 ; shift ;;
--) shift ; break ;;
Expand Down Expand Up @@ -48,20 +51,6 @@ declare() {
echo $address
}

add_component() {
if [ $debug -eq 1 ]; then
printf "starkli invoke %s register %s --keystore-password KEYSTORE_PASSWORD --rpc %s --watch \n" "$PROVIDER_ADDRESS" $COMPONENT_CLASS "$STARKNET_RPC" >> ./scripts/debug_setup_provider.log
fi
output=$(starkli invoke $PROVIDER_ADDRESS register $COMPONENT_CLASS --keystore-password $KEYSTORE_PASSWORD --rpc $STARKNET_RPC --watch 2>&1)

if [[ $output == *"Error"* ]]; then
echo "Error: $output"
exit 1
fi

echo "Registering component: " $COMPONENT_CLASS
}

component_classes=();

# Declares all components
Expand Down Expand Up @@ -89,19 +78,19 @@ declare_all() {
PROVIDER_CLASS=$class_hash
echo "PROVIDER_CLASS="$PROVIDER_CLASS

echo "$PROVIDER_CLASS" > .tmp.addr.provider
echo "$PROVIDER_CLASS" > .tmp.declaring.provider

declare_components

echo "${component_classes[@]}" > .tmp.addr.component_classes
echo "${component_classes[@]}" > .tmp.declaring.component_classes

echo ${#component_classes[@]}" Components to register"
}

deploy_provider() {
OWNER=$DEPLOYER_ADDRESS

PROVIDER_CLASS=$(cat .tmp.addr.provider)
PROVIDER_CLASS=$(cat .tmp.declaring.provider)
printf "Logs : Provider class : %s \n" "$PROVIDER_CLASS" > ./scripts/debug_setup_provider.log

if [ $debug -eq 1 ]; then
Expand All @@ -121,25 +110,55 @@ deploy_provider() {
setup_provider() {
contract=$(deploy_provider)
PROVIDER_ADDRESS=$contract
echo "Provider deployed at:"$PROVIDER_ADDRESS
echo "Provider deployed at: "$PROVIDER_ADDRESS

echo "$PROVIDER_ADDRESS" > .tmp.addr.provider
}

add_component() {
local multi_call_param=$1

readarray -t component_classes < .tmp.addr.component_classes
if [ $debug -eq 1 ]; then
printf "starkli invoke --keystore-password KEYSTORE_PASSWORD --watch %s \n" "$multi_call_param" >> ./scripts/debug_setup_provider.log
fi
output=$(starkli invoke --keystore-password $KEYSTORE_PASSWORD --watch $multi_call_param 2>&1)

if [[ $output == *"Error"* ]]; then
echo "Error: $output"
exit 1
fi

echo "Registering components: " $multi_call_param
}

register_provider() {
readarray -t component_classes < .tmp.declaring.component_classes

PROVIDER_ADDRESS=$(cat .tmp.addr.provider)

command_string=""
counter=0
for class_hash in ${component_classes[@]};
do
COMPONENT_CLASS=$class_hash
add_component
command_string+="$PROVIDER_ADDRESS register $class_hash \\ "
((counter++))
done

echo "$command_string" > .tmp.debug

add_component "$command_string"

echo "Total components added: $counter"
}

if [ $declare -eq 1 ]; then
declare_all
fi

if [ $setup -eq 1 ]; then
if [ $provider -eq 1 ]; then
setup_provider
fi

if [ $register -eq 1 ]; then
register_provider
fi
10 changes: 5 additions & 5 deletions src/metadata/slots/karathuru/data.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use metadata::metadata::common::models::{ProjectStaticData, String, Shortstring}
const NAME: Shortstring = 'Karathuru';
const DEVELOPER: Shortstring = 'Wordview Intl Foundation';
const CERTIFIER: Shortstring = 'Verra';
const AREA: u32 = 228;
const AREA: u32 = 500;
const COUNTRY: Shortstring = 'Myanmar';
const END_YEAR: u32 = 2048; // get from project
const END_YEAR: u32 = 2047; // get from project
const END_MONTH: u8 = 12; // get from project
const DURATION_IN_YEARS: u32 = consteval_int!(2048 - 2024); // get from project
const TOTAL_CU: u64 = 187142; // get from project
const PROJECTED_CU: u64 = 187142; // get from project
const DURATION_IN_YEARS: u32 = consteval_int!(2047 - 2024); // get from project
const TOTAL_CU: u64 = 410400; // get from project
const PROJECTED_CU: u64 = 410400; // get from project
const COLOR: Shortstring = 'Blue';
const TYPE: Shortstring = 'ARR';
const CATEGORY: Shortstring = 'Mangrove';
Expand Down
2 changes: 1 addition & 1 deletion src/metadata/slots/template/generate_slot.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use alexandria_ascii::ToAsciiTrait;
fn add_metadata_members_(ref metadata: JsonMetadata, data: @TemplateData) {
metadata.add_member('name', *data.token_name);
metadata.add_member('description', *data.token_description);
metadata.add_member('image', svg::generate(data));
metadata.add_member('image_data', svg::generate(data));
metadata
.add_member(
'banner_image_url',
Expand Down
2 changes: 1 addition & 1 deletion src/metadata/slots/template/generate_token.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn add_metadata_members_(ref metadata: JsonMetadata, data: @TemplateData) {
metadata.add_member('description', *data.token_description);
metadata.add_member('external_url', *data.external_url);
metadata.add_member('youtube_url', *data.youtube_url);
metadata.add_member('image', svg::generate(data));
metadata.add_member('image_data', svg::generate(data));
}

#[inline(always)]
Expand Down
1 change: 0 additions & 1 deletion src/metadata/slots/template/svg.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use metadata::metadata::slots::template::data::TemplateData;

fn generate(data: @TemplateData) -> Span<felt252> {
let mut svg: Array<felt252> = Default::default();
svg.append('data:image/svg+xml,');
print_head_sft_template(ref svg, data);
svg.span()
}
Expand Down
Loading