Import ABI from json, with as const #1084
Replies: 5 comments 6 replies
-
Unfortunately TypeScript doesn't support this right now. This is something we are very interested in supporting and are looking into alternatives. Curious: Where do you get your ABIs from right now (block explorer, forge build, etc.)? |
Beta Was this translation helpful? Give feedback.
-
I think this is a great feature and I appreciate you adding it in it's current form, that said It's quite un-usable as it's basically the same as type casting. Having to type abi as js array in each file where the hook is used is not very practical, especially if ABI is huge and during development while ABI is changing often. Perhaps more of a useDapp + typechain approach can be used instead? |
Beta Was this translation helpful? Give feedback.
-
Is there perhaps some script we can use to generate an abi from JSON to a format we can import and pass to wagmi? Otherwise I don't really see a way to use this new feature without duplicating an ABI code in each file where a hook is used? Am I missing something? |
Beta Was this translation helpful? Give feedback.
-
One thing I noticed is that types are getting lost if I re-import abi in index.ts
|
Beta Was this translation helpful? Give feedback.
-
I forked hardhat's plugin 'hardhat-abi-exporter' and setup a default option ( |
Beta Was this translation helpful? Give feedback.
-
Is it possible to import an ABI from a json file, with as const assertion?
I can get it working if i copy paste my ABI into a .ts file, but struggling when reading from a json.
Beta Was this translation helpful? Give feedback.
All reactions