-
Notifications
You must be signed in to change notification settings - Fork 40
/
init.sh
executable file
·55 lines (45 loc) · 1.9 KB
/
init.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
55
#!/bin/bash
# NOTE: This can only be run against an anvil-node. Production initialization needs to be done in the spell.
set -e
for ARGUMENT in "$@"
do
KEY=$(echo "$ARGUMENT" | cut -f1 -d=)
VALUE=$(echo "$ARGUMENT" | cut -f2 -d=)
if [ "$VALUE" = "" ]; then
continue
fi
case "$KEY" in
config) export FOUNDRY_SCRIPT_CONFIG="$VALUE" ;;
d3m) D3M="$VALUE" ;;
*)
esac
done
[[ -n "$FOUNDRY_SCRIPT_CONFIG" ]] || {
echo "Please specify the D3M configration JSON. Example: ./init.sh config=aave";
exit 1;
}
[[ -n "$MCD_PAUSE_PROXY" ]] || {
echo "Please set MCD_PAUSE_PROXY";
exit 1;
}
[[ -n "$FOUNDRY_ROOT_CHAINID" ]] || {
[[ -n $ETH_RPC_URL ]] || {
echo "Please set FOUNDRY_ROOT_CHAINID (1 or 5) or ETH_RPC_URL";
exit 1;
}
FOUNDRY_ROOT_CHAINID="$(cast chain-id)"
}
[[ "$FOUNDRY_ROOT_CHAINID" == "1" ]] || [[ "$FOUNDRY_ROOT_CHAINID" == "5" ]] || {
echo "Invalid chainid of $FOUNDRY_ROOT_CHAINID. Please set your forking environment via ETH_RPC_URL or manually by defining FOUNDRY_ROOT_CHAINID (1 or 5)."
exit 1;
}
[[ "$FOUNDRY_ROOT_CHAINID" == "1" ]] && echo "Initializing '$FOUNDRY_SCRIPT_CONFIG' D3M on Mainnet"
[[ "$FOUNDRY_ROOT_CHAINID" == "5" ]] && echo "Initializing '$FOUNDRY_SCRIPT_CONFIG' D3M on Goerli"
export FOUNDRY_ROOT_CHAINID
FOUNDRY_SCRIPT_DEPS_TEXT=$(jq -sc ".[0] * .[1]" script/output/"$FOUNDRY_ROOT_CHAINID"/core-latest.json script/output/"$FOUNDRY_ROOT_CHAINID"/"$D3M"-latest.json)
export FOUNDRY_SCRIPT_DEPS_TEXT
unset ETH_FROM
cast rpc anvil_setBalance "$MCD_PAUSE_PROXY" 0x10000000000000000 > /dev/null
cast rpc anvil_impersonateAccount "$MCD_PAUSE_PROXY" > /dev/null
forge script script/D3MInit.s.sol:D3MInitScript --use solc:0.8.14 --rpc-url "$ETH_RPC_URL" --broadcast --unlocked --sender "$MCD_PAUSE_PROXY"
cast rpc anvil_stopImpersonatingAccount "$MCD_PAUSE_PROXY" > /dev/null