Skip to content

Commit

Permalink
Update deployment and setup instructions (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arn0d authored Feb 9, 2024
1 parent 031a687 commit f94a9ee
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 54 deletions.
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,25 @@ scarb test

Instructions for deployment

1. Declare the Metadata implementations: `bash scripts/declare_contracts.sh`
2. Declare the components: `bash scripts/deploy_components.sh` (stop before the 1 minute pause)
3. Deploy and configure the provider: `bash scripts/deploy_components.sh`
1. Component Declaration
- Run the script `bash 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.

3. Metadata Class Declaration
- Declare classes using the script `bash scripts/declare_contracts.sh --contracts --debug`.

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

5. Project URI Setup
- Set the Project URI.

6. Slot URI Setup
- Set the Slot URI.


## 📄 License

Expand Down
41 changes: 29 additions & 12 deletions scripts/declare_contracts.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
#!/bin/bash
source .env

# Check if --debug parameter is passed
debug=0
declare=0
build=0

TEMP=$(getopt -o cbd --long contracts,build,debug -- "$@")

eval set -- "$TEMP"

while true ; do
case "$1" in
-c|--contracts)
declare=1 ; shift ;;
-b|--provider)
build=1 ; shift ;;
-d|--debug)
debug=1 ; shift ;;
--) shift ; break ;;
*) echo "Internal error!" ; exit 1 ;;
esac
done

# build the project
build() {
output=$(scarb build 2>&1)
Expand Down Expand Up @@ -34,9 +56,8 @@ Jaguar="./target/dev/compiled_JaguarIpfsUri.sierra.json"
BORDER="./target/dev/compiled_metadata_components_component_sft_border_v2_Component.sierra.json"

contracts=( $BanegasFarm $LasDelicias $Manjarisoa $Karathuru $ERC3525Contract )
# contracts=( $Manjarisoa )

declare_all() {
declare_contracts() {
for contract in ${contracts[@]};
do
SIERRA_FILE=$contract
Expand All @@ -46,13 +67,9 @@ declare_all() {
done
}

make() {
echo "building project"
#build

echo "Declaring all contracts"

declare_all
}

make
if [ $declare -eq 1 ]; then
declare_contracts
fi
if [ $build -eq 1 ]; then
build
fi
111 changes: 72 additions & 39 deletions scripts/deploy_components.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
#!/bin/bash
source .env

# Check if --debug parameter is passed
debug=0
declare=0
setup=0

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

eval set -- "$TEMP"

while true ; do
case "$1" in
-c|--components)
declare=1 ; shift ;;
-p|--provider)
setup=1 ; shift ;;
-d|--debug)
debug=1 ; shift ;;
--) shift ; break ;;
*) echo "Internal error!" ; exit 1 ;;
esac
done

# build the project
build() {
output=$(scarb build 2>&1)
Expand All @@ -11,8 +33,10 @@ build() {
fi
}

# declare the contract
declare() {
if [ $debug -eq 1 ]; then
printf "starkli declare %s --keystore-password KEYSTORE_PASSWORD --rpc %s --watch \n" "$SIERRA_FILE" "$STARKNET_RPC" > ./scripts/debug_declare_components.log
fi
output=$(starkli declare $SIERRA_FILE --keystore-password $KEYSTORE_PASSWORD --rpc $STARKNET_RPC --watch 2>&1)

if [[ $output == *"Error"* ]]; then
Expand All @@ -24,21 +48,10 @@ declare() {
echo $address
}

deploy_provider() {
OWNER=$DEPLOYER_ADDRESS

output=$(starkli deploy $PROVIDER_CLASS "$OWNER" --keystore-password $KEYSTORE_PASSWORD --rpc $STARKNET_RPC --watch 2>&1)

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

address=$(echo "$output" | grep -oP '0x[0-9a-fA-F]+' | tail -n 1)
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
Expand Down Expand Up @@ -69,44 +82,64 @@ declare_components() {
done
}

setup_provider() {
contract=$(deploy_provider)
PROVIDER_ADDRESS=$contract
echo "Provider deployed at:"$PROVIDER_ADDRESS

for class_hash in ${component_classes[@]};
do
COMPONENT_CLASS=$class_hash
add_component
done
}


declare_all() {
# build
SIERRA_FILE="./target/dev/compiled_ComponentProvider.sierra.json"
class_hash=$(declare | tail -n 1)
PROVIDER_CLASS=$class_hash
echo "PROVIDER_CLASS="$PROVIDER_CLASS

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

declare_components

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

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

make() {
echo "Declaring all contracts"
deploy_provider() {
OWNER=$DEPLOYER_ADDRESS

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

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

echo ${#component_classes[@]}" Components to register"
echo "Waiting a minute.."
if [[ $output == *"Error"* ]]; then
echo "Error: $output"
exit 1
fi

sleep 60
address=$(echo "$output" | grep -oP '0x[0-9a-fA-F]+' | tail -n 1)
echo $address
}

setup_provider
setup_provider() {
contract=$(deploy_provider)
PROVIDER_ADDRESS=$contract
echo "Provider deployed at:"$PROVIDER_ADDRESS

readarray -t component_classes < .tmp.addr.component_classes

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

echo "Total components added: $counter"
}

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

# SIERRA_FILE="./target/dev/compiled_metadata_components_component_logos_carbonable_Component.sierra.json"
# class_hash=$(declare | tail -n 1)
# echo $class_hash
if [ $setup -eq 1 ]; then
setup_provider
fi

0 comments on commit f94a9ee

Please sign in to comment.