zink/
event.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use crate::{ffi, primitives::Bytes32};

/// Zink event interface
pub trait Event {
    const NAME: &'static [u8];

    fn log0(&self) {
        unsafe {
            ffi::evm::log0(Self::NAME);
        }
    }

    fn log1(&self, topic: impl Into<Bytes32>) {
        unsafe { ffi::evm::log1(topic.into(), Self::NAME) }
    }

    fn log2(&self, topic1: impl Into<Bytes32>, topic2: impl Into<Bytes32>) {
        unsafe { ffi::evm::log2(topic1.into(), topic2.into(), Self::NAME) }
    }

    fn log3(
        &self,
        topic1: impl Into<Bytes32>,
        topic2: impl Into<Bytes32>,
        topic3: impl Into<Bytes32>,
    ) {
        unsafe { ffi::evm::log3(topic1.into(), topic2.into(), topic3.into(), Self::NAME) }
    }

    fn log4(
        &self,
        topic1: impl Into<Bytes32>,
        topic2: impl Into<Bytes32>,
        topic3: impl Into<Bytes32>,
        topic4: impl Into<Bytes32>,
    ) {
        unsafe {
            ffi::evm::log4(
                topic1.into(),
                topic2.into(),
                topic3.into(),
                topic4.into(),
                Self::NAME,
            )
        }
    }
}