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
48
elrond_wasm::imports!();
#[elrond_wasm::module]
pub trait PauseModule {
#[view(isPaused)]
#[storage_get("pause_module:paused")]
fn is_paused(&self) -> bool;
fn not_paused(&self) -> bool {
!self.is_paused()
}
#[storage_set("pause_module:paused")]
fn set_paused(&self, paused: bool);
#[endpoint(pause)]
fn pause_endpoint(&self) -> SCResult<()> {
require!(
self.blockchain().get_caller() == self.blockchain().get_owner_address(),
"only owner allowed to pause contract"
);
self.set_paused(true);
Ok(())
}
#[endpoint(unpause)]
fn unpause_endpoint(&self) -> SCResult<()> {
require!(
self.blockchain().get_caller() == self.blockchain().get_owner_address(),
"only owner allowed to unpause contract"
);
self.set_paused(false);
Ok(())
}
}