From 7fcb45e702618f9486fd0ea3ddb1e1a0c8acc310 Mon Sep 17 00:00:00 2001 From: Armani Ferrante Date: Thu, 15 Apr 2021 08:41:18 +0800 Subject: [PATCH] lang: Impl Bump trait for associated accounts (#199) --- lang/attribute/account/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lang/attribute/account/src/lib.rs b/lang/attribute/account/src/lib.rs index f87805e2..c066c337 100644 --- a/lang/attribute/account/src/lib.rs +++ b/lang/attribute/account/src/lib.rs @@ -102,6 +102,7 @@ pub fn associated( input: proc_macro::TokenStream, ) -> proc_macro::TokenStream { let mut account_strct = parse_macro_input!(input as syn::ItemStruct); + let account_name = &account_strct.ident; // Add a `__nonce: u8` field to the struct to hold the bump seed for // the program dervied address. @@ -135,5 +136,11 @@ pub fn associated( #[anchor_lang::account] #[derive(Default)] #account_strct + + impl anchor_lang::Bump for #account_name { + fn seed(&self) -> u8 { + self.__nonce + } + } }) }