Skip to content

Commit

Permalink
Refactor out transcode as a separate library (use-ink#597)
Browse files Browse the repository at this point in the history
* refactoring transcode as library

* refactored as lib

* remove unused deps

* fix imports

* cleanup

* modified README

* run fmt

* make clippy happy

* clippy cd

* use std

* PR comments

* fixit
  • Loading branch information
fbielejec authored Jun 8, 2022
1 parent 5e6f941 commit a565f58
Show file tree
Hide file tree
Showing 16 changed files with 356 additions and 34 deletions.
41 changes: 29 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 2 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = [".", "metadata"]
members = [".", "metadata", "transcode"]

[package]
name = "cargo-contract"
Expand Down Expand Up @@ -39,6 +39,7 @@ toml = "0.5.9"
rustc_version = "0.4.0"
blake2 = "0.10.4"
contract-metadata = { version = "0.6.0", path = "./metadata" }
transcode = { package = "contract-transcode", version = "0.1.0", path = "./transcode" }
semver = { version = "1.0.9", features = ["serde"] }
serde = { version = "1.0.137", default-features = false, features = ["derive"] }
serde_json = "1.0.81"
Expand All @@ -50,19 +51,11 @@ regex = "1.5.6"
# dependencies for extrinsics (deploying and calling a contract)
async-std = { version = "1.11.0", features = ["attributes", "tokio1"] }
ink_metadata = { version = "3", features = ["derive"] }
ink_env = "3"
scale-info = { version = "2.1.2", default-features = false, features = ["derive"] }
sp-core = "6.0.0"
sp-runtime = "6.0.0"
pallet-contracts-primitives = "6.0.0"
subxt = "0.21.0"
hex = "0.4.3"
jsonrpsee = { version = "0.13.1", features = ["ws-client"] }
nom = "7.1.1"
nom-supreme = { version = "0.7.0", features = ["error"] }
indexmap = "1.8.2"
escape8259 = "0.5.1"
itertools = "0.10.3"

[build-dependencies]
anyhow = "1.0.57"
Expand All @@ -75,16 +68,11 @@ regex = "1.5.6"

[dev-dependencies]
assert_cmd = "2.0.4"
assert_matches = "1.5.0"
pretty_assertions = "1.2.1"
wabt = "0.10.0"
regex = "1.5.6"
predicates = "2.1.1"

ink_primitives = "3"
ink_storage = "3"
ink_lang = "3"

[features]
# This `std` feature is required for testing using an inline contract's metadata, because `ink!` annotates the metadata
# generation code with `#[cfg(feature = "std")]`.
Expand Down
8 changes: 4 additions & 4 deletions src/cmd/extrinsics/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

use super::{
runtime_api::api::contracts::events::ContractEmitted,
transcode::{
ContractMessageTranscoder,
TranscoderBuilder,
},
RuntimeEvent,
};
use crate::{
Expand All @@ -28,6 +24,10 @@ use crate::{
DEFAULT_KEY_COL_WIDTH,
};
use colored::Colorize as _;
use transcode::{
ContractMessageTranscoder,
TranscoderBuilder,
};

use anyhow::Result;
use subxt::{
Expand Down
3 changes: 1 addition & 2 deletions src/cmd/extrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ mod call;
mod events;
mod instantiate;
mod runtime_api;
mod transcode;
mod upload;

#[cfg(test)]
Expand Down Expand Up @@ -54,13 +53,13 @@ use subxt::{
HasModuleError as _,
};

pub use self::transcode::ContractMessageTranscoder;
pub use call::CallCommand;
pub use instantiate::InstantiateCommand;
pub use runtime_api::api::{
DispatchError as RuntimeDispatchError,
Event as RuntimeEvent,
};
pub use transcode::ContractMessageTranscoder;
pub use upload::UploadCommand;

type Balance = u128;
Expand Down
49 changes: 49 additions & 0 deletions transcode/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[package]
name = "contract-transcode"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"

license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/paritytech/cargo-contract"
documentation = "https://docs.rs/contract-transcode"
homepage = "https://www.substrate.io/"
description = "Library encoding calls for smart contracts on substrate"
keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
include = ["Cargo.toml", "*.rs", "LICENSE"]

[lib]
path = "src/lib.rs"

[dependencies]
anyhow = "1.0.57"
contract-metadata = { version = "0.6.0", path = "../metadata" }
env_logger = "0.9.0"
escape8259 = "0.5.1"
hex = "0.4.3"
indexmap = "1.8.1"
ink_env = "3.0"
ink_metadata = { version = "3.0", features = ["derive"] }
itertools = "0.10.3"
log = "0.4.17"
nom = "7.1.1"
nom-supreme = { version = "0.7.0", features = ["error"] }
scale = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
serde = { version = "1.0.137", default-features = false, features = ["derive"] }
serde_json = "1.0.81"
sp-core = "6.0.0"
sp-runtime = "6.0.0"

[dev-dependencies]
assert_matches = "1.5.0"
ink_lang = "3"
ink_primitives = "3"
ink_storage = "3"

[features]
# This `std` feature is required for testing using an inline contract's metadata, because `ink!` annotates the metadata
# generation code with `#[cfg(feature = "std")]`.
default = ["std"]
std = []
Loading

0 comments on commit a565f58

Please sign in to comment.