carbon_player_profile_decoder/instructions/
mod.rs1use crate::PROGRAM_ID;
3use crate::PlayerProfileDecoder;
4
5pub mod accept_role_invitation;
6pub mod add_existing_member_to_role;
7pub mod add_keys;
8pub mod adjust_auth;
9pub mod create_profile;
10pub mod create_role;
11pub mod invite_member_to_role;
12pub mod join_role;
13pub mod leave_role;
14pub mod remove_keys;
15pub mod remove_member_from_role;
16pub mod remove_role;
17pub mod set_name;
18pub mod set_role_accepting_members;
19pub mod set_role_authorizer;
20pub mod set_role_name;
21pub mod set_role_not_accepting_members;
22
23pub use self::accept_role_invitation::*;
24pub use self::add_existing_member_to_role::*;
25pub use self::add_keys::*;
26pub use self::adjust_auth::*;
27pub use self::create_profile::*;
28pub use self::create_role::*;
29pub use self::invite_member_to_role::*;
30pub use self::join_role::*;
31pub use self::leave_role::*;
32pub use self::remove_keys::*;
33pub use self::remove_member_from_role::*;
34pub use self::remove_role::*;
35pub use self::set_name::*;
36pub use self::set_role_accepting_members::*;
37pub use self::set_role_authorizer::*;
38pub use self::set_role_name::*;
39pub use self::set_role_not_accepting_members::*;
40
41#[derive(Debug, Clone, PartialEq, Eq, Hash)]
42#[cfg_attr(
43 feature = "serde",
44 derive(carbon_core::InstructionType, serde::Serialize, serde::Deserialize)
45)]
46#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
47pub enum PlayerProfileInstruction {
48 AcceptRoleInvitation(AcceptRoleInvitation),
49 AddExistingMemberToRole(AddExistingMemberToRole),
50 AddKeys(AddKeys),
51 AdjustAuth(AdjustAuth),
52 CreateProfile(CreateProfile),
53 CreateRole(CreateRole),
54 InviteMemberToRole(InviteMemberToRole),
55 JoinRole(JoinRole),
56 LeaveRole(LeaveRole),
57 RemoveKeys(RemoveKeys),
58 RemoveMemberFromRole(RemoveMemberFromRole),
59 RemoveRole(RemoveRole),
60 SetName(SetName),
61 SetRoleAcceptingMembers(SetRoleAcceptingMembers),
62 SetRoleAuthorizer(SetRoleAuthorizer),
63 SetRoleName(SetRoleName),
64 SetRoleNotAcceptingMembers(SetRoleNotAcceptingMembers),
65}
66
67impl carbon_core::instruction::InstructionDecoder<'_> for PlayerProfileDecoder {
68 type InstructionType = PlayerProfileInstruction;
69
70 fn decode_instruction(
71 &self,
72 instruction: &solana_instruction::Instruction,
73 ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
74 if !instruction.program_id.eq(&PROGRAM_ID) {
75 return None;
76 }
77
78 let data = instruction.data.as_slice();
79
80 {
81 if let Some(decoded) = accept_role_invitation::AcceptRoleInvitation::decode(data) {
82 return Some(carbon_core::instruction::DecodedInstruction {
83 program_id: instruction.program_id,
84 data: PlayerProfileInstruction::AcceptRoleInvitation(decoded),
85 accounts: instruction.accounts.clone(),
86 });
87 }
88 }
89 {
90 if let Some(decoded) =
91 add_existing_member_to_role::AddExistingMemberToRole::decode(data)
92 {
93 return Some(carbon_core::instruction::DecodedInstruction {
94 program_id: instruction.program_id,
95 data: PlayerProfileInstruction::AddExistingMemberToRole(decoded),
96 accounts: instruction.accounts.clone(),
97 });
98 }
99 }
100 {
101 if let Some(decoded) = add_keys::AddKeys::decode(data) {
102 return Some(carbon_core::instruction::DecodedInstruction {
103 program_id: instruction.program_id,
104 data: PlayerProfileInstruction::AddKeys(decoded),
105 accounts: instruction.accounts.clone(),
106 });
107 }
108 }
109 {
110 if let Some(decoded) = adjust_auth::AdjustAuth::decode(data) {
111 return Some(carbon_core::instruction::DecodedInstruction {
112 program_id: instruction.program_id,
113 data: PlayerProfileInstruction::AdjustAuth(decoded),
114 accounts: instruction.accounts.clone(),
115 });
116 }
117 }
118 {
119 if let Some(decoded) = create_profile::CreateProfile::decode(data) {
120 return Some(carbon_core::instruction::DecodedInstruction {
121 program_id: instruction.program_id,
122 data: PlayerProfileInstruction::CreateProfile(decoded),
123 accounts: instruction.accounts.clone(),
124 });
125 }
126 }
127 {
128 if let Some(decoded) = create_role::CreateRole::decode(data) {
129 return Some(carbon_core::instruction::DecodedInstruction {
130 program_id: instruction.program_id,
131 data: PlayerProfileInstruction::CreateRole(decoded),
132 accounts: instruction.accounts.clone(),
133 });
134 }
135 }
136 {
137 if let Some(decoded) = invite_member_to_role::InviteMemberToRole::decode(data) {
138 return Some(carbon_core::instruction::DecodedInstruction {
139 program_id: instruction.program_id,
140 data: PlayerProfileInstruction::InviteMemberToRole(decoded),
141 accounts: instruction.accounts.clone(),
142 });
143 }
144 }
145 {
146 if let Some(decoded) = join_role::JoinRole::decode(data) {
147 return Some(carbon_core::instruction::DecodedInstruction {
148 program_id: instruction.program_id,
149 data: PlayerProfileInstruction::JoinRole(decoded),
150 accounts: instruction.accounts.clone(),
151 });
152 }
153 }
154 {
155 if let Some(decoded) = leave_role::LeaveRole::decode(data) {
156 return Some(carbon_core::instruction::DecodedInstruction {
157 program_id: instruction.program_id,
158 data: PlayerProfileInstruction::LeaveRole(decoded),
159 accounts: instruction.accounts.clone(),
160 });
161 }
162 }
163 {
164 if let Some(decoded) = remove_keys::RemoveKeys::decode(data) {
165 return Some(carbon_core::instruction::DecodedInstruction {
166 program_id: instruction.program_id,
167 data: PlayerProfileInstruction::RemoveKeys(decoded),
168 accounts: instruction.accounts.clone(),
169 });
170 }
171 }
172 {
173 if let Some(decoded) = remove_member_from_role::RemoveMemberFromRole::decode(data) {
174 return Some(carbon_core::instruction::DecodedInstruction {
175 program_id: instruction.program_id,
176 data: PlayerProfileInstruction::RemoveMemberFromRole(decoded),
177 accounts: instruction.accounts.clone(),
178 });
179 }
180 }
181 {
182 if let Some(decoded) = remove_role::RemoveRole::decode(data) {
183 return Some(carbon_core::instruction::DecodedInstruction {
184 program_id: instruction.program_id,
185 data: PlayerProfileInstruction::RemoveRole(decoded),
186 accounts: instruction.accounts.clone(),
187 });
188 }
189 }
190 {
191 if let Some(decoded) = set_name::SetName::decode(data) {
192 return Some(carbon_core::instruction::DecodedInstruction {
193 program_id: instruction.program_id,
194 data: PlayerProfileInstruction::SetName(decoded),
195 accounts: instruction.accounts.clone(),
196 });
197 }
198 }
199 {
200 if let Some(decoded) = set_role_accepting_members::SetRoleAcceptingMembers::decode(data)
201 {
202 return Some(carbon_core::instruction::DecodedInstruction {
203 program_id: instruction.program_id,
204 data: PlayerProfileInstruction::SetRoleAcceptingMembers(decoded),
205 accounts: instruction.accounts.clone(),
206 });
207 }
208 }
209 {
210 if let Some(decoded) = set_role_authorizer::SetRoleAuthorizer::decode(data) {
211 return Some(carbon_core::instruction::DecodedInstruction {
212 program_id: instruction.program_id,
213 data: PlayerProfileInstruction::SetRoleAuthorizer(decoded),
214 accounts: instruction.accounts.clone(),
215 });
216 }
217 }
218 {
219 if let Some(decoded) = set_role_name::SetRoleName::decode(data) {
220 return Some(carbon_core::instruction::DecodedInstruction {
221 program_id: instruction.program_id,
222 data: PlayerProfileInstruction::SetRoleName(decoded),
223 accounts: instruction.accounts.clone(),
224 });
225 }
226 }
227 {
228 if let Some(decoded) =
229 set_role_not_accepting_members::SetRoleNotAcceptingMembers::decode(data)
230 {
231 return Some(carbon_core::instruction::DecodedInstruction {
232 program_id: instruction.program_id,
233 data: PlayerProfileInstruction::SetRoleNotAcceptingMembers(decoded),
234 accounts: instruction.accounts.clone(),
235 });
236 }
237 }
238
239 None
240 }
241}