@@ -9,7 +9,7 @@ use bytemuck::{
9
9
} ;
10
10
use solana_program:: account_info:: AccountInfo ;
11
11
use solana_program:: clock:: Clock ;
12
- use solana_program:: entrypoint:: SUCCESS ;
12
+ use solana_program:: entrypoint:: ProgramResult ;
13
13
use solana_program:: program_error:: ProgramError ;
14
14
use solana_program:: program_memory:: {
15
15
sol_memcpy,
@@ -57,7 +57,6 @@ use crate::deserialize::{
57
57
load_account_as_mut,
58
58
load_checked,
59
59
} ;
60
- use crate :: error:: OracleResult ;
61
60
use crate :: OracleError ;
62
61
63
62
use crate :: utils:: {
@@ -113,7 +112,7 @@ pub fn resize_price_account(
113
112
program_id : & Pubkey ,
114
113
accounts : & [ AccountInfo ] ,
115
114
_instruction_data : & [ u8 ] ,
116
- ) -> OracleResult {
115
+ ) -> ProgramResult {
117
116
let [ funding_account_info, price_account_info, system_program] = match accounts {
118
117
[ x, y, z] => Ok ( [ x, y, z] ) ,
119
118
_ => Err ( ProgramError :: InvalidArgument ) ,
@@ -156,9 +155,9 @@ pub fn resize_price_account(
156
155
load_checked :: < PriceAccountWrapper > ( price_account_info, PC_VERSION ) ?;
157
156
//Initialize Time Machine
158
157
price_account. initialize_time_machine ( ) ?;
159
- Ok ( SUCCESS )
158
+ Ok ( ( ) )
160
159
}
161
- PRICE_ACCOUNT_SIZE => Ok ( SUCCESS ) ,
160
+ PRICE_ACCOUNT_SIZE => Ok ( ( ) ) ,
162
161
_ => Err ( ProgramError :: InvalidArgument ) ,
163
162
}
164
163
}
@@ -171,7 +170,7 @@ pub fn init_mapping(
171
170
program_id : & Pubkey ,
172
171
accounts : & [ AccountInfo ] ,
173
172
instruction_data : & [ u8 ] ,
174
- ) -> OracleResult {
173
+ ) -> ProgramResult {
175
174
let [ funding_account, fresh_mapping_account] = match accounts {
176
175
[ x, y] => Ok ( [ x, y] ) ,
177
176
_ => Err ( ProgramError :: InvalidArgument ) ,
@@ -189,14 +188,14 @@ pub fn init_mapping(
189
188
let hdr = load :: < cmd_hdr_t > ( instruction_data) ?;
190
189
initialize_pyth_account_checked :: < pc_map_table_t > ( fresh_mapping_account, hdr. ver_ ) ?;
191
190
192
- Ok ( SUCCESS )
191
+ Ok ( ( ) )
193
192
}
194
193
195
194
pub fn add_mapping (
196
195
program_id : & Pubkey ,
197
196
accounts : & [ AccountInfo ] ,
198
197
instruction_data : & [ u8 ] ,
199
- ) -> OracleResult {
198
+ ) -> ProgramResult {
200
199
let [ funding_account, cur_mapping, next_mapping] = match accounts {
201
200
[ x, y, z] => Ok ( [ x, y, z] ) ,
202
201
_ => Err ( ProgramError :: InvalidArgument ) ,
@@ -217,7 +216,7 @@ pub fn add_mapping(
217
216
initialize_pyth_account_checked :: < pc_map_table_t > ( next_mapping, hdr. ver_ ) ?;
218
217
pubkey_assign ( & mut cur_mapping. next_ , & next_mapping. key . to_bytes ( ) ) ;
219
218
220
- Ok ( SUCCESS )
219
+ Ok ( ( ) )
221
220
}
222
221
223
222
/// a publisher updates a price
@@ -228,7 +227,7 @@ pub fn upd_price(
228
227
program_id : & Pubkey ,
229
228
accounts : & [ AccountInfo ] ,
230
229
instruction_data : & [ u8 ] ,
231
- ) -> OracleResult {
230
+ ) -> ProgramResult {
232
231
let cmd_args = load :: < cmd_upd_price_t > ( instruction_data) ?;
233
232
234
233
let [ funding_account, price_account, clock_account] = match accounts {
@@ -316,16 +315,16 @@ pub fn upd_price(
316
315
}
317
316
}
318
317
319
- Ok ( SUCCESS )
318
+ Ok ( ( ) )
320
319
}
321
320
322
321
pub fn upd_price_no_fail_on_error (
323
322
program_id : & Pubkey ,
324
323
accounts : & [ AccountInfo ] ,
325
324
instruction_data : & [ u8 ] ,
326
- ) -> OracleResult {
325
+ ) -> ProgramResult {
327
326
match upd_price ( program_id, accounts, instruction_data) {
328
- Err ( _) => Ok ( SUCCESS ) ,
327
+ Err ( _) => Ok ( ( ) ) ,
329
328
Ok ( value) => Ok ( value) ,
330
329
}
331
330
}
@@ -339,7 +338,7 @@ pub fn add_price(
339
338
program_id : & Pubkey ,
340
339
accounts : & [ AccountInfo ] ,
341
340
instruction_data : & [ u8 ] ,
342
- ) -> OracleResult {
341
+ ) -> ProgramResult {
343
342
let cmd_args = load :: < cmd_add_price_t > ( instruction_data) ?;
344
343
345
344
check_exponent_range ( cmd_args. expo_ ) ?;
@@ -369,14 +368,14 @@ pub fn add_price(
369
368
pubkey_assign ( & mut price_data. next_ , bytes_of ( & product_data. px_acc_ ) ) ;
370
369
pubkey_assign ( & mut product_data. px_acc_ , & price_account. key . to_bytes ( ) ) ;
371
370
372
- Ok ( SUCCESS )
371
+ Ok ( ( ) )
373
372
}
374
373
375
374
pub fn init_price (
376
375
program_id : & Pubkey ,
377
376
accounts : & [ AccountInfo ] ,
378
377
instruction_data : & [ u8 ] ,
379
- ) -> OracleResult {
378
+ ) -> ProgramResult {
380
379
let cmd_args = load :: < cmd_init_price_t > ( instruction_data) ?;
381
380
382
381
check_exponent_range ( cmd_args. expo_ ) ?;
@@ -432,7 +431,7 @@ pub fn init_price(
432
431
) ;
433
432
}
434
433
435
- Ok ( SUCCESS )
434
+ Ok ( ( ) )
436
435
}
437
436
438
437
/// add a publisher to a price account
@@ -442,7 +441,7 @@ pub fn add_publisher(
442
441
program_id : & Pubkey ,
443
442
accounts : & [ AccountInfo ] ,
444
443
instruction_data : & [ u8 ] ,
445
- ) -> OracleResult {
444
+ ) -> ProgramResult {
446
445
let cmd_args = load :: < cmd_add_publisher_t > ( instruction_data) ?;
447
446
448
447
pyth_assert (
@@ -485,7 +484,7 @@ pub fn add_publisher(
485
484
price_data. size_ =
486
485
try_convert :: < _ , u32 > ( size_of :: < pc_price_t > ( ) - size_of_val ( & price_data. comp_ ) ) ?
487
486
+ price_data. num_ * try_convert :: < _ , u32 > ( size_of :: < pc_price_comp > ( ) ) ?;
488
- Ok ( SUCCESS )
487
+ Ok ( ( ) )
489
488
}
490
489
491
490
/// add a publisher to a price account
@@ -495,7 +494,7 @@ pub fn del_publisher(
495
494
program_id : & Pubkey ,
496
495
accounts : & [ AccountInfo ] ,
497
496
instruction_data : & [ u8 ] ,
498
- ) -> OracleResult {
497
+ ) -> ProgramResult {
499
498
let cmd_args = load :: < cmd_del_publisher_t > ( instruction_data) ?;
500
499
501
500
pyth_assert (
@@ -529,7 +528,7 @@ pub fn del_publisher(
529
528
price_data. size_ =
530
529
try_convert :: < _ , u32 > ( size_of :: < pc_price_t > ( ) - size_of_val ( & price_data. comp_ ) ) ?
531
530
+ price_data. num_ * try_convert :: < _ , u32 > ( size_of :: < pc_price_comp > ( ) ) ?;
532
- return Ok ( SUCCESS ) ;
531
+ return Ok ( ( ) ) ;
533
532
}
534
533
}
535
534
Err ( ProgramError :: InvalidArgument )
@@ -539,7 +538,7 @@ pub fn add_product(
539
538
program_id : & Pubkey ,
540
539
accounts : & [ AccountInfo ] ,
541
540
instruction_data : & [ u8 ] ,
542
- ) -> OracleResult {
541
+ ) -> ProgramResult {
543
542
let [ funding_account, tail_mapping_account, new_product_account] = match accounts {
544
543
[ x, y, z] => Ok ( [ x, y, z] ) ,
545
544
_ => Err ( ProgramError :: InvalidArgument ) ,
@@ -574,7 +573,7 @@ pub fn add_product(
574
573
try_convert :: < _ , u32 > ( size_of :: < pc_map_table_t > ( ) - size_of_val ( & mapping_data. prod_ ) ) ?
575
574
+ mapping_data. num_ * try_convert :: < _ , u32 > ( size_of :: < pc_pub_key_t > ( ) ) ?;
576
575
577
- Ok ( SUCCESS )
576
+ Ok ( ( ) )
578
577
}
579
578
580
579
/// Update the metadata associated with a product, overwriting any existing metadata.
@@ -583,7 +582,7 @@ pub fn upd_product(
583
582
program_id : & Pubkey ,
584
583
accounts : & [ AccountInfo ] ,
585
584
instruction_data : & [ u8 ] ,
586
- ) -> OracleResult {
585
+ ) -> ProgramResult {
587
586
let [ funding_account, product_account] = match accounts {
588
587
[ x, y] => Ok ( [ x, y] ) ,
589
588
_ => Err ( ProgramError :: InvalidArgument ) ,
@@ -634,14 +633,14 @@ pub fn upd_product(
634
633
let mut product_data = load_checked :: < pc_prod_t > ( product_account, hdr. ver_ ) ?;
635
634
product_data. size_ = try_convert ( size_of :: < pc_prod_t > ( ) + new_data. len ( ) ) ?;
636
635
637
- Ok ( SUCCESS )
636
+ Ok ( ( ) )
638
637
}
639
638
640
639
pub fn set_min_pub (
641
640
program_id : & Pubkey ,
642
641
accounts : & [ AccountInfo ] ,
643
642
instruction_data : & [ u8 ] ,
644
- ) -> OracleResult {
643
+ ) -> ProgramResult {
645
644
let cmd = load :: < cmd_set_min_pub_t > ( instruction_data) ?;
646
645
647
646
pyth_assert (
@@ -660,5 +659,5 @@ pub fn set_min_pub(
660
659
let mut price_account_data = load_checked :: < pc_price_t > ( price_account, cmd. ver_ ) ?;
661
660
price_account_data. min_pub_ = cmd. min_pub_ ;
662
661
663
- Ok ( SUCCESS )
662
+ Ok ( ( ) )
664
663
}
0 commit comments