zink/
event.rs

1use crate::{ffi, primitives::Bytes32};
2
3/// Zink event interface
4pub trait Event {
5    const NAME: &'static [u8];
6
7    fn log0(&self) {
8        unsafe {
9            ffi::evm::log0(Self::NAME);
10        }
11    }
12
13    fn log1(&self, topic: impl Into<Bytes32>) {
14        unsafe { ffi::evm::log1(topic.into(), Self::NAME) }
15    }
16
17    fn log2(&self, topic1: impl Into<Bytes32>, topic2: impl Into<Bytes32>) {
18        unsafe { ffi::evm::log2(topic1.into(), topic2.into(), Self::NAME) }
19    }
20
21    fn log3(
22        &self,
23        topic1: impl Into<Bytes32>,
24        topic2: impl Into<Bytes32>,
25        topic3: impl Into<Bytes32>,
26    ) {
27        unsafe { ffi::evm::log3(topic1.into(), topic2.into(), topic3.into(), Self::NAME) }
28    }
29
30    fn log4(
31        &self,
32        topic1: impl Into<Bytes32>,
33        topic2: impl Into<Bytes32>,
34        topic3: impl Into<Bytes32>,
35        topic4: impl Into<Bytes32>,
36    ) {
37        unsafe {
38            ffi::evm::log4(
39                topic1.into(),
40                topic2.into(),
41                topic3.into(),
42                topic4.into(),
43                Self::NAME,
44            )
45        }
46    }
47}