Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ts: Automatically convert legacy IDLs #3238

Open
ngundotra opened this issue Sep 10, 2024 · 7 comments
Open

ts: Automatically convert legacy IDLs #3238

ngundotra opened this issue Sep 10, 2024 · 7 comments

Comments

@ngundotra
Copy link
Contributor

That way explorers have easy access to same functionality as in #3009

@acheroncrypto
Copy link
Collaborator

Yep, we should do it. The Rust conversion should also work in WASM, so maybe we can use that instead rather than duplicating the logic.

@ngundotra
Copy link
Contributor Author

I think I'd prefer vanilla TS so I don't have to think about where it runs.

Example port I wrote for TS: solana-labs/explorer#374

@acheroncrypto
Copy link
Collaborator

solana-labs/explorer#374 looks great! It would be helpful to support it from Anchor itself for other people to also benefit from it. Would you like to create a PR?

@ngundotra
Copy link
Contributor Author

Yes I can create a PR. I will note that in order to get legacy IDLs supported, I had to prune unused types after formatting them to the new spec. Is this expected behavior? If I don't do this, an error is thrown in the construction of the Borsh coders.

solana-labs/explorer#376 (comment)

@acheroncrypto
Copy link
Collaborator

I think it makes sense for it to error if a field references a type that's not included in the IDL (or a default type). Otherwise how can we de/serialize it correctly?

@ngundotra
Copy link
Contributor Author

@acheroncrypto what if the type that's doing the dangling reference is never used?

In this case I think it should be fine to prune, right?

I think the old coder seemed to be fine loading this.

@acheroncrypto
Copy link
Collaborator

@acheroncrypto what if the type that's doing the dangling reference is never used?

In this case I think it should be fine to prune, right?

It should be fine to prune in that case.

I think the old coder seemed to be fine loading this.

I think that's because the old generation did not know whether a type was being used or not, so the old coder also had to be loose. In contrast, the new generation doesn't include unused types in the IDL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants