1- use crate :: c_oracle_header:: {
2- cmd_hdr,
3- command_t_e_cmd_add_mapping,
4- command_t_e_cmd_add_price,
5- command_t_e_cmd_add_product,
6- command_t_e_cmd_add_publisher,
7- command_t_e_cmd_agg_price,
8- command_t_e_cmd_del_price,
9- command_t_e_cmd_del_product,
10- command_t_e_cmd_del_publisher,
11- command_t_e_cmd_init_mapping,
12- command_t_e_cmd_init_price,
13- command_t_e_cmd_resize_price_account,
14- command_t_e_cmd_set_min_pub,
15- command_t_e_cmd_upd_price,
16- command_t_e_cmd_upd_price_no_fail_on_error,
17- command_t_e_cmd_upd_product,
18- PC_VERSION ,
19- } ;
20- use crate :: deserialize:: load;
211use crate :: error:: OracleError ;
2+ use crate :: instruction:: {
3+ load_command_header_checked,
4+ OracleCommand ,
5+ } ;
226use solana_program:: entrypoint:: ProgramResult ;
23- use solana_program:: program_error:: ProgramError ;
247use solana_program:: pubkey:: Pubkey ;
258use solana_program:: sysvar:: slot_history:: AccountInfo ;
269
@@ -47,37 +30,27 @@ pub fn process_instruction(
4730 accounts : & [ AccountInfo ] ,
4831 instruction_data : & [ u8 ] ,
4932) -> ProgramResult {
50- let cmd_data = load :: < cmd_hdr > ( instruction_data) ?;
51-
52- if cmd_data . ver_ != PC_VERSION {
53- return Err ( ProgramError :: InvalidArgument ) ;
54- }
55-
56- match cmd_data
57- . cmd_
58- . try_into ( )
59- . map_err ( |_| OracleError :: IntegerCastingError ) ?
60- {
61- command_t_e_cmd_upd_price | command_t_e_cmd_agg_price => {
62- upd_price ( program_id , accounts , instruction_data )
63- }
64- command_t_e_cmd_upd_price_no_fail_on_error => {
33+ match load_command_header_checked ( instruction_data) ? {
34+ OracleCommand :: InitMapping => init_mapping ( program_id , accounts , instruction_data ) ,
35+ OracleCommand :: AddMapping => add_mapping ( program_id , accounts , instruction_data ) ,
36+ OracleCommand :: AddProduct => add_product ( program_id , accounts , instruction_data ) ,
37+ OracleCommand :: UpdProduct => upd_product ( program_id , accounts , instruction_data ) ,
38+ OracleCommand :: AddPrice => add_price ( program_id , accounts , instruction_data ) ,
39+ OracleCommand :: AddPublisher => add_publisher ( program_id , accounts , instruction_data ) ,
40+ OracleCommand :: DelPublisher => del_publisher ( program_id , accounts , instruction_data ) ,
41+ OracleCommand :: UpdPrice => upd_price ( program_id , accounts , instruction_data ) ,
42+ OracleCommand :: AggPrice => upd_price ( program_id , accounts , instruction_data ) ,
43+ OracleCommand :: InitPrice => init_price ( program_id , accounts , instruction_data ) ,
44+ OracleCommand :: InitTest => Err ( OracleError :: UnrecognizedInstruction . into ( ) ) ,
45+ OracleCommand :: UpdTest => Err ( OracleError :: UnrecognizedInstruction . into ( ) ) ,
46+ OracleCommand :: SetMinPub => set_min_pub ( program_id , accounts , instruction_data ) ,
47+ OracleCommand :: UpdPriceNoFailOnError => {
6548 upd_price_no_fail_on_error ( program_id, accounts, instruction_data)
6649 }
67- command_t_e_cmd_resize_price_account => {
50+ OracleCommand :: ResizePriceAccount => {
6851 resize_price_account ( program_id, accounts, instruction_data)
6952 }
70- command_t_e_cmd_add_price => add_price ( program_id, accounts, instruction_data) ,
71- command_t_e_cmd_init_mapping => init_mapping ( program_id, accounts, instruction_data) ,
72- command_t_e_cmd_init_price => init_price ( program_id, accounts, instruction_data) ,
73- command_t_e_cmd_add_mapping => add_mapping ( program_id, accounts, instruction_data) ,
74- command_t_e_cmd_add_publisher => add_publisher ( program_id, accounts, instruction_data) ,
75- command_t_e_cmd_del_publisher => del_publisher ( program_id, accounts, instruction_data) ,
76- command_t_e_cmd_add_product => add_product ( program_id, accounts, instruction_data) ,
77- command_t_e_cmd_upd_product => upd_product ( program_id, accounts, instruction_data) ,
78- command_t_e_cmd_set_min_pub => set_min_pub ( program_id, accounts, instruction_data) ,
79- command_t_e_cmd_del_price => del_price ( program_id, accounts, instruction_data) ,
80- command_t_e_cmd_del_product => del_product ( program_id, accounts, instruction_data) ,
81- _ => Err ( OracleError :: UnrecognizedInstruction . into ( ) ) ,
53+ OracleCommand :: DelPrice => del_price ( program_id, accounts, instruction_data) ,
54+ OracleCommand :: DelProduct => del_product ( program_id, accounts, instruction_data) ,
8255 }
8356}
0 commit comments