forked from use-ink/ink
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP derive Event * Move tests to top level * Add failing Event derive test * Test compiles, now fails * Passing test, now impl * Passing test with no fields * Add events integration-tests example * Expose Event derive macro at the top level ::ink::Event * Remove println! * Remove ContractEventBase * WIP rewiring event codegen for use with derive. * Direct impl of emit_event * Use bound_impl * WIP impl derive EventMetadata * WIP add event metadata derive * Add some metadata derive todos * WIP Collect metadata from linked events * Refactor event metadata collection * Add metadata test * Check for external and Inline events * Add todo for inline events * WIP adding compile time topics check to emit_event. * fmt * Refactor EventRespectsTopicsLimit to use const assertion * Fmt * Remove unused code from legacy events generation * test and generate SIGNATURE topic * use built in ink macro for generating signature topic * Remove all warnings * Implement anonymous event * Remove PrefixedValue * Implement field topics * Use TOPICS_LEN for topics remaining * WIP don't push Option::None topics * Fix only publishing if not `Option::None` * Fix only publishing if not `Option::None` * Only publish value of `Some` topic, not none. * Fix event derive codegen tests * Add test for None topic * Rename Topics trait to Event * Fmt * Remove println * Remove EmitEvent imports * WIP adding E2E test for topics * Clippy * Unnused imports * E2E test contract events emitted * WIP e2e testing topics * Add e2e test which checks topics * Add signature topic to event spec metadata * Use Result in EventMetadata derive * Tests for generating events metadata * Remove max topics len compile time check * Add failing test for topics len validation at metadata generation time * Check for max topics limit breach in metadata generation * Add extra event with no signature topic * Remove checks for generics and pub visibility * Fix anonymous attr * Move topics attr validation to derive macro * Fmt and remove remaining MAX_TOPICS check * Remove event spec field type name * Clippy * WIP add `#[ink::event]` which expands to derives * Check for signature topics collisions when building metadata * Commentl * Remove EventRespectsTopicLimits * Remove cfg attr test * Remove unused topics attr test * Fmt * Fix trait erc20 tests * Fix erc20 tests and fmt * Fix duplicate inline attrs. Remove offchain duplicate topics check. * Fmt * Clippy * clippy * events clippy * Push 0 topic if `None` * Expose signature_topic * Change SignatureTopic to expose as_bytes * Add test for None topic value * Fix erc20 topic tests * Add module_path * Fix max topics in tests * Fix event docs test * Clippy * Use path dependency for ink_env * Remove ink_env dependency * RUSTFLAGS for test to fix linking issue * RUSTFLAGS for test to fix linking issue * Fix custom environment, remove extra topic * Use ink::event syntax * Add ui test for cfg attributes * Add success ui tests for ink::event * UI test for `enum` should fail * Refactor topic attribute fn to accept BindingInfo * Fmt * Remove commented out code * Event docs * Add event field docs * Fix event param spec doc tests * Fix metadata codegen tests * Implement docs for `Event` derive macro * Spellcheck * Check for multiple ink attributes * Spellcheck * Ink attribute validation * Remove Topic * Oops * Oops again * Test for events in different crates being used in the metadata. * Test for unused event not included in metadata * Add test for inline event definition metadata. * Add test for emitting inline event * Fmt * Remove todo, duplicate attributes are checked in the derive impls * Add docs * Fix examples-test * Add docs for `#[ink::event]` * Add docs for `EventMetadata` trait * Update Event trait comments * Docs * SIGNATURE_TOPIC docs * Fix docs * fmt * Try setting lto = "thin" for metadata crate to fix met * Add lto to test profile of unit test * Add test to check disallow generics for Event derive * Fmt * Change to `#[ink::event(anonymous = true)]` syntax * Fix test * Annotate derived event struct with anon * UI test * Document limitation of signature topic derive * Fix doctest * Fix up errors after merge * Usage of the crate includes defined there events (use-ink#1842) * Usage of the crate includes defined there events * Inclusion of the event from `event_def_unused` is expected * Update anonymous syntax * Anonymous comment * Move haashing macro inline signature topic gen fn * Fix signature_topic return type --------- Co-authored-by: Green Baneling <[email protected]>
- Loading branch information
Showing
82 changed files
with
2,574 additions
and
1,625 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// Copyright 2018-2022 Parity Technologies (UK) Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use ink_env::Environment; | ||
#[cfg(feature = "std")] | ||
use std::fmt::Debug; | ||
|
||
use subxt::{ | ||
events::StaticEvent, | ||
ext::{ | ||
scale_decode, | ||
scale_encode, | ||
}, | ||
}; | ||
|
||
/// 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")] | ||
pub struct ContractInstantiatedEvent<E: Environment> { | ||
/// Account id of the deployer. | ||
pub deployer: E::AccountId, | ||
/// Account id where the contract was instantiated to. | ||
pub contract: E::AccountId, | ||
} | ||
|
||
impl<E> StaticEvent for ContractInstantiatedEvent<E> | ||
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")] | ||
pub struct CodeStoredEvent<E: Environment> { | ||
/// Hash under which the contract code was stored. | ||
pub code_hash: E::Hash, | ||
} | ||
|
||
impl<E> StaticEvent for CodeStoredEvent<E> | ||
where | ||
E: Environment, | ||
{ | ||
const PALLET: &'static str = "Contracts"; | ||
const EVENT: &'static str = "CodeStored"; | ||
} | ||
|
||
#[derive( | ||
scale::Decode, | ||
scale::Encode, | ||
scale_decode::DecodeAsType, | ||
scale_encode::EncodeAsType, | ||
Debug, | ||
)] | ||
#[decode_as_type(trait_bounds = "", crate_path = "subxt::ext::scale_decode")] | ||
#[encode_as_type(crate_path = "subxt::ext::scale_encode")] | ||
/// A custom event emitted by the contract. | ||
pub struct ContractEmitted<E: Environment> { | ||
pub contract: E::AccountId, | ||
pub data: Vec<u8>, | ||
} | ||
|
||
impl<E> StaticEvent for ContractEmitted<E> | ||
where | ||
E: Environment, | ||
{ | ||
const PALLET: &'static str = "Contracts"; | ||
const EVENT: &'static str = "ContractEmitted"; | ||
} | ||
|
||
/// A decoded event with its associated topics. | ||
pub struct EventWithTopics<T> { | ||
pub topics: Vec<sp_core::H256>, | ||
pub event: T, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.