-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_salts.sh
executable file
·54 lines (43 loc) · 1.38 KB
/
test_salts.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
# Usage:
# ./test_salts.sh --saltKey <salt key> --envFile <.env>
# Iterate through named arguments
# Source: https://unix.stackexchange.com/a/388038
while [ $# -gt 0 ]; do
if [[ $1 == *"--"* ]]; then
v="${1/--/}"
declare $v="$2"
fi
shift
done
# Get the name of the .env file or use the default
ENV_FILE=${envFile:-".env"}
echo "Sourcing environment variables from $ENV_FILE"
# Load environment file
set -a # Automatically export all variables
source $ENV_FILE
set +a # Disable automatic export
# Check that the CHAIN environment variable is set
if [ -z "$CHAIN" ]
then
echo "CHAIN environment variable is not set. Please set it in the .env file or provide it as an environment variable."
exit 1
fi
# Check if saltKey is specified
if [ -z "$saltKey" ]
then
echo "No salt key specified. Provide the salt key after the --saltKey flag."
exit 1
fi
echo "Using chain: $CHAIN"
echo "Using RPC at URL: $RPC_URL"
echo "Salt key: $saltKey"
salt_file="./script/salts/salts.json"
salt_tmp_file="./script/salts/salts.json.tmp"
# Clear the salts for the specified salt key
if [ -f $salt_file ]; then
echo "Clearing old values for salt key: $saltKey"
jq "del(.\"Test_$saltKey\")" $salt_file > $salt_tmp_file && mv $salt_tmp_file $salt_file
fi
# Generate bytecode
forge script ./script/salts/test/TestSalts.s.sol:TestSalts --sig "generate(string,string)()" $CHAIN $saltKey