Open ngundotra opened 1 month ago
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.
I think I'd prefer vanilla TS so I don't have to think about where it runs.
Example port I wrote for TS: https://github.com/solana-labs/explorer/pull/374
https://github.com/solana-labs/explorer/pull/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?
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.
https://github.com/solana-labs/explorer/pull/376#event-14250318111
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?
@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 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.
That way explorers have easy access to same functionality as in #3009