Unverified Commit 41aa104f authored by Michael Müller's avatar Michael Müller Committed by GitHub
Browse files

Fix bugs in two examples + Fix `master` CI (#820)

* Enable debug output for `contract-transfer` example

It uses `debug_println!`.

* Enable sending payments to `fn invoke_transaction()`

It needs to be possible to send value with the transaction,
because `t.transferred_value` in this function could be set
to > 0.

* Rename `Error::UnknownError` to `Error::Unknown`

Clippy fails otherwise:

	= note: `-D clippy::enum-variant-names` implied by `-D warnings`
	= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names

* Revert "Enable sending payments to `fn invoke_transaction()`"

This reverts commit 9b051d2c.

* Require sending transaction payment to `fn invoke_transaction()`

It needs to be possible to send value with the transaction,
because `t.transferred_value` in this function could be set
to > 0.

* Fix interpunctuation

* Introduce `ink-debug` feature

* Revert "Introduce `ink-debug` feature"

This reverts commit e61673a5.
parent 9b7b92c1
Pipeline #144255 passed with stages
in 30 minutes and 33 seconds
......@@ -50,7 +50,7 @@ macro_rules! define_error_codes {
$name = $discr,
)*
/// Returns if an unknown error was received from the host module.
UnknownError,
Unknown,
}
impl From<ReturnCode> for Result {
......@@ -61,7 +61,7 @@ macro_rules! define_error_codes {
$(
$discr => Err(Error::$name),
)*
_ => Err(Error::UnknownError),
_ => Err(Error::Unknown),
}
}
}
......
......@@ -102,7 +102,7 @@ impl CryptoHash for Keccak256 {
impl From<ext::Error> for crate::Error {
fn from(ext_error: ext::Error) -> Self {
match ext_error {
ext::Error::UnknownError => Self::UnknownError,
ext::Error::Unknown => Self::Unknown,
ext::Error::CalleeTrapped => Self::CalleeTrapped,
ext::Error::CalleeReverted => Self::CalleeReverted,
ext::Error::KeyNotFound => Self::KeyNotFound,
......
......@@ -35,7 +35,7 @@ macro_rules! define_error_codes {
$name = $discr,
)*
/// Returns if an unknown error was received from the host module.
UnknownError,
Unknown,
}
impl From<ReturnCode> for Result {
......@@ -46,7 +46,7 @@ macro_rules! define_error_codes {
$(
$discr => Err(Error::$name),
)*
_ => Err(Error::UnknownError),
_ => Err(Error::Unknown),
}
}
}
......
......@@ -101,7 +101,7 @@ impl CryptoHash for Keccak256 {
impl From<ext::Error> for Error {
fn from(ext_error: ext::Error) -> Self {
match ext_error {
ext::Error::UnknownError => Self::UnknownError,
ext::Error::Unknown => Self::Unknown,
ext::Error::CalleeTrapped => Self::CalleeTrapped,
ext::Error::CalleeReverted => Self::CalleeReverted,
ext::Error::KeyNotFound => Self::KeyNotFound,
......
......@@ -45,7 +45,7 @@ pub enum Error {
/// The account that was called is either no contract (e.g. user account) or is a tombstone.
NotCallable,
/// An unknown error has occurred.
UnknownError,
Unknown,
/// The call to `seal_debug_message` had no effect because debug message
/// recording was disabled.
LoggingDisabled,
......
......@@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
ink_primitives = { version = "3.0.0-rc3", path = "../../crates/primitives", default-features = false }
ink_metadata = { version = "3.0.0-rc3", path = "../../crates/metadata", default-features = false, features = ["derive"], optional = true }
ink_env = { version = "3.0.0-rc3", path = "../../crates/env", default-features = false }
ink_env = { version = "3.0.0-rc3", path = "../../crates/env", default-features = false, features = [ "ink-debug" ] }
ink_storage = { version = "3.0.0-rc3", path = "../../crates/storage", default-features = false }
ink_lang = { version = "3.0.0-rc3", path = "../../crates/lang", default-features = false }
ink_prelude = { version = "3.0.0-rc3", path = "../../crates/prelude", default-features = false }
......
......@@ -484,15 +484,20 @@ mod multisig_plain {
/// Invoke a confirmed execution without getting its output.
///
/// If the transaction which is invoked transfers value, this value has
/// to be sent as payment with this call. The method will fail otherwise,
/// and the transaction would then be reverted.
///
/// Its return value indicates whether the called transaction was successful.
/// This can be called by anyone.
#[ink(message)]
#[ink(message, payable)]
pub fn invoke_transaction(
&mut self,
trans_id: TransactionId,
) -> Result<(), Error> {
self.ensure_confirmed(trans_id);
let t = self.take_transaction(trans_id).expect(WRONG_TRANSACTION_ID);
assert!(self.env().transferred_balance() == t.transferred_value);
let result = build_call::<<Self as ::ink_lang::ContractEnv>::Env>()
.callee(t.callee)
.gas_limit(t.gas_limit)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment