Skip to content

Commit

Permalink
add pallet-utility (paritytech#122)
Browse files Browse the repository at this point in the history
1. add pallet-utility
2. update jsonrpc to 14.2.0
3. fix some authors info in Cargo.toml
  • Loading branch information
atenjin authored Jun 27, 2020
1 parent dfc571b commit 4b6e483
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 28 deletions.
17 changes: 17 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"

[dependencies]
futures = "0.3.4"
jsonrpc-core = "14.0.3"
jsonrpc-core = "14.2.0"
log = "0.4.8"
parking_lot = "0.10.0"
structopt = "0.3.8"
Expand Down
10 changes: 4 additions & 6 deletions rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@ 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"
jsonrpc-core = "14.2.0"
jsonrpc-core-client = "14.2.0"
jsonrpc-derive = "14.2.1"
serde_json = "1.0"

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

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

# Substrate primitives
sp-api = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-blockchain = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
Expand All @@ -29,6 +26,7 @@ sp-transaction-pool = { git = "https://github.com/paritytech/substrate.git", tag

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

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

Expand Down
3 changes: 3 additions & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.101", optional = true, features = ["derive"] }
static_assertions = "1.1.0"

# Substrate primitives
sp-api = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
Expand All @@ -35,6 +36,7 @@ pallet-grandpa = { git = "https://github.com/paritytech/substrate.git", tag = "v
pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
pallet-sudo = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }
pallet-utility = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3", default-features = false }

# ChainX primitives
chainx-primitives = { path = "../primitives", default-features = false }
Expand Down Expand Up @@ -81,6 +83,7 @@ std = [
"pallet-randomness-collective-flip/std",
"pallet-sudo/std",
"pallet-timestamp/std",
"pallet-utility/std",

"chainx-primitives/std",

Expand Down
47 changes: 34 additions & 13 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

use pallet_grandpa::fg_primitives;
use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
use static_assertions::const_assert;

use sp_api::impl_runtime_apis;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
Expand All @@ -24,27 +24,29 @@ use sp_std::{collections::btree_map::BTreeMap, prelude::*};
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;

use xrml_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;

pub use chainx_primitives::{
AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, Moment, Signature,
};
use xrml_contracts_rpc_runtime_api::ContractExecResult;
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
pub use sp_runtime::{Perbill, Permill};
// A few exports that help ease life for downstream crates.
pub use chainx_primitives::{AssetId, Token};
pub use frame_support::{
construct_runtime, parameter_types,
traits::{KeyOwnerProofSystem, Randomness},
traits::{KeyOwnerProofSystem, Randomness, Filter, InstanceFilter},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
IdentityFee, Weight,
},
StorageValue,
};
pub use pallet_timestamp::Call as TimestampCall;
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
pub use sp_runtime::{Perbill, Permill};
use pallet_grandpa::fg_primitives;
use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};

pub use chainx_primitives::{
AssetId, Token,AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, Moment, Signature,
};
use xrml_contracts_rpc_runtime_api::ContractExecResult;
use xrml_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;

// xrml re-exports
pub use xrml_assets::{
AssetInfo, AssetRestriction, AssetRestrictions, AssetType, Chain, TotalAssetInfo,
Expand Down Expand Up @@ -91,6 +93,16 @@ pub fn native_version() -> NativeVersion {
}
}

pub struct BaseFilter;
impl Filter<Call> for BaseFilter {
fn filter(_call: &Call) -> bool {
// TODO
true
}
}
pub struct IsCallable;
frame_support::impl_filter_stack!(IsCallable, BaseFilter, Call, is_callable);

const AVERAGE_ON_INITIALIZE_WEIGHT: Perbill = Perbill::from_percent(10);
parameter_types! {
pub const BlockHashCount: BlockNumber = 2400;
Expand All @@ -105,6 +117,8 @@ parameter_types! {
pub const Version: RuntimeVersion = VERSION;
}

const_assert!(AvailableBlockRatio::get().deconstruct() >= AVERAGE_ON_INITIALIZE_WEIGHT.deconstruct());

impl frame_system::Trait for Runtime {
/// The ubiquitous origin type.
type Origin = Origin;
Expand Down Expand Up @@ -192,6 +206,12 @@ impl pallet_timestamp::Trait for Runtime {
type MinimumPeriod = MinimumPeriod;
}

impl pallet_utility::Trait for Runtime {
type Event = Event;
type Call = Call;
type IsCallable = IsCallable;
}

impl pallet_sudo::Trait for Runtime {
type Event = Event;
type Call = Call;
Expand Down Expand Up @@ -248,6 +268,7 @@ construct_runtime!(
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
Aura: pallet_aura::{Module, Config<T>, Inherent(Timestamp)},
Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},
Utility: pallet_utility::{Module, Call, Event},
Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},

XAssets: xrml_assets::{Module, Call, Storage, Event<T>, Config<T>},
Expand Down
6 changes: 3 additions & 3 deletions xrml/assets/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ edition = "2018"
[dependencies]
codec = { package = "parity-scale-codec", version = "1.3.0" }
serde = { version = "1.0.101", features = ["derive"] }
jsonrpc-core = "14.0.3"
jsonrpc-core-client = "14.0.5"
jsonrpc-derive = "14.0.3"
jsonrpc-core = "14.2.0"
jsonrpc-core-client = "14.2.0"
jsonrpc-derive = "14.2.1"

sp-api = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
sp-runtime = { git = "https://github.com/paritytech/substrate.git", tag = "v2.0.0-rc3" }
Expand Down
2 changes: 1 addition & 1 deletion xrml/contracts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "xrml-contracts"
version = "2.0.0-rc3"
authors = ["Parity Technologies <admin@parity.io> and ChainX community <http://www.chainx.org>"]
authors = ["Parity Technologies <admin@parity.io> and ChainX community <https://www.chainx.org>"]
edition = "2018"
license = "Apache-2.0"
homepage = "https://substrate.dev"
Expand Down
2 changes: 1 addition & 1 deletion xrml/contracts/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "xrml-contracts-primitives"
version = "2.0.0-rc3"
authors = ["Parity Technologies <admin@parity.io> and ChainX community <http://www.chainx.org>"]
authors = ["Parity Technologies <admin@parity.io> and ChainX community <https://www.chainx.org>"]
edition = "2018"
license = "Apache-2.0"
homepage = "https://substrate.dev"
Expand Down
2 changes: 1 addition & 1 deletion xrml/contracts/rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "xrml-contracts-rpc"
version = "0.8.0-rc3"
authors = ["Parity Technologies <admin@parity.io> and ChainX community <http://www.chainx.org>"]
authors = ["Parity Technologies <admin@parity.io> and ChainX community <https://www.chainx.org>"]
edition = "2018"
license = "Apache-2.0"
homepage = "https://substrate.dev"
Expand Down
2 changes: 1 addition & 1 deletion xrml/contracts/rpc/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "xrml-contracts-rpc-runtime-api"
version = "0.8.0-rc3"
authors = ["Parity Technologies <admin@parity.io> and ChainX community <http://www.chainx.org>"]
authors = ["Parity Technologies <admin@parity.io> and ChainX community <https://www.chainx.org>"]
edition = "2018"
license = "Apache-2.0"
homepage = "https://substrate.dev"
Expand Down
2 changes: 1 addition & 1 deletion xrml/transaction-payment/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "xrml-transaction-payment"
version = "2.0.0-rc3"
authors = ["Parity Technologies <admin@parity.io> and ChainX community <http://www.chainx.org>"]
authors = ["Parity Technologies <admin@parity.io> and ChainX community <https://www.chainx.org>"]
edition = "2018"
license = "Apache-2.0"
homepage = "https://substrate.dev"
Expand Down

0 comments on commit 4b6e483

Please sign in to comment.