Skip to content

Commit

Permalink
Split out cli crate (paritytech#120)
Browse files Browse the repository at this point in the history
* Split out cli crate

* Rearrange the deps alphabetically

* https

* Add crates to workspace memembers

* ChainX runtime should require unwinding too

* .

* Nits

* Reorg assets-runtim-api crate

Should be organized as follows:

assets/
    rpc/
        runtime-api/
            Cargo.toml
       Cargo.toml
    Cargo.toml
  • Loading branch information
liuchengxu authored Jun 27, 2020
1 parent 460b850 commit dfc571b
Show file tree
Hide file tree
Showing 23 changed files with 163 additions and 114 deletions.
15 changes: 11 additions & 4 deletions Cargo.lock

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

54 changes: 21 additions & 33 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,29 @@ edition = "2018"
description = "Fully Decentralized Interchain Crypto Asset Management on Polkadot"

[dependencies]
futures = "0.3.4"
log = "0.4.8"
structopt = "0.3.8"
parking_lot = "0.10.0"
jsonrpc-core = "14.0.3"

sc-cli = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-core = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-rpc = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-executor = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-service = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-inherents = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-transaction-pool = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-transaction-pool = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-network = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-consensus-aura = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-consensus-aura = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-consensus = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-consensus = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-finality-grandpa = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-finality-grandpa = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-client-api = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-runtime = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-basic-authorship = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }

chainx-primitives = { path = "./primitives" }
chainx-runtime = { path = "./runtime" }
chainx-rpc = { path = "./rpc" }

xrml-protocol = { path = "./xrml/protocol" }

[build-dependencies]
substrate-build-script-utils = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
cli = { package = "chainx-cli", path = "cli" }

[workspace]
members = [
"cli",
"runtime",
"primitives",
"rpc",

"xrml/assets",
"xrml/assets/rpc",
"xrml/assets/rpc/runtime-api",
"xrml/bridge/bitcoin",
"xrml/contracts",
"xrml/contracts/common",
"xrml/contracts/rpc",
"xrml/contracts/rpc/runtime-api",
"xrml/protocol",
"xrml/support",
"xrml/transaction-payment",
"xrml/transaction-payment/rpc",
"xrml/transaction-payment/rpc/runtime-api",
]

[profile.release]
panic = "unwind"
43 changes: 43 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[package]
name = "chainx-cli"
version = "2.0.0"
authors = ["ChainX community <https://www.chainx.org>"]
edition = "2018"

[dependencies]
futures = "0.3.4"
jsonrpc-core = "14.0.3"
log = "0.4.8"
parking_lot = "0.10.0"
structopt = "0.3.8"

# Substrate client
sc-basic-authorship = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-cli = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-client-api = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-consensus = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-consensus-aura = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-executor = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-finality-grandpa = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-network = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-rpc = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-service = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-transaction-pool = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }

# Substrate primitives
sp-core = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-consensus = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-consensus-aura = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-finality-grandpa = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-inherents = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-runtime = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-transaction-pool = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }

chainx-primitives = { path = "../primitives" }
chainx-runtime = { path = "../runtime" }
chainx-rpc = { path = "../rpc" }

xrml-protocol = { path = "../xrml/protocol" }

[build-dependencies]
substrate-build-script-utils = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//! ChainX CLI library.

#![warn(missing_docs)]
#![warn(unused_extern_crates)]

mod chain_spec;
#[macro_use]
mod service;
mod cli;
mod command;

pub use command::*;
pub use sc_cli::Result;
File renamed without changes.
2 changes: 1 addition & 1 deletion primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "chainx-primitives"
version = "2.0.0"
authors = ["ChainX community <http://www.chainx.org>"]
authors = ["ChainX community <https://www.chainx.org>"]
edition = "2018"

[dependencies]
Expand Down
14 changes: 7 additions & 7 deletions rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
[package]
name = "chainx-rpc"
version = "2.0.0"
authors = ["ChainX community <http://www.chainx.org>"]
authors = ["ChainX community <https://www.chainx.org>"]
edition = "2018"

[dependencies]
codec = { package = "parity-scale-codec", version = "1.3.0", features = ["derive"] }
hex = "0.4"
jsonrpc-core = "14.0.3"
jsonrpc-core-client = "14.0.5"
jsonrpc-derive = "14.0.3"
serde_json = "1.0"
hex = "0.4"

# Substrate client
sc-service = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", features = ["test-helpers"] }
sc-client-api = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sc-service = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", features = ["test-helpers"] }

# Substrate utils
substrate-frame-rpc-system = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }

# Substrate primitives
sp-runtime = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-consensus = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-api = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-transaction-pool = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-blockchain = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-consensus = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-runtime = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-state-machine = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-transaction-pool = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }

# Substrate pallets
frame-support = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3" }
Expand All @@ -37,7 +37,7 @@ chainx-primitives = { path = "../primitives" }

