Giter Site home page Giter Site logo

Comments (5)

reedsa avatar reedsa commented on September 12, 2024 2

Following up, web3.types will not be updated to include the "error" Literal on the ABIFunction type. ABIError is preferred.

from web3.py.

reedsa avatar reedsa commented on September 12, 2024 1

@avoiney-ledger sorry for the back and forth, I had another chat with the team and we'll implement the error type in the web3.types module in v6. Instead of adding "error" to the ABIFunction type, we decided to add ABIError as a type and it will be added as another valid ABIElement. Look for that in the next v6 release!

from web3.py.

reedsa avatar reedsa commented on September 12, 2024

There are new types for ABIs available in ethereum/eth-typing for this purpose. You can get around this by using the new types and casting your ABI to the new type.

from eth_typing import ABI

abi: ABI = { ... }

c: Contract = w3.eth.contract(
    address="0x48C7f48622a2C31FC72B326332cF1e2357C8EF30", abi=abi
)

for el_abi in cast(ABI, c.abi):
    if el_abi["type"] == "error":
        print(
            f"Error: {el_abi['name']}({', '.join([arg['name'] for arg in el_abi['inputs']])})"
        )

Using ABI from web3.typing will show a type error when referencing the "error" type on an ABIFunction.

Non-overlapping equality check (left operand type: "Literal['fallback', 'receive']", right operand type: "Literal['error']")Mypy[comparison-overlap](https://mypy.readthedocs.io/en/latest/_refs.html#code-comparison-overlap)
(variable) el_abi: Any | ABIFunction | ABIEvent

We could add "error" as a valid ABIFunction type in web3.types to mitigate the typing error. Do you agree with adding that @kclowes @fselmo @pacrob ?

from web3.py.

avoiney-ledger avatar avoiney-ledger commented on September 12, 2024

Ok thanks for this detailed answer!

from web3.py.

avoiney-ledger avatar avoiney-ledger commented on September 12, 2024

So cool thanks! I will look forward for it!

from web3.py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.