Unverified Commit 2beb8311 authored by Michael Müller's avatar Michael Müller Committed by GitHub
Browse files

Improve readme and `decode` sub-command documentation (#572)

* Add Stack Exchange badge

* Have IntelliJ shut up about whitespace at EOL

* Make capitalization of log messages consistent

* Improve docs for `decode`

* Update changelog

* Update link to `ink-docs`

* Apply `cargo fmt`

* Remove unnecessary monospace
parent 8ea7a77d
Pipeline #194623 passed with stages
in 11 minutes and 55 seconds
......@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Updated `cargo contract new` template dependencies to ink! `3` - [#569](https://github.com/paritytech/cargo-contract/pull/569)
- Improved documentation on how to invoke `cargo contract decode` - [#572](https://github.com/paritytech/cargo-contract/pull/572)
## [1.3.0] - 2022-05-09
......
......@@ -3,12 +3,14 @@
[![CI Status][a1]][a2]
[![Latest Release][d1]][d2]
[![stack-exchange][s1]][s2]
[a1]: https://gitlab.parity.io/parity/mirrors/cargo-contract/badges/master/pipeline.svg
[a2]: https://gitlab.parity.io/parity/mirrors/cargo-contract/pipelines
[b2]: https://substrate.stackexchange.com/questions/tagged/ink?tab=Votes
[d1]: https://img.shields.io/crates/v/cargo-contract.svg
[d2]: https://crates.io/crates/cargo-contract
[s1]: https://img.shields.io/badge/click-white.svg?logo=StackExchange&label=ink!%20Support%20on%20StackExchange&labelColor=white&color=blue
[s2]: https://substrate.stackexchange.com/questions/tagged/ink?tab=Votes
<p align="center">
......@@ -18,14 +20,14 @@
<br/>
[Guided Tutorial for Beginners](https://docs.substrate.io/tutorials/v3/ink-workshop/pt1/)&nbsp;&nbsp;&nbsp;&nbsp;
[ink! Documentation Portal](https://paritytech.github.io/ink-docs)
[ink! Documentation Portal](https://ink.substrate.io)
<br/>
</div>
More relevant links:
* Find answers to your questions by joining our [Stack Exchange][b2] community
* [`ink!`](https://github.com/paritytech/ink) ‒ The main ink! repository with smart contract examples
* Find answers to your questions by joining our [Stack Exchange][s2] community
* [ink!](https://github.com/paritytech/ink) ‒ The main ink! repository with smart contract examples
* [Contracts UI](https://paritytech.github.io/contracts-ui/) ‒ Frontend for contract deployment and interaction
* [Substrate Contracts Node](https://github.com/paritytech/substrate-contracts-node) ‒ Simple Substrate blockchain which includes smart contract functionality
......@@ -125,6 +127,14 @@ Create an instance of a contract on chain. See [extrinsics](docs/extrinsics.md).
Invoke a message on an existing contract on chain. See [extrinsics](docs/extrinsics.md).
##### `cargo contract decode`
Decodes a contracts input or output data.
This can be either an event, an invocation of a contract message, or an invocation of a contract constructor.
The argument has to be given as hex-encoding, starting with `0x`.
## License
The entire code within this repository is licensed under the [GPLv3](LICENSE).
......
......@@ -29,12 +29,15 @@ use anyhow::{
use colored::Colorize as _;
#[derive(Debug, Clone, clap::Args)]
#[clap(name = "decode", about = "Decode input_data for a contract")]
#[clap(
name = "decode",
about = "Decodes the input or output data of a contract"
)]
pub struct DecodeCommand {
/// Type of data
/// The type of data to encode.
#[clap(arg_enum, short, long)]
r#type: DataType,
/// The data to decode
/// The data to decode; this has to be a hex value starting with `0x`.
#[clap(short, long)]
data: String,
}
......
......@@ -84,7 +84,7 @@ impl CallCommand {
load_metadata(self.extrinsic_opts.manifest_path.as_ref())?;
let transcoder = ContractMessageTranscoder::new(&contract_metadata);
let call_data = transcoder.encode(&self.message, &self.args)?;
log::debug!("message data: {:?}", hex::encode(&call_data));
log::debug!("Message data: {:?}", hex::encode(&call_data));
let signer = super::pair_signer(self.extrinsic_opts.signer()?);
......
......@@ -207,7 +207,7 @@ impl<'a> ContractMessageTranscoder<'a> {
variant_index
)
})?;
log::debug!("decoding contract event '{}'", event_spec.label());
log::debug!("Decoding contract event '{}'", event_spec.label());
let mut args = Vec::new();
for arg in event_spec.args() {
......@@ -234,7 +234,7 @@ impl<'a> ContractMessageTranscoder<'a> {
hex::encode(&msg_selector)
)
})?;
log::debug!("decoding contract message '{}'", msg_spec.label());
log::debug!("Decoding contract message '{}'", msg_spec.label());
let mut args = Vec::new();
for arg in msg_spec.args() {
......@@ -261,7 +261,7 @@ impl<'a> ContractMessageTranscoder<'a> {
hex::encode(&msg_selector)
)
})?;
log::debug!("decoding contract constructor '{}'", msg_spec.label());
log::debug!("Decoding contract constructor '{}'", msg_spec.label());
let mut args = Vec::new();
for arg in msg_spec.args() {
......
......@@ -465,7 +465,7 @@ enum Command {
/// Call a contract
#[clap(name = "call")]
Call(CallCommand),
/// Decode a contract input data
/// Decodes a contracts input or output data (supplied in hex-encoding)
#[clap(name = "decode")]
Decode(DecodeCommand),
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment