@@ -494,27 +494,29 @@ fn apply_impl<'info>(
494494 data. copy_from_slice ( component. try_borrow_data ( ) ?. as_ref ( ) ) ;
495495 }
496496
497- bolt_component:: cpi:: set_owner (
498- CpiContext :: new_with_signer (
499- program. to_account_info ( ) ,
500- bolt_component:: cpi:: accounts:: SetOwner {
497+ if component. owner != bolt_system. key {
498+ bolt_component:: cpi:: set_owner (
499+ CpiContext :: new_with_signer (
500+ program. to_account_info ( ) ,
501+ bolt_component:: cpi:: accounts:: SetOwner {
502+ cpi_auth : cpi_auth. to_account_info ( ) ,
503+ component : component. to_account_info ( ) ,
504+ } ,
505+ & [ World :: cpi_auth_seeds ( ) . as_slice ( ) ] ,
506+ ) ,
507+ * bolt_system. key ,
508+ ) ?;
509+
510+ bolt_system:: cpi:: set_data ( CpiContext :: new_with_signer (
511+ bolt_system. to_account_info ( ) ,
512+ bolt_system:: cpi:: accounts:: SetData {
501513 cpi_auth : cpi_auth. to_account_info ( ) ,
514+ buffer : buffer. to_account_info ( ) ,
502515 component : component. to_account_info ( ) ,
503516 } ,
504517 & [ World :: cpi_auth_seeds ( ) . as_slice ( ) ] ,
505- ) ,
506- * bolt_system. key ,
507- ) ?;
508-
509- bolt_system:: cpi:: set_data ( CpiContext :: new_with_signer (
510- bolt_system. to_account_info ( ) ,
511- bolt_system:: cpi:: accounts:: SetData {
512- cpi_auth : cpi_auth. to_account_info ( ) ,
513- buffer : buffer. to_account_info ( ) ,
514- component : component. to_account_info ( ) ,
515- } ,
516- & [ World :: cpi_auth_seeds ( ) . as_slice ( ) ] ,
517- ) ) ?;
518+ ) ) ?;
519+ }
518520 }
519521
520522 bolt_system:: cpi:: bolt_execute (
@@ -529,31 +531,33 @@ fn apply_impl<'info>(
529531 data. copy_from_slice ( component. try_borrow_data ( ) ?. as_ref ( ) ) ;
530532 }
531533
532- bolt_system:: cpi:: set_owner (
533- CpiContext :: new_with_signer (
534- bolt_system. to_account_info ( ) ,
535- bolt_system:: cpi:: accounts:: SetOwner {
534+ if * component. owner != program. key ( ) {
535+ bolt_system:: cpi:: set_owner (
536+ CpiContext :: new_with_signer (
537+ bolt_system. to_account_info ( ) ,
538+ bolt_system:: cpi:: accounts:: SetOwner {
539+ cpi_auth : cpi_auth. to_account_info ( ) ,
540+ component : component. to_account_info ( ) ,
541+ } ,
542+ & [ World :: cpi_auth_seeds ( ) . as_slice ( ) ] ,
543+ ) ,
544+ program. key ( ) ,
545+ ) ?;
546+
547+ if * component. owner != program. key ( ) {
548+ return Err ( WorldError :: InvalidComponentOwner . into ( ) ) ;
549+ }
550+
551+ bolt_component:: cpi:: set_data ( CpiContext :: new_with_signer (
552+ program. to_account_info ( ) ,
553+ bolt_component:: cpi:: accounts:: SetData {
536554 cpi_auth : cpi_auth. to_account_info ( ) ,
555+ buffer : buffer. to_account_info ( ) ,
537556 component : component. to_account_info ( ) ,
538557 } ,
539558 & [ World :: cpi_auth_seeds ( ) . as_slice ( ) ] ,
540- ) ,
541- program. key ( ) ,
542- ) ?;
543-
544- if * component. owner != program. key ( ) {
545- return Err ( WorldError :: InvalidComponentOwner . into ( ) ) ;
559+ ) ) ?;
546560 }
547-
548- bolt_component:: cpi:: set_data ( CpiContext :: new_with_signer (
549- program. to_account_info ( ) ,
550- bolt_component:: cpi:: accounts:: SetData {
551- cpi_auth : cpi_auth. to_account_info ( ) ,
552- buffer : buffer. to_account_info ( ) ,
553- component : component. to_account_info ( ) ,
554- } ,
555- & [ World :: cpi_auth_seeds ( ) . as_slice ( ) ] ,
556- ) ) ?;
557561 }
558562
559563 buffer. realloc ( 0 , false ) ?;
0 commit comments