Skip to content

Instantly share code, notes, and snippets.

@frenchypeanut
Forked from DanielVF/compare_live.fish
Created June 27, 2023 16:41
Show Gist options
  • Save frenchypeanut/3604aab63f93aaa4c1a09ccf0aa5d8cb to your computer and use it in GitHub Desktop.
Save frenchypeanut/3604aab63f93aaa4c1a09ccf0aa5d8cb to your computer and use it in GitHub Desktop.
Compare deployed contracts to version in local repo
#!/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