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

Relates to #727 Print formatted contract build info #1136

Closed
wants to merge 14 commits into from

Conversation

ltfschoen
Copy link

@ltfschoen ltfschoen commented May 29, 2023

Proposed changes
This PR relates to issue #727.
So far it generates an array of hashmaps for each contract that is generated, and if it has generated one with the same contract name before it overwrites the existing hashmap and stores it in a JSON file build_info.json in the project root that is in the .gitignore file. it could be stored pretty using serde_json::to_string_pretty(...).unwrap(), or similar.

[{"Size":"8.81 KB","Contract":"Flipper","Metadata Path":"target/ink/flipper"},{"Metadata Path":"target/ink/flipper","Contract":"Hi","Size":"8.81 KB"}]

The user can:

  • Run cargo run -p cargo-contract contract summary --output-build-info-json to output the contents of the file to the terminal in JSON format (or just cargo contract summary --output-build-info-json if they have cargo contract installed), or;
Screen Shot 2023-05-31 at 3 44 45 am
  • Run just cargo run -p cargo-contract contract summary to output it in Table tabular format (or just cargo contract summary if they have cargo contract installed)
Screen Shot 2023-05-31 at 3 13 53 am

The outputs are also output to the terminal when a contract is built

Usage

  • Run a substrate-contracts-node on ws://127.0.0.1:9944 (e.g. this codebase allows you to run it in a Docker container https://github.com/ltfschoen/InkTemplate, and if necessary delete the chain db and restart the node by running docker exec -it ink /app/docker/reset.sh)

  • Run the following to build a Flipper contract after running https://github.com/paritytech/cargo-contract && cd cargo-contract:

cargo build
cargo run -p cargo-contract contract new flipper
  • Move the ./flipper folder out of the workspace, otherwise you'll get error ERROR: Unable to execute build of the smart contract
mv ./flipper ../
cargo run -p cargo-contract contract build --manifest-path /path_to_flipper/Cargo.toml
cargo run -p cargo-contract contract summary --output-build-info-json
cargo run -p cargo-contract contract summary
  • View the logs

@ltfschoen ltfschoen marked this pull request as ready for review May 30, 2023 17:48
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue as specified is a follow up to #182 for first-class multi-contract workspace support. When that is implemented it should be possible to generate the summary from existing metadata and build artifacts, without having to generate this additional file in the project root.

@cmichi
Copy link
Collaborator

cmichi commented Feb 27, 2024

I'm closing the PR due to staleness and the cargo-contract master having moved on significantly since the PR was created. Feel free to reopen based on the latest master in case you're interested in continuing work on it!

@cmichi cmichi closed this Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants