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

Add debug logging and fix to be support on macos scripts #311

Merged
merged 1 commit into from
Dec 29, 2023
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ node.json
*.deployments.txt
artifacts
target
Scarb.lock

# nile
127.0.0.1.*
Expand All @@ -25,4 +26,5 @@ build
.DS_Store

tmp
.tmp*
.tmp*
scripts/*.log
34 changes: 32 additions & 2 deletions scripts/deploy_minter.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#!/bin/bash
source ../.env
# Check if --debug parameter is passed
debug="false"
for arg in "$@"
do
if [ "$arg" == "--debug" ]
then
debug="true"
fi
done

SIERRA_FILE=../target/dev/carbon_Minter.sierra.json
PROJECT=0x007afb15db3fb57839fec89c20754eb59f8d7e3f87d953ee68b0a99b6f527b3e
Expand All @@ -26,14 +35,23 @@ build() {
# declare the contract
declare() {
build
if [[ $debug == "true" ]]; then
printf "declare %s\n" "$SIERRA_FILE" > debug_minter.log
fi
output=$(starkli declare $SIERRA_FILE --keystore-password $KEYSTORE_PASSWORD --watch 2>&1)

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

address=$(echo "$output" | grep -oP '0x[0-9a-fA-F]+')
# Check if ggrep is available
if command -v ggrep >/dev/null 2>&1; then
address=$(echo -e "$output" | ggrep -oP '0x[0-9a-fA-F]+')
else
# If ggrep is not available, use grep
address=$(echo -e "$output" | grep -oP '0x[0-9a-fA-F]\+')
fi
echo $address
}

Expand All @@ -52,21 +70,33 @@ deploy() {
class_hash=$(declare | tail -n 1)
sleep 5

if [[ $debug == "true" ]]; then
printf "deploy %s %s %s %s %s %s %s %s %s %s \n" "$class_hash" "$PROJECT" "$SLOT" "$ERC20" "$PUBLIC_SALE_OPEN" "$MIN_VALUE_PER_TX" "$MAX_VALUE_PER_TX" "$MAX_VALUE" "$UNIT_PRICE" "$RESERVED_VALUE" >> debug_minter.log
fi
output=$(starkli deploy $class_hash "$PROJECT" u256:"$SLOT" "$ERC20" "$PUBLIC_SALE_OPEN" u256:"$MAX_VALUE_PER_TX" u256:"$MIN_VALUE_PER_TX" u256:"$MAX_VALUE" u256:"$UNIT_PRICE" u256:"$RESERVED_VALUE" "$OWNER" --keystore-password $KEYSTORE_PASSWORD --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)
# Check if ggrep is available
if command -v ggrep >/dev/null 2>&1; then
address=$(echo -e "$output" | ggrep -oP '0x[0-9a-fA-F]+' | tail -n 1)
else
# If ggrep is not available, use grep
address=$(echo -e "$output" | grep -oP '0x[0-9a-fA-F]+' | tail -n 1)
fi
echo $address
}

setup() {
contract=$(deploy)
sleep 5

if [[ $debug == "true" ]]; then
printf "invoke %s add_minter %s %s \n" "$PROJECT" "$SLOT" "$contract" >> debug_minter.log
fi
output=$(starkli invoke $PROJECT add_minter u256:$SLOT $contract --keystore-password $KEYSTORE_PASSWORD --watch 2>&1)

if [[ $output == *"Error"* ]]; then
Expand Down
31 changes: 29 additions & 2 deletions scripts/deploy_offseter.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#!/bin/bash
source ../.env
# Check if --debug parameter is passed
debug="false"
for arg in "$@"
do
if [ "$arg" == "--debug" ]
then
debug="true"
fi
done

SIERRA_FILE=../target/dev/carbon_Offseter.sierra.json
PROJECT=0x007afb15db3fb57839fec89c20754eb59f8d7e3f87d953ee68b0a99b6f527b3e
Expand All @@ -20,14 +29,23 @@ build() {
# declare the contract
declare() {
build
if [[ $debug == "true" ]]; then
printf "declare %s\n" "$SIERRA_FILE" > debug_offseter.log
fi
output=$(starkli declare $SIERRA_FILE --keystore-password $KEYSTORE_PASSWORD --watch 2>&1)

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

address=$(echo "$output" | grep -oP '0x[0-9a-fA-F]+')
# Check if ggrep is available
if command -v ggrep >/dev/null 2>&1; then
address=$(echo -e "$output" | ggrep -oP '0x[0-9a-fA-F]+')
else
# If ggrep is not available, use grep
address=$(echo -e "$output" | grep -oP '0x[0-9a-fA-F]\+')
fi
echo $address
}

Expand All @@ -38,14 +56,23 @@ declare() {
# $4 - Owner
deploy() {
class_hash=$(declare | tail -n 1)
if [[ $debug == "true" ]]; then
printf "deploy %s %s %s %s %s \n" "$class_hash" "$PROJECT" "$SLOT" "$MIN_CLAIMABLE" "$OWNER" >> debug_offseter.log
fi
output=$(starkli deploy $class_hash "$PROJECT" u256:"$SLOT" u256:"$MIN_CLAIMABLE" "$OWNER" --keystore-password $KEYSTORE_PASSWORD --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)
# Check if ggrep is available
if command -v ggrep >/dev/null 2>&1; then
address=$(echo -e "$output" | ggrep -oP '0x[0-9a-fA-F]+' | tail -n 1)
else
# If ggrep is not available, use grep
address=$(echo -e "$output" | grep -oP '0x[0-9a-fA-F]+' | tail -n 1)
fi
echo $address
}

Expand Down
65 changes: 53 additions & 12 deletions scripts/deploy_project.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,57 @@
#!/bin/bash
source ../.env

# Check if --debug parameter is passed
debug="false"
for arg in "$@"
do
if [ "$arg" == "--debug" ]
then
debug="true"
fi
done

SIERRA_FILE=../target/dev/carbon_Project.sierra.json
NAME=0x436172626f6e5f54657374
SYMBOL="CARBT"
DECIMALS=6
OWNER=0x05bB7458b87FaaA41303A69B771ae26235F28b79aBD5FA1C451C43461DFE1438
OWNER=0x01e2F67d8132831f210E19c5Ee0197aA134308e16F7f284bBa2c72E28FC464D2
SLOT=1
PROJECT_VALUE=100000000
TIMES="2 1688169600 1719792000"
ABSORPTIONS="2 0 2746197000000"
PROJECT_VALUE=17600000000
TIMES="24 1667314458 1698850458 1730472858 1762008858 1793544858 1825080858 1856703258 1888239258 1919775258 1951311258 1982933658 2046005658 2109164058 2172236058 2235394458 2266930458 2330002458 2361624858 2393160858 2424696858 2456232858 2487855258 2582463258 2614085658"
ABSORPTIONS=" 24 0 4719000 12584000 25168000 40898000 64493000 100672000 147862000 202917000 265837000 333476000 478192000 629200000 773916000 915486000 983125000 1108965000 1164020000 1223794000 1280422000 1335477000 1387386000 1528956000 1573000000"
TON_EQUIVALENT=1000000

# build the solution
build() {
output=$(scarb build 2>&1)

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

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

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

address=$(echo "$output" | grep -oP '0x[0-9a-fA-F]+')
# Check if ggrep is available
if command -v ggrep >/dev/null 2>&1; then
address=$(echo -e "$output" | ggrep -oP '0x[0-9a-fA-F]+')
else
# If ggrep is not available, use grep
address=$(echo -e "$output" | grep -oP '0x[0-9a-fA-F]\+')
fi
echo $address
}

Expand All @@ -45,36 +64,58 @@ deploy() {
class_hash=$(declare | tail -n 1)
sleep 5

if [[ $debug == "true" ]]; then
printf "deploy %s %s %s %s %s \n" "$class_hash" "$NAME" "$SYMBOL" "$DECIMALS" "$OWNER" >> debug_project.log
fi

output=$(starkli deploy $class_hash "$NAME" str:"$SYMBOL" "$DECIMALS" "$OWNER" --keystore-password $KEYSTORE_PASSWORD --watch 2>&1)

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

address=$(echo "$output" | grep -oP '0x[0-9a-fA-F]+' | tail -n 1)
# Check if ggrep is available
if command -v ggrep >/dev/null 2>&1; then
address=$(echo -e "$output" | ggrep -oP '0x[0-9a-fA-F]+' | tail -n 1)
else
# If ggrep is not available, use grep
address=$(echo -e "$output" | grep -oP '0x[0-9a-fA-F]+' | tail -n 1)
fi
echo $address
}

setup() {
contract=$(deploy)
sleep 5

if [[ $debug == "true" ]]; then
printf "invoke %s set_project_value %s %s \n" "$contract" "$SLOT" "$PROJECT_VALUE" >> debug_project.log
fi

output=$(starkli invoke $contract set_project_value u256:$SLOT u256:$PROJECT_VALUE --keystore-password $KEYSTORE_PASSWORD --watch 2>&1)
if [[ $output == *"Error"* ]]; then
echo "Error: $output"
echo -e "Error: $output"
exit 1
fi

if [[ $debug == "true" ]]; then
printf "invoke %s set_certifier %s %s \n" "$contract" "$SLOT" "$OWNER" >> debug_project.log
fi

output=$(starkli invoke $contract set_certifier u256:$SLOT $OWNER --keystore-password $KEYSTORE_PASSWORD --watch 2>&1)
if [[ $output == *"Error"* ]]; then
echo "Error: $output"
echo -e "Error: $output"
exit 1
fi

if [[ $debug == "true" ]]; then
printf "invoke %s set_absorptions u256:%s %s %s %s \n" "$contract" "$SLOT" "$TIMES" "$ABSORPTIONS" "$TON_EQUIVALENT" >> debug_project.log
fi

output=$(starkli invoke $contract set_absorptions u256:$SLOT $TIMES $ABSORPTIONS $TON_EQUIVALENT --keystore-password $KEYSTORE_PASSWORD --watch 2>&1)
if [[ $output == *"Error"* ]]; then
echo "Error: $output"
echo -e "Error: $output"
exit 1
fi

Expand Down
34 changes: 32 additions & 2 deletions scripts/deploy_yielder.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#!/bin/bash
source ../.env
# Check if --debug parameter is passed
debug="false"
for arg in "$@"
do
if [ "$arg" == "--debug" ]
then
debug="true"
fi
done

SIERRA_FILE=../target/dev/carbon_Yielder.sierra.json
PROJECT=0x04b9f63c40668305ff651677f97424921bcd1b781aafa66d1b4948a87f056d0d
Expand All @@ -22,13 +31,22 @@ build() {
declare() {
build

if [[ $debug == "true" ]]; then
printf "declare %s\n" "$SIERRA_FILE" > debug_yielder.log
fi
output=$(starkli declare $SIERRA_FILE --keystore-password $KEYSTORE_PASSWORD --watch 2>&1)
if [[ $output == *"Error"* ]]; then
echo "Error: $output"
exit 1
fi

address=$(echo "$output" | grep -oP '0x[0-9a-fA-F]+')
# Check if ggrep is available
if command -v ggrep >/dev/null 2>&1; then
address=$(echo -e "$output" | ggrep -oP '0x[0-9a-fA-F]+')
else
# If ggrep is not available, use grep
address=$(echo -e "$output" | grep -oP '0x[0-9a-fA-F]\+')
fi
echo $address
}

Expand All @@ -40,20 +58,32 @@ declare() {
deploy() {
class_hash=$(declare | tail -n 1)

if [[ $debug == "true" ]]; then
printf "deploy %s %s %s %s %s \n" "$class_hash" "$PROJECT" "$SLOT" "$ERC20" "$OWNER" >> debug_yielder.log
fi
output=$(starkli deploy $class_hash "$PROJECT" u256:"$SLOT" "$ERC20" "$OWNER" --keystore-password $KEYSTORE_PASSWORD --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)
# Check if ggrep is available
if command -v ggrep >/dev/null 2>&1; then
address=$(echo -e "$output" | ggrep -oP '0x[0-9a-fA-F]+' | tail -n 1)
else
# If ggrep is not available, use grep
address=$(echo -e "$output" | grep -oP '0x[0-9a-fA-F]+' | tail -n 1)
fi
echo $address
}

setup() {
contract=$(deploy)
sleep 5

if [[ $debug == "true" ]]; then
printf "invoke %s set_prices %s %s \n" "$contract" "$TIMES" "$PRICE" >> debug_yielder.log
fi
output=$(starkli invoke $contract set_prices $TIMES $PRICE --keystore-password $KEYSTORE_PASSWORD --watch 2>&1)
if [[ $output == *"Error"* ]]; then
echo "Error: $output"
Expand Down