coral-xyz / anchor

⚓ Solana Sealevel Framework
https://anchor-lang.com
Apache License 2.0
3.6k stars 1.32k forks source link

IDL json output casing doesn't match TS output #1513

Closed asktree closed 7 months ago

asktree commented 2 years ago

on anchor 0.20.1

left: idl JSON output right: idl typescript output

image

what i expected i expected these to be the same

what happened instead they have different casing and yes this does seem to cause errors. as a result I have to do this:

image

sorry if this is a known issue. my code is private but if anyone wants to repro i can add you and let you poke around.

paul-schaaf commented 2 years ago

Im not sure I agree with it but Ive found that this is intentional

https://github.com/project-serum/anchor/blob/04b824773621d06cb3d5da6279ff2fa6046f2e68/cli/src/template.rs#L34

asktree commented 2 years ago

@paul-schaaf yeah seems that the change in casing is intentional, but is the discrepancy?

asktree commented 2 years ago

Using anchor 0.22 I seem to no longer get errors due to this discrepancy

paul-schaaf commented 2 years ago

the discrepancy still exists for me on 0.22.1 and Ive found out that there should be no discrepancy

paul-schaaf commented 2 years ago

reopening this because we are reverting #1609 (#1604) because #1609 causes const IDL to not have the <MyProgram> type. Not clear yet whether we just leave it like this in the long term

ShaunSHamilton commented 1 year ago

I am encountering:

IdlError: Type not found: {"type":{"defined":"Player"}}
    at Function.fieldLayout (/home/shauh/anch/node_modules/@coral-xyz/anchor/src/coder/borsh/idl.ts:100:19)
image

This does not seem to be just a type error.

zhe-t commented 1 year ago

Getting this too

acheroncrypto commented 7 months ago

Fixed in https://github.com/coral-xyz/anchor/pull/2824.