Skip to content

Commit

Permalink
Fixed compilation errors events (#1533)
Browse files Browse the repository at this point in the history
* Update README.md (#1521)

* Fixed compilation errors

* Make CI happy

* Make CI happy

* Return clippy changes back to minimize conflicts

Co-authored-by: German <german@parity.io>
  • Loading branch information
xgreenx and German authored Dec 12, 2022
1 parent bba0e88 commit c999880
Show file tree
Hide file tree
Showing 23 changed files with 40 additions and 41 deletions.
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -690,9 +690,9 @@ ink! 3.0-rc4 is compatible with
- [`substrate-contracts-node`](https://github.com/paritytech/substrate-contracts-node) version `0.1.0` or newer.
- Install the newest version using `cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-node.git --force`.

The documentation on our [Documentation Portal](https://ink.substrate.io)
The documentation on our [Documentation Portal](https://use.ink)
is up-to-date with this release candidate. Since the last release candidate we notably
added a number of [Frequently Asked Questions](https://ink.substrate.io/faq)
added a number of [Frequently Asked Questions](https://use.ink/faq)
there.

### Quality Assurance
Expand Down Expand Up @@ -721,7 +721,7 @@ of key improvements to our testing setup:
- Implemented the (unstable) `seal_rent_status` API ‒ [#798](https://github.com/paritytech/ink/pull/798).
- Implemented the (unstable) `seal_debug_message` API ‒ [#792](https://github.com/paritytech/ink/pull/792).
- Printing debug messages can now be achieved via `ink_env::debug_println!(…)`.
- See [our documentation](https://ink.substrate.io/faq#how-do-i-print-something-to-the-console-from-the-runtime)
- See [our documentation](https://use.ink/faq#how-do-i-print-something-to-the-console-from-the-runtime)
for more information.
- The examples have been updated to reflect this new way of printing debug messages.
- Added usage comments with code examples to the `ink_env` API ‒ [#797](https://github.com/paritytech/ink/pull/797).
Expand Down Expand Up @@ -782,7 +782,7 @@ ink! 3.0-rc3 is compatible with
### Added

- Implemented chain extensions feature for ink!.
- ink!'s official documentation portal: https://ink.substrate.io/
- ink!'s official documentation portal: https://use.ink/
- It is now possible to pass a `salt` argument to contract instantiations.
- Implemented fuzz testing for the ink! codebase.

Expand Down
2 changes: 1 addition & 1 deletion MONTHLY_UPDATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Monthly Update: Parity Smart Contracts

The monthly update has been moved to [https://ink.substrate.io/monthly-update](https://ink.substrate.io/monthly-update)!
The monthly update has been moved to [https://use.ink/monthly-update](https://use.ink/monthly-update)!
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<br/>

[Guided Tutorial for Beginners](https://docs.substrate.io/tutorials/smart-contracts/)&nbsp;&nbsp;&nbsp;&nbsp;
[ink! Documentation Portal](https://ink.substrate.io)&nbsp;&nbsp;&nbsp;&nbsp;
[ink! Documentation Portal](https://use.ink)&nbsp;&nbsp;&nbsp;&nbsp;
[Developer Documentation](https://paritytech.github.io/ink/ink)


Expand Down Expand Up @@ -72,11 +72,10 @@ More relevant links:
If you want to have a local setup you can use our [`substrate-contracts-node`](https://github.com/paritytech/substrate-contracts-node) for a quickstart.
It's a simple Substrate blockchain which includes the Substrate module for smart contract functionality ‒ the `contracts` pallet (see [How it Works](#how-it-works) for more).

We also have a live testnet on [Rococo](https://github.com/paritytech/cumulus/#rococo-)
called [Canvas](https://ink.substrate.io/canvas). Canvas is a Substrate based
We also have a live testnet on [Rococo](https://github.com/paritytech/cumulus/#rococo-). Rococo is a Substrate based
parachain which supports ink! smart contracts. For further instructions on using this
testnet, follow the instructions in the
[our documentation](https://ink.substrate.io/canvas#rococo-deployment).
[our documentation](https://use.ink/testnet).

For both types of chains the [Contracts UI](https://contracts-ui.substrate.io/)
can be used to instantiate your contract to a chain and interact with it.
Expand Down Expand Up @@ -245,7 +244,7 @@ The `#[ink::test]` procedural macro enables off-chain testing. See e.g. the [`ex

## Developer Documentation

We have [a very comprehensive documentation portal](https://ink.substrate.io),
We have [a very comprehensive documentation portal](https://use.ink),
but if you are looking for the crate level documentation itself, then these are
the relevant links:

Expand Down
5 changes: 2 additions & 3 deletions crates/env/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,12 @@ where
}

/// Emits an event with the given event data.
pub fn emit_event<E, Event>(event: Event)
pub fn emit_event<Event>(event: Event)
where
E: Environment,
Event: Topics + scale::Encode,
{
<EnvInstance as OnInstance>::on_instance(|instance| {
TypedEnvBackend::emit_event::<E, Event>(instance, event)
TypedEnvBackend::emit_event::<Event>(instance, event)
})
}

Expand Down
3 changes: 1 addition & 2 deletions crates/env/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,8 @@ pub trait TypedEnvBackend: EnvBackend {
/// # Note
///
/// For more details visit: [`emit_event`][`crate::emit_event`]
fn emit_event<E, Event>(&mut self, event: Event)
fn emit_event<Event>(&mut self, event: Event)
where
E: Environment,
Event: Topics + scale::Encode;

/// Invokes a contract message and returns its result.
Expand Down
3 changes: 1 addition & 2 deletions crates/env/src/engine/off_chain/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,8 @@ impl TypedEnvBackend for EnvInstance {
})
}

fn emit_event<E, Event>(&mut self, event: Event)
fn emit_event<Event>(&mut self, event: Event)
where
E: Environment,
Event: Topics + scale::Encode,
{
let builder = TopicsBuilder::default();
Expand Down
8 changes: 4 additions & 4 deletions crates/env/src/engine/on_chain/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,13 +401,13 @@ impl TypedEnvBackend for EnvInstance {
self.get_property_little_endian::<E::Balance>(ext::minimum_balance)
}

fn emit_event<E, Event>(&mut self, event: Event)
fn emit_event<Event>(&mut self, event: Event)
where
E: Environment,
Event: Topics + scale::Encode,
{
let (mut scope, enc_topics) =
event.topics::<E, _>(TopicsBuilder::from(self.scoped_buffer()).into());
let (mut scope, enc_topics) = event.topics(
TopicsBuilder::<<Event as Topics>::Env>::from(self.scoped_buffer()).into(),
);
let enc_data = scope.take_encoded(&event);
ext::deposit_event(enc_topics, enc_data);
}
Expand Down
1 change: 0 additions & 1 deletion crates/env/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
missing_docs,
bad_style,
bare_trait_objects,
const_err,
improper_ctypes,
non_shorthand_field_patterns,
no_mangle_generic_items,
Expand Down
2 changes: 1 addition & 1 deletion crates/ink/src/env_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ where
where
Event: ink_env::Topics + scale::Encode,
{
ink_env::emit_event::<E, Event>(event)
ink_env::emit_event::<Event>(event)
}

/// Instantiates another contract.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod contract {
#[ink::event_definition]
#[ink(storage)]
pub enum Event {
Event {}
Event {},
}

impl Contract {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ mod contract {
arg_3: i32,
#[ink(topic)]
arg_4: i32,
}
},
}

impl Contract {
Expand Down
2 changes: 1 addition & 1 deletion crates/ink/tests/ui/contract/fail/event-too-many-topics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mod contract {
arg_2: i16,
#[ink(topic)]
arg_3: i32,
}
},
}

impl Contract {
Expand Down
2 changes: 1 addition & 1 deletion crates/ink/tests/ui/contract/pass/event-anonymous.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ mod contract {
arg_4: i64,
// #[ink(topic)] <- Cannot have more than 4 topics by default.
arg_5: i128,
}
},
}

impl Contract {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ mod contract {
arg_9: u64,
#[ink(topic)]
arg_10: u128,
}
},
}

impl Contract {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mod contract {
arg_3: i32,
arg_4: i64,
arg_5: i128,
}
},
}

impl Contract {
Expand Down
5 changes: 3 additions & 2 deletions crates/ink/tests/ui/contract/pass/event-shared-external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub enum SharedEvent {
arg_1: u8,
#[ink(topic)]
arg_2: u16,
}
},
}

#[ink::contract]
Expand All @@ -20,7 +20,8 @@ mod contract {

#[ink(message)]
pub fn message(&self) {
self.env().emit_event(super::SharedEvent::Event1 { arg_1: 1, arg_2: 2 });
self.env()
.emit_event(super::SharedEvent::Event1 { arg_1: 1, arg_2: 2 });
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod contract {

#[ink::event_definition]
pub enum Event {
Event0 {}
Event0 {},
}

impl Contract {
Expand Down
2 changes: 1 addition & 1 deletion crates/ink/tests/ui/contract/pass/event-topics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ mod contract {
arg_4: i64,
// #[ink(topic)] <- Cannot have more than 4 topics by default.
arg_5: i128,
}
},
}

impl Contract {
Expand Down
2 changes: 1 addition & 1 deletion crates/ink/tests/ui/contract/pass/example-erc721-works.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ mod erc721 {
#[ink(topic)]
operator: AccountId,
approved: bool,
}
},
}

impl Erc721 {
Expand Down
1 change: 0 additions & 1 deletion crates/storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
missing_docs,
bad_style,
bare_trait_objects,
const_err,
improper_ctypes,
non_shorthand_field_patterns,
no_mangle_generic_items,
Expand Down
2 changes: 1 addition & 1 deletion examples/delegator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ In order to test this bundle of smart contracts you need to execute the
following steps.

You can upload the contracts using our [Contracts UI](https://contracts-ui.substrate.io/).
If you want to test it locally, our [`substrate-contracts-node`](https://ink.substrate.io/getting-started/setup/#installing-the-substrate-smart-contracts-node)
If you want to test it locally, our [`substrate-contracts-node`](https://use.ink/getting-started/setup/#installing-the-substrate-smart-contracts-node)
is an easy way to get a local smart contract chain running.

1. Compile all contracts using the `./build-all.sh` script.
Expand Down
12 changes: 8 additions & 4 deletions examples/multisig/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ mod multisig {
ensure_requirement_is_valid(self.owners.len() as u32 + 1, self.requirement);
self.is_owner.insert(new_owner, &());
self.owners.push(new_owner);
self.env().emit_event(Event::OwnerAddition { owner: new_owner });
self.env()
.emit_event(Event::OwnerAddition { owner: new_owner });
}

/// Remove an owner from the contract.
Expand Down Expand Up @@ -404,8 +405,10 @@ mod multisig {
self.is_owner.remove(old_owner);
self.is_owner.insert(new_owner, &());
self.clean_owner_confirmations(&old_owner);
self.env().emit_event(Event::OwnerRemoval { owner: old_owner });
self.env().emit_event(Event::OwnerAddition { owner: new_owner });
self.env()
.emit_event(Event::OwnerRemoval { owner: old_owner });
self.env()
.emit_event(Event::OwnerAddition { owner: new_owner });
}

/// Change the requirement to a new value.
Expand All @@ -420,7 +423,8 @@ mod multisig {
self.ensure_from_wallet();
ensure_requirement_is_valid(self.owners.len() as u32, new_requirement);
self.requirement = new_requirement;
self.env().emit_event(Event::RequirementChange { new_requirement });
self.env()
.emit_event(Event::RequirementChange { new_requirement });
}

/// Add a new transaction candidate to the contract.
Expand Down
2 changes: 1 addition & 1 deletion examples/rand-extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

It demonstrates how to call a custom Substrate function from ink!.

See [this chapter](https://ink.substrate.io/macros-attributes/chain-extension)
See [this chapter](https://use.ink/macros-attributes/chain-extension)
in our ink! documentation for more details.

There are two parts to this example:
Expand Down

0 comments on commit c999880

Please sign in to comment.