Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: include proxy ABIs in contract-type ABIs #2413

Merged
merged 11 commits into from
Dec 12, 2024

Conversation

antazoey
Copy link
Member

@antazoey antazoey commented Dec 11, 2024

What I did

fixes: #1249

I could no longer call masterCopy() in a safe proxy since #2400
I not 100% sure why but this PR fixes it.
I think before, it was never actually recognized as a safe proxy...

Anyway, the masterCopy() ABI is sort of hidden.
And proxy ABIs in general (that were not hidden) were not included in the contract-types ABIs you could call.
This PR makes both of those things work.

How I did it

  1. When detecting proxies, allow a place for ABIs to be included (not in the cache but just in the API). This helps masterCopy() be included.
  2. When looking up a contract-type, also check to see if there is proxy info. If there is, it includes some of the ABIs if it is not already there. This way, past cached contract types (safes) will also suddenly work when calling .masterCopy().
  3. Also when caching a deployment, such as local testing environment using Safe (ape-safe's tests), include the ABIs so the returned instance can use masterCopy()

Can get ape-safe tests to pass again, altho this all started because was debuggin a different problem...

Show it Working

In [7]: contract = Contract("0x4Fabb145d64652a948d72533023f6E7A623C7C53")

In [8]: contract.implementation
Out[8]: implementation() -> address


In [9]: contract.balanceOf
Out[9]: balanceOf(address _addr) -> uint256

Example of Safe!

First, delete any cached contract. This also deletes the proxy info that is cached, you can check!

In [1]: del chain.contracts['0x872Df5f6CF2C2Eaa9e7511AB079D263AB8fdc79f']

Next, get this contract as if it is the first time! Notice it uses Etherscan...

In [2]: contract = Contract("0x872Df5f6CF2C2Eaa9e7511AB079D263AB8fdc79f")
contract.

Show you can call both proxy ABIs as well as the actual safe ABIs:

In [3]: contract.masterCopy()
Out[3]: '0xfb1bffC9d739B8D520DaF37dF666da4C687191EA'

In [4]: contract.setGuard
Out[4]: setGuard(address guard)

Checklist

  • All changes are completed
  • New test cases have been added
  • Documentation has been updated

fubuloubu
fubuloubu previously approved these changes Dec 12, 2024
@antazoey antazoey marked this pull request as draft December 12, 2024 16:05
@antazoey antazoey force-pushed the feat/include-proxy-abi branch from f939082 to d57bf74 Compare December 12, 2024 17:01
@antazoey antazoey marked this pull request as ready for review December 12, 2024 17:01
@antazoey antazoey force-pushed the feat/include-proxy-abi branch from 35e459a to 2ecceb4 Compare December 12, 2024 18:06
@antazoey antazoey merged commit fdbbb07 into ApeWorX:main Dec 12, 2024
18 checks passed
@antazoey antazoey deleted the feat/include-proxy-abi branch December 12, 2024 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Merge missing proxy ABI methods/events into contract types for proxies
3 participants