diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 51c26534a87..57cdca8999e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -26,9 +26,7 @@ variables: GIT_DEPTH: 100 CARGO_INCREMENTAL: 0 CARGO_TARGET_DIR: "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}" - # CI_IMAGE is changed to "-:staging" when the CI image gets rebuilt - # read more https://github.com/paritytech/scripts/pull/244 - CI_IMAGE: "paritytech/ink-ci-linux:a1f03f4b-20230420" + CI_IMAGE: "paritytech/ci-unified:bullseye-1.71.0-2023-05-23" PURELY_STD_CRATES: "ink/codegen metadata engine e2e e2e/macro ink/ir" ALSO_WASM_CRATES: "env storage storage/traits allocator prelude primitives ink ink/macro" ALL_CRATES: "${PURELY_STD_CRATES} ${ALSO_WASM_CRATES}" diff --git a/crates/e2e/Cargo.toml b/crates/e2e/Cargo.toml index 5ca85ef826f..97456a0df72 100644 --- a/crates/e2e/Cargo.toml +++ b/crates/e2e/Cargo.toml @@ -20,24 +20,24 @@ ink = { version = "4.2.1", path = "../ink" } ink_env = { version = "4.2.1", path = "../env" } ink_primitives = { version = "4.2.1", path = "../primitives" } -funty = { workspace = true } -impl-serde = { workspace = true } -jsonrpsee = { workspace = true, features = ["ws-client"] } -serde = { workspace = true, features = ["derive"] } -serde_json = { workspace = true } -tokio = { workspace = true, features = ["rt-multi-thread"] } -tracing = { workspace = true } -tracing-subscriber = { workspace = true, features = ["env-filter"] } -scale = { package = "parity-scale-codec", workspace = true } -subxt = { workspace = true } -subxt-signer = { workspace = true, features = ["subxt", "sr25519"] } +funty = "2.0.0" +impl-serde = { version = "0.3.1", default-features = false } +jsonrpsee = { version = "0.17.0", features = ["ws-client"] } +serde = { version = "1.0.137", default-features = false, features = ["derive"] } +serde_json = { version = "1.0.81" } +tokio = { version = "1.18.2", features = ["rt-multi-thread"] } +log = { version = "0.4" } +env_logger = { version = "0.10" } +scale = { package = "parity-scale-codec", version = "3.4", default-features = false, features = ["derive"] } +subxt = "0.31.0" +subxt-signer = { version = "0.31.0", features = ["subxt", "sr25519"] } # Substrate -pallet-contracts-primitives = { workspace = true } -sp-core = { workspace = true } -sp-keyring = { workspace = true } -sp-runtime = { workspace = true } -sp-weights = { workspace = true } +pallet-contracts-primitives = "24.0.0" +sp-core = "21.0.0" +sp-keyring = "24.0.0" +sp-runtime = "24.0.0" +sp-weights = "20.0.0" [dev-dependencies] # Required for the doctest of `MessageBuilder::call` diff --git a/crates/e2e/macro/Cargo.toml b/crates/e2e/macro/Cargo.toml index 6a54eb56468..098010367da 100644 --- a/crates/e2e/macro/Cargo.toml +++ b/crates/e2e/macro/Cargo.toml @@ -21,7 +21,7 @@ proc-macro = true [dependencies] ink_ir = { version = "4.2.1", path = "../../ink/ir" } cargo_metadata = "0.15.3" -contract-build = "2.0.2" +contract-build = "3.2.0" derive_more = "0.99.17" env_logger = "0.10.0" log = "0.4.17" diff --git a/crates/e2e/macro/src/codegen.rs b/crates/e2e/macro/src/codegen.rs index 512a9183cd3..9f0c8768cba 100644 --- a/crates/e2e/macro/src/codegen.rs +++ b/crates/e2e/macro/src/codegen.rs @@ -293,7 +293,6 @@ fn build_contract(path_to_cargo_toml: &str) -> String { output_type: OutputType::HumanReadable, skip_wasm_validation: false, target: Target::Wasm, - ..ExecuteArgs::default() }; match contract_build::execute(args) { diff --git a/crates/e2e/src/client.rs b/crates/e2e/src/client.rs index 87be6c9d743..f7f5971558b 100644 --- a/crates/e2e/src/client.rs +++ b/crates/e2e/src/client.rs @@ -29,23 +29,9 @@ use super::{ ContractsApi, Keypair, }; -use crate::contract_results::{ - CallDryRunResult, - CallResult, - InstantiationResult, - UploadResult, -}; -use ink_env::{ - call::{ - utils::{ - ReturnType, - Set, - }, - Call, - ExecutionInput, - }, - Environment, -}; +use ink_env::Environment; +use ink_primitives::MessageResult; +use pallet_contracts_primitives::ExecReturnValue; #[cfg(feature = "std")] use std::{ collections::BTreeMap, @@ -64,22 +50,320 @@ use subxt::{ ValueDef, }, tx::Signer, + Config, }; -pub type Error = crate::error::Error< - ::AccountId, - ::Balance, - ::Hash, - subxt::error::DispatchError, ->; - -/// Represents an initialized contract message builder. -pub type CallBuilderFinal = ink_env::call::CallBuilder< - E, - Set>, - Set>, - Set>, ->; +/// Result of a contract instantiation. +pub struct InstantiationResult { + /// The account id at which the contract was instantiated. + pub account_id: E::AccountId, + /// The result of the dry run, contains debug messages + /// if there were any. + pub dry_run: ContractInstantiateResult, + /// Events that happened with the contract instantiation. + pub events: ExtrinsicEvents, +} + +/// Result of a contract upload. +pub struct UploadResult { + /// The hash with which the contract can be instantiated. + pub code_hash: E::Hash, + /// The result of the dry run, contains debug messages + /// if there were any. + pub dry_run: CodeUploadResult, + /// Events that happened with the contract instantiation. + pub events: ExtrinsicEvents, +} + +/// We implement a custom `Debug` here, to avoid requiring the trait +/// bound `Debug` for `E`. +impl Debug for UploadResult +where + C: subxt::Config, + E: Environment, + ::Balance: Debug, + ::Hash: Debug, +{ + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + f.debug_struct("UploadResult") + .field("code_hash", &self.code_hash) + .field("dry_run", &self.dry_run) + .field("events", &self.events) + .finish() + } +} + +/// We implement a custom `Debug` here, as to avoid requiring the trait +/// bound `Debug` for `E`. +impl core::fmt::Debug for InstantiationResult +where + C: subxt::Config, + C::AccountId: Debug, + E: Environment, + ::AccountId: Debug, + ::Balance: Debug, +{ + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + f.debug_struct("InstantiationResult") + .field("account_id", &self.account_id) + .field("dry_run", &self.dry_run) + .field("events", &self.events) + .finish() + } +} + +/// Result of a contract call. +pub struct CallResult { + /// The result of the dry run, contains debug messages + /// if there were any. + pub dry_run: CallDryRunResult, + /// Events that happened with the contract instantiation. + pub events: ExtrinsicEvents, +} + +impl CallResult +where + C: subxt::Config, + E: Environment, + V: scale::Decode, +{ + /// Returns the [`MessageResult`] from the execution of the dry-run message + /// call. + /// + /// # Panics + /// - if the dry-run message call failed to execute. + /// - if message result cannot be decoded into the expected return value type. + pub fn message_result(&self) -> MessageResult { + self.dry_run.message_result() + } + + /// Returns the decoded return value of the message from the dry-run. + /// + /// Panics if the value could not be decoded. The raw bytes can be accessed + /// via [`CallResult::return_data`]. + pub fn return_value(self) -> V { + self.dry_run.return_value() + } + + /// Returns the return value as raw bytes of the message from the dry-run. + /// + /// Panics if the dry-run message call failed to execute. + pub fn return_data(&self) -> &[u8] { + &self.dry_run.exec_return_value().data + } + + /// Returns any debug message output by the contract decoded as UTF-8. + pub fn debug_message(&self) -> String { + self.dry_run.debug_message() + } + + /// Returns true if the specified event was triggered by the call. + pub fn contains_event(&self, pallet_name: &str, variant_name: &str) -> bool { + self.events.iter().any(|event| { + let event = event.unwrap(); + event.pallet_name() == pallet_name && event.variant_name() == variant_name + }) + } +} + +/// We implement a custom `Debug` here, as to avoid requiring the trait +/// bound `Debug` for `E`. +// TODO(#xxx) Improve the `Debug` implementation. +impl Debug for CallResult +where + C: subxt::Config + Debug, + E: Environment + Debug, + ::Balance: Debug, + V: Debug, +{ + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + f.debug_struct("CallResult") + .field("dry_run", &self.dry_run) + .field("events", &self.events) + .finish() + } +} + +/// Result of the dry run of a contract call. +#[derive(Debug)] +pub struct CallDryRunResult { + /// The result of the dry run, contains debug messages + /// if there were any. + pub exec_result: ContractExecResult, + _marker: PhantomData, +} + +impl CallDryRunResult +where + E: Environment, + V: scale::Decode, +{ + /// Returns true if the dry-run execution resulted in an error. + pub fn is_err(&self) -> bool { + self.exec_result.result.is_err() + } + + /// Returns the [`ExecReturnValue`] resulting from the dry-run message call. + /// + /// Panics if the dry-run message call failed to execute. + pub fn exec_return_value(&self) -> &ExecReturnValue { + self.exec_result + .result + .as_ref() + .unwrap_or_else(|call_err| panic!("Call dry-run failed: {call_err:?}")) + } + + /// Returns the [`MessageResult`] from the execution of the dry-run message + /// call. + /// + /// # Panics + /// - if the dry-run message call failed to execute. + /// - if message result cannot be decoded into the expected return value type. + pub fn message_result(&self) -> MessageResult { + let data = &self.exec_return_value().data; + scale::Decode::decode(&mut data.as_ref()).unwrap_or_else(|env_err| { + panic!( + "Decoding dry run result to ink! message return type failed: {env_err}" + ) + }) + } + + /// Returns the decoded return value of the message from the dry-run. + /// + /// Panics if the value could not be decoded. The raw bytes can be accessed + /// via [`CallResult::return_data`]. + pub fn return_value(self) -> V { + self.message_result() + .unwrap_or_else(|lang_err| { + panic!( + "Encountered a `LangError` while decoding dry run result to ink! message: {lang_err:?}" + ) + }) + } + + /// Returns the return value as raw bytes of the message from the dry-run. + /// + /// Panics if the dry-run message call failed to execute. + pub fn return_data(&self) -> &[u8] { + &self.exec_return_value().data + } + + /// Returns any debug message output by the contract decoded as UTF-8. + pub fn debug_message(&self) -> String { + String::from_utf8_lossy(&self.exec_result.debug_message).into() + } +} + +/// An error occurred while interacting with the Substrate node. +/// +/// We only convey errors here that are caused by the contract's +/// testing logic. For anything concerning the node (like inability +/// to communicate with it, fetch the nonce, account info, etc.) we +/// panic. +pub enum Error +where + C: subxt::Config, + E: Environment, + ::Balance: core::fmt::Debug, +{ + /// No contract with the given name found in scope. + ContractNotFound(String), + /// The `instantiate_with_code` dry run failed. + InstantiateDryRun(ContractInstantiateResult), + /// The `instantiate_with_code` extrinsic failed. + InstantiateExtrinsic(subxt::error::DispatchError), + /// The `upload` dry run failed. + UploadDryRun(CodeUploadResult), + /// The `upload` extrinsic failed. + UploadExtrinsic(subxt::error::DispatchError), + /// The `call` dry run failed. + CallDryRun(ContractExecResult), + /// The `call` extrinsic failed. + CallExtrinsic(subxt::error::DispatchError), + /// Error fetching account balance. + Balance(String), + /// Decoding failed. + Decoding(subxt::Error), +} + +// We implement a custom `Debug` here, as to avoid requiring the trait +// bound `Debug` for `C`. +// TODO(#xxx) Improve the Debug implementations below to also output `_`. +impl core::fmt::Debug for Error +where + C: subxt::Config, + E: Environment, + ::Balance: core::fmt::Debug, +{ + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + match &self { + Error::ContractNotFound(name) => { + f.write_str(&format!("ContractNotFound: {name}")) + } + Error::InstantiateDryRun(res) => { + f.write_str(&format!( + "InstantiateDryRun: {}", + &String::from_utf8_lossy(&res.debug_message) + )) + } + Error::InstantiateExtrinsic(_) => f.write_str("InstantiateExtrinsic"), + Error::UploadDryRun(_) => f.write_str("UploadDryRun"), + Error::UploadExtrinsic(_) => f.write_str("UploadExtrinsic"), + Error::CallDryRun(_) => f.write_str("CallDryRun"), + Error::CallExtrinsic(_) => f.write_str("CallExtrinsic"), + Error::Balance(msg) => write!(f, "Balance: {msg}"), + Error::Decoding(err) => write!(f, "Decoding: {err}"), + } + } +} + +/// A contract was successfully instantiated. +#[derive( + Debug, + scale::Decode, + scale::Encode, + scale_decode::DecodeAsType, + scale_encode::EncodeAsType, +)] +#[decode_as_type(trait_bounds = "", crate_path = "subxt::ext::scale_decode")] +#[encode_as_type(crate_path = "subxt::ext::scale_encode")] +struct ContractInstantiatedEvent { + /// Account id of the deployer. + pub deployer: E::AccountId, + /// Account id where the contract was instantiated to. + pub contract: E::AccountId, +} + +impl subxt::events::StaticEvent for ContractInstantiatedEvent +where + E: Environment, +{ + const PALLET: &'static str = "Contracts"; + const EVENT: &'static str = "Instantiated"; +} + +/// Code with the specified hash has been stored. +#[derive( + Debug, + scale::Decode, + scale::Encode, + scale_decode::DecodeAsType, + scale_encode::EncodeAsType, +)] +#[decode_as_type(trait_bounds = "", crate_path = "subxt::ext::scale_decode")] +#[encode_as_type(crate_path = "subxt::ext::scale_encode")] +struct CodeStoredEvent { + /// Hash under which the contract code was stored. + pub code_hash: E::Hash, +} + +impl subxt::events::StaticEvent for CodeStoredEvent +where + E: Environment, +{ + const PALLET: &'static str = "Contracts"; + const EVENT: &'static str = "CodeStored"; +} /// The `Client` takes care of communicating with the node. /// @@ -182,7 +466,7 @@ where &mut self, contract_name: &str, signer: &Keypair, - constructor: CreateBuilderPartial, + constructor: CreateBuilderPartial, value: E::Balance, storage_deposit_limit: Option, ) -> Result>, Error> @@ -208,10 +492,10 @@ where &mut self, contract_name: &str, signer: &Keypair, - constructor: CreateBuilderPartial, + constructor: CreateBuilderPartial, value: E::Balance, storage_deposit_limit: Option, - ) -> ContractInstantiateResult + ) -> ContractInstantiateResult where Args: scale::Encode, { @@ -452,7 +736,7 @@ where pub async fn call( &mut self, signer: &Keypair, - message: &CallBuilderFinal, + message: Message, value: E::Balance, storage_deposit_limit: Option, ) -> Result>, Error> @@ -553,7 +837,7 @@ where pub async fn call_dry_run( &mut self, signer: &Keypair, - message: &CallBuilderFinal, + message: &Message, value: E::Balance, storage_deposit_limit: Option, ) -> CallDryRunResult @@ -569,8 +853,7 @@ where .api .call_dry_run( Signer::::account_id(signer), - dest, - exec_input, + message, value, storage_deposit_limit, ) @@ -666,7 +949,7 @@ where } /// Returns true if the give event is System::Extrinsic failed. -fn is_extrinsic_failed_event(event: &EventDetails) -> bool { +fn is_extrinsic_failed_event(event: &EventDetails) -> bool { event.pallet_name() == "System" && event.variant_name() == "ExtrinsicFailed" } diff --git a/crates/e2e/src/lib.rs b/crates/e2e/src/lib.rs index 301c71fe3fb..d29bccba32a 100644 --- a/crates/e2e/src/lib.rs +++ b/crates/e2e/src/lib.rs @@ -21,9 +21,6 @@ mod builders; mod client; -mod contract_results; -mod error; -pub mod events; mod node_proc; mod xts; @@ -38,6 +35,7 @@ pub use contract_results::{ InstantiationResult, UploadResult, }; +pub use env_logger; pub use ink_e2e_macro::test; pub use node_proc::{ TestNodeProcess, diff --git a/crates/e2e/src/node_proc.rs b/crates/e2e/src/node_proc.rs index f7358b33e5c..60d777f3a05 100644 --- a/crates/e2e/src/node_proc.rs +++ b/crates/e2e/src/node_proc.rs @@ -149,7 +149,7 @@ where } Err(err) => { let err = format!("Failed to connect to node rpc at {url}: {err}"); - tracing::error!("{}", err); + log::error!("{}", err); proc.kill().map_err(|e| { format!("Error killing substrate process '{}': {}", proc.id(), e) })?; diff --git a/crates/e2e/src/xts.rs b/crates/e2e/src/xts.rs index fe1fbacb7bc..c5fa06fbf89 100644 --- a/crates/e2e/src/xts.rs +++ b/crates/e2e/src/xts.rs @@ -268,7 +268,7 @@ where data: Vec, salt: Vec, signer: &Keypair, - ) -> ContractInstantiateResult { + ) -> ContractInstantiateResult { let code = Code::Upload(code); let call_request = RpcInstantiateRequest:: { origin: Signer::::account_id(signer), diff --git a/crates/env/Cargo.toml b/crates/env/Cargo.toml index 1794537ba47..2625d23c26e 100644 --- a/crates/env/Cargo.toml +++ b/crates/env/Cargo.toml @@ -50,9 +50,9 @@ schnorrkel = { version = "0.10.2", optional = true } # # Sadly couldn't be marked as dev-dependency. # Never use this crate outside the off-chain environment! -scale-decode = { workspace = true, optional = true } -scale-encode = { workspace = true, optional = true } -scale-info = { workspace = true, features = ["derive"], optional = true } +scale-decode = { version = "0.9.0", default-features = false, optional = true } +scale-encode = { version = "0.5.0", default-features = false, optional = true } +scale-info = { version = "2.5", default-features = false, features = ["derive"], optional = true } [dev-dependencies] ink = { workspace = true } diff --git a/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr b/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr index 7b6483a4fe1..877500181fa 100644 --- a/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr +++ b/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr @@ -52,7 +52,7 @@ error[E0599]: the method `try_invoke` exists for struct `CallBuilder $CARGO/parity-scale-codec-3.5.0/src/codec.rs + --> $CARGO/parity-scale-codec-3.6.4/src/codec.rs | | pub trait Decode: Sized { | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr b/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr index 78cd797fd0a..f2321903953 100644 --- a/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr +++ b/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr @@ -36,7 +36,7 @@ error[E0599]: the method `try_invoke` exists for struct `CallBuilder $CARGO/parity-scale-codec-3.5.0/src/codec.rs + --> $CARGO/parity-scale-codec-3.6.4/src/codec.rs | | pub trait Decode: Sized { | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 95f35abe42f..ac30010361a 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -18,8 +18,8 @@ include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"] derive_more = { version = "0.99", default-features = false, features = ["from", "display"] } ink_prelude = { version = "4.2.1", path = "../prelude/", default-features = false } scale = { package = "parity-scale-codec", version = "3.4", default-features = false, features = ["derive"] } -scale-decode = { version = "0.5.0", default-features = false, features = ["derive"], optional = true } -scale-encode = { version = "0.1.0", default-features = false, features = ["derive"], optional = true } +scale-decode = { version = "0.9.0", default-features = false, features = ["derive"], optional = true } +scale-encode = { version = "0.5.0", default-features = false, features = ["derive"], optional = true } scale-info = { version = "2.5", default-features = false, features = ["derive"], optional = true } xxhash-rust = { version = "0.8", features = ["const_xxh32"] } diff --git a/integration-tests/e2e-call-runtime/Cargo.toml b/integration-tests/e2e-call-runtime/Cargo.toml index a4d7b650355..3b589611bb7 100644 --- a/integration-tests/e2e-call-runtime/Cargo.toml +++ b/integration-tests/e2e-call-runtime/Cargo.toml @@ -13,7 +13,7 @@ scale-info = { version = "2.6", default-features = false, features = ["derive"], [dev-dependencies] ink_e2e = { path = "../../crates/e2e" } -subxt = { version = "0.30.0", default-features = false } +subxt = { version = "0.31.0", default-features = false } [lib] path = "lib.rs" diff --git a/integration-tests/e2e-call-runtime/lib.rs b/integration-tests/e2e-call-runtime/lib.rs index 16a899feb4e..d72b06e9424 100644 --- a/integration-tests/e2e-call-runtime/lib.rs +++ b/integration-tests/e2e-call-runtime/lib.rs @@ -32,9 +32,8 @@ pub mod e2e_call_runtime { let contract = client .instantiate("e2e_call_runtime", &ink_e2e::alice(), constructor, 0, None) .await - .expect("instantiate failed"); - let call = contract.call::(); - + .expect("instantiate failed") + .account_id; let transfer_amount = 100_000_000_000u128; // when @@ -47,7 +46,8 @@ pub mod e2e_call_runtime { Value::u128(transfer_amount), ]; - let get_balance = call.get_contract_balance(); + let get_balance = build_message::(contract_acc_id.clone()) + .call(|contract| contract.get_contract_balance()); let pre_balance = client .call_dry_run(&ink_e2e::alice(), &get_balance, 0, None) .await diff --git a/integration-tests/lang-err-integration-tests/call-builder-delegate/lib.rs b/integration-tests/lang-err-integration-tests/call-builder-delegate/lib.rs index 66ec07f6cc7..5cfc5e1d8a9 100755 --- a/integration-tests/lang-err-integration-tests/call-builder-delegate/lib.rs +++ b/integration-tests/lang-err-integration-tests/call-builder-delegate/lib.rs @@ -94,6 +94,7 @@ mod call_builder { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; + use ink_e2e::build_message; type E2EResult = std::result::Result>; @@ -107,11 +108,11 @@ mod call_builder { let expected_value = 42; let constructor = CallBuilderDelegateTestRef::new(expected_value); - let call_builder = client + let contract_acc_id = client .instantiate("call_builder_delegate", &origin, constructor, 0, None) .await - .expect("instantiate failed"); - let mut call_builder_call = call_builder.call::(); + .expect("instantiate failed") + .account_id; let code_hash = client .upload("incrementer", &origin, None) @@ -120,9 +121,13 @@ mod call_builder { .code_hash; let selector = ink::selector_bytes!("get"); - let call = call_builder_call.invoke(code_hash, selector); + let call = + build_message::(contract_acc_id.clone()) + .call(|call_builder_contract| { + call_builder_contract.invoke(code_hash, selector) + }); let call_result = client - .call(&origin, &call, 0, None) + .call(&origin, call, 0, None) .await .expect("Client failed to call `call_builder::invoke`.") .return_value(); @@ -144,12 +149,11 @@ mod call_builder { .await; let constructor = CallBuilderDelegateTestRef::new(Default::default()); - let call_builder_contract = client + let contract_acc_id = client .instantiate("call_builder_delegate", &origin, constructor, 0, None) .await - .expect("instantiate failed"); - let mut call_builder_call = - call_builder_contract.call::(); + .expect("instantiate failed") + .account_id; let code_hash = client .upload("incrementer", &origin, None) @@ -158,9 +162,13 @@ mod call_builder { .code_hash; let selector = ink::selector_bytes!("invalid_selector"); - let call = call_builder_call.delegate(code_hash, selector); + let call = + build_message::(contract_acc_id.clone()) + .call(|call_builder_contract| { + call_builder_contract.delegate(code_hash, selector) + }); let call_result = client - .call(&origin, &call, 0, None) + .call(&origin, call, 0, None) .await .expect("Calling `call_builder::delegate` failed"); @@ -181,12 +189,11 @@ mod call_builder { .await; let constructor = CallBuilderDelegateTestRef::new(Default::default()); - let call_builder_contract = client + let contract_acc_id = client .instantiate("call_builder_delegate", &origin, constructor, 0, None) .await - .expect("instantiate failed"); - let mut call_builder_call = - call_builder_contract.call::(); + .expect("instantiate failed") + .account_id; let code_hash = client .upload("incrementer", &origin, None) @@ -197,7 +204,11 @@ mod call_builder { // Since `LangError`s can't be handled by the `CallBuilder::invoke()` method // we expect this to panic. let selector = ink::selector_bytes!("invalid_selector"); - let call = call_builder_call.invoke(code_hash, selector); + let call = + build_message::(contract_acc_id.clone()) + .call(|call_builder_contract| { + call_builder_contract.invoke(code_hash, selector) + }); let call_result = client.call_dry_run(&origin, &call, 0, None).await; assert!(call_result.is_err()); diff --git a/integration-tests/payment-channel/Cargo.toml b/integration-tests/payment-channel/Cargo.toml index 6d71793a825..133837b0225 100755 --- a/integration-tests/payment-channel/Cargo.toml +++ b/integration-tests/payment-channel/Cargo.toml @@ -9,7 +9,7 @@ publish = false ink = { path = "../../crates/ink", default-features = false } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } -scale-info = { version = "2.6", default-features = false, features = ["derive"], optional = true } +scale-info = { version = "2.5", default-features = false, features = ["derive"], optional = true } [dev-dependencies] hex-literal = { version = "0.4.1" }