diem_types/account_config/constants/
event.rs

1// Copyright (c) The Diem Core Contributors
2// SPDX-License-Identifier: Apache-2.0
3
4// Copyright 2021 Conflux Foundation. All rights reserved.
5// Conflux is free software and distributed under GNU General Public License.
6// See http://www.gnu.org/licenses/
7
8use crate::account_config::constants::CORE_CODE_ADDRESS;
9use move_core_types::{
10    identifier::{IdentStr, Identifier},
11    language_storage::{ModuleId, StructTag},
12};
13use once_cell::sync::Lazy;
14
15static EVENT_MODULE_NAME: Lazy<Identifier> =
16    Lazy::new(|| Identifier::new("Event").unwrap());
17pub static EVENT_MODULE: Lazy<ModuleId> =
18    Lazy::new(|| ModuleId::new(CORE_CODE_ADDRESS, EVENT_MODULE_NAME.clone()));
19
20static EVENT_HANDLE_STRUCT_NAME: Lazy<Identifier> =
21    Lazy::new(|| Identifier::new("EventHandle").unwrap());
22static EVENT_HANDLE_GENERATOR_STRUCT_NAME: Lazy<Identifier> =
23    Lazy::new(|| Identifier::new("EventHandleGenerator").unwrap());
24
25pub fn event_module_name() -> &'static IdentStr { &*EVENT_MODULE_NAME }
26
27pub fn event_handle_generator_struct_name() -> &'static IdentStr {
28    &*EVENT_HANDLE_GENERATOR_STRUCT_NAME
29}
30
31pub fn event_handle_struct_name() -> &'static IdentStr {
32    &*EVENT_HANDLE_STRUCT_NAME
33}
34
35pub fn event_handle_generator_struct_tag() -> StructTag {
36    StructTag {
37        address: CORE_CODE_ADDRESS,
38        module: event_module_name().to_owned(),
39        name: event_handle_generator_struct_name().to_owned(),
40        type_params: vec![],
41    }
42}