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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
use crate::{
account_config::{
constants::ACCOUNT_MODULE_IDENTIFIER, KeyRotationCapabilityResource,
WithdrawCapabilityResource,
},
event::EventHandle,
};
use move_core_types::{
identifier::IdentStr,
move_resource::{MoveResource, MoveStructType},
};
#[cfg(any(test, feature = "fuzzing"))]
use proptest_derive::Arbitrary;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
#[cfg_attr(any(test, feature = "fuzzing"), derive(Arbitrary))]
pub struct AccountResource {
authentication_key: Vec<u8>,
withdrawal_capability: Option<WithdrawCapabilityResource>,
key_rotation_capability: Option<KeyRotationCapabilityResource>,
received_events: EventHandle,
sent_events: EventHandle,
sequence_number: u64,
}
impl AccountResource {
pub fn new(
sequence_number: u64,
authentication_key: Vec<u8>,
withdrawal_capability: Option<WithdrawCapabilityResource>,
key_rotation_capability: Option<KeyRotationCapabilityResource>,
sent_events: EventHandle,
received_events: EventHandle,
) -> Self {
AccountResource {
authentication_key,
withdrawal_capability,
key_rotation_capability,
received_events,
sent_events,
sequence_number,
}
}
pub fn sequence_number(&self) -> u64 {
self.sequence_number
}
pub fn has_delegated_withdrawal_capability(&self) -> bool {
self.withdrawal_capability.is_none()
}
pub fn has_delegated_key_rotation_capability(&self) -> bool {
self.key_rotation_capability.is_none()
}
pub fn authentication_key(&self) -> &[u8] {
&self.authentication_key
}
pub fn sent_events(&self) -> &EventHandle {
&self.sent_events
}
pub fn received_events(&self) -> &EventHandle {
&self.received_events
}
}
impl MoveStructType for AccountResource {
const MODULE_NAME: &'static IdentStr = ACCOUNT_MODULE_IDENTIFIER;
const STRUCT_NAME: &'static IdentStr = ACCOUNT_MODULE_IDENTIFIER;
}
impl MoveResource for AccountResource {}