-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathrun-fork.sh
executable file
·48 lines (35 loc) · 1.21 KB
/
run-fork.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
#!/bin/bash
dotenv=$(dirname $0)/../.env
if [ -f "${dotenv}" ]; then
source ${dotenv}
fi
username=${TENDERLY_USERNAME}
if [ -n "${TEST_FORK}" ]; then
project=${TENDERLY_TEST_PROJECT}
else
project=${TENDERLY_PROJECT}
fi
echo "Creating a Mainnet Tenderly Fork... "
echo
TENDERLY_FORK_API="https://api.tenderly.co/api/v1/account/${username}/project/${project}/fork"
cleanup() {
if [ -n "${fork_id}" ] && [ -n "${TEST_FORK}" ]; then
echo "Deleting a fork ${fork_id} from ${username}/${project}..."
echo
curl -sX DELETE "${TENDERLY_FORK_API}/${fork_id}" \
-H "Content-Type: application/json" -H "X-Access-Key: ${TENDERLY_ACCESS_KEY}"
fi
}
trap cleanup TERM EXIT
fork_id=$(curl -sX POST "${TENDERLY_FORK_API}" \
-H "Content-Type: application/json" -H "X-Access-Key: ${TENDERLY_ACCESS_KEY}" \
-d '{"network_id": "1"}' | jq -r '.simulation_fork.id')
echo "Created Tenderly Fork ${fork_id} at ${username}/${project}..."
echo
# Create a new dir for the deploy script files and copy them there
rm -rf deployments/tenderly && cp -rf deployments/mainnet/. deployments/tenderly
command="TENDERLY_FORK_ID=${fork_id} ${@:1}"
echo "Running:"
echo
echo ${command}
eval ${command}