@@ -9,7 +9,9 @@ impl<T: Discriminator, const P0: u128, const P1: u128> Discriminator for BoltAcc
99 const DISCRIMINATOR : & ' static [ u8 ] = T :: DISCRIMINATOR ;
1010}
1111
12- impl < T : anchor_lang:: AccountDeserialize , const P0 : u128 , const P1 : u128 > anchor_lang:: AccountDeserialize for BoltAccount < T , P0 , P1 > {
12+ impl < T : anchor_lang:: AccountDeserialize , const P0 : u128 , const P1 : u128 >
13+ anchor_lang:: AccountDeserialize for BoltAccount < T , P0 , P1 >
14+ {
1315 fn try_deserialize ( data : & mut & [ u8 ] ) -> Result < Self > {
1416 Ok ( BoltAccount ( T :: try_deserialize ( data) ?) )
1517 }
@@ -19,32 +21,47 @@ impl<T: anchor_lang::AccountDeserialize, const P0: u128, const P1: u128> anchor_
1921 }
2022}
2123
22- impl < T : anchor_lang:: AccountSerialize , const P0 : u128 , const P1 : u128 > anchor_lang:: AccountSerialize for BoltAccount < T , P0 , P1 > {
24+ impl < T : anchor_lang:: AccountSerialize , const P0 : u128 , const P1 : u128 > anchor_lang:: AccountSerialize
25+ for BoltAccount < T , P0 , P1 >
26+ {
2327 fn try_serialize < W : std:: io:: Write > ( & self , writer : & mut W ) -> Result < ( ) > {
2428 self . 0 . try_serialize ( writer)
2529 }
2630}
2731
28- impl < T : anchor_lang:: Owner , const P0 : u128 , const P1 : u128 > anchor_lang:: Owner for BoltAccount < T , P0 , P1 > {
32+ impl < T : anchor_lang:: Owner , const P0 : u128 , const P1 : u128 > anchor_lang:: Owner
33+ for BoltAccount < T , P0 , P1 >
34+ {
2935 fn owner ( ) -> Pubkey {
3036 pubkey_from_array ( [ P0 , P1 ] )
3137 }
3238}
3339
34- impl < ' info , T : anchor_lang:: ToAccountInfos < ' info > , const P0 : u128 , const P1 : u128 > anchor_lang:: ToAccountInfos < ' info > for BoltAccount < T , P0 , P1 > {
40+ impl < ' info , T : anchor_lang:: ToAccountInfos < ' info > , const P0 : u128 , const P1 : u128 >
41+ anchor_lang:: ToAccountInfos < ' info > for BoltAccount < T , P0 , P1 >
42+ {
3543 fn to_account_infos ( & self ) -> Vec < AccountInfo < ' info > > {
3644 self . 0 . to_account_infos ( )
3745 }
3846}
3947
40- impl < ' info , T : anchor_lang:: ToAccountMetas , const P0 : u128 , const P1 : u128 > anchor_lang:: ToAccountMetas for BoltAccount < T , P0 , P1 > {
48+ impl < T : anchor_lang:: ToAccountMetas , const P0 : u128 , const P1 : u128 > anchor_lang:: ToAccountMetas
49+ for BoltAccount < T , P0 , P1 >
50+ {
4151 fn to_account_metas ( & self , is_signer : Option < bool > ) -> Vec < AccountMeta > {
4252 self . 0 . to_account_metas ( is_signer)
4353 }
4454}
4555
46- impl < ' info , T : anchor_lang:: ToAccountInfos < ' info > + anchor_lang:: ToAccountInfo < ' info > + anchor_lang:: AccountSerialize + anchor_lang:: AccountsExit < ' info > , const P0 : u128 , const P1 : u128 > anchor_lang:: AccountsExit < ' info >
47- for BoltAccount < T , P0 , P1 >
56+ impl <
57+ ' info ,
58+ T : anchor_lang:: ToAccountInfos < ' info >
59+ + anchor_lang:: ToAccountInfo < ' info >
60+ + anchor_lang:: AccountSerialize
61+ + anchor_lang:: AccountsExit < ' info > ,
62+ const P0 : u128 ,
63+ const P1 : u128 ,
64+ > anchor_lang:: AccountsExit < ' info > for BoltAccount < T , P0 , P1 >
4865{
4966 fn exit ( & self , _program_id : & Pubkey ) -> Result < ( ) > {
5067 let info = self . 0 . to_account_info ( ) ;
@@ -56,7 +73,6 @@ impl<'info, T: anchor_lang::ToAccountInfos<'info> + anchor_lang::ToAccountInfo<'
5673 }
5774}
5875
59-
6076impl < T , const P0 : u128 , const P1 : u128 > std:: ops:: Deref for BoltAccount < T , P0 , P1 > {
6177 type Target = T ;
6278
@@ -72,11 +88,15 @@ impl<T, const P0: u128, const P1: u128> std::ops::DerefMut for BoltAccount<T, P0
7288}
7389
7490#[ cfg( feature = "idl-build" ) ]
75- impl < T : anchor_lang:: IdlBuild , const P0 : u128 , const P1 : u128 > anchor_lang:: IdlBuild for BoltAccount < T , P0 , P1 > {
91+ impl < T : anchor_lang:: IdlBuild , const P0 : u128 , const P1 : u128 > anchor_lang:: IdlBuild
92+ for BoltAccount < T , P0 , P1 >
93+ {
7694 fn create_type ( ) -> Option < anchor_lang:: idl:: types:: IdlTypeDef > {
7795 T :: create_type ( )
7896 }
79- fn insert_types ( types : & mut std:: collections:: BTreeMap < String , anchor_lang:: idl:: types:: IdlTypeDef > ) {
97+ fn insert_types (
98+ types : & mut std:: collections:: BTreeMap < String , anchor_lang:: idl:: types:: IdlTypeDef > ,
99+ ) {
80100 T :: insert_types ( types) ;
81101 }
82102 fn get_full_path ( ) -> String {
@@ -87,20 +107,16 @@ impl<T: anchor_lang::IdlBuild, const P0: u128, const P1: u128> anchor_lang::IdlB
87107pub const fn pubkey_p0 ( key : Pubkey ) -> u128 {
88108 let bytes = key. to_bytes ( ) ;
89109 u128:: from_le_bytes ( [
90- bytes[ 0 ] , bytes[ 1 ] , bytes[ 2 ] , bytes[ 3 ] ,
91- bytes[ 4 ] , bytes[ 5 ] , bytes[ 6 ] , bytes[ 7 ] ,
92- bytes[ 8 ] , bytes[ 9 ] , bytes[ 10 ] , bytes[ 11 ] ,
93- bytes[ 12 ] , bytes[ 13 ] , bytes[ 14 ] , bytes[ 15 ] ,
110+ bytes[ 0 ] , bytes[ 1 ] , bytes[ 2 ] , bytes[ 3 ] , bytes[ 4 ] , bytes[ 5 ] , bytes[ 6 ] , bytes[ 7 ] , bytes[ 8 ] ,
111+ bytes[ 9 ] , bytes[ 10 ] , bytes[ 11 ] , bytes[ 12 ] , bytes[ 13 ] , bytes[ 14 ] , bytes[ 15 ] ,
94112 ] )
95113}
96114
97115pub const fn pubkey_p1 ( key : Pubkey ) -> u128 {
98116 let bytes = key. to_bytes ( ) ;
99117 u128:: from_le_bytes ( [
100- bytes[ 16 ] , bytes[ 17 ] , bytes[ 18 ] , bytes[ 19 ] ,
101- bytes[ 20 ] , bytes[ 21 ] , bytes[ 22 ] , bytes[ 23 ] ,
102- bytes[ 24 ] , bytes[ 25 ] , bytes[ 26 ] , bytes[ 27 ] ,
103- bytes[ 28 ] , bytes[ 29 ] , bytes[ 30 ] , bytes[ 31 ] ,
118+ bytes[ 16 ] , bytes[ 17 ] , bytes[ 18 ] , bytes[ 19 ] , bytes[ 20 ] , bytes[ 21 ] , bytes[ 22 ] , bytes[ 23 ] ,
119+ bytes[ 24 ] , bytes[ 25 ] , bytes[ 26 ] , bytes[ 27 ] , bytes[ 28 ] , bytes[ 29 ] , bytes[ 30 ] , bytes[ 31 ] ,
104120 ] )
105121}
106122
@@ -111,5 +127,9 @@ pub const fn pubkey_from_u128s(p0: u128, p1: u128) -> Pubkey {
111127pub const fn pubkey_from_array ( array : [ u128 ; 2 ] ) -> Pubkey {
112128 let p0 = array[ 0 ] . to_le_bytes ( ) ;
113129 let p1 = array[ 1 ] . to_le_bytes ( ) ;
114- Pubkey :: new_from_array ( [ p0[ 0 ] , p0[ 1 ] , p0[ 2 ] , p0[ 3 ] , p0[ 4 ] , p0[ 5 ] , p0[ 6 ] , p0[ 7 ] , p0[ 8 ] , p0[ 9 ] , p0[ 10 ] , p0[ 11 ] , p0[ 12 ] , p0[ 13 ] , p0[ 14 ] , p0[ 15 ] , p1[ 0 ] , p1[ 1 ] , p1[ 2 ] , p1[ 3 ] , p1[ 4 ] , p1[ 5 ] , p1[ 6 ] , p1[ 7 ] , p1[ 8 ] , p1[ 9 ] , p1[ 10 ] , p1[ 11 ] , p1[ 12 ] , p1[ 13 ] , p1[ 14 ] , p1[ 15 ] ] )
130+ Pubkey :: new_from_array ( [
131+ p0[ 0 ] , p0[ 1 ] , p0[ 2 ] , p0[ 3 ] , p0[ 4 ] , p0[ 5 ] , p0[ 6 ] , p0[ 7 ] , p0[ 8 ] , p0[ 9 ] , p0[ 10 ] , p0[ 11 ] ,
132+ p0[ 12 ] , p0[ 13 ] , p0[ 14 ] , p0[ 15 ] , p1[ 0 ] , p1[ 1 ] , p1[ 2 ] , p1[ 3 ] , p1[ 4 ] , p1[ 5 ] , p1[ 6 ] , p1[ 7 ] ,
133+ p1[ 8 ] , p1[ 9 ] , p1[ 10 ] , p1[ 11 ] , p1[ 12 ] , p1[ 13 ] , p1[ 14 ] , p1[ 15 ] ,
134+ ] )
115135}
0 commit comments