diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 100dbe52e019ae9cfad24b8b075b5f421325af76..0884d5355d0db512b17680562b0b398d3e275d93 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -64,7 +64,7 @@ fmt:
script:
- cargo fmt --verbose --all -- --check
-#### stage: test
+#### stage: test (all features)
test:
stage: test
@@ -72,7 +72,7 @@ test:
script:
- cargo test --verbose --all-features --release
-#### stage: build
+#### stage: build (default features)
build:
stage: build
@@ -81,4 +81,4 @@ build:
- schedules
- master
script:
- - cargo build --verbose --all-features --release
+ - cargo build --verbose --release
diff --git a/src/cmd/extrinsics.rs b/src/cmd/extrinsics.rs
new file mode 100644
index 0000000000000000000000000000000000000000..ffdabda421378f998c6f6670de856282417c5767
--- /dev/null
+++ b/src/cmd/extrinsics.rs
@@ -0,0 +1,59 @@
+// Copyright 2018-2019 Parity Technologies (UK) Ltd.
+// This file is part of ink!.
+//
+// ink! is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// ink! is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with ink!. If not, see .
+
+use anyhow::Result;
+use subxt::{ClientBuilder, DefaultNodeRuntime, ExtrinsicSuccess};
+
+use crate::ExtrinsicOpts;
+
+/// Submits an extrinsic to a substrate node, waits for it to succeed and returns an event expected
+/// to have been triggered by the extrinsic.
+pub(crate) fn submit_extrinsic(
+ extrinsic_opts: &ExtrinsicOpts,
+ call: subxt::Call,
+ event_mod: &str,
+ event_name: &str,
+) -> Result
+where
+ C: codec::Encode,
+ E: codec::Decode,
+{
+ let result: Result> = async_std::task::block_on(async move {
+ let cli = ClientBuilder::::new()
+ .set_url(&extrinsic_opts.url.to_string())
+ .build()
+ .await?;
+ let signer = extrinsic_opts.signer()?;
+ let xt = cli.xt(signer, None).await?;
+ let success = xt.watch().submit(call).await?;
+ Ok(success)
+ });
+
+ match result?.find_event::(event_mod, event_name) {
+ Some(Ok(hash)) => Ok(hash),
+ Some(Err(err)) => Err(anyhow::anyhow!(
+ "Failed to decode event '{} {}': {}",
+ event_mod,
+ event_name,
+ err
+ )),
+ None => Err(anyhow::anyhow!(
+ "Failed to find '{} {}' Event",
+ event_mod,
+ event_name
+ )),
+ }
+}
diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs
index 78b766256559200f9350952becc354eb5d3deb67..a7f9988296f82077fe3c99d5229166f2f85c5cc9 100644
--- a/src/cmd/mod.rs
+++ b/src/cmd/mod.rs
@@ -14,30 +14,30 @@
// You should have received a copy of the GNU General Public License
// along with ink!. If not, see .
-use crate::ExtrinsicOpts;
use anyhow::Result;
use std::{
io::{self, Write},
path::PathBuf,
process::Command,
};
-use subxt::{ClientBuilder, DefaultNodeRuntime, ExtrinsicSuccess};
mod build;
#[cfg(feature = "extrinsics")]
mod deploy;
#[cfg(feature = "extrinsics")]
+mod extrinsics;
+#[cfg(feature = "extrinsics")]
mod instantiate;
mod metadata;
mod new;
-#[cfg(feature = "extrinsics")]
-pub(crate) use self::deploy::execute_deploy;
-#[cfg(feature = "extrinsics")]
-pub(crate) use self::instantiate::execute_instantiate;
pub(crate) use self::{
build::execute_build, metadata::execute_generate_metadata, new::execute_new,
};
+#[cfg(feature = "extrinsics")]
+pub(crate) use self::{
+ deploy::execute_deploy, extrinsics::submit_extrinsic, instantiate::execute_instantiate,
+};
fn exec_cargo(command: &str, args: &[&'static str], working_dir: Option<&PathBuf>) -> Result<()> {
let mut cmd = Command::new("cargo");
@@ -71,45 +71,6 @@ fn exec_cargo(command: &str, args: &[&'static str], working_dir: Option<&PathBuf
Ok(())
}
-/// Submits an extrinsic to a substrate node, waits for it to succeed and returns an event expected
-/// to have been triggered by the extrinsic.
-fn submit_extrinsic(
- extrinsic_opts: &ExtrinsicOpts,
- call: subxt::Call,
- event_mod: &str,
- event_name: &str,
-) -> Result
-where
- C: codec::Encode,
- E: codec::Decode,
-{
- let result: Result> = async_std::task::block_on(async move {
- let cli = ClientBuilder::::new()
- .set_url(&extrinsic_opts.url.to_string())
- .build()
- .await?;
- let signer = extrinsic_opts.signer()?;
- let xt = cli.xt(signer, None).await?;
- let success = xt.watch().submit(call).await?;
- Ok(success)
- });
-
- match result?.find_event::(event_mod, event_name) {
- Some(Ok(hash)) => Ok(hash),
- Some(Err(err)) => Err(anyhow::anyhow!(
- "Failed to decode event '{} {}': {}",
- event_mod,
- event_name,
- err
- )),
- None => Err(anyhow::anyhow!(
- "Failed to find '{} {}' Event",
- event_mod,
- event_name
- )),
- }
-}
-
#[cfg(test)]
mod tests {
use std::path::PathBuf;
diff --git a/src/main.rs b/src/main.rs
index 2274c3dcb3ef2632a29a3faa012197e14e42f309..361847de1bdb92c998516304b28dfc189178664d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -18,7 +18,7 @@ mod cmd;
#[cfg(feature = "extrinsics")]
use sp_core::{crypto::Pair, sr25519, H256};
-use std::{path::PathBuf, result::Result as StdResult, str::FromStr};
+use std::path::PathBuf;
use anyhow::Result;
use structopt::{clap, StructOpt};
@@ -44,10 +44,10 @@ pub(crate) struct ContractArgs {
pub(crate) struct HexData(pub Vec);
#[cfg(feature = "extrinsics")]
-impl FromStr for HexData {
+impl std::str::FromStr for HexData {
type Err = hex::FromHexError;
- fn from_str(input: &str) -> StdResult {
+ fn from_str(input: &str) -> std::result::Result {
hex::decode(input).map(HexData)
}
}