sns_records/instruction.rs
1pub use crate::processor::{
2 allocate_and_post_record, allocate_record, delete_record, edit_record, unverify_roa,
3 validate_ethereum_signature, validate_solana_signature, write_roa,
4};
5use {
6 bonfida_utils::InstructionsAccount,
7 borsh::{BorshDeserialize, BorshSerialize},
8 num_derive::FromPrimitive,
9 solana_program::{instruction::Instruction, pubkey::Pubkey},
10};
11#[allow(missing_docs)]
12#[derive(BorshDeserialize, BorshSerialize, FromPrimitive)]
13pub enum ProgramInstruction {
14 /// Allocate record account
15 ///
16 /// | Index | Writable | Signer | Description |
17 /// | ------------------------------------------------------------- |
18 /// | 0 | ❌ | ❌ | The system program account |
19 /// | 1 | ❌ | ❌ | The SPL token program account |
20 /// | 2 | ✅ | ✅ | The fee payer account |
21 /// | 3 | ✅ | ❌ | The record account to create |
22 /// | 4 | ✅ | ❌ | The domain name owning the record |
23 /// | 5 | ✅ | ✅ | The domain owner |
24 /// | 6 | ❌ | ❌ | The SNS Record central state |
25 AllocateRecord,
26 /// Allocate record account
27 ///
28 /// | Index | Writable | Signer | Description |
29 /// | ----------------------------------------------------------------- |
30 /// | 0 | ❌ | ❌ | The system program account |
31 /// | 1 | ❌ | ❌ | The SPL token program account |
32 /// | 2 | ✅ | ✅ | The fee payer account |
33 /// | 3 | ✅ | ❌ | The record account to create and post |
34 /// | 4 | ✅ | ❌ | The domain name owning the record |
35 /// | 5 | ✅ | ✅ | The domain owner |
36 /// | 6 | ❌ | ❌ | The SNS Record central state |
37 AllocateAndPostRecord,
38 /// Edit the record content
39 ///
40 /// | Index | Writable | Signer | Description |
41 /// | --------------------------------------------------------- |
42 /// | 0 | ❌ | ❌ | The system program account |
43 /// | 1 | ❌ | ❌ | The SPL token program account |
44 /// | 2 | ✅ | ✅ | The fee payer account |
45 /// | 3 | ✅ | ❌ | The record account to edit |
46 /// | 4 | ✅ | ❌ | |
47 /// | 5 | ✅ | ✅ | |
48 /// | 6 | ❌ | ❌ | |
49 EditRecord,
50 /// Validate a RoA or Staleness via Solana signature
51 ///
52 /// | Index | Writable | Signer | Description |
53 /// | ----------------------------------------------------------------- |
54 /// | 0 | ❌ | ❌ | The system program account |
55 /// | 1 | ❌ | ❌ | The SPL token program account |
56 /// | 2 | ✅ | ✅ | The fee payer account |
57 /// | 3 | ✅ | ❌ | The record account to create and post |
58 /// | 4 | ✅ | ❌ | The domain name owning the record |
59 /// | 5 | ✅ | ❌ | The domain owner |
60 /// | 6 | ❌ | ❌ | The SNS Record central state |
61 /// | 7 | ✅ | ✅ | The RoA/Staleness verifier public key |
62 ValidateSolanaSignature,
63 /// Validate and ETH signature
64 ///
65 /// | Index | Writable | Signer | Description |
66 /// | ----------------------------------------------------------------- |
67 /// | 0 | ❌ | ❌ | The system program account |
68 /// | 1 | ❌ | ❌ | The SPL token program account |
69 /// | 2 | ✅ | ✅ | The fee payer account |
70 /// | 3 | ✅ | ❌ | The record account to create and post |
71 /// | 4 | ✅ | ❌ | The domain name owning the record |
72 /// | 5 | ✅ | ✅ | The domain owner |
73 /// | 6 | ❌ | ❌ | The SNS Record central state |
74 ValidateEthereumSignature,
75 /// Delete a record account
76 ///
77 /// | Index | Writable | Signer | Description |
78 /// | ------------------------------------------------------------- |
79 /// | 0 | ❌ | ❌ | The system program account |
80 /// | 1 | ❌ | ❌ | The SPL token program account |
81 /// | 2 | ✅ | ✅ | The fee payer account |
82 /// | 3 | ✅ | ❌ | The record account to delete |
83 /// | 4 | ✅ | ❌ | The domain name owning the record |
84 /// | 5 | ✅ | ✅ | The domain owner |
85 /// | 6 | ❌ | ❌ | The SNS Record central state |
86 DeleteRecord,
87 /// Write a RoA in the record
88 ///
89 /// | Index | Writable | Signer | Description |
90 /// | ----------------------------------------------------------------- |
91 /// | 0 | ❌ | ❌ | The system program account |
92 /// | 1 | ❌ | ❌ | The SPL token program account |
93 /// | 2 | ✅ | ✅ | The fee payer account |
94 /// | 3 | ✅ | ❌ | The record account to create and post |
95 /// | 4 | ✅ | ❌ | The domain name owning the record |
96 /// | 5 | ✅ | ✅ | The domain owner |
97 /// | 6 | ❌ | ❌ | The SNS Record central state |
98 WriteRoa,
99 /// Unverify a RoA in the record
100 ///
101 /// | Index | Writable | Signer | Description |
102 /// | ----------------------------------------------------------------- |
103 /// | 0 | ❌ | ❌ | The system program account |
104 /// | 1 | ❌ | ❌ | The SPL token program account |
105 /// | 2 | ✅ | ✅ | The fee payer account |
106 /// | 3 | ✅ | ❌ | The record account to create and post |
107 /// | 4 | ✅ | ❌ | The domain name owning the record |
108 /// | 5 | ❌ | ❌ | The SNS Record central state |
109 /// | 6 | ✅ | ✅ | The current ROA verifier |
110 UnverifyRoa,
111}
112#[allow(missing_docs)]
113pub fn allocate_record(
114 accounts: allocate_record::Accounts<Pubkey>,
115 params: allocate_record::Params,
116) -> Instruction {
117 accounts.get_instruction(crate::ID, ProgramInstruction::AllocateRecord as u8, params)
118}
119#[allow(missing_docs)]
120pub fn allocate_and_post_record(
121 accounts: allocate_and_post_record::Accounts<Pubkey>,
122 params: allocate_and_post_record::Params,
123) -> Instruction {
124 accounts.get_instruction(
125 crate::ID,
126 ProgramInstruction::AllocateAndPostRecord as u8,
127 params,
128 )
129}
130pub fn edit_record(
131 accounts: edit_record::Accounts<Pubkey>,
132 params: edit_record::Params,
133) -> Instruction {
134 accounts.get_instruction(crate::ID, ProgramInstruction::EditRecord as u8, params)
135}
136pub fn validate_ethereum_signature(
137 accounts: validate_ethereum_signature::Accounts<Pubkey>,
138 params: validate_ethereum_signature::Params,
139) -> Instruction {
140 accounts.get_instruction(
141 crate::ID,
142 ProgramInstruction::ValidateEthereumSignature as u8,
143 params,
144 )
145}
146pub fn validate_solana_signature(
147 accounts: validate_solana_signature::Accounts<Pubkey>,
148 params: validate_solana_signature::Params,
149) -> Instruction {
150 accounts.get_instruction(
151 crate::ID,
152 ProgramInstruction::ValidateSolanaSignature as u8,
153 params,
154 )
155}
156pub fn delete_record(
157 accounts: delete_record::Accounts<Pubkey>,
158 params: delete_record::Params,
159) -> Instruction {
160 accounts.get_instruction(crate::ID, ProgramInstruction::DeleteRecord as u8, params)
161}
162pub fn write_roa(accounts: write_roa::Accounts<Pubkey>, params: write_roa::Params) -> Instruction {
163 accounts.get_instruction(crate::ID, ProgramInstruction::WriteRoa as u8, params)
164}
165pub fn unverify_roa(
166 accounts: unverify_roa::Accounts<Pubkey>,
167 params: unverify_roa::Params,
168) -> Instruction {
169 accounts.get_instruction(crate::ID, ProgramInstruction::UnverifyRoa as u8, params)
170}