// Executes the given transaction if threshold owners have signed it.
Executes the given transaction if threshold owners have signed it.
Executes the given transaction if threshold owners have signed it .
pub fn execute_transaction(ctx: Context<ExecuteTransaction>) -> Result<()> {
        // Has this been executed already?
        if ctx.accounts.transaction.did_execute {
            return Err(ErrorCode::AlreadyExecuted.into());
        }
        // Do we have enough signers?
        let sig_count = ctx
            .accounts
            .transaction
            .signers
            .iter()
            .filter_map(|s| match s {
                false => None,
                true => Some(true),
            })
            .collect::<Vec<_>>()
            .len() as u64;
        if sig_count < ctx.accounts.multisig.threshold {
            return Err(ErrorCode::NotEnoughSigners.into());
        }
        // Execute the transaction signed by the multisig.
        let mut ix: Instruction = (&*ctx.accounts.transaction).into();
        ix.accounts = ix
            .accounts
            .iter()
            .map(|acc| {
                if &acc.pubkey == ctx.accounts.multisig_signer.key {
                    AccountMeta::new_readonly(acc.pubkey, true)
                } else {
                    acc.clone()
                }
            })
            .collect();
        let seeds = &[
            ctx.accounts.multisig.to_account_info().key.as_ref(),
            &[ctx.accounts.multisig.nonce],
        ];
        let signer = &[&seeds[..]];
        let accounts = ctx.remaining_accounts;
        solana_program::program::invoke_signed(&ix, &accounts, signer)?;
        // Burn the transaction to ensure one time use.
        ctx.accounts.transaction.did_execute = true;
        Ok(())
    }
pub fn execute_transaction ( ctx : Context < ExecuteTransaction > ) -> Result < ( ) > { // Has this been executed already? if ctx . accounts . transaction . did_execute { return Err ( ErrorCode :: AlreadyExecuted . into ( ) ) ; } // Do we have enough signers? let sig_count = ctx . accounts . transaction . signers . iter ( ) . filter_map ( | s | match s { false => None , true => Some ( true ) , } ) . collect :: < Vec < _ > > ( ) . len ( ) as u64 ; if sig_count < ctx . accounts . multisig . threshold { return Err ( ErrorCode :: NotEnoughSigners . into ( ) ) ; } // Execute the transaction signed by the multisig. let mut ix : Instruction = ( & * ctx . accounts . transaction ) . into ( ) ; ix . accounts = ix . accounts . iter ( ) . map ( | acc | { if & acc . pubkey == ctx . accounts . multisig_signer . key { AccountMeta :: new_readonly ( acc . pubkey , true ) } else { acc . clone ( ) } } ) . collect ( ) ; let seeds = & [ ctx . accounts . multisig . to_account_info ( ) . key . as_ref ( ) , & [ ctx . accounts . multisig . nonce ] , ] ; let signer = & [ & seeds [ .. ] ] ; let accounts = ctx . remaining_accounts ; solana_program :: program :: invoke_signed ( & ix , & accounts , signer ) ? ; // Burn the transaction to ensure one time use. ctx . accounts . transaction . did_execute = true ; Ok ( ( ) ) }
Executes the given transaction if threshold owners have signed it.
Executes the given transaction if threshold owners have signed it .
ctx
Context<ExecuteTransaction>