Created
June 27, 2023 14:03
-
-
Save DanielVF/322cc1111ffd808464b05eb7b54e0fe9 to your computer and use it in GitHub Desktop.
Compare deployed contracts to version in local repo
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
#!/opt/homebrew/bin/fish | |
# Usage: | |
# ./compare_live.fish CONTRACT_ADDRESS | |
# Config | |
set SRC_DIR /PATH/TO/REPO/CONTRACTS | |
set OZ_DIR $SRC_DIR/node_modules | |
# Download | |
rm -rf /tmp/thecontract | |
cast etherscan-source -d thecontract $argv | |
cd thecontract/*/ | |
# Compare | |
function contract_compare; | |
set DIR $argv[1] | |
set src_file $argv[2] | |
echo ">> $src_file"; | |
git diff --color-words --no-index ./$src_file $DIR/$src_file; | |
end | |
for i in (find . | grep '.sol' | grep '^\./contracts' | xargs -n 1); contract_compare "$SRC_DIR" "$i"; end | |
for i in (find . | grep '.sol' | grep '^\./@openzeppelin' | xargs -n 1); contract_compare "$OZ_DIR" "$i"; end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment