Autogenerate abi/metadata package

Sergej Kostjucenko requested to merge aj-abi into master

Created by: ascjones

Closes #39 (closed).

Generating metadata requires a separate workspace package which is invoked via cargo run --package abi-gen. Currently this is generated by the template and exists statically in the contract's workspace.

This PR instead dynamically generates the abi-gen package, adding it to the contract workspace before invoking it. This simplifies the contract's workspace, and also allows changes to the metadata generation process without relying on all contract authors to update their local abi-gen packages.

Template updated to be ink/master compatible

Limitations

  • Not backwards compatible - will not work for ink! v2 contracts. Agreed with @Robbepop that this is too much work.
  • Cannot generate metadata for ink-as-dependency sub contracts in a multi contract workspace (e.g. delegator). I began to write code for this, it's possible but requires several more hours work. This could be addressed in a follow up https://github.com/paritytech/cargo-contract/issues/60, since we don't currently support this anyway.

todo

  • separate PR for splitting workspace module into files, for easier review here
  • PR description here
  • ink! v2 backwards compatibility
  • handle where storage struct has a different name than the contract package e.g. ink/examples/dns
  • test with ink/examples/delegator
  • test with generated template
  • friendly message for user to remove old abi_gen package

Merge request reports