metaplex-foundation / shank

Extracts IDL from Solana Rust contracts
https://docs.rs/crate/shank_macro/latest
116 stars 23 forks source link

Shank panics on NFT-Packs #29

Closed blockiosaurus closed 2 years ago

blockiosaurus commented 2 years ago

When running shank on the MPL program NFT-Packs (https://github.com/metaplex-foundation/metaplex-program-library/tree/master/nft-packs/program), it fails with the following error:

shank DEBUG No crate_root provided, assuming in current dir
shank DEBUG out_dir is relative, resolving from current dir
thread 'main' panicked at 'not yet implemented: Not yet handling custom angle bracketed types with 2 type parameters', /home/kelliott/.cargo/registry/src/github.com-1ecc6299db9ec823/shank_macro_impl-0.0.4/src/types/resolve_rust_ty.rs:301:34
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14
   2: shank_macro_impl::types::resolve_rust_ty::ident_to_kind
   3: shank_macro_impl::types::resolve_rust_ty::resolve_rust_ty
   4: <shank_macro_impl::parsed_struct::parsed_struct::StructField as core::convert::TryFrom<&syn::data::Field>>::try_from
   5: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold
   6: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
   7: <shank_macro_impl::parsed_struct::parsed_struct::ParsedStruct as core::convert::TryFrom<&syn::item::ItemStruct>>::try_from
   8: <shank_macro_impl::custom_type::custom_struct::CustomStruct as core::convert::TryFrom<&syn::item::ItemStruct>>::try_from
   9: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  10: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold
  11: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  12: core::iter::adapters::try_process
  13: shank_idl::file::types
  14: shank_idl::file::parse_file
  15: shank_idl::extract_idl
  16: shank_cli::idl
  17: shank_cli::entry
  18: shank::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thlorenz commented 2 years ago

Isolated the issue to the use of BTreeMap, i.e. here.

shank doesn't support those yet, but will. I assume the JS representation would be the same as a HashMap since BTreeMap is just a HashMap optimized for search right?

thlorenz commented 2 years ago

Fixed with various updates to shank, beet and solita and finally generated a valid SDK in this PR