From 679fa92a5645eaf2e0a81b7921f539f0b3b74afc Mon Sep 17 00:00:00 2001 From: Reisen Date: Fri, 30 Apr 2021 03:01:25 +0000 Subject: [PATCH] Move account related verification out of API handler Change-Id: Ice70ab8bfcf4018693f90cb5e47bea6cb9e46309 --- .../programs/anchor-bridge/src/api/verify_signatures.rs | 7 ------- solana/anchor-bridge/programs/anchor-bridge/src/lib.rs | 6 ++++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/solana/anchor-bridge/programs/anchor-bridge/src/api/verify_signatures.rs b/solana/anchor-bridge/programs/anchor-bridge/src/api/verify_signatures.rs index 5ef5c7feb..f1685c7a9 100644 --- a/solana/anchor-bridge/programs/anchor-bridge/src/api/verify_signatures.rs +++ b/solana/anchor-bridge/programs/anchor-bridge/src/api/verify_signatures.rs @@ -45,14 +45,7 @@ pub fn verify_signatures( initial_creation: bool, ) -> ProgramResult { let sig_infos = filter_empty_signatures(&signers); - - // We check this manually because the type-level checks are - // not available for Instructions yet. See the VerifySig - // struct for more info. let ix_acc = &ctx.accounts.instruction_sysvar; - if *ix_acc.key != solana_program::sysvar::instructions::id() { - return Err(ProgramError::Custom(42)); - } let current_ix_idx = solana_program::sysvar::instructions::load_current_index(&ix_acc.try_borrow_data()?); diff --git a/solana/anchor-bridge/programs/anchor-bridge/src/lib.rs b/solana/anchor-bridge/programs/anchor-bridge/src/lib.rs index 8ca668a19..2350ca57e 100644 --- a/solana/anchor-bridge/programs/anchor-bridge/src/lib.rs +++ b/solana/anchor-bridge/programs/anchor-bridge/src/lib.rs @@ -128,6 +128,12 @@ pub mod anchor_bridge { } pub fn verify_signatures(&mut self, ctx: Context, data: VerifySigsData) -> ProgramResult { + // We check this manually because the type-level checks are not available for + // Instructions yet. See the VerifySig struct for more info. + if *ctx.accounts.instruction_sysvar.key != solana_program::sysvar::instructions::id() { + return Err(ProgramError::Custom(42)); + } + api::verify_signatures( self, ctx,