diff --git a/CHANGELOG.md b/CHANGELOG.md index da102618d8..f794e227f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# Version 0.10.1 (2020-06-19) + +* Release client v0.2.0 [#133](https://github.com/paritytech/substrate-subxt/pull/133) + +# Version 0.10.0 (2020-06-19) + +* Upgrade to substrate rc4 release [#131](https://github.com/paritytech/substrate-subxt/pull/131) +* Support unsigned extrinsics. [#130](https://github.com/paritytech/substrate-subxt/pull/130) + # Version 0.9.0 (2020-06-25) * Events sub [#126](https://github.com/paritytech/substrate-subxt/pull/126) diff --git a/Cargo.toml b/Cargo.toml index 4326a10251..1910c4bf3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = [".", "client", "proc-macro", "test-node"] [package] name = "substrate-subxt" -version = "0.9.0" +version = "0.10.1" authors = ["Parity Technologies "] edition = "2018" @@ -42,7 +42,7 @@ sp-rpc = { version = "2.0.0-rc4", package = "sp-rpc" } sp-core = { version = "2.0.0-rc4", package = "sp-core" } sc-rpc-api = { version = "0.8.0-rc4", package = "sc-rpc-api" } sp-transaction-pool = { version = "2.0.0-rc4", package = "sp-transaction-pool" } -substrate-subxt-client = { version = "0.1.0", path = "client", optional = true } +substrate-subxt-client = { version = "0.2.0", path = "client", optional = true } substrate-subxt-proc-macro = { version = "0.9.0", path = "proc-macro" } sp-std = "2.0.0-rc4" application-crypto = { version = "2.0.0-rc4", package = "sp-application-crypto", default-features = false } @@ -59,6 +59,6 @@ wabt = "0.9.2" frame-system = { version = "2.0.0-rc4", package = "frame-system" } pallet-balances = { version = "2.0.0-rc4", package = "pallet-balances" } sp-keyring = { version = "2.0.0-rc4", package = "sp-keyring" } -substrate-subxt-client = { version = "0.1.0", path = "client" } +substrate-subxt-client = { version = "0.2.0", path = "client" } tempdir = "0.3.7" test-node = { path = "test-node" } diff --git a/client/Cargo.toml b/client/Cargo.toml index 588e11392a..eab144bb3d 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substrate-subxt-client" -version = "0.1.0" +version = "0.2.0" authors = ["David Craven ", "Parity Technologies "] edition = "2018" @@ -20,7 +20,7 @@ log = "0.4.8" sc-network = { version = "0.8.0-rc4", default-features = false } sc-service = { version = "0.8.0-rc4", default-features = false } serde_json = "1.0.55" -sp-keyring = { version = "2.0.0-rc4", package = "sp-keyring" } +sp-keyring = "2.0.0-rc4" thiserror = "1.0.20" [dev-dependencies] diff --git a/client/src/lib.rs b/client/src/lib.rs index 70b8a3596b..a6c63018aa 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -213,7 +213,8 @@ fn start_subxt_client( TaskType::Async => task::spawn(fut), TaskType::Blocking => task::spawn_blocking(|| task::block_on(fut)), }; - }).into(), + }) + .into(), database: config.db, keystore: KeystoreConfig::InMemory, max_runtime_instances: 8, @@ -243,6 +244,8 @@ fn start_subxt_client( tracing_targets: Default::default(), transaction_pool: Default::default(), wasm_method: Default::default(), + base_path: Default::default(), + informant_output_format: Default::default(), }; log::info!("{}", service_config.impl_name); @@ -332,6 +335,7 @@ mod tests { test_node::chain_spec::ChainSpec::from_json_bytes(bytes).unwrap(); let tmp = TempDir::new("subxt-").expect("failed to create tempdir"); let config = SubxtClientConfig { + // base_path: impl_name: "substrate-subxt-light-client", impl_version: "0.0.1", author: "David Craven", diff --git a/proc-macro/Cargo.toml b/proc-macro/Cargo.toml index 2256ac0552..c8e050410b 100644 --- a/proc-macro/Cargo.toml +++ b/proc-macro/Cargo.toml @@ -28,7 +28,7 @@ async-std = { version = "=1.5.0", features = ["attributes"] } codec = { package = "parity-scale-codec", version = "1.3.1", features = ["derive"] } env_logger = "0.7.1" pretty_assertions = "0.6.1" -sp-keyring = { version = "2.0.0-rc4", package = "sp-keyring" } +sp-keyring = "2.0.0-rc4" substrate-subxt = { path = ".." } trybuild = "1.0.30" diff --git a/src/lib.rs b/src/lib.rs index 17b7d7a738..dc10523c1a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -312,10 +312,10 @@ impl Client { .and_then(|module| module.call(C::FUNCTION, call))?) } - /// Creates an unsigned extrinsic. + /// Creates an payload for an extrinsic. /// /// If `nonce` is `None` the nonce will be fetched from the chain. - pub async fn create_unsigned>( + pub async fn create_payload>( &self, call: C, account_id: &::AccountId, @@ -340,6 +340,23 @@ impl Client { Ok(raw_payload) } + /// Creates an unsigned extrinsic. + pub async fn create_unsigned + Send + Sync>( + &self, + call: C, + account_id: &::AccountId, + nonce: Option, + ) -> Result, Error> + where + <>::Extra as SignedExtension>::AdditionalSigned: + Send + Sync, + { + let payload = self.create_payload(call, account_id, nonce).await?; + let (call, _, _) = payload.deconstruct(); + let unsigned = UncheckedExtrinsic::::new_unsigned(call); + Ok(unsigned) + } + /// Creates a signed extrinsic. pub async fn create_signed + Send + Sync>( &self, @@ -350,10 +367,10 @@ impl Client { <>::Extra as SignedExtension>::AdditionalSigned: Send + Sync, { - let unsigned = self - .create_unsigned(call, signer.account_id(), signer.nonce()) + let payload = self + .create_payload(call, signer.account_id(), signer.nonce()) .await?; - let signed = signer.sign(unsigned).await?; + let signed = signer.sign(payload).await?; Ok(signed) } @@ -565,7 +582,7 @@ mod tests { // create raw payload with AccoundId and sign it let raw_payload = client - .create_unsigned( + .create_payload( balances::TransferCall { to: &dest, amount: 10_000, diff --git a/src/rpc.rs b/src/rpc.rs index d640784c46..95e176ae32 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -37,7 +37,6 @@ use jsonrpsee::{ }, Client, }; -use num_traits::bounds::Bounded; use sc_rpc_api::state::ReadProof; use serde::Serialize; use sp_core::{ @@ -82,7 +81,7 @@ pub type ChainBlock = SignedBlock::Header, ::Extrinsic>>; /// Wrapper for NumberOrHex to allow custom From impls -#[derive(Serialize, Debug)] +#[derive(Serialize)] pub struct BlockNumber(NumberOrHex); impl From for BlockNumber { @@ -151,8 +150,7 @@ impl Rpc { } /// Fetch the genesis hash - pub async fn genesis_hash(&self) -> Result - { + pub async fn genesis_hash(&self) -> Result { let block_zero = Some(ListOrValue::Value(NumberOrHex::Number(0))); let params = Params::Array(vec![to_json_value(block_zero)?]); let list_or_value: ListOrValue> = diff --git a/test-node/Cargo.toml b/test-node/Cargo.toml index 7e5a9fe6ae..5325a3b634 100644 --- a/test-node/Cargo.toml +++ b/test-node/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test-node" -version = "2.0.0-rc3" +version = "2.0.0-rc4" authors = ["Anonymous"] description = "Substrate Node template" edition = "2018" @@ -19,12 +19,12 @@ structopt = "0.3.15" parking_lot = "0.11.0" sc-cli = { version = "0.8.0-rc4", features = ["wasmtime"] } -sp-core = { version = "2.0.0-rc4", package = "sp-core" } +sp-core = "2.0.0-rc4" sc-executor = { version = "0.8.0-rc4", features = ["wasmtime"] } sc-service = { version = "0.8.0-rc4", features = ["wasmtime"] } sp-inherents = "2.0.0-rc4" sc-transaction-pool = "2.0.0-rc4" -sp-transaction-pool = { version = "2.0.0-rc4", package = "sp-transaction-pool" } +sp-transaction-pool = "2.0.0-rc4" sc-network = "0.8.0-rc4" sc-consensus-aura = "0.8.0-rc4" sp-consensus-aura = "0.8.0-rc4" @@ -33,10 +33,10 @@ sc-consensus = "0.8.0-rc4" sc-finality-grandpa = "0.8.0-rc4" sp-finality-grandpa = "2.0.0-rc4" sc-client-api = "2.0.0-rc4" -sp-runtime = { version = "2.0.0-rc4", package = "sp-runtime" } +sp-runtime = "2.0.0-rc4" sc-basic-authorship = "0.8.0-rc4" -test-node-runtime = { version = "2.0.0-rc3", path = "runtime" } +test-node-runtime = { version = "2.0.0-rc4", path = "runtime" } [build-dependencies] substrate-build-script-utils = "2.0.0-rc4" diff --git a/test-node/runtime/Cargo.toml b/test-node/runtime/Cargo.toml index 90767f8b08..220b6523bb 100644 --- a/test-node/runtime/Cargo.toml +++ b/test-node/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test-node-runtime" -version = "2.0.0-rc3" +version = "2.0.0-rc4" authors = ["Anonymous"] edition = "2018" license = "Unlicense" @@ -15,7 +15,7 @@ codec = { package = "parity-scale-codec", version = "1.3.1", default-features = aura = { version = "2.0.0-rc4", default-features = false, package = "pallet-aura" } balances = { version = "2.0.0-rc4", default-features = false, package = "pallet-balances" } -frame-support = { version = "2.0.0-rc4", default-features = false, package = "frame-support" } +frame-support = { version = "2.0.0-rc4", default-features = false } grandpa = { version = "2.0.0-rc4", default-features = false, package = "pallet-grandpa" } randomness-collective-flip = { version = "2.0.0-rc4", default-features = false, package = "pallet-randomness-collective-flip" } sudo = { version = "2.0.0-rc4", default-features = false, package = "pallet-sudo" } @@ -27,15 +27,15 @@ serde = { version = "1.0.114", optional = true, features = ["derive"] } sp-api = { version = "2.0.0-rc4", default-features = false } sp-block-builder = { default-features = false, version = "2.0.0-rc4" } sp-consensus-aura = { version = "0.8.0-rc4", default-features = false } -sp-core = { version = "2.0.0-rc4", default-features = false, package = "sp-core" } +sp-core = { version = "2.0.0-rc4", default-features = false } sp-inherents = { default-features = false, version = "2.0.0-rc4" } sp-io = { version = "2.0.0-rc4", default-features = false } sp-offchain = { version = "2.0.0-rc4", default-features = false } -sp-runtime = { version = "2.0.0-rc4", default-features = false, package = "sp-runtime" } +sp-runtime = { version = "2.0.0-rc4", default-features = false } sp-session = { version = "2.0.0-rc4", default-features = false } sp-std = { version = "2.0.0-rc4", default-features = false } -sp-transaction-pool = { version = "2.0.0-rc4", default-features = false, package = "sp-transaction-pool" } -sp-version = { version = "2.0.0-rc4", default-features = false, package = "sp-version" } +sp-transaction-pool = { version = "2.0.0-rc4", default-features = false } +sp-version = { version = "2.0.0-rc4", default-features = false } [build-dependencies] wasm-builder-runner = { version = "1.0.6", package = "substrate-wasm-builder-runner" } diff --git a/test-node/runtime/src/lib.rs b/test-node/runtime/src/lib.rs index 978a648842..d8cc5318bd 100644 --- a/test-node/runtime/src/lib.rs +++ b/test-node/runtime/src/lib.rs @@ -181,6 +181,8 @@ parameter_types! { } impl system::Trait for Runtime { + /// The basic call filter to use in dispatchable. + type BaseCallFilter = (); /// The identifier used to distinguish between accounts. type AccountId = AccountId; /// The aggregated dispatch type that is available for extrinsics. diff --git a/test-node/src/service.rs b/test-node/src/service.rs index abeb2c8e3a..5aba8d00bb 100644 --- a/test-node/src/service.rs +++ b/test-node/src/service.rs @@ -145,7 +145,7 @@ pub fn new_full(config: Configuration) -> Result>; Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _) })? - .build_light()?; + .build_full()?; if role.is_authority() { let proposer = sc_basic_authorship::ProposerFactory::new( @@ -177,19 +177,20 @@ pub fn new_full(config: Configuration) -> Result Result Result>; Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _) })? - .build_light() + .build_light() }