You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While rendering JS client for IDL for solana program dump vmT2hAx4N2U6DyjYxgQHER4VGC8tHJCfHNsSepBKCJZ,
I got the following: CodamaError: Unrecognized Anchor IDL type [{"generic":"T"}].
import{renderVisitor}from'@codama/renderers-js';import{createFromRoot}from'codama';import{rootNodeFromAnchor}from'@codama/nodes-from-anchor';importfsfrom'fs';importpathfrom'path';// solana program dump vmT2hAx4N2U6DyjYxgQHER4VGC8tHJCfHNsSepBKCJZconstanchorIdl=JSON.parse(fs.readFileSync('anchor-idl.json','utf8'));constcodama=createFromRoot(rootNodeFromAnchor(anchorIdl));constpathToGeneratedFolder=path.join(__dirname,'clients','rust','src','generated');constoptions={};// See below.codama.accept(renderVisitor(pathToGeneratedFolder,options));
The text was updated successfully, but these errors were encountered:
Oh yeah that's because Codama doesn't support generic types. I thought there was an issue for this already but I couldn't find it.
The main reason Codama doesn't support generics (yet?) is because the Codama spec aims to be language agnostic. It describes high-level program logic and binary layouts regardless of how the program was written. It also means it can be used to render client code for any languages. Many of whom don't support generics. So by adding generics support to the spec, we are limiting the set of languages Codama can work with.
Anchor doesn't need to worry about this because it limits itself to Rust on the program side and JavaScript on the client side.
A potential solution to this would be to force a "fallback" type for generic types that can be used when generics are not supported by the language. But this wouldn't help here with the conversion from Anchor.
While rendering JS client for IDL for
solana program dump vmT2hAx4N2U6DyjYxgQHER4VGC8tHJCfHNsSepBKCJZ
,I got the following:
CodamaError: Unrecognized Anchor IDL type [{"generic":"T"}].
The text was updated successfully, but these errors were encountered: