ink_e2e/
events.rs

1// Copyright (C) Use Ink (UK) Ltd.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use crate::H256;
16use pallet_revive::evm::H160;
17#[cfg(feature = "std")]
18use std::fmt::Debug;
19use subxt::{
20    events::StaticEvent,
21    ext::{
22        scale_decode,
23        scale_encode,
24    },
25};
26
27/// A contract was successfully instantiated.
28#[derive(
29    Debug,
30    scale::Decode,
31    scale::Encode,
32    scale_decode::DecodeAsType,
33    scale_encode::EncodeAsType,
34)]
35#[decode_as_type(trait_bounds = "", crate_path = "subxt::ext::scale_decode")]
36#[encode_as_type(crate_path = "subxt::ext::scale_encode")]
37pub struct ContractInstantiatedEvent {
38    /// Address of the deployer.
39    pub deployer: H160,
40    /// Address where the contract was instantiated to.
41    pub contract: H160,
42}
43
44impl StaticEvent for ContractInstantiatedEvent {
45    const PALLET: &'static str = "Revive";
46    const EVENT: &'static str = "Instantiated";
47}
48
49/// Code with the specified hash has been stored.
50#[derive(
51    Debug,
52    scale::Decode,
53    scale::Encode,
54    scale_decode::DecodeAsType,
55    scale_encode::EncodeAsType,
56)]
57#[decode_as_type(trait_bounds = "", crate_path = "subxt::ext::scale_decode")]
58#[encode_as_type(crate_path = "subxt::ext::scale_encode")]
59pub struct CodeStoredEvent {
60    /// Hash under which the contract code was stored.
61    pub code_hash: H256,
62}
63
64impl StaticEvent for CodeStoredEvent {
65    const PALLET: &'static str = "Revive";
66    const EVENT: &'static str = "CodeStored";
67}
68
69#[derive(
70    scale::Decode,
71    scale::Encode,
72    scale_decode::DecodeAsType,
73    scale_encode::EncodeAsType,
74    Debug,
75)]
76#[decode_as_type(trait_bounds = "", crate_path = "subxt::ext::scale_decode")]
77#[encode_as_type(crate_path = "subxt::ext::scale_encode")]
78/// A custom event emitted by the contract.
79pub struct ContractEmitted {
80    pub contract: H160,
81    pub data: Vec<u8>,
82    pub topics: Vec<H256>,
83}
84
85impl StaticEvent for ContractEmitted {
86    const PALLET: &'static str = "Revive";
87    const EVENT: &'static str = "ContractEmitted";
88}
89
90/// A decoded event with its associated topics.
91pub struct EventWithTopics<T> {
92    pub topics: Vec<H256>,
93    pub event: T,
94}