-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
29 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,30 @@ | ||
#!/bin/bash | ||
|
||
FOUNDRY_COMMAND="$1" | ||
SOLC_PATH="--use /usr/local/bin/solc" | ||
FOUNDRY_DIRECTORY="--root $2" | ||
FOUNDRY_SCRIPT="$3" | ||
main() { | ||
local FOUNDRY_COMMAND="" | ||
local FOUNDRY_DIRECTORY="" | ||
local FOUNDRY_SCRIPT="" | ||
local SOLC_PATH="--use /usr/local/bin/solc" | ||
|
||
if [ "$FOUNDRY_COMMAND" = "script" ] && [ -z "$FOUNDRY_SCRIPT" ]; then | ||
echo "Error: 'foundry-script' is required when 'foundry-command' is 'script'" | ||
exit 1 | ||
fi | ||
# Parse named arguments | ||
while [[ "$#" -gt 0 ]]; do | ||
case $1 in | ||
--foundry-command) FOUNDRY_COMMAND="$2"; shift ;; | ||
--foundry-directory) FOUNDRY_DIRECTORY="--root $2"; shift ;; | ||
--foundry-script) FOUNDRY_SCRIPT="$2"; shift ;; | ||
*) echo "Unknown parameter passed: $1"; exit 1 ;; | ||
esac | ||
shift | ||
done | ||
|
||
if [ "$FOUNDRY_COMMAND" = "script" ]; then | ||
exec forge script $FOUNDRY_SCRIPT $SOLC_PATH $FOUNDRY_DIRECTORY --fork-url http://localhost:8545 --broadcast -vvvv | ||
else | ||
exec forge $FOUNDRY_COMMAND $SOLC_PATH $FOUNDRY_DIRECTORY | ||
fi | ||
if [ "$FOUNDRY_COMMAND" = "script" ] && [ -z "$FOUNDRY_SCRIPT" ]; then | ||
echo "Error: 'foundry-script' is required when 'foundry-command' is 'script'" | ||
exit 1 | ||
fi | ||
|
||
if [ "$FOUNDRY_COMMAND" = "script" ]; then | ||
exec forge script $FOUNDRY_SCRIPT $SOLC_PATH $FOUNDRY_DIRECTORY --fork-url http://localhost:8545 --broadcast -vvvv | ||
else | ||
exec forge $FOUNDRY_COMMAND $SOLC_PATH $FOUNDRY_DIRECTORY | ||
fi | ||
} |