diff --git a/runtime/src/bank/address_lookup_table.rs b/runtime/src/bank/address_lookup_table.rs index 483ec7cea00ea1..51eee794803e14 100644 --- a/runtime/src/bank/address_lookup_table.rs +++ b/runtime/src/bank/address_lookup_table.rs @@ -10,6 +10,17 @@ use { }, }; +fn into_address_loader_error(err: AddressLookupError) -> AddressLoaderError { + match err { + AddressLookupError::LookupTableAccountNotFound => { + AddressLoaderError::LookupTableAccountNotFound + } + AddressLookupError::InvalidAccountOwner => AddressLoaderError::InvalidAccountOwner, + AddressLookupError::InvalidAccountData => AddressLoaderError::InvalidAccountData, + AddressLookupError::InvalidLookupIndex => AddressLoaderError::InvalidLookupIndex, + } +} + impl AddressLoader for &Bank { fn load_addresses( self, @@ -23,15 +34,18 @@ impl AddressLoader for &Bank { .get_slot_hashes() .map_err(|_| AddressLoaderError::SlotHashesSysvarNotFound)?; - Ok(address_table_lookups + address_table_lookups .iter() .map(|address_table_lookup| { - self.rc.accounts.load_lookup_table_addresses( - &self.ancestors, - address_table_lookup, - &slot_hashes, - ) + self.rc + .accounts + .load_lookup_table_addresses( + &self.ancestors, + address_table_lookup, + &slot_hashes, + ) + .map_err(into_address_loader_error) }) - .collect::>()?) + .collect::>() } } diff --git a/sdk/program/src/address_lookup_table/error.rs b/sdk/program/src/address_lookup_table/error.rs index b427067afc386c..9925dee4dbbf4c 100644 --- a/sdk/program/src/address_lookup_table/error.rs +++ b/sdk/program/src/address_lookup_table/error.rs @@ -1,5 +1,3 @@ -#[cfg(not(target_os = "solana"))] -use solana_program::message::AddressLoaderError; use thiserror::Error; #[derive(Debug, Error, PartialEq, Eq, Clone)] @@ -20,15 +18,3 @@ pub enum AddressLookupError { #[error("Address lookup contains an invalid index")] InvalidLookupIndex, } - -#[cfg(not(target_os = "solana"))] -impl From for AddressLoaderError { - fn from(err: AddressLookupError) -> Self { - match err { - AddressLookupError::LookupTableAccountNotFound => Self::LookupTableAccountNotFound, - AddressLookupError::InvalidAccountOwner => Self::InvalidAccountOwner, - AddressLookupError::InvalidAccountData => Self::InvalidAccountData, - AddressLookupError::InvalidLookupIndex => Self::InvalidLookupIndex, - } - } -}