File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,10 +16,12 @@ incremented for features.
1616* cli: Specify test files to run ([ #118 ] ( https://github.com/project-serum/anchor/pull/118 ) ).
1717* lang: Allow overriding the ` #[state] ` account's size ([ #121 ] ( https://github.com/project-serum/anchor/pull/121 ) ).
1818* lang, client, ts: Add event emission and subscriptions ([ #89 ] ( https://github.com/project-serum/anchor/pull/89 ) ).
19+ * lang/account: Allow namespacing account discriminators ([ #128 ] ( https://github.com/project-serum/anchor/pull/128 ) ).
1920
2021## Breaking Changes
2122
2223* client: Replace url str with ` Cluster ` struct when constructing clients ([ #89 ] ( https://github.com/project-serum/anchor/pull/89 ) ).
24+ * lang: Changes the account discriminator of ` IdlAccount ` to be namespaced by ` "internal" ` ([ #128 ] ( https://github.com/project-serum/anchor/pull/128 ) ).
2325
2426## [ 0.3.0] - 2021-03-12
2527
Original file line number Diff line number Diff line change @@ -19,15 +19,24 @@ use syn::parse_macro_input;
1919/// and the account deserialization will exit with an error.
2020#[ proc_macro_attribute]
2121pub fn account (
22- _args : proc_macro:: TokenStream ,
22+ args : proc_macro:: TokenStream ,
2323 input : proc_macro:: TokenStream ,
2424) -> proc_macro:: TokenStream {
25+ let namespace = args. to_string ( ) . replace ( "\" " , "" ) ;
26+
2527 let account_strct = parse_macro_input ! ( input as syn:: ItemStruct ) ;
2628 let account_name = & account_strct. ident ;
2729
2830 let discriminator: proc_macro2:: TokenStream = {
2931 // Namespace the discriminator to prevent collisions.
30- let discriminator_preimage = format ! ( "account:{}" , account_name. to_string( ) ) ;
32+ let discriminator_preimage = {
33+ if namespace. is_empty ( ) {
34+ format ! ( "account:{}" , account_name. to_string( ) )
35+ } else {
36+ format ! ( "{}:{}" , namespace, account_name. to_string( ) )
37+ }
38+ } ;
39+
3140 let mut discriminator = [ 0u8 ; 8 ] ;
3241 discriminator. copy_from_slice (
3342 & anchor_syn:: hash:: hash ( discriminator_preimage. as_bytes ( ) ) . to_bytes ( ) [ ..8 ] ,
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ pub struct IdlSetBuffer<'info> {
8181//
8282// Note: we use the same account for the "write buffer", similar to the
8383// bpf upgradeable loader's mechanism.
84- #[ account]
84+ #[ account( "internal" ) ]
8585#[ derive( Debug ) ]
8686pub struct IdlAccount {
8787 // Address that can modify the IDL.
You can’t perform that action at this time.
0 commit comments