# ChainX pallets
xrml-assets-rpc = { path = "../xrml/assets/rpc" }
xrml-assets-runtime-api = { path = "../xrml/assets/runtime-api" }
xrml-assets-rpc-runtime-api = { path = "../xrml/assets/rpc/runtime-api" }
xrml-contracts-rpc = { path = "../xrml/contracts/rpc" }
xrml-contracts-rpc-runtime-api = { path = "../xrml/contracts/rpc/runtime-api" }
xrml-transaction-payment-rpc = { path = "../xrml/transaction-payment/rpc" }
2 changes: 1 addition & 1 deletion rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ where
UncheckedExtrinsic,
>,
<Client<BE, E, Block, RA> as ProvideRuntimeApi<Block>>::Api:
xrml_assets_runtime_api::AssetsApi<Block, AccountId, Balance>,
xrml_assets_rpc_runtime_api::AssetsApi<Block, AccountId, Balance>,
<Client<BE, E, Block, RA> as ProvideRuntimeApi<Block>>::Api:
xrml_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber>,
<<Client<BE, E, Block, RA> as ProvideRuntimeApi<Block>>::Api as sp_api::ApiErrorExt>::Error:
Expand Down
50 changes: 25 additions & 25 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "chainx-runtime"
version = "2.0.0"
authors = ["ChainX community <http://www.chainx.org>"]
authors = ["ChainX community <https://www.chainx.org>"]
edition = "2018"

[package.metadata.docs.rs]
Expand All @@ -12,36 +12,36 @@ codec = { package = "parity-scale-codec", version = "1.3.0", default-features =
serde = { version = "1.0.101", optional = true, features = ["derive"] }

# Substrate primitives
sp-io = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
sp-std = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
sp-core = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
sp-runtime = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
sp-session = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
sp-version = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
sp-api = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
sp-inherents = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
sp-offchain = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
sp-block-builder = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
sp-consensus-aura = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
sp-core = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
sp-inherents = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
sp-io = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
sp-offchain = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
sp-runtime = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
sp-session = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
sp-std = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
sp-transaction-pool = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
sp-version = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }

# Substrate pallets
frame-executive = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
frame-support = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
frame-system = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
frame-system-rpc-runtime-api = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
frame-executive = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
pallet-aura = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
pallet-grandpa = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
pallet-timestamp = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
pallet-sudo = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
pallet-randomness-collective-flip = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
pallet-sudo = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
pallet-timestamp = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }

# ChainX primitives
chainx-primitives = { path = "../primitives", default-features = false }

# ChainX pallets
xrml-assets = { path = "../xrml/assets", default-features = false }
xrml-assets-runtime-api = { path = "../xrml/assets/runtime-api", default-features = false }
xrml-assets-rpc-runtime-api = { path = "../xrml/assets/rpc/runtime-api", default-features = false }
xrml-bridge-bitcoin = { path = "../xrml/bridge/bitcoin", default-features = false }
xrml-contracts = { path = "../xrml/contracts", default-features = false }
xrml-contracts-primitives = { path = "../xrml/contracts/common", default-features = false }
Expand All @@ -58,34 +58,34 @@ std = [
"codec/std",
"serde",

"sp-io/std",
"sp-std/std",
"sp-core/std",
"sp-runtime/std",
"sp-session/std",
"sp-version/std",
"sp-api/std",
"sp-inherents/std",
"sp-offchain/std",
"sp-block-builder/std",
"sp-consensus-aura/std",
"sp-core/std",
"sp-inherents/std",
"sp-io/std",
"sp-offchain/std",
"sp-runtime/std",
"sp-session/std",
"sp-std/std",
"sp-transaction-pool/std",
"sp-version/std",

"frame-executive/std",
"frame-support/std",
"frame-system/std",
"frame-system-rpc-runtime-api/std",
"frame-executive/std",

"pallet-aura/std",
"pallet-grandpa/std",
"pallet-timestamp/std",
"pallet-sudo/std",
"pallet-randomness-collective-flip/std",
"pallet-sudo/std",
"pallet-timestamp/std",

"chainx-primitives/std",

"xrml-assets/std",
"xrml-assets-runtime-api/std",
"xrml-assets-rpc-runtime-api/std",
"xrml-bridge-bitcoin/std",
"xrml-contracts/std",
"xrml-contracts-primitives/std",
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ impl_runtime_apis! {
}
}

impl xrml_assets_runtime_api::AssetsApi<Block, AccountId, Balance> for Runtime {
impl xrml_assets_rpc_runtime_api::AssetsApi<Block, AccountId, Balance> for Runtime {
fn assets_for_account(who: AccountId) -> BTreeMap<AssetId, BTreeMap<AssetType, Balance>> {
XAssets::valid_assets_of(&who)
}
Expand Down
13 changes: 3 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
//! Substrate Node Template CLI library.
#![warn(missing_docs)]
//! ChainX CLI

mod chain_spec;
#[macro_use]
mod service;
mod cli;
mod command;

fn main() -> sc_cli::Result<()> {
command::run()
fn main() -> cli::Result<()> {
cli::run()
}
11 changes: 6 additions & 5 deletions xrml/assets/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "xrml-assets"
version = "0.1.0"
authors = ["ChainX community <http://www.chainx.org>"]
authors = ["ChainX community <https://www.chainx.org>"]
edition = "2018"

[dependencies]
serde = { version = "1.0", optional = true }
codec = { package = "parity-scale-codec", version = "1.3.0", features = ["derive"], default-features = false }
bitmask = { version = "0.5.0", default-features = false }
codec = { package = "parity-scale-codec", version = "1.3.0", features = ["derive"], default-features = false }
serde = { version = "1.0", optional = true }

# Substrate primitives
sp-std = { git = "https:/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
Expand All @@ -28,9 +28,9 @@ xrml-support = { path = "../support", default-features = false }
[features]
default = ["std"]
std = [
"serde",
"codec/std",
"bitmask/std",
"codec/std",
"serde",

"sp-std/std",
"sp-core/std",
Expand All @@ -40,6 +40,7 @@ std = [
"frame-system/std",

"chainx-primitives/std",

"xrml-protocol/std",
"xrml-support/std",
]
Loading

0 comments on commit dfc571b

Please sign in to comment.