Comments (7)
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.
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.
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.
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.
@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.
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.
Discussion created here.
from abitype.
Related Issues (16)
- Conflict with Typescript version HOT 2
- bug: tuple[] generated type is incorrect? HOT 3
- bug: bytes32 type is too strict HOT 5
- bug: uint and uint256 parsed different in EIP-712 Typed Data event signatures HOT 5
- test issue ci workflow HOT 1
- bug: parseAbi throws type error HOT 9
- Error when build in Nextjs 12.1.6 HOT 6
- Identifiers with `$` are not recognized HOT 2
- TS build error: instantiation is excessively deep HOT 10
- Extra space in formatAbi return type HOT 4
- `FormatAbiParameter` infers incorrect string on nested unnamed `components` HOT 1
- Abi `Zod` schema does not infer to `Abi` type HOT 8
- Compilation issue with TypeScript 5.2.2 HOT 9
- Unable to resolve "abitype/zod" in Expo React Native HOT 3
- `(encode|parse)AbiParameters` detects types correctly when passed as string but not array HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from abitype.