Skip to content

Instantly share code, notes, and snippets.

@DanielVF
Created June 27, 2023 14:03
Show Gist options
  • Save DanielVF/322cc1111ffd808464b05eb7b54e0fe9 to your computer and use it in GitHub Desktop.
Save DanielVF/322cc1111ffd808464b05eb7b54e0fe9 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