Created
July 24, 2023 15:39
-
-
Save 0age/76e44499cc7f077e1831a031f116ae37 to your computer and use it in GitHub Desktop.
shell script to examine and deprecate a Wyvern user proxy via `cast`
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
##### SUMMARY ##### | |
# | |
# to brick a user proxy, you can upgrade to this contract then call the proxy: | |
# https://etherscan.io/address/0x00000000008fe2c0c1795fe9a8e2c1d3f913b35d#code | |
# | |
# Step 1: find the proxy for the account | |
# proxy registry: 0xa5409ec958C83C3f309868babACA7c86DCB077c1 | |
# call: proxies(address) where address = user's account | |
# | |
# Step 2: upgrade the proxy and call it to renounce ownership | |
# upgradeToAndCall(address implementation, bytes data) | |
# 0x4f1ef28600000000000000000000000000000000008fe2c0c1795fe9a8e2c1d3f913b35d00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000 | |
# | |
# example tx: https://etherscan.io/tx/0x86a5d29d7088476c4bac3385589b8c352ad22167782aed9b0f3552c88d975ff8 | |
# | |
##### USAGE ##### | |
# | |
# cast must be installed to use the script below: | |
# $ curl -L https://foundry.paradigm.xyz | bash | |
# | |
# example usage (leave the derivation path off to provide a private key): | |
# $ deprecate_wyvern_user_proxy 0x0734d56DA60852A03e2Aafae8a36FFd8c12B32f1 https://eth.llamarpc.com "m/44'/60'/0'/2" | |
function deprecate_wyvern_user_proxy () { | |
ADDRESS=$1 | |
RPC=$2 | |
DERIVATION_PATH=$3 | |
REGISTRY=0xa5409ec958C83C3f309868babACA7c86DCB077c1 | |
NULL_ADDRESS=0x0000000000000000000000000000000000000000 | |
PROXY=$(cast parse-bytes32-address $(cast call -r $RPC $REGISTRY "proxies(address)" $ADDRESS)) | |
if [ "$PROXY" = "$NULL_ADDRESS" ] | |
then | |
echo "No proxy found for $ADDRESS"; | |
return 1 | |
fi | |
echo "Proxy: "$PROXY""; | |
ORIGINAL=0xF9e266af4BcA5890e2781812cc6a6E89495a79f2 | |
DEPRECATED=0x00000000008FE2c0C1795Fe9A8e2C1D3F913b35d | |
IMPLEMENTATION=$(cast parse-bytes32-address $(cast call -r $RPC $PROXY "implementation()")) | |
if [ "$IMPLEMENTATION" = "$ORIGINAL" ] | |
then | |
echo "Implementation: "$IMPLEMENTATION" (original)"; | |
elif [ "$IMPLEMENTATION" = "$DEPRECATED" ] | |
then | |
echo "Implementation: "$IMPLEMENTATION" (deprecated)"; | |
else | |
echo "Implementation: "$IMPLEMENTATION" (unknown)"; | |
fi | |
OWNER=$(cast parse-bytes32-address $(cast call -r $RPC $PROXY "proxyOwner()")) | |
if [ "$OWNER" = "$ADDRESS" ] | |
then | |
echo "Owner: "$OWNER" (owned)"; | |
elif [ "$OWNER" = "$NULL_ADDRESS" ] | |
then | |
echo "Owner: "$OWNER" (burned)"; | |
return 0 | |
else | |
echo "Owner: "$OWNER" (OWNED BY ANOTHER ACCOUNT)"; | |
return 1 | |
fi | |
echo "Preparing transaction to deprecate proxy..." | |
if [[ -z "$DERIVATION_PATH" ]]; then | |
cast send -i --from $ADDRESS -r $RPC $PROXY 0x4f1ef28600000000000000000000000000000000008fe2c0c1795fe9a8e2c1d3f913b35d00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000 | |
else | |
cast send --ledger --from $ADDRESS --mnemonic-derivation-path $DERIVATION_PATH -r $RPC $PROXY 0x4f1ef28600000000000000000000000000000000008fe2c0c1795fe9a8e2c1d3f913b35d00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000 | |
fi | |
if [[ $? -eq 0 ]]; then | |
echo "Done." | |
else | |
echo "Error." | |
fi | |
return 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment