-
Notifications
You must be signed in to change notification settings - Fork 480
Events 2.0
#1827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Events 2.0
#1827
Changes from 147 commits
Commits
Show all changes
152 commits
Select commit
Hold shift + click to select a range
4841460
WIP derive Event
ascjones bce872d
Move tests to top level
ascjones cbdf8ff
Add failing Event derive test
ascjones 0e42a02
Test compiles, now fails
ascjones bb979c9
Passing test, now impl
ascjones 5cf66c2
Passing test with no fields
ascjones a78360a
Add events integration-tests example
ascjones eb1b771
Expose Event derive macro at the top level ::ink::Event
ascjones c0dbde2
Remove println!
ascjones e979a9a
Remove ContractEventBase
ascjones 8f44244
WIP rewiring event codegen for use with derive.
ascjones a320001
Direct impl of emit_event
ascjones a75e7f7
Use bound_impl
ascjones 5e92390
WIP impl derive EventMetadata
ascjones fc39589
WIP add event metadata derive
ascjones 5fea6ff
Add some metadata derive todos
ascjones c1ba2fa
WIP Collect metadata from linked events
ascjones dc88a33
Refactor event metadata collection
ascjones 1fcf5e2
Add metadata test
ascjones 5f7f99f
Check for external and Inline events
ascjones 884e82c
Add todo for inline events
ascjones e5951e7
Merge branch 'master' into aj/shared-events-redux
ascjones 1b51949
Merge branch 'master' into aj/shared-events-redux
ascjones e2658d6
WIP adding compile time topics check to emit_event.
ascjones a82a6ad
fmt
ascjones b084d61
Refactor EventRespectsTopicsLimit to use const assertion
ascjones 6c4ad8e
Fmt
ascjones 07d9b85
Remove unused code from legacy events generation
ascjones b7c7199
test and generate SIGNATURE topic
ascjones 7258197
use built in ink macro for generating signature topic
ascjones 76a176f
Remove all warnings
ascjones b3b2587
Implement anonymous event
ascjones d0d917b
Remove PrefixedValue
ascjones 951543a
Implement field topics
ascjones c152723
Use TOPICS_LEN for topics remaining
ascjones affd57d
WIP don't push Option::None topics
ascjones e66f697
Fix only publishing if not `Option::None`
ascjones ef6693c
Fix only publishing if not `Option::None`
ascjones cacb540
Only publish value of `Some` topic, not none.
ascjones c2ac444
Fix event derive codegen tests
ascjones 5a378e7
Add test for None topic
ascjones bbdb5fb
Rename Topics trait to Event
ascjones 45460fa
Fmt
ascjones 57e6ac4
Remove println
ascjones 4c731ea
Remove EmitEvent imports
ascjones 938b361
WIP adding E2E test for topics
ascjones 562b044
Clippy
ascjones b83bba9
Unnused imports
ascjones 20b2c44
E2E test contract events emitted
ascjones 56ef583
WIP e2e testing topics
ascjones 0714290
Merge branch 'master' into aj/shared-events-redux
ascjones dbd0dbe
Add e2e test which checks topics
ascjones 694d8f5
Merge branch 'master' into aj/shared-events-redux
ascjones 916399f
Add signature topic to event spec metadata
ascjones e1eba71
Use Result in EventMetadata derive
ascjones 39bd2d9
Tests for generating events metadata
ascjones d97c51e
Remove max topics len compile time check
ascjones 0704d94
Merge branch 'master' into aj/shared-events-redux
ascjones c74da8c
Add failing test for topics len validation at metadata generation time
ascjones ca861ae
Check for max topics limit breach in metadata generation
ascjones 39e6e28
Add extra event with no signature topic
ascjones fc40629
Remove checks for generics and pub visibility
ascjones bbbee5e
Fix anonymous attr
ascjones 43e3ab0
Move topics attr validation to derive macro
ascjones 6e93717
Fmt and remove remaining MAX_TOPICS check
ascjones 28b2d30
Remove event spec field type name
ascjones 98a73c2
Merge branch 'master' into aj/shared-events-redux
ascjones 298cfa8
Clippy
ascjones e7e1837
WIP add `#[ink::event]` which expands to derives
ascjones 6616265
Merge branch 'master' into aj/shared-events-redux
ascjones e8f186b
Check for signature topics collisions when building metadata
ascjones a232e30
Merge branch 'master' into aj/shared-events-redux
ascjones 309e30c
Commentl
ascjones 03f7e7c
Remove EventRespectsTopicLimits
ascjones eeecbc7
Remove cfg attr test
ascjones 5391171
Remove unused topics attr test
ascjones 0891fd3
Fmt
ascjones 81d62ae
Fix trait erc20 tests
ascjones 4073c7e
Fix erc20 tests and fmt
ascjones b423df0
Fix duplicate inline attrs. Remove offchain duplicate topics check.
ascjones 5414c95
Fmt
ascjones a0c0218
Clippy
ascjones cb52b1a
clippy
ascjones 4eb0e81
events clippy
ascjones 7bf21cc
Push 0 topic if `None`
ascjones 7fef4a6
Expose signature_topic
ascjones ef91f80
Change SignatureTopic to expose as_bytes
ascjones 7f5f6d8
Add test for None topic value
ascjones 4334aac
Fix erc20 topic tests
ascjones 37115d9
Add module_path
ascjones f8bbb3b
Fix max topics in tests
ascjones ad144ca
Fix event docs test
ascjones 4af676f
Clippy
ascjones 8908f10
Use path dependency for ink_env
ascjones d63afe5
Remove ink_env dependency
ascjones c7636fb
RUSTFLAGS for test to fix linking issue
ascjones 4ca3065
RUSTFLAGS for test to fix linking issue
ascjones 87a965f
Fix custom environment, remove extra topic
ascjones 986147a
Merge branch 'master' into aj/shared-events-redux
ascjones 346b380
Use ink::event syntax
ascjones f1bd57f
Add ui test for cfg attributes
ascjones 1ed1e88
Add success ui tests for ink::event
ascjones bb26312
UI test for `enum` should fail
ascjones 3d3c898
Refactor topic attribute fn to accept BindingInfo
ascjones f27176e
Merge branch 'master' into aj/shared-events-redux
ascjones 7b0abe9
Fmt
ascjones 4fd7cf6
Remove commented out code
ascjones 5aa6366
Event docs
ascjones 49281d5
Add event field docs
ascjones 4327ce0
Fix event param spec doc tests
ascjones f6d1953
Fix metadata codegen tests
ascjones e4c3572
Implement docs for `Event` derive macro
ascjones 4d48669
Spellcheck
ascjones 3dcc12f
Check for multiple ink attributes
ascjones 1defd81
Spellcheck
ascjones a1e3879
Ink attribute validation
ascjones 89e3df6
Remove Topic
ascjones a80bb74
Oops
ascjones 15bc04a
Oops again
ascjones 802c799
Test for events in different crates being used in the metadata.
ascjones ad8b3e7
Test for unused event not included in metadata
ascjones 4dcc771
Add test for inline event definition metadata.
ascjones 47b8e70
Add test for emitting inline event
ascjones 4a6431b
Fmt
ascjones 9dea0aa
Remove todo, duplicate attributes are checked in the derive impls
ascjones 9612515
Add docs
ascjones ce7c4e0
Fix examples-test
ascjones 0b2d2de
Add docs for `#[ink::event]`
ascjones 7bc0183
Add docs for `EventMetadata` trait
ascjones 100cbaa
Update Event trait comments
ascjones 850c38a
Docs
ascjones d8185cc
SIGNATURE_TOPIC docs
ascjones b7376e6
Fix docs
ascjones 205f876
fmt
ascjones c558972
Try setting lto = "thin" for metadata crate to fix met
ascjones 083fad8
Add lto to test profile of unit test
ascjones df91ae5
Add test to check disallow generics for Event derive
ascjones f7a4f4f
Fmt
ascjones 8f8d346
Change to `#[ink::event(anonymous = true)]` syntax
ascjones 26245ac
Fix test
ascjones f912b7b
Annotate derived event struct with anon
ascjones 68688b1
UI test
ascjones 1a10613
Document limitation of signature topic derive
ascjones c60a786
Fix doctest
ascjones 59fe50e
Merge branch 'master' into aj/shared-events-redux
ascjones dd8d861
Fix up errors after merge
ascjones 1a8b157
Usage of the crate includes defined there events (#1842)
xgreenx cac0f95
Update anonymous syntax
ascjones 4d97e78
Anonymous comment
ascjones c39b678
Merge branch 'master' into aj/shared-events-redux
ascjones 1371e35
Move haashing macro inline signature topic gen fn
ascjones 9fb00fc
Fix signature_topic return type
ascjones File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.