Skip to content

Commit

Permalink
Env var update (#171)
Browse files Browse the repository at this point in the history
* update env vars

* fix address assertion casing

* made sncast point to juno

* rm debug echos

* revert to sepolia sncast

* merge conflict fixes

* changed round durations to vault constructor args

* scarb fmt

* Update .env.example

* update ABIs

* fix script for sepolia

* Update constants.cairo

* update foundry for sepolia

* comment updates

* update sncast script

* added new constructor args to docker/launcer setup

* env example updates

* Move image args to runtime env vars + deployment scripts cleanup

* Update .env.example

---------

Co-authored-by: Eugen Patru <[email protected]>
  • Loading branch information
0xDegenDeveloper and eugenPtr authored Dec 4, 2024
1 parent 9a4dfe3 commit 81bbd8a
Show file tree
Hide file tree
Showing 23 changed files with 339 additions and 210 deletions.
16 changes: 10 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
FOSSIL_PROCESSOR_ADDRESS=0x0768D44B56fD0F6f660A449697c906391b1aE682B30086F4d521c4c414d399d9
VAULT_ROUND_DURATION=5555
VAULT_ALPHA=2500
VAULT_STRIKE=0
ROUND_TRANSITION_DURATION=180 # 3 min
AUCTION_DURATION=180 # 3 min
ROUND_DURATION=720 # 12 min

SIGNER_PRIVATE_KEY=0x2bff1b26236b72d8a930be1dfbee09f79a536a49482a4c8b8f1030e2ab3bf1b
SIGNER_ADDRESS=0x101
STRK_TOKEN=0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7
DEVNET_RPC=http://host.docker.internal:6060
DEVNET_RPC=http://localhost:6060

# Copy this from the Argent extension
ARGENT_WALLET_ADDRESS=0x0768d44b56fd0f6f660a449697c906391b1ae682b30086f4d521c4c414d399d9
# Copy this from the Argent extension
ARGENT_WALLET_ADDRESS=
# These 2 can be found in the Argent extenstion: Settings -> Developer Settings -> Deployment Data
ARGENT_WALLET_SALT=0x15337fc442ab75a3589746a426987f9dfb49b3abd8d447dab3550c3ead971b
ARGENT_WALLET_CONSTRUCTOR_ARG1=37459222005894634870375857944293937532221532474070351093573957772534191899
ARGENT_WALLET_SALT=
ARGENT_WALLET_CONSTRUCTOR_ARG1=
36 changes: 2 additions & 34 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,8 @@ SHELL ["/bin/bash", "-c"]
ENV SCARB_VERSION=2.8.4
ENV STARKLI_VERSION=0.3.5

# Define build-time arguments
ARG SIGNER_PRIVATE_KEY
ARG DEVNET_RPC
ARG SIGNER_ADDRESS
ARG FOSSIL_PROCESSOR_ADDRESS
ARG VAULT_ROUND_DURATION
ARG ARGENT_ADDRESS
ARG ARGENT_SALT
ARG ARGENT_CONSTRUCTOR_ARG1

# Check if all required arguments are provided
RUN if [ -z "$SIGNER_PRIVATE_KEY" ] || \
[ -z "$DEVNET_RPC" ] || \
[ -z "$SIGNER_ADDRESS" ] || \
[ -z "$FOSSIL_PROCESSOR_ADDRESS" ] || \
[ -z "$VAULT_ROUND_DURATION" ] || \
[ -z "$ARGENT_ADDRESS" ] || \
[ -z "$ARGENT_SALT" ] || \
[ -z "$ARGENT_CONSTRUCTOR_ARG1" ]; then \
echo "Error: All build arguments must be provided."; \
exit 1; \
fi

# Starkli environment variables
ENV STARKNET_ACCOUNT=/root/starkli_deployer_account.json
ENV STARKNET_PRIVATE_KEY=$SIGNER_PRIVATE_KEY
ENV STARKNET_RPC=$DEVNET_RPC

ENV SIGNER_ADDRESS=$SIGNER_ADDRESS
ENV FOSSIL_PROCESSOR_ADDRESS=$FOSSIL_PROCESSOR_ADDRESS
ENV VAULT_ROUND_DURATION=$VAULT_ROUND_DURATION
ENV ARGENT_ADDRESS=$ARGENT_ADDRESS
ENV ARGENT_SALT=$ARGENT_SALT
ENV ARGENT_CONSTRUCTOR_ARG1=$ARGENT_CONSTRUCTOR_ARG1

# Install necessary dependencies
RUN apt-get update && apt-get install -y \
Expand Down Expand Up @@ -68,5 +36,5 @@ RUN scarb build
CMD bash -c " cd katana && \
chmod +x ./deploy_contracts_devnet.sh && \
chmod +x ./deploy_and_fund_argent_wallet.sh && \
./deploy_contracts_devnet.sh $SIGNER_ADDRESS $FOSSIL_PROCESSOR_ADDRESS $VAULT_ROUND_DURATION && \
./deploy_and_fund_argent_wallet.sh $ARGENT_ADDRESS $ARGENT_SALT $ARGENT_CONSTRUCTOR_ARG1"
./deploy_contracts_devnet.sh $SIGNER_ADDRESS $FOSSIL_PROCESSOR_ADDRESS $VAULT_ALPHA $VAULT_STRIKE $ROUND_TRANSITION_DURATION $AUCTION_DURATION $ROUND_DURATION && \
./deploy_and_fund_argent_wallet.sh $ARGENT_ADDRESS $ARGENT_SALT $ARGENT_CONSTRUCTOR_ARG1"
25 changes: 15 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
version: '3.8'
version: "3.8"

services:
pitchlake_starknet:
platform: linux/amd64
build:
context: .
args:
- SIGNER_PRIVATE_KEY=${SIGNER_PRIVATE_KEY}
- DEVNET_RPC=${DEVNET_RPC}
- SIGNER_ADDRESS=${SIGNER_ADDRESS}
- FOSSIL_PROCESSOR_ADDRESS=${FOSSIL_PROCESSOR_ADDRESS}
- VAULT_ROUND_DURATION=${VAULT_ROUND_DURATION}
- ARGENT_ADDRESS=${ARGENT_WALLET_ADDRESS}
- ARGENT_SALT=${ARGENT_WALLET_SALT}
- ARGENT_CONSTRUCTOR_ARG1=${ARGENT_WALLET_CONSTRUCTOR_ARG1}
environment:
STARKNET_PRIVATE_KEY: ${PITCHLAKE_DEPLOYER_PRIVATE_KEY}
STARKNET_RPC: ${DEVNET_RPC}
SIGNER_ADDRESS: ${PITCHLAKE_DEPLOYER_ADDRESS}
FOSSIL_PROCESSOR_ADDRESS: ${FOSSIL_ADDRESS}
VAULT_ALPHA: ${VAULT_ALPHA}
VAULT_STRIKE: ${VAULT_STRIKE}
ROUND_TRANSITION_DURATION: ${ROUND_TRANSITION_DURATION}
AUCTION_DURATION: ${AUCTION_DURATION}
ROUND_DURATION: ${ROUND_DURATION}
ARGENT_ADDRESS: ${ARGENT_WALLET_ADDRESS}
ARGENT_SALT: ${ARGENT_WALLET_SALT}
ARGENT_CONSTRUCTOR_ARG1: ${ARGENT_WALLET_CONSTRUCTOR_ARG1}
46 changes: 24 additions & 22 deletions katana/deploy_and_fund_argent_wallet.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Declare Argent contract

echo
echo
echo "============================"
echo "Deploy Argent Account"
echo "============================"
echo
echo

# Check required environment variables
if [ -z "$STARKNET_ACCOUNT" ] || [ -z "$STARKNET_RPC" ] || [ -z "$STARKNET_PRIVATE_KEY" ]; then
echo "Error: Required environment variables not set"
echo "Please ensure STARKNET_ACCOUNT, STARKNET_RPC and STARKNET_PRIVATE_KEY are set"
exit 1
echo "Error: Required environment variables not set"
echo "Please ensure STARKNET_ACCOUNT, STARKNET_RPC and STARKNET_PRIVATE_KEY are set"
exit 1
fi

echo "Environment variables:"
echo "STARKNET_ACCOUNT: $STARKNET_ACCOUNT"
echo "STARKNET_RPC: $STARKNET_RPC"
echo "STARKNET_RPC: $STARKNET_RPC"
echo "STARKNET_PRIVATE_KEY: $STARKNET_PRIVATE_KEY"
echo

Expand All @@ -26,33 +26,35 @@ ARG1=$3

# Check if all required arguments are provided
if [ $# -ne 3 ]; then
echo "Error: Did not provide all arguments"
echo "Usage: $0 <ARGENT_WALLET_ADDRESS> <ARGENT_WALLET_SALT> <ARGENT_WALLET_CONSTRUCTOR_ARG1>"
exit 1
echo "Error: Did not provide all arguments"
echo "Usage: $0 <ARGENT_WALLET_ADDRESS> <ARGENT_WALLET_SALT> <ARGENT_WALLET_CONSTRUCTOR_ARG1>"
exit 1
fi

if [ ! -f "$STARKNET_ACCOUNT" ]; then
starkli account fetch $SIGNER_ADDRESS --output $STARKNET_ACCOUNT
starkli account fetch $SIGNER_ADDRESS --output $STARKNET_ACCOUNT
fi

# Deploy Argent wallet
ARGENT_HASH=$(starkli declare --watch argent_ArgentAccount.contract_class.json --compiler-version 2.8.2 | grep -o '0x[a-fA-F0-9]\{64\}' | head -1)
echo "[Argent Wallet] Class hash declared: $ARGENT_HASH"

if starkli class-hash-at $ADDRESS; then
echo "Argent wallet already deployed at $ADDRESS"
echo "Argent wallet already deployed at $ADDRESS"
else
DEPLOYED_ARGENT_ADDRESS=$(starkli deploy --watch $ARGENT_HASH 0 $ARG1 1 --salt $SALT --not-unique | grep -o '0x[a-fA-F0-9]\{64\}' | head -1)
DEPLOYED_ARGENT_ADDRESS=$(starkli deploy --watch $ARGENT_HASH 0 $ARG1 1 --salt $SALT --not-unique | grep -o '0x[a-fA-F0-9]\{64\}' | head -1)

echo "Expected wallet address: $ADDRESS"
echo "Deployed wallet address: $DEPLOYED_ARGENT_ADDRESS"
echo "Expected wallet address: $ADDRESS"
echo "Deployed wallet address: $DEPLOYED_ARGENT_ADDRESS"

# Verify addresses match
if [ "$ADDRESS" != "$DEPLOYED_ARGENT_ADDRESS" ]; then
echo "Error: Deployed address does not match expected address"
exit 1
fi
# Verify addresses match (case-insensitive)
ADDRESS_LOWER=${ADDRESS,,}
DEPLOYED_ADDRESS_LOWER=${DEPLOYED_ARGENT_ADDRESS,,}
if [ "$ADDRESS_LOWER" != "$DEPLOYED_ADDRESS_LOWER" ]; then
echo "Error: Deployed address does not match expected address"
exit 1
fi

OUTPUT=$(starkli invoke --watch 0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7 transfer $ADDRESS 10000 0)
echo "Funded wallet $OUTPUT"
fi
OUTPUT=$(starkli invoke --watch 0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7 transfer $ADDRESS 10000 0)
echo "Funded wallet $OUTPUT"
fi
2 changes: 1 addition & 1 deletion katana/deploy_contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ echo "Class hash declared: $VAULT_HASH"

# Deploy the third contract with additional parameters and salt
echo "Deploying pitch_lake_Vault contract..."
VAULT_ADDRESS=$(starkli deploy $VAULT_HASH $FOSSILCLIENT_ADDRESS 0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7 $OPTIONROUND_HASH 5555 0 --salt 1 | grep -o '0x[a-fA-F0-9]\{64\}' | head -1)
VAULT_ADDRESS=$(starkli deploy $VAULT_HASH $FOSSILCLIENT_ADDRESS 0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7 $OPTIONROUND_HASH $VAULT_ALPHA $VAULT_STRIKE --salt 1 | grep -o '0x[a-fA-F0-9]\{64\}' | head -1)
echo "Contract deployed at: $VAULT_ADDRESS"

# Perform the first call to get the round address
Expand Down
62 changes: 30 additions & 32 deletions katana/deploy_contracts_devnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# Ensure the script stops on the first error
set -e

echo
echo
echo "============================"
echo "Deploy Pitchlake Contracts"
echo "============================"
echo
echo

# Set compiler version
COMPILER_VERSION="2.8.2"
Expand All @@ -20,35 +20,39 @@ echo "STARKNET_RPC: $STARKNET_RPC"

# Check if environment variables exist
if [ -z "$STARKNET_ACCOUNT" ] || [ -z "$STARKNET_PRIVATE_KEY" ] || [ -z "$STARKNET_RPC" ]; then
echo "Error: One or more required environment variables are missing."
exit 1
echo "Error: One or more required environment variables are missing."
exit 1
fi

# Check if all required arguments are provided
if [ $# -ne 3 ]; then
echo "Usage: $0 <SIGNER_ADDRESS> <FOSSIL_PROCESSOR_ADDRESS> <VAULT_ROUND_DURATION>"
exit 1
if [ $# -ne 7 ]; then
echo "Usage: $0 <SIGNER_ADDRESS> <FOSSIL_PROCESSOR_ADDRESS> <VAULT_ALPHA> <VAULT_STRIKE> <ROUND_TRANSITION_DURATION> <AUCTION_DURATION> <ROUND_DURATION>"
exit 1
fi

# Assign command line arguments to variables
SIGNER_ADDRESS=$1
FOSSIL_PROCESSOR_ADDRESS=$2
VAULT_ROUND_DURATION=$3
VAULT_ALPHA=$3
VAULT_STRIKE=$4
ROUND_TRANSITION_DURATION=$5
AUCTION_DURATION=$6
ROUND_DURATION=$7

# Check if deployment_addresses.env exists
if [ -f "deployment_addresses.env" ]; then
echo "Contracts already deployed"
echo "Deployment addresses:"
cat deployment_addresses.env
echo "Exiting..."
exit 0
echo "Contracts already deployed"
echo "Deployment addresses:"
cat deployment_addresses.env
echo "Exiting..."
exit 0
fi

# Check if the account file already exists
if [ ! -f "$STARKNET_ACCOUNT" ]; then
starkli account fetch $SIGNER_ADDRESS --output $STARKNET_ACCOUNT
else
echo "Acount config already exists at path $STARKNET_ACCOUNT"
starkli account fetch $SIGNER_ADDRESS --output $STARKNET_ACCOUNT
else
echo "Acount config already exists at path $STARKNET_ACCOUNT"
fi

# Declare and deploy the ETH contract
Expand All @@ -64,33 +68,27 @@ ETH_ADDRESS="0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"

# Declare the first contract
sleep 2
FOSSILCLIENT_HASH=$(starkli declare ../target/dev/pitch_lake_FossilClient.contract_class.json --compiler-version $COMPILER_VERSION | grep -o '0x[a-fA-F0-9]\{64\}' | head -1)
FOSSILCLIENT_HASH=$(starkli declare ../target/dev/pitch_lake_FossilClient.contract_class.json --compiler-version $COMPILER_VERSION --watch | grep -o '0x[a-fA-F0-9]\{64\}' | head -1)
echo "[Fossil Client] Class hash declared"

# Deploy the first contract with salt and FOSSIL_PROCESSOR_ADDRESS
sleep 2
FOSSILCLIENT_ADDRESS=$(starkli deploy $FOSSILCLIENT_HASH $FOSSIL_PROCESSOR_ADDRESS --salt 1 | grep -o '0x[a-fA-F0-9]\{64\}' | head -1)
FOSSILCLIENT_ADDRESS=$(starkli deploy $FOSSILCLIENT_HASH $FOSSIL_PROCESSOR_ADDRESS --salt 1 --watch| grep -o '0x[a-fA-F0-9]\{64\}' | head -1)
echo "[Fossil Client] Contract deployed"

# Declare the second contract
sleep 2
OPTIONROUND_HASH=$(starkli declare ../target/dev/pitch_lake_OptionRound.contract_class.json --compiler-version $COMPILER_VERSION | grep -o '0x[a-fA-F0-9]\{64\}' | head -1)
OPTIONROUND_HASH=$(starkli declare ../target/dev/pitch_lake_OptionRound.contract_class.json --compiler-version $COMPILER_VERSION --watch | grep -o '0x[a-fA-F0-9]\{64\}' | head -1)
echo "[Option Round] Class hash declared"

# Declare the third contract
sleep 2
VAULT_HASH=$(starkli declare ../target/dev/pitch_lake_Vault.contract_class.json --compiler-version $COMPILER_VERSION | grep -o '0x[a-fA-F0-9]\{64\}' | head -1)
VAULT_HASH=$(starkli declare ../target/dev/pitch_lake_Vault.contract_class.json --compiler-version $COMPILER_VERSION --watch | grep -o '0x[a-fA-F0-9]\{64\}' | head -1)
echo "[Vault] Class hash declared"

# Deploy the third contract with additional parameters and salt
sleep 2
VAULT_ADDRESS=$(starkli deploy $VAULT_HASH $FOSSILCLIENT_ADDRESS $ETH_ADDRESS $OPTIONROUND_HASH $VAULT_ROUND_DURATION 0 --salt 1 | grep -o '0x[a-fA-F0-9]\{64\}' | head -1)
VAULT_ADDRESS=$(starkli deploy $VAULT_HASH $FOSSILCLIENT_ADDRESS $ETH_ADDRESS $OPTIONROUND_HASH $VAULT_ALPHA $VAULT_STRIKE $ROUND_TRANSITION_DURATION $AUCTION_DURATION $ROUND_DURATION --salt 1 --watch | grep -o '0x[a-fA-F0-9]\{64\}' | head -1)
echo "[Vault] Contract deployed"


# Set pricing data for first round to start
echo "Fulfilling 1st round job request..."
sleep 2
OUTPUT6=$(starkli call $VAULT_ADDRESS get_request_to_start_first_round)
CALLDATA1=$(echo "$OUTPUT6" | tr -d '[]"' | tr ',' ' ' | tr -s '[:space:]' | sed 's/^ *//; s/ *$//')
echo $CALLDATA1
Expand All @@ -99,10 +97,10 @@ starkli invoke --watch $FOSSILCLIENT_ADDRESS fossil_callback $CALLDATA1 0x6 0x02
echo "Finished"

{
echo "ETH_ADDRESS=$ETH_ADDRESS"
echo "FOSSILCLIENT_ADDRESS=$FOSSILCLIENT_ADDRESS"
echo "VAULT_ADDRESS=$VAULT_ADDRESS"
} > deployment_addresses.env
echo "ETH_ADDRESS=$ETH_ADDRESS"
echo "FOSSILCLIENT_ADDRESS=$FOSSILCLIENT_ADDRESS"
echo "VAULT_ADDRESS=$VAULT_ADDRESS"
} >deployment_addresses.env

echo "Deployment addresses"
cat deployment_addresses.env
cat deployment_addresses.env
12 changes: 12 additions & 0 deletions scripts/abi/optionRound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,18 @@ export const ABI = [
{
"name": "pricing_data",
"type": "pitch_lake::option_round::interface::PricingData"
},
{
"name": "round_transition_duration",
"type": "core::integer::u64"
},
{
"name": "auction_duration",
"type": "core::integer::u64"
},
{
"name": "round_duration",
"type": "core::integer::u64"
}
]
},
Expand Down
Loading

0 comments on commit 81bbd8a

Please sign in to comment.