فهرست منبع

Add account accessor

Armani Ferrante 4 سال پیش
والد
کامیت
056e33370b
2فایلهای تغییر یافته به همراه7 افزوده شده و 1 حذف شده
  1. 1 1
      examples/multisig/programs/multisig/src/lib.rs
  2. 6 0
      lang/src/program_account.rs

+ 1 - 1
examples/multisig/programs/multisig/src/lib.rs

@@ -72,7 +72,7 @@ pub mod multisig {
     pub fn set_owners(ctx: Context<Auth>, owners: Vec<Pubkey>) -> Result<()> {
         let multisig = &mut ctx.accounts.multisig;
 
-        if owners.len() as u64 > multisig.threshold {
+        if (owners.len() as u64) < multisig.threshold {
             multisig.threshold = owners.len() as u64;
         }
 

+ 6 - 0
lang/src/program_account.rs

@@ -16,6 +16,12 @@ pub struct ProgramAccount<'info, T: AccountSerialize + AccountDeserialize + Clon
     inner: Box<Inner<'info, T>>,
 }
 
+impl<'info, T: AccountSerialize + AccountDeserialize + Clone> ProgramAccount<'info, T> {
+    pub fn account(&self) -> &T {
+        &self.inner.account
+    }
+}
+
 #[derive(Clone)]
 struct Inner<'info, T: AccountSerialize + AccountDeserialize + Clone> {
     info: AccountInfo<'info>,