-
Notifications
You must be signed in to change notification settings - Fork 791
abigen is intolerant of duplicate names with different casing #571
Comments
Nice catch, this is similar to #548 and should be fixed with the same approach. In the meantime, you should be able to prevent this with abigen!(StakedOHM,
"https://etherscan.io/address/0x04f2694c8fcee23e8fd0dfea1d4f5bb8c352111f",
methods {
INDEX() as alias_for_this_function_name;
}
); Or in your case, since you use the builder use the |
@casualjim could you please check that the issue is no longer present in master? |
There is progress: different error, but still an issue:
|
@casualjim abigen!(
StakedOHM,
"etherscan:0x04f2694c8fcee23e8fd0dfea1d4f5bb8c352111f"
); compiles and generates fn index()
fn INDEX() did you update with |
@casualjim what's the exact ABI you're using? |
I did update to master, I verified the commit hashes after running I think maybe some local cache needed to be invalidated. It works now! And it appears that the etherscan stuff now also works again. |
I used a downloaded version, because when I was trying this there was an issue with downloading from etherscan through ethers. I used a json structure like this: [
{
"network": "ethereum",
"symbol": "sOHM",
"typeName": "StakedOHM",
"filename": "staked_ohm",
"address": "0x04f2694c8fcee23e8fd0dfea1d4f5bb8c352111f"
},
] in combination with this download script: set -eu -o pipefail
declare -A explorers=( ["ethereum"]="etherscan.io" ["polygon"]="polygonscan.com" ["avalanche"]="snowtrace.io" )
declare -A apikeys=( ["ethereum"]="$ETHERSCAN_API_KEY" ["polygon"]="$POLYGONSCAN_API_KEY" ["avalanche"]="$SNOWTRACE_API_KEY" )
download::abi() {
local explorer
local filename
local address
local network
network="$(jq -r .network <<< "$1")"
explorer="${explorers[$network]}"
address="$(jq -r .address <<< "$1")"
filename="$(jq -r .filename <<< "$1")"
>&2 echo "downloading $(jq -r .typeName <<< "$1") $(jq -r .network <<< "$1") ABI"
url="https://api.${explorer}/api?"
url="${url}module=contract&action=getabi"
url="${url}&address=${address}"
url="${url}&apikey=${apikeys[$network]}"
curl -LSs "${url}" | jq -r .result | jq > "abi/${filename}.json"
}
main() {
readarray -t contracts < <(jq -c '.[]' ./contractdeps.json)
for item in "${contracts[@]}"; do
download::abi "$item"
done
}
main "$@" |
Version
https://github.com/gakonst/ethers-rs#906c504f
Platform
linux
Description
Abigen is intolerant of identifiers that have the same name but differ in casing.
For example the names
index
andINDEX
both appear in the sOHM contract: 0x04f2694c8fcee23e8fd0dfea1d4f5bb8c352111fI tried this code:
I expected to see this happen: the generated code compiles
Instead, this happened:
The text was updated successfully, but these errors were encountered: