ink icon indicating copy to clipboard operation
ink copied to clipboard

Make metadata crate available for other compilers

Open cmichi opened this issue 3 years ago • 2 comments

Relates to https://github.com/hyperledger-labs/solang/issues/666.

@seanyoung Could you detail what you would need from us?

cmichi avatar Apr 23 '22 09:04 cmichi

Solang uses contract-metadata for contract metadata generation but this crate does not define anything for the abi itself. So, solang includes some code for the abi generation. This code has been updated to match the latest abi metadata format already, but once again it is out of date.

What would be ideal if there was some code which could be shared between ink and solang for metadata generation:

  • messages, constructors, events
  • storage
  • types

For types, it would be useful if there is a way of creating:

  • primitives
  • account, string, byte string
  • enums
  • composit structurs: structs, array, slice, Result
  • function pointers (both function with and without account, i.e. function internal and function external in solidity
  • mappings

This would require an implementation of the type registry.

Solang does contain an implementation of this, but it is:

  • out of date
  • if even updated, as some point it would be out of date again
  • could use improvement
  • built by looking at metadata generated by ink!, so it may contain mistakes due misunderstanding

Ideally this would be added to contract-metadata.

seanyoung avatar Apr 24 '22 08:04 seanyoung

@cmichi @seanyoung

https://github.com/paritytech/cargo-contract/issues/659 These are my current attempts to reuse crates that rely on cargo-metadata for solang,

I think the most difficult part would be unable to register non-rust types within the registry. Ink can do it because it uses macro that expand native rust data structures. But the same strategy may not be feasible for non-rust projects. Hope these feeback are useful for going forward.

extraymond avatar Jul 24 '22 11:07 extraymond