diff --git a/crates/env/src/call/create_builder.rs b/crates/env/src/call/create_builder.rs index 541a1b3058..ed3b203213 100644 --- a/crates/env/src/call/create_builder.rs +++ b/crates/env/src/call/create_builder.rs @@ -368,8 +368,8 @@ where /// # } /// # use contract::MyContractRef; /// let my_contract: MyContractRef = build_create::() -/// .code_hash(Hash::from([0x42; 32])) -/// .endowment(25) +/// .code_hash(ink::H256::from([0x42; 32])) +/// .endowment(25.into()) /// .exec_input( /// ExecutionInput::new(Selector::new(ink::selector_bytes!("my_constructor"))) /// .push_arg(42) @@ -412,8 +412,8 @@ where /// # } /// # use contract::{MyContractRef, ConstructorError}; /// let my_contract: MyContractRef = build_create::() -/// .code_hash(Hash::from([0x42; 32])) -/// .endowment(25) +/// .code_hash(ink::H256::from([0x42; 32])) +/// .endowment(25.into()) /// .exec_input( /// ExecutionInput::new(Selector::new(ink::selector_bytes!("my_constructor"))) /// .push_arg(42) @@ -531,7 +531,7 @@ where CreateBuilder { code_hash: self.code_hash, limits: self.limits, - endowment: endowment, + endowment, exec_input: self.exec_input, salt: self.salt, return_type: self.return_type, diff --git a/crates/env/src/contract.rs b/crates/env/src/contract.rs index 86b5d1b524..423b9a1cc0 100644 --- a/crates/env/src/contract.rs +++ b/crates/env/src/contract.rs @@ -58,6 +58,7 @@ /// type BlockNumber = u32; /// type Timestamp = u64; /// type ChainExtension = ::ChainExtension; +/// type EventRecord = ::EventRecord; /// } /// /// #[ink::contract(env = super::CustomEnvironment)] diff --git a/crates/env/src/engine/on_chain/buffer.rs b/crates/env/src/engine/on_chain/buffer.rs index 6987552214..b9444c05e8 100644 --- a/crates/env/src/engine/on_chain/buffer.rs +++ b/crates/env/src/engine/on_chain/buffer.rs @@ -79,7 +79,7 @@ impl<'a> EncodeScope<'a> { } } -impl<'a> scale::Output for EncodeScope<'a> { +impl scale::Output for EncodeScope<'_> { fn write(&mut self, bytes: &[u8]) { debug_assert!( self.len().checked_add(bytes.len()).unwrap() <= self.capacity(), diff --git a/crates/env/src/engine/on_chain/pallet_revive.rs b/crates/env/src/engine/on_chain/pallet_revive.rs index 74a06d99ae..6b32a99849 100644 --- a/crates/env/src/engine/on_chain/pallet_revive.rs +++ b/crates/env/src/engine/on_chain/pallet_revive.rs @@ -657,9 +657,11 @@ impl TypedEnvBackend for EnvInstance { Some(output), ); match call_result { - Ok(()) | Err(ReturnErrorCode::CalleeReverted) => { - let decoded = scale::DecodeAll::decode_all(&mut &output[..])?; - Ok(decoded) + Ok(()) => { + // no need to decode, is () + //let decoded = scale::DecodeAll::decode_all(&mut &output[..])?; + //Ok(decoded) + Ok(()) } Err(actual_error) => Err(actual_error.into()), } diff --git a/crates/ink/macro/src/lib.rs b/crates/ink/macro/src/lib.rs index 1e20413687..c2fe0f31c6 100644 --- a/crates/ink/macro/src/lib.rs +++ b/crates/ink/macro/src/lib.rs @@ -171,6 +171,7 @@ pub fn selector_bytes(input: TokenStream) -> TokenStream { /// type Timestamp = u64; /// type BlockNumber = u32; /// type ChainExtension = ::ink::env::NoChainExtension; +/// type EventRecord = (); /// } /// ``` /// A user might implement their ink! smart contract using the above custom @@ -189,6 +190,7 @@ pub fn selector_bytes(input: TokenStream) -> TokenStream { /// # type Timestamp = u64; /// # type BlockNumber = u32; /// # type ChainExtension = ::ink::env::NoChainExtension; +/// # type EventRecord = (); /// # } /// # /// # #[ink(storage)] @@ -398,7 +400,7 @@ pub fn selector_bytes(input: TokenStream) -> TokenStream { /// For example it is possible to query the current call's caller via: /// ``` /// # ink_env::test::run_test::(|_| { -/// let caller = ink_env::caller::(); +/// let caller = ink_env::caller(); /// # let _caller = caller; /// # Ok(()) /// # }).unwrap(); @@ -445,23 +447,25 @@ pub fn selector_bytes(input: TokenStream) -> TokenStream { /// ``` /// #[ink::contract] /// mod erc20 { +/// use ink::{H160, U256}; +/// /// /// Defines an event that is emitted every time value is transferred. /// #[ink(event)] /// pub struct Transferred { -/// from: Option, -/// to: Option, -/// value: Balance, +/// from: Option, +/// to: Option, +/// value: U256, /// } /// /// #[ink(storage)] /// pub struct Erc20 { -/// total_supply: Balance, +/// total_supply: U256, /// // more fields... /// } /// /// impl Erc20 { /// #[ink(constructor)] -/// pub fn new(initial_supply: Balance) -> Self { +/// pub fn new(initial_supply: U256) -> Self { /// let caller = Self::env().caller(); /// Self::env().emit_event(Transferred { /// from: None, @@ -474,7 +478,7 @@ pub fn selector_bytes(input: TokenStream) -> TokenStream { /// } /// /// #[ink(message)] -/// pub fn total_supply(&self) -> Balance { +/// pub fn total_supply(&self) -> U256 { /// self.total_supply /// } /// } @@ -538,18 +542,15 @@ pub fn contract(attr: TokenStream, item: TokenStream) -> TokenStream { /// # Trait definition: /// /// ``` -/// # type Balance = ::Balance; -/// # type AccountId = ::AccountId; -/// /// #[ink::trait_definition] /// pub trait Erc20 { /// /// Returns the total supply of the ERC-20 smart contract. /// #[ink(message)] -/// fn total_supply(&self) -> Balance; +/// fn total_supply(&self) -> ink::U256; /// /// /// Transfers balance from the caller to the given address. /// #[ink(message)] -/// fn transfer(&mut self, amount: Balance, to: ink::H160) -> bool; +/// fn transfer(&mut self, amount: ink::U256, to: ink::H160) -> bool; /// /// // etc. /// } @@ -562,26 +563,27 @@ pub fn contract(attr: TokenStream, item: TokenStream) -> TokenStream { /// ``` /// #[ink::contract] /// mod base_erc20 { +/// use ink::{H160, U256}; /// # // We somehow cannot put the trait in the doc-test crate root due to bugs. /// # #[ink::trait_definition] /// # pub trait Erc20 { /// # /// Returns the total supply of the ERC-20 smart contract. /// # #[ink(message)] -/// # fn total_supply(&self) -> Balance; +/// # fn total_supply(&self) -> U256; /// # /// # /// Transfers balance from the caller to the given address. /// # #[ink(message)] -/// # fn transfer(&mut self, amount: Balance, to: H160) -> bool; +/// # fn transfer(&mut self, amount: U256, to: H160) -> bool; /// # } /// # /// #[ink(storage)] /// pub struct BaseErc20 { -/// total_supply: Balance, +/// total_supply: U256, /// } /// /// impl BaseErc20 { /// #[ink(constructor)] -/// pub fn new(initial_supply: Balance) -> Self { +/// pub fn new(initial_supply: U256) -> Self { /// Self { total_supply: initial_supply } /// } /// } @@ -589,12 +591,12 @@ pub fn contract(attr: TokenStream, item: TokenStream) -> TokenStream { /// impl Erc20 for BaseErc20 { /// /// Returns the total supply of the ERC-20 smart contract. /// #[ink(message)] -/// fn total_supply(&self) -> Balance { +/// fn total_supply(&self) -> H256 { /// self.total_supply /// } /// /// #[ink(message)] -/// fn transfer(&mut self, amount: Balance, to: H160) -> bool { +/// fn transfer(&mut self, amount: U256, to: H160) -> bool { /// unimplemented!() /// } /// } @@ -1180,6 +1182,7 @@ pub fn test(attr: TokenStream, item: TokenStream) -> TokenStream { /// type Hash = ::Hash; /// type BlockNumber = ::BlockNumber; /// type Timestamp = ::Timestamp; +/// type EventRecord = ::EventRecord; /// /// type ChainExtension = RuntimeReadWrite; /// } @@ -1321,6 +1324,7 @@ pub fn test(attr: TokenStream, item: TokenStream) -> TokenStream { /// # type Hash = ::Hash; /// # type BlockNumber = ::BlockNumber; /// # type Timestamp = ::Timestamp; +/// # type EventRecord = ::EventRecord; /// # /// # type ChainExtension = RuntimeReadWrite; /// # } diff --git a/crates/ink/src/env_access.rs b/crates/ink/src/env_access.rs index e48ab78e7b..5144a8d269 100644 --- a/crates/ink/src/env_access.rs +++ b/crates/ink/src/env_access.rs @@ -303,7 +303,7 @@ where /// # /// /// Returns the contract's balance. /// #[ink(message)] - /// pub fn my_balance(&self) -> Balance { + /// pub fn my_balance(&self) -> ink::U256 { /// self.env().balance() /// } /// # @@ -440,14 +440,14 @@ where /// .ref_time_limit(500_000_000) /// .proof_size_limit(100_000) /// .storage_deposit_limit(500_000_000_000) - /// .endowment(25) + /// .endowment(25.into()) /// .exec_input( /// ExecutionInput::new(Selector::new(ink::selector_bytes!("new"))) /// .push_arg(42) /// .push_arg(true) /// .push_arg(&[0x10u8; 32]), /// ) - /// .salt_bytes(Some([0xCA, 0xFE, 0xBA, 0xBE])) + /// .salt_bytes(Some([0x13; 32])) /// .returns::() /// .params(); /// self.env() @@ -590,7 +590,7 @@ where /// pub fn invoke_contract_delegate(&self) -> i32 { /// let call_params = build_call::() /// .call_type(DelegateCall::new( - /// ink::H256::zero(), + /// ink::H160::zero(), /// )) /// .exec_input( /// ExecutionInput::new(Selector::new([0xCA, 0xFE, 0xBA, 0xBE])) diff --git a/crates/ink/tests/ui/contract/fail/constructor-return-result-invalid.stderr b/crates/ink/tests/ui/contract/fail/constructor-return-result-invalid.stderr index 5bd02c7af0..f761a45649 100644 --- a/crates/ink/tests/ui/contract/fail/constructor-return-result-invalid.stderr +++ b/crates/ink/tests/ui/contract/fail/constructor-return-result-invalid.stderr @@ -24,14 +24,14 @@ error[E0277]: the trait bound `Result: ConstructorReturnTyp = help: the following other types implement trait `ConstructorReturnType`: `Result` implements `ConstructorReturnType` `Result` implements `ConstructorReturnType` -note: required by a bound in `CreateBuilder::>>::returns` +note: required by a bound in `CreateBuilder::>>::returns` --> $WORKSPACE/crates/env/src/call/create_builder.rs | | pub fn returns( | ------- required by a bound in this associated function ... | R: ConstructorReturnType, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `CreateBuilder::>>::returns` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `CreateBuilder::>>::returns` error[E0277]: the trait bound `ConstructorOutputValue>: ConstructorOutput` is not satisfied --> tests/ui/contract/fail/constructor-return-result-invalid.rs:4:16 diff --git a/crates/ink/tests/ui/contract/fail/constructor-return-result-non-codec-error.stderr b/crates/ink/tests/ui/contract/fail/constructor-return-result-non-codec-error.stderr index b6dca220c5..c53d04f77f 100644 --- a/crates/ink/tests/ui/contract/fail/constructor-return-result-non-codec-error.stderr +++ b/crates/ink/tests/ui/contract/fail/constructor-return-result-non-codec-error.stderr @@ -34,14 +34,14 @@ error[E0277]: the trait bound `contract::Error: WrapperTypeDecode` is not satisf sp_core::Bytes = note: required for `contract::Error` to implement `ink::parity_scale_codec::Decode` = note: required for `Result` to implement `ConstructorReturnType` -note: required by a bound in `CreateBuilder::>>::returns` +note: required by a bound in `CreateBuilder::>>::returns` --> $WORKSPACE/crates/env/src/call/create_builder.rs | | pub fn returns( | ------- required by a bound in this associated function ... | R: ConstructorReturnType, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `CreateBuilder::>>::returns` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `CreateBuilder::>>::returns` error[E0277]: the trait bound `contract::Error: TypeInfo` is not satisfied --> tests/ui/contract/fail/constructor-return-result-non-codec-error.rs:4:16 diff --git a/crates/ink/tests/ui/contract/pass/constructor-return-result-cross-contract.rs b/crates/ink/tests/ui/contract/pass/constructor-return-result-cross-contract.rs index 0a4d618f61..8503d6943a 100644 --- a/crates/ink/tests/ui/contract/pass/constructor-return-result-cross-contract.rs +++ b/crates/ink/tests/ui/contract/pass/constructor-return-result-cross-contract.rs @@ -45,7 +45,7 @@ fn main() { let _: fn() -> CalleeRef = || { CalleeRef::new_self() .code_hash(ink::primitives::H256::zero()) - .endowment(25) + .endowment(ink::U256::from(25)) .salt_bytes(Some([1u8; 32])) .instantiate() }; @@ -54,7 +54,7 @@ fn main() { let _: fn() -> CalleeRef = || { CalleeRef::new_storage_name() .code_hash(ink::primitives::H256::zero()) - .endowment(25) + .endowment(ink::U256::from(25)) .salt_bytes(Some([1u8; 32])) .instantiate() }; @@ -63,7 +63,7 @@ fn main() { let _: fn() -> Result = || { CalleeRef::new_result_self() .code_hash(ink::primitives::H256::zero()) - .endowment(25) + .endowment(ink::U256::from(25)) .salt_bytes(Some([1u8; 32])) .instantiate() }; @@ -72,7 +72,7 @@ fn main() { let _: fn() -> Result = || { CalleeRef::new_result_self() .code_hash(ink::primitives::H256::zero()) - .endowment(25) + .endowment(ink::U256::from(25)) .salt_bytes(Some([1u8; 32])) .instantiate() }; diff --git a/integration-tests/public/combined-extension/lib.rs b/integration-tests/public/combined-extension/lib.rs index 5c5cd76a8a..e73836a0f1 100755 --- a/integration-tests/public/combined-extension/lib.rs +++ b/integration-tests/public/combined-extension/lib.rs @@ -42,6 +42,7 @@ impl Environment for CustomEnvironment { type Hash = ::Hash; type Timestamp = ::Timestamp; type BlockNumber = ::BlockNumber; + type EventRecord = ::EventRecord; /// Setting up the combined chain extension as a primary extension. /// diff --git a/integration-tests/public/multi-contract-caller/lib.rs b/integration-tests/public/multi-contract-caller/lib.rs index 74729d11e5..b602959fb3 100644 --- a/integration-tests/public/multi-contract-caller/lib.rs +++ b/integration-tests/public/multi-contract-caller/lib.rs @@ -153,7 +153,7 @@ mod multi_contract_caller { .code_hash; let mut constructor = MultiContractCallerRef::new( - 123, // initial value + 1234, // initial value 1337, // salt accumulator_hash, adder_hash, diff --git a/integration-tests/public/psp22-extension/lib.rs b/integration-tests/public/psp22-extension/lib.rs index 3691ca280f..e43efabca3 100755 --- a/integration-tests/public/psp22-extension/lib.rs +++ b/integration-tests/public/psp22-extension/lib.rs @@ -115,6 +115,7 @@ impl Environment for CustomEnvironment { type Hash = ::Hash; type Timestamp = ::Timestamp; type BlockNumber = ::BlockNumber; + type EventRecord = ::EventRecord; type ChainExtension = crate::Psp22Extension; } diff --git a/integration-tests/public/rand-extension/lib.rs b/integration-tests/public/rand-extension/lib.rs index 861c9f9667..df86ffe569 100755 --- a/integration-tests/public/rand-extension/lib.rs +++ b/integration-tests/public/rand-extension/lib.rs @@ -47,6 +47,7 @@ impl Environment for CustomEnvironment { type Hash = ::Hash; type BlockNumber = ::BlockNumber; type Timestamp = ::Timestamp; + type EventRecord = ::EventRecord; type ChainExtension = FetchRandom; } diff --git a/integration-tests/public/upgradeable-contracts/delegator/lib.rs b/integration-tests/public/upgradeable-contracts/delegator/lib.rs index d169c150a4..cda972a788 100644 --- a/integration-tests/public/upgradeable-contracts/delegator/lib.rs +++ b/integration-tests/public/upgradeable-contracts/delegator/lib.rs @@ -25,7 +25,7 @@ pub mod delegator { pub struct Delegator { addresses: Mapping>, counter: i32, - delegate_to: Lazy, + delegate_to: Lazy, } impl Delegator {