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

Generate metadata for sub-contracts in multi contract workspace #60

Closed
ascjones opened this issue Jun 23, 2020 · 4 comments · Fixed by #174
Closed

Generate metadata for sub-contracts in multi contract workspace #60

ascjones opened this issue Jun 23, 2020 · 4 comments · Fixed by #174
Assignees
Labels
enhancement New feature or request

Comments

@ascjones
Copy link
Collaborator

ascjones commented Jun 23, 2020

Following on from #58, we should support generating of metadata for the non-root contract in a multi contract workspace.

For example, the delegator example hosts multiple contracts which are dependencies of the main contract.

Proposal

  • All metadata files will be written to the target directory of the workspace root, with the file name the same as the contract module name e.g. delegator.json, incrementer.json etc.
  • cargo contract generate-metadata in the root workspace dir generates just the metadata for the root contract (in this case the delegator
  • Sub contracts: e.g cd adder && cargo contract generate-metadata generates just the metadata for that sub contract.
  • Alternatively cargo contract generate-metadata -p adder from the root does the same, mirroring cargo functionality.
  • cargo contract generate-metadata --all will generate metadata files for all contracts in the workspace, e.g. delegator.json, adder.json, subber.json

Implementation notes

  • Need to auto remove the ink-as-dependency feature in the root workspace manifest for the sub contracts
@ascjones ascjones added the enhancement New feature or request label Jun 23, 2020
@ii-ii-ii
Copy link

ii-ii-ii commented Dec 31, 2020

@ascjones hi, I would like to know if this issue is solved. Because I'm working on multiple contracts and I'll have some trouble if I can't generate abi for sub-contracts.

@ascjones
Copy link
Collaborator Author

ascjones commented Jan 5, 2021

It's not solved yet. It should still work if you run cargo-contract from a sub contract's directory, or use the --manifest-path argument

@ii-ii-ii
Copy link

ii-ii-ii commented Jan 8, 2021

When I try to execute cargo +nightly contract build in a subdirectory I get an error:

error[E0463]: can't find crate for `contract`
 --> .ink/metadata_gen/main.rs:1:1
  |
1 | extern crate contract;
  | ^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `metadata-gen`

To learn more, run the command again with --verbose.

It can get a wasm file, but cannot generate abi. Using --manifest-path also gives the same error

@ascjones
Copy link
Collaborator Author

ascjones commented Jan 8, 2021

My mistake, I thought it would have worked. I'll look at implementing this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants