Giter Site home page Giter Site logo

Comments (7)

Raiden1411 avatar Raiden1411 commented on May 22, 2024 1

I have an idea that could make this work. I am testing it out and if it works I wil create a discussion on viem since I think the topic that we are discussing is more appropriate there since here we dont control those functions types here.

from abitype.

Raiden1411 avatar Raiden1411 commented on May 22, 2024

image

This means if you don't define a state mutability (view, pure, payable) in your function or constructor, then the stateMutability will be inferred as nonpayable meaning that the stateMutability will always be present on the abi.
I don't think I've seen an compiled abi without the stateMutability property on it, either as a function or constructor.

Your suggested fix does work. So I will let @tmm share his thoughts on the matter.

from abitype.

tmm avatar tmm commented on May 22, 2024

Agree with @Raiden1411's comment. @chenxsan Where did you get the ABI from? (block explorer, compiler output, etc.)

Going to close this out as expected behavior. Can discuss further once we know where the ABI came from.

from abitype.

chenxsan avatar chenxsan commented on May 22, 2024

Agree with @Raiden1411's comment. @chenxsan Where did you get the ABI from? (block explorer, compiler output, etc.)

Going to close this out as expected behavior. Can discuss further once we know where the ABI came from.

Interesting, I get it from a canto explorer, see https://tuber.build/address/0x990efF367C6c4aece43c1E98099061c897730F27/contracts#address-tabs, that's when I found type inference won't work in my case.

Btw, let's say stateMutability is required for constructor, then is it possible to report error about the type of inline abi? Obviously { type: 'constructor', inputs: [ { type: 'address', name: 'token_addr' }, { type: 'address', name: 'art_proxy' }, ], } isn't valid per AbiConstructor, it would be great typescript can report it. Otherwise we have to dig the problem ourselves.

from abitype.

Raiden1411 avatar Raiden1411 commented on May 22, 2024

@chenxsan If you take the source code from that link and compile it in remix, you will see that the stateMutability gets placed on the constructor's abi. You can also use the IsAbi type helper to check if the abi that you are using is within the abi spec.
Using your example, you will see that when using the type helper, it results in false.

@tmm could possibly make sense in bubbling up the error so that folks get the error message as the (function|event|error) name autocomplete suggestion, given that there are no throw types. Let me know what you think.

from abitype.

tmm avatar tmm commented on May 22, 2024

Yeah, down if there's an easy way to bubble it up! Think it might be challenging the way things are currently set up since we fall back if it's not an ABI with readonly unknown[].

from abitype.

Raiden1411 avatar Raiden1411 commented on May 22, 2024

Discussion created here.

from abitype.

Related Issues (16)

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.