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

Extrinsics: allow specifying contract artifact directly #893

Merged
merged 21 commits into from
Jan 12, 2023
Merged

Conversation

ascjones
Copy link
Collaborator

@ascjones ascjones commented Jan 6, 2023

Extrinsic commands need to locate contract artifacts: for upload we require the contract Wasm and for instantiate and call the contract metadata. Currently this is designed to be similar to other cargo commands: providing a --manifest-path argument to point to the Cargo.toml of the contract project, if not present assuming the working directory is the project root. From there it can locate the artifacts in the ./target/ink/ directory. This is good for a development workflow from inside a project dir like:

cargo contract build --release
cargo contract upload --suri //Alice
cargo contract instantiate ...

Or from a different directory relative to the contract project directory:

cargo contract build --manifest-path ../my-contract/Cargo.toml --release
cargo contract upload --manifest-path ../my-contract/Cargo.toml --suri //Alice
cargo contract instantiate --manifest-path ../my-contract/Cargo.toml ...

However, this workflow is designed for a developer who is working with the contract source locally.

This PR adds the ability to provide the path to a contract artifact file directly, for use cases where a user does not have the contract source project locally.

For all extrinsics, there is now an optional positional argument for the path to an artifact file. This can be one of .wasm (code only), .json (metadata only) or .contract (metadata + wasm). e.g.

cargo upload ../path/to/mycontract.wasm
cargo instantiate ../path/to/mycontract.contract
cargo call ..path/to/metadata.json

When specified, it will use that artifact file. When not specified it will fall back to the existing --manifest-path method.

Note: The existing instantiate command has a --wasm-path argument. This has been replaced by this new positional argument for consistency across the extrinsic commands.

Closes #892

@ascjones ascjones marked this pull request as ready for review January 10, 2023 17:17
@ascjones ascjones changed the title Extrinsics: allow specifying contract artifacts directly Extrinsics: allow specifying contract artifact directly Jan 11, 2023
@ascjones ascjones mentioned this pull request Jan 11, 2023
3 tasks
docs/extrinsics.md Outdated Show resolved Hide resolved
crates/cargo-contract/src/cmd/extrinsics/upload.rs Outdated Show resolved Hide resolved
crates/build/src/crate_metadata.rs Outdated Show resolved Hide resolved
ascjones and others added 6 commits January 12, 2023 10:08
Co-authored-by: Michael Müller <[email protected]>
Bumps [assert_cmd](https://github.com/assert-rs/assert_cmd) from 2.0.7 to 2.0.8.
- [Release notes](https://github.com/assert-rs/assert_cmd/releases)
- [Changelog](https://github.com/assert-rs/assert_cmd/blob/master/CHANGELOG.md)
- [Commits](assert-rs/assert_cmd@v2.0.7...v2.0.8)

---
updated-dependencies:
- dependency-name: assert_cmd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [regex](https://github.com/rust-lang/regex) from 1.7.0 to 1.7.1.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](rust-lang/regex@1.7.0...1.7.1)

---
updated-dependencies:
- dependency-name: regex
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
* dependabot: ignore substrate deps

* Move ignore section and use pattern

* Fix update-types
@ascjones ascjones requested a review from a team as a code owner January 12, 2023 10:32
@ascjones ascjones removed the request for review from a team January 12, 2023 10:33
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.

Unnecessary requirements when uploading a contract
2 participants