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

fix: handle result from make_request() #78

Merged
merged 3 commits into from
Aug 8, 2024
Merged

fix: handle result from make_request() #78

merged 3 commits into from
Aug 8, 2024

Conversation

antazoey
Copy link
Member

@antazoey antazoey commented Aug 8, 2024

What I did

I tried simply connecting to base sepolia using alchemy but I was unable to make calls on contracts because it was trying to turn HexBytes(dict)

realized it was because ape-alchemy overrides make_request and does different stuff

How I did it

How to verify it

should get this know:

(ape08) ➜  chess.vy git:(main) ape console --network base:sepolia:alchemy

In [1]: contract = Contract("0x6fC96122dC615DeE5F988B0d03BBA50aEf5B8Ae2")

In [2]: account = accounts.load("metamask0")

In [3]: contract.knight_const()
Out[3]: 3

Checklist

  • Passes all linting checks (pre-commit and CI jobs)
  • New test cases have been added and are passing
  • Documentation has been updated
  • PR title follows Conventional Commit standard (will be automatically included in the changelog)

@antazoey antazoey enabled auto-merge (squash) August 8, 2024 00:29
@antazoey antazoey requested a review from fubuloubu August 8, 2024 00:29
@@ -203,6 +203,11 @@ def make_request(self, rpc: str, parameters: Optional[Iterable] = None) -> Any:
)
raise cls(message) from err

if isinstance(result, dict) and (res := result.get("result")):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bugfix here, does the same as ape-ethereum, thus causing eth_call (and other RPCs) to function correctly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnson2427 it processes it here (like ape core does) and returns the extracted value

this was kind of a regression because as part of the optimizations in core, switched the base class to use make_request more, causing us to reach this bug

@@ -184,7 +184,7 @@ def create_access_list(
def make_request(self, rpc: str, parameters: Optional[Iterable] = None) -> Any:
parameters = parameters or []
try:
return self.web3.provider.make_request(RPCEndpoint(rpc), parameters)
result = self.web3.provider.make_request(RPCEndpoint(rpc), parameters)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't want this result, I'll approve

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the result is returned later on after some processing!

Copy link

@johnson2427 johnson2427 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't want that returned, and you just want that RPC endpoint to be called, then you can merge. Just want to make sure that's what you want to do

@antazoey antazoey merged commit b58fcb3 into main Aug 8, 2024
26 checks passed
@antazoey antazoey deleted the fix/make-request branch August 8, 2024 00:39
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.

2 participants