-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Trajan0x <[email protected]>
- Loading branch information
Showing
4 changed files
with
36 additions
and
99 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
# This script flattens Solidity contracts and saves them in ./flattened | ||
# The existing content of ./flattened is removed | ||
# This tool takes both globs and filenames as the list of arguments and flattens everything | ||
# Usage: ./script/sh/flatten.sh contracts/**.sol contracts/client/TestClient.sol <...> | ||
|
||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
NC='\033[0m' # No Color | ||
|
||
# Check if arguments were supplied | ||
if [ $# -eq 0 ]; then | ||
echo -e "${RED}Error: provide globs/filenames of the contracts to flatten!${NC}" | ||
exit 1 | ||
fi | ||
|
||
# First, we remove the existing flattened files | ||
rm -rf ./flattened | ||
|
||
# Track the amount of flattened files for the final report | ||
count=0 | ||
# Then, we iterate over the supplied arguments | ||
# If any argument was a glob, this will iterate over the files it specifies | ||
for var in "$@"; do | ||
# Strip contract name "Abc.sol" from the path | ||
fn=$(basename "$var") | ||
# Flatten the file and save it in ./flattened | ||
# Make sure that flattened contracts base names are unique! | ||
forge flatten "$var" -o "./flattened/$fn" | ||
((++count)) | ||
done | ||
|
||
echo -e "${GREEN}Files flattened: $count${NC}" |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
../../make/scripts/flatten.sh |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../make/scripts/flatten.sh |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
../../make/scripts/flatten.sh